widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #00446
[Merge] lp:~nomeata/widelands/plot-improvements into lp:widelands
Joachim Breitner has proposed merging lp:~nomeata/widelands/plot-improvements into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #536543 in widelands: "Add "whole game" to the time axis in statistics"
https://bugs.launchpad.net/widelands/+bug/536543
Bug #672085 in widelands: "New stock menu layout too high for small resolutions"
https://bugs.launchpad.net/widelands/+bug/672085
Bug #886709 in widelands: "new slider statistics menu opens in wrong position or so"
https://bugs.launchpad.net/widelands/+bug/886709
For more details, see:
https://code.launchpad.net/~nomeata/widelands/plot-improvements/+merge/81392
This should be the fix for #886709. Good morning by the way.
--
https://code.launchpad.net/~nomeata/widelands/plot-improvements/+merge/81392
Your team Widelands Developers is requested to review the proposed merge of lp:~nomeata/widelands/plot-improvements into lp:widelands.
=== modified file 'src/wui/plot_area.cc'
--- src/wui/plot_area.cc 2011-11-05 18:24:22 +0000
+++ src/wui/plot_area.cc 2011-11-06 10:40:34 +0000
@@ -58,7 +58,8 @@
:
UI::Panel (parent, x, y, w, h),
m_time (TIME_GAME),
-m_plotmode(PLOTMODE_ABSOLUTE)
+m_plotmode(PLOTMODE_ABSOLUTE),
+m_game_time_id(0)
{}
@@ -115,6 +116,7 @@
case UNIT_HOUR: return _("h");
case UNIT_MIN: return _("min");
}
+ return "invalid";
}
uint32_t WUIPlot_Area::ms_to_unit(UNIT unit, uint32_t ms) {
@@ -123,26 +125,31 @@
case UNIT_HOUR: return ms / hours;
case UNIT_MIN: return ms / minutes;
}
+ return -1;
}
std::vector<std::string> WUIPlot_Area::get_labels() {
std::vector<std::string> labels;
+ for (int32_t i = 0; i < m_game_time_id; i++) {
+ UNIT unit = get_suggested_unit(time_in_ms[i]);
+ uint32_t val = ms_to_unit(unit, time_in_ms[i]);
+ labels.push_back(boost::lexical_cast<std::string>(val) + get_unit_name(unit));
+ }
+ labels.push_back(_("game"));
+ return labels;
+}
+
+/**
+ * Find the last predefined time span that is less than the game time
+ */
+void WUIPlot_Area::calc_game_time_id() {
uint32_t game_time = get_game_time();
uint32_t i = 0;
-
- for (i = 0; i < 7; i++) {
- if (time_in_ms[i] < game_time) {
- UNIT unit = get_suggested_unit(time_in_ms[i]);
- uint32_t val = ms_to_unit(unit, time_in_ms[i]);
- labels.push_back(boost::lexical_cast<std::string>(val) + get_unit_name(unit));
- }
+ for (i = 0; i < 7 && time_in_ms[i] <= game_time; i++) {
}
- labels.push_back(_("game"));
- m_game_label = i;
- return labels;
+ m_game_time_id = i;
}
-
/*
* Draw this. This is the main function
*/
@@ -379,6 +386,8 @@
m_plotdata[id].dataset = data;
m_plotdata[id].showplot = false;
m_plotdata[id].plotcolor = color;
+
+ calc_game_time_id();
}
/*
=== modified file 'src/wui/plot_area.h'
--- src/wui/plot_area.h 2011-11-05 21:32:08 +0000
+++ src/wui/plot_area.h 2011-11-06 10:40:34 +0000
@@ -42,7 +42,6 @@
TIME_EIGHT_HOURS,
TIME_16_HOURS,
TIME_GAME,
- TIME_LAST,
};
enum UNIT {
UNIT_MIN,
@@ -66,13 +65,14 @@
m_time = id;
}
- void set_time_int(int32_t time) {
- if (time == m_game_label)
+ void set_time_id(int32_t time) {
+ if (time == m_game_time_id)
set_time(TIME_GAME);
else
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; };
void set_sample_rate(uint32_t id); // in milliseconds
void register_plot_data
@@ -86,6 +86,7 @@
private:
uint32_t get_game_time();
uint32_t get_plot_time();
+ void calc_game_time_id();
UNIT get_suggested_unit(uint32_t game_time);
std::string get_unit_name(UNIT unit);
uint32_t ms_to_unit(UNIT unit, uint32_t ms);
@@ -96,10 +97,10 @@
RGBColor plotcolor;
};
std::vector<__plotdata> m_plotdata;
- int32_t m_time; // How much do you want to list
+ TIME m_time; // How much do you want to list
int32_t m_sample_rate;
int32_t m_plotmode;
- int32_t m_game_label; // what label is used for TIME_GAME
+ int32_t m_game_time_id; // what label is used for TIME_GAME
};
/**
@@ -119,13 +120,13 @@
(parent,
x, y, w, h,
plot_area.get_labels(),
- plot_area.get_time(),
+ plot_area.get_game_time_id(),
background_picture_id,
tooltip_text,
cursor_size,
enabled)
{
- changedto->set(&plot_area, &WUIPlot_Area::set_time_int);
+ changedto->set(&plot_area, &WUIPlot_Area::set_time_id);
}
};