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

📄 editordatamanager.java

📁 Vyger offers a D & D and Rogue-like environment in a graphical online roleplay game.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
 /*------------------------------------------------------------------------------------*/  /** Main loop to tick the graphics director every 50ms.   */    public void run() {      long now;      int deltaT;      int delay;      String os   = System.getProperty( "os.name" );      String arch = System.getProperty( "os.arch" );      String vers = System.getProperty( "os.version" );      Debug.signal( Debug.NOTICE, this, "OS INFO :\n\nOS NAME : <"+os+">\nOS ARCH: <"+arch+">\nOS VERSION: <"+vers+">\n" );      delay = 50;      //if ( os.equals("Windows 2000") || os.equals("Windows XP") )      //  delay = 40;      pauseTickThread = false;      while( true ) {          now = System.currentTimeMillis();       // Pause Thread ?          synchronized( pauseTickThreadLock ) {             if(pauseTickThread)                try{                   pauseTickThreadLock.wait();                }catch(Exception e){}          }       // Tick          tick();          deltaT = (int) (System.currentTimeMillis()-now);          if (deltaT<delay)              Tools.waitTime(delay-deltaT);      }   } /*------------------------------------------------------------------------------------*/  /** Tick Action. We propagate the tick on the players & GraphicsDirector.   */    public void tick() {    // III - Graphics Director update & redraw       if( screen.getState()==Frame.ICONIFIED )          Tools.waitTime(400); // we reduce our tick rate... and don't refresh the screen       else          gDirector.tick(); // game screen update    // IV - Sync Messages Execution   } /*------------------------------------------------------------------------------------*/  /** To pause the tick thread.   */    private void pauseTickThread() {          synchronized( pauseTickThreadLock ) {                pauseTickThread=true;          }    } /*------------------------------------------------------------------------------------*/  /** To resume the tick thread.   */    private void resumeTickThread() {          synchronized( pauseTickThreadLock ) {                pauseTickThread=false;                pauseTickThreadLock.notify();          }    } /*------------------------------------------------------------------------------------*/  /** To tell if the DataManager's tick thread is running.   * @return true if it's running, false otherwise   */    public boolean isRunning() {          synchronized( pauseTickThreadLock ) {                if( !pauseTickThread )                    return true;                return false;          }    } /*------------------------------------------------------------------------------------*/  /** To show a warning message   */    public void showWarningMessage(String warningMsg) {         JOptionPane.showMessageDialog( screen, warningMsg, "Warning message!", JOptionPane.WARNING_MESSAGE);    } /*------------------------------------------------------------------------------------*/  /** Called when user left-clic on JMapPanel   */    public void onLeftClicJMapPanel(MouseEvent e) {      if(SHOW_DEBUG)         System.out.println("DataManager::onLeftClicJMapPanel");      if(updatingMapData)         return; // updating Map Location   // Menu clicked ?      if( menuManager.isVisible() )          if( !menuManager.mouseClicked( e ) )               menuManager.hide();          else               return;   // Object/Player selected ?      if( mouseSelect( e.getX(), e.getY(), true ) )          return;      if (SHOW_DEBUG)         System.out.println("END of DataManager::onLeftClicJMapPanel");  } /*------------------------------------------------------------------------------------*/ /** Called when user right-clic on JMapPanel  */   public void onRightClicJMapPanel(MouseEvent e) {      if (SHOW_DEBUG)        System.out.println("DataManager::onRightClicJMapPanel");      if( menuManager.isVisible() )          menuManager.hide();      else {      	 // Menu selection & display          mouseSelect( e.getX(), e.getY(), false );          menuManager.initNoContent();          menuManager.show( new Point( e.getX(), e.getY() ) );      }    } /*------------------------------------------------------------------------------------*/  /** Called when the mouse cursor is dragged with the left button.   * @param e mouse event   * @param dx delta x since mouse pressed   * @param dy delta y since mouse pressed   * @param finalMov movement type as describe in JMapPanel, INIT_MOUSE_MOVEMENT, etc...   */   public void onLeftButtonDragged( MouseEvent e, int dx, int dy, byte movementType ) {   }    public void onLeftButtonMoved( int x, int y ) {        if( !menuManager.isVisible() )            return;        menuManager.mouseMoved( x, y );    }        public void onRightButtonDragged( int dx, int dy,  boolean startsNow ) {/*        if( !menuManager.isVisible() )            return;        menuManager.mouseDragged( dx, dy, startsNow );*/    } /*------------------------------------------------------------------------------------*/  /** To select an object/player on screen via a mouse click   * @param screen game screen dimension   * @param x x position of the mouse   * @param y y position of the mouse   * @param isLeftClick true if the left button was clicked, false if it's the right.   * @return true if we processed the mouse event, false if it was not for us.   */    public boolean mouseSelect( int x, int y, boolean isLeftClick ) {     // We search for the owner of the object        Object object = gDirector.findOwner( x, y );        /*        if ( object instanceof ScreenObject ) {        }//      else if( object instanceof BaseObject ) {////             ADD HERE SELECTION CODE FOR OBJECTS (use the player selection as example)//      }        else if( object!=null ) {           // Unknown Object !              Debug.signal(Debug.WARNING,this,"Unknown Object Clicked : "+object);              return true;        }         */       return false; // event not for us    } /*------------------------------------------------------------------------------------*/  /** To change the current MapData ( TownMap, WorldMap, InteriorMap ).   */    public void changeMapData() {        updatingMapData=true;        if( menuManager.isVisible() )            menuManager.hide();                myMapData = new TileMapData();        myMapData.showDebug(SHOW_DEBUG);        WotlasLocation location = new WotlasLocation();        location.setTileMapID(0);        myMapData.initDisplayEditor( this, location );        updatingMapData=false;   } /*------------------------------------------------------------------------------------*/  /** To suppress drawables, shadows, data   */    public void cleanInteriorMapData() {      gDirector.removeAllDrawables();    } /*------------------------------------------------------------------------------------*/  /** To draw a rectangle on the screen   *   * @param rect the rectangle to display   */    public void drawScreenRectangle(Rectangle rect, Color color) {        Point p[] = new Point[5];        int x = (int) rect.getX();        int y = (int) rect.getY();        int width = (int) rect.getWidth();        int height = (int) rect.getHeight();        p[0] = new Point(x,y);        p[1] = new Point(x+width, y);        p[2] = new Point(x+width, y+height);        p[3] = new Point(x, y+height);        p[4] = new Point(x,y);        Drawable pathDrawable = (Drawable) new PathDrawable( p, color, (short) ImageLibRef.AURA_PRIORITY );        gDirector.addDrawable( pathDrawable);    } /*------------------------------------------------------------------------------------*/  /** To exit wotlas.   */    public void exit() {       // SoundLibrary.clear();       Debug.exit();       System.exit(0);    } /*------------------------------------------------------------------------------------*/   /** Method called when an item has been clicked on an item who is not a menu link.    *  @param e menu event generated.    */    public void menuItemClicked( Menu2DEvent e ) {        if(SHOW_DEBUG)            System.out.println("Menu Item Clicked : "+e.toString());     } /*------------------------------------------------------------------------------------*/    public void clickOnATile( int x, int y ) {        if(EditorPlugIn.itSelf.MainTabb.getSelectedIndex() == 2){            EditorPlugIn.manageAddExit(x,y);            System.out.println("x,y per primo exit : "+x+" "+y);        }        else if(EditorPlugIn.itSelf.MainTabb.getSelectedIndex() == 1){            EditTile.workingOnThisTileMap.getManager().getMapBackGroundData(            )[x][y][0] = (byte) EditorPlugIn.selectedGroup;            EditTile.workingOnThisTileMap.getManager().getMapBackGroundData(            )[x][y][1] = (byte) EditorPlugIn.selectedGroupImgNr;            EditTile.workingOnThisTileMap.getManager().getMapMask(            )[x][y] = GroupOfGraphics.ROGUE_SET[EditorPlugIn.selectedGroup            ].getFreeStatus();//            EditTile.workingOnThisTileMap.getManager().getMapMask(//            )[x][y] = EditorPlugIn.selectedIsFree;            EditorPlugIn.AddIt(x,y);        }    }}

⌨️ 快捷键说明

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