Пример #1
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);
  }
Пример #2
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();
    }
  }