Пример #1
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;
    }
  }
Пример #2
0
public abstract class RenderLayer {

  boolean isRendering = true;

  protected Graphics2D draw;
  protected Canvas screen = Game.getGraphics();

  public RenderLayer() {
    // this.draw=draw;
  }

  public Graphics2D getGraphics() {
    return draw;
  }

  public abstract void renderThisLayer();

  public void setIsRendering(boolean render) {
    this.isRendering = render;
  }

  public boolean isRendering() {

    return isRendering;
  }

  public void setDraw(Graphics2D d) {

    draw = d;
  }
}