Search in sources :

Example 1 with Vector2

use of micdoodle8.mods.galacticraft.api.vector.Vector2 in project Galacticraft by micdoodle8.

the class GuiNewSpaceRace method initGui.

@Override
public void initGui() {
    float sliderR = 0;
    float sliderG = 0;
    float sliderB = 0;
    if (this.sliderColorR != null && this.sliderColorG != null && this.sliderColorB != null) {
        sliderR = this.sliderColorR.getSliderPos() / (float) this.sliderColorR.getButtonHeight();
        sliderG = this.sliderColorG.getSliderPos() / (float) this.sliderColorG.getButtonHeight();
        sliderB = this.sliderColorB.getSliderPos() / (float) this.sliderColorB.getButtonHeight();
    }
    super.initGui();
    this.buttonList.clear();
    if (this.initialized) {
        this.buttonFlag_width = 81;
        this.buttonFlag_height = 58;
        this.buttonFlag_xPosition = this.width / 2 - this.buttonFlag_width / 2;
        this.buttonFlag_yPosition = this.height / 2 - this.height / 3 + 10;
        this.buttonTeamColor_width = 45;
        this.buttonTeamColor_height = 45;
        this.buttonTeamColor_xPosition = this.buttonFlag_xPosition + this.buttonFlag_width + 10;
        this.buttonTeamColor_yPosition = this.buttonFlag_yPosition + this.buttonFlag_height / 2 - this.buttonTeamColor_height / 2;
        this.buttonList.add(new GuiElementGradientButton(0, this.width / 2 - this.width / 3 + 15, this.height / 2 - this.height / 4 - 15, 50, 15, this.currentState == EnumSpaceRaceGui.MAIN ? GCCoreUtil.translate("gui.space_race.create.close.name") : GCCoreUtil.translate("gui.space_race.create.back.name")));
        switch(this.currentState) {
            case MAIN:
                this.textBoxRename = new GuiElementTextBox(1, this, this.width / 2 - 75, this.buttonFlag_yPosition + this.buttonFlag_height + 10, 150, 16, GCCoreUtil.translate("gui.space_race.create.rename.name"), false, 25, true);
                this.buttonList.add(this.textBoxRename);
                if (this.canEdit) {
                    this.buttonList.add(new GuiElementGradientButton(2, this.width / 2 - 120, this.textBoxRename.yPosition + this.height / 10, 100, this.height / 10, GCCoreUtil.translate("gui.space_race.create.add_players.name")));
                    this.buttonList.add(new GuiElementGradientButton(3, this.width / 2 - 120, this.textBoxRename.yPosition + this.height / 10 + this.height / 10 + this.height / 50, 100, this.height / 10, GCCoreUtil.translate("gui.space_race.create.rem_players.name")));
                }
                GuiElementGradientButton localStats = new GuiElementGradientButton(4, this.width / 2 + (this.canEdit ? 20 : -50), this.textBoxRename.yPosition + this.height / 10, 100, this.height / 10, GCCoreUtil.translate("gui.space_race.create.server_stats.name"));
                GuiElementGradientButton serverStats = new GuiElementGradientButton(5, this.width / 2 + (this.canEdit ? 20 : -50), this.textBoxRename.yPosition + this.height / 10 + this.height / 10 + this.height / 50, 100, this.height / 10, GCCoreUtil.translate("gui.space_race.create.global_stats.name"));
                localStats.enabled = false;
                serverStats.enabled = false;
                this.buttonList.add(localStats);
                this.buttonList.add(serverStats);
                break;
            case ADD_PLAYER:
                this.buttonList.add(new GuiElementGradientButton(2, this.width / 2 - this.width / 3 + 7, this.height / 2 + this.height / 4 - 15, 64, 15, GCCoreUtil.translate("gui.space_race.create.send_invite.name")));
                int xPos0 = ((GuiElementGradientButton) this.buttonList.get(0)).xPosition + ((GuiElementGradientButton) this.buttonList.get(0)).getButtonWidth() + 10;
                int xPos1 = this.width / 2 + this.width / 3 - 10;
                int yPos0 = this.height / 2 - this.height / 3 + 10;
                int yPos1 = this.height / 2 + this.height / 3 - 10;
                this.gradientListAddPlayers = new GuiElementGradientList(xPos0, yPos0, xPos1 - xPos0, yPos1 - yPos0);
                break;
            case REMOVE_PLAYER:
                this.buttonList.add(new GuiElementGradientButton(2, this.width / 2 - this.width / 3 + 7, this.height / 2 + this.height / 4 - 15, 64, 15, GCCoreUtil.translate("gui.space_race.create.remove.name")));
                int xPos0b = ((GuiElementGradientButton) this.buttonList.get(0)).xPosition + ((GuiElementGradientButton) this.buttonList.get(0)).getButtonWidth() + 10;
                int xPos1b = this.width / 2 + this.width / 3 - 10;
                int yPos0b = this.height / 2 - this.height / 3 + 10;
                int yPos1b = this.height / 2 + this.height / 3 - 10;
                this.gradientListRemovePlayers = new GuiElementGradientList(xPos0b, yPos0b, xPos1b - xPos0b, yPos1b - yPos0b);
                break;
            case DESIGN_FLAG:
                int guiBottom = this.height / 2 + this.height / 4;
                int guiTop = this.height / 2 - this.height / 4;
                int guiRight = this.width / 2 + this.width / 3;
                int guiLeft;
                this.flagDesignerScale = new Vector2(this.width / 130.0F, this.height / 70.0F);
                this.flagDesignerMinX = this.width / 2 - this.spaceRaceData.getFlagData().getWidth() * (float) this.flagDesignerScale.x / 2;
                this.flagDesignerMinY = this.height / 2 - this.spaceRaceData.getFlagData().getHeight() * (float) this.flagDesignerScale.y / 2;
                this.flagDesignerWidth = this.spaceRaceData.getFlagData().getWidth() * (float) this.flagDesignerScale.x;
                this.flagDesignerHeight = this.spaceRaceData.getFlagData().getHeight() * (float) this.flagDesignerScale.y;
                int flagDesignerRight = (int) (this.flagDesignerMinX + this.flagDesignerWidth);
                int availWidth = (int) ((guiRight - 10 - (this.flagDesignerMinX + this.flagDesignerWidth + 10)) / 3);
                float x1 = flagDesignerRight + 10;
                float x2 = guiRight - 10;
                float y1 = guiBottom - 10 - (x2 - x1);
                int height = (int) (y1 - 10 - (guiTop + 10));
                this.sliderColorR = new GuiElementSlider(1, flagDesignerRight + 10, guiTop + 10, availWidth, height, true, new Vector3(0, 0, 0), new Vector3(1, 0, 0));
                this.sliderColorG = new GuiElementSlider(2, flagDesignerRight + 11 + availWidth, guiTop + 10, availWidth, height, true, new Vector3(0, 0, 0), new Vector3(0, 1, 0));
                this.sliderColorB = new GuiElementSlider(3, flagDesignerRight + 12 + availWidth * 2, guiTop + 10, availWidth, height, true, new Vector3(0, 0, 0), new Vector3(0, 0, 1));
                this.sliderColorR.setSliderPos(sliderR);
                this.sliderColorG.setSliderPos(sliderG);
                this.sliderColorB.setSliderPos(sliderB);
                this.buttonList.add(this.sliderColorR);
                this.buttonList.add(this.sliderColorG);
                this.buttonList.add(this.sliderColorB);
                this.checkboxPaintbrush = new GuiElementCheckbox(5, this, (int) (this.flagDesignerMinX - 15), this.height / 2 - this.height / 4 + 10, 13, 13, 26, 26, 133, 0, "", 4210752, false);
                this.checkboxEraser = new GuiElementCheckbox(6, this, (int) (this.flagDesignerMinX - 15), this.height / 2 - this.height / 4 + 25, 13, 13, 26, 26, 133, 52, "", 4210752, false);
                this.checkboxSelector = new GuiElementCheckbox(7, this, (int) (this.flagDesignerMinX - 15), this.height / 2 - this.height / 4 + 40, 13, 13, 26, 26, 133, 78, "", 4210752, false);
                this.checkboxColorSelector = new GuiElementCheckbox(8, this, (int) (this.flagDesignerMinX - 15), this.height / 2 - this.height / 4 + 55, 13, 13, 26, 26, 133, 104, "", 4210752, false);
                this.checkboxShowGrid = new GuiElementCheckbox(9, this, (int) (this.flagDesignerMinX - 15), this.height / 2 - this.height / 4 + 90, 13, 13, 26, 26, 133, 26, "", 4210752, false);
                this.sliderBrushSize = new GuiElementSlider(10, this.checkboxPaintbrush.xPosition - 40, this.checkboxPaintbrush.yPosition, 35, 13, false, new Vector3(0.34, 0.34, 0.34), new Vector3(0.34, 0.34, 0.34), GCCoreUtil.translate("gui.space_race.create.brush_size.name"));
                this.sliderEraserSize = new GuiElementSlider(11, this.checkboxEraser.xPosition - 40, this.checkboxEraser.yPosition, 35, 13, false, new Vector3(0.34, 0.34, 0.34), new Vector3(0.34, 0.34, 0.34), GCCoreUtil.translate("gui.space_race.create.eraser_size.name"));
                this.sliderEraserSize.visible = false;
                this.buttonList.add(this.checkboxPaintbrush);
                this.buttonList.add(this.checkboxShowGrid);
                this.buttonList.add(this.checkboxEraser);
                this.buttonList.add(this.checkboxSelector);
                this.buttonList.add(this.checkboxColorSelector);
                this.buttonList.add(this.sliderBrushSize);
                this.buttonList.add(this.sliderEraserSize);
                break;
            case CHANGE_TEAM_COLOR:
                guiBottom = this.height / 2 + this.height / 4;
                guiTop = this.height / 2 - this.height / 4;
                guiLeft = this.width / 6;
                guiRight = this.width / 2 + this.width / 3;
                flagDesignerRight = guiLeft;
                availWidth = (guiRight - guiLeft - 100) / 3;
                x1 = flagDesignerRight + 10;
                x2 = guiLeft - 10;
                y1 = guiBottom - 10 - (x2 - x1);
                height = (int) (y1 - 10 - (guiTop + 30));
                this.sliderColorR = new GuiElementSlider(1, flagDesignerRight + 25, guiTop + 30, availWidth, height, true, new Vector3(0, 0, 0), new Vector3(1, 0, 0));
                this.sliderColorG = new GuiElementSlider(2, flagDesignerRight + availWidth + 50, guiTop + 30, availWidth, height, true, new Vector3(0, 0, 0), new Vector3(0, 1, 0));
                this.sliderColorB = new GuiElementSlider(3, flagDesignerRight + availWidth * 2 + 75, guiTop + 30, availWidth, height, true, new Vector3(0, 0, 0), new Vector3(0, 0, 1));
                this.sliderColorR.setSliderPos(this.spaceRaceData.getTeamColor().floatX());
                this.sliderColorG.setSliderPos(this.spaceRaceData.getTeamColor().floatY());
                this.sliderColorB.setSliderPos(this.spaceRaceData.getTeamColor().floatZ());
                this.buttonList.add(this.sliderColorR);
                this.buttonList.add(this.sliderColorG);
                this.buttonList.add(this.sliderColorB);
                break;
            default:
                break;
        }
    }
}
Also used : Vector2(micdoodle8.mods.galacticraft.api.vector.Vector2) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3)

Aggregations

Vector2 (micdoodle8.mods.galacticraft.api.vector.Vector2)1 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)1