Merge lp:~nomeata/widelands/statistics-menu-settings-persistent into lp:widelands

Proposed by Joachim Breitner
Status: Merged
Merged at revision: 6087
Proposed branch: lp:~nomeata/widelands/statistics-menu-settings-persistent
Merge into: lp:widelands
Diff against target: 231 lines (+60/-23)
8 files modified
src/ui_basic/unique_window.cc (+2/-2)
src/ui_basic/unique_window.h (+1/-1)
src/wui/game_main_menu.cc (+13/-6)
src/wui/game_options_menu.cc (+12/-3)
src/wui/general_statistics_menu.cc (+14/-4)
src/wui/general_statistics_menu.h (+11/-1)
src/wui/interactive_gamebase.h (+2/-1)
src/wui/interactive_player.cc (+5/-5)
To merge this branch: bzr merge lp:~nomeata/widelands/statistics-menu-settings-persistent
Reviewer Review Type Date Requested Status
Widelands Developers Pending
Review via email: mp+81411@code.launchpad.net

Description of the change

This makes the general statistics menu remember the selected category (but not the selected player or others, but now that the infrastructure is there, that can easily be added).

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/ui_basic/unique_window.cc'
2--- src/ui_basic/unique_window.cc 2010-10-17 16:54:32 +0000
3+++ src/ui_basic/unique_window.cc 2011-11-06 18:20:30 +0000
4@@ -33,7 +33,7 @@
5 */
6 void UniqueWindow::Registry::create() {
7 if (not window) {
8- constr(*this);
9+ constr();
10 }
11 }
12
13@@ -53,7 +53,7 @@
14 if (window) {
15 delete window;
16 } else {
17- constr(*this);
18+ constr();
19 }
20 }
21
22
23=== modified file 'src/ui_basic/unique_window.h'
24--- src/ui_basic/unique_window.h 2010-11-05 19:36:57 +0000
25+++ src/ui_basic/unique_window.h 2011-11-06 18:20:30 +0000
26@@ -40,7 +40,7 @@
27 UniqueWindow * window;
28 boost::function<void()> onCreate;
29 boost::function<void()> onDelete;
30- boost::function<void(Registry &)> constr;
31+ boost::function<void()> constr;
32
33 void create();
34 void destroy();
35
36=== modified file 'src/wui/game_main_menu.cc'
37--- src/wui/game_main_menu.cc 2010-11-21 11:44:22 +0000
38+++ src/wui/game_main_menu.cc 2011-11-06 18:20:30 +0000
39@@ -48,7 +48,7 @@
40 posx(0, 4), posy(0, 3), buttonw(4), buttonh(1),
41 g_gr->get_picture(PicMod_UI, "pics/but4.png"),
42 g_gr->get_picture(PicMod_Game, "pics/menu_general_stats.png"),
43- boost::bind(&UI::UniqueWindow::Registry::toggle, boost::ref(m_windows.general_stats)),
44+ boost::bind(&General_Statistics_Menu::Registry::toggle, boost::ref(m_windows.general_stats)),
45 _("General Statistics")),
46 ware_stats
47 (this, "ware_stats",
48@@ -85,14 +85,21 @@
49 INIT_BTN_HOOKS(m_windows.stock, stock)
50
51 m_windows.general_stats.constr = boost::lambda::bind
52- (boost::lambda::new_ptr<General_Statistics_Menu>(), boost::ref(m_player), boost::lambda::_1);
53+ (boost::lambda::new_ptr<General_Statistics_Menu>(),
54+ boost::ref(m_player),
55+ boost::ref(m_windows.general_stats));
56 m_windows.ware_stats.constr = boost::lambda::bind
57- (boost::lambda::new_ptr<Ware_Statistics_Menu>(), boost::ref(m_player), boost::lambda::_1);
58+ (boost::lambda::new_ptr<Ware_Statistics_Menu>(),
59+ boost::ref(m_player),
60+ boost::ref(m_windows.ware_stats));
61 m_windows.building_stats.constr = boost::lambda::bind
62- (boost::lambda::new_ptr<Building_Statistics_Menu>(), boost::ref(m_player), boost::lambda::_1);
63+ (boost::lambda::new_ptr<Building_Statistics_Menu>(),
64+ boost::ref(m_player),
65+ boost::ref(m_windows.building_stats));
66 m_windows.stock.constr = boost::lambda::bind
67- (boost::lambda::new_ptr<Stock_Menu>(), boost::ref(m_player), boost::lambda::_1);
68-
69+ (boost::lambda::new_ptr<Stock_Menu>(),
70+ boost::ref(m_player),
71+ boost::ref(m_windows.stock));
72 if (get_usedefaultpos())
73 center_to_parent();
74 }
75
76=== modified file 'src/wui/game_options_menu.cc'
77--- src/wui/game_options_menu.cc 2010-11-21 11:44:22 +0000
78+++ src/wui/game_options_menu.cc 2011-11-06 18:20:30 +0000
79@@ -100,9 +100,18 @@
80 _("Exit Game"))
81 {
82
83- m_windows.readme.constr = boost::bind(&fileview_window, boost::ref(m_gb), _1, "txts/README");
84- m_windows.license.constr = boost::bind(&fileview_window, boost::ref(m_gb), _1, "txts/COPYING");
85- m_windows.authors.constr = boost::bind(&fileview_window, boost::ref(m_gb), _1, "txts/developers");
86+ m_windows.readme.constr = boost::bind
87+ (&fileview_window, boost::ref(m_gb),
88+ boost::ref(m_windows.readme),
89+ "txts/README");
90+ m_windows.license.constr = boost::bind
91+ (&fileview_window, boost::ref(m_gb),
92+ boost::ref(m_windows.license),
93+ "txts/COPYING");
94+ m_windows.authors.constr = boost::bind
95+ (&fileview_window, boost::ref(m_gb),
96+ boost::ref(m_windows.authors),
97+ "txts/developers");
98
99 #define INIT_BTN_HOOKS(registry, btn) \
100 registry.onCreate = boost::bind(&UI::Button::set_perm_pressed, &btn, true); \
101
102=== modified file 'src/wui/general_statistics_menu.cc'
103--- src/wui/general_statistics_menu.cc 2011-11-06 12:38:07 +0000
104+++ src/wui/general_statistics_menu.cc 2011-11-06 18:20:30 +0000
105@@ -42,14 +42,20 @@
106 #define NR_BASE_DATASETS 11
107
108 General_Statistics_Menu::General_Statistics_Menu
109- (Interactive_GameBase & parent, UI::UniqueWindow::Registry & registry)
110+ (Interactive_GameBase & parent, General_Statistics_Menu::Registry & registry)
111 :
112 UI::UniqueWindow
113 (&parent, "statistics_menu", &registry,
114 440, 400, _("General Statistics")),
115+m_my_registry (&registry),
116 m_box (this, 0, 0, UI::Box::Vertical, 0, 0, 5),
117-m_plot (&m_box, 0, 0, 430, PLOT_HEIGHT)
118+m_plot (&m_box, 0, 0, 430, PLOT_HEIGHT),
119+m_selected_information(0)
120 {
121+ if (m_my_registry) {
122+ m_selected_information = m_my_registry->selected_information;
123+ }
124+
125 set_center_panel(&m_box);
126 m_box.set_border(5, 5, 5, 5);
127
128@@ -257,8 +263,7 @@
129 hbox2->add(btn, UI::Box::AlignLeft);
130 }
131
132- m_radiogroup.set_state(0);
133- m_selected_information = 0;
134+ m_radiogroup.set_state(m_selected_information);
135 m_radiogroup.changedto.set
136 (this, &General_Statistics_Menu::radiogroup_changed);
137
138@@ -273,6 +278,11 @@
139
140 }
141
142+General_Statistics_Menu::~General_Statistics_Menu() {
143+ if (m_my_registry) {
144+ m_my_registry->selected_information = m_selected_information;
145+ }
146+}
147
148 /**
149 * called when the help button was clicked
150
151=== modified file 'src/wui/general_statistics_menu.h'
152--- src/wui/general_statistics_menu.h 2011-11-06 12:38:07 +0000
153+++ src/wui/general_statistics_menu.h 2011-11-06 18:20:30 +0000
154@@ -35,10 +35,20 @@
155 }
156
157 struct General_Statistics_Menu : public UI::UniqueWindow {
158+
159+ // Custom registry, to store the selected_information as well.
160+ struct Registry : public UI::UniqueWindow::Registry {
161+ Registry() : UI::UniqueWindow::Registry(), selected_information(0) {}
162+
163+ int32_t selected_information;
164+ };
165+
166 General_Statistics_Menu
167- (Interactive_GameBase &, UI::UniqueWindow::Registry &);
168+ (Interactive_GameBase &, Registry &);
169+ virtual ~General_Statistics_Menu();
170
171 private:
172+ Registry * m_my_registry;
173 UI::Box m_box;
174 WUIPlot_Area m_plot;
175 UI::Radiogroup m_radiogroup;
176
177=== modified file 'src/wui/interactive_gamebase.h'
178--- src/wui/interactive_gamebase.h 2011-02-19 23:53:52 +0000
179+++ src/wui/interactive_gamebase.h 2011-11-06 18:20:30 +0000
180@@ -23,6 +23,7 @@
181 #include "interactive_base.h"
182 #include "logic/game.h"
183 #include "graphic/graphic.h"
184+#include "general_statistics_menu.h"
185
186 struct ChatOverlay;
187 struct ChatProvider;
188@@ -40,7 +41,7 @@
189 UI::UniqueWindow::Registry sound_options;
190
191 UI::UniqueWindow::Registry building_stats;
192- UI::UniqueWindow::Registry general_stats;
193+ General_Statistics_Menu::Registry general_stats;
194 UI::UniqueWindow::Registry ware_stats;
195 UI::UniqueWindow::Registry stock;
196 };
197
198=== modified file 'src/wui/interactive_player.cc'
199--- src/wui/interactive_player.cc 2011-11-04 21:57:40 +0000
200+++ src/wui/interactive_player.cc 2011-11-06 18:20:30 +0000
201@@ -189,25 +189,25 @@
202 m_encyclopedia.constr = boost::lambda::bind
203 (boost::lambda::new_ptr<EncyclopediaWindow>(),
204 boost::ref(*this),
205- boost::lambda::_1);
206+ boost::ref(m_encyclopedia));
207 m_options.constr = boost::lambda::bind
208 (boost::lambda::new_ptr<GameOptionsMenu>(),
209 boost::ref(*this),
210- boost::lambda::_1,
211+ boost::ref(m_options),
212 boost::ref(m_mainm_windows));
213 m_statisticsmenu.constr = boost::lambda::bind
214 (boost::lambda::new_ptr<GameMainMenu>(),
215 boost::ref(*this),
216- boost::lambda::_1,
217+ boost::ref(m_statisticsmenu),
218 boost::ref(m_mainm_windows));
219 m_objectives.constr = boost::lambda::bind
220 (boost::lambda::new_ptr<GameObjectivesMenu>(),
221 boost::ref(*this),
222- boost::lambda::_1);
223+ boost::ref(m_objectives));
224 m_message_menu.constr = boost::lambda::bind
225 (boost::lambda::new_ptr<GameMessageMenu>(),
226 boost::ref(*this),
227- boost::lambda::_1);
228+ boost::ref(m_message_menu));
229
230 #ifdef DEBUG // only in debug builds
231 addCommand

Subscribers

People subscribed via source and target branches

to status/vote changes: