 |
Crossfire JXClient, Trunk
|
Go to the documentation of this file.
23 package com.realtime.crossfire.jxclient.map;
33 import java.util.Collection;
34 import java.util.HashSet;
36 import org.jetbrains.annotations.NotNull;
55 private final Object
sync =
new Object();
141 public void mapFace(@NotNull
final Location location,
final int faceNum) {
221 synchronized (
sync) {
234 assert Thread.holdsLock(
sync);
244 mapFace(location, faceNum,
true);
253 public void mapFace(@NotNull
final Location location,
final int faceNum,
final boolean clearAnimation) {
254 assert Thread.holdsLock(
sync);
255 if (clearAnimation) {
259 final int x = location.getX();
260 final int y = location.getY();
275 assert Thread.holdsLock(
sync);
277 if (animation ==
null) {
278 System.err.println(
"unknown animation id "+animationNum+
", ignoring");
283 map.
setFace(location.getX(), location.getY(), location.getLayer(),
null);
290 assert Thread.holdsLock(
sync);
296 assert Thread.holdsLock(
sync);
298 map.
setSmooth(location.getX(), location.getY(), location.getLayer(), smooth);
303 public void mapDarkness(
final int x,
final int y,
final int darkness) {
304 assert Thread.holdsLock(
sync);
311 public void magicMap(
final int x,
final int y,
final byte @NotNull [] @NotNull [] data) {
312 assert Thread.holdsLock(
sync);
329 public void mapEnd(
final boolean alwaysProcess) {
330 assert Thread.holdsLock(
sync);
333 if (!alwaysProcess && squares.isEmpty()) {
338 listener.mapChanged(
map, squares);
345 assert Thread.holdsLock(
sync);
349 map.
setFace(location.getX(), location.getY(), location.getLayer(),
null);
361 mapscrollListener.mapScrolled(dx, dy);
378 synchronized (
sync) {
379 final boolean changed = this.mapWidth !=
mapWidth || this.mapHeight !=
mapHeight;
396 listener.commandNewmapReceived();
431 public void tick(
final int tickNo) {
432 synchronized (
sync) {
Maintains a mapping of face numbers to face data.
Interface for listeners interested in received "newmap" messages.
MapUpdaterState(@NotNull final FacesManager facesManager, @NotNull final Animations animations, @NotNull final CfAnimations cfAnimations)
Creates a new instance.
void mapScroll(final int dx, final int dy)
Part of "map2" parsing: scroll the map view.
void setFace(final int x, final int y, final int layer, @Nullable final Face face)
Sets the face of one square.
Interface for listeners interested in changes within CfMap instances.
void setDarkness(final int x, final int y, final int darkness)
Sets the darkness value of one square.
void mapFace(@NotNull final Location location, final int faceNum)
Part of "map2" parsing: set the face of a cell.
final CfAnimations cfAnimations
The animations in the visible map area.
Animation get(final int animationId)
Returns the animation for an animation id.
final EventListenerList2< NewmapListener > newmapListeners
The listeners to notify about cleared maps.
void tick(final int tickNo)
A "tick" command has been received.
void addCrossfireMapScrollListener(@NotNull final MapScrollListener listener)
Adds a listener to notify about scrolled maps.
Manages animations received from the server.
Represents a map (as seen by the client).
void mapSmooth(@NotNull final Location location, final int smooth)
Part of "map2" parsing: set the smooth level.
void removeCrossfireMapListener(@NotNull final MapListener listener)
Removes a listener to notify about changed map squares.
void removeMapSizeListener(@NotNull final MapSizeListener listener)
Removes a listener to be notified about map size changes.
Interface for listeners interested in FacesManager events.
void newMap(final int mapWidth, final int mapHeight)
A "newmap" command has been received.
int mapWidth
The width of the visible map area.
Manages animations received from the server.
void clearSquare(final int x, final int y)
Clears the content of one square.
Manages image information ("faces") needed to display the map view, items, and spell icons.
void mapSetSize(final int mapWidth, final int mapHeight)
Updates the map size.
void addCrossfireNewmapListener(@NotNull final NewmapListener listener)
Adds a listener to notify about cleared maps.
void addCrossfireMapListener(@NotNull final MapListener listener)
Adds a listener to notify about changed map squares.
A list of event listeners.
void setMagicMap(final int x0, final int y0, final byte @NotNull[] @NotNull[] data)
Sets the magic map color of one square.
final EventListenerList2< MapScrollListener > mapScrollListeners
The listeners to notify about scrolled maps.
void faceUpdated(@NotNull final Face face)
Called when a Face has been updated.
void setMapListener(@NotNull final CfAnimationsMapListener mapListener)
Sets the CfAnimationsMapListener to notify of changes.
int mapHeight
The height of the visible map area.
void mapScroll(final int dx, final int dy)
Scrolls the map animations.
void mapUpdateSpeed(@NotNull final Location location, final int speed)
Updates the map animation speed value.
final Animations animations
The defined animations.
void setSmooth(final int x, final int y, final int layer, final int smooth)
Sets the smooth value of one square.
void mapDarkness(final int x, final int y, final int darkness)
Part of "map2" parsing: change the darkness of a cell.
int getMapHeight()
Returns the height of the visible map area.
CfMap getMap()
Returns the current map instance.
final EventListenerList2< MapSizeListener > mapSizeListeners
The MapSizeListeners to be notified.
void updateFace(final int faceNum, final int width, final int height)
Processes an updated face image.
void mapFace(@NotNull final Location location, final int faceNum, final boolean clearAnimation)
Updates a map square by changing a face.
void magicMap(final int x, final int y, final byte @NotNull[] @NotNull[] data)
Part of "magicmap" parsing: set the magic map color.
Object mapBegin()
Parsing of a "map2" command has been started.
final Object sync
The object used for synchronization.
void mapAnimation(@NotNull final Location location, final int animationNum, final int animationType)
Part of "map2" parsing: set the animation of a cell.
final FacesManager facesManager
The FacesManager to track for updated faces.
Interface for listeners interested in "tick" commands.
Listener for clients interested in map size changes.
Manages a set of animated faces.
void reset()
Resets the animation state.
final Collection< Location > outOfViewMultiFaces
All multi-tiled faces with heads outside the visible map area.
void tick(final int tickNo)
Processes a tick command.
Interface for listeners interested in map related commands.
final CfMap map
The current CfMap instance.
void mapRemove(final int x, final int y)
Removes all visible map animations for a tile.
void addMapSizeListener(@NotNull final MapSizeListener listener)
Adds a listener to be notified about map size changes.
int getTileWidth()
Returns the face width in tiles.
void mapEnd()
Parsing of "map2" has been finished.
void mapEnd(final boolean alwaysProcess)
Finishes processing of a set of map square changes.
int getMapWidth()
Returns the width of the visible map area.
void removeCrossfireNewmapListener(@NotNull final NewmapListener listener)
Removes a listener to notify about cleared maps.
void mapAnimationSpeed(@NotNull final Location location, final int animationSpeed)
Part of "map2" parsing: set the animation speed.
Set< CfMapSquare > getDirtyMapSquares()
Returns the dirty map squares.
void mapAdd(@NotNull final Location location, @NotNull final Animation animation, final int type)
Adds a visible map animation.
boolean processMapScroll(final int dx, final int dy, final int width, final int height)
Processes a map scroll command.
Update a CfMap model from protocol commands.
void reset(final int mapWidth, final int mapHeight)
Clears the map contents.
void mapClear(final int x, final int y)
Part of "map2" parsing: clear a cell.
int getTileHeight()
Returns the face height in tiles.
final EventListenerList2< MapListener > mapListeners
The listeners to notify about changed map squares.
void mapClear()
Forgets all map animations.
void removeCrossfireMapScrollListener(@NotNull final MapScrollListener listener)
Removes a listener to notify about scrolled maps.
Face getFace2(int faceNum)
Returns the Face instance for a given face ID.