Unit Advance: some layout improvements, code cleanup and clarification, and a minor issue fix
The fix is disabling ESC-closing of the dialog.
This commit is contained in:
parent
ebf90fbd94
commit
5398980ac0
4 changed files with 28 additions and 23 deletions
|
@ -21,12 +21,11 @@
|
|||
[grid]
|
||||
[row]
|
||||
[column]
|
||||
grow_factor = 1
|
||||
grow_factor = 0
|
||||
horizontal_grow = "true"
|
||||
|
||||
# Smaller border deliberately
|
||||
border = "all"
|
||||
border_size = 1
|
||||
border_size = 5
|
||||
|
||||
[image]
|
||||
id = "advancement_image"
|
||||
definition = "default"
|
||||
|
@ -35,6 +34,7 @@
|
|||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
|
@ -133,6 +133,8 @@
|
|||
[row]
|
||||
grow_factor=0
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
[label]
|
||||
definition = "default"
|
||||
label = _ "What should our victorious unit become?"
|
||||
|
@ -142,6 +144,7 @@
|
|||
[row]
|
||||
grow_factor=1
|
||||
[column]
|
||||
horizontal_grow = "true"
|
||||
{_GUI_ADVANCE_LIST}
|
||||
[/column]
|
||||
[/row]
|
||||
|
|
|
@ -106,13 +106,17 @@ int advance_unit_dialog(const map_location &loc)
|
|||
|
||||
if(previews.size() > 1 || always_display) {
|
||||
gui2::tunit_advance dlg(previews, num_real_advances);
|
||||
|
||||
dlg.show(CVideo::get_singleton());
|
||||
|
||||
if(dlg.get_retval() == gui2::twindow::OK) {
|
||||
return dlg.get_selected_index();
|
||||
} else {
|
||||
assert(false);
|
||||
}
|
||||
|
||||
// This should be unreachable, since canceling is disabled for the dialog
|
||||
assert(false);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,16 +29,7 @@
|
|||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
#include "units/unit.hpp"
|
||||
//#include "gettext.hpp"
|
||||
#include "help/help.hpp"
|
||||
//#include "marked-up_text.hpp"
|
||||
//#include "play_controller.hpp"
|
||||
//#include "resources.hpp"
|
||||
//#include "team.hpp"
|
||||
//#include "actions/attack.hpp" // for get_advanced_unit, get_amla_unit
|
||||
//#include "units/types.hpp"
|
||||
//#include "whiteboard/manager.hpp"
|
||||
//#include "game_preferences.hpp"
|
||||
|
||||
#include "utils/functional.hpp"
|
||||
|
||||
|
@ -50,7 +41,7 @@ REGISTER_DIALOG(unit_advance)
|
|||
tunit_advance::tunit_advance(const unit_ptr_vector& samples, size_t real)
|
||||
: previews_(samples)
|
||||
, selected_index_(0)
|
||||
, real_(real)
|
||||
, last_real_advancement_(real)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -76,21 +67,25 @@ void tunit_advance::pre_show(twindow& window)
|
|||
|
||||
for(size_t i = 0; i < previews_.size(); i++) {
|
||||
const unit& sample = *previews_[i];
|
||||
|
||||
std::map<std::string, string_map> row_data;
|
||||
string_map column;
|
||||
|
||||
std::string image_string, name = sample.type_name();
|
||||
if(i >= real_) {
|
||||
auto iter = sample
|
||||
.get_modifications()
|
||||
.child_range("advancement")
|
||||
.second;
|
||||
std::string image_string, name = sample.type_name();
|
||||
|
||||
// This checks if we've finished iterating over the last unit type advancements
|
||||
// and are into the modification-based advancements.
|
||||
if(i >= last_real_advancement_) {
|
||||
auto iter = sample.get_modifications().child_range("advancement").second;
|
||||
iter--;
|
||||
|
||||
if(iter->has_attribute("image")) {
|
||||
image_string = iter->get("image")->str();
|
||||
}
|
||||
|
||||
name = iter->get("description")->str();
|
||||
}
|
||||
|
||||
if(image_string.empty()) {
|
||||
image_string = sample.type().image() + sample.image_mods();
|
||||
}
|
||||
|
@ -105,6 +100,9 @@ void tunit_advance::pre_show(twindow& window)
|
|||
}
|
||||
|
||||
list_item_clicked(window);
|
||||
|
||||
// Disable ESC existing
|
||||
window.set_escape_disabled(true);
|
||||
}
|
||||
|
||||
void tunit_advance::list_item_clicked(twindow& window)
|
||||
|
|
|
@ -44,7 +44,7 @@ private:
|
|||
|
||||
const unit_ptr_vector& previews_;
|
||||
|
||||
size_t selected_index_, real_;
|
||||
size_t selected_index_, last_real_advancement_;
|
||||
};
|
||||
|
||||
} // namespace gui2
|
||||
|
|
Loading…
Add table
Reference in a new issue