erland.game.tileadventure
Class MapEditor

java.lang.Object
  extended by erland.game.tileadventure.MapEditor
All Implemented Interfaces:
GamePanelInterface
Direct Known Subclasses:
TileMapEditor

public abstract class MapEditor
extends Object
implements GamePanelInterface

Abstract class that implement basic behaviour in a map editor

Author:
Erland Isaksson

Field Summary
protected static int BUTTON_EXIT
          Standard Exit button, used in getDefaultButtons()
protected static int BUTTON_LOAD
          Standard Load button, used in getDefaultButtons()
protected static int BUTTON_SAVE
          Standard Save button, used in getDefaultButtons()
 
Constructor Summary
MapEditor()
           
 
Method Summary
protected  void clickedMapBlock(int posX, int posY)
          Called when a block on the map is clicked, this method will either insert the selected block in the clicked map position or remove the current block at the map position
protected  void clickedSelectBlock(int posX, int posY)
          Called when a block in the selection area is clicked, this method will make the clicked block the currently selected block or if there were no block at the clicked make no block selected
protected abstract  MapObjectInterface cloneBlock(MapObjectInterface block, IrregularBlockContainerInterface cont, int x, int y, int z)
          Clone specified block
 void draw()
           
protected  void drawBlock(Graphics g, MapObjectInterface block)
          Draw the specified block
protected  void drawFinish(Graphics g)
          Called everything normal has been drawed, can be used to do extra drawing on top of the other graphics
abstract  void drawHoveringFrame(Graphics g, int posX, int posY)
           
abstract  void drawMapBlocks(Graphics g, MapObjectContainerInterface blocks)
           
 void drawPaletteBlocks(Graphics g, MapObjectContainerInterface paletteBlocks)
           
abstract  void drawSelectedFrame(Graphics g, MapObjectInterface selectedBlock)
           
 void exit()
           
protected  void exitButton()
          Called when the standard exit button is pressed, the map editor should exit
protected  void exitFinish()
          Called once when exit of the map editor is finished
protected  int getDefaultButtons()
          Called to get which default buttons that should be available, the return value is a bitmask composed by BUTTON_EXIT, BUTTON_LOAD, BUTTON_SAVE
 GameEnvironmentInterface getEnvironment()
           
protected abstract  MapObjectContainerInterface getMapBlocks()
          Get matrix with all blocks in the map
protected abstract  IrregularBlockContainerInterface getMapContainer()
          Get block container for the map area
protected  int getMapPosZ()
           
protected abstract  MapObjectContainerInterface getPaletteBlocks()
          Get matrix with all blocks in the block selection area
protected abstract  IrregularBlockContainerInterface getPaletteContainer()
          Get block container for the block selection area
protected  int getPalettePosZ()
           
protected  void hoverMapBlock(int posX, int posY)
          Called when the mouse pointer is hovering over a block on the map , this method will just be called to make it possible to show which block the mouse is hovering over The method is called with -1 in both parameters if the mouse is not hovering over any block
 void init(GameEnvironmentInterface environ)
           
protected  EPanel initButtonPanel()
          Create and initialize button panel
protected  void initButtons(EPanel panel)
          Create and initialize all buttons
protected  void initDefaultButtons(EPanel panel)
          Create and initialize default butons
protected  void initFinish()
          Called once when the initialization of the map editor is finished
protected abstract  boolean isEmptyAllowed()
          Checks if it is allowed to have positions in the map without any block
 boolean isExit()
           
protected  void leftMouseDragged(int x, int y)
           
protected  void leftMousePressed(int x, int y)
           
protected  void loadButton()
          Called when the standard load button is pressed, a new map should be loaded
protected  void mouseHovering(int x, int y)
           
protected  MapObjectInterface prepareNewBlock(MapObjectInterface oldBlock, MapObjectInterface newBlock)
          Prepare a new block so it can be inserted in the map
protected  void saveButton(MapObjectContainerInterface blocks)
          Called when the standard save button is pressed, the current blocks in the map area should be saved to the map
 void setCheatmode(boolean enable)
           
protected  void setMapBlock(MapObjectInterface block, int posX, int posY, int posZ)
          Uppdates the map with a new block
 void update()
           
protected  void updateBlocks()
          Update all blocks
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUTTON_EXIT

protected static final int BUTTON_EXIT
Standard Exit button, used in getDefaultButtons()

See Also:
Constant Field Values

BUTTON_SAVE

protected static final int BUTTON_SAVE
Standard Save button, used in getDefaultButtons()

See Also:
Constant Field Values

BUTTON_LOAD

protected static final int BUTTON_LOAD
Standard Load button, used in getDefaultButtons()

See Also:
Constant Field Values
Constructor Detail

MapEditor

public MapEditor()
Method Detail

isExit

public boolean isExit()
Specified by:
isExit in interface GamePanelInterface

exit

public void exit()
Specified by:
exit in interface GamePanelInterface

getMapContainer

protected abstract IrregularBlockContainerInterface getMapContainer()
Get block container for the map area

Returns:
The block container

getPaletteContainer

protected abstract IrregularBlockContainerInterface getPaletteContainer()
Get block container for the block selection area

Returns:
The block container

getPaletteBlocks

protected abstract MapObjectContainerInterface getPaletteBlocks()
Get matrix with all blocks in the block selection area

Returns:
Matrix with the blocks

getMapBlocks

protected abstract MapObjectContainerInterface getMapBlocks()
Get matrix with all blocks in the map

Returns:
Matrix with the blocks

prepareNewBlock

protected MapObjectInterface prepareNewBlock(MapObjectInterface oldBlock,
                                             MapObjectInterface newBlock)
Prepare a new block so it can be inserted in the map

Parameters:
oldBlock - Old block at the same position
newBlock - New block that should be inserted
Returns:
Prepared block that should be inserted, may be same as newBlock but may also be a completely new block based on newBlock and oldBlock

init

public void init(GameEnvironmentInterface environ)
Specified by:
init in interface GamePanelInterface

clickedMapBlock

protected void clickedMapBlock(int posX,
                               int posY)
Called when a block on the map is clicked, this method will either insert the selected block in the clicked map position or remove the current block at the map position

Parameters:
posX - X position of the block in the map that was clicked
posY - Y position of the block in the map that was clicked

setMapBlock

protected void setMapBlock(MapObjectInterface block,
                           int posX,
                           int posY,
                           int posZ)
Uppdates the map with a new block

Parameters:
block - The new block to insert in map
posX - The x position of the new block
posY - The y position of the new block
posZ - The z position of the new block

hoverMapBlock

protected void hoverMapBlock(int posX,
                             int posY)
Called when the mouse pointer is hovering over a block on the map , this method will just be called to make it possible to show which block the mouse is hovering over The method is called with -1 in both parameters if the mouse is not hovering over any block

Parameters:
posX - X position of the block in the map that was hovered over
posY - Y position of the block in the map that was hovered over

clickedSelectBlock

protected void clickedSelectBlock(int posX,
                                  int posY)
Called when a block in the selection area is clicked, this method will make the clicked block the currently selected block or if there were no block at the clicked make no block selected

Parameters:
posX - X position of the block in the selection area that was clicked
posY - Y position of the block in the selection area that was clicked

leftMouseDragged

protected void leftMouseDragged(int x,
                                int y)

mouseHovering

protected void mouseHovering(int x,
                             int y)

leftMousePressed

protected void leftMousePressed(int x,
                                int y)

updateBlocks

protected void updateBlocks()
Update all blocks


update

public void update()
Specified by:
update in interface GamePanelInterface

drawBlock

protected void drawBlock(Graphics g,
                         MapObjectInterface block)
Draw the specified block

Parameters:
g - Graphics object to draw on
block - Block to draw

cloneBlock

protected abstract MapObjectInterface cloneBlock(MapObjectInterface block,
                                                 IrregularBlockContainerInterface cont,
                                                 int x,
                                                 int y,
                                                 int z)
Clone specified block

Parameters:
block - Block to clone
cont - Block container to put new block in
x - X position to put new block at
y - Y position to put new block at
z - Z position to put new block at
Returns:
Newly cloned block

isEmptyAllowed

protected abstract boolean isEmptyAllowed()
Checks if it is allowed to have positions in the map without any block

Returns:
true/false (Empty positions allowed/No empty positions allowed)

initButtons

protected void initButtons(EPanel panel)
Create and initialize all buttons

Parameters:
panel - EPanel to put buttons on

initFinish

protected void initFinish()
Called once when the initialization of the map editor is finished


exitFinish

protected void exitFinish()
Called once when exit of the map editor is finished


saveButton

protected void saveButton(MapObjectContainerInterface blocks)
Called when the standard save button is pressed, the current blocks in the map area should be saved to the map

Parameters:
blocks - The blocks in the map area

loadButton

protected void loadButton()
Called when the standard load button is pressed, a new map should be loaded


exitButton

protected void exitButton()
Called when the standard exit button is pressed, the map editor should exit


getDefaultButtons

protected int getDefaultButtons()
Called to get which default buttons that should be available, the return value is a bitmask composed by BUTTON_EXIT, BUTTON_LOAD, BUTTON_SAVE

Returns:
Bitmask that indicates which default buttons that should be used

initDefaultButtons

protected void initDefaultButtons(EPanel panel)
Create and initialize default butons

Parameters:
panel - EPanel which the buttons should be added to

initButtonPanel

protected EPanel initButtonPanel()
Create and initialize button panel

Returns:
The newly created EPanel for the buttons

drawFinish

protected void drawFinish(Graphics g)
Called everything normal has been drawed, can be used to do extra drawing on top of the other graphics

Parameters:
g - The Graphics object to draw on

drawMapBlocks

public abstract void drawMapBlocks(Graphics g,
                                   MapObjectContainerInterface blocks)

drawSelectedFrame

public abstract void drawSelectedFrame(Graphics g,
                                       MapObjectInterface selectedBlock)

drawHoveringFrame

public abstract void drawHoveringFrame(Graphics g,
                                       int posX,
                                       int posY)

drawPaletteBlocks

public void drawPaletteBlocks(Graphics g,
                              MapObjectContainerInterface paletteBlocks)

draw

public void draw()
Specified by:
draw in interface GamePanelInterface

setCheatmode

public void setCheatmode(boolean enable)
Specified by:
setCheatmode in interface GamePanelInterface

getEnvironment

public GameEnvironmentInterface getEnvironment()

getMapPosZ

protected int getMapPosZ()

getPalettePosZ

protected int getPalettePosZ()


Copyright © 2003-2006 Erland Isaksson. All Rights Reserved.