Example #1
0
 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();
   }
 }
Example #2
0
  @Override
  protected void buttonClicked(Button btn) {
    if (btn.equals(buttonDone)) {
      mc.displayGuiScreen(parentScreen);
      return;
    }

    if (btn.equals(buttonAdd)) {
      Shortcut sh = new Shortcut();
      sh.setTitle("");
      sh.setKey(Keyboard.KEY_UNKNOWN.getKeyCode());
      editItem(sh);
      return;
    }
    ControlsBasicItem item = model.getItem(view.getSelectedRow());
    ShortcutBindingItem sh = null;
    if (item != null && item instanceof ShortcutBindingItem) {
      sh = (ShortcutBindingItem) item;
    }
    if (sh != null && btn.equals(buttonEdit)) {
      editItem(sh.getShortcut());
    } else if (btn.equals(buttonEdit) && item != null) {
      model.setEditing(item);
    }
  }
Example #3
0
 private void updateRecordButton() {
   String keyname = recording ? "Press a key!" : "Click Here!";
   if (item.getKey() >= 0 && !recording) {
     keyname = item.toString();
   }
   String name = (recording ? "> " : "") + keyname + (recording ? " <" : "");
   recordButton.setText(name);
 }
Example #4
0
 protected void keyTyped(char c, int i) {
   if (recording && !SimpleKeyBindingManager.isModifierKey(i)) {
     item.setKey(i);
     item.setRawModifiers((byte) 0);
     SimpleKeyBindingManager.setModifiersToShortcut(item);
     recording = false;
     updateRecordButton();
   } else {
     super.keyTyped(c, i);
   }
 }
Example #5
0
  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();
  }
Example #6
0
 public void updateItems() {
   clear();
   for (String cmd : shortcut.getCommands()) {
     addItem(new CommandLWI(cmd));
   }
 }
Example #7
0
 public void editCommand(int i) {
   item.setTitle(commandText.getText());
   GuiEditCommand gui = new GuiEditCommand(this, i);
   mc.displayGuiScreen(gui);
 }