示例#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;
    }
  }
示例#3
0
 @Override
 public void onUpdate() {
   KeyboardListener kbl = this.getScreenFactory().getGame().getKeyboardListener();
   if (kbl.isOnPress("btn_ESC") && tickcounter == 0) // ESC button
   {
     Button b = new Button("Zurueck", false, false);
     b.addActionListener(this);
     b.callActions();
   }
   if (tickcounter != 0) {
     tickcounter--;
   }
   super.onUpdate(); // updating Gui Elements
 }
示例#4
0
 public static void update() {
   if (update) {
     Sound.random("random", 1f, "OGG", "res/sound/music", 11);
     GUI.Background.draw("dirt");
     Text.draw("SETTINGS", GUI.Coordinates.x / 2 - 94, GUI.Coordinates.y / 4 * 3, 6, Color.white);
     GUI.Button.draw(
         "Music",
         GUIScale.toUpperCase(),
         GUI.Coordinates.x / 2 - 94,
         GUI.Coordinates.y / 2,
         1,
         1,
         "planks_oak",
         2,
         128);
     if (Button.isButtonClicked("Music")) {
       if (GUIScale.length() == 6) {
         GUIScale = "Auto";
         Create.createFile("Settings/GUIScale");
         Create.write("Auto");
         Create.closeFile();
       } else {
         GUIScale = "Normal";
         Create.createFile("Settings/GUIScale");
         Create.write("Normal");
         Create.closeFile();
         game.Main.Sleep(256);
       }
     }
   }
 }