src/main/java/codes/biscuit/skyblockaddons/gui/SkyblockAddonsGui.java
/**
     * Adds a button, limiting its width and setting the correct position.
     */
Adds a button, limiting its width and setting the correct position.
Adds a button limiting its width and setting the correct position .
private void addButton(Feature feature, EnumUtils.ButtonType buttonType) {
        if (displayCount == 0) return;
        String text = feature.getMessage();
        int halfWidth = width/2;
        int boxWidth = 140;
        int boxHeight = 50;
        int x = 0;
        if (collumn == 1) {
            x = halfWidth-90-boxWidth;
        } else if (collumn == 2) {
            x = halfWidth-(boxWidth/2);
        } else if (collumn == 3) {
            x = halfWidth+90;
        }
        double y = getRowHeight(row);
        if (buttonType == EnumUtils.ButtonType.TOGGLE) {
            ButtonNormal button = new ButtonNormal(x, y, text, main, feature);
            buttonList.add(button);
            EnumUtils.FeatureCredit credit = EnumUtils.FeatureCredit.fromFeature(feature);
            if (credit != null) {
                CoordsPair coords = button.getCreditsCoords(credit);
                buttonList.add(new ButtonCredit(coords.getX(), coords.getY(), text, main, credit, feature));
            }
            if (feature.getSettings().size() > 0) {
                buttonList.add(new ButtonSettings(x + boxWidth - 33, y + boxHeight - 23, text, main, feature));
            }
            buttonList.add(new ButtonToggle(x+40, y+boxHeight-23, main, feature));
        } else if (buttonType == EnumUtils.ButtonType.SOLID) {
            buttonList.add(new ButtonNormal(x, y, text, main, feature));
            if (feature == Feature.TEXT_STYLE) {
                buttonList.add(new ButtonSolid(x + 35, y + boxHeight - 23, 70, 15, "", main, feature));
            } else if (feature == Feature.WARNING_TIME) {
                int solidButtonX = x+(boxWidth/2)-17;
                buttonList.add(new ButtonModify(solidButtonX-20, y + boxHeight - 23, 15, 15, "+", main, Feature.ADD));
                buttonList.add(new ButtonSolid(solidButtonX, y + boxHeight - 23, 35, 15, "", main, feature));
                buttonList.add(new ButtonModify(solidButtonX+35+5, y + boxHeight - 23, 15, 15,"-", main, Feature.SUBTRACT));
            }
        }
        collumn++;
        if (collumn > 3) {
            collumn = 1;
            row++;
        }
        displayCount--;
    }
private void addButton ( Feature feature , EnumUtils . ButtonType buttonType ) { if ( displayCount == 0 ) return ; String text = feature . getMessage ( ) ; int halfWidth = width / 2 ; int boxWidth = 140 ; int boxHeight = 50 ; int x = 0 ; if ( collumn == 1 ) { x = halfWidth - 90 - boxWidth ; } else if ( collumn == 2 ) { x = halfWidth - ( boxWidth / 2 ) ; } else if ( collumn == 3 ) { x = halfWidth + 90 ; } double y = getRowHeight ( row ) ; if ( buttonType == EnumUtils . ButtonType . TOGGLE ) { ButtonNormal button = new ButtonNormal ( x , y , text , main , feature ) ; buttonList . add ( button ) ; EnumUtils . FeatureCredit credit = EnumUtils . FeatureCredit . fromFeature ( feature ) ; if ( credit != null ) { CoordsPair coords = button . getCreditsCoords ( credit ) ; buttonList . add ( new ButtonCredit ( coords . getX ( ) , coords . getY ( ) , text , main , credit , feature ) ) ; } if ( feature . getSettings ( ) . size ( ) > 0 ) { buttonList . add ( new ButtonSettings ( x + boxWidth - 33 , y + boxHeight - 23 , text , main , feature ) ) ; } buttonList . add ( new ButtonToggle ( x + 40 , y + boxHeight - 23 , main , feature ) ) ; } else if ( buttonType == EnumUtils . ButtonType . SOLID ) { buttonList . add ( new ButtonNormal ( x , y , text , main , feature ) ) ; if ( feature == Feature . TEXT_STYLE ) { buttonList . add ( new ButtonSolid ( x + 35 , y + boxHeight - 23 , 70 , 15 , "" , main , feature ) ) ; } else if ( feature == Feature . WARNING_TIME ) { int solidButtonX = x + ( boxWidth / 2 ) - 17 ; buttonList . add ( new ButtonModify ( solidButtonX - 20 , y + boxHeight - 23 , 15 , 15 , "+" , main , Feature . ADD ) ) ; buttonList . add ( new ButtonSolid ( solidButtonX , y + boxHeight - 23 , 35 , 15 , "" , main , feature ) ) ; buttonList . add ( new ButtonModify ( solidButtonX + 35 + 5 , y + boxHeight - 23 , 15 , 15 , "-" , main , Feature . SUBTRACT ) ) ; } } collumn ++ ; if ( collumn > 3 ) { collumn = 1 ; row ++ ; } displayCount -- ; }
Adds a button, limiting its width and setting the correct position.
Adds a button limiting its width and setting the correct position .