Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2005:
[Freeciv-Dev] (PR#13725) new text function get_info_label_text_popup
Home

[Freeciv-Dev] (PR#13725) new text function get_info_label_text_popup

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#13725) new text function get_info_label_text_popup
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 20 Aug 2005 19:42:16 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13725 >

This should have been done long ago...

The attached patch adds a new text.c function get_info_label_text_popup. 
  This generates the string used in the...(surprise)...info label text 
popup.

I "cleaned up" the string a bit.  Of course it's split by line now which 
makes translation easier.  It also no longer needs duplicate cases.  The 
research line is better.  And the tax rates line is (IMO) improved. 
And, I added new lines for global warming and nuclear winter (as 
requested by Chris in PR#12206).

In the process I fixed a bug in the nuclear winter tooltip that made it 
identical to the global warming one.  Oops.

Finally I added a new line to regular info label text: "(Click for more 
info)".  A lot of players don't know about this so this should help out. 
  We have plenty of vertical space so room shouldn't be a problem (I think).

-jason

Index: client/text.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/text.c,v
retrieving revision 1.47
diff -p -u -r1.47 text.c
--- client/text.c       19 Aug 2005 20:57:53 -0000      1.47
+++ client/text.c       21 Aug 2005 02:41:44 -0000
@@ -497,6 +497,8 @@ const char *get_science_goal_text(Tech_t
 /****************************************************************************
   Return the text for the label on the info panel.  (This is traditionally
   shown to the left of the mapview.)
+
+  Clicking on this text should bring up the get_info_label_text_popup text.
 ****************************************************************************/
 const char *get_info_label_text(void)
 {
@@ -517,6 +519,50 @@ const char *get_info_label_text(void)
   if (!game.info.simultaneous_phases) {
     astr_add_line(&str, _("Moving: %s"), get_player(game.info.phase)->name);
   }
+  astr_add_line(&str, _("(Click for more info)"));
+  return str.str;
+}
+
+/****************************************************************************
+  Return the text for the popup label on the info panel.  (This is
+  traditionally done as a popup whenever the regular info text is clicked
+  on.)
+****************************************************************************/
+const char *get_info_label_text_popup(void)
+{
+  static struct astring str = ASTRING_INIT;
+  struct player_research *research = get_player_research(game.player_ptr);
+
+  astr_clear(&str);
+
+  astr_add_line(&str, _("%s People"),
+               population_to_text(civ_population(game.player_ptr)));
+  astr_add_line(&str, _("Year: %s"), textyear(game.info.year));
+  astr_add_line(&str, _("Turn: %d"), game.info.turn);
+  astr_add_line(&str, _("Gold: %d"), game.player_ptr->economic.gold);
+  astr_add_line(&str, _("Net Income: %d"),
+               player_get_expected_income(game.player_ptr));
+  /* TRANS: Gold, luxury, and science rates are in percentage values. */
+  astr_add_line(&str, _("Tax rates: Gold:%d%% Luxury:%d%% Science:%d%%"),
+               game.player_ptr->economic.tax,
+               game.player_ptr->economic.luxury,
+               game.player_ptr->economic.science);
+  astr_add_line(&str, _("Researching %s: %s"),
+               get_tech_name(game.player_ptr, research->researching),
+               get_science_target_text(NULL));
+
+  /* These mirror the code in get_global_warming_tooltip and
+   * get_nuclear_winter_tooltip. */
+  astr_add_line(&str, _("Global warming chance: %d%% (%+d%%/turn)"),
+               CLIP(0, (game.info.globalwarming + 1) / 2, 100),
+               DIVIDE(game.info.heating - game.info.warminglevel + 1, 2));
+  astr_add_line(&str, _("Nuclear winter chance: %d%% (%+d%%/turn)"),
+               CLIP(0, (game.info.nuclearwinter + 1) / 2, 100),
+               DIVIDE(game.info.cooling - game.info.coolinglevel + 1, 2));
+
+  astr_add_line(&str, _("Government: %s"),
+               get_government_name(game.player_ptr->government));
+
   return str.str;
 }
 
@@ -643,9 +689,9 @@ const char *get_nuclear_winter_tooltip(v
   /* This mirrors the logic in update_environmental_upset. */
   astr_add_line(&str, _("Shows the progress of nuclear winter:"));
   astr_add_line(&str, _("Fallout rate: %d%%"),
-               DIVIDE(game.info.heating - game.info.warminglevel + 1, 2));
+               DIVIDE(game.info.cooling - game.info.coolinglevel + 1, 2));
   astr_add_line(&str, _("Chance of catastrophic winter each turn: %d%%"),
-               CLIP(0, (game.info.globalwarming + 1) / 2, 100));
+               CLIP(0, (game.info.nuclearwinter + 1) / 2, 100));
   return str.str;
 }
 
Index: client/text.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/text.h,v
retrieving revision 1.14
diff -p -u -r1.14 text.h
--- client/text.h       16 Aug 2005 06:54:53 -0000      1.14
+++ client/text.h       21 Aug 2005 02:41:44 -0000
@@ -30,6 +30,7 @@ const char *science_dialog_text(void);
 const char *get_science_target_text(double *percent);
 const char *get_science_goal_text(Tech_type_id goal);
 const char *get_info_label_text(void);
+const char *get_info_label_text_popup(void);
 const char *get_bulb_tooltip(void);
 const char *get_global_warming_tooltip(void);
 const char *get_nuclear_winter_tooltip(void);
Index: client/gui-gtk-2.0/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/gui_main.c,v
retrieving revision 1.135
diff -p -u -r1.135 gui_main.c
--- client/gui-gtk-2.0/gui_main.c       18 Aug 2005 06:53:30 -0000      1.135
+++ client/gui-gtk-2.0/gui_main.c       21 Aug 2005 02:41:45 -0000
@@ -70,6 +70,7 @@
 #include "pages.h"
 #include "spaceshipdlg.h"
 #include "resources.h"
+#include "text.h"
 #include "tilespec.h"
 
 
@@ -1507,51 +1508,14 @@ static gboolean show_info_popup(GtkWidge
 {
   if(ev->button == 1) {
     GtkWidget *p;
-    char buf[512];
-    struct player_research* research = get_player_research(game.player_ptr);
-    
-    if (get_player_research(game.player_ptr)->researching != A_UNSET) {
-      my_snprintf(buf, sizeof(buf),
-           _("%s People\nYear: %s Turn: %d\nGold: %d\nNet Income: %d\n"
-             "Tax:%d Lux:%d Sci:%d\nResearching %s: %d/%d\nGovernment: %s"),
-           population_to_text(civ_population(game.player_ptr)),
-           textyear(game.info.year), game.info.turn,
-           game.player_ptr->economic.gold,
-           player_get_expected_income(game.player_ptr),
-           game.player_ptr->economic.tax,
-           game.player_ptr->economic.luxury,
-           game.player_ptr->economic.science,
-
-           get_tech_name(game.player_ptr,
-                         research->researching),
-           research->bulbs_researched,
-           total_bulbs_required(game.player_ptr),
-           get_government_name(game.player_ptr->government));
-    } else {
-      my_snprintf(buf, sizeof(buf),
-           _("%s People\nYear: %s Turn: %d\nGold: %d\nNet Income: %d\n"
-             "Tax:%d Lux:%d Sci:%d\nResearching %s: %d/-\nGovernment: %s"),
-           population_to_text(civ_population(game.player_ptr)),
-           textyear(game.info.year), game.info.turn,
-           game.player_ptr->economic.gold,
-           player_get_expected_income(game.player_ptr),
-           game.player_ptr->economic.tax,
-           game.player_ptr->economic.luxury,
-           game.player_ptr->economic.science,
-
-           get_tech_name(game.player_ptr,
-                         research->researching),
-           research->bulbs_researched,
-           get_government_name(game.player_ptr->government));
-    }
-        
+
     p = gtk_window_new(GTK_WINDOW_POPUP);
     gtk_widget_set_app_paintable(p, TRUE);
     gtk_container_set_border_width(GTK_CONTAINER(p), 4);
     gtk_window_set_position(GTK_WINDOW(p), GTK_WIN_POS_MOUSE);
 
     gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::parent", p,
-                                  "GtkLabel::label", buf,
+                  "GtkLabel::label", get_info_label_text_popup(),
                                   "GtkWidget::visible", TRUE,
                                   NULL);
     gtk_widget_show(p);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#13725) new text function get_info_label_text_popup, Jason Short <=