1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
/*
* Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod
* Copyright (C) 2021 cyoung06
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package kr.syeyoung.dungeonsguide.features.impl.secret.mechanicbrowser;
import kr.syeyoung.dungeonsguide.gui.MPanel;
import kr.syeyoung.dungeonsguide.utils.GlStateUtils;
import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor;
import lombok.AllArgsConstructor;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.GlStateManager;
import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Supplier;
@AllArgsConstructor
public class MechanicBrowserElement extends MPanel {
private Supplier<String> name;
private boolean isCategory = false;
private BiConsumer<MechanicBrowserElement, Point> onClick;
@Override
public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) {
if (isCategory || isFocused)
Gui.drawRect(0, 0, bounds.width, bounds.height, 0xFF444444);
else if (lastAbsClip.contains(absMousex, absMousey))
Gui.drawRect(0, 0, bounds.width, bounds.height, 0xFF555555);
Minecraft.getMinecraft().fontRendererObj.drawString((String)name.get(), 4, 1, 0xFFEEEEEE);
}
@Override
public Dimension getPreferredSize() {
return new Dimension(Minecraft.getMinecraft().fontRendererObj.getStringWidth(name.get()) + 8, Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT);
}
@Override
public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) {
if (lastAbsClip.contains(absMouseX, absMouseY) && onClick != null)
onClick.accept(this, new Point(lastParentPoint.x + bounds.x, lastParentPoint.y + bounds.y));
}
@Override
public void mouseMoved(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) {
if (lastAbsClip.contains(absMouseX, absMouseY) && onClick != null)
setCursor(EnumCursor.POINTING_HAND);
}
}
|