Spis Ui Api

模组

· 作者 spidrone

一个模组库,添加了易于使用的 UI 元素,如自定义字体或动画纹理

0 本站下载 0 关注 更新于 1 个月前

最新 1.7.0 · 1.21.1 · NeoForge

一键开服(送7天)

适合谁使用?

本库主要用于我的模组中,以简化用户界面(UI)/图形用户界面(GUI)的开发流程。 不过,任何人都可以将此模组作为依赖项来使用其功能。

为何使用它?

目前该模组提供以下功能; 一套新的 drawStrings() 方法,支持轻松访问自定义字体,以及为自定义边界框添加自动换行功能,并允许设置左对齐/居中/右对齐。

如何使用?

Github Wiki
导入语句

import net.spidrone.uiapi.UIAnimationManager;  
import net.spidrone.uiapi.UIGraphicsHelper;  

动画图形

UIAnimationManager.drawGif(GuiGraphics graphics, String imagePath, int x, int y, int frameWidth, int frameHeight, int totalFrames, int fps, float scaleX, float scaleY, float red, float green, float blue)

自定义 drawString()

UIGraphicsHelper.drawCustomFont(GuiGraphics graphics, ResourceLocation fontLocation, String message, int x, int y, int color, boolean dropShadow, TextAlign align)

带边界框/自动换行/断行的自定义 drawString()

UIGraphicsHelper.drawCustomFontBound(GuiGraphics graphics, ResourceLocation fontLocation, String message, char splitChar, int x1, int y1, int x2, int y2, int color, boolean dropShadow, TextAlign align)

如果不包含类似 fontLocation 的参数,将使用默认字体 align : LEFT/CENTER/RIGHT

若指定 splitChar "$",则 hi$world 将在你的 UI 中显示为:

hi
world

通过将 TTF 字体文件放置在你的资源文件夹中来注册字体 assets/modid/font 在同一文件夹中包含一个 .json 文件

{
  "providers": [
    {
      "type": "ttf",
      "file": "spis_ui_api:boldpixels.ttf",
      "shift": [0.0, 0.0],
      "size": 16.0,
      "oversample": 2.0
    }
  ]
}

在 UI 中声明字体的资源位置

public static final ResourceLocation BOLD_PIXELS_FONT = ResourceLocation.fromNamespaceAndPath("spis_ui_api", "boldpixels");

致谢

Bold Pixels :
这款字体非常适合 Minecraft

附加内容

问:你支持 X 版本吗
答:本库主要供我用于自己的项目。如果你想请求某个版本的兼容性,可以加入 Discord 服务器,但 1.21.1 之前的版本将不予考虑

你是这个资源的作者?登录后可认领此资源。

评论 0

0.0
暂无评分
5 星
0
4 星
0
3 星
0
2 星
0
1 星
0
我的评分

登录后参与评分

还没有评论,来抢沙发吧

评论配图

相似资源