⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainframe.java

📁 Massively Multiplayer Space Trading and Combat game. This is an online strategy game, not a 3D space
💻 JAVA
字号:
/*
 * MainFrame.java
 *
 * Copyright (C) 2000 Jason M. Hanley
 * Released under the GNU General Public License (GPL)
 * See license.txt for additional information.
 *
 * Created on July 26, 2000, 10:30 PM
 */
 
package fate.server;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;

import fate.*;
import fate.util.*;
import fate.ui.*;
import fate.network.*;
import fate.world.edit.*;

/** 
 * Main UI window for the server.
 *
 * @author  preylude@s3m.com
 * @version 0.1.0
 */
public class MainFrame extends JFrame implements ActionListener {
  
  MapPlayerInfo mapPlayerInfo;

  /** Creates new MainFrame */
  public MainFrame( String title, MapPlayerInfo mapPlayerInfo ) {
    super( title );
    this.mapPlayerInfo = mapPlayerInfo;
    
    JTextArea welcomeMsg = new JTextArea( 8, 40 ); 
    welcomeMsg.setText( 
      "Welcome to " + FateServer.programName + ". \n\n" +
      "Visit Fate on the web at http://fate.sourceforce.net\n\n" +
      "This version is able to create/edit account, accept client " +
      "connections, and relay chat messages.  See readme.txt for " +
      "additional information.\n\n" +
      FateServer.programName + " is released under the GNU General " +
      "Public License (GPL).  " +
      "See license.txt or http://www.gnu.org for more information.\n\n" +
      "This program is distributed in the hope that it will be useful, " +
      "but WITHOUT ANY WARRANTY; without even the implied warranty of " +
      "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the " +
      "GNU General Public License for more details.\n\n" +
      "Copyright 2000 Jason M. Hanley (preylude@s3m.com)" );
    welcomeMsg.setLineWrap( true );
    welcomeMsg.setWrapStyleWord( true );
    welcomeMsg.setEditable( false );
    JScrollPane welcomeScroll = new JScrollPane( welcomeMsg );
    welcomeScroll.setBorder( BorderFactory.createEtchedBorder() );
    getContentPane().add( welcomeScroll, BorderLayout.NORTH );

    JPanel panel = new JPanel();
    SwingUtil.addButton(  panel, "User Manager", 'u', "UserManager", this );
    SwingUtil.addButton(  panel, "World Editor", 'w', "WorldEditor", this );
    panel.setBorder( BorderFactory.createEtchedBorder() );
    
    getContentPane().add( panel, BorderLayout.CENTER );

    addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e) {
        onExit();
      }
    });
  }
  
  /** Exit handler */
  public void onExit() {
    try {
      Debug.trace( "Attempting to write player database" );
      FileOutputStream fileOut = new FileOutputStream( FateServer.playerDBFile );
      ObjectOutputStream out = new ObjectOutputStream( fileOut );
      out.writeObject( mapPlayerInfo );
      out.close();
      fileOut.close();
    } catch( Exception e ) {
      Debug.trace( "Error writing player database" );
      e.printStackTrace();
    }

    try {
      Debug.trace( "Attempting to write Universe" );
      FileOutputStream fileOut = new FileOutputStream( FateServer.universeFile );
      ObjectOutputStream out = new ObjectOutputStream( fileOut );
      out.writeObject( FateServer.universe );
      out.close();
      fileOut.close();
    } catch( Exception e ) {
      Debug.trace( "Error writing Universe" );
      e.printStackTrace();
    }

    System.exit(0);
  }
  
  /** Handles ActionEvent */
  public void actionPerformed(ActionEvent e) {
    String strAction = e.getActionCommand();
    
    if ( strAction.equals( "UserManager" ) ) {
      Debug.trace( "Calling up User Manager dialog" );
      UserManagerDialog dialog = new UserManagerDialog( this, mapPlayerInfo );
      dialog.pack();
      SwingUtil.centerWindow( dialog );
      dialog.show();
    }
    else if ( strAction.equals( "WorldEditor" ) ) {
      Debug.trace( "Calling up World Editor dialog" );
      WorldEditDialog dialog = new WorldEditDialog( this );
      dialog.pack();
      SwingUtil.centerWindow( dialog );
      dialog.show();
    }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -