适合谁使用?
本库主要用于我的模组中,以简化用户界面(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 之前的版本将不予考虑
你是这个资源的作者?登录后可认领此资源。
相似资源
一个用于收集生物掉落物的多区块模组。
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
查看物品与配方
使用 JavaScript 编辑配方、添加自定义物品、编写世界事件!
适用于 MC 1.18+ 的 Effekseer 加载器
那是什么?一个 Waila/Hwyla 的分支。
评论 0
登录后参与评分
还没有评论,来抢沙发吧