📄 serversetup.java
字号:
/*
* Light And Shadow. A Persistent Universe based on Robert Jordan's Wheel of Time Books.
* Copyright (C) 2001-2002 WOTLAS Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package wotlas.server.setup;
import wotlas.common.*;
import wotlas.server.*;
import wotlas.utils.*;
import wotlas.libs.aswing.*;
import wotlas.libs.wizard.*;
import wotlas.libs.wizard.step.*;
import wotlas.libs.log.*;
import wotlas.libs.graphics2D.FontFactory;
import wotlas.libs.net.utils.NetInterface;
import java.io.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Properties;
/** A small utility to register/update the server config.
*
* @author Aldiss
* @see wotlas.common.ServerConfig
*/
public class ServerSetup extends JWizard {
/*------------------------------------------------------------------------------------*/
/** Setup Command Line Help
*/
public final static String SETUP_COMMAND_LINE_HELP =
"Usage: ServerSetup -[help|base <path>]\n\n"
+"Examples : \n"
+" ServerSetup -base ../base : sets the data location.\n\n"
+"If the -base option is not set we search for data in "+ResourceManager.DEFAULT_BASE_PATH
+"\n\n";
/*------------------------------------------------------------------------------------*/
/** Towns Name & initial position - TEMP will be replaced by a more oo...
*/
public final static String TOWNS_NAME[] = {
"Near Tar Valon",
"In the Blight",
"Near Shayol Ghul",
"Near Caemlyn",
"Near Cairhien",
"Near Tear",
"Near Illian",
"Near Edou Bar",
"Near Stedding Shangtai",
"Near Amador"
};
public final static int TOWNS_NEAR_POSITION[][] = {
{ 743, 277 }, // position near Tar Valon on the World Map
{ 778, 135 }, // position near the Blight on the World Map
{ 815, 84 }, // ... etc ...
{ 724, 441 },
{ 811, 360 },
{ 769, 608 },
{ 651, 674 },
{ 489, 443 },
{ 935, 541 },
{ 394, 565 }
};
/*------------------------------------------------------------------------------------*/
/** Our current serverID
*/
private static int serverID;
/*------------------------------------------------------------------------------------*/
/** Constructor.
*/
public ServerSetup() {
super("Server Config",
ServerDirector.getResourceManager(),
FontFactory.getDefaultFontFactory().getFont("Lucida Blackletter").deriveFont(18f),
470,450);
setLocation(200,100);
serverID = ServerDirector.getServerID(); // we get the current server ID
// We display first step
try{
init( WelcomeWizardStep.getStaticParameters() );
}
catch( WizardException we ) {
we.printStackTrace();
dispose(); // init failed !
ServerAdminGUI.setAdminGUI();
}
}
/*------------------------------------------------------------------------------------*/
/** Called when wizard is finished (after last step's end).
*/
protected void onFinished(Object context) {
dispose();
ServerAdminGUI.setAdminGUI();
}
/*------------------------------------------------------------------------------------*/
/** Called when wizard is canceled ('cancel' button pressed).
*/
protected void onCanceled(Object context) {
dispose();
ServerAdminGUI.setAdminGUI();
}
/*------------------------------------------------------------------------------------*/
/**
* First Step of our JWizard. A welcome message.
*/
public static class WelcomeWizardStep extends JWizardStepInfo {
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/** This is a static JWizardStep, to build it more simply this method
* returns the JWizardStepParameters needed for the JWizard.
*/
public static JWizardStepParameters getStaticParameters() {
JWizardStepParameters param = new JWizardStepParameters(
"wotlas.server.setup.ServerSetup$WelcomeWizardStep",
"Welcome !" );
param.setIsPrevButtonEnabled(false);
param.setIsDynamic(true);
param.setProperty("init.info0", "\n\n\n This wizard will help you configure your wotlas"
+" server. Click on 'next' to continue.");
return param;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/** Constructor.
*/
public WelcomeWizardStep() {
super();
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/** Called each time the step is shown on screen.
*/
protected void onShow(Object context, JWizard wizard) {
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/** Called when the "Next" button is clicked.
* Use the wizard's setNextStep() method to set the next step to be displayed.
* @return return true to validate the "Next" button action, false to cancel it...
*/
protected boolean onNext(Object context, JWizard wizard) {
// we move on to the next step
wizard.setNextStep( RegisterChoicesWizardStep.getStaticParameters() );
return true;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/** Called when Previous button is clicked.
* Use the wizard's setNextStep() method to set the next step to be displayed.
* @return return true to validate the "Previous" button action, false to cancel it...
*/
protected boolean onPrevious(Object context, JWizard wizard) {
return false; // should never been reached
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
}
/*------------------------------------------------------------------------------------*/
/**
* Second Step of our JWizard. Register choices.
*/
public static class RegisterChoicesWizardStep extends JWizardStepRadio {
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/** This is a static JWizardStep, to build it more simply this method
* returns the JWizardStepParameters needed for the JWizard.
*/
public static JWizardStepParameters getStaticParameters() {
JWizardStepParameters param = new JWizardStepParameters(
"wotlas.server.setup.ServerSetup$RegisterChoicesWizardStep",
"Register Choice" );
param.setIsPrevButtonEnabled(true);
param.setIsDynamic(false);
param.setProperty("init.label0", "Here are the options you have :");
param.setProperty("init.nbChoices", "4");
param.setProperty("init.choice0", "Create a public wotlas server.");
param.setProperty("init.info0", " With this option your server will be added to the list of our public Internet servers.\n");
param.setProperty("init.choice1", "Create a private wotlas server.");
param.setProperty("init.info1", " With this option you can choose which wotlas network you want to join for your server ( "
+"with the wotlas manager package everyone can create his/her own wotlas network ).");
param.setProperty("init.choice2", "Create a local server.");
param.setProperty("init.info2", " With this option your server will remain local to your computer. It will not be published on the Internet. "
+"This is a fast & easy solution for running a server locally and perform some tests.");
param.setProperty("init.choice3", "Update your server's config.");
param.setProperty("init.info3", " Choose this option if you want to edit/view your previously created server config.\n");
return param;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/** Constructor.
*/
public RegisterChoicesWizardStep() {
super();
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/** Called each time the step is shown on screen.
*/
protected void onShow(Object context, JWizard wizard) {
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/** Called when the "Next" button is clicked.
* Use the wizard's setNextStep() method to set the next step to be displayed.
* @return return true to validate the "Next" button action, false to cancel it...
*/
protected boolean onNext(Object context, JWizard wizard) {
switch(getChoice()) {
case 0:
wizard.setNextStep( ServerIdWizardStep.getStaticParameters() );
break;
case 1:
wizard.setNextStep( PrivateServerWizardStep.getStaticParameters() );
break;
case 2:
serverID=0;
wizard.setNextStep( ServerInterfaceWizardStep.getStaticParameters() );
break;
case 3:
wizard.setNextStep( ServerInterfaceWizardStep.getStaticParameters() );
break;
}
return true;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/** Called when Previous button is clicked.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -