From 0e0ca6025ff46856abb70e5e5727c08c6d460d50 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Sun, 5 Jan 2025 13:35:47 +0200
Subject: [PATCH 15/15] Replace is_view_supported() by gui property

See RM #1109

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 client/gui-gtk-3.22/graphics.c | 20 --------------------
 client/gui-gtk-3.22/gui_main.c |  7 +++++++
 client/gui-gtk-4.0/graphics.c  | 20 --------------------
 client/gui-gtk-4.0/gui_main.c  |  7 +++++++
 client/gui-gtk-5.0/graphics.c  | 20 --------------------
 client/gui-gtk-5.0/gui_main.c  |  7 +++++++
 client/gui-qt/graphics.cpp     | 16 ----------------
 client/gui-qt/gui_main.cpp     |  3 +++
 client/gui-qt/qtg_cxxside.cpp  |  1 -
 client/gui-qt/qtg_cxxside.h    |  1 -
 client/gui-sdl2/graphics.c     | 16 ----------------
 client/gui-sdl2/gui_main.c     |  3 +++
 client/gui-sdl3/graphics.c     | 16 ----------------
 client/gui-sdl3/gui_main.c     |  3 +++
 client/gui-stub/graphics.c     |  9 ---------
 client/gui_cbsetter.c          |  1 -
 client/gui_interface.c         |  8 --------
 client/gui_interface.h         |  1 -
 client/gui_properties.h        |  5 +++++
 client/include/graphics_g.h    |  3 +--
 client/tilespec.c              | 15 ++++++++++++++-
 21 files changed, 50 insertions(+), 132 deletions(-)

diff --git a/client/gui-gtk-3.22/graphics.c b/client/gui-gtk-3.22/graphics.c
index 508a37591f..36476e2df5 100644
--- a/client/gui-gtk-3.22/graphics.c
+++ b/client/gui-gtk-3.22/graphics.c
@@ -47,26 +47,6 @@
 
 GdkCursor *fc_cursors[CURSOR_LAST][NUM_CURSOR_FRAMES];
 
-/***********************************************************************//**
-  Returns TRUE to indicate that gtk3.22-client supports given view type
-***************************************************************************/
-bool is_view_supported(enum ts_type type)
-{
-  switch (type) {
-  case TS_ISOMETRIC:
-  case TS_OVERHEAD:
-    return TRUE;
-  case TS_3D:
-#ifdef GTK3_3D_ENABLED
-    return TRUE;
-#else  /* GTK3_3D_ENABLED */
-    return FALSE;
-#endif /* GTK3_3D_ENABLED */
-  }
-
-  return FALSE;
-}
-
 /***********************************************************************//**
   Loading tileset of the specified type
 ***************************************************************************/
diff --git a/client/gui-gtk-3.22/gui_main.c b/client/gui-gtk-3.22/gui_main.c
index dc069d2ee7..fc1f0c519d 100644
--- a/client/gui-gtk-3.22/gui_main.c
+++ b/client/gui-gtk-3.22/gui_main.c
@@ -2650,4 +2650,11 @@ static void adjust_default_options(void)
 void setup_gui_properties(void)
 {
   gui_properties.animations = FALSE;
+  gui_properties.views.isometric = TRUE;
+  gui_properties.views.overhead = TRUE;
+#ifdef GTK3_3D_ENABLED
+  gui_properties.views.d3 = TRUE;
+#else  /* GTK3_3D_ENABLED */
+  gui_properties.views.d3 = FALSE;
+#endif /* GTK3_3D_ENABLED */
 }
diff --git a/client/gui-gtk-4.0/graphics.c b/client/gui-gtk-4.0/graphics.c
index 3858ec0387..13324f8eef 100644
--- a/client/gui-gtk-4.0/graphics.c
+++ b/client/gui-gtk-4.0/graphics.c
@@ -47,26 +47,6 @@
 
 GdkCursor *fc_cursors[CURSOR_LAST][NUM_CURSOR_FRAMES];
 
-/***********************************************************************//**
-  Returns TRUE to indicate that gtk4-client supports given view type
-***************************************************************************/
-bool is_view_supported(enum ts_type type)
-{
-  switch (type) {
-  case TS_ISOMETRIC:
-  case TS_OVERHEAD:
-    return TRUE;
-  case TS_3D:
-#ifdef GTK3_3D_ENABLED
-    return TRUE;
-#else  /* GTK3_3D_ENABLED */
-    return FALSE;
-#endif /* GTK3_3D_ENABLED */
-  }
-
-  return FALSE;
-}
-
 /***********************************************************************//**
   Loading tileset of the specified type
 ***************************************************************************/
diff --git a/client/gui-gtk-4.0/gui_main.c b/client/gui-gtk-4.0/gui_main.c
index 695c13c5a8..2852c9cda9 100644
--- a/client/gui-gtk-4.0/gui_main.c
+++ b/client/gui-gtk-4.0/gui_main.c
@@ -2682,4 +2682,11 @@ GtkApplication *gui_app(void)
 void setup_gui_properties(void)
 {
   gui_properties.animations = TRUE;
+  gui_properties.views.isometric = TRUE;
+  gui_properties.views.overhead = TRUE;
+#ifdef GTK3_3D_ENABLED
+  gui_properties.views.d3 = TRUE;
+#else  /* GTK3_3D_ENABLED */
+  gui_properties.views.d3 = FALSE;
+#endif /* GTK3_3D_ENABLED */
 }
diff --git a/client/gui-gtk-5.0/graphics.c b/client/gui-gtk-5.0/graphics.c
index 32fb839b1c..ff9016069e 100644
--- a/client/gui-gtk-5.0/graphics.c
+++ b/client/gui-gtk-5.0/graphics.c
@@ -47,26 +47,6 @@
 
 GdkCursor *fc_cursors[CURSOR_LAST][NUM_CURSOR_FRAMES];
 
-/***********************************************************************//**
-  Returns TRUE to indicate that gtk4x-client supports given view type
-***************************************************************************/
-bool is_view_supported(enum ts_type type)
-{
-  switch (type) {
-  case TS_ISOMETRIC:
-  case TS_OVERHEAD:
-    return TRUE;
-  case TS_3D:
-#ifdef GTK3_3D_ENABLED
-    return TRUE;
-#else  /* GTK3_3D_ENABLED */
-    return FALSE;
-#endif /* GTK3_3D_ENABLED */
-  }
-
-  return FALSE;
-}
-
 /***********************************************************************//**
   Loading tileset of the specified type
 ***************************************************************************/
diff --git a/client/gui-gtk-5.0/gui_main.c b/client/gui-gtk-5.0/gui_main.c
index 794160f36a..ae953dfa4c 100644
--- a/client/gui-gtk-5.0/gui_main.c
+++ b/client/gui-gtk-5.0/gui_main.c
@@ -2735,4 +2735,11 @@ GtkApplication *gui_app(void)
 void setup_gui_properties(void)
 {
   gui_properties.animations = TRUE;
+  gui_properties.views.isometric = TRUE;
+  gui_properties.views.overhead = TRUE;
+#ifdef GTK3_3D_ENABLED
+  gui_properties.views.d3 = TRUE;
+#else  /* GTK3_3D_ENABLED */
+  gui_properties.views.d3 = FALSE;
+#endif /* GTK3_3D_ENABLED */
 }
diff --git a/client/gui-qt/graphics.cpp b/client/gui-qt/graphics.cpp
index 3b226e8f13..8b9d6a84d1 100644
--- a/client/gui-qt/graphics.cpp
+++ b/client/gui-qt/graphics.cpp
@@ -22,22 +22,6 @@
 #include "graphics.h"
 #include "qtg_cxxside.h"
 
-/************************************************************************//**
-  Return whether the client supports given view type.
-****************************************************************************/
-bool qtg_is_view_supported(enum ts_type type)
-{
-  switch (type) {
-  case TS_ISOMETRIC:
-  case TS_OVERHEAD:
-    return true;
-  case TS_3D:
-    return false;
-  }
-
-  return false;
-}
-
 /************************************************************************//**
   Loading tileset of the specified type
 ****************************************************************************/
diff --git a/client/gui-qt/gui_main.cpp b/client/gui-qt/gui_main.cpp
index 3771f5eff3..43684c1cf2 100644
--- a/client/gui-qt/gui_main.cpp
+++ b/client/gui-qt/gui_main.cpp
@@ -606,4 +606,7 @@ void qtg_insert_client_build_info(char *outbuf, size_t outlen)
 void qtg_setup_gui_properties()
 {
   gui_properties.animations = FALSE;
+  gui_properties.views.isometric = TRUE;
+  gui_properties.views.overhead = TRUE;
+  gui_properties.views.d3 = FALSE;
 }
diff --git a/client/gui-qt/qtg_cxxside.cpp b/client/gui-qt/qtg_cxxside.cpp
index acaa32e976..4a7dceeb95 100644
--- a/client/gui-qt/qtg_cxxside.cpp
+++ b/client/gui-qt/qtg_cxxside.cpp
@@ -40,7 +40,6 @@ void setup_gui_funcs()
   funcs->version_message = qtg_version_message;
   funcs->real_output_window_append = qtg_real_output_window_append;
 
-  funcs->is_view_supported = qtg_is_view_supported;
   funcs->tileset_type_set = qtg_tileset_type_set;
   funcs->load_gfxfile = qtg_load_gfxfile;
   funcs->load_gfxnumber = qtg_load_gfxnumber;
diff --git a/client/gui-qt/qtg_cxxside.h b/client/gui-qt/qtg_cxxside.h
index be22b65f23..21707b5561 100644
--- a/client/gui-qt/qtg_cxxside.h
+++ b/client/gui-qt/qtg_cxxside.h
@@ -39,7 +39,6 @@ void qtg_real_output_window_append(const char *astring,
                                    const struct text_tag_list *tags,
                                    int conn_id);
 
-bool qtg_is_view_supported(enum ts_type type);
 void qtg_tileset_type_set(enum ts_type type);
 struct sprite *qtg_load_gfxfile(const char *filename, bool svgflag);
 struct sprite *qtg_load_gfxnumber(int num);
diff --git a/client/gui-sdl2/graphics.c b/client/gui-sdl2/graphics.c
index ca849198fa..90b040cfcb 100644
--- a/client/gui-sdl2/graphics.c
+++ b/client/gui-sdl2/graphics.c
@@ -1321,22 +1321,6 @@ SDL_Surface *copy_surface(SDL_Surface *src)
 
 /* ============ Freeciv game graphics function =========== */
 
-/**********************************************************************//**
-  Return whether the client supports given view type
-**************************************************************************/
-bool is_view_supported(enum ts_type type)
-{
-  switch (type) {
-  case TS_ISOMETRIC:
-  case TS_OVERHEAD:
-    return TRUE;
-  case TS_3D:
-    return FALSE;
-  }
-
-  return FALSE;
-}
-
 /**********************************************************************//**
   Loading tileset of the specified type
 **************************************************************************/
diff --git a/client/gui-sdl2/gui_main.c b/client/gui-sdl2/gui_main.c
index e8df07861f..1185131cb8 100644
--- a/client/gui-sdl2/gui_main.c
+++ b/client/gui-sdl2/gui_main.c
@@ -1354,4 +1354,7 @@ bool flush_event(void)
 void setup_gui_properties(void)
 {
   gui_properties.animations = FALSE;
+  gui_properties.views.isometric = TRUE;
+  gui_properties.views.overhead = TRUE;
+  gui_properties.views.d3 = FALSE;
 }
diff --git a/client/gui-sdl3/graphics.c b/client/gui-sdl3/graphics.c
index 83c468afd5..0bfc0256a1 100644
--- a/client/gui-sdl3/graphics.c
+++ b/client/gui-sdl3/graphics.c
@@ -1140,22 +1140,6 @@ SDL_Surface *copy_surface(SDL_Surface *src)
 
 /* ============ Freeciv game graphics function =========== */
 
-/**********************************************************************//**
-  Return whether the client supports given view type
-**************************************************************************/
-bool is_view_supported(enum ts_type type)
-{
-  switch (type) {
-  case TS_ISOMETRIC:
-  case TS_OVERHEAD:
-    return TRUE;
-  case TS_3D:
-    return FALSE;
-  }
-
-  return FALSE;
-}
-
 /**********************************************************************//**
   Loading tileset of the specified type
 **************************************************************************/
diff --git a/client/gui-sdl3/gui_main.c b/client/gui-sdl3/gui_main.c
index f79247bd6e..c7f0ac8d5d 100644
--- a/client/gui-sdl3/gui_main.c
+++ b/client/gui-sdl3/gui_main.c
@@ -1356,4 +1356,7 @@ bool flush_event(void)
 void setup_gui_properties(void)
 {
   gui_properties.animations = FALSE;
+  gui_properties.views.isometric = TRUE;
+  gui_properties.views.overhead = TRUE;
+  gui_properties.views.d3 = FALSE;
 }
diff --git a/client/gui-stub/graphics.c b/client/gui-stub/graphics.c
index f34371cb24..3f9ed25151 100644
--- a/client/gui-stub/graphics.c
+++ b/client/gui-stub/graphics.c
@@ -25,15 +25,6 @@
 
 #include "graphics.h"
 
-/************************************************************************//**
-  Return whether the client supports given view type
-****************************************************************************/
-bool gui_is_view_supported(enum ts_type type)
-{
-  /* PORTME */
-  return FALSE;
-}
-
 /************************************************************************//**
   Loading tileset of the specified type
 ****************************************************************************/
diff --git a/client/gui_cbsetter.c b/client/gui_cbsetter.c
index 6c633ca53e..f89660678f 100644
--- a/client/gui_cbsetter.c
+++ b/client/gui_cbsetter.c
@@ -52,7 +52,6 @@ void setup_gui_funcs(void)
   funcs->version_message = gui_version_message;
   funcs->real_output_window_append = gui_real_output_window_append;
 
-  funcs->is_view_supported = gui_is_view_supported;
   funcs->load_gfxfile = gui_load_gfxfile;
   funcs->create_sprite = gui_create_sprite;
   funcs->get_sprite_dimensions = gui_get_sprite_dimensions;
diff --git a/client/gui_interface.c b/client/gui_interface.c
index cdbaa25bc2..34b7cb1b3f 100644
--- a/client/gui_interface.c
+++ b/client/gui_interface.c
@@ -103,14 +103,6 @@ void insert_client_build_info(char *outbuf, size_t outlen)
   funcs.insert_client_build_info(outbuf, outlen);
 }
 
-/**********************************************************************//**
-  Call is_view_supported callback
-**************************************************************************/
-bool is_view_supported(enum ts_type type)
-{
-  return funcs.is_view_supported(type);
-}
-
 /**********************************************************************//**
   Call tileset_type_set callback
 **************************************************************************/
diff --git a/client/gui_interface.h b/client/gui_interface.h
index f7277555aa..4817df5679 100644
--- a/client/gui_interface.h
+++ b/client/gui_interface.h
@@ -47,7 +47,6 @@ struct gui_funcs {
                                     const struct text_tag_list *tags,
                                     int conn_id);
 
-  bool (*is_view_supported)(enum ts_type type);
   void (*tileset_type_set)(enum ts_type type);
   struct sprite * (*load_gfxfile)(const char *filename, bool svgflag);
   struct sprite * (*load_gfxnumber)(int num);
diff --git a/client/gui_properties.h b/client/gui_properties.h
index 836ca7dd07..de4ff859d7 100644
--- a/client/gui_properties.h
+++ b/client/gui_properties.h
@@ -19,6 +19,11 @@ extern "C" {
 
 struct client_properties {
   bool animations;
+  struct {
+    bool isometric;
+    bool overhead;
+    bool d3;
+  } views;
 };
 
 extern struct client_properties gui_properties;
diff --git a/client/include/graphics_g.h b/client/include/graphics_g.h
index a8c30b7941..78f0587b86 100644
--- a/client/include/graphics_g.h
+++ b/client/include/graphics_g.h
@@ -24,9 +24,8 @@
 
 #include "gui_proto_constructor.h"
 
-GUI_FUNC_PROTO(bool, is_view_supported, enum ts_type type)
 GUI_FUNC_PROTO(void, tileset_type_set, enum ts_type type)
 
 GUI_FUNC_PROTO(void, load_cursors, void)
 
-#endif  /* FC__GRAPHICS_G_H */
+#endif /* FC__GRAPHICS_G_H */
diff --git a/client/tilespec.c b/client/tilespec.c
index 5744f2f35b..c7d59a1306 100644
--- a/client/tilespec.c
+++ b/client/tilespec.c
@@ -1952,6 +1952,7 @@ static struct tileset *tileset_read_toplevel(const char *tileset_name,
   bool svg;
   enum spec_file_types slist_type;
   const char *type_name;
+  bool vsup;
 
   fname = tilespec_fullname(tileset_name);
 
@@ -2093,7 +2094,19 @@ static struct tileset *tileset_read_toplevel(const char *tileset_name,
 
   t->ts_topo_idx = ts_topology_index(topo);
 
-  if (!is_view_supported(t->type)) {
+  switch (t->type) {
+  case TS_ISOMETRIC:
+    vsup = gui_properties.views.isometric;
+    break;
+  case TS_OVERHEAD:
+    vsup = gui_properties.views.overhead;
+    break;
+  case TS_3D:
+    vsup = gui_properties.views.d3;
+    break;
+  }
+
+  if (!vsup) {
     /* TRANS: "Overhead" or "Isometric" */
     log_normal(_("Client does not support %s tilesets."),
                _(ts_type_name(t->type)));
-- 
2.45.2

