Finetuned the recruit dialogue.
This commit is contained in:
parent
56757e1a2b
commit
3fe7c28c3d
3 changed files with 225 additions and 41 deletions
|
@ -444,6 +444,103 @@
|
|||
[/listbox]
|
||||
#enddef
|
||||
|
||||
#define _GUI_RECRUIT_LIST
|
||||
[listbox]
|
||||
id = "recruit_list"
|
||||
definition = "wml_message"
|
||||
[list_definition]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
[toggle_panel]
|
||||
definition = "wml_message"
|
||||
|
||||
return_value_id = "ok"
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
grow_factor = 0
|
||||
horizontal_alignment = "left"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[image]
|
||||
id = "icon"
|
||||
definition = "default"
|
||||
linked_group = "icon"
|
||||
[/image]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 0
|
||||
horizontal_alignment = "left"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "type"
|
||||
definition = "default"
|
||||
linked_group = "type"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 0
|
||||
horizontal_alignment = "left"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[image]
|
||||
id = "gold"
|
||||
definition = "default"
|
||||
#linked_group = "icon"
|
||||
[/image]
|
||||
|
||||
[/column]
|
||||
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "cost"
|
||||
definition = "default"
|
||||
linked_group = "cost"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/toggle_panel]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/list_definition]
|
||||
|
||||
[/listbox]
|
||||
#enddef
|
||||
|
||||
|
||||
|
||||
[window]
|
||||
id = "wml_message_left"
|
||||
|
@ -657,29 +754,91 @@
|
|||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "center"
|
||||
horizontal_grow = "true"
|
||||
|
||||
[button]
|
||||
# This button will be shown or hidden depending on the
|
||||
# whether or not a scrollbar is needed to show the
|
||||
# text.
|
||||
id = "ok"
|
||||
definition = "transparent"
|
||||
|
||||
label = _ "OK"
|
||||
[/button]
|
||||
{_GUI_RECRUIT_LIST}
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "center"
|
||||
|
||||
[button]
|
||||
# This button will be shown or hidden depending on the
|
||||
# whether or not a sellection may be avoided
|
||||
id = "help"
|
||||
definition = "transparent"
|
||||
label = _ "Help"
|
||||
[/button]
|
||||
[/column]
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "center"
|
||||
|
||||
[button]
|
||||
# This button will be shown or hidden depending on the
|
||||
# whether or not a sellection may be avoided
|
||||
id = "profile"
|
||||
definition = "transparent"
|
||||
|
||||
label = _ "Profile"
|
||||
[/button]
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "center"
|
||||
|
||||
[button]
|
||||
# This button will be shown or hidden depending on the
|
||||
# whether or not a scrollbar is needed to show the
|
||||
# text.
|
||||
id = "ok"
|
||||
definition = "transparent"
|
||||
|
||||
label = _ "OK"
|
||||
[/button]
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "center"
|
||||
|
||||
[button]
|
||||
# This button will be shown or hidden depending on the
|
||||
# whether or not a scrollbar is needed to show the
|
||||
# text.
|
||||
id = "cancel"
|
||||
definition = "transparent"
|
||||
|
||||
label = _ "Cancel"
|
||||
[/button]
|
||||
[/column]
|
||||
[/row]
|
||||
[/grid]
|
||||
[/column]
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/column]
|
||||
|
@ -911,6 +1070,25 @@ if(gamemap_width - ({__GUI_IMAGE_WIDTH}) > {MAX_TEXT_WIDTH}
|
|||
[/button]
|
||||
|
||||
[/column]
|
||||
[/row]
|
||||
[row]
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "center"
|
||||
|
||||
[button]
|
||||
# This button will be shown or hidden depending on the
|
||||
# whether or not a scrollbar is needed to show the
|
||||
# text.
|
||||
id = "canel"
|
||||
definition = "transparent"
|
||||
|
||||
label = _ "Cancel"
|
||||
[/button]
|
||||
|
||||
[/column]
|
||||
|
||||
|
||||
[/row]
|
||||
|
||||
|
@ -967,6 +1145,7 @@ if(gamemap_width - (10 + ({__GUI_IMAGE_WIDTH})) > {MAX_TEXT_WIDTH}
|
|||
[/window]
|
||||
|
||||
#undef _GUI_INPUT_LIST
|
||||
#undef _GUI_UNIT_LIST
|
||||
|
||||
#undef __GUI_IMAGE_DISPLAYED_Y
|
||||
#undef __GUI_IMAGE_DISPLAYED_X
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "map.hpp"
|
||||
#include "help.hpp"
|
||||
#include "gettext.hpp" //could be done in menu_events
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
|
@ -53,7 +54,7 @@ void twml_message_::help_pressed() {
|
|||
}
|
||||
|
||||
void twml_message_::update_unit_list(twindow& window) {
|
||||
tlistbox& unit_listbox = find_widget<tlistbox> (&window, "unit_list", false);
|
||||
tlistbox& unit_listbox = find_widget<tlistbox> (&window, "recruit_list", false);
|
||||
|
||||
//TODO this hack does not respect the sorting of the list.
|
||||
chosen_unit_ = &unit_list_[unit_listbox.get_selected_row()];
|
||||
|
@ -103,6 +104,7 @@ void twml_message_::set_unit_list(
|
|||
|
||||
unit_id_ = unit_id;
|
||||
unit_list_ = unit_list;
|
||||
chosen_unit_ = &unit_list_[0];
|
||||
}
|
||||
|
||||
void twml_message_::set_type_list(
|
||||
|
@ -119,12 +121,10 @@ void twml_message_::set_type_list(
|
|||
|
||||
for (it = type_list.begin(); it != type_list.end(); it++)
|
||||
{
|
||||
// TODO false is the right value
|
||||
//unit new_unit(*it, side_num, false);
|
||||
unit new_unit(*it, side_num, true);
|
||||
//new_unit.set_
|
||||
unit new_unit(*it, side_num, false);
|
||||
unit_list_.push_back(new_unit);
|
||||
}
|
||||
chosen_unit_ = &unit_list_[0];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -169,12 +169,32 @@ void twml_message_::pre_show(CVideo& /*video*/, twindow& window)
|
|||
}
|
||||
|
||||
// Find the unit list related fields:
|
||||
tlistbox& units = find_widget<tlistbox>(&window, "unit_list", true);
|
||||
// tlistbox& units = find_widget<tlistbox>(&window, "unit_list", true);
|
||||
tlistbox& units = find_widget<tlistbox>(&window, "recruit_list", true);
|
||||
units.set_callback_value_change(dialog_callback<twml_message_,
|
||||
&twml_message_::update_unit_list> );
|
||||
|
||||
|
||||
if(!unit_list_.empty()) {
|
||||
|
||||
window.canvas(1).set_variable("portrait_image", variant(
|
||||
chosen_unit_->big_profile()));
|
||||
window.set_dirty();
|
||||
|
||||
//TODO make it optional
|
||||
connect_signal_mouse_left_click(
|
||||
find_widget<tbutton>(&window, "help", true)
|
||||
, boost::bind(
|
||||
&twml_message_::help_pressed
|
||||
, this
|
||||
));
|
||||
|
||||
connect_signal_mouse_left_click(
|
||||
find_widget<tbutton>(&window, "profile", true)
|
||||
, boost::bind(
|
||||
&twml_message_::profile_pressed
|
||||
, this
|
||||
));
|
||||
|
||||
std::map<std::string, string_map> data;
|
||||
for(size_t i = 0; i < unit_list_.size(); ++i) {
|
||||
|
||||
|
@ -195,7 +215,7 @@ void twml_message_::pre_show(CVideo& /*video*/, twindow& window)
|
|||
|
||||
// Show units of level (0=gray, 1 normal, 2 bold, 2+ bold&wbright)
|
||||
const int level_number = unit.level();
|
||||
//TODO enabe the switch construct after replacing the font::NORMAL_TEXT etc.
|
||||
//TODO enable the switch construct after replacing the font::NORMAL_TEXT etc.
|
||||
// switch(level_number)
|
||||
// {
|
||||
// case 0: level << "<150,150,150>";
|
||||
|
@ -218,6 +238,7 @@ void twml_message_::pre_show(CVideo& /*video*/, twindow& window)
|
|||
// Add the data.
|
||||
data["cost"]["label"] = cost.str();
|
||||
data["cost"]["use_markup"] = "true";
|
||||
data["gold"]["label"] = "items/gold-coins-small.png";
|
||||
data["usage"]["label"] = unit.usage();
|
||||
data["icon"]["label"] = icon;
|
||||
data["icon"]["use_markup"] = "true";
|
||||
|
@ -226,10 +247,14 @@ void twml_message_::pre_show(CVideo& /*video*/, twindow& window)
|
|||
data["label"]["use_markup"] = "true";
|
||||
data["level"]["label"] = level.str();
|
||||
data["xp"]["label"] = xp.str();
|
||||
//TODO traits handling changed through the versions
|
||||
//data["traits"]["label"] = unit.traits_description();
|
||||
units.add_row(data);
|
||||
}
|
||||
} else {
|
||||
tbutton* profile_button = find_widget<tbutton> (&window, "profile", false,
|
||||
false);
|
||||
profile_button->set_visible(twidget::INVISIBLE);
|
||||
units.set_visible(twidget::INVISIBLE);
|
||||
}
|
||||
|
||||
|
@ -312,8 +337,7 @@ int show_recruit_message(const bool left_side
|
|||
{
|
||||
const std::string title = _("Recruit");
|
||||
const std::string message = _("Select unit:");
|
||||
//TODO correct fetching the portrait
|
||||
const std::string portrait = "";//type_list.begin()->big_profile(); //.begin().big_profile();
|
||||
const std::string portrait = "";
|
||||
const bool mirror = false;
|
||||
std::auto_ptr<twml_message_> dlg;
|
||||
if(left_side) {
|
||||
|
|
|
@ -718,25 +718,6 @@ void menu_handler::recruit(int side_num, const map_location &last_hex)
|
|||
recruit_res = gui2::show_recruit_message(left_side, gui_->video(),
|
||||
sample_units, &unit_type, side_num, gold);
|
||||
|
||||
/* TODO old gui1 call, can be removed
|
||||
{
|
||||
dialogs::unit_types_preview_pane unit_preview(
|
||||
sample_units, NULL, side_num);
|
||||
std::vector<gui::preview_pane*> preview_panes;
|
||||
preview_panes.push_back(&unit_preview);
|
||||
|
||||
gui::dialog rmenu(*gui_, _("Recruit") + get_title_suffix(side_num),
|
||||
_("Select unit:") + std::string("\n"),
|
||||
gui::OK_CANCEL,
|
||||
gui::dialog::default_style);
|
||||
rmenu.add_button(new help::help_button(*gui_,"recruit_and_recall"),
|
||||
gui::dialog::BUTTON_HELP);
|
||||
rmenu.set_menu(items);
|
||||
rmenu.set_panes(preview_panes);
|
||||
recruit_res = rmenu.show();
|
||||
}
|
||||
*/
|
||||
|
||||
//TODO fix the dialog and enable again
|
||||
// if(recruit_res != -1) {
|
||||
if(recruit_res == -1) {
|
||||
|
|
Loading…
Add table
Reference in a new issue