Crossfire JXClient, Trunk  R20561
com.realtime.crossfire.jxclient.map.MapUpdaterState Class Reference

Update a CfMap model from protocol commands. More...

+ Inheritance diagram for com.realtime.crossfire.jxclient.map.MapUpdaterState:
+ Collaboration diagram for com.realtime.crossfire.jxclient.map.MapUpdaterState:

Public Member Functions

void addAnimation (final int animation, final int flags, @NotNull final int[] faces)
 An "addanim" command has been received.
Parameters
animationthe animation ID
flagsthe animation flags
facesthe faces list; must not be modified
More...
 
void addCrossfireMapListener (@NotNull final MapListener listener)
 Adds a listener to notify about changed map squares. More...
 
void addCrossfireMapScrollListener (@NotNull final MapScrollListener listener)
 Adds a listener to notify about scrolled maps. More...
 
void addCrossfireNewmapListener (@NotNull final NewmapListener listener)
 Adds a listener to notify about cleared maps. More...
 
void addMapSizeListener (@NotNull final MapSizeListener listener)
 Adds a listener to be notified about map size changes. More...
 
void faceUpdated (@NotNull final Face face)
 Called when a Face has been updated.
Parameters
facethe face
More...
 
CfMap getMap ()
 Returns the current map instance. More...
 
int getMapHeight ()
 Returns the height of the visible map area. More...
 
int getMapWidth ()
 Returns the width of the visible map area. More...
 
void magicMap (final int x, final int y, final byte[][] data)
 Part of "magicmap" parsing: set the magic map color.
Parameters
xthe x-coordinate
ythe y-coordinate
datathe magic map data (y, x); must not be changed
More...
 
void mapAnimation (@NotNull final Location location, final int animationNum, final int animationType)
 Part of "map2" parsing: set the animation of a cell.
Parameters
locationthe location
animationNumthe animation ID
animationTypethe animation type
More...
 
void mapAnimationSpeed (@NotNull final Location location, final int animationSpeed)
 Part of "map2" parsing: set the animation speed.
Parameters
locationthe location
animationSpeedthe animation speed
More...
 
Object mapBegin ()
 Parsing of a "map2" command has been started.
Returns
the synchronization object which must be
synchronized
while calling any other function (except )
More...
 
void mapClear (final int x, final int y)
 Part of "map2" parsing: clear a cell.
Parameters
xthe x-coordinate
ythe y-coordinate
More...
 
void mapDarkness (final int x, final int y, final int darkness)
 Part of "map2" parsing: change the darkness of a cell.
Parameters
xthe x-coordinate
ythe y-coordinate
darknessthe darkness value
More...
 
void mapEnd ()
 Parsing of "map2" has been finished. More...
 
void mapEnd (final boolean alwaysProcess)
 Finishes processing of a set of map square changes. More...
 
void mapFace (@NotNull final Location location, final int faceNum)
 Part of "map2" parsing: set the face of a cell.
Parameters
locationthe location
faceNumthe face ID
More...
 
void mapFace (@NotNull final Location location, final int faceNum, final boolean clearAnimation)
 Updates a map square by changing a face. More...
 
void mapScroll (final int dx, final int dy)
 Part of "map2" parsing: scroll the map view.
Parameters
dxthe x-distance
dythe y-distance
More...
 
void mapSmooth (@NotNull final Location location, final int smooth)
 Part of "map2" parsing: set the smooth level.
Parameters
locationthe location
smooththe smooth value
More...
 
 MapUpdaterState (@NotNull final FacesManager facesManager, @Nullable final GuiStateManager guiStateManager)
 Creates a new instance. More...
 
void newMap (final int mapWidth, final int mapHeight)
 A "newmap" command has been received.
Parameters
mapWidththe map width
mapHeightthe map height
More...
 
void removeCrossfireMapListener (@NotNull final MapListener listener)
 Removes a listener to notify about changed map squares. More...
 
void removeCrossfireMapScrollListener (@NotNull final MapScrollListener listener)
 Removes a listener to notify about scrolled maps. More...
 
void removeCrossfireNewmapListener (@NotNull final NewmapListener listener)
 Removes a listener to notify about cleared maps. More...
 
void removeMapSizeListener (@NotNull final MapSizeListener listener)
 Removes a listener to be notified about map size changes. More...
 
void reset ()
 Resets the animation state. More...
 
void tick (final int tickNo)
 A "tick" command has been received.
Parameters
tickNothe current tick
More...
 

Private Attributes

final Animations animations
 The defined animations. More...
 
final FacesManager facesManager
 The FacesManager to track for updated faces. More...
 
final CfMap map = new CfMap()
 The current CfMap instance. More...
 
int mapHeight
 The height of the visible map area. More...
 
final EventListenerList2< MapListenermapListeners = new EventListenerList2<>()
 The listeners to notify about changed map squares. More...
 
final EventListenerList2< MapScrollListenermapScrollListeners = new EventListenerList2<>()
 The listeners to notify about scrolled maps. More...
 
final EventListenerList2< MapSizeListenermapSizeListeners = new EventListenerList2<>()
 The MapSizeListeners to be notified. More...
 
int mapWidth
 The width of the visible map area. More...
 
final EventListenerList2< NewmapListenernewmapListeners = new EventListenerList2<>()
 The listeners to notify about cleared maps. More...
 
final Collection< LocationoutOfViewMultiFaces = new HashSet<>()
 All multi-tiled faces with heads outside the visible map area. More...
 
final Object sync = new Object()
 The object used for synchronization. More...
 
final CfMapAnimations visibleAnimations = new CfMapAnimations()
 The animations in the visible map area. More...
 

Detailed Description

Update a CfMap model from protocol commands.

The map updater is called from two threads: the com.realtime.crossfire.jxclient.server.socket.ClientSocket reading commands received from the Crossfire server, and com.realtime.crossfire.jxclient.faces.FileCacheFaceQueue reading faces from the (file) cache. Synchronization is by sync and applies to the whole map model map.

Author
Andreas Kirschbaum

Definition at line 50 of file MapUpdaterState.java.

Constructor & Destructor Documentation

◆ MapUpdaterState()

com.realtime.crossfire.jxclient.map.MapUpdaterState.MapUpdaterState ( @NotNull final FacesManager  facesManager,
@Nullable final GuiStateManager  guiStateManager 
)

Creates a new instance.

Parameters
facesManagerthe faces manager to track for updated faces
guiStateManagerthe gui state manager to watch or
null

Definition at line 127 of file MapUpdaterState.java.

References com.realtime.crossfire.jxclient.map.MapUpdaterState.facesManager.

Member Function Documentation

◆ addAnimation()

void com.realtime.crossfire.jxclient.map.MapUpdaterState.addAnimation ( final int  animation,
final int  flags,
@NotNull final int []  faces 
)

An "addanim" command has been received.

Parameters
animationthe animation ID
flagsthe animation flags
facesthe faces list; must not be modified

Implements com.realtime.crossfire.jxclient.server.crossfire.CrossfireUpdateMapListener.

Definition at line 445 of file MapUpdaterState.java.

References com.realtime.crossfire.jxclient.animations.Animations.addAnimation().

+ Here is the call graph for this function:

◆ addCrossfireMapListener()

void com.realtime.crossfire.jxclient.map.MapUpdaterState.addCrossfireMapListener ( @NotNull final MapListener  listener)

Adds a listener to notify about changed map squares.

Parameters
listenerthe listener to add

Definition at line 136 of file MapUpdaterState.java.

References com.realtime.crossfire.jxclient.util.EventListenerList2< T extends EventListener >.add().

+ Here is the call graph for this function:

◆ addCrossfireMapScrollListener()

void com.realtime.crossfire.jxclient.map.MapUpdaterState.addCrossfireMapScrollListener ( @NotNull final MapScrollListener  listener)

Adds a listener to notify about scrolled maps.

Parameters
listenerthe listener to add

Definition at line 168 of file MapUpdaterState.java.

References com.realtime.crossfire.jxclient.util.EventListenerList2< T extends EventListener >.add().

Referenced by com.realtime.crossfire.jxclient.skin.events.MapScrollSkinEvent.MapScrollSkinEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addCrossfireNewmapListener()

void com.realtime.crossfire.jxclient.map.MapUpdaterState.addCrossfireNewmapListener ( @NotNull final NewmapListener  listener)

Adds a listener to notify about cleared maps.

Parameters
listenerthe listener to add

Definition at line 152 of file MapUpdaterState.java.

References com.realtime.crossfire.jxclient.util.EventListenerList2< T extends EventListener >.add().

+ Here is the call graph for this function:

◆ addMapSizeListener()

void com.realtime.crossfire.jxclient.map.MapUpdaterState.addMapSizeListener ( @NotNull final MapSizeListener  listener)

Adds a listener to be notified about map size changes.

Parameters
listenerthe listener to add

Definition at line 184 of file MapUpdaterState.java.

References com.realtime.crossfire.jxclient.util.EventListenerList2< T extends EventListener >.add().

+ Here is the call graph for this function:

◆ faceUpdated()

◆ getMap()

◆ getMapHeight()

int com.realtime.crossfire.jxclient.map.MapUpdaterState.getMapHeight ( )

Returns the height of the visible map area.

Returns
the height of the visible map area

Definition at line 437 of file MapUpdaterState.java.

References com.realtime.crossfire.jxclient.map.MapUpdaterState.mapHeight.

Referenced by com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.cmdRequest().

+ Here is the caller graph for this function:

◆ getMapWidth()

int com.realtime.crossfire.jxclient.map.MapUpdaterState.getMapWidth ( )

Returns the width of the visible map area.

Returns
the width of the visible map area

Definition at line 429 of file MapUpdaterState.java.

References com.realtime.crossfire.jxclient.map.MapUpdaterState.mapWidth.

Referenced by com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.cmdRequest().

+ Here is the caller graph for this function:

◆ magicMap()

void com.realtime.crossfire.jxclient.map.MapUpdaterState.magicMap ( final int  x,
final int  y,
final byte  data[][] 
)

Part of "magicmap" parsing: set the magic map color.

Parameters
xthe x-coordinate
ythe y-coordinate
datathe magic map data (y, x); must not be changed

Implements com.realtime.crossfire.jxclient.server.crossfire.CrossfireUpdateMapListener.

Definition at line 314 of file MapUpdaterState.java.

References com.realtime.crossfire.jxclient.map.MapUpdaterState.map, and com.realtime.crossfire.jxclient.map.CfMap.setMagicMap().

+ Here is the call graph for this function:

◆ mapAnimation()

void com.realtime.crossfire.jxclient.map.MapUpdaterState.mapAnimation ( @NotNull final Location  location,
final int  animationNum,
final int  animationType 
)

Part of "map2" parsing: set the animation of a cell.

Parameters
locationthe location
animationNumthe animation ID
animationTypethe animation type

Implements com.realtime.crossfire.jxclient.server.crossfire.CrossfireUpdateMapListener.

Definition at line 265 of file MapUpdaterState.java.

References com.realtime.crossfire.jxclient.map.CfMapAnimations.add(), com.realtime.crossfire.jxclient.animations.Animations.get(), com.realtime.crossfire.jxclient.map.MapUpdaterState.map, and com.realtime.crossfire.jxclient.map.CfMap.setFace().

+ Here is the call graph for this function:

◆ mapAnimationSpeed()

void com.realtime.crossfire.jxclient.map.MapUpdaterState.mapAnimationSpeed ( @NotNull final Location  location,
final int  animationSpeed 
)

Part of "map2" parsing: set the animation speed.

Parameters
locationthe location
animationSpeedthe animation speed

Implements com.realtime.crossfire.jxclient.server.crossfire.CrossfireUpdateMapListener.

Definition at line 283 of file MapUpdaterState.java.

References com.realtime.crossfire.jxclient.map.CfMapAnimations.updateSpeed().

+ Here is the call graph for this function:

◆ mapBegin()

◆ mapClear()

◆ mapDarkness()

void com.realtime.crossfire.jxclient.map.MapUpdaterState.mapDarkness ( final int  x,
final int  y,
final int  darkness 
)

Part of "map2" parsing: change the darkness of a cell.

Parameters
xthe x-coordinate
ythe y-coordinate
darknessthe darkness value

Implements com.realtime.crossfire.jxclient.server.crossfire.CrossfireUpdateMapListener.

Definition at line 303 of file MapUpdaterState.java.

References com.realtime.crossfire.jxclient.map.MapUpdaterState.map, and com.realtime.crossfire.jxclient.map.CfMap.setDarkness().

+ Here is the call graph for this function:

◆ mapEnd() [1/2]

◆ mapEnd() [2/2]

void com.realtime.crossfire.jxclient.map.MapUpdaterState.mapEnd ( final boolean  alwaysProcess)

Finishes processing of a set of map square changes.

Notifies listeners about changes.

Parameters
alwaysProcessif set, notify listeners even if no changes are present

Definition at line 335 of file MapUpdaterState.java.

References com.realtime.crossfire.jxclient.map.CfMap.getDirtyMapSquares(), and com.realtime.crossfire.jxclient.map.MapUpdaterState.map.

+ Here is the call graph for this function:

◆ mapFace() [1/2]

void com.realtime.crossfire.jxclient.map.MapUpdaterState.mapFace ( @NotNull final Location  location,
final int  faceNum 
)

◆ mapFace() [2/2]

void com.realtime.crossfire.jxclient.map.MapUpdaterState.mapFace ( @NotNull final Location  location,
final int  faceNum,
final boolean  clearAnimation 
)

Updates a map square by changing a face.

Parameters
locationthe location to update
faceNumthe face to set;
0
clears the square
clearAnimationwhether an animation should be cleared

Definition at line 241 of file MapUpdaterState.java.

References com.realtime.crossfire.jxclient.faces.FacesManager.getFace2(), com.realtime.crossfire.jxclient.faces.Face.getTileHeight(), com.realtime.crossfire.jxclient.faces.Face.getTileWidth(), com.realtime.crossfire.jxclient.map.MapUpdaterState.map, com.realtime.crossfire.jxclient.map.CfMapAnimations.remove(), and com.realtime.crossfire.jxclient.map.CfMap.setFace().

+ Here is the call graph for this function:

◆ mapScroll()

void com.realtime.crossfire.jxclient.map.MapUpdaterState.mapScroll ( final int  dx,
final int  dy 
)

◆ mapSmooth()

void com.realtime.crossfire.jxclient.map.MapUpdaterState.mapSmooth ( @NotNull final Location  location,
final int  smooth 
)

Part of "map2" parsing: set the smooth level.

Parameters
locationthe location
smooththe smooth value

Implements com.realtime.crossfire.jxclient.server.crossfire.CrossfireUpdateMapListener.

Definition at line 292 of file MapUpdaterState.java.

References com.realtime.crossfire.jxclient.map.MapUpdaterState.map, and com.realtime.crossfire.jxclient.map.CfMap.setSmooth().

+ Here is the call graph for this function:

◆ newMap()

◆ removeCrossfireMapListener()

void com.realtime.crossfire.jxclient.map.MapUpdaterState.removeCrossfireMapListener ( @NotNull final MapListener  listener)

Removes a listener to notify about changed map squares.

Parameters
listenerthe listener to remove

Definition at line 144 of file MapUpdaterState.java.

References com.realtime.crossfire.jxclient.util.EventListenerList2< T extends EventListener >.remove().

Referenced by com.realtime.crossfire.jxclient.gui.map.AbstractGUIMap.dispose().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeCrossfireMapScrollListener()

void com.realtime.crossfire.jxclient.map.MapUpdaterState.removeCrossfireMapScrollListener ( @NotNull final MapScrollListener  listener)

Removes a listener to notify about scrolled maps.

Parameters
listenerthe listener to remove

Definition at line 176 of file MapUpdaterState.java.

References com.realtime.crossfire.jxclient.util.EventListenerList2< T extends EventListener >.remove().

Referenced by com.realtime.crossfire.jxclient.skin.events.MapScrollSkinEvent.dispose(), and com.realtime.crossfire.jxclient.gui.map.AbstractGUIMap.dispose().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeCrossfireNewmapListener()

void com.realtime.crossfire.jxclient.map.MapUpdaterState.removeCrossfireNewmapListener ( @NotNull final NewmapListener  listener)

Removes a listener to notify about cleared maps.

Parameters
listenerthe listener to remove

Definition at line 160 of file MapUpdaterState.java.

References com.realtime.crossfire.jxclient.util.EventListenerList2< T extends EventListener >.remove().

Referenced by com.realtime.crossfire.jxclient.gui.map.AbstractGUIMap.dispose().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeMapSizeListener()

void com.realtime.crossfire.jxclient.map.MapUpdaterState.removeMapSizeListener ( @NotNull final MapSizeListener  listener)

Removes a listener to be notified about map size changes.

Parameters
listenerthe listener to remove

Definition at line 192 of file MapUpdaterState.java.

References com.realtime.crossfire.jxclient.util.EventListenerList2< T extends EventListener >.remove().

Referenced by com.realtime.crossfire.jxclient.gui.map.AbstractGUIMap.dispose().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reset()

void com.realtime.crossfire.jxclient.map.MapUpdaterState.reset ( )

Resets the animation state.

Definition at line 199 of file MapUpdaterState.java.

References com.realtime.crossfire.jxclient.map.MapUpdaterState.newMap(), and com.realtime.crossfire.jxclient.map.MapUpdaterState.sync.

+ Here is the call graph for this function:

◆ tick()

void com.realtime.crossfire.jxclient.map.MapUpdaterState.tick ( final int  tickNo)

A "tick" command has been received.

Parameters
tickNothe current tick

Implements com.realtime.crossfire.jxclient.server.crossfire.CrossfireTickListener.

Definition at line 453 of file MapUpdaterState.java.

References com.realtime.crossfire.jxclient.map.MapUpdaterState.sync, and com.realtime.crossfire.jxclient.map.CfMapAnimations.tick().

Referenced by com.realtime.crossfire.jxclient.map.MapUpdaterStateTest.testDisplayArtifacts1().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ animations

final Animations com.realtime.crossfire.jxclient.map.MapUpdaterState.animations
private

The defined animations.

Definition at line 68 of file MapUpdaterState.java.

◆ facesManager

final FacesManager com.realtime.crossfire.jxclient.map.MapUpdaterState.facesManager
private

The FacesManager to track for updated faces.

Definition at line 62 of file MapUpdaterState.java.

Referenced by com.realtime.crossfire.jxclient.map.MapUpdaterState.MapUpdaterState().

◆ map

◆ mapHeight

int com.realtime.crossfire.jxclient.map.MapUpdaterState.mapHeight
private

◆ mapListeners

final EventListenerList2<MapListener> com.realtime.crossfire.jxclient.map.MapUpdaterState.mapListeners = new EventListenerList2<>()
private

The listeners to notify about changed map squares.

Definition at line 90 of file MapUpdaterState.java.

◆ mapScrollListeners

final EventListenerList2<MapScrollListener> com.realtime.crossfire.jxclient.map.MapUpdaterState.mapScrollListeners = new EventListenerList2<>()
private

The listeners to notify about scrolled maps.

Definition at line 102 of file MapUpdaterState.java.

◆ mapSizeListeners

final EventListenerList2<MapSizeListener> com.realtime.crossfire.jxclient.map.MapUpdaterState.mapSizeListeners = new EventListenerList2<>()
private

The MapSizeListeners to be notified.

Definition at line 108 of file MapUpdaterState.java.

◆ mapWidth

int com.realtime.crossfire.jxclient.map.MapUpdaterState.mapWidth
private

◆ newmapListeners

final EventListenerList2<NewmapListener> com.realtime.crossfire.jxclient.map.MapUpdaterState.newmapListeners = new EventListenerList2<>()
private

The listeners to notify about cleared maps.

Definition at line 96 of file MapUpdaterState.java.

◆ outOfViewMultiFaces

final Collection<Location> com.realtime.crossfire.jxclient.map.MapUpdaterState.outOfViewMultiFaces = new HashSet<>()
private

All multi-tiled faces with heads outside the visible map area.

Definition at line 120 of file MapUpdaterState.java.

◆ sync

final Object com.realtime.crossfire.jxclient.map.MapUpdaterState.sync = new Object()
private

◆ visibleAnimations

final CfMapAnimations com.realtime.crossfire.jxclient.map.MapUpdaterState.visibleAnimations = new CfMapAnimations()
private

The animations in the visible map area.

Definition at line 114 of file MapUpdaterState.java.


The documentation for this class was generated from the following file: