Esempio n. 1
0
  public StructureDialog(
      String id,
      String title,
      String message,
      Image picture,
      int picWidth,
      int picHeight,
      boolean upgradeButton) {

    TrueTypeFont ttf = Config.getFont1();

    this.status = WindowStatus.ACTIVE;
    this.id = id;
    this.title = title;
    this.message = message;
    this.width = ttf.getWidth(message) + 40;
    this.height = ttf.getHeight() + 60;
    this.x = (Config.getScreenWidth() - width) / 2;
    this.y = (Config.getScreenHeight() - height) / 2;
    this.picWidth = picWidth;
    this.picHeight = picHeight;
    this.picture = picture;

    widgetList = new ArrayList<Widget>();

    // TODO: Add title to the dialog window
    addWidget(new Panel(id, 0, 0, width, height, true));

    addWidget(new PictureBox(id, 10, 10, picWidth, picHeight, picture));
    addWidget(
        new Label(id, width / 2 - ttf.getWidth(message) / 2 + 10 + picWidth + 10, 15, message));

    if (upgradeButton) {
      addWidget(new Button(id, width / 2 - 115, height - 30, "Upgrade", "Upgrade"));
      addWidget(new Button(id, width / 2 + 7, height - 30, "Close", "Close"));
    } else {
      addWidget(new Button(id, width / 2 - 54, height - 30, "Close", "Close"));
    }
  }
Esempio n. 2
0
  public StructureDialog(
      String id,
      String title,
      String message,
      int width,
      int height,
      Image picture,
      int picWidth,
      int picHeight,
      boolean upgradeButton) {
    this.status = WindowStatus.ACTIVE;
    this.id = id;
    this.title = title;
    this.message = message;
    this.width = width;
    this.height = height;
    this.x = (Config.getScreenWidth() - width) / 2;
    this.y = (Config.getScreenHeight() - height) / 2;
    this.picWidth = picWidth;
    this.picHeight = picHeight;
    this.picture = picture;

    widgetList = new ArrayList<Widget>();

    // TODO: Add title to the dialog window
    addWidget(new Panel(id, 0, 0, width, height, true));
    addWidget(new PictureBox(id, 10, 10, picWidth, picHeight, picture));
    TrueTypeFont ttf = Config.getFont1();

    ArrayList<Integer> breaks = new ArrayList<Integer>();

    // Parse the text
    for (int i = 0; i < message.length(); i++) {
      if (message.charAt(i) == '/') {
        if (message.charAt(i + 1) == 'n') {
          breaks.add(i);
        }
      }
    }

    ArrayList<String> lines = new ArrayList<String>();
    int lastIndex = 0;
    for (Integer breakIndex : breaks) {
      lines.add(message.substring(lastIndex, breakIndex));
      lastIndex = breakIndex + 2;
    }
    lines.add(message.substring(lastIndex));

    int top = 10;
    for (String line : lines) {
      addWidget(new Label(id, 20 + picWidth, top, line));
      top += 18;
    }

    if (upgradeButton) {
      addWidget(new Button(id, width / 2 - 115, height - 30, "Upgrade", "Upgrade"));
      addWidget(new Button(id, width / 2 + 7, height - 30, "Close", "Close"));
    } else {
      addWidget(new Button(id, width / 2 - 54, height - 30, "Close", "Close"));
    }
  }