mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-15 09:02:30 +00:00
Hotkey/Command Executor: removed get_video() member in favor of singleton
Also removed CVideo reference passed to make_screenshot() and its argument function, since the reference is only used in the one specific screenshot() function anyway.
This commit is contained in:
parent
e0cebdd402
commit
9b988f27f7
@ -43,13 +43,13 @@ static lg::log_domain log_config("config");
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
bool screenshot(const std::string& filename, CVideo& video)
|
bool screenshot(const std::string& filename)
|
||||||
{
|
{
|
||||||
return image::save_image(video.getSurface(), filename);
|
return image::save_image(CVideo::get_singleton().getSurface(), filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename TFunc>
|
template<typename TFunc>
|
||||||
void make_screenshot(const std::string& name, CVideo& video, const TFunc& func)
|
void make_screenshot(const std::string& name, const TFunc& func)
|
||||||
{
|
{
|
||||||
std::string filename = filesystem::get_screenshot_dir() + "/" + name + "_";
|
std::string filename = filesystem::get_screenshot_dir() + "/" + name + "_";
|
||||||
#ifdef HAVE_LIBPNG
|
#ifdef HAVE_LIBPNG
|
||||||
@ -58,7 +58,7 @@ void make_screenshot(const std::string& name, CVideo& video, const TFunc& func)
|
|||||||
const std::string ext = ".bmp";
|
const std::string ext = ".bmp";
|
||||||
#endif
|
#endif
|
||||||
filename = filesystem::get_next_filename(filename, ext);
|
filename = filesystem::get_next_filename(filename, ext);
|
||||||
const bool res = func(filename, video);
|
const bool res = func(filename);
|
||||||
if (res) {
|
if (res) {
|
||||||
gui2::dialogs::screenshot_notification::display(filename);
|
gui2::dialogs::screenshot_notification::display(filename);
|
||||||
} else {
|
} else {
|
||||||
@ -561,10 +561,10 @@ void execute_command(const hotkey_command& command, command_executor* executor,
|
|||||||
executor->recalculate_minimap();
|
executor->recalculate_minimap();
|
||||||
break;
|
break;
|
||||||
case HOTKEY_FULLSCREEN:
|
case HOTKEY_FULLSCREEN:
|
||||||
executor->get_video().toggle_fullscreen();
|
CVideo::get_singleton().toggle_fullscreen();
|
||||||
break;
|
break;
|
||||||
case HOTKEY_SCREENSHOT:
|
case HOTKEY_SCREENSHOT:
|
||||||
make_screenshot(_("Screenshot"), executor->get_video(), &::screenshot);
|
make_screenshot(_("Screenshot"), &::screenshot);
|
||||||
break;
|
break;
|
||||||
case HOTKEY_ANIMATE_MAP:
|
case HOTKEY_ANIMATE_MAP:
|
||||||
preferences::set_animate_map(!preferences::animate_map());
|
preferences::set_animate_map(!preferences::animate_map());
|
||||||
@ -669,11 +669,6 @@ void command_executor_default::recalculate_minimap()
|
|||||||
get_display().recalculate_minimap();
|
get_display().recalculate_minimap();
|
||||||
}
|
}
|
||||||
|
|
||||||
CVideo& command_executor_default::get_video()
|
|
||||||
{
|
|
||||||
return get_display().video();
|
|
||||||
}
|
|
||||||
|
|
||||||
void command_executor_default::lua_console()
|
void command_executor_default::lua_console()
|
||||||
{
|
{
|
||||||
if (get_display().in_game()) {
|
if (get_display().in_game()) {
|
||||||
@ -712,9 +707,7 @@ void command_executor_default::zoom_default()
|
|||||||
|
|
||||||
void command_executor_default::map_screenshot()
|
void command_executor_default::map_screenshot()
|
||||||
{
|
{
|
||||||
make_screenshot(_("Map-Screenshot"), get_video(),
|
make_screenshot(_("Map-Screenshot"), [this](const std::string& filename) {
|
||||||
[this](const std::string& filename, const CVideo&)
|
|
||||||
{
|
|
||||||
return get_display().screenshot(filename, true);
|
return get_display().screenshot(filename, true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,6 @@ public:
|
|||||||
|
|
||||||
virtual void set_button_state() {}
|
virtual void set_button_state() {}
|
||||||
virtual void recalculate_minimap() {}
|
virtual void recalculate_minimap() {}
|
||||||
virtual CVideo& get_video() = 0;
|
|
||||||
|
|
||||||
// execute_command's parameter is changed to "hotkey_command& command" and this not maybe that is too inconsitent.
|
// execute_command's parameter is changed to "hotkey_command& command" and this not maybe that is too inconsitent.
|
||||||
// Gets the action's image (if any). Displayed left of the action text in menus.
|
// Gets the action's image (if any). Displayed left of the action text in menus.
|
||||||
@ -142,7 +141,6 @@ class command_executor_default : public command_executor
|
|||||||
protected:
|
protected:
|
||||||
virtual display& get_display() = 0;
|
virtual display& get_display() = 0;
|
||||||
public:
|
public:
|
||||||
CVideo& get_video();
|
|
||||||
void set_button_state();
|
void set_button_state();
|
||||||
void recalculate_minimap();
|
void recalculate_minimap();
|
||||||
void lua_console();
|
void lua_console();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user