Beispiel #1
0
 public void deleteCurrentControl() {
   SimpleKeyBindingManager man =
       (SimpleKeyBindingManager) SpoutClient.getInstance().getKeyBindingManager();
   ControlsBasicItem item = model.getItem(view.getSelectedRow());
   ShortcutBindingItem sh = null;
   if (item != null && item instanceof ShortcutBindingItem) {
     sh = (ShortcutBindingItem) item;
   }
   KeyBindingItem binding = null;
   if (item != null && item instanceof KeyBindingItem) {
     binding = (KeyBindingItem) item;
   }
   if (sh != null) {
     man.unregisterShortcut(sh.getShortcut());
     man.save();
   } else if (binding != null) {
     man.unregisterControl(binding.getBinding());
     man.save();
     model.refresh();
   } else {
     item.setKey(-128);
   }
   model.refresh();
 }
Beispiel #2
0
  protected void createInstances() {
    labelTitle = new GenericLabel("Controls");
    buttonDone = new GenericButton("Done");
    buttonAdd = new GenericButton("Add Shortcut");
    buttonEdit = new GenericButton("Edit");
    buttonEdit.setTooltip("Edit Shortcut");
    buttonRemove = new DeleteControlButton(this);
    buttonRemove.setTooltip("Remove Shortcut");
    labelDescription = new GenericLabel();
    labelDescription.setText("Double-click an item, then press the key (combination).");
    labelDescription.setWrapLines(true);
    filter = new GenericScrollArea();
    view = new GenericListView(model);
    model.setCurrentGui(this);

    checkVanilla = new ControlsCheckBox(this, VANILLA_COLOR + "Minecraft Bindings");
    checkSpoutcraft = new ControlsCheckBox(this, SPOUTCRAFT_COLOR + "Spoutcraft Bindings");
    checkCustom = new ControlsCheckBox(this, CUSTOM_COLOR + "Custom Bindings");
    checkShortcuts = new ControlsCheckBox(this, SHORTCUTS_COLOR + "Shortcuts");
    search = new ControlsSearch(this);

    filter.attachWidget("Spoutcraft", checkVanilla);
    filter.attachWidget("Spoutcraft", checkSpoutcraft);
    filter.attachWidget("Spoutcraft", checkCustom);
    filter.attachWidget("Spoutcraft", checkShortcuts);

    getScreen().attachWidget("Spoutcraft", search);
    getScreen().attachWidget("Spoutcraft", labelTitle);
    getScreen().attachWidget("Spoutcraft", filter);
    getScreen().attachWidget("Spoutcraft", view);
    getScreen().attachWidget("Spoutcraft", buttonAdd);
    getScreen().attachWidget("Spoutcraft", buttonEdit);
    getScreen().attachWidget("Spoutcraft", buttonRemove);
    getScreen().attachWidget("Spoutcraft", buttonDone);
    getScreen().attachWidget("Spoutcraft", labelDescription);
    updateButtons();
    model.refresh();
  }