Made use of [list_data] for static lists in various dialogs

This commit is contained in:
Charles Dang 2016-08-29 19:10:04 +11:00
parent 0bc5e2ba4a
commit 0bbe26ec5e
11 changed files with 258 additions and 100 deletions

View file

@ -514,6 +514,49 @@
[/column]
[/row]
[/list_definition]
[list_data]
[row]
[column]
[widget]
id = "tab_label"
label = _ "Paths"
[/widget]
[/column]
[/row]
[row]
[column]
[widget]
id = "tab_label"
label = _ "Libraries"
[/widget]
[/column]
[/row]
[row]
[column]
[widget]
id = "tab_label"
label = _ "Features"
[/widget]
[/column]
[/row]
[/list_data]
[/horizontal_listbox]
[/column]

View file

@ -716,34 +716,87 @@
#enddef
#define _GUI_MP_CREATE_TAB_BAR
[toggle_panel]
linked_group = "tabs"
[horizontal_listbox]
id = "tab_bar"
[grid]
[list_definition]
[row]
[column]
[toggle_panel]
linked_group = "tabs"
[grid]
[row]
{_GUI_MP_CREATE_TAB_PADDING}
[column]
grow_factor = 1
border = all
border_size = 5
[label]
id = "tab_label"
wrap = true
[/label]
[/column]
{_GUI_MP_CREATE_TAB_PADDING}
[/row]
[/grid]
[/toggle_panel]
[/column]
[/row]
[/list_definition]
[list_data]
[row]
{_GUI_MP_CREATE_TAB_PADDING}
[column]
grow_factor = 1
border = all
border_size = 5
[label]
[widget]
id = "tab_label"
wrap = true
[/label]
label = _ "General"
[/widget]
[/column]
{_GUI_MP_CREATE_TAB_PADDING}
[/row]
[row]
[column]
[widget]
id = "tab_label"
label = _ "Custom Options"
[/widget]
[/column]
[/row]
[/grid]
[row]
[/toggle_panel]
[column]
[widget]
id = "tab_label"
label = _ "Game Settings"
[/widget]
[/column]
[/row]
[/list_data]
[/horizontal_listbox]
#enddef
#define _GUI_MP_CREATE_TAB_PADDING

View file

@ -247,17 +247,7 @@
border_size = 5
horizontal_alignment = "center"
[horizontal_listbox]
id = "tab_bar"
[list_definition]
[row]
[column]
{_GUI_MP_CREATE_TAB_BAR}
[/column]
[/row]
[/list_definition]
[/horizontal_listbox]
{_GUI_MP_CREATE_TAB_BAR}
[/column]

View file

@ -248,17 +248,7 @@
border_size = 5
horizontal_alignment = "center"
[horizontal_listbox]
id = "tab_bar"
[list_definition]
[row]
[column]
{_GUI_MP_CREATE_TAB_BAR}
[/column]
[/row]
[/list_definition]
[/horizontal_listbox]
{_GUI_MP_CREATE_TAB_BAR}
[/column]

View file

@ -51,17 +51,7 @@
border_size = 5
horizontal_alignment = "right"
[horizontal_listbox]
id = "tab_bar"
[list_definition]
[row]
[column]
{_GUI_MP_CREATE_TAB_BAR}
[/column]
[/row]
[/list_definition]
[/horizontal_listbox]
{_GUI_MP_CREATE_TAB_BAR}
[/column]
[/row]
[/grid]

View file

@ -15,7 +15,7 @@
[/column]
#enddef
#define _GUI_PREFS_TAB_BAR
#define _GUI_PREFS_TAB_BAR _LIST_DATA
[horizontal_listbox]
id = "tab_selector"
@ -54,6 +54,10 @@
[/row]
[/list_definition]
[list_data]
{_LIST_DATA}
[/list_data]
[/horizontal_listbox]
#enddef
@ -275,6 +279,118 @@
[/column]
[/row]
[/list_definition]
[list_data]
[row]
[column]
[widget]
id = "icon"
label = "icons/icon-general.png"
[/widget]
[widget]
id = "label"
label = _ "General"
[/widget]
[/column]
[/row]
[row]
[column]
[widget]
id = "icon"
label = "icons/icon-hotkeys.png"
[/widget]
[widget]
id = "label"
label = _ "Hotkeys"
[/widget]
[/column]
[/row]
[row]
[column]
[widget]
id = "icon"
label = "icons/icon-display.png"
[/widget]
[widget]
id = "label"
label = _ "Display"
[/widget]
[/column]
[/row]
[row]
[column]
[widget]
id = "icon"
label = "icons/icon-music.png"
[/widget]
[widget]
id = "label"
label = _ "Sound"
[/widget]
[/column]
[/row]
[row]
[column]
[widget]
id = "icon"
label = "icons/icon-multiplayer.png"
[/widget]
[widget]
id = "label"
label = _ "Multiplayer"
[/widget]
[/column]
[/row]
[row]
[column]
[widget]
id = "icon"
label = "icons/icon-advanced.png"
[/widget]
[widget]
id = "label"
label = _ "Advanced"
[/widget]
[/column]
[/row]
[/list_data]
[/listbox]
[/column]

View file

@ -403,7 +403,33 @@
border_size = 5
horizontal_alignment = "left"
{_GUI_PREFS_TAB_BAR}
{_GUI_PREFS_TAB_BAR (
[row]
[column]
[widget]
id = "tab_label"
label = _ "General"
[/widget]
[/column]
[/row]
[row]
[column]
[widget]
id = "tab_label"
label = _ "Friends"
[/widget]
[/column]
[/row]
)}
[/column]
[/row]
#enddef
@ -426,7 +452,7 @@
{_GUI_PREFERENCES_MP_PAGE_1_GRID_1}
[/grid]
[/column]
[/row]
[/row]
[row]
[column]

View file

@ -267,16 +267,6 @@ void tgame_version::pre_show(twindow& window)
tlistbox& tab_bar
= find_widget<tlistbox>(&window, "tab_bar", false);
list_data["tab_label"]["label"] = _("Paths");
tab_bar.add_row(list_data);
list_data["tab_label"]["label"] = _("Libraries");
tab_bar.add_row(list_data);
list_data["tab_label"]["label"] = _("Features");
tab_bar.add_row(list_data);
tab_bar.select_row(0);
window.keyboard_capture(&tab_bar);
const unsigned tab_count = tab_bar.get_item_count();

View file

@ -281,17 +281,6 @@ void tmp_create_game::pre_show(twindow& window)
dialog_callback<tmp_create_game, &tmp_create_game::on_tab_select>);
#endif
std::map<std::string, string_map> list_data;
list_data["tab_label"]["label"] = _("General");
tab_bar.add_row(list_data);
list_data["tab_label"]["label"] = _("Custom Options");
tab_bar.add_row(list_data);
list_data["tab_label"]["label"] = _("Game Settings");
tab_bar.add_row(list_data);
//
// Main games list
//

View file

@ -1083,32 +1083,12 @@ void tpreferences::on_advanced_prefs_list_select(tlistbox& list, twindow& window
}
}
void tpreferences::add_pager_row(tlistbox& selector, const std::string& icon, const std::string& label)
{
std::map<std::string, string_map> data;
data["icon"]["label"] = "icons/icon-" + icon;
data["label"]["label"] = label;
selector.add_row(data);
}
void tpreferences::add_tab(tlistbox& tab_bar, const std::string& label)
{
std::map<std::string, string_map> data;
data["tab_label"]["label"] = label;
tab_bar.add_row(data);
}
void tpreferences::initialize_tabs(twindow& /*window*/, tlistbox& selector, const int index)
{
//
// MULTIPLAYER TABS
//
if(index == 4) {
add_tab(selector, _("Prefs tab^General"));
add_tab(selector, _("Prefs tab^Friends"));
}
#ifdef GUI2_EXPERIMENTAL_LISTBOX
connect_signal_notify_modified(selector, std::bind(
&tpreferences::on_tab_select,
@ -1143,13 +1123,6 @@ void tpreferences::pre_show(twindow& window)
#endif
window.keyboard_capture(&selector);
add_pager_row(selector, "general.png", _("Prefs section^General"));
add_pager_row(selector, "hotkeys.png", _("Prefs section^Hotkeys"));
add_pager_row(selector, "display.png", _("Prefs section^Display"));
add_pager_row(selector, "music.png", _("Prefs section^Sound"));
add_pager_row(selector, "multiplayer.png", _("Prefs section^Multiplayer"));
add_pager_row(selector, "advanced.png", _("Prefs section^Advanced"));
// Initializes initial values and sets up callbacks. This needs to be
// done before selecting the initial page, otherwise widgets from other
// pages cannot be found afterwards.

View file

@ -82,8 +82,6 @@ private:
void remove_friend_list_entry(tlistbox& friends_list,
ttext_box& textbox, twindow& window);
void add_tab(tlistbox& tab_bar, const std::string& label);
void add_pager_row(tlistbox& selector, const std::string& icon, const std::string& label);
void set_visible_page(twindow& window, unsigned int page, const std::string& pager_id);
/** Callback for selection changes */