public class MapUpdaterState extends java.lang.Object implements CrossfireTickListener, CrossfireUpdateMapListener, com.realtime.crossfire.jxclient.faces.FacesManagerListener
CfMap model from protocol commands.
The map updater is called from two threads: the ClientSocket reading commands
received from the Crossfire server, and FileCacheFaceQueue
reading faces from the (file) cache. Synchronization is by sync and
applies to the whole map model map.
| Constructor and Description |
|---|
MapUpdaterState(@NotNull com.realtime.crossfire.jxclient.faces.FacesManager facesManager,
@NotNull com.realtime.crossfire.jxclient.animations.Animations animations,
@NotNull CfAnimations cfAnimations)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addCrossfireMapListener(@NotNull com.realtime.crossfire.jxclient.map.MapListener listener)
Adds a listener to notify about changed map squares.
|
void |
addCrossfireMapScrollListener(@NotNull com.realtime.crossfire.jxclient.map.MapScrollListener listener)
Adds a listener to notify about scrolled maps.
|
void |
addCrossfireNewmapListener(@NotNull com.realtime.crossfire.jxclient.map.NewmapListener listener)
Adds a listener to notify about cleared maps.
|
void |
addMapSizeListener(@NotNull com.realtime.crossfire.jxclient.map.MapSizeListener listener)
Adds a listener to be notified about map size changes.
|
void |
faceUpdated(@NotNull com.realtime.crossfire.jxclient.faces.Face face) |
@NotNull com.realtime.crossfire.jxclient.map.CfMap |
getMap()
Returns the current map instance.
|
int |
getMapHeight()
Returns the height of the visible map area.
|
int |
getMapWidth()
Returns the width of the visible map area.
|
void |
magicMap(int x,
int y,
byte[][] data)
Part of "magicmap" parsing: set the magic map color.
|
void |
mapAnimation(@NotNull com.realtime.crossfire.jxclient.map.Location location,
int animationNum,
int animationType)
Part of "map2" parsing: set the animation of a cell.
|
void |
mapAnimationSpeed(@NotNull com.realtime.crossfire.jxclient.map.Location location,
int animationSpeed)
Part of "map2" parsing: set the animation speed.
|
@NotNull java.lang.Object |
mapBegin()
Parsing of a "map2" command has been started.
|
void |
mapClear(int x,
int y)
Part of "map2" parsing: clear a cell.
|
void |
mapDarkness(int x,
int y,
int darkness)
Part of "map2" parsing: change the darkness of a cell.
|
void |
mapEnd()
Parsing of "map2" has been finished.
|
void |
mapEnd(boolean alwaysProcess)
Finishes processing of a set of map square changes.
|
void |
mapFace(@NotNull com.realtime.crossfire.jxclient.map.Location location,
int faceNum)
Part of "map2" parsing: set the face of a cell.
|
void |
mapFace(@NotNull com.realtime.crossfire.jxclient.map.Location location,
int faceNum,
boolean clearAnimation)
Updates a map square by changing a face.
|
void |
mapScroll(int dx,
int dy)
Part of "map2" parsing: scroll the map view.
|
void |
mapSmooth(@NotNull com.realtime.crossfire.jxclient.map.Location location,
int smooth)
Part of "map2" parsing: set the smooth level.
|
void |
newMap(int mapWidth,
int mapHeight)
A "newmap" command has been received.
|
void |
removeCrossfireMapListener(@NotNull com.realtime.crossfire.jxclient.map.MapListener listener)
Removes a listener to notify about changed map squares.
|
void |
removeCrossfireMapScrollListener(@NotNull com.realtime.crossfire.jxclient.map.MapScrollListener listener)
Removes a listener to notify about scrolled maps.
|
void |
removeCrossfireNewmapListener(@NotNull com.realtime.crossfire.jxclient.map.NewmapListener listener)
Removes a listener to notify about cleared maps.
|
void |
removeMapSizeListener(@NotNull com.realtime.crossfire.jxclient.map.MapSizeListener listener)
Removes a listener to be notified about map size changes.
|
void |
reset()
Resets the animation state.
|
void |
tick(int tickNo)
A "tick" command has been received.
|
public MapUpdaterState(@NotNull
@NotNull com.realtime.crossfire.jxclient.faces.FacesManager facesManager,
@NotNull
@NotNull com.realtime.crossfire.jxclient.animations.Animations animations,
@NotNull
@NotNull CfAnimations cfAnimations)
facesManager - the faces manager to track for updated facesanimations - the known animationscfAnimations - the animations manager to usepublic void addCrossfireMapListener(@NotNull
@NotNull com.realtime.crossfire.jxclient.map.MapListener listener)
listener - the listener to addpublic void removeCrossfireMapListener(@NotNull
@NotNull com.realtime.crossfire.jxclient.map.MapListener listener)
listener - the listener to removepublic void addCrossfireNewmapListener(@NotNull
@NotNull com.realtime.crossfire.jxclient.map.NewmapListener listener)
listener - the listener to addpublic void removeCrossfireNewmapListener(@NotNull
@NotNull com.realtime.crossfire.jxclient.map.NewmapListener listener)
listener - the listener to removepublic void addCrossfireMapScrollListener(@NotNull
@NotNull com.realtime.crossfire.jxclient.map.MapScrollListener listener)
listener - the listener to addpublic void removeCrossfireMapScrollListener(@NotNull
@NotNull com.realtime.crossfire.jxclient.map.MapScrollListener listener)
listener - the listener to removepublic void addMapSizeListener(@NotNull
@NotNull com.realtime.crossfire.jxclient.map.MapSizeListener listener)
listener - the listener to addpublic void removeMapSizeListener(@NotNull
@NotNull com.realtime.crossfire.jxclient.map.MapSizeListener listener)
listener - the listener to removepublic void reset()
@NotNull public @NotNull java.lang.Object mapBegin()
CrossfireUpdateMapListenermapBegin in interface CrossfireUpdateMapListenersynchronized
while calling any other function (except newMap())public void mapClear(int x,
int y)
CrossfireUpdateMapListenermapClear in interface CrossfireUpdateMapListenerx - the x-coordinatey - the y-coordinatepublic void mapFace(@NotNull
@NotNull com.realtime.crossfire.jxclient.map.Location location,
int faceNum)
CrossfireUpdateMapListenermapFace in interface CrossfireUpdateMapListenerlocation - the locationfaceNum - the face IDpublic void mapFace(@NotNull
@NotNull com.realtime.crossfire.jxclient.map.Location location,
int faceNum,
boolean clearAnimation)
location - the location to updatefaceNum - the face to set; 0 clears the squareclearAnimation - whether an animation should be clearedpublic void mapAnimation(@NotNull
@NotNull com.realtime.crossfire.jxclient.map.Location location,
int animationNum,
int animationType)
CrossfireUpdateMapListenermapAnimation in interface CrossfireUpdateMapListenerlocation - the locationanimationNum - the animation IDanimationType - the animation typepublic void mapAnimationSpeed(@NotNull
@NotNull com.realtime.crossfire.jxclient.map.Location location,
int animationSpeed)
CrossfireUpdateMapListenermapAnimationSpeed in interface CrossfireUpdateMapListenerlocation - the locationanimationSpeed - the animation speedpublic void mapSmooth(@NotNull
@NotNull com.realtime.crossfire.jxclient.map.Location location,
int smooth)
CrossfireUpdateMapListenermapSmooth in interface CrossfireUpdateMapListenerlocation - the locationsmooth - the smooth valuepublic void mapDarkness(int x,
int y,
int darkness)
CrossfireUpdateMapListenermapDarkness in interface CrossfireUpdateMapListenerx - the x-coordinatey - the y-coordinatedarkness - the darkness valuepublic void magicMap(int x,
int y,
byte[][] data)
CrossfireUpdateMapListenermagicMap in interface CrossfireUpdateMapListenerx - the x-coordinatey - the y-coordinatedata - the magic map data (y, x); must not be changedpublic void mapEnd()
CrossfireUpdateMapListenermapEnd in interface CrossfireUpdateMapListenerpublic void mapEnd(boolean alwaysProcess)
alwaysProcess - if set, notify listeners even if no changes are
presentpublic void mapScroll(int dx,
int dy)
CrossfireUpdateMapListenermapScroll in interface CrossfireUpdateMapListenerdx - the x-distancedy - the y-distancepublic void faceUpdated(@NotNull
@NotNull com.realtime.crossfire.jxclient.faces.Face face)
faceUpdated in interface com.realtime.crossfire.jxclient.faces.FacesManagerListenerpublic void newMap(int mapWidth,
int mapHeight)
CrossfireUpdateMapListenernewMap in interface CrossfireUpdateMapListenermapWidth - the map widthmapHeight - the map height@NotNull public @NotNull com.realtime.crossfire.jxclient.map.CfMap getMap()
public int getMapWidth()
public int getMapHeight()
public void tick(int tickNo)
CrossfireTickListenertick in interface CrossfireTickListenertickNo - the current tick