Allow changing theme while in a game

This commit is contained in:
Celtic Minstrel 2017-04-24 09:46:35 -04:00
parent b6212132a2
commit b9a35fa870
5 changed files with 16 additions and 19 deletions

View file

@ -27,6 +27,7 @@ Version 1.13.7+dev:
* Improved Hotkey category sorting interface in Preferences.
* Improved Addon Manager and MP Staging interfaces at low resolutions.
* Fixed bug that allows you to use the minimap to bypass view locking
* You can now change the theme (in preferences) while a game is in progress.
* WML Engine:
* Add base_income key to [store_side]
* Fix issues with alpha animations on hidden units (#14503)

View file

@ -55,23 +55,6 @@
[/row]
[row]
grow_factor = 0
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[label]
definition = "default"
label = _ "The new theme will take effect after loading or starting a new game."
wrap = true
[/label]
[/column]
[/row]
[row]
grow_factor = 1

View file

@ -255,6 +255,13 @@ display::~display()
resources::fake_units = nullptr;
}
void display::set_theme(config theme_cfg) {
theme_ = theme(theme_cfg, screen_area());
menu_buttons_.clear();
action_buttons_.clear();
create_buttons();
invalidate_theme();
}
void display::init_flags() {

View file

@ -375,6 +375,7 @@ public:
void clear_redraw_observers();
theme& get_theme() { return theme_; }
void set_theme(config theme_cfg);
/**
* Retrieves a pointer to a theme UI button.

View file

@ -34,6 +34,10 @@
#include "gui/dialogs/transient_message.hpp"
#include "gui/widgets/window.hpp"
#include "log.hpp"
#include "play_controller.hpp"
#include "game_display.hpp"
#include "game_config_manager.hpp"
#include "resources.hpp"
#include <boost/math/common_factor_rt.hpp>
@ -120,9 +124,10 @@ bool show_theme_dialog(CVideo& video)
const int action = dlg.selected_index();
if (action >= 0) {
// FIXME: it would be preferable for the new theme to take effect
// immediately.
preferences::set_theme(themes[action].id);
if(resources::screen && resources::controller) {
resources::screen->set_theme(resources::controller->get_theme(game_config_manager::get()->game_config(), themes[action].id));
}
return true;
}