From 91f23c7eaff39122104a94da49b294c2d09291c7 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Wed, 26 Jan 2022 02:07:52 +0200 Subject: [PATCH 16/16] gtk: Describe current Small Wonders visibility rule Wonder List Intelligence Dialog tells the visibility rule. See osdn #43084 Signed-off-by: Marko Lindqvist --- client/gui-gtk-3.0/inteldlg.c | 21 ++++++++++++++++++++- client/gui-gtk-3.22/inteldlg.c | 22 +++++++++++++++++++++- client/gui-gtk-4.0/inteldlg.c | 22 +++++++++++++++++++++- 3 files changed, 62 insertions(+), 3 deletions(-) diff --git a/client/gui-gtk-3.0/inteldlg.c b/client/gui-gtk-3.0/inteldlg.c index 71643fc3b9..0fad996743 100644 --- a/client/gui-gtk-3.0/inteldlg.c +++ b/client/gui-gtk-3.0/inteldlg.c @@ -96,6 +96,7 @@ struct intel_wonder_dialog { GtkWidget *shell; GtkListStore *wonders; + GtkWidget *rule; }; #define SPECLIST_TAG wonder_dialog @@ -378,6 +379,7 @@ static struct intel_wonder_dialog *create_intel_wonder_dialog(struct player *p) struct intel_wonder_dialog *pdialog; GtkWidget *shell, *sw, *view; GtkCellRenderer *rend; + GtkWidget *box; pdialog = fc_malloc(sizeof(*pdialog)); pdialog->pplayer = p; @@ -398,6 +400,8 @@ static struct intel_wonder_dialog *create_intel_wonder_dialog(struct player *p) g_signal_connect(shell, "response", G_CALLBACK(gtk_widget_destroy), NULL); + pdialog->rule = gtk_label_new("-"); + /* columns: 0 - wonder name, 1 - location (city/unknown/lost), * 2 - strikethrough (for lost or obsolete), * 3 - font weight (great wonders in bold) */ @@ -430,7 +434,10 @@ static struct intel_wonder_dialog *create_intel_wonder_dialog(struct player *p) sw = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_ETCHED_IN); - gtk_container_add(GTK_CONTAINER(sw), view); + box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2); + gtk_container_add(GTK_CONTAINER(box), pdialog->rule); + gtk_container_add(GTK_CONTAINER(box), view); + gtk_container_add(GTK_CONTAINER(sw), box); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, @@ -631,10 +638,22 @@ void update_intel_wonder_dialog(struct player *p) if (pdialog != NULL) { gchar *title = g_strdup_printf(_("Wonders of %s Empire"), nation_adjective_for_player(p)); + const char *rule = NULL; gtk_window_set_title(GTK_WINDOW(pdialog->shell), title); g_free(title); + switch (game.info.small_wonder_visibility) { + case WV_ALWAYS: + rule = _("All Wonders are known"); + break; + case WV_NEVER: + rule = _("Small Wonders not known"); + break; + } + + gtk_label_set_text(GTK_LABEL(pdialog->rule), rule); + gtk_list_store_clear(pdialog->wonders); improvement_iterate(impr) { diff --git a/client/gui-gtk-3.22/inteldlg.c b/client/gui-gtk-3.22/inteldlg.c index e24628523c..ce2d9463c7 100644 --- a/client/gui-gtk-3.22/inteldlg.c +++ b/client/gui-gtk-3.22/inteldlg.c @@ -96,6 +96,7 @@ struct intel_wonder_dialog { GtkWidget *shell; GtkListStore *wonders; + GtkWidget *rule; }; #define SPECLIST_TAG wonder_dialog @@ -378,6 +379,7 @@ static struct intel_wonder_dialog *create_intel_wonder_dialog(struct player *p) struct intel_wonder_dialog *pdialog; GtkWidget *shell, *sw, *view; GtkCellRenderer *rend; + GtkWidget *box; pdialog = fc_malloc(sizeof(*pdialog)); pdialog->pplayer = p; @@ -398,6 +400,9 @@ static struct intel_wonder_dialog *create_intel_wonder_dialog(struct player *p) g_signal_connect(shell, "response", G_CALLBACK(gtk_widget_destroy), NULL); + + pdialog->rule = gtk_label_new("-"); + /* columns: 0 - wonder name, 1 - location (city/unknown/lost), * 2 - strikethrough (for lost or obsolete), * 3 - font weight (great wonders in bold) */ @@ -430,7 +435,10 @@ static struct intel_wonder_dialog *create_intel_wonder_dialog(struct player *p) sw = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_ETCHED_IN); - gtk_container_add(GTK_CONTAINER(sw), view); + box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2); + gtk_container_add(GTK_CONTAINER(box), pdialog->rule); + gtk_container_add(GTK_CONTAINER(box), view); + gtk_container_add(GTK_CONTAINER(sw), box); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, @@ -631,10 +639,22 @@ void update_intel_wonder_dialog(struct player *p) if (pdialog != NULL) { gchar *title = g_strdup_printf(_("Wonders of %s Empire"), nation_adjective_for_player(p)); + const char *rule = NULL; gtk_window_set_title(GTK_WINDOW(pdialog->shell), title); g_free(title); + switch (game.info.small_wonder_visibility) { + case WV_ALWAYS: + rule = _("All Wonders are known"); + break; + case WV_NEVER: + rule = _("Small Wonders not known"); + break; + } + + gtk_label_set_text(GTK_LABEL(pdialog->rule), rule); + gtk_list_store_clear(pdialog->wonders); improvement_iterate(impr) { diff --git a/client/gui-gtk-4.0/inteldlg.c b/client/gui-gtk-4.0/inteldlg.c index 482e5984e6..ecd4a5bde7 100644 --- a/client/gui-gtk-4.0/inteldlg.c +++ b/client/gui-gtk-4.0/inteldlg.c @@ -96,6 +96,7 @@ struct intel_wonder_dialog { GtkWidget *shell; GtkListStore *wonders; + GtkWidget *rule; }; #define SPECLIST_TAG wonder_dialog @@ -382,6 +383,7 @@ static struct intel_wonder_dialog *create_intel_wonder_dialog(struct player *p) struct intel_wonder_dialog *pdialog; GtkWidget *shell, *sw, *view; GtkCellRenderer *rend; + GtkWidget *box; pdialog = fc_malloc(sizeof(*pdialog)); pdialog->pplayer = p; @@ -402,6 +404,9 @@ static struct intel_wonder_dialog *create_intel_wonder_dialog(struct player *p) g_signal_connect(shell, "response", G_CALLBACK(gtk_window_destroy), NULL); + + pdialog->rule = gtk_label_new("-"); + /* columns: 0 - wonder name, 1 - location (city/unknown/lost), * 2 - strikethrough (for lost or obsolete), * 3 - font weight (great wonders in bold) */ @@ -436,7 +441,10 @@ static struct intel_wonder_dialog *create_intel_wonder_dialog(struct player *p) sw = gtk_scrolled_window_new(); gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), TRUE); - gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), view); + box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2); + gtk_box_append(GTK_BOX(box), pdialog->rule); + gtk_box_append(GTK_BOX(box), view); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), box); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, @@ -636,10 +644,22 @@ void update_intel_wonder_dialog(struct player *p) if (pdialog != NULL) { gchar *title = g_strdup_printf(_("Wonders of %s Empire"), nation_adjective_for_player(p)); + const char *rule = NULL; gtk_window_set_title(GTK_WINDOW(pdialog->shell), title); g_free(title); + switch (game.info.small_wonder_visibility) { + case WV_ALWAYS: + rule = _("All Wonders are known"); + break; + case WV_NEVER: + rule = _("Small Wonders not known"); + break; + } + + gtk_label_set_text(GTK_LABEL(pdialog->rule), rule); + gtk_list_store_clear(pdialog->wonders); improvement_iterate(impr) { -- 2.34.1