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();
   }
 }
Beispiel #2
0
 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) {
   }
 }
Beispiel #3
0
  @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);
 }