ICustomBackground

基本信息

属性 值
全限定名 betterachievements.api.components.page.ICustomBackground
类型 接口(AchievementPage 自定义背景)
源文件 src/main/java/betterachievements/api/components/page/ICustomBackground.java

功能

由 AchievementPage 实现,让第三方 mod 把自己的背景绘制注入到 GuiBetterAchievements。调用前 GuiBetterAchievements 已 GL11.glTranslatef(left, top + borderWidthY, -200.0F),且已经关闭 lighting、开启 COLOR_MATERIAL —— 实现方需自行处理缩放与纹理绑定。

方法签名

void drawBackground(int left, int top, int width, int height, float z, float scale);
参数 含义
left GUI 左上角 X(GuiBetterAchievements.left)
top GUI 左上角 Y(GuiBetterAchievements.top)
width 内容区宽度 = innerWidth + borderWidthX(228 + 8 = 236)
height 内容区高度 = innerHeight + borderWidthY(158 + 17 = 175)
z 当前 zLevel
scale 当前缩放因子(默认 1.0F ~ 2.0F)

调用点

GuiBetterAchievements.drawAchievementsBackground(page):

if (page instanceof ICustomBackground) {
    GL11.glPushMatrix();
    ((ICustomBackground) page).drawBackground(
        this.left, this.top,
        innerWidth + borderWidthX, innerHeight + borderWidthY,
        this.zLevel, this.scale);
    GL11.glPopMatrix();
}

否则进入默认的伪地形方块背景生成(drawAchievementsBackground else 分支)。

使用注意

注释原文:NOTE: You need to do your own scaling. 调用方已经 glPushMatrix 后调用,由实现方决定是否再 glScalef。

相关条目