Пример #1
0
 @SuppressWarnings("unused")
 public void mouseClicked(int button, int x, int y, int clickCount) {
   if ((x >= NEWGAME_X && x <= (NEWGAME_X + newGameImage.getWidth()))
       && (y >= NEWGAME_Y && y <= (NEWGAME_Y + newGameImage.getHeight()))) {
     selection = Game.NEWGAME_STATE;
   } else if ((x >= LOADGAME_X && x <= (LOADGAME_X + loadGameImage.getWidth()))
       && (y >= LOADGAME_Y && y <= (LOADGAME_Y + loadGameImage.getHeight()))) {
     selection = Game.LOADGAME_STATE;
   } else if (optionsActivated
       && (x >= OPTIONS_X && x <= (OPTIONS_X + optionsImage.getWidth()))
       && (y >= OPTIONS_Y && y <= (OPTIONS_Y + optionsImage.getHeight()))) {
     selection = Game.OPTIONSGAME_STATE;
   } else {
     int id = Save.getInstance().levelIdForPoint(x - MAP_X, y - MAP_Y);
     if (id > -1 && Save.getInstance().hasSaveLoaded()) {
       if (!Save.getInstance().hasUnlockedLevelWithID(id)) {
         mapErrorLabel.setText("Niveau pas encore debloque!");
       } else {
         selection = Game.GAMEPLAY_STATE;
         levelSelection = id;
         mapErrorLabel.setText("");
       }
     }
   }
 }
Пример #2
0
  @Override
  public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
    // Images
    backgroundImage = Global.setImage("papyrus_page.png");
    backgroundImage.rotate(90);
    mapImage = Global.setImage("scroll_background_page_horizontal.png");
    mapLvlDefaultImage = Global.setImage("bloque_niveau.png");
    mapLvlUnlockedImage = Global.setImage("debut_niveau.png");
    mapLvlUnlockedFinishedImage = Global.setImage("fin_niveau.png");
    mapLvlFinishedImage = Global.setImage("fin_niveau.png");

    // Labels
    newGameImage = Global.setImage("main_menu_nouvelle_partie.png");
    newGameImage =
        newGameImage.getScaledCopy(
            (int) (newGameImage.getWidth() * SCALE_DOWN_W), newGameImage.getHeight());

    loadGameImage = Global.setImage("main_menu_charger_partie.png");
    loadGameImage =
        loadGameImage.getScaledCopy(
            (int) (loadGameImage.getWidth() * SCALE_DOWN_W), loadGameImage.getHeight());

    if (optionsActivated) {
      optionsImage = Global.setImage("main_menu_options.png");
      optionsImage =
          optionsImage.getScaledCopy(
              (int) (optionsImage.getWidth() * SCALE_DOWN_W), optionsImage.getHeight());
    }

    titleImage = Global.setImage("main_menu_title.png");
    titleImage =
        titleImage.getScaledCopy(
            (int) (titleImage.getWidth() * SCALE_DOWN_W * 1.5), titleImage.getHeight());

    display = new Display(gc);
    Image labelImage = Global.setImage(Global.BUTTON_STANDARD_IMAGE);
    Image playerImage = labelImage.getScaledCopy(150, 25);
    mapErrorLabel = new Label(playerImage, "");
    mapErrorLabel.setForeground(Color.red);
    mapErrorLabel.setBounds(800 - ERROR_X - ERROR_W, ERROR_Y, ERROR_W, ERROR_H);
    mapErrorLabel.pack();
    this.display.add(mapErrorLabel);
    mapErrorLabel.setImage(null);
  }
Пример #3
0
  /**
   * Displays client version (ThinClient Version) based on rev.txt If rev.txt is not found, ? is
   * displayed
   */
  private void setClientRevision() {
    String path = System.getProperty("res.path");
    if (path == null || path.equalsIgnoreCase("NULL")) {
      path = "./";
    }
    File f = new File(path + "/.svn/entries");

    try {
      if (f.exists()) {
        Scanner s = new Scanner(f);
        s.nextLine();
        s.nextLine();
        s.nextLine();

        m_clientRev = new Label("Client Version: svn:" + s.nextLine());
        f = new File(path + "rev.txt");
        s = new Scanner(f);
        m_clientRev.setText(m_clientRev.getText() + " // rev:" + s.nextLine());

      } else {
        f = new File(path + "rev.txt");
        Scanner s;
        s = new Scanner(f);

        m_clientRev = new Label("Client Version: r" + s.nextLine());
      }
    } catch (Exception e) {
      System.out.println(e.getMessage());
      m_clientRev = new Label("Client Version: ?");
    }

    m_clientRev.setFont(GameClient.getFontSmall());
    m_clientRev.setForeground(new Color(255, 255, 255));
    m_clientRev.pack();
    m_clientRev.setLocation(4, 600 - m_clientRev.getHeight() - 8);
    this.add(m_clientRev);
  }
Пример #4
0
  public UIDeath(GameContainer gc) {
    this.backgroundTransparency = 0.7f;
    this.menuBackgroundTransparency = 0.3f;
    this.display = new Display(gc);

    // Background image
    this.menuBackgroundImage = Global.setImage("1770925_s.jpg");

    // You lost label
    Image gameOverImage =
        Global.setImage("blur11.jpg").getScaledCopy(DEATH_W - 2 * BUTTON_SPACE, BUTTON_H);
    Label gameOver = new Label(gameOverImage, "Vous etes morts!\n");
    gameOver.setBounds(
        BUTTON_X, DEATH_Y + DEATH_H / 3 - BUTTON_H, DEATH_W - 2 * BUTTON_SPACE, BUTTON_H);
    gameOver.setForeground(Color.black);
    gameOver.pack();
    this.display.add(gameOver);
    gameOver.setImage(null);

    // Restart button //TODO: Button
    Image buttonImage = Global.setImage("blur11.jpg").getScaledCopy(BUTTON_W, BUTTON_H);
    Label restartLabel = new Label(buttonImage, "Recommencer");
    restartLabel.setBounds(BUTTON_X, BUTTON_Y, BUTTON_W, BUTTON_H);
    restartLabel.pack();
    this.display.add(restartLabel);

    // Back button //TODO: Button
    Label backToMenuLabel = new Label(buttonImage, "Menu principal");
    backToMenuLabel.setBounds(BUTTON_X + BUTTON_W + BUTTON_SPACE, BUTTON_Y, BUTTON_W, BUTTON_H);
    backToMenuLabel.pack();
    this.display.add(backToMenuLabel);
  }
Пример #5
0
  /** Default constructor */
  public LoginScreen() {
    String respath = System.getProperty("res.path");
    if (respath == null) respath = "";
    try {
      InputStream f;
      //			m_bgColor = new Color(255, 255, 255, 70);
      List<String> translated = new ArrayList<String>();
      translated = Translator.translate("_LOGIN");
      /*
       * Load the background image
       * NOTE: Months start at 0, not 1
       */
      Calendar cal = Calendar.getInstance();
      if (cal.get(Calendar.MONTH) == 1) {
        if (cal.get(Calendar.DAY_OF_MONTH) >= 7 && cal.get(Calendar.DAY_OF_MONTH) <= 14) {
          /* Valentines day! */
          f = new FileInputStream(respath + "res/pokenet_valentines.png");
        } else {
          f = new FileInputStream(respath + "res/pokenet_venonat.png");
        }
      } else if (cal.get(Calendar.MONTH) == 2 && cal.get(Calendar.DAY_OF_MONTH) > 14) {
        /* If second half of March, show Easter login */
        f = new FileInputStream(respath + "res/pokenet_easter.png");
      } else if (cal.get(Calendar.MONTH) == 3 && cal.get(Calendar.DAY_OF_MONTH) < 26) {
        /* If before April 26, show Easter login */
        f = new FileInputStream(respath + "res/pokenet_easter.png");
      } else if (cal.get(Calendar.MONTH) == 9) {
        /* Halloween */
        f = new FileInputStream(respath + "res/pokenet_halloween.png");
      } else if (cal.get(Calendar.MONTH) == 11) {
        /* Christmas! */
        f = new FileInputStream(respath + "res/pokenet_xmas.png");
      } else if (cal.get(Calendar.MONTH) == 0) {
        /* January - Venonat Time! */
        f = new FileInputStream(respath + "res/pokenet_venonat.png");
      } else if (cal.get(Calendar.MONTH) >= 5 && cal.get(Calendar.MONTH) <= 7) {
        /* Summer login */
        f = new FileInputStream(respath + "res/pokenet_summer.png");
      } else {
        /* Show normal login screen */
        f = new FileInputStream(respath + "res/pokenet_normal.png");
      }
      m_bg = new Label(new Image(f, "bg", false));
      m_bg.pack();
      m_bg.setLocation(0, 0);
      m_bg.setVisible(true);
      this.add(m_bg);

      /*
       * Create the server selector container
       */
      m_select = new ServerDialog();
      this.add(m_select);
      /*
       * Create the language selector container
       */
      m_lang = new LanguageDialog();
      this.add(m_lang);

      /*
       * Create the login container
       */
      m_login = new LoginDialog();
      this.add(m_login);

      m_register = new RegisterDialog();
      this.add(m_register);

      m_about = new AboutDialog();
      this.add(m_about);

      m_terms = new ToSDialog();
      this.add(m_terms);

      m_openAbout = new Button(translated.get(3));
      m_openAbout.setSize(64, 32);
      m_openAbout.setLocation(800 - 64 - 8, 8);
      m_openAbout.setVisible(false);
      m_openAbout.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
              showAbout();
            }
          });
      this.add(m_openAbout);

      m_openToS = new Button(translated.get(4));
      m_openToS.setSize(64, 32);
      m_openToS.setLocation(800 - 64 - 8, 40);
      m_openToS.setVisible(false);
      m_openToS.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
              showToS();
            }
          });
      this.add(m_openToS);

      setClientRevision();

      m_serverRev = new Label("Server Version: ?");
      m_serverRev.setFont(GameClient.getFontSmall());
      m_serverRev.setForeground(new Color(255, 255, 255));
      m_serverRev.pack();
      m_serverRev.setLocation(m_clientRev.getX() + m_clientRev.getWidth() + 16, m_clientRev.getY());
      m_serverRev.setVisible(true);
      this.add(m_serverRev);

      this.setLocation(0, 0);
      this.setSize(800, 600);
      this.setVisible(true);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Пример #6
0
 /**
  * Sets the server version to be displayed
  *
  * @param rev
  */
 public void setServerRevision(String rev) {
   m_serverRev.setText("Server Version: r" + rev);
   m_serverRev.pack();
   m_serverRev.setLocation(m_clientRev.getX() + m_clientRev.getWidth() + 16, m_clientRev.getY());
 }