private void updateWidth() { if (getWidth() == 0) { setWidth(DEFAULT_SIZE); return; } if (orientation == HORIZONTAL) { incButton.setX(getWidth() - incButton.getWidth()); slider.setX(decButton.getWidth()); slider.setWidth(getWidth() - (incButton.getWidth() + decButton.getWidth())); } else { // VERTICAL incButton.setWidth(Math.min(getWidth(), incButton.getWidth())); decButton.setWidth(Math.min(getWidth(), decButton.getWidth())); slider.setWidth(Math.min(getWidth(), slider.getWidth())); slider.setX(getWidth() / 2f - slider.getWidth() / 2f); incButton.setX(getWidth() / 2f - incButton.getWidth() / 2f); decButton.setX(getWidth() / 2f - incButton.getWidth() / 2f); } }
public HeroesSelectGUI(HeroesHUD plugin, SpoutPlayer spoutp) { this.plugin = plugin; this.spoutp = spoutp; GenericTexture backgroundMain = new GenericTexture(); int screenWidth = spoutp.getMainScreen().getWidth(); int screenHeight = spoutp.getMainScreen().getHeight(); int x = (screenWidth / 2) - 170; int y = (screenHeight / 2) - 100; // BackgroundMain! backgroundMain.setX(x).setY(y); backgroundMain.setWidth(340).setHeight(200); backgroundMain.setUrl(plugin.HeroesSelectGuiBackgroundMain); backgroundMain.setFixed(false); backgroundMain.setPriority(RenderPriority.Highest); // Button1 Main button1 = new GenericButton(); button1.setText("Primary"); button1 .setWidth(GenericLabel.getStringWidth(button1.getText()) + 5 + 30) .setHeight(GenericLabel.getStringHeight(button1.getText()) + 5); button1.setX(backgroundMain.getX() + 20); button1.setY(backgroundMain.getY() + 65); button1.setDirty(true); button1.setAutoDirty(true); // Button2 Main button2 = new GenericButton(); button2.setText("Profession"); button2 .setWidth(GenericLabel.getStringWidth(button2.getText()) + 5 + 30) .setHeight(GenericLabel.getStringHeight(button2.getText()) + 5); button2.setX(backgroundMain.getX() + 235); button2.setY(backgroundMain.getY() + 65); button2.setDirty(true); button2.setAutoDirty(true); super.attachWidgets(plugin, backgroundMain, button1, button2); super.setAnchor(WidgetAnchor.TOP_LEFT); }