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 gearTexture;
|
||||||
private final Texture gearTextureEnabled;
|
private final Texture gearTextureEnabled;
|
||||||
private final Texture checkTexture;
|
|
||||||
|
|
||||||
public ColorComponent(String name, int defaultColor) {
|
public ColorComponent(String name, int defaultColor) {
|
||||||
super(name, String.valueOf(defaultColor), false);
|
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.displayValue = "#" + Integer.toHexString(this.currentColor.getRGB()).toLowerCase().substring(2);
|
||||||
this.gearTexture = new Texture("gear_wheel.png");
|
this.gearTexture = new Texture("gear_wheel.png");
|
||||||
this.gearTextureEnabled = new Texture("gear_wheel-enabled.png");
|
this.gearTextureEnabled = new Texture("gear_wheel-enabled.png");
|
||||||
this.checkTexture = new Texture("check.png");
|
|
||||||
|
|
||||||
this.setH(9);
|
this.setH(9);
|
||||||
}
|
}
|
||||||
|
@ -77,10 +75,12 @@ public class ColorComponent extends TextComponent {
|
||||||
RenderUtil.drawRect(blockX, blockY, blockX + blockWidth, blockY + blockHeight, 0xFFFFFFFF);
|
RenderUtil.drawRect(blockX, blockY, blockX + blockWidth, blockY + blockHeight, 0xFFFFFFFF);
|
||||||
|
|
||||||
// draw gear
|
// 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.bind();
|
||||||
this.gearTextureEnabled.render(this.getX() + this.getW() - 9, this.getY() + 0.5f, 8, 8);
|
this.gearTextureEnabled.render(this.getX() + this.getW() - 9, this.getY() + 0.5f, 8, 8);
|
||||||
|
|
||||||
// check
|
// 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.bind();
|
||||||
this.checkTexture.render(this.getX() + this.getW() - 19, this.getY() + 0.5f, 8, 8);
|
this.checkTexture.render(this.getX() + this.getW() - 19, this.getY() + 0.5f, 8, 8);
|
||||||
|
|
||||||
|
@ -107,10 +107,9 @@ public class ColorComponent extends TextComponent {
|
||||||
public void mouseRelease(int mouseX, int mouseY, int button) {
|
public void mouseRelease(int mouseX, int mouseY, int button) {
|
||||||
super.mouseRelease(mouseX, mouseY, button);
|
super.mouseRelease(mouseX, mouseY, button);
|
||||||
|
|
||||||
if (!this.focused || !this.isMouseInside(mouseX, mouseY)) // must be focused & inside
|
if (!this.focused) // must be focused
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (this.isMouseInside(mouseX, mouseY)) {
|
|
||||||
if (button == 0) {
|
if (button == 0) {
|
||||||
// check for clicking check
|
// 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()) {
|
if (mouseX >= this.getX() + this.getW() - 20 && mouseX <= this.getX() + this.getW() - 10 && mouseY >= this.getY() && mouseY <= this.getY() + this.getH()) {
|
||||||
|
@ -118,7 +117,6 @@ public class ColorComponent extends TextComponent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void enterPressed() {
|
protected void enterPressed() {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package me.rigamortis.seppuku.api.gui.hud.component;
|
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.RenderUtil;
|
||||||
import me.rigamortis.seppuku.api.util.Timer;
|
import me.rigamortis.seppuku.api.util.Timer;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
@ -16,6 +17,8 @@ public class TextComponent extends HudComponent {
|
||||||
public ComponentListener returnListener;
|
public ComponentListener returnListener;
|
||||||
public TextComponentListener textListener;
|
public TextComponentListener textListener;
|
||||||
|
|
||||||
|
protected Texture checkTexture;
|
||||||
|
|
||||||
protected Timer backspaceTimer = new Timer(), backspaceWaitTimer = new Timer();
|
protected Timer backspaceTimer = new Timer(), backspaceWaitTimer = new Timer();
|
||||||
protected boolean doBackspacing = false;
|
protected boolean doBackspacing = false;
|
||||||
|
|
||||||
|
@ -25,6 +28,8 @@ public class TextComponent extends HudComponent {
|
||||||
this.displayValue = displayValue;
|
this.displayValue = displayValue;
|
||||||
this.focused = false;
|
this.focused = false;
|
||||||
this.digitOnly = digitOnly;
|
this.digitOnly = digitOnly;
|
||||||
|
|
||||||
|
this.checkTexture = new Texture("check.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -44,6 +49,11 @@ public class TextComponent extends HudComponent {
|
||||||
int blockHeight = Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 2;
|
int blockHeight = Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 2;
|
||||||
RenderUtil.drawRect(blockX, blockY, blockX + blockWidth, blockY + blockHeight, 0xFFFFFFFF);
|
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 (Keyboard.isKeyDown(Keyboard.KEY_BACK) || Keyboard.isKeyDown(Keyboard.KEY_DELETE)) {
|
||||||
if (this.doBackspacing && this.backspaceWaitTimer.passed(750)) {
|
if (this.doBackspacing && this.backspaceWaitTimer.passed(750)) {
|
||||||
if (this.backspaceTimer.passed(75)) {
|
if (this.backspaceTimer.passed(75)) {
|
||||||
|
@ -63,12 +73,18 @@ public class TextComponent extends HudComponent {
|
||||||
public void mouseRelease(int mouseX, int mouseY, int button) {
|
public void mouseRelease(int mouseX, int mouseY, int button) {
|
||||||
super.mouseRelease(mouseX, mouseY, button);
|
super.mouseRelease(mouseX, mouseY, button);
|
||||||
|
|
||||||
if (!this.isMouseInside(mouseX, mouseY) || button != 0) {
|
if (this.isMouseInside(mouseX, mouseY) && button == 0) {
|
||||||
this.focused = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
@Override
|
||||||
|
|
|
@ -28,6 +28,7 @@ public class TrayComponent extends DraggableHudComponent {
|
||||||
super("Tray");
|
super("Tray");
|
||||||
|
|
||||||
buttons.add(new TrayButtonComponent("hub"));
|
buttons.add(new TrayButtonComponent("hub"));
|
||||||
|
buttons.add(new TrayButtonComponent("colors"));
|
||||||
buttons.add(new TrayButtonComponent("combat"));
|
buttons.add(new TrayButtonComponent("combat"));
|
||||||
buttons.add(new TrayButtonComponent("movement"));
|
buttons.add(new TrayButtonComponent("movement"));
|
||||||
buttons.add(new TrayButtonComponent("render"));
|
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