TrayComponent: Add colors
This commit is contained in:
parent
5a738d2e10
commit
0bcf09aef4
|
@ -21,7 +21,6 @@ public class ColorComponent extends TextComponent {
|
|||
|
||||
private final Texture gearTexture;
|
||||
private final Texture gearTextureEnabled;
|
||||
private final Texture checkTexture;
|
||||
|
||||
public ColorComponent(String name, int defaultColor) {
|
||||
super(name, String.valueOf(defaultColor), false);
|
||||
|
@ -29,7 +28,6 @@ public class ColorComponent extends TextComponent {
|
|||
this.displayValue = "#" + Integer.toHexString(this.currentColor.getRGB()).toLowerCase().substring(2);
|
||||
this.gearTexture = new Texture("gear_wheel.png");
|
||||
this.gearTextureEnabled = new Texture("gear_wheel-enabled.png");
|
||||
this.checkTexture = new Texture("check.png");
|
||||
|
||||
this.setH(9);
|
||||
}
|
||||
|
@ -77,10 +75,12 @@ public class ColorComponent extends TextComponent {
|
|||
RenderUtil.drawRect(blockX, blockY, blockX + blockWidth, blockY + blockHeight, 0xFFFFFFFF);
|
||||
|
||||
// draw gear
|
||||
RenderUtil.drawRect(this.getX() + this.getW() - 10, this.getY(), this.getX() + this.getW(), this.getY() + this.getH(), 0xFF101010);
|
||||
this.gearTextureEnabled.bind();
|
||||
this.gearTextureEnabled.render(this.getX() + this.getW() - 9, this.getY() + 0.5f, 8, 8);
|
||||
|
||||
// check
|
||||
RenderUtil.drawRect(this.getX() + this.getW() - 20, this.getY(), this.getX() + this.getW() - 10, this.getY() + this.getH(), 0xFF101010);
|
||||
this.checkTexture.bind();
|
||||
this.checkTexture.render(this.getX() + this.getW() - 19, this.getY() + 0.5f, 8, 8);
|
||||
|
||||
|
@ -107,15 +107,13 @@ public class ColorComponent extends TextComponent {
|
|||
public void mouseRelease(int mouseX, int mouseY, int button) {
|
||||
super.mouseRelease(mouseX, mouseY, button);
|
||||
|
||||
if (!this.focused || !this.isMouseInside(mouseX, mouseY)) // must be focused & inside
|
||||
if (!this.focused) // must be focused
|
||||
return;
|
||||
|
||||
if (this.isMouseInside(mouseX, mouseY)) {
|
||||
if (button == 0) {
|
||||
// check for clicking check
|
||||
if (mouseX >= this.getX() + this.getW() - 20 && mouseX <= this.getX() + this.getW() - 10 && mouseY >= this.getY() && mouseY <= this.getY() + this.getH()) {
|
||||
this.enterPressed();
|
||||
}
|
||||
if (button == 0) {
|
||||
// check for clicking check
|
||||
if (mouseX >= this.getX() + this.getW() - 20 && mouseX <= this.getX() + this.getW() - 10 && mouseY >= this.getY() && mouseY <= this.getY() + this.getH()) {
|
||||
this.enterPressed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package me.rigamortis.seppuku.api.gui.hud.component;
|
||||
|
||||
import me.rigamortis.seppuku.api.texture.Texture;
|
||||
import me.rigamortis.seppuku.api.util.RenderUtil;
|
||||
import me.rigamortis.seppuku.api.util.Timer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
@ -16,6 +17,8 @@ public class TextComponent extends HudComponent {
|
|||
public ComponentListener returnListener;
|
||||
public TextComponentListener textListener;
|
||||
|
||||
protected Texture checkTexture;
|
||||
|
||||
protected Timer backspaceTimer = new Timer(), backspaceWaitTimer = new Timer();
|
||||
protected boolean doBackspacing = false;
|
||||
|
||||
|
@ -25,6 +28,8 @@ public class TextComponent extends HudComponent {
|
|||
this.displayValue = displayValue;
|
||||
this.focused = false;
|
||||
this.digitOnly = digitOnly;
|
||||
|
||||
this.checkTexture = new Texture("check.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -44,6 +49,11 @@ public class TextComponent extends HudComponent {
|
|||
int blockHeight = Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 2;
|
||||
RenderUtil.drawRect(blockX, blockY, blockX + blockWidth, blockY + blockHeight, 0xFFFFFFFF);
|
||||
|
||||
// check
|
||||
RenderUtil.drawRect(this.getX() + this.getW() - 10, this.getY(), this.getX() + this.getW(), this.getY() + this.getH(), 0xFF101010);
|
||||
this.checkTexture.bind();
|
||||
this.checkTexture.render(this.getX() + this.getW() - 9, this.getY() + 0.5f, 8, 8);
|
||||
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_BACK) || Keyboard.isKeyDown(Keyboard.KEY_DELETE)) {
|
||||
if (this.doBackspacing && this.backspaceWaitTimer.passed(750)) {
|
||||
if (this.backspaceTimer.passed(75)) {
|
||||
|
@ -63,12 +73,18 @@ public class TextComponent extends HudComponent {
|
|||
public void mouseRelease(int mouseX, int mouseY, int button) {
|
||||
super.mouseRelease(mouseX, mouseY, button);
|
||||
|
||||
if (!this.isMouseInside(mouseX, mouseY) || button != 0) {
|
||||
this.focused = false;
|
||||
return;
|
||||
}
|
||||
if (this.isMouseInside(mouseX, mouseY) && button == 0) {
|
||||
this.focused = true;
|
||||
|
||||
this.focused = true;
|
||||
// check for clicking check
|
||||
if (!(this instanceof ColorComponent)) {
|
||||
if (mouseX >= this.getX() + this.getW() - 10 && mouseX <= this.getX() + this.getW() && mouseY >= this.getY() && mouseY <= this.getY() + this.getH()) {
|
||||
this.enterPressed();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.focused = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,6 +28,7 @@ public class TrayComponent extends DraggableHudComponent {
|
|||
super("Tray");
|
||||
|
||||
buttons.add(new TrayButtonComponent("hub"));
|
||||
buttons.add(new TrayButtonComponent("colors"));
|
||||
buttons.add(new TrayButtonComponent("combat"));
|
||||
buttons.add(new TrayButtonComponent("movement"));
|
||||
buttons.add(new TrayButtonComponent("render"));
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
Loading…
Reference in New Issue