Crossfire JXClient, Trunk  R20561
CfMapPatch.java
Go to the documentation of this file.
1 /*
2  * This file is part of JXClient, the Fullscreen Java Crossfire Client.
3  *
4  * JXClient is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * JXClient is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with JXClient; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  * Copyright (C) 2005-2008 Yann Chachkoff.
19  * Copyright (C) 2006-2011 Andreas Kirschbaum.
20  */
21 
22 package com.realtime.crossfire.jxclient.map;
23 
25 import org.jetbrains.annotations.NotNull;
26 import org.jetbrains.annotations.Nullable;
27 
32 public class CfMapPatch {
33 
37  public static final int SIZE_LOG = 5;
38 
42  public static final int SIZE = 1<<SIZE_LOG;
43 
48  @NotNull
49  private final CfMapSquare[][] square = new CfMapSquare[SIZE][SIZE];
50 
59  public CfMapPatch(@NotNull final CfMap map, final int x0, final int y0) {
60  for (int y = 0; y < SIZE; y++) {
61  for (int x = 0; x < SIZE; x++) {
62  square[x][y] = new CfMapSquare(map, x0+x, y0+y);
63  }
64  }
65  }
66 
72  public void dirty(final int x, final int y) {
73  square[x][y].dirty();
74  }
75 
82  public void clearSquare(final int x, final int y) {
83  square[x][y].clear();
84  }
85 
93  public boolean setDarkness(final int x, final int y, final int darkness) {
94  return square[x][y].setDarkness(darkness);
95  }
96 
104  public int getDarkness(final int x, final int y) {
105  return square[x][y].getDarkness();
106  }
107 
117  public int setSmooth(final int x, final int y, final int layer, final int smooth) {
118  return square[x][y].setSmooth(layer, smooth);
119  }
120 
128  public int getSmooth(final int x, final int y, final int layer) {
129  return square[x][y].getSmooth(layer);
130  }
131 
139  public boolean setColor(final int x, final int y, final int color) {
140  return square[x][y].setColor(color);
141  }
142 
149  public int getColor(final int x, final int y) {
150  return square[x][y].getColor();
151  }
152 
160  @Nullable
161  public Face getFace(final int x, final int y, final int layer) {
162  return square[x][y].getFace(layer);
163  }
164 
176  public void setHeadMapSquare(final int x, final int y, final int layer, @Nullable final CfMapSquare mapSquare, final boolean setAlways) {
177  square[x][y].setHeadMapSquare(layer, mapSquare, setAlways);
178  }
179 
188  @Nullable
189  public CfMapSquare getHeadMapSquare(final int x, final int y, final int layer) {
190  return square[x][y].getHeadMapSquare(layer);
191  }
192 
199  public boolean isFogOfWar(final int x, final int y) {
200  return square[x][y].isFogOfWar();
201  }
202 
209  public boolean resetFogOfWar(final int x, final int y) {
210  return square[x][y].resetFogOfWar();
211  }
212 
219  @NotNull
220  public CfMapSquare getSquare(final int x, final int y) {
221  return square[x][y];
222  }
223 
224 }
CfMapSquare getHeadMapSquare(final int layer)
Returns the map square of the head of a multi-square object.
CfMapSquare getSquare(final int x, final int y)
Returns one map square.
Represents a square in a CfMap.
int getSmooth(final int layer)
Returns the smooth value of this square.
Represents a map (as seen by the client).
Definition: CfMap.java:45
static final int SIZE
Size of patches in x- and y-direction.
Definition: CfMapPatch.java:42
void clearSquare(final int x, final int y)
Clears the content of one square.
Definition: CfMapPatch.java:82
void setHeadMapSquare(final int x, final int y, final int layer, @Nullable final CfMapSquare mapSquare, final boolean setAlways)
Sets the map square containing the head face for a layer.
void dirty()
Marks this square as dirty, i.e., needing redraw.
int getDarkness()
Returns the darkness value of this square.
boolean resetFogOfWar(final int x, final int y)
Returns and reset the "fog-of-war" flag of a square.
void dirty(final int x, final int y)
Marks a square as dirty.
Definition: CfMapPatch.java:72
Face getFace(final int x, final int y, final int layer)
Determines the face of one square.
boolean setColor(final int x, final int y, final int color)
Sets the magic map color of one square.
Manages image information ("faces") needed to display the map view, items, and spell icons...
CfMapSquare getHeadMapSquare(final int x, final int y, final int layer)
Returns the map square of the head of a multi-square object.
int getColor(final int x, final int y)
Determines the magic map color value of one square.
int getDarkness(final int x, final int y)
Determines the darkness value of one square.
boolean setColor(final int color)
Sets the magic map color of this square.
boolean isFogOfWar(final int x, final int y)
Determines if a square is not up-to-date.
boolean isFogOfWar()
Determines if the square is not up-to-date.
boolean setDarkness(final int x, final int y, final int darkness)
Sets the darkness value of one square.
Definition: CfMapPatch.java:93
CfMapPatch(@NotNull final CfMap map, final int x0, final int y0)
Creates a new (empty) patch.
Definition: CfMapPatch.java:59
Represents a square area of CfMapSquares.
Definition: CfMapPatch.java:32
void clear()
Marks this square as &#39;fog-og-war&#39;.
int setSmooth(final int layer, final int smooth)
Sets the smooth value of this square.
boolean setDarkness(final int darkness)
Sets the darkness value of this square.
Face getFace(final int layer)
Returns the face of a layer.
int getColor()
Returns the magic map color of this square.
final CfMapSquare [][] square
The array of CfMapSquares.
Definition: CfMapPatch.java:49
boolean resetFogOfWar()
Returns and resets the "fog-of-war" flag.
int setSmooth(final int x, final int y, final int layer, final int smooth)
Sets the smooth value of one square.
void setHeadMapSquare(final int layer, @Nullable final CfMapSquare mapSquare, final boolean setAlways)
Sets the map square containing the head face for a layer.
static final int SIZE_LOG
Log2 of SIZE.
Definition: CfMapPatch.java:37
int getSmooth(final int x, final int y, final int layer)
Determines the smooth value of one square.