Crossfire JXClient, Trunk
Public Member Functions | Private Attributes | List of all members
com.realtime.crossfire.jxclient.map.MapUpdaterState Class Reference
Inheritance diagram for com.realtime.crossfire.jxclient.map.MapUpdaterState:
Inheritance graph
Collaboration diagram for com.realtime.crossfire.jxclient.map.MapUpdaterState:
Collaboration graph

Public Member Functions

void addCrossfireMapListener (@NotNull final MapListener listener)
 
void addCrossfireMapScrollListener (@NotNull final MapScrollListener listener)
 
void addCrossfireNewmapListener (@NotNull final NewmapListener listener)
 
void addMapSizeListener (@NotNull final MapSizeListener listener)
 
void faceUpdated (@NotNull final Face face)
 
CfMap getMap ()
 
int getMapHeight ()
 
int getMapWidth ()
 
void magicMap (final int x, final int y, final byte @NotNull[] @NotNull[] data)
 
void mapAnimation (@NotNull final Location location, final int animationNum, final int animationType)
 
void mapAnimationSpeed (@NotNull final Location location, final int animationSpeed)
 
Object mapBegin ()
 
void mapClear (final int x, final int y)
 
void mapDarkness (final int x, final int y, final int darkness)
 
void mapEnd ()
 
void mapEnd (final boolean alwaysProcess)
 
void mapFace (@NotNull final Location location, final int faceNum)
 
void mapFace (@NotNull final Location location, final int faceNum, final boolean clearAnimation)
 
void mapScroll (final int dx, final int dy)
 
void mapSmooth (@NotNull final Location location, final int smooth)
 
 MapUpdaterState (@NotNull final FacesManager facesManager, @NotNull final Animations animations, @NotNull final CfAnimations cfAnimations)
 
void newMap (final int mapWidth, final int mapHeight)
 
void removeCrossfireMapListener (@NotNull final MapListener listener)
 
void removeCrossfireMapScrollListener (@NotNull final MapScrollListener listener)
 
void removeCrossfireNewmapListener (@NotNull final NewmapListener listener)
 
void removeMapSizeListener (@NotNull final MapSizeListener listener)
 
void reset ()
 
void tick (final int tickNo)
 

Private Attributes

final Animations animations
 
final CfAnimations cfAnimations
 
final FacesManager facesManager
 
final CfMap map = new CfMap()
 
int mapHeight
 
final EventListenerList2< MapListenermapListeners = new EventListenerList2<>()
 
final EventListenerList2< MapScrollListenermapScrollListeners = new EventListenerList2<>()
 
final EventListenerList2< MapSizeListenermapSizeListeners = new EventListenerList2<>()
 
int mapWidth
 
final EventListenerList2< NewmapListenernewmapListeners = new EventListenerList2<>()
 
final Collection< LocationoutOfViewMultiFaces = new HashSet<>()
 
final Object sync = new Object()
 

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 49 of file MapUpdaterState.java.

Constructor & Destructor Documentation

◆ MapUpdaterState()

com.realtime.crossfire.jxclient.map.MapUpdaterState.MapUpdaterState ( @NotNull final FacesManager  facesManager,
@NotNull final Animations  animations,
@NotNull final CfAnimations  cfAnimations 
)

Member Function Documentation

◆ 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 157 of file MapUpdaterState.java.

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

◆ 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 189 of file MapUpdaterState.java.

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

Referenced by com.realtime.crossfire.jxclient.skin.events.MapScrollSkinEvent.MapScrollSkinEvent(), and com.realtime.crossfire.jxclient.scripts.AbstractScriptProcess.run().

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 173 of file MapUpdaterState.java.

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

Referenced by com.realtime.crossfire.jxclient.scripts.AbstractScriptProcess.run().

Here is the caller 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 205 of file MapUpdaterState.java.

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

◆ faceUpdated()

void com.realtime.crossfire.jxclient.map.MapUpdaterState.faceUpdated ( @NotNull final Face  face)

◆ getMap()

CfMap com.realtime.crossfire.jxclient.map.MapUpdaterState.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 424 of file MapUpdaterState.java.

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

Referenced by com.realtime.crossfire.jxclient.scripts.AbstractScriptProcess.cmdRequest(), and com.realtime.crossfire.jxclient.scripts.AbstractScriptProcess.commandSentMap().

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 414 of file MapUpdaterState.java.

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

Referenced by com.realtime.crossfire.jxclient.scripts.AbstractScriptProcess.cmdRequest(), and com.realtime.crossfire.jxclient.scripts.AbstractScriptProcess.commandSentMap().

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 @NotNull @[]NotNull[]  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 311 of file MapUpdaterState.java.

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

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 
)

◆ 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 289 of file MapUpdaterState.java.

References com.realtime.crossfire.jxclient.map.MapUpdaterState.cfAnimations, com.realtime.crossfire.jxclient.map.CfAnimations.mapUpdateSpeed(), and com.realtime.crossfire.jxclient.map.MapUpdaterState.sync.

Here is the call graph for this function:

◆ mapBegin()

Object com.realtime.crossfire.jxclient.map.MapUpdaterState.mapBegin ( )

◆ mapClear()

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

◆ 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, com.realtime.crossfire.jxclient.map.CfMap.setDarkness(), and com.realtime.crossfire.jxclient.map.MapUpdaterState.sync.

Here is the call graph for this function:

◆ mapEnd() [1/2]

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

◆ 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 329 of file MapUpdaterState.java.

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

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 
)

◆ 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 295 of file MapUpdaterState.java.

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

Here is the call graph for this function:

◆ newMap()

void com.realtime.crossfire.jxclient.map.MapUpdaterState.newMap ( final int  mapWidth,
final int  mapHeight 
)

◆ 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 165 of file MapUpdaterState.java.

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

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

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 197 of file MapUpdaterState.java.

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

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

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 181 of file MapUpdaterState.java.

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

Referenced by com.realtime.crossfire.jxclient.gui.map.AbstractGUIMap.dispose(), and com.realtime.crossfire.jxclient.scripts.AbstractScriptProcess.run().

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 213 of file MapUpdaterState.java.

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

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

Here is the caller graph for this function:

◆ reset()

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

◆ 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 431 of file MapUpdaterState.java.

References com.realtime.crossfire.jxclient.map.MapUpdaterState.cfAnimations, com.realtime.crossfire.jxclient.map.MapUpdaterState.sync, and com.realtime.crossfire.jxclient.map.CfAnimations.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

◆ cfAnimations

final CfAnimations com.realtime.crossfire.jxclient.map.MapUpdaterState.cfAnimations
private

◆ facesManager

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

◆ map

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

◆ mapHeight

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

◆ mapListeners

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

◆ mapScrollListeners

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

◆ mapSizeListeners

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

◆ mapWidth

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

◆ newmapListeners

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

◆ outOfViewMultiFaces

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

◆ sync

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

The documentation for this class was generated from the following file:
com.realtime.crossfire.jxclient.map.MapUpdaterState.newMap
void newMap(final int mapWidth, final int mapHeight)
Definition: MapUpdaterState.java:377