Search in sources :

Example 1 with GuiRoomInfoButton

use of com.wuest.prefab.Gui.Controls.GuiRoomInfoButton in project MC-Prefab by Brian-Wuest.

the class GuiDrafter method enableRoomsForFloor.

protected void enableRoomsForFloor(RoomInfo[] roomArray, int floorNumber) {
    for (int i = 0; i < 49; i++) {
        GuiRoomInfoButton button = this.roomButtons.get(i);
        button.roomInfo = roomArray[i];
        button.selected = false;
        // Ground floor room 47 is the foyer and will always exist.
        if (i == 45 && floorNumber == 0) {
            button.enabled = true;
            continue;
        } else if (i == 45) {
            button.enabled = true;
            continue;
        }
        // Only set the buttons to enabled if a neighbor is enabled and it has a structure name.
        button.enabled = button.roomInfo.checkNeighbors(roomArray);
        if (button.enabled && button.roomInfo.StructureName.getName().equals(AvailableRoomType.Empty.getName())) {
            button.displayString = "+";
        } else if (!button.enabled) {
            button.displayString = "";
        }
    }
}
Also used : GuiRoomInfoButton(com.wuest.prefab.Gui.Controls.GuiRoomInfoButton)

Example 2 with GuiRoomInfoButton

use of com.wuest.prefab.Gui.Controls.GuiRoomInfoButton in project MC-Prefab by Brian-Wuest.

the class GuiDrafter method createGeneralTabControls.

private int createGeneralTabControls(int grayBoxX, int grayBoxY, int uiComponentID) {
    int roomX = grayBoxX + 40;
    int roomY = grayBoxY + 30;
    // Create the 49 room buttons.
    for (int i = 1; i < 50; i++) {
        GuiRoomInfoButton roomButton = new GuiRoomInfoButton(uiComponentID++, roomX, roomY, 18, 18, "");
        HoverChecker hoverChecker = new HoverChecker(roomButton, 800);
        this.roomHovers.add(hoverChecker);
        this.buttonList.add(roomButton);
        this.roomButtons.add(roomButton);
        roomX = roomX + 18;
        if (i % 7 == 0) {
            roomX = grayBoxX + 40;
            roomY = roomY + 18;
        }
    }
    this.btnBasement2 = new GuiButtonExt(uiComponentID++, grayBoxX + 10, grayBoxY + 145, 20, 20, "B2");
    this.buttonList.add(this.btnBasement2);
    this.btnBasement1 = new GuiButtonExt(uiComponentID++, grayBoxX + 10, grayBoxY + 120, 20, 20, "B1");
    this.buttonList.add(this.btnBasement1);
    this.btnGroundFloor = new GuiButtonExt(uiComponentID++, grayBoxX + 10, grayBoxY + 95, 20, 20, "G");
    this.btnGroundFloor.enabled = false;
    this.buttonList.add(this.btnGroundFloor);
    this.btnSecondFloor = new GuiButtonExt(uiComponentID++, grayBoxX + 10, grayBoxY + 70, 20, 20, "2");
    this.buttonList.add(this.btnSecondFloor);
    this.btnThirdFloor = new GuiButtonExt(uiComponentID++, grayBoxX + 10, grayBoxY + 45, 20, 20, "3");
    this.buttonList.add(this.btnThirdFloor);
    this.btnClearPending = new GuiButtonExt(uiComponentID++, grayBoxX + 110, grayBoxY + 186, 80, 20, "Clear Pending");
    this.buttonList.add(this.btnClearPending);
    this.btnBuild = new GuiButtonExt(uiComponentID++, grayBoxX + 195, grayBoxY + 186, 50, 20, GuiLangKeys.translateString(GuiLangKeys.GUI_BUTTON_BUILD));
    this.buttonList.add(this.btnBuild);
    this.btnCancel = new GuiButtonExt(uiComponentID++, grayBoxX + 250, grayBoxY + 186, 50, 20, "Close");
    this.buttonList.add(this.btnCancel);
    // Tabs:
    this.tabGeneral = new GuiTab(this.Tabs, GuiLangKeys.translateString(GuiLangKeys.STARTER_TAB_GENERAL), grayBoxX + 5, grayBoxY - 10);
    this.Tabs.AddTab(this.tabGeneral);
    this.tabDesignRoom = new GuiTab(this.Tabs, "Design Room", grayBoxX + 58, grayBoxY - 10);
    this.tabDesignRoom.width = 90;
    this.tabDesignRoom.visible = false;
    this.Tabs.AddTab(tabDesignRoom);
    this.tabPendingChanges = new GuiTab(this.Tabs, "Pending Changes", grayBoxX + 151, grayBoxY - 10);
    this.tabPendingChanges.width = 100;
    this.tabPendingChanges.visible = false;
    this.Tabs.AddTab(this.tabPendingChanges);
    try {
        this.actionPerformed(this.btnGroundFloor);
        this.roomButtons.get(45).roomInfo.StructureName = AvailableRoomType.Foyer;
        this.actionPerformed(this.btnGroundFloor);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return uiComponentID;
}
Also used : GuiTab(com.wuest.prefab.Gui.Controls.GuiTab) GuiRoomInfoButton(com.wuest.prefab.Gui.Controls.GuiRoomInfoButton) GuiButtonExt(net.minecraftforge.fml.client.config.GuiButtonExt) IOException(java.io.IOException) HoverChecker(net.minecraftforge.fml.client.config.HoverChecker)

Example 3 with GuiRoomInfoButton

use of com.wuest.prefab.Gui.Controls.GuiRoomInfoButton in project MC-Prefab by Brian-Wuest.

the class GuiDrafter method drawScreen.

/**
 * Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks
 */
@Override
public void drawScreen(int x, int y, float f) {
    int grayBoxX = (this.width / 2) - 158;
    int grayBoxY = (this.height / 2) - 93;
    this.Tabs.trayX = grayBoxX;
    this.Tabs.trayY = grayBoxY - 21;
    this.drawDefaultBackground();
    // Draw the control background.
    this.mc.getTextureManager().bindTexture(backgroundTextures);
    this.drawModalRectWithCustomSizedTexture(grayBoxX, grayBoxY, 0, 320, 320, 320, 320);
    for (GuiButton button : this.buttonList) {
        // Make all buttons invisible.
        if (button != this.btnCancel) {
            button.visible = false;
        }
    }
    // Update visibility on controls based on the selected tab.
    if (this.getSelectedTab() == this.tabGeneral) {
        this.makeGeneralTabControlsVisible();
    } else if (this.getSelectedTab() == this.tabDesignRoom) {
        this.makeDesignRoomTabControlsVisible(x, y, f);
    } else if (this.getSelectedTab() == this.tabPendingChanges) {
        this.makePendingChangesTabControlsVisible(x, y, f);
    }
    // Draw the buttons, labels and tabs.
    super.drawScreen(x, y, f);
    for (int i = 0; i < 49; i++) {
        HoverChecker hoverChecker = this.roomHovers.get(i);
        if (hoverChecker.checkHover(x, y)) {
            GuiRoomInfoButton button = this.roomButtons.get(i);
            if (button.enabled) {
                String hoverText = "";
                if (button.roomInfo.StructureName.getName().equals(AvailableRoomType.Empty.getName())) {
                    hoverText = "\nRoom Coordinates:\n X: BlahX Y: BlahY Z: BlahZ";
                } else {
                    hoverText = "Room Name: " + (i + 1) + "\nRoom Coordinates:\n X: BlahX Y: BlahY Z: BlahZ";
                }
                this.drawHoveringText(this.mc.fontRenderer.listFormattedStringToWidth(button.getHoverText(), 300), x, y);
            }
        }
    }
    // Draw the text here.
    int color = Color.DARK_GRAY.getRGB();
    if (this.getSelectedTab() == this.tabGeneral) {
        this.mc.fontRenderer.drawString("Level", grayBoxX + 7, grayBoxY + 20, color);
        if (this.selectedRoom != null && !this.selectedRoom.roomInfo.StructureName.getName().equals(AvailableRoomType.Empty.getName())) {
        // Show the structure name and room coordinates for this selected room.
        }
    } else if (this.getSelectedTab() == this.tabDesignRoom) {
        this.mc.fontRenderer.drawString("Available Room Styles", grayBoxX + 7, grayBoxY + 5, color);
        this.mc.fontRenderer.drawString("Room Materials", grayBoxX + 125, grayBoxY + 5, color);
    }
}
Also used : GuiButton(net.minecraft.client.gui.GuiButton) GuiRoomInfoButton(com.wuest.prefab.Gui.Controls.GuiRoomInfoButton) HoverChecker(net.minecraftforge.fml.client.config.HoverChecker)

Example 4 with GuiRoomInfoButton

use of com.wuest.prefab.Gui.Controls.GuiRoomInfoButton in project MC-Prefab by Brian-Wuest.

the class GuiDrafter method makeGeneralTabControlsVisible.

private void makeGeneralTabControlsVisible() {
    for (GuiRoomInfoButton roomInfoButton : this.roomButtons) {
        roomInfoButton.visible = true;
    }
    this.btnBasement2.visible = true;
    this.btnBasement1.visible = true;
    this.btnBuild.visible = true;
    this.btnClearPending.visible = true;
    this.btnGroundFloor.visible = true;
    this.btnSecondFloor.visible = true;
    this.btnThirdFloor.visible = true;
}
Also used : GuiRoomInfoButton(com.wuest.prefab.Gui.Controls.GuiRoomInfoButton)

Aggregations

GuiRoomInfoButton (com.wuest.prefab.Gui.Controls.GuiRoomInfoButton)4 HoverChecker (net.minecraftforge.fml.client.config.HoverChecker)2 GuiTab (com.wuest.prefab.Gui.Controls.GuiTab)1 IOException (java.io.IOException)1 GuiButton (net.minecraft.client.gui.GuiButton)1 GuiButtonExt (net.minecraftforge.fml.client.config.GuiButtonExt)1