[Freeciv-Dev] Re: (PR#10117) focus_tile for gui-ftwl
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=10117 >
Jason Short wrote:
> <URL: http://rt.freeciv.org/Ticket/Display.html?id=10117 >
>
> This patch adds the focus_tile code into gui-ftwl/mapview.c.
>
> It fixes several bugs in the original focus_tile code (in PR#9479):
>
> - Fix handling of (-1,-1) by checking is_normal rather than is_real.
>
> - Clear the focus tile when disconnecting from a server.
Oops, here's the right patch.
jason
Index: client/gui-ftwl/dialogs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-ftwl/dialogs.c,v
retrieving revision 1.2
diff -u -r1.2 dialogs.c
--- client/gui-ftwl/dialogs.c 10 Sep 2004 21:20:52 -0000 1.2
+++ client/gui-ftwl/dialogs.c 15 Sep 2004 02:09:41 -0000
@@ -29,6 +29,7 @@
#include "widget.h"
#include "dialogs.h"
+#include "mapview.h"
static struct sw_widget *nations_window;
#if 0
@@ -386,4 +387,5 @@
void popdown_all_game_dialogs(void)
{
/* PORTME */
+ clear_focus_tile();
}
Index: client/gui-ftwl/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-ftwl/mapview.c,v
retrieving revision 1.2
diff -u -r1.2 mapview.c
--- client/gui-ftwl/mapview.c 14 Sep 2004 22:35:24 -0000 1.2
+++ client/gui-ftwl/mapview.c 15 Sep 2004 02:09:41 -0000
@@ -25,6 +25,7 @@
#include "support.h"
#include "civclient.h"
+#include "climap.h"
#include "climisc.h"
#include "combat.h"
#include "control.h"
@@ -1607,3 +1608,51 @@
/* PORTME */
}
+static struct map_position focus_tile = { -1, -1 };
+
+/****************************************************************************
+ Set the position of the focus tile, and update the mapview.
+****************************************************************************/
+void set_focus_tile(int x, int y)
+{
+ struct map_position old = focus_tile;
+
+ CHECK_MAP_POS(x, y);
+ focus_tile.x = x;
+ focus_tile.y = y;
+
+ if (old.x >= 0) {
+ refresh_tile_mapcanvas(old.x, old.y, TRUE);
+ }
+ refresh_tile_mapcanvas(focus_tile.x, focus_tile.y, TRUE);
+}
+
+/****************************************************************************
+ Clear the focus tile, and update the mapview.
+****************************************************************************/
+void clear_focus_tile(void)
+{
+ struct map_position old = focus_tile;
+
+ focus_tile.x = -1;
+ focus_tile.y = -1;
+
+ if (map_exists() && is_normal_map_pos(old.x, old.x)) {
+ refresh_tile_mapcanvas(old.x, old.y, TRUE);
+ }
+}
+
+/****************************************************************************
+ Find the focus tile. Returns FALSE if there is no focus tile.
+****************************************************************************/
+bool get_focus_tile(int *x, int *y)
+{
+ if (focus_tile.x < 0) {
+ *x = *y = -1;
+ return FALSE;
+ } else {
+ *x = focus_tile.x;
+ *y = focus_tile.y;
+ return TRUE;
+ }
+}
Index: client/gui-ftwl/mapview.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-ftwl/mapview.h,v
retrieving revision 1.1
diff -u -r1.1 mapview.h
--- client/gui-ftwl/mapview.h 29 Jul 2004 14:10:13 -0000 1.1
+++ client/gui-ftwl/mapview.h 15 Sep 2004 02:09:41 -0000
@@ -18,4 +18,8 @@
void mapview_update_actions(void);
+void set_focus_tile(int x, int y);
+void clear_focus_tile(void);
+bool get_focus_tile(int *x, int *y);
+
#endif /* FC__MAPVIEW_H */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] Re: (PR#10117) focus_tile for gui-ftwl,
Jason Short <=
|
|