Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add texture name on railroad sign gui #442

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/main/java/jp/ngt/rtm/gui/GuiButtonSelectTexture.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,39 @@ public void drawButton(Minecraft mc, int par2, int par3) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.getTextureManager().bindTexture(this.property.getTexture());
this.draw();

// Draw texture name
int textureYPosition = this.yPosition + this.height + 16;
String textureName = property.displayName;
int stringWidth = mc.fontRenderer.getStringWidth(textureName);
int charWidth = mc.fontRenderer.getCharWidth('A');

if (stringWidth > this.width) {
StringBuilder newTextureNameBuilder = new StringBuilder();
int currentWidth = 0;

for (int i = 0; i < textureName.length(); i++) {
char c = textureName.charAt(i);

currentWidth += charWidth;

if (currentWidth > width) {
newTextureNameBuilder.append("\n");
currentWidth = charWidth;
}

newTextureNameBuilder.append(c);
}

textureName = newTextureNameBuilder.toString();
}

String[] splittedText = textureName.split("\n");

for (int i = 0; i < splittedText.length; i++) {
mc.fontRenderer.drawString(splittedText[i], this.xPosition, textureYPosition + (mc.fontRenderer.FONT_HEIGHT * i), 16777215);
}

/*int k = this.getHoverState(this.field_146123_n);
if(k == 2)
{
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/jp/ngt/rtm/gui/GuiSelectTexture.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class GuiSelectTexture extends GuiScreenCustom {
private int currentScroll;
private int prevScroll;
private int uCount, vCount;
private final int SPACING_TEXT_Y = 64;

public GuiSelectTexture(ITextureHolder par1) {
this.holder = par1;
Expand Down Expand Up @@ -57,7 +58,7 @@ public void initGui() {
int w = (int) (prop.width * f0);
int h = (int) (prop.height * f0);
int xPos = x * u + ((x - w) / 2) + offsetX;
int yPos = y * v + ((y - h) / 2);
int yPos = (y * v + (v * this.SPACING_TEXT_Y)) + ((y - h) / 2);
this.buttonList.add(new GuiButtonSelectTexture(index, xPos, yPos, w, h, prop));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ public abstract class TextureProperty {

protected ResourceLocation resource;

public String displayName;

protected void init() {
if (this.texture != null) {
this.displayName = this.texture.replace("textures/signboard/", "").replace(".png", "");
}
}

public ResourceLocation getTexture() {
Expand Down
Loading