Пример #1
0
  protected void layoutWidgets() {
    int top = 5;

    int swidth = mc.fontRenderer.getStringWidth(labelTitle.getText());
    labelTitle.setY(top + 7).setX(width / 2 - swidth / 2).setHeight(11).setWidth(swidth);

    search.setX(5).setY(top).setWidth(150).setHeight(20);

    top += 25;

    int sheight = height - top - 55;

    filter.setX(5).setY(top).setWidth(130).setHeight(sheight);

    view.setX((int) (5 + filter.getX() + filter.getWidth()))
        .setY(top)
        .setWidth((int) (width - 15 - filter.getWidth()))
        .setHeight(sheight);

    int ftop = 5;
    checkVanilla.setX(5).setY(ftop).setWidth(100).setHeight(20);
    ftop += 25;
    checkSpoutcraft.setX(5).setY(ftop).setWidth(100).setHeight(20);
    ftop += 25;
    checkCustom.setX(5).setY(ftop).setWidth(100).setHeight(20);
    ftop += 25;
    checkShortcuts.setX(5).setY(ftop).setWidth(100).setHeight(20);

    for (Widget w : filter.getAttachedWidgets()) {
      w.setWidth(filter.getViewportSize(Orientation.HORIZONTAL) - 10);
    }
    search.setWidth((int) filter.getWidth());

    top += 5 + view.getHeight();

    int totalWidth = Math.min(width - 10, 200 * 3 + 10);
    int cellWidth = (totalWidth - 10) / 3;
    int left = width / 2 - totalWidth / 2;
    int center = left + 5 + cellWidth;
    int right = center + 5 + cellWidth;

    buttonAdd.setHeight(20).setWidth(cellWidth).setX(left).setY(top);

    buttonEdit.setHeight(20).setWidth(cellWidth).setX(center).setY(top);

    buttonRemove.setHeight(20).setWidth(cellWidth).setX(right).setY(top);

    top += 25;

    labelDescription.setHeight(20).setWidth(cellWidth * 2 + 5).setX(left).setY(top);
    labelDescription.recalculateLines();

    buttonDone.setHeight(20).setWidth(cellWidth).setX(right).setY(top);
  }
Пример #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();
  }