aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/Danker/gui/CrystalHollowWaypointActionGui.java
blob: d7f598d12e997c710e4cd72525af4a8e877e959f (plain)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package me.Danker.gui;

import me.Danker.DankersSkyblockMod;
import me.Danker.features.CrystalHollowWaypoints;
import me.Danker.utils.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.util.EnumChatFormatting;

public class CrystalHollowWaypointActionGui extends GuiScreen {

    private int id;

    private GuiButton goBack;
    private GuiButton toggle;
    private GuiButton sendNormal;
    private GuiButton sendDSM;
    private GuiButton sendSBE;
    private GuiButton delete;

    public CrystalHollowWaypointActionGui(int id) {
        this.id = id;
    }

    @Override
    public boolean doesGuiPauseGame() {
        return false;
    }

    @Override
    public void initGui() {
        super.initGui();

        ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
        int height = sr.getScaledHeight();
        int width = sr.getScaledWidth();

        CrystalHollowWaypoints.Waypoint waypoint = CrystalHollowWaypoints.waypoints.get(id);

        goBack = new GuiButton(0, 2, height - 30, 100, 20, "Go Back");
        toggle = new GuiButton(0, width / 2 - 100, (int) (height * 0.1), "Set Visibility: " + Utils.getColouredBoolean(waypoint.toggled));
        sendNormal = new GuiButton(0, width / 2 - 100, (int) (height * 0.2), "Send Location And Coordinates");
        sendDSM = new GuiButton(0, width / 2 - 100, (int) (height * 0.3), "Send DSM Formatted Waypoint");
        sendSBE = new GuiButton(0, width / 2 - 100, (int) (height * 0.4), "Send SBE Formatted Waypoint");
        delete = new GuiButton(0, width / 2 - 100, (int) (height * 0.8), EnumChatFormatting.RED + "Delete Waypoint");

        this.buttonList.add(toggle);
        this.buttonList.add(sendNormal);
        this.buttonList.add(sendDSM);
        this.buttonList.add(sendSBE);
        this.buttonList.add(delete);
        this.buttonList.add(goBack);
    }

    @Override
    public void drawScreen(int mouseX, int mouseY, float partialTicks) {
        this.drawDefaultBackground();
        super.drawScreen(mouseX, mouseY, partialTicks);
    }

    @Override
    public void actionPerformed(GuiButton button) {
        CrystalHollowWaypoints.Waypoint waypoint = CrystalHollowWaypoints.waypoints.get(id);
        EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
        if (button == goBack) {
            DankersSkyblockMod.guiToOpen = "crystalwaypoints";
        } else if (button == toggle) {
            waypoint.toggle();
            toggle.displayString = "Set Visibility: " + Utils.getColouredBoolean(waypoint.toggled);
        } else if (button == sendNormal) {
            player.sendChatMessage(waypoint.location + " @ " + waypoint.getPos());
        } else if (button == sendDSM) {
            player.sendChatMessage("$DSMCHWP:" + waypoint.getFormattedWaypoint());
        } else if (button == sendSBE) {
            player.sendChatMessage("$SBECHWP:" + waypoint.getFormattedWaypoint());
        } else if (button == delete) {
            CrystalHollowWaypoints.waypoints.remove(id);
            mc.displayGuiScreen(new CrystalHollowWaypointsGui(1));
            return;
        }
        CrystalHollowWaypoints.waypoints.set(id, waypoint);
    }

}