📄 editordatamanager.java
字号:
/* * Light And Shadow. A Persistent Universe based on Robert Jordan's Wheel of Time Books. * Copyright (C) 2001-2003 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.editor;import wotlas.client.*;// import wotlas.client.gui.*;// import wotlas.client.screen.*;import wotlas.client.screen.extraplugin.*;import wotlas.client.screen.JPanelPlugIn;import wotlas.client.screen.plugin.InfoPlugIn;import wotlas.common.character.*;import wotlas.common.*;import wotlas.common.message.account.*;import wotlas.common.message.description.*;import wotlas.common.PlayerState;import wotlas.common.universe.*;import wotlas.libs.graphics2D.*;import wotlas.libs.graphics2D.drawable.*;import wotlas.libs.graphics2D.policy.*;import wotlas.libs.graphics2D.menu.*;import wotlas.libs.persistence.*;import wotlas.libs.sound.SoundLibrary;import wotlas.libs.aswing.*;import wotlas.utils.*;import java.awt.*;import java.awt.event.*;import java.awt.image.BufferedImage;import java.io.File;import java.io.IOException;import javax.swing.*;import java.util.Hashtable;import java.util.Iterator;import java.util.Properties;/** A EditorDataManager manages Game Data to be used by editor * It possesses a WorldManager * * @author Petrus, Aldiss * @see wotlas.common.NetConnectionListener */public class EditorDataManager extends Thread implements Tickable, Menu2DListener { /*------------------------------------------------------------------------------------*/ /** Image Library */ public final static String IMAGE_LIBRARY = "graphics/imagelib"; /** size of a mask's cell (in pixels) */ public final static int TILE_SIZE = 5; /** Number of tick before destroying the circle */ private static final int CIRCLE_LIFETIME = 20; /** True if we show debug informations */ public static boolean SHOW_DEBUG = false; /*------------------------------------------------------------------------------------*/ /*** THE MAIN DATA WE MANAGE ***/ /** Our World Manager */ private WorldManager worldManager; /** Our TileMapData : data of the current map displayed on screen. */ public TileMapData myMapData; /** Our ImageLibrary. */ private ImageLibrary imageLib; /** Our Graphics Director. */ private GraphicsDirector gDirector; private JScreen screen; private EditMenu menuManager; /*------------------------------------------------------------------------------------*/ /*** DATA ACCESS CONTROLLER ***/ /** Tick Thread Lock. */ private Object pauseTickThreadLock = new Object(); /** Do we have to pause the tick thread ? */ private boolean pauseTickThread; /** Are we changing the MapData ? */ private boolean updatingMapData = false; /** Ghost orientation (to limit the update massages sent) */ private double ghostOrientation; /** Reference orientation */ private double refOrientation; /*------------------------------------------------------------------------------------*/ /*** SELECTION CIRCLE ***/ /** Circle selection */ private CircleDrawable circle; /** Number of tick since circle creation */ private int circleLife = 0; /** Circle Lock */ private byte circleLock[] = new byte[1]; /*------------------------------------------------------------------------------------*/ /** Constructor with resource manager. */ public EditorDataManager( ResourceManager rManager ) { // 1 - We create our world Manager. It will load the universe data. worldManager = new WorldManager( true, rManager ); // 2 - Misc inits pauseTickThreadLock = new Object(); pauseTickThread = false; updatingMapData = false; circleLife = 0; circleLock= new byte[1]; } /*------------------------------------------------------------------------------------*/ /** To get the world manager. * * @return the world manager. */ public WorldManager getWorldManager() { return worldManager; } /*------------------------------------------------------------------------------------*/ /** To get the graphicsDirector * * @return the graphicsDirector */ public GraphicsDirector getGraphicsDirector() { return gDirector; } /*------------------------------------------------------------------------------------*/ /** To get the image Library * * @return the image library */ public ImageLibrary getImageLibrary() { return imageLib; } /*------------------------------------------------------------------------------------*/ /*** GETTERS ***/ /** To get MapData */ public TileMapData getMapData() { return myMapData; } /** To get JScreen. */ public JScreen getScreen() { return screen; } /*------------------------------------------------------------------------------------*/ /** Set to true to show debug information */ public void showDebug(boolean value) { SHOW_DEBUG = value; } /*------------------------------------------------------------------------------------*/ public void showInterface() { // 0 - State analysis, progress monitor init... Debug.signal( Debug.NOTICE, null, "DataManager call to ShowInterface"); AProgressMonitor pMonitor = new AProgressMonitor( ClientDirector.getClientManager(), "Wotlas" ); pMonitor.setProgress("Loading Shared Images...",0); // 1 - Create Image Library try { imageLib = new ImageLibrary( EditTile.getResourceManager() ); imageLib.setLoadAllJITDirectoryImages(true); // images from JIT directories are loaded together. } catch( Exception ex ) { Debug.signal(Debug.FAILURE, this, ex ); Debug.exit(); } pMonitor.setProgress("Reading Preferences...",10); pMonitor.setProgress("Creating 2D Engine...",15); // 3 - Create Graphics Director WindowPolicy wPolicy = null; wPolicy = new CenterWindowPolicy(); gDirector = new EnhancedGraphicsDirector( wPolicy, imageLib ); pMonitor.setProgress("Creating GUI...",20); // 4 - Creation of the GUI components screen = new JScreen(gDirector, this ); if(SHOW_DEBUG) System.out.println("JScreen created"); pMonitor.setProgress("Loading Player Data from PseudoServer...",30); screen.init(); menuManager = new EditMenu( gDirector ); menuManager.addMenu2DListener(this); pMonitor.setProgress("Loading Map Data...",85); // 7 - Init the map display... changeMapData(); if(SHOW_DEBUG) System.out.println("Changed map data !"); pMonitor.setProgress("Starting Game...",95); // 8 - Start the tick thread. start(); Debug.signal( Debug.NOTICE, null, "Started the tick thread..." ); screen.show(); Debug.signal( Debug.NOTICE, null, "Show screen..." ); pMonitor.setProgress("Done...",100); pMonitor.close(); if (SHOW_DEBUG) System.out.println("Frame displayed on screen..."); // 9 - Welcome message if(SHOW_DEBUG) System.out.println("End of DataManager's showInterface !"); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -