MCPcopy Create free account
hub / github.com/5zig/The-5zig-Mod / draw

Method draw

Minecraft-Utils/1.12.2/src/ColorSelector.java:22–65  ·  view source on GitHub ↗
(int mouseX, int mouseY)

Source from the content-addressed store, hash-verified

20 }
21
22 @Override
23 public void draw(int mouseX, int mouseY) {
24 super.draw(mouseX, mouseY);
25
26 int boxX = getBoxX();
27 int boxY = getBoxY();
28
29 if (isEnabled() && !selected && !requireMoveOut && mouseX >= boxX && mouseX <= boxX + boxWidth && mouseY >= boxY && mouseY <= boxY + boxHeight) {
30 selectedX = boxX - 16 * 12 / 2 + 7;
31 selectedY = boxY + 3;
32 if (boxX + 16 * 12 / 2 + 2 > MinecraftFactory.getVars().getCurrentScreen().getWidth())
33 this.selectedX = MinecraftFactory.getVars().getCurrentScreen().getWidth() - 192 - 2;
34
35 selected = true;
36 } else if (requireMoveOut) {
37 if (mouseX < boxX || mouseX > boxX + boxWidth || mouseY < selectedY || mouseY > selectedY + 8) {
38 selectedX = selectedY = -1;
39 selected = false;
40 requireMoveOut = false;
41 }
42 } else if (!selected || (mouseX < selectedX || mouseX > selectedX + 192 || mouseY < selectedY - 8 || mouseY > selectedY + 8 + 8)) {
43 selectedX = selectedY = -1;
44 selected = false;
45 requireMoveOut = false;
46 }
47
48 // draw Selected Color Box
49 Gui.drawRect(boxX, boxY, boxX + boxWidth, boxY + boxHeight,
50 ((selected && !requireMoveOut) || (mouseX >= boxX && mouseX <= boxX + boxWidth && mouseY >= boxY && mouseY <= boxY + boxHeight) ? 0xFF444444 : 0xFF222222));
51 Gui.drawRect(boxX + 2, boxY + 2, boxX + boxWidth - 2, boxY + boxHeight - 2, (0x00FFFFFF & callback.getColor().getColor()) | 0xFF << 24);
52
53 // draw Select Color Box
54 if (selected) {
55 int width = 192;
56 Gui.drawRect(selectedX - 2, selectedY - 2, selectedX + width + 2, selectedY + 10, 0xFF222222);
57 int x = 0;
58 for (ChatColor chatColor : ChatColor.values()) {
59 if (chatColor.getColor() == -1)
60 continue;
61 Gui.drawRect(selectedX + x, selectedY, selectedX + x + 12, selectedY + 8, (0x00FFFFFF & chatColor.getColor()) | 0xFF << 24);
62 x += 12;
63 }
64 }
65 }
66
67 /**
68 * getHoverState

Callers

nothing calls this directly

Calls 9

getBoxXMethod · 0.95
getBoxYMethod · 0.95
getVarsMethod · 0.95
drawRectMethod · 0.95
drawMethod · 0.65
isEnabledMethod · 0.65
getWidthMethod · 0.65
getCurrentScreenMethod · 0.65
getColorMethod · 0.65

Tested by

no test coverage detected