Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add "advanced graphics" preference dialog, for scaling algo options
This commit also gives the smart enums in src/make_enum.hpp introspective capabilities, by giving them a static const size_t which tells how many possible values they may take (hence the range of the enum.) It was convenient for the dialog implementation to have this. Note that, I had to make use of __attribute__((unused)) to compile this. I apply this using a macro which adds it for gcc, clang, and mingw which I know respond to this attribute. I don't know what is the equivalent MSVC device, or if it is even necessary, so its possible that this commit needs to be fixed up. We also disable unit tests for the new advanced graphics dialog, there are no tests for it right now...
- Loading branch information
Showing
9 changed files
with
423 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
#textdomain wesnoth-lib | ||
|
||
#define _GUI_COLUMN_LABEL LABEL TOOLTIP | ||
[row] | ||
grow_factor=0 | ||
[column] | ||
grow_factor = 1 | ||
border = "all" | ||
border_size = 5 | ||
horizontal_alignment = "left" | ||
|
||
[label] | ||
definition = "default" | ||
label = {LABEL} | ||
tooltip = {TOOLTIP} | ||
[/label] | ||
[/column] | ||
[/row] | ||
#enddef | ||
|
||
#define _GUI_SCALE_OPTION ID LABEL TOOLTIP | ||
[row] | ||
grow_factor=0 | ||
[column] | ||
grow_factor = 1 | ||
border = "all" | ||
border_size = 5 | ||
horizontal_alignment = "left" | ||
|
||
[toggle_button] | ||
id = "scale_"+{ID} | ||
definition = "radio" | ||
label = {LABEL} | ||
tooltip = {TOOLTIP} | ||
[/toggle_button] | ||
[/column] | ||
[/row] | ||
#enddef | ||
|
||
|
||
#define _GUI_SCALE_ALGO_OPTIONS CASE | ||
{_GUI_SCALE_OPTION ({CASE}+"_linear") _"Linear" _"Bilinear intepolation scaling (legacy wesnoth option)"} | ||
{_GUI_SCALE_OPTION ({CASE}+"_nn") _"Nearest Neighbor" _"Nearest Neighbor scaling (fastest)"} | ||
{_GUI_SCALE_OPTION ({CASE}+"_xbrzlin") _"xBRZ + linear" _"xBRZ followed by Bilinear interpolation"} | ||
{_GUI_SCALE_OPTION ({CASE}+"_xbrznn") _"xBRZ + NN" _"xBRZ followed by Nearest Neighbor (recommended)"} | ||
#enddef | ||
|
||
#define _GUI_SCALE_CHOICE CASE LABEL TOOLTIP | ||
[grid] | ||
{_GUI_COLUMN_LABEL {LABEL} {TOOLTIP}} | ||
{_GUI_SCALE_ALGO_OPTIONS {CASE}} | ||
[/grid] | ||
#enddef | ||
|
||
[window] | ||
id = "advanced_graphics_options" | ||
description = "Advanced options to control what image processing algorithms are used." | ||
|
||
[resolution] | ||
definition = "default" | ||
|
||
#click_dismiss = "true" | ||
maximum_width = 800 | ||
|
||
automatic_placement = "true" | ||
vertical_placement = "center" | ||
horizontal_placement = "center" | ||
|
||
[linked_group] | ||
id = "algorithm" | ||
fixed_width = "true" | ||
[/linked_group] | ||
|
||
[tooltip] | ||
id = "tooltip_large" | ||
[/tooltip] | ||
|
||
[helptip] | ||
id = "tooltip_large" | ||
[/helptip] | ||
|
||
[grid] | ||
[row] | ||
|
||
[column] | ||
border = "all" | ||
border_size = 5 | ||
horizontal_alignment = "left" | ||
[label] | ||
definition = "title" | ||
label = _ "Advanced Graphics Options" | ||
[/label] | ||
[/column] | ||
|
||
[/row] | ||
|
||
[row] | ||
grow_factor = 0 | ||
|
||
[column] | ||
border = "all" | ||
border_size = 5 | ||
horizontal_alignment = "left" | ||
|
||
[label] | ||
definition = "default" | ||
label = _ "Images will be scaled using the following algorithms:" | ||
wrap = "true" | ||
[/label] | ||
[/column] | ||
|
||
[/row] | ||
|
||
[row] | ||
grow_factor = 0 | ||
|
||
[column] | ||
[grid] | ||
[row] | ||
grow_factor = 0 | ||
[column] | ||
horizontal_grow = "true" | ||
vertical_grow = "true" | ||
|
||
border = "top" | ||
border_size = 5 | ||
|
||
{_GUI_SCALE_CHOICE zoom _"Scaled to zoom" _"All units, haloes, border hexes"} | ||
[/column] | ||
|
||
|
||
[column] | ||
horizontal_grow = "true" | ||
vertical_grow = "true" | ||
|
||
border = "top" | ||
border_size = 5 | ||
|
||
{_GUI_SCALE_CHOICE hex _"Scaled to hex" _"Everything else"} | ||
[/column] | ||
[/row] | ||
[/grid] | ||
[/column] | ||
[/row] | ||
|
||
[row] | ||
grow_factor = 0 | ||
|
||
[column] | ||
horizontal_alignment = "right" | ||
|
||
[grid] | ||
|
||
[row] | ||
grow_factor = 0 | ||
|
||
[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] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/* | ||
Copyright (C) 2014 by Chris Beck <render787@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/advanced_graphics_options.hpp" | ||
|
||
#include "desktop/notifications.hpp" | ||
#include "gui/auxiliary/find_widget.tpp" | ||
#include "gui/dialogs/message.hpp" | ||
#include "gui/widgets/button.hpp" | ||
#include "gui/widgets/label.hpp" | ||
#include "gui/widgets/settings.hpp" | ||
#include "gui/widgets/toggle_button.hpp" | ||
#include "gui/widgets/window.hpp" | ||
|
||
#include "preferences.hpp" | ||
#include "formula_string_utils.hpp" | ||
|
||
#include <boost/bind.hpp> | ||
#include <boost/foreach.hpp> | ||
#include <boost/assign/list_of.hpp> | ||
|
||
#include "gettext.hpp" | ||
|
||
namespace gui2 | ||
{ | ||
|
||
/*WIKI | ||
* @page = GUIWindowDefinitionWML | ||
* @order = 2_mp_alerts_options | ||
* | ||
* == Lobby sounds options == | ||
* | ||
* A Preferences subdialog permitting to configure the sounds and notifications | ||
* generated in response to various mp lobby / game events. | ||
* | ||
* @begin{table}{dialog_widgets} | ||
* | ||
* _label & & label & m & | ||
* Item name. $ | ||
* | ||
* _sound & & toggle_button & m & | ||
* Toggles whether to play the item sound. $ | ||
* | ||
* _notif & & toggle_button & m & | ||
* Toggles whether to give a notification. $ | ||
* | ||
* _lobby & & toggle_button & m & | ||
* Toggles whether to take actions for this item when in the lobby. $ | ||
* | ||
* @end{table} | ||
*/ | ||
|
||
REGISTER_DIALOG(advanced_graphics_options) | ||
|
||
const std::vector<std::string> tadvanced_graphics_options::scale_cases = boost::assign::list_of("zoom")("hex"); | ||
|
||
void tadvanced_graphics_options::setup_scale_button(const std::string & case_id, SCALING_ALGORITHM button, twindow & window ) | ||
{ | ||
std::string pref_id = "scale_" + case_id; | ||
|
||
tadvanced_graphics_options::SCALING_ALGORITHM algo = tadvanced_graphics_options::LINEAR; | ||
try { | ||
algo = string_to_SCALING_ALGORITHM(preferences::get(pref_id)); | ||
} catch (bad_enum_cast &) { | ||
preferences::set(pref_id, SCALING_ALGORITHM_to_string(algo)); | ||
} | ||
|
||
// algo is now synced with preference, and default value of linear if something went wrong | ||
|
||
ttoggle_button * b = &find_widget<ttoggle_button>(&window, pref_id + "_" + SCALING_ALGORITHM_to_string(button), false); | ||
b->set_value(algo == button); | ||
|
||
connect_signal_mouse_left_click(*b, boost::bind(&tadvanced_graphics_options::scale_button_callback, this, pref_id, button, boost::ref(window))); | ||
} | ||
|
||
void tadvanced_graphics_options::scale_button_callback(std::string pref_id, SCALING_ALGORITHM me, twindow & window) | ||
{ | ||
preferences::set(pref_id, SCALING_ALGORITHM_to_string(me)); | ||
|
||
for (size_t x = 0; x < SCALING_ALGORITHM_COUNT; ++x) { | ||
ttoggle_button * b = &find_widget<ttoggle_button>(&window, pref_id + "_" + SCALING_ALGORITHM_to_string(static_cast<SCALING_ALGORITHM>(x)), false); | ||
b->set_value(x == me); | ||
} | ||
} | ||
|
||
void tadvanced_graphics_options::setup_scale_case(const std::string & i, twindow & window) | ||
{ | ||
for (size_t x = 0; x < SCALING_ALGORITHM_COUNT; ++x) { | ||
setup_scale_button(i, static_cast<SCALING_ALGORITHM>(x), window); | ||
} | ||
} | ||
|
||
tadvanced_graphics_options::tadvanced_graphics_options() | ||
{ | ||
} | ||
|
||
void tadvanced_graphics_options::pre_show(CVideo& /*video*/, twindow& window) | ||
{ | ||
BOOST_FOREACH(const std::string & i, scale_cases) { | ||
setup_scale_case(i, window); | ||
} | ||
|
||
/* | ||
tbutton * defaults; | ||
defaults = &find_widget<tbutton>(&window,"revert_to_defaults", false); | ||
connect_signal_mouse_left_click(*defaults, boost::bind(&revert_to_default_pref_values, boost::ref(window))); | ||
*/ | ||
} | ||
|
||
void tadvanced_graphics_options::post_show(twindow& /*window*/) | ||
{ | ||
} | ||
|
||
} // end namespace gui2 |
Oops, something went wrong.