Beispiel #1
0
  private void setTheme(Theme theme) {
    if (theme == null) return;

    Sui.setTheme(theme);

    colors[0] = theme.getActiveTitleBar1();
    colors[1] = theme.getActiveTitleBar2();
    colors[2] = theme.getBackground();
    colors[3] = theme.getDisabledMask();
    colors[4] = theme.getForeground();
    colors[5] = theme.getPrimary1();
    colors[6] = theme.getPrimary2();
    colors[7] = theme.getPrimary3();
    colors[8] = theme.getPrimaryBorder1();
    colors[9] = theme.getPrimaryBorder2();
    colors[10] = theme.getSecondary1();
    colors[11] = theme.getSecondary2();
    colors[12] = theme.getSecondary3();
    colors[13] = theme.getSecondaryBorder1();
    colors[14] = theme.getSecondaryBorder2();
    colors[15] = theme.getTitleBar1();
    colors[16] = theme.getTitleBar2();

    for (int i = 0; i < labels.length; i++) {
      Color c = colors[i];
      labels[i].setBackground(new Color(c.r, c.g, c.b, c.a));
      methodNames[i].setBackground(theme.getBackground());
      methodNames[i].setForeground(theme.getForeground());
    }
    nameLabel.setForeground(theme.getForeground());
    nameLabel.setText(theme.getName());

    Sui.updateComponentTreeTheme(display);
  }
Beispiel #2
0
  public Creature(Position pos, Map world) {

    setMoving(5);
    attacked = false;
    setTarget(null);
    setTile(world.tileAt(pos));
    getTile().setC(this);
    this.setPos(pos);
    this.world = world;

    setHp(DEF_HP);
    setMp(DEF_MP);
    setMaxhp(DEF_HP);
    setMaxmp(DEF_MP);
    setSpeed(DEF_SPEED);

    setActive(false);
    setDead(false);

    damageTaken = new Label("");
    damageTaken.setForeground(Color.red);

    healTaken = new Label("");
    healTaken.setForeground(Color.green);
  }
Beispiel #3
0
    public void init(GameContainer container, StateBasedGame game) throws SlickException {
      indv = new Display(container);
      indv.setSendingGlobalEvents(false);

      final Frame win1 = new Frame("State 2");
      win1.setBounds(200, 205, 200, 100);
      win1.setVisible(true);
      win1.setResizable(false);
      indvWindows.add(win1);
      indv.add(win1);

      ToggleButton button = new ToggleButton("Click");
      button.pack();
      button.setLocation(200, 150);
      button.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              win1.setResizable(!win1.isResizable());
            }
          });
      indv.add(button);

      Label label = new Label("Use the button to toggle window resizing.");
      label.pack();
      label.setLocation(button.getX(), button.getY() - label.getHeight() - 5);
      label.setOpaque(true);
      label.setBackground(new Color(1f, 1f, 1f, 0.85f));

      indv.add(label);
    }
Beispiel #4
0
  public void takeDamage(int dmg) {
    // battle text points
    damageTaken.setText("-" + Integer.toString(dmg));
    damageTaken.pack();
    deltaDamage = show_damage_time;

    int x = getPos().getX() - targeted.getPos().getX();
    int y = getPos().getY() - targeted.getPos().getY();

    int center_x = 7 * 50 + 10;
    int center_y = 5 * 50 + 10;
    x = center_x + x * 50 + 30;
    y = center_y + y * 50 + 10;

    damageTaken.setLocation(x, y);

    this.hp -= dmg;
    if (this.hp < 1) {
      this.hp = 0;
      setDead(true);
    }
  }
Beispiel #5
0
  public void init(GameContainer container) throws SlickException {
    // Sui.setSkin(new WireframeSkin());
    display = new Display(container);
    display.setSendingGlobalEvents(false);
    display.setFocusable(true);

    // setup method names
    Method[] m = Theme.class.getMethods();
    Arrays.sort(
        m,
        new Comparator() {
          public int compare(Object o1, Object o2) {
            return ((Method) o1).getName().compareTo(((Method) o2).getName());
          }
        });
    ArrayList list = new ArrayList(COLORS);
    for (int i = 0; i < m.length; i++) {
      String nameStr = m[i].getName();
      if (nameStr.indexOf("getName") == -1) list.add(nameStr);
    }
    methods = (String[]) list.toArray(new String[list.size()]);

    // dump names
    // for (int i=0;i<methods.length;i++) {
    //    System.out.println("private color
    // "+Character.toLowerCase(methods[i].charAt(3))+methods[i].substring(4)+" =");
    // }

    // dump methods
    // for (int i=0;i<methods.length;i++) {
    //    String var = Character.toLowerCase(methods[i].charAt(3))+methods[i].substring(4);
    //    System.out.println("public Color "+methods[i]+"() { return "+var+"; }");
    // }

    class BorderLabel extends Label {
      public void renderComponent(GUIContext c, Graphics g) {
        super.renderComponent(c, g);
        g.setColor(Color.darkGray);
        g.draw(this.getAbsoluteBounds());
      }
    };

    float startx = 280;
    float starty = 70;

    Container parent = display;
    for (int i = 0; i < labels.length; i++) {
      methodNames[i] = new BorderLabel();
      methodNames[i].setText(methods[i]);
      methodNames[i].setSize(155, 25);
      methodNames[i].setOpaque(true);
      methodNames[i].setLocation(startx, starty + i * (methodNames[i].getHeight() + 5));
      parent.add(methodNames[i]);

      labels[i] = new BorderLabel();
      labels[i].setOpaque(true);
      labels[i].setSize(65, 25);
      labels[i].setLocation(
          startx + methodNames[i].getWidth() + 5, starty + i * (labels[i].getHeight() + 5));
      parent.add(labels[i]);
    }

    Container panel = new Container();

    left = new Button("Previous");
    left.pack();
    left.setRequestFocusEnabled(false);
    left.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (currentIndex > 0) {
              currentIndex--;
              setTheme((Theme) themes.get(currentIndex));
              updateButtons();
            }
          }
        });
    panel.add(left);

    right = new Button("Next");
    right.pack();
    right.setRequestFocusEnabled(false);
    right.setX(left.getWidth() + 5);
    right.setHeight(left.getHeight());
    right.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (currentIndex < themes.size() - 1) {
              currentIndex++;
              setTheme((Theme) themes.get(currentIndex));
              updateButtons();
            }
          }
        });
    panel.add(right);

    panel.setSize(right.getX() + right.getWidth(), left.getHeight());
    panel.setLocationRelativeTo(display);
    panel.setY(starty - panel.getHeight() - 5);
    display.add(panel);

    nameLabel = new Label("No themes found.");
    nameLabel.pack();
    nameLabel.setLocationRelativeTo(display);
    nameLabel.setY(panel.getY() - nameLabel.getHeight() - 5);
    display.add(nameLabel);

    final CheckBox box = new CheckBox("Show Demo Box");

    demoBox = new DemoFrame();
    demoBox.setLocation(50, 100);
    demoBox
        .getCloseButton()
        .addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                box.setSelected(false);
              }
            });
    display.add(demoBox);

    box.pack();
    box.setX(demoBox.getX());
    box.setY(demoBox.getY() - box.getHeight() - 5);
    box.setSelected(true);
    box.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            demoBox.setVisible(box.isSelected());
          }
        });
    box.setRequestFocusEnabled(false);
    display.add(box);

    if (Sui.getSkin() instanceof SimpleSkin) {
      final CheckBox roundBox = new CheckBox("Round Rectangles");
      roundBox.pack();
      roundBox.setSelected(true);
      SimpleSkin.setRoundRectanglesEnabled(roundBox.isSelected());

      roundBox.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              SimpleSkin.setRoundRectanglesEnabled(roundBox.isSelected());
            }
          });

      box.setWidth(Math.max(roundBox.getWidth(), box.getWidth()));
      roundBox.setWidth(Math.max(roundBox.getWidth(), box.getWidth()));
      roundBox.setLocation(box.getX(), box.getY() - roundBox.getHeight() - 5);
      roundBox.setRequestFocusEnabled(false);
      display.add(roundBox);
    }

    // load up the themes
    populateThemes();

    if (!themes.isEmpty()) {
      setTheme((Theme) themes.get(0));
    }
    updateButtons();
  }
Beispiel #6
0
 public void renderComponent(GUIContext c, Graphics g) {
   super.renderComponent(c, g);
   g.setColor(Color.darkGray);
   g.draw(this.getAbsoluteBounds());
 }
Beispiel #7
0
 public void animateBT() {
   float x = damageTaken.getAbsoluteX();
   float y = damageTaken.getAbsoluteY();
   damageTaken.setLocation(x, y - deltaDamage / 500);
 }