Modified the game state inspector for the bug #22337
(Bug in inspect long array) When an array are more than 20000 characters, its label is duplicated for the number of "pages" that needs to display its content [[Minor style fixes from shadowm.]]
This commit is contained in:
parent
e20e7d7f87
commit
ddbdec3a61
2 changed files with 24 additions and 10 deletions
|
@ -125,6 +125,7 @@ Version 1.13.0-dev:
|
|||
resolution for OS X to 800 x 600 (bug #20332).
|
||||
* Removed the "Replay viewer" text label from the replay controller theme,
|
||||
because it caused problems for translators and was unnecessary
|
||||
* Fixed bug #22337: Bug in inspect long arrays
|
||||
* WML engine:
|
||||
* Added customizable recall costs for unit types and individual units,
|
||||
using the new recall_cost attribute in [unit_type] and [unit].
|
||||
|
|
|
@ -140,6 +140,8 @@ public:
|
|||
tcontrol* inspector_name;
|
||||
tbutton* copy_button;
|
||||
|
||||
static const unsigned int max_inspect_win_len = 20000;
|
||||
|
||||
|
||||
void clear_stuff_list()
|
||||
{
|
||||
|
@ -175,14 +177,18 @@ public:
|
|||
}
|
||||
|
||||
|
||||
void set_inspect_window_text(const std::string& s)
|
||||
void set_inspect_window_text(const std::string& s, unsigned int page = 0)
|
||||
{
|
||||
std::string s_ = s;
|
||||
if(s_.length() > 20000) { // workaround for known bug
|
||||
s_.resize(20000);
|
||||
}
|
||||
unsigned int reminder = (s.length() - (max_inspect_win_len * page));
|
||||
std::string s_ = s.substr(max_inspect_win_len * page, reminder > max_inspect_win_len ? max_inspect_win_len : reminder);
|
||||
inspect->set_label(s_);
|
||||
}
|
||||
|
||||
|
||||
unsigned int get_num_page(const std::string& s)
|
||||
{
|
||||
return (s.length() / max_inspect_win_len) + (s.length() % max_inspect_win_len > 0 ? 1 : 0);
|
||||
}
|
||||
};
|
||||
|
||||
class single_mode_controller
|
||||
|
@ -235,7 +241,12 @@ public:
|
|||
|
||||
FOREACH(const AUTO & c, vars.all_children_range())
|
||||
{
|
||||
model_.add_row_to_stuff_list("[" + c.key + "]", "[" + c.key + "]");
|
||||
unsigned int num_pages = model_.get_num_page(config_to_string(c.cfg));
|
||||
for (unsigned int i = 0; i < num_pages; i++) {
|
||||
std::ostringstream cur_str;
|
||||
cur_str << "[" << c.key << "] " << (i + 1) << "/" << num_pages;
|
||||
model_.add_row_to_stuff_list(cur_str.str(), cur_str.str());
|
||||
}
|
||||
}
|
||||
|
||||
model_.set_inspect_window_text("");
|
||||
|
@ -265,11 +276,13 @@ public:
|
|||
|
||||
FOREACH(const AUTO & c, vars.all_children_range())
|
||||
{
|
||||
if(selected == i) {
|
||||
model_.set_inspect_window_text(config_to_string(c.cfg));
|
||||
return;
|
||||
for (unsigned int j = 0; j < model_.get_num_page(config_to_string(c.cfg)); ++j) {
|
||||
if (selected == i) {
|
||||
model_.set_inspect_window_text(config_to_string(c.cfg), j);
|
||||
return;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue