Пример #1
0
 public void run() {
   if (Thread.currentThread() != this.mt)
     throw (new RuntimeException("MainFrame is being run from an invalid context"));
   Thread ui = new HackThread(p, "Haven UI thread");
   ui.start();
   try {
     try {
       Session sess = null;
       while (true) {
         UI.Runner fun;
         if (sess == null) {
           Bootstrap bill = new Bootstrap(Config.defserv, Config.mainport);
           if ((Config.authuser != null) && (Config.authck != null)) {
             bill.setinitcookie(Config.authuser, Config.authck);
             Config.authck = null;
           }
           fun = bill;
           setTitle(String.format("Amish Paradise %s", version));
         } else {
           fun = new RemoteUI(sess);
           setTitle(String.format("Amish Paradise %s \u2013 %s", version, sess.username));
         }
         sess = fun.run(p.newui(sess));
       }
     } catch (InterruptedException e) {
     }
     savewndstate();
   } finally {
     ui.interrupt();
     dispose();
   }
 }
Пример #2
0
  public MainFrame(Coord isz) {
    super("Haven and Hearth");
    version = "1.6 (12.22.2015)";
    Coord sz;
    if (isz == null) {
      sz = Utils.getprefc("wndsz", new Coord(800, 600));
      if (sz.x < 640) sz.x = 640;
      if (sz.y < 480) sz.y = 480;
    } else {
      sz = isz;
    }
    this.g = new ThreadGroup(HackThread.tg(), "Haven client");
    this.mt = new HackThread(this.g, this, "Haven main thread");
    p = new HavenPanel(sz.x, sz.y);
    if (fsmode == null) {
      Coord pfm = Utils.getprefc("fsmode", null);
      if (pfm != null) fsmode = findmode(pfm.x, pfm.y);
    }
    if (fsmode == null) {
      DisplayMode cm = getGraphicsConfiguration().getDevice().getDisplayMode();
      fsmode = findmode(cm.getWidth(), cm.getHeight());
    }
    if (fsmode == null) fsmode = findmode(800, 600);
    add(p);
    pack();
    setResizable(!Utils.getprefb("wndlock", false));
    p.requestFocusInWindow();
    seticon();
    setVisible(true);
    p.init();
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            g.interrupt();
          }

          public void windowActivated(WindowEvent e) {
            p.bgmode = false;
          }

          public void windowDeactivated(WindowEvent e) {
            p.bgmode = true;
          }
        });
    if ((isz == null) && Utils.getprefb("wndmax", false))
      setExtendedState(getExtendedState() | MAXIMIZED_BOTH);
  }
Пример #3
0
 private void savewndstate() {
   if (prefs == null) {
     if (getExtendedState() == NORMAL)
     /* Apparent, getSize attempts to return the "outer
      * size" of the window, including WM decorations, even
      * though setSize sets the "inner size" of the
      * window. Therefore, use the Panel's size instead; it
      * ought to correspond to the inner size at all
      * times. */ {
       Dimension dim = p.getSize();
       Utils.setprefc("wndsz", new Coord(dim.width, dim.height));
     }
     Utils.setprefb("wndmax", (getExtendedState() & MAXIMIZED_BOTH) != 0);
   }
 }