22 package com.realtime.crossfire.jxclient.gui.map;
32 import java.awt.Color;
33 import java.awt.Dimension;
34 import java.awt.Graphics;
35 import java.awt.event.MouseEvent;
36 import org.jetbrains.annotations.NotNull;
37 import org.jetbrains.annotations.Nullable;
78 super(avoidCopyArea, tooltipManager, elementListener, name, mapUpdaterState, facesProvider,
new SmoothingRenderer(smoothFaces, facesProvider), darknessColors);
80 tileSize = facesProvider.getSize();
95 protected void markPlayer(@NotNull
final Graphics g,
final int dx,
final int dy) {
103 super.mouseClicked(e);
104 switch (e.getButton()) {
105 case MouseEvent.BUTTON1:
108 if (dx1 >= 0 && dy1 >= 0) {
111 final int dx2 = dx1/tileSize-mapWidth/2;
112 final int dy2 = dy1/tileSize-mapHeight/2;
113 if (dx2 < mapWidth && dy2 < mapHeight) {
114 crossfireServerConnection.
sendLookat(dx2, dy2);
119 case MouseEvent.BUTTON2:
120 case MouseEvent.BUTTON3:
Listener for GUIElement related events.
int mapHeight
The map height in squares.
GUIMap(final boolean avoidCopyArea, @NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final String name, @NotNull final MapUpdaterState mapUpdaterState, @NotNull final FacesProvider facesProvider, @NotNull final CrossfireServerConnection crossfireServerConnection, @NotNull final SmoothFaces smoothFaces, @NotNull final DarknessColors darknessColors)
Creates a new instance.
final TooltipManager tooltipManager
The TooltipManager to update.
Represents a square in a CfMap.
void markPlayer(@NotNull final Graphics g, final int dx, final int dy)
final boolean avoidCopyArea
Whether map scrolling is done by copying pixel areas.
int getOffsetY()
Returns the y offset for drawing the square at coordinate 0 of the map.
int getMapHeight()
Returns the map height in squares.
Implements the map model which is shown in the map and magic map views.
Manages image information ("faces") needed to display the map view, items, and spell icons...
Abstract base class for GUIElements that display map views.
final GUIElementListener elementListener
The GUIElementListener to notify.
void mouseClicked(@NotNull final MouseEvent e)
Will be called when the user has clicked (pressed+released) this element.This event will be delivered...
final String name
The name of this element.
final int tileSize
The size of one tile.
Utility class for mathematical functions.
Dimension getPreferredSize()
int getMapWidth()
Returns the map width in squares.
int mapWidth
The map width in squares.
final FacesProvider facesProvider
The FacesProvider for looking up faces.
Interface for face providers.
int getOffsetX()
Returns the x offset for drawing the square at coordinate 0 of the map.
Update a CfMap model from protocol commands.
final MapUpdaterState mapUpdaterState
The MapUpdaterState instance to display.
final DarknessColors darknessColors
The DarknessColors instance for converting darkness values into colors.
static int divRoundUp(final int numerator, final int denominator)
Returns the quotient of two values, rounded up to the nearest integer.
void paintColoredSquare(@NotNull final Graphics g, @NotNull final Color color, final int x, final int y)
Fills a square with one Color.
Renderer for painting smoothed faces into map views.
Utility class for converting darkness values into colors.
Adds encoding/decoding of crossfire protocol packets to a ServerConnection.
final CrossfireServerConnection crossfireServerConnection
The CrossfireServerConnection to monitor.
void paintSquareBackground(@NotNull final Graphics g, final int px, final int py, final boolean hasImage, @NotNull final CfMapSquare mapSquare)
void sendLookat(final int dx, int dy)
Sends a "lookat" command to the server.
int getPreferredMapWidth()
Returns the minimal map width in squares needed to fill the map area.
Maintains smoothing information received from the Crossfire server.
int getPreferredMapHeight()
Returns the minimal map height in squares needed to fill the map area.
static final long serialVersionUID
The serial version UID.