public void initGui() { Addon spoutcraft = Spoutcraft.getAddonManager().getAddon("Spoutcraft"); recordLabel = new GenericLabel("Key:"); recordLabel.setAlign(WidgetAnchor.TOP_LEFT); recordLabel.setWidth(50).setHeight(20); recordLabel.setX(10).setY(40); getScreen().attachWidget(spoutcraft, recordLabel); recordButton = new GenericButton(); recordButton.setAlign(WidgetAnchor.CENTER_CENTER); recordButton.setHeight(20).setWidth(100); recordButton.setX(44).setY(33); getScreen().attachWidget(spoutcraft, recordButton); updateRecordButton(); titleLabel = new GenericLabel("Name:"); titleLabel.setAlign(WidgetAnchor.TOP_LEFT); titleLabel.setWidth(50).setHeight(20); titleLabel.setX(10).setY(10); getScreen().attachWidget(spoutcraft, titleLabel); commandText = new GenericTextField(); commandText.setHeight(16).setWidth(355); commandText.setX(45).setY(8); commandText.setText(item.getTitle()); commandText.setFocus(true); commandText.setMaximumCharacters(99); getScreen().attachWidget(spoutcraft, commandText); slot = new GuiCommandsSlot(this); getScreen().attachWidget(spoutcraft, slot); doneButton = new GenericButton("Done"); doneButton.setHeight(20).setWidth(50); doneButton.setX(10).setY(height - 30); getScreen().attachWidget(spoutcraft, doneButton); addButton = new GenericButton("Add Command"); addButton.setHeight(20).setWidth(100); addButton.setX(70).setY(height - 30); getScreen().attachWidget(spoutcraft, addButton); editButton = new GenericButton("Edit Command"); editButton.setHeight(20).setWidth(100); editButton.setX(180).setY(height - 30); getScreen().attachWidget(spoutcraft, editButton); removeButton = new GenericButton("Remove Command"); removeButton.setHeight(20).setWidth(100); removeButton.setX(290).setY(height - 30); getScreen().attachWidget(spoutcraft, removeButton); updateButtons(); }
protected void buttonClicked(Button btn) { if (btn.equals(recordButton)) { recording = !recording; updateRecordButton(); } if (btn.equals(doneButton)) { item.setTitle(commandText.getText()); if (!item.getTitle().equals("") && item.getKey() != -1) { SimpleKeyBindingManager manager = (SimpleKeyBindingManager) SpoutClient.getInstance().getKeyBindingManager(); manager.unregisterShortcut(item); manager.registerShortcut(item); } mc.displayGuiScreen(parent); parent.getModel().refresh(); } if (btn.equals(addButton)) { editCommand(-1); } if (btn.equals(editButton)) { editCommand(slot.getSelectedRow()); } if (btn.equals(removeButton)) { item.removeCommand(slot.getSelectedRow()); slot.updateItems(); updateButtons(); } }
public void doQuickJoin() { try { String adress = textQuickJoin.getText(); if (!adress.isEmpty()) { String split[] = adress.split(":"); String ip = split[0]; int port = split.length > 1 ? Integer.parseInt(split[1]) : 25565; SpoutClient.getHandle().gameSettings.lastServer = adress.replace(":", "_"); SpoutClient.getHandle().gameSettings.saveOptions(); SpoutClient.getInstance().getServerManager().join(ip, port, this, "Favorites"); } } catch (Exception e) { } }
@Override public void initGui() { Addon spoutcraft = SpoutClient.getInstance().getAddonManager().getAddon("spoutcraft"); title = new GenericLabel("Favorite Servers"); title.setX( width / 2 - SpoutClient.getHandle().fontRenderer.getStringWidth(title.getText()) / 2); title.setY(12); title .setHeight(15) .setWidth(SpoutClient.getHandle().fontRenderer.getStringWidth(title.getText()) / 2); getScreen().attachWidget(spoutcraft, title); buttonMoveUp = new GenericButton("/\\"); buttonMoveUp.setTooltip("Move Item Up"); buttonMoveUp.setX(5).setY(5); buttonMoveUp.setHeight(20).setWidth(20); getScreen().attachWidget(spoutcraft, buttonMoveUp); buttonMoveDown = new GenericButton("\\/"); buttonMoveDown.setTooltip("Move Item Down"); buttonMoveDown.setX(25).setY(5); buttonMoveDown.setHeight(20).setWidth(20); getScreen().attachWidget(spoutcraft, buttonMoveDown); buttonRefresh = new GenericButton("Refresh"); buttonRefresh.setHeight(20).setWidth(100).setX(width - 105).setY(5); getScreen().attachWidget(spoutcraft, buttonRefresh); view = new GenericListView(model); view.setX(5).setY(30).setWidth(width - 10).setHeight(height - 110); getScreen().attachWidget(spoutcraft, view); int top = (int) (view.getY() + view.getHeight() + 5); int totalWidth = Math.min(width - 9, 200 * 3 + 10); int cellWidth = (totalWidth - 10) / 3; int left = width / 2 - totalWidth / 2; int center = left + cellWidth + 5; int right = center + cellWidth + 5; String text = SpoutClient.getHandle().gameSettings.lastServer.replace("_", ":"); if (textQuickJoin != null) text = textQuickJoin.getText(); textQuickJoin = new GenericTextField(); textQuickJoin.setX(left + 2).setY(top + 2).setHeight(16).setWidth(cellWidth * 2 + 5 - 4); textQuickJoin.setMaximumCharacters(0); textQuickJoin.setText(text); getScreen().attachWidget(spoutcraft, textQuickJoin); buttonQuickJoin = new GenericButton("Quick Join"); buttonQuickJoin.setX(right).setY(top).setWidth(cellWidth).setHeight(20); getScreen().attachWidget(spoutcraft, buttonQuickJoin); top += 25; buttonJoin = new GenericButton("Join Server"); buttonJoin.setX(right).setY(top).setWidth(cellWidth).setHeight(20); getScreen().attachWidget(spoutcraft, buttonJoin); buttonAdd = new GenericButton("Add Favorite"); buttonAdd.setX(center).setY(top).setWidth(cellWidth).setHeight(20); getScreen().attachWidget(spoutcraft, buttonAdd); buttonEdit = new GenericButton("Edit"); buttonEdit.setX(left).setY(top).setWidth(cellWidth).setHeight(20); getScreen().attachWidget(spoutcraft, buttonEdit); top += 25; buttonDelete = new GenericButton("Delete"); buttonDelete.setX(left).setY(top).setWidth(cellWidth).setHeight(20); getScreen().attachWidget(spoutcraft, buttonDelete); buttonServerList = new GenericButton("Server List"); buttonServerList.setX(center).setY(top).setWidth(cellWidth).setHeight(20); getScreen().attachWidget(spoutcraft, buttonServerList); buttonMainMenu = new GenericButton("Main Menu"); buttonMainMenu.setX(right).setY(top).setWidth(cellWidth).setHeight(20); getScreen().attachWidget(spoutcraft, buttonMainMenu); updateButtons(); }
public void editCommand(int i) { item.setTitle(commandText.getText()); GuiEditCommand gui = new GuiEditCommand(this, i); mc.displayGuiScreen(gui); }