예제 #1
0
  @Override
  public void onCreate() {

    String adding[] = {
      "Zurueck", "Game-Settings", "Steuerrung", "Audio", "Video", "Hauptmenue", "Beenden"
    };

    int Wwidth = getScreenFactory().getGame().getWindow().getWidth();
    int Wheight = getScreenFactory().getGame().getWindow().getHeight();
    int width = Wwidth / 5;
    int height = Wheight * 2 / 5;

    Panel p = new Panel(Wwidth / 2 - width / 2, Wheight / 2 - height / 2, width, height);
    p.setLayout(new GridLayout(adding.length, 1, p));
    for (String toadd : adding) {

      Button newb = new Button(toadd, true, false);
      newb.addActionListener(this);
      p.addElement(newb);
    }

    Button placeholder = new Button(0, 0, Wwidth, Wheight, "", false, false);
    placeholder.setImage(null);
    placeholder.setBackgroundColor(new Color(0, 0, 0, 0.5f));
    addGuiElement(placeholder);

    addGuiElement(p);
  }
예제 #2
0
  @Override
  public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand() == null) {
      return;
    }
    switch (e.getActionCommand()) { // name of the button
        // MainSettings
      case "Zurueck":
        if (subpanel != null) {
          rmGuiElement(subpanel);
          subpanel = null;
          break;
        }
        this.getScreenFactory().activeScreen(prevscreen);
        break;
      case "Audio":
        String adding[] = {"Zurueck", "Ton"};

        int Wwidth = getScreenFactory().getGame().getWindow().getWidth();
        int Wheight = getScreenFactory().getGame().getWindow().getHeight();
        int width = Wwidth / 5;
        int height = Wheight * 2 / 5;
        subpanel = new Panel(Wwidth / 2 + width / 2, Wheight / 2 - height / 2, width, height);
        subpanel.setLayout(new GridLayout(adding.length, 1, subpanel));
        for (String toadd : adding) {
          Button newb = new Button(toadd, true, false);
          newb.addActionListener(this);
          subpanel.addElement(newb);
        }
        addGuiElement(subpanel);
        break;

      case "WorldEditor":
        this.getScreenFactory().createScreen(new WorldEditor(this.getScreenFactory()));
        break;
      case "Hauptmenue":
        this.getScreenFactory().createScreen(new MainScreen(this.getScreenFactory()));
        break;
      case "Beenden":
        System.exit(0);
        break;
      case "Steuerrung":
        this.getScreenFactory().createScreen(new ControlScreen(this.getScreenFactory(), this));
        break;
        // GameSettings:

        // Sound:
      case "Ton":
        Game.getSetting().switchValue("cl_s_sound");
        getScreenFactory().getGame().needSound(Game.getSetting().getValueBool("cl_s_sound"));
        break;
        // Video:

      default:
        System.out.println("Unknown ActionEvent: " + e.getActionCommand());
        break;
    }
  }