gui2/tpreferences: initial layout

This commit is contained in:
Ignacio R. Morelle 2015-07-10 17:28:19 +11:00 committed by Charles Dang
parent b4aa768fc8
commit 677e7077ae
12 changed files with 1449 additions and 0 deletions

View file

@ -0,0 +1,250 @@
#textdomain wesnoth-lib
###
### Main game preferences dialog.
###
#define _GUI_PREFS_PLACEHOLDER PAGE_NUM
[row]
[column]
grow_factor = 1
horizontal_grow = "true"
border = "all"
border_size = 5
[label]
id = "page{PAGE_NUM}_label1"
definition = "default"
label = "This is page #{PAGE_NUM}."
[/label]
[/column]
[/row]
[row]
[column]
border = "all"
border_size = 5
horizontal_alignment = "right"
[button]
id = "button{PAGE_NUM}"
definition = "default"
label = "Button {PAGE_NUM}"
tooltip = "This is the page #{PAGE_NUM} button — you know you want to push it"
[/button]
[/column]
[/row]
#enddef
#define _GUI_PREFS_PAGE1_CONTENTS
{_GUI_PREFS_PLACEHOLDER (1)}
#enddef
#define _GUI_PREFS_PAGE2_CONTENTS
{_GUI_PREFS_PLACEHOLDER (2)}
#enddef
#define _GUI_PREFS_PAGE3_CONTENTS
{_GUI_PREFS_PLACEHOLDER (3)}
#enddef
#define _GUI_PREFS_PAGE4_CONTENTS
{_GUI_PREFS_PLACEHOLDER (4)}
#enddef
#define _GUI_PREFS_PAGE5_CONTENTS
{_GUI_PREFS_PLACEHOLDER (5)}
#enddef
#define _GUI_PREFS_PAGE PAGE_NUM
[layer]
id = "page{PAGE_NUM}"
{_GUI_PREFS_PAGE{PAGE_NUM}_CONTENTS}
[/layer]
#enddef
[window]
id = "preferences"
description = "Main game preferences dialog."
[resolution]
definition = "default"
automatic_placement = "true"
vertical_placement = "center"
horizontal_placement = "center"
maximum_width = 800
maximum_height = 600
[linked_group]
id = "page_icon"
fixed_width = "true"
[/linked_group]
[linked_group]
id = "page_label"
fixed_width = "true"
[/linked_group]
[tooltip]
id = "tooltip_large"
[/tooltip]
[helptip]
id = "tooltip_large"
[/helptip]
[grid]
[row]
grow_factor = 0
[column]
grow_factor = 1
border = "all"
border_size = 5
horizontal_alignment = "left"
[label]
id = "title"
definition = "title"
label = _ "Preferences Mk. II"
[/label]
[/column]
{GUI_FILLER}
[/row]
[row]
grow_factor = 1
[column]
grow_factor = 1
horizontal_grow = "true"
vertical_grow = "true"
border = "all"
border_size = 5
[listbox]
id = "selector"
definition = "default"
[list_definition]
[row]
[column]
vertical_grow = "true"
horizontal_grow = "true"
[toggle_panel]
definition = "default"
[grid]
[row]
[column]
grow_factor = 0
horizontal_alignment = "left"
border = "all"
border_size = 5
[image]
id = "icon"
definition = "default"
linked_group = "page_icon"
[/image]
[/column]
[column]
grow_factor = 1
horizontal_grow = "true"
border = "all"
border_size = 5
[label]
id = "label"
definition = "default"
linked_group = "page_label"
[/label]
[/column]
[column]
#
# Some icons aren't actually 72px tall, so enforce some
# consistency with an invisible spacer.
#
[spacer]
width = 0
height = 72
[/spacer]
[/column]
[/row]
[/grid]
[/toggle_panel]
[/column]
[/row]
[/list_definition]
[/listbox]
[/column]
[column]
grow_factor = 1
horizontal_grow = "true"
vertical_grow = "true"
[stacked_widget]
id = "pager"
definition = "default"
[stack]
{./preferences}
[/stack]
[/stacked_widget]
[/column]
[/row]
[row]
{GUI_FILLER}
[column]
horizontal_alignment = "right"
[grid]
[row]
grow_factor = 0
{GUI_FILLER}
[column]
border = "all"
border_size = 5
horizontal_alignment = "right"
[button]
id = "ok"
definition = "default"
label = _ "Close"
[/button]
[/column]
[/row]
[/grid]
[/column]
[/row]
[/grid]
[/resolution]
[/window]
#undef _GUI_PREFS_PLACEHOLDER
#undef _GUI_PREFS_PAGE1
#undef _GUI_PREFS_PAGE2
#undef _GUI_PREFS_PAGE3
#undef _GUI_PREFS_PAGE4
#undef _GUI_PREFS_PAGE5
#undef _GUI_PREFS_PAGE

View file

@ -0,0 +1,299 @@
#textdomain wesnoth-lib
###
### Preferences dialog, General page
###
#define _GUI_PREFERENCES_MAIN_COMPOSITE_SLIDER _LABEL_ID _LABEL_TEXT _SLIDER_ID _SLIDER_ATTRIBUTES
[grid]
[row]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[label]
id = {_LABEL_ID}
definition = "default_small"
label = {_LABEL_TEXT}
[/label]
[/column]
[/row]
[row]
[column]
border = "all"
border_size = 5
horizontal_grow = true
[slider]
id = {_SLIDER_ID}
definition = "minimal"
{_SLIDER_ATTRIBUTES}
[/slider]
[/column]
[/row]
[/grid]
#enddef
#define _GUI_PREFERENCES_MAIN_GRID_1
[row]
[column]
horizontal_grow = true
[grid]
[row]
[column]
border = "all"
border_size = 5
[label]
label = _ "Scroll speed:"
[/label]
[/column]
[column]
horizontal_grow = true
border = "all"
border_size = 5
[slider]
id = "scroll_speed"
definition = "minimal"
minimum_value = 1
maximum_value = 100
step_size = 1
tooltip = _ "Change the speed of scrolling around the map"
[/slider]
[/column]
[/row]
[/grid]
[/column]
[/row]
[row]
[column]
horizontal_grow = true
[grid]
[row]
[column]
border = "top,left,right"
border_size = 5
horizontal_alignment = "left"
[toggle_button]
id = "turbo_toggle"
label = _ "Accelerated speed"
tooltip = _ "Make units move and fight faster"
[/toggle_button]
[/column]
[column]
border = "top,left,right"
border_size = 5
horizontal_alignment = "left"
[toggle_button]
id = "skip_ai_moves"
label = _ "Skip AI moves"
tooltip = _ "Do not animate AI units moving"
[/toggle_button]
[/column]
[/row]
[/grid]
[/column]
[/row]
[row]
[column]
horizontal_grow = true
{_GUI_PREFERENCES_CHECKBOX_ALIGN_BORDER}
{_GUI_PREFERENCES_MAIN_COMPOSITE_SLIDER
turbo_value ( _ "Speed: $value")
turbo_slider (
minimum_value,maximum_value=0,11
step_size=1
tooltip= _ "Units move and fight speed"
)
}
[/column]
[/row]
{_GUI_PREFERENCES_SPACER_ROW}
[row]
[column]
border = "top,left,right"
border_size = 5
horizontal_alignment = "left"
[toggle_button]
id = "disable_auto_moves"
label = _ "Disable automatic moves"
tooltip = _ "Do not allow automatic movements at the beginning of a turn"
[/toggle_button]
[/column]
[/row]
[row]
[column]
border = "top,left,right"
border_size = 5
horizontal_alignment = "left"
[toggle_button]
id = "show_turn_dialog"
label = _ "Turn dialog"
tooltip = _ "Display a dialog at the beginning of your turn"
[/toggle_button]
[/column]
[/row]
[row]
[column]
border = "top,left,right"
border_size = 5
horizontal_alignment = "left"
[toggle_button]
id = "whiteboard_on_start"
label = _ "Enable planning mode on start"
tooltip = _ "Activates Planning Mode on game start"
[/toggle_button]
[/column]
[/row]
[row]
[column]
border = "top,left,right"
border_size = 5
horizontal_alignment = "left"
[toggle_button]
id = "whiteboard_hide_allies"
label = _ "Hide allies plans by default"
tooltip = _ "Hide allies Planning Mode plans in multiplayer games"
[/toggle_button]
[/column]
[/row]
[row]
[column]
border = "top,left,right"
border_size = 5
horizontal_alignment = "left"
[toggle_button]
id = "interrupt_move_when_ally_sighted"
label = _ "Interrupt move when an ally is sighted"
tooltip = _ "Sighting an allied unit interrupts your units movement"
[/toggle_button]
[/column]
[/row]
{_GUI_PREFERENCES_SPACER_ROW}
[row]
[column]
border = "top,left,right"
border_size = 5
horizontal_alignment = "left"
[toggle_button]
id = "save_replays"
label = _ "Save replays at the end of scenarios"
tooltip = _ "Save replays of games on victory in all modes and defeat in multiplayer"
[/toggle_button]
[/column]
[/row]
[row]
[column]
border = "top,left,right"
border_size = 5
horizontal_alignment = "left"
[toggle_button]
id = "delete_saves"
label = _ "Delete auto-saves at the end of scenarios"
tooltip = _ "Delete previous auto-saves on victory in all modes and defeat in multiplayer"
[/toggle_button]
[/column]
[/row]
[row]
[column]
horizontal_grow = true
{_GUI_PREFERENCES_CHECKBOX_ALIGN_BORDER}
{_GUI_PREFERENCES_MAIN_COMPOSITE_SLIDER
max_saves_value ( _ "Maximum auto-saves: $value")
max_saves_slider (
minimum_value,maximum_value=0,61
step_size=1
tooltip= _ "Set maximum number of automatic saves to be retained"
)
}
[/column]
[/row]
#enddef
#define _GUI_PREFERENCES_MAIN_GRID_2
[row]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[button]
id = hotkeys
label = _ "Hotkeys"
[/button]
[/column]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[button]
id = cachemg
label = _ "Cache"
[/button]
[/column]
[/row]
#enddef
[layer]
[row]
[column]
horizontal_grow = true
vertical_grow = true
[grid]
[row]
[column]
horizontal_alignment = "left"
vertical_alignment = "top"
[grid]
{_GUI_PREFERENCES_MAIN_GRID_1}
[/grid]
[/column]
[/row]
[row]
[column]
horizontal_alignment = "left"
vertical_alignment = "bottom"
[grid]
{_GUI_PREFERENCES_MAIN_GRID_2}
[/grid]
[/column]
[/row]
[/grid]
[/column]
[/row]
[/layer]
#undef _GUI_PREFERENCES_MAIN_GRID_1
#undef _GUI_PREFERENCES_MAIN_GRID_2

View file

@ -0,0 +1,283 @@
#textdomain wesnoth-lib
###
### Preferences dialog, Display page
###
#define _GUI_PREFERENCES_DISPLAY_GRID_1
[row]
[column]
horizontal_alignment = "left"
[grid]
[row]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[label]
label = _ "Resolution:"
[/label]
[/column]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[scroll_label]
id = "resolution"
definition = "description"
label = "1920x1080"
[/scroll_label]
[/column]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[button]
id = "resolution_set"
label = _ "display_resolution^Change"
[/button]
[/column]
[/row]
[row]
{GUI_FILLER}
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[toggle_button]
id = "fullscreen"
label = _ "Full screen"
[/toggle_button]
[/column]
{GUI_FILLER}
[/row]
[/grid]
[/column]
[/row]
{_GUI_PREFERENCES_SPACER_ROW}
[row]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[toggle_button]
id = "show_floating_labels"
label = _ "Show floating labels"
[/toggle_button]
[/column]
[/row]
[row]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[toggle_button]
id = "show_halos"
label = _ "Show haloing effects"
[/toggle_button]
[/column]
[/row]
[row]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[toggle_button]
id = "show_ellipses"
label = _ "Show team colors"
[/toggle_button]
[/column]
[/row]
{_GUI_PREFERENCES_SPACER_ROW}
[row]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[toggle_button]
id = "show_grid"
label = _ "Show grid"
[/toggle_button]
[/column]
[/row]
{_GUI_PREFERENCES_SPACER_ROW}
[row]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[toggle_button]
id = "animate_terrains"
label = _ "Animate map"
[/toggle_button]
[/column]
[/row]
[row]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[toggle_button]
id = "animate_units_standing"
label = _ "Show unit standing animations"
[/toggle_button]
[/column]
[/row]
[row]
[column]
horizontal_grow = "true"
[grid]
[row]
[column]
border = "top,left,right"
border_size = 5
horizontal_alignment = "left"
[toggle_button]
id = "animate_units_idle"
label = _ "Show unit idle animations"
[/toggle_button]
[/column]
[/row]
[row]
[column]
horizontal_grow = true
[grid]
[row]
[column]
{_GUI_PREFERENCES_CHECKBOX_ALIGN_SPACER}
[/column]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[label]
definition = "default_small"
label = _ "Frequency:"
[/label]
[/column]
[column]
border = "all"
border_size = 5
[slider]
id = "idle_anim_frequency"
definition = "minimal"
minimum_value = -40
maximum_value = 30
step_size = 1
tooltip = _ "Set the frequency of unit idle animations"
[/slider]
[/column]
[/row]
[/grid]
[/column]
[/row]
[/grid]
[/column]
[/row]
#enddef
#define _GUI_PREFERENCES_DISPLAY_GRID_2
[row]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[button]
id = choose_theme
label = _ "Theme"
[/button]
[/column]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[button]
id = orbs_setup
label = _ "Colors"
[/button]
[/column]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[button]
id = disp_advanced
label = _ "Advanced"
[/button]
[/column]
[/row]
#enddef
[layer]
[row]
[column]
horizontal_grow = true
vertical_grow = true
[grid]
[row]
[column]
horizontal_alignment = "left"
vertical_alignment = "top"
[grid]
{_GUI_PREFERENCES_DISPLAY_GRID_1}
[/grid]
[/column]
[/row]
[row]
[column]
horizontal_alignment = "left"
vertical_alignment = "bottom"
[grid]
{_GUI_PREFERENCES_DISPLAY_GRID_2}
[/grid]
[/column]
[/row]
[/grid]
[/column]
[/row]
[/layer]
#undef _GUI_PREFERENCES_DISPLAY_GRID_1
#undef _GUI_PREFERENCES_DISPLAY_GRID_2

View file

@ -0,0 +1,156 @@
#textdomain wesnoth-lib
###
### Preferences dialog, Sound page
###
#define _GUI_SOUND_SLIDER_CONTROL _TOGGLE_ID _TOGGLE_LABEL _TOGGLE_TOOLTIP _SLIDER_ID _SLIDER_TOOLTIP
[grid]
[row]
[column]
border = "top,left,right"
border_size = 5
horizontal_alignment = "left"
[toggle_button]
id = {_TOGGLE_ID}
label = {_TOGGLE_LABEL}
tooltip = {_TOGGLE_TOOLTIP}
[/toggle_button]
[/column]
[/row]
[row]
[column]
horizontal_grow = true
[grid]
[row]
[column]
{_GUI_PREFERENCES_CHECKBOX_ALIGN_SPACER}
[/column]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[label]
definition = "default_small"
label = _ "Volume:"
[/label]
[/column]
[column]
border = "all"
border_size = 5
horizontal_grow = true
[slider]
id = {_SLIDER_ID}
definition = "minimal"
minimum_value = 0
maximum_value = 128
step_size = 1
tooltip = {_SLIDER_TOOLTIP}
[/slider]
[/column]
[/row]
[/grid]
[/column]
[/row]
[/grid]
#enddef
#define _GUI_PREFERENCES_SOUND_GRID_1
[row]
[column]
horizontal_grow = true
vertical_alignment = "top"
{_GUI_SOUND_SLIDER_CONTROL
sound_toggle_sfx ( _ "Sound effects") ( _ "Sound effects on/off")
sound_volume_sfx ( _ "Change the sound effects volume")
}
[/column]
[/row]
[row]
[column]
horizontal_grow = true
vertical_alignment = "top"
{_GUI_SOUND_SLIDER_CONTROL
sound_toggle_music ( _ "Music") ( _ "Music on/off")
sound_volume_music ( _ "Change the music volume")
}
[/column]
[/row]
[row]
[column]
horizontal_grow = true
{_GUI_SOUND_SLIDER_CONTROL
sound_toggle_bell ( _ "Turn bell") ( _ "Play a bell sound at the beginning of your turn")
sound_volume_bell ( _ "Change the bell volume")
}
[/column]
[/row]
[row]
[column]
horizontal_grow = true
{_GUI_SOUND_SLIDER_CONTROL
sound_toggle_uisfx ( _ "User interface sounds") ( _ "Turn menu and button sopunds on/off")
sound_volume_uisfx ( _ "Change the sound volume for buttom clicks, etc.")
}
[/column]
[/row]
#enddef
#define _GUI_PREFERENCES_SOUND_GRID_2
[row]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[button]
id = sound_advanced
label = _ "Advanced"
[/button]
[/column]
[/row]
#enddef
[layer]
[row]
[column]
horizontal_grow = true
vertical_grow = true
[grid]
[row]
[column]
horizontal_alignment = "left"
vertical_alignment = "top"
[grid]
{_GUI_PREFERENCES_SOUND_GRID_1}
[/grid]
[/column]
[/row]
[row]
[column]
horizontal_alignment = "left"
vertical_alignment = "bottom"
[grid]
{_GUI_PREFERENCES_SOUND_GRID_2}
[/grid]
[/column]
[/row]
[/grid]
[/column]
[/row]
[/layer]
#undef _GUI_PREFERENCES_SOUND_GRID_1
#undef _GUI_PREFERENCES_SOUND_GRID_2
#undef _GUI_SOUND_SLIDER_CONTROL

View file

@ -0,0 +1,219 @@
#textdomain wesnoth-lib
###
### Preferences dialog, Multiplayer page
###
#define _GUI_PREFERENCES_MP_GRID_1
[row]
[column]
horizontal_grow = true
[grid]
[row]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[label]
label = _ "Chat lines:"
[/label]
[/column]
[column]
border = "all"
border_size = 5
horizontal_grow = true
[slider]
id = "chat_lines"
definition = "default"
minimum_value = 1
maximum_value = 20
step_size = 1
[/slider]
[/column]
[/row]
[/grid]
[/column]
[/row]
[row]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[toggle_button]
id = "chat_timestamps"
label = _ "Chat timestamping"
[/toggle_button]
[/column]
[/row]
{_GUI_PREFERENCES_SPACER_ROW}
[row]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[toggle_button]
id = "remember_password"
label = _ "Save password to preferences (plain text)"
[/toggle_button]
[/column]
[/row]
{_GUI_PREFERENCES_SPACER_ROW}
[row]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[toggle_button]
id = "lobby_sort_players"
label = _ "Sort lobby list"
tooltip= _ "Sort the player list in the lobby by player groups"
[/toggle_button]
[/column]
[/row]
[row]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[toggle_button]
id = "lobby_player_icons"
label = _ "Iconize lobby list"
tooltip= _ "Show icons in front of the player names in the lobby"
[/toggle_button]
[/column]
[/row]
{_GUI_PREFERENCES_SPACER_ROW}
[row]
[column]
border = "top,left,right"
border_size = 5
horizontal_alignment = "left"
[toggle_button]
id = "lobby_joins_none"
definition = "radio"
label = _ "Do not show lobby joins"
tooltip = _ "Do not show messages about players joining the multiplayer lobby"
[/toggle_button]
[/column]
[/row]
[row]
[column]
border = "top,left,right"
border_size = 5
horizontal_alignment = "left"
[toggle_button]
id = "lobby_joins_friends"
definition = "radio"
label = _ "Show lobby joins of friends only"
tooltip = _ "Show messages about your friends joining the multiplayer lobby"
[/toggle_button]
[/column]
[/row]
[row]
[column]
border = "top,left,right"
border_size = 5
horizontal_alignment = "left"
[toggle_button]
id = "lobby_joins_all"
definition = "radio"
label = _ "Show all lobby joins"
tooltip = _ "Show messages about all players joining the multiplayer lobby"
[/toggle_button]
[/column]
[/row]
#enddef
#define _GUI_PREFERENCES_MP_GRID_2
[row]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[button]
id = mp_friends
label = _ "Friends List"
[/button]
[/column]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[button]
id = mp_alerts
label = _ "Alerts"
[/button]
[/column]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[button]
id = mp_wesnothd
label = _ "Set Path to wesnothd"
[/button]
[/column]
[/row]
#enddef
[layer]
[row]
[column]
horizontal_grow = true
vertical_grow = true
[grid]
[row]
[column]
horizontal_grow = "true"
vertical_alignment = "top"
[grid]
{_GUI_PREFERENCES_MP_GRID_1}
[/grid]
[/column]
[/row]
[row]
[column]
horizontal_alignment = "left"
vertical_alignment = "bottom"
[grid]
{_GUI_PREFERENCES_MP_GRID_2}
[/grid]
[/column]
[/row]
[/grid]
[/column]
[/row]
[/layer]
#undef _GUI_PREFERENCES_MP_GRID_1
#undef _GUI_PREFERENCES_MP_GRID_2

View file

@ -0,0 +1,15 @@
#textdomain wesnoth-lib
###
### Preferences dialog, Advanced page
###
[layer]
[row]
[column]
[spacer][/spacer]
[/column]
[/row]
[/layer]

View file

@ -0,0 +1,3 @@
#undef _GUI_PREFERENCES_SPACER_ROW
#undef _GUI_PREFERENCES_CHECKBOX_ALIGN_SPACER

View file

@ -0,0 +1,27 @@
#textdomain wesnoth-lib
##
## Utility macros for the preferences dialog layout WML.
##
#define _GUI_PREFERENCES_SPACER_ROW
[row]
[column]
border = "all"
border_size = 5
[spacer][/spacer]
[/column]
[/row]
#enddef
#define _GUI_PREFERENCES_CHECKBOX_ALIGN_SPACER
[spacer]
width = 25
height = 20
[/spacer]
#enddef
#define _GUI_PREFERENCES_CHECKBOX_ALIGN_BORDER
border = "left" # FIXME: RTL
border_size = 25
#enddef

View file

@ -454,6 +454,7 @@ wesnoth_sources = Split("""
gui/dialogs/mp_login.cpp
gui/dialogs/mp_method_selection.cpp
gui/dialogs/network_transmission.cpp
gui/dialogs/preferences_dialog.cpp
gui/dialogs/popup.cpp
gui/dialogs/edit_text.cpp
gui/dialogs/screenshot_notification.cpp

View file

@ -21,12 +21,14 @@
#include "filechooser.hpp"
#include "game_preferences.hpp"
#include "gettext.hpp"
#include "gui/dialogs/preferences_dialog.hpp"
#include "gui/dialogs/advanced_graphics_options.hpp"
#include "gui/dialogs/game_cache_options.hpp"
#include "gui/dialogs/mp_alerts_options.hpp"
#include "gui/dialogs/simple_item_selector.hpp"
#include "gui/dialogs/theme_list.hpp"
#include "gui/dialogs/transient_message.hpp"
#include "gui/widgets/settings.hpp"
#include "lobby_preferences.hpp"
#include "marked-up_text.hpp"
#include "preferences_display.hpp"
@ -1684,6 +1686,12 @@ void preferences_dialog::set_selection(int index)
void show_preferences_dialog(CVideo& video, const config& game_cfg)
{
if(true/*gui2::new_widgets*/) {
gui2::tpreferences dlg;
dlg.show(disp.video());
return;
}
std::vector<std::string> items;
std::string const pre = IMAGE_PREFIX + std::string("icons/icon-");

View file

@ -0,0 +1,120 @@
/*
Copyright (C) 2011, 2015 by Ignacio Riquelme Morelle <shadowm2006@gmail.com>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#define GETTEXT_DOMAIN "wesnoth-lib"
#include "gui/dialogs/preferences_dialog.hpp"
#include "formatter.hpp"
#include "gui/dialogs/helper.hpp"
#include "gui/auxiliary/find_widget.tpp"
#include "gui/widgets/button.hpp"
#include "gui/widgets/grid.hpp"
#ifdef GUI2_EXPERIMENTAL_LISTBOX
#include "gui/widgets/list.hpp"
#else
#include "gui/widgets/listbox.hpp"
#endif
#include "gui/widgets/settings.hpp"
#include "gui/widgets/stacked_widget.hpp"
#include "gui/widgets/window.hpp"
#include "gettext.hpp"
#include <boost/bind.hpp>
namespace {
//const unsigned int num_pages = 5;
}
namespace gui2 {
REGISTER_DIALOG(preferences)
tpreferences::tpreferences()
{
}
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::pre_show(CVideo& /*video*/, twindow& window)
{
tlistbox& selector = find_widget<tlistbox>(&window, "selector", false);
tstacked_widget& pager = find_widget<tstacked_widget>(&window, "pager", false);
#ifdef GUI2_EXPERIMENTAL_LISTBOX
connect_signal_notify_modified(selector, boost::bind(
&tpreferences::on_page_select
, this
, boost::ref(window)));
#else
selector.set_callback_value_change(dialog_callback
<tpreferences
, &tpreferences::on_page_select>);
#endif
window.keyboard_capture(&selector);
add_pager_row(selector, "general.png", _("Prefs section^General"));
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", _("Advanced section^Advanced"));
//
// We need to establish callbacks before selecting the initial page,
// otherwise widgets from other pages cannot be found afterwards.
//
#if 0
tbutton& test_button = find_widget<tbutton>(&window, "button1", false);
connect_signal_mouse_left_click(
test_button,
boost::bind(&tpreferences::button_test_callback,
this));
#endif
assert(selector.get_item_count() == pager.get_layer_count());
selector.select_row(0);
pager.select_layer(0);
}
void tpreferences::set_visible_page(twindow& window, unsigned int page)
{
tstacked_widget& pager = find_widget<tstacked_widget>(&window, "pager", false);
pager.select_layer(page);
}
void tpreferences::button_test_callback()
{
std::cerr << "hi from button1\n";
}
void tpreferences::on_page_select(twindow& window)
{
const int selected_row =
std::max(0, find_widget<tlistbox>(&window, "selector", false).get_selected_row());
set_visible_page(window, static_cast<unsigned int>(selected_row));
}
void tpreferences::post_show(twindow& /*window*/)
{
}
} // end namespace gui2

View file

@ -0,0 +1,68 @@
/*
Copyright (C) 2011, 2015 by Ignacio Riquelme Morelle <shadowm2006@gmail.com>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#ifndef GUI_DIALOGS_PREFERENCES_DIALOG_HPP_INCLUDED
#define GUI_DIALOGS_PREFERENCES_DIALOG_HPP_INCLUDED
#include "gui/dialogs/dialog.hpp"
// This file is not named preferences.hpp in order -I conflicts with
// src/preferences.hpp.
namespace gui2
{
class tpreferences : public tdialog
{
public:
/**
* Constructor.
*/
tpreferences();
/** The execute function -- see @ref tdialog for more information. */
//
// TODO: we want to get status info out in case it's necessary, e.g.
// to refresh the game display or stuff, hence this is execute() and
// not display(). But we probably should drop this later and force
// callers communicate with the dialog directly. Undecided. -- shadowm
//
static bool execute(CVideo& video)
{
tpreferences().show(video);
return true;
}
private:
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
/** Inherited from tdialog. */
void pre_show(CVideo& video, twindow& window);
/** Inherited from tdialog. */
void post_show(twindow& window);
void add_pager_row(class tlistbox& selector, const std::string& icon, const std::string& label);
void set_visible_page(twindow& window, unsigned int page);
/** Callback for page selection changes. */
void on_page_select(twindow& window);
void button_test_callback();
};
} // namespace gui2
#endif /* ! GUI_DIALOGS_PREFERENCES_DIALOG_HPP_INCLUDED */