← Back to team overview

widelands-dev team mailing list archive

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

 

Joachim Breitner has proposed merging lp:~nomeata/widelands/statistics-menu-settings-persistent into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #840377 in widelands: "WL should remember which section in general statistic the user had opened last"
  https://bugs.launchpad.net/widelands/+bug/840377

For more details, see:
https://code.launchpad.net/~nomeata/widelands/statistics-menu-settings-persistent/+merge/81419

Now the persistence of the statistics window works for all of its setting, and reliable.
-- 
https://code.launchpad.net/~nomeata/widelands/statistics-menu-settings-persistent/+merge/81419
Your team Widelands Developers is requested to review the proposed merge of lp:~nomeata/widelands/statistics-menu-settings-persistent into lp:widelands.
=== modified file 'src/wui/general_statistics_menu.cc'
--- src/wui/general_statistics_menu.cc	2011-11-06 18:12:32 +0000
+++ src/wui/general_statistics_menu.cc	2011-11-06 21:28:29 +0000
@@ -52,9 +52,9 @@
 m_plot          (&m_box, 0, 0, 430, PLOT_HEIGHT),
 m_selected_information(0)
 {
-	if (m_my_registry) {
-		m_selected_information = m_my_registry->selected_information;
-	}
+	assert (m_my_registry);
+
+	m_selected_information = m_my_registry->selected_information;
 
 	set_center_panel(&m_box);
 	m_box.set_border(5, 5, 5, 5);
@@ -64,7 +64,6 @@
 	// Setup plot data
 	m_plot.set_sample_rate(STATISTICS_SAMPLE_TIME);
 	m_plot.set_plotmode(WUIPlot_Area::PLOTMODE_ABSOLUTE);
-
 	Game & game = *parent.get_game();
 	const Game::General_Stats_vector & genstats =
 		game.get_general_statistics();
@@ -126,9 +125,13 @@
 				 color);
 		}
 		if (game.get_player(i + 1)) // Show area plot
-			m_plot.show_plot(i * m_ndatasets, 1);
+			m_plot.show_plot
+				(i * m_ndatasets + m_selected_information,
+				 m_my_registry->selected_players[i]);
 	}
 
+	m_plot.set_time(m_my_registry->time);
+
 	// Setup Widgets
 	m_box.add(&m_plot, UI::Box::AlignTop);
 
@@ -152,7 +155,9 @@
 					 boost::ref(*this),
 					p),
 				 player->get_name().c_str());
-		cb.set_perm_pressed(true);
+
+		cb.set_perm_pressed(m_my_registry->selected_players[p - 1]);
+
 		m_cbs[p - 1] = &cb;
 
 		hbox1->add(&cb, UI::Box::AlignLeft);
@@ -279,8 +284,13 @@
 }
 
 General_Statistics_Menu::~General_Statistics_Menu() {
-	if (m_my_registry) {
-		m_my_registry->selected_information = m_selected_information;
+	m_my_registry->selected_information = m_selected_information;
+	m_my_registry->time = m_plot.get_time();
+	Game & game = ref_cast<Interactive_GameBase, UI::Panel>(*get_parent()).game();
+	Player_Number const nr_players = game.map().get_nrplayers();
+	iterate_players_existing_const(p, nr_players, game, player) {
+		m_my_registry->selected_players[p - 1] =
+			m_cbs[p - 1]->get_perm_pressed();
 	}
 }
 

=== modified file 'src/wui/general_statistics_menu.h'
--- src/wui/general_statistics_menu.h	2011-11-06 18:12:32 +0000
+++ src/wui/general_statistics_menu.h	2011-11-06 21:28:29 +0000
@@ -38,9 +38,16 @@
 
 	// Custom registry, to store the selected_information as well.
 	struct Registry : public UI::UniqueWindow::Registry {
-		Registry() : UI::UniqueWindow::Registry(), selected_information(0) {}
+		Registry() :
+			UI::UniqueWindow::Registry(),
+			selected_information(0),
+			selected_players(true, MAX_PLAYERS),
+			time(WUIPlot_Area::TIME_GAME)
+		{}
 
 		int32_t selected_information;
+		std::vector<bool> selected_players;
+		WUIPlot_Area::TIME time;
 	};
 
 	General_Statistics_Menu

=== modified file 'src/wui/plot_area.h'
--- src/wui/plot_area.h	2011-11-06 10:23:32 +0000
+++ src/wui/plot_area.h	2011-11-06 21:28:29 +0000
@@ -72,7 +72,12 @@
 			set_time(static_cast<TIME>(time));
 	};
 	TIME get_time() {return static_cast<TIME>(m_time); };
-	int32_t get_game_time_id() {return m_game_time_id; };
+	int32_t get_time_id() {
+		if (m_time == TIME_GAME)
+			return m_game_time_id;
+		else
+			return m_time;
+	};
 	void set_sample_rate(uint32_t id); // in milliseconds
 
 	void register_plot_data
@@ -120,7 +125,7 @@
 		(parent,
 		 x, y, w, h,
 		 plot_area.get_labels(),
-		 plot_area.get_game_time_id(),
+		 plot_area.get_time_id(),
 		 background_picture_id,
 		 tooltip_text,
 		 cursor_size,


Follow ups