java.lang.Object com.realtime.crossfire.jxclient.mapupdater.CfMapUpdater
public class CfMapUpdater
Utility class to update a CfMap
model from protocol commands.
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
.
Field Summary | |
---|---|
private Animations |
animations
The defined animations. |
private CrossfireUpdateMapListener |
crossfireUpdateMapListener
The listener to detect map model changes. |
private FacesManager |
facesManager
The FacesManager to track for updated faces. |
private FacesManagerListener |
facesManagerListener
The listener to detect updated faces. |
private GuiStateListener |
guiStateListener
The GuiStateListener for detecting established or dropped
connections. |
private int |
height
The height of the visible map area. |
private CfMap |
map
The current CfMap instance. |
private java.util.Collection<MapListener> |
mapListeners
The listeners to notify about changed map squares. |
private java.util.Collection<MapScrollListener> |
mapScrollListeners
The listeners to notify about scrolled maps. |
private java.util.Collection<MapSizeListener> |
mapSizeListeners
The MapSizeListener s to be notified. |
private java.util.Collection<NewmapListener> |
newmapListeners
The listeners to notify about cleared maps. |
private java.util.Collection<Location> |
outOfViewMultiFaces
All multi-tiled faces with heads outside the visible map area. |
private java.lang.Object |
sync
The object used for synchronization. |
private CfMapAnimations |
visibleAnimations
The animations in the visible map area. |
private int |
width
The width of the visible map area. |
Constructor Summary | |
---|---|
CfMapUpdater(CrossfireServerConnection crossfireServerConnection,
FacesManager facesManager,
GuiStateManager guiStateManager)
Creates a new instance. |
|
CfMapUpdater(FacesManager facesManager)
Creates a new instance. |
Method Summary | |
---|---|
void |
addCrossfireMapListener(MapListener listener)
Adds a listener to notify about changed map squares. |
void |
addCrossfireMapScrollListener(MapScrollListener listener)
Adds a listener to notify about scrolled maps. |
void |
addCrossfireNewmapListener(NewmapListener listener)
Adds a listener to notify about cleared maps. |
void |
addMapSizeListener(MapSizeListener listener)
Adds a listener to be notified about map size changes. |
private Face |
getFace(int faceNum)
Returns the Face instance by face ID. |
int |
getHeight()
Returns the height of the visible map area. |
CfMap |
getMap()
Returns the current map instance. |
CfMapAnimations |
getMapAnimations()
Returns the CfMapAnimations instance. |
int |
getWidth()
Returns the width of the visible map area. |
void |
processMagicMap(int x,
int y,
int color)
Finishes processing of a set of map square changes. |
private void |
processMapAnimation(int x,
int y,
int layer,
Animation animation,
int type)
Updates a map square by changing an animation. |
private void |
processMapAnimationSpeed(int x,
int y,
int layer,
int animationSpeed)
Updates a map square by changing the animation speed. |
void |
processMapBegin()
Starts processing of a set of map square changes. |
void |
processMapClear(int x,
int y)
Updates a map square by clearing it. |
private void |
processMapDarkness(int x,
int y,
int darkness)
Updates a map square by changing the darkness value. |
void |
processMapEnd(boolean alwaysProcess)
Finishes processing of a set of map square changes. |
void |
processMapFace(Location location,
int faceNum,
boolean clearAnimation)
Updates a map square by changing a face. |
void |
processMapScroll(int dx,
int dy)
Processes a map scroll command. |
void |
processNewMap(int width,
int height)
Processes a newmap command. |
void |
removeCrossfireMapListener(MapListener listener)
Removes a listener to notify about changed map squares. |
void |
removeCrossfireMapScrollListener(MapScrollListener listener)
Removes a listener to notify about scrolled maps. |
void |
removeCrossfireNewmapListener(NewmapListener listener)
Removes a listener to notify about cleared maps. |
void |
removeMapSizeListener(MapSizeListener listener)
Removes a listener to be notified about map size changes. |
private void |
reset()
Resets the animation state. |
private void |
updateFace(int faceNum)
Processes an updated face image. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
@NotNull private final Animations animations
@NotNull private final CrossfireUpdateMapListener crossfireUpdateMapListener
@NotNull private final FacesManager facesManager
FacesManager
to track for updated faces.
@NotNull private final FacesManagerListener facesManagerListener
@NotNull private final GuiStateListener guiStateListener
GuiStateListener
for detecting established or dropped
connections.
private int height
@NotNull private CfMap map
CfMap
instance.
@NotNull private final java.util.Collection<MapListener> mapListeners
@NotNull private final java.util.Collection<MapScrollListener> mapScrollListeners
@NotNull private final java.util.Collection<MapSizeListener> mapSizeListeners
MapSizeListener
s to be notified.
@NotNull private final java.util.Collection<NewmapListener> newmapListeners
@NotNull private final java.util.Collection<Location> outOfViewMultiFaces
@NotNull private final java.lang.Object sync
@NotNull private final CfMapAnimations visibleAnimations
private int width
Constructor Detail |
---|
public CfMapUpdater(@NotNull CrossfireServerConnection crossfireServerConnection, @NotNull FacesManager facesManager, @NotNull GuiStateManager guiStateManager)
crossfireServerConnection
- the connection to monitorfacesManager
- the faces manager to track for updated facesguiStateManager
- the gui state manager to watchpublic CfMapUpdater(@NotNull FacesManager facesManager)
facesManager
- the faces manager to track for updated facesMethod Detail |
---|
public void addCrossfireMapListener(@NotNull MapListener listener)
listener
- the listener to addpublic void addCrossfireMapScrollListener(@NotNull MapScrollListener listener)
listener
- the listener to addpublic void addCrossfireNewmapListener(@NotNull NewmapListener listener)
listener
- the listener to addpublic void addMapSizeListener(@NotNull MapSizeListener listener)
listener
- the listener to add@Nullable private Face getFace(int faceNum)
Face
instance by face ID.
faceNum
- the face ID
null
if
faceNum==0
public int getHeight()
@NotNull public CfMap getMap()
@NotNull public CfMapAnimations getMapAnimations()
CfMapAnimations
instance.
public int getWidth()
public void processMagicMap(int x, int y, int color)
x
- the x-coordinate of the squarey
- the y-coordinate of the squarecolor
- the magic map color to setprivate void processMapAnimation(int x, int y, int layer, @NotNull Animation animation, int type)
x
- the x-coordinate of the squarey
- the y-coordinate of the squarelayer
- the layer to updateanimation
- the animation to settype
- the animation typeprivate void processMapAnimationSpeed(int x, int y, int layer, int animationSpeed)
x
- the x-coordinate of the squarey
- the y-coordinate of the squarelayer
- the layer to updateanimationSpeed
- the animation speed to setpublic void processMapBegin()
public void processMapClear(int x, int y)
x
- the x-coordinate of the squarey
- the y-coordinate of the squareprivate void processMapDarkness(int x, int y, int darkness)
x
- the x-coordinate of the squarey
- the y-coordinate of the squaredarkness
- the darkness value to setpublic void processMapEnd(boolean alwaysProcess)
alwaysProcess
- if set, notify listeners even if no changes are
presentpublic void processMapFace(@NotNull 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 processMapScroll(int dx, int dy)
dx
- the distance to scroll in x-direction in squaresdy
- the distance to scroll in y-direction in squarespublic void processNewMap(int width, int height)
width
- the width of the visible map areaheight
- the height of the visible map areapublic void removeCrossfireMapListener(@NotNull MapListener listener)
listener
- the listener to removepublic void removeCrossfireMapScrollListener(@NotNull MapScrollListener listener)
listener
- the listener to removepublic void removeCrossfireNewmapListener(@NotNull NewmapListener listener)
listener
- the listener to removepublic void removeMapSizeListener(@NotNull MapSizeListener listener)
listener
- the listener to removeprivate void reset()
private void updateFace(int faceNum)
faceNum
- the face that has changed