Package ipm.gerdc.baccarat

Source Code of ipm.gerdc.baccarat.Main

/**
* @Author: Edmond Hoi
* @Description: IPM-ESAP-GERDC
* @Date: 2010.09.01
*/
package ipm.gerdc.baccarat;

import ipm.gerdc.baccarat.core.GameEngine;
import ipm.gerdc.baccarat.model.GameInfoBean;
import ipm.gerdc.baccarat.page.InfoPage;
import ipm.gerdc.baccarat.util.GameTools;
import ipm.gerdc.baccarat.util.MemoryControl;
import ipm.gerdc.baccarat.util.SysConfig;
import ipm.gerdc.baccarat.util.TextFactory;
import ipm.gerdc.baccarat.util.UIFactory;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.WindowConstants;

public class Main {

  public JMenu menus;

  public JMenuItem[] menuItems;

  public JMenuBar mbar;

  public static MainFrame frm;

  private static Dimension screen;

  private static List<GameInfoBean> gameList;

  private static GameEngine gameEngine;

  private String pageName;

  public void about() {
    String msg = TextFactory.textList.get("GameTitle") + "\n\n" + SysConfig.getCopyright() + "\n\n" + SysConfig.getVersion() + "\n\n";
    JOptionPane.showMessageDialog(frm, msg, TextFactory.textList.get("about"), JOptionPane.INFORMATION_MESSAGE);
  }

  public void popup(String type, String msg) {
    if (type.equals("E")) {
      JOptionPane.showMessageDialog(frm, msg, TextFactory.textList.get("ErrMsg"), JOptionPane.ERROR_MESSAGE);
    } else if (type.equals("W")) {
      JOptionPane.showMessageDialog(frm, msg, TextFactory.textList.get("WarnMsg"), JOptionPane.WARNING_MESSAGE);
    } else if (type.equals("S")) {
      JOptionPane.showMessageDialog(frm, msg, TextFactory.textList.get("InfoMsg"), JOptionPane.INFORMATION_MESSAGE);
    } else {
      JOptionPane.showMessageDialog(frm, msg, TextFactory.textList.get("InfoMsg"), JOptionPane.INFORMATION_MESSAGE);
    }
  }

  public void switchPage(String page) {
    try {
      setPageName(page);
      InfoPage infoPage = (InfoPage) Class.forName(page).newInstance();
      infoPage.buildPage(this);
      frm.getContentPane().removeAll();
      frm.getContentPane().add(infoPage, BorderLayout.CENTER);
      frm.setVisible(false);
      frm.setVisible(true);
      MemoryControl.runGC();
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }

  public void reloadMenuBar() {
    frm.buildMenuBar();
  }

  public Dimension getSreen() {
    return screen;
  }

  public GameInfoBean getCurrentGame() {
    return gameList.size() > 0 ? gameList.get(gameList.size() - 1) : null;
  }

  public GameEngine getGameEngine() {
    return gameEngine;
  }

  public List<GameInfoBean> getGameList() {
    return gameList;
  }

  public String getPageName() {
    return pageName;
  }

  public void setPageName(String pageName) {
    this.pageName = pageName;
  }

  public static void main(String[] args) {
    try {
      Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
      screen = new Dimension();
      screen.width = screenSize.width - 100;
      screen.height = screenSize.height * 2 / 3;
      System.out.println(TextFactory.textList.get("GameTitle") + "\nLanguage: " + TextFactory.textList.get("SysLang") + "\n" + GameTools.getCurrentTime());
      gameList = new ArrayList<GameInfoBean>();
      gameEngine = new GameEngine();
      frm = new MainFrame(new Main());
      frm.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
      frm.setIconImage(UIFactory.makeImageIcon("logo").getImage());
      frm.setTitle(TextFactory.textList.get("GameTitle"));
      frm.setUndecorated(false);
      frm.setSize(screenSize);
      frm.setResizable(false);
      frm.setVisible(true);
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
}
TOP

Related Classes of ipm.gerdc.baccarat.Main

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.