@Override
 public void actionPerformed(ActionEvent e) {
   Object s = e.getSource();
   if (s == Return) {
     MenuHandler.CloseMenu();
   } else if (s == Prev) {
     Game.edit.ChangePlayer(false);
   } else if (s == Next) {
     Game.edit.ChangePlayer(true);
   }
   for (int i = 0; i < Game.displayU.size(); i++) {
     if (s == Units[i]) {
       Game.edit.pick = engine.Editor.Type.UNIT;
       Game.edit.id = i;
       MenuHandler.CloseMenu();
     }
   }
   for (int i = 0; i < Game.displayB.size(); i++) {
     if (s == Cities[i]) {
       Game.edit.pick = engine.Editor.Type.CITY;
       Game.edit.id = i;
       MenuHandler.CloseMenu();
     }
   }
   for (int i = 0; i < Game.map.tiles.size(); i++) {
     if (s == Tiles[i]) {
       Game.edit.pick = engine.Editor.Type.TILE;
       Game.edit.id = i;
       MenuHandler.CloseMenu();
     }
   }
 }
  private void Show() {
    Game.gui.removeAll();
    Point size = MenuHandler.PrepMenu(260, 140);
    Prev.setBounds(size.x + 190, size.y + 100, 60, 24);
    Next.setBounds(size.x + 10, size.y + 100, 60, 24);
    Return.setBounds(size.x + 80, size.y + 100, 100, 24);

    if (Game.edit.owner > 0) {
      for (int i = 0; i < Game.displayU.size(); i++) {
        Units[i] = new JButton(ButtonImage(i, 0, Type.UNIT));
        Units[i].addActionListener(this);
        Units[i].setBounds(size.x + 10 + 32 * i, size.y + 10, 32, 32);
        Game.gui.add(Units[i]);
      }
    }
    for (int i = 0; i < Game.displayB.size(); i++) {
      Cities[i] = new JButton(ButtonImage(i, 0, Type.CITY));
      Cities[i].addActionListener(this);
      Cities[i].setBounds(size.x + 10 + 32 * i, size.y + 40, 32, 32);
      Game.gui.add(Cities[i]);
    }
    int use = 0; // Hack so people can't place cities.
    for (int i = 0; i < Game.map.tiles.size(); i++) {
      if (!Game.map.tiles.get(i).building()) {
        Tiles[i] =
            new JButton(ButtonImage(Game.map.tiles.get(i).x, Game.map.tiles.get(i).y, Type.TILE));
        Tiles[i].addActionListener(this);
        Tiles[i].setBounds(size.x + 10 + 32 * use, size.y + 70, 32, 32);
        Game.gui.add(Tiles[i]);
        use++;
      }
    }
    Game.gui.add(Prev);
    Game.gui.add(Next);
    Game.gui.add(Return);
  }
Пример #3
0
 public void fetchPackageInfo() {
   if (pkginfo == null && appinfo != null)
     pkginfo = MenuHandler.getPackageInfo(pm, appinfo.packageName);
 }