Skip to content

Commit 2604cff

Browse files
committed
Some fixes + WIP CheckBox + TextField + ImageButton
1 parent 73b6ff8 commit 2604cff

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

src/main/resources/forge-1.12.2/templates/gui/gui_window.java.ftl

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,10 @@ public class ${name}Screen extends GuiContainer implements ${JavaModName}Screens
142142
<#if hasProcedure(component.text)>
143143
String hoverText = <@procedureOBJToStringCode component.text/>;
144144
if (hoverText != null) {
145-
this.renderTooltip(Arrays.stream(hoverText.split("\n")).collect(Collectors.toList()), mouseX, mouseY);
145+
this.drawHoveringText(Arrays.stream(hoverText.split("\n")).collect(Collectors.toList()), mouseX, mouseY);
146146
}
147147
<#else>
148-
this.renderTooltip(new TextComponentTranslation("gui.${modid}.${registryname}.${component.getName()}").getFormattedText(), mouseX, mouseY);
148+
this.drawHoveringText(new TextComponentTranslation("gui.${modid}.${registryname}.${component.getName()}").getFormattedText(), mouseX, mouseY);
149149
</#if>
150150
customTooltipShown = true;
151151
}
@@ -239,7 +239,10 @@ public class ${name}Screen extends GuiContainer implements ${JavaModName}Screens
239239

240240
<#list textFields as component>
241241
${component.getName()} = new GuiTextField(${component_index}, this.fontRenderer, this.guiLeft + ${component.gx(data.width) + 1}, this.guiTop + ${component.gy(data.height) + 1},
242-
${component.width - 2}, ${component.height - 2}, new TextComponentTranslation("gui.${modid}.${registryname}.${component.getName()}").getFormattedText());
242+
${component.width - 2}, ${component.height - 2})<#if component.placeholder?has_content> {
243+
@Override ${mcc.getMethod("net.minecraft.client.gui.GuiTextField", "drawTextBox")
244+
.replace("if (flag1)", "if (!flag2) this.fontRenderer.drawStringWithShadow(new TextComponentTranslation(\"gui." + modid + "." + registryname + "." + component.getName() + "\").getFormattedText(), (float)(k1 - 1), (float)i1, -8355712); if (flag1)")}
245+
}</#if>;
243246
${component.getName()}.setMaxStringLength(8192);
244247
${component.getName()}.setGuiResponder(new GuiPageButtonList.GuiResponder() {
245248

@@ -254,11 +257,6 @@ public class ${name}Screen extends GuiContainer implements ${JavaModName}Screens
254257
@Override public void setEntryValue(int id, float content) {
255258
}
256259
});
257-
<#if component.placeholder?has_content>
258-
${component.getName()}.setText(new TextComponentTranslation("gui.${modid}.${registryname}.${component.getName()}").getFormattedText());
259-
</#if>
260-
261-
this.labelList.add(this.${component.getName()});
262260
</#list>
263261

264262
<#assign btid = 0>
@@ -288,12 +286,12 @@ public class ${name}Screen extends GuiContainer implements ${JavaModName}Screens
288286
this.guiLeft + ${component.gx(data.width)}, this.guiTop + ${component.gy(data.height)},
289287
${component.getWidth(w.getWorkspace())}, ${component.getHeight(w.getWorkspace())},
290288
0, 0, ${component.getHeight(w.getWorkspace())},
291-
new ResourceLocation("${modid}:textures/screens/atlas/${component.getName()}.png"),
292-
${component.getWidth(w.getWorkspace())},
293-
${component.getHeight(w.getWorkspace()) * 2})
294-
<#if hasProcedure(component.onClick)>{
295-
<@buttonOnClick component/>
296-
}</#if>;
289+
new ResourceLocation("${modid}:textures/screens/atlas/${component.getName()}.png")) {<#if hasProcedure(component.onClick)>
290+
<@buttonOnClick component/></#if>
291+
292+
@Override ${mcc.getMethod("net.minecraft.client.gui.GuiButtonImage", "drawButton", "Minecraft", "int", "int", "float")
293+
.replace("drawTexturedModalRect(this.x, this.y, i, j, this.width, this.height)", "drawModalRectWithCustomSizedTexture(this.x, this.y, i, j, this.width, this.height," + component.getWidth(w.getWorkspace()) + ", " + (component.getHeight(w.getWorkspace()) * 2) + ")")}
294+
};
297295

298296
this.addButton(${component.getName()});
299297

0 commit comments

Comments
 (0)