@Override
 public int getPreferredHeight() {
   int totalheight = verticalPadding;
   for (int i = 0; i < getNumChildren(); ++i) {
     Widget widget = getChild(i);
     int height = childDefaultHeight;
     if (!overrideHeight) {
       height = widget.getPreferredHeight();
     }
     if (heightOverrideExceptions.containsKey(widget)) {
       Integer heightSet = heightOverrideExceptions.get(widget);
       if (heightSet < 1) {
         height = widget.getPreferredHeight();
         heightSet = -heightSet;
         if ((heightSet != 0) && (heightSet > height)) {
           height = heightSet;
         }
       } else {
         height = heightSet;
       }
     }
     totalheight += height + defaultPadding;
   }
   return totalheight;
 }
Example #2
0
 /** convenience text setting adder */
 public SettingText addSetting(Widget w2, String nicename, String backendname, String value) {
   SettingText s = new SettingText(backendname, value);
   WidgetText w = new WidgetText(s, nicename);
   w2.add(w);
   append(s);
   return s;
 }
Example #3
0
 /** convenience key setting adder */
 public SettingKey addSetting(Widget w2, String nicename, String backendname, int value) {
   SettingKey s = new SettingKey(backendname, value);
   WidgetKeybinding w = new WidgetKeybinding(s, nicename);
   w2.add(w);
   append(s);
   return s;
 }
Example #4
0
 /** convenience float setting adder */
 public SettingFloat addSetting(Widget w2, String nicename, String backendname, float value) {
   SettingFloat s = new SettingFloat(backendname, value);
   WidgetFloat w = new WidgetFloat(s, nicename);
   w2.add(w);
   append(s);
   return s;
 }
Example #5
0
 /** convenience boolean setting adder */
 public SettingBoolean addSetting(Widget w2, String nicename, String backendname, boolean value) {
   SettingBoolean s = new SettingBoolean(backendname, value);
   WidgetBoolean w = new WidgetBoolean(s, nicename);
   w2.add(w);
   append(s);
   return s;
 }
Example #6
0
  /**
   * Create a new CreatureDetailsWindow displaying details for the specified Creature.
   *
   * @param creature the Creature to show details for
   */
  public CreatureDetailsWindow(Creature creature) {
    this.creature = creature;
    creature.addViewer(this);

    this.setSize(280, 300);
    this.setTitle("Details for " + creature.getTemplate().getName());

    DialogLayout layout = new DialogLayout();
    layout.setTheme("content");
    this.add(layout);

    // set up the widgets for the top row
    Widget viewer = new Viewer();
    viewer.setTheme("iconviewer");
    Label title = new Label(creature.getTemplate().getName());
    title.setTheme("titlelabel");

    DialogLayout.Group topRowV = layout.createParallelGroup(viewer, title);

    DialogLayout.Group topRowH = layout.createSequentialGroup(viewer);
    topRowH.addGap(10);
    topRowH.addWidget(title);
    topRowH.addGap(10);

    // create widgets for details text area
    textAreaModel = new HTMLTextAreaModel();
    TextArea textArea = new TextArea(textAreaModel);
    ScrollPane textPane = new ScrollPane(textArea);
    textPane.setFixed(ScrollPane.Fixed.HORIZONTAL);
    textPane.setTheme("detailspane");

    // set the main top level layout
    Group mainGroupV = layout.createSequentialGroup();
    mainGroupV.addGroup(topRowV);
    mainGroupV.addGap(5);
    mainGroupV.addWidget(textPane);

    Group mainGroupH = layout.createParallelGroup();
    mainGroupH.addGroup(topRowH);
    mainGroupH.addWidget(textPane);

    layout.setHorizontalGroup(mainGroupH);
    layout.setVerticalGroup(mainGroupV);

    entityUpdated(creature);
  }
Example #7
0
 /** convenience multi setting adder */
 public SettingMulti addSetting(
     Widget w2, String nicename, String backendname, int value, String... labels) {
   SettingMulti s = new SettingMulti(backendname, value, labels);
   WidgetMulti w = new WidgetMulti(s, nicename);
   w2.add(w);
   append(s);
   return s;
 }
Example #8
0
 /** convenience int setting adder */
 public SettingInt addSetting(
     Widget w2, String nicename, String backendname, int value, int min, int step, int max) {
   SettingInt s = new SettingInt(backendname, value, min, step, max);
   WidgetInt w = new WidgetInt(s, nicename);
   w2.add(w);
   append(s);
   return s;
 }
Example #9
0
 private void addTestAlert(int x, int y, String text) {
   Alert alert = new Alert(text);
   alert.addButton("OK");
   alert.addButton("Cancel");
   alert.setPosition(x, y);
   root.add(alert);
   alert.adjustSize();
 }
Example #10
0
  /** convenience list setting adder */
  public SettingList addSetting(Widget w2, String nicename, String backendname, String... options) {

    ArrayList<String> arrayList = new ArrayList<String>();

    for (int i = 0; i < options.length; i++) {
      arrayList.add(options[i]);
    }

    SettingList s = new SettingList(backendname, arrayList);
    WidgetList w = new WidgetList(s, nicename);
    w2.add(w);
    append(s);
    return s;
  }
Example #11
0
  public TwlTest() throws Exception {
    renderer = new LWJGLRenderer();

    theme =
        ThemeManager.createThemeManager(SimpleTest.class.getResource("simple_demo.xml"), renderer);

    root = new Widget();
    root.setTheme("");

    gui = new GUI(root, renderer);
    gui.setSize();
    gui.applyTheme(theme);

    addTestAlert(10, 10, "&lt;minwidth");

    addTestAlert(10, 100, "Between min and max width");

    addTestAlert(
        10,
        180,
        "Past max width but less than max height. "
            + "This is a lot of text. This is a lot of text. This is a lot of text. This is a lot of text. "
            + "This is a lot of text. This is a lot of text. This is a lot of text. This is a lot of text. "
            + "This is a lot of text. This is a lot of text. This is a lot of text. This is a lot of text. "
            + "This is a lot of text. This is a lot of text. This is a lot of text. This is a lot of text. "
            + "This is a lot of text. This is a lot of text. This is a lot of text. This is a lot of text. ");

    addTestAlert(
        10,
        350,
        "Past max width and past max height. "
            + "This is a lot of text. This is a lot of text. This is a lot of text. This is a lot of text. "
            + "This is a lot of text. This is a lot of text. This is a lot of text. This is a lot of text. "
            + "This is a lot of text. This is a lot of text. This is a lot of text. This is a lot of text. "
            + "This is a lot of text. This is a lot of text. This is a lot of text. This is a lot of text. "
            + "This is a lot of text. This is a lot of text. This is a lot of text. This is a lot of text. "
            + "This is a lot of text. This is a lot of text. This is a lot of text. This is a lot of text. "
            + "This is a lot of text. This is a lot of text. This is a lot of text. This is a lot of text. "
            + "This is a lot of text. This is a lot of text. This is a lot of text. This is a lot of text. "
            + "This is a lot of text. This is a lot of text. This is a lot of text. This is a lot of text. "
            + "This is a lot of text. This is a lot of text. This is a lot of text. This is a lot of text. ");
  }
 public void layout(Widget widget, boolean visible) {
   if (label != null) {
     if (label.getParent() != widget) {
       System.out.println("Adding widget Label");
       widget.add(label);
     }
     if (visible) {
       // adjust this to account for view location
       Vector2D labelLocation =
           Vector2D.subtract(
               getLocation(), -Main.viewLocation.x, (Main.viewLocation.y - Main.SCREEN_HEIGHT));
       //                Vector2D labelLocation = Vector2D.subtract( Main.viewLocation,
       // getLocation());
       label.setPosition((int) labelLocation.x, (int) labelLocation.y);
       label.setText(name);
       label.adjustSize();
     }
     label.setVisible(visible);
   }
 }
Example #13
0
  @Override
  public void layout() {
    int totalheight = verticalPadding;
    for (int i = 0; i < getNumChildren(); ++i) {
      Widget w = getChild(i);
      int height = childDefaultHeight;
      int width = childDefaultWidth;
      if (!overrideHeight) {
        height = w.getPreferredHeight();
      }
      if (heightOverrideExceptions.containsKey(w)) {
        Integer heightSet = heightOverrideExceptions.get(w);
        if (heightSet < 1) {
          height = w.getPreferredHeight();
          heightSet = -heightSet;
          if ((heightSet != 0) && (heightSet > height)) {
            height = heightSet;
          }
        } else {
          height = heightSet;
        }
      }
      if (widthOverrideExceptions.containsKey(w)) {
        Integer widthSet = widthOverrideExceptions.get(w);

        if (widthSet < 1) {
          width = w.getPreferredWidth();
          widthSet = -widthSet;
          if ((widthSet != 0) && (widthSet > width)) {
            width = widthSet;
          }
        } else {
          width = widthSet;
        }
      }
      w.setSize(width, height);
      w.setPosition((getX() + (getWidth() / 2)) - (width / 2), getY() + totalheight);
      totalheight += height + defaultPadding;
    }
  }
Example #14
0
    @Override
    protected void paintWidget(GUI gui) {
      super.paintWidget(gui);

      creature.uiDraw(getInnerX(), getInnerY());
    }
Example #15
0
 @Override
 protected void applyTheme(ThemeInfo themeInfo) {
   super.applyTheme(themeInfo);
   icons = themeInfo.getParameterMap("icons");
   findIcon();
 }