/* * Gets where the next screenshot should be saved to. * Returns true if ready, false if user cancels */ BOOL get_screenshot_filename(TCHAR *ext) { StringCbCopy(screenshot_fn_backup, sizeof(screenshot_fn_backup), screenshot_file_name); if (screenshot_autosave) { /* do file save */ if (screenshot_use_increasing) { get_next_filename(ext); } } else { int index; if (_tcscmp(ext, pngext) == 0) { index = 2; } else { index = 1; } #ifdef _WINDOWS #ifndef _WINDLL if (SaveFile(screenshot_file_name, _T("Graphics Interchange Format (*.gif)\0*.gif\0Portable Network Graphics (*.png)\0*.png\0All Files (*.*)\0*.*\0\0"), _T("Wabbitemu Screenshot File Target"), ext, 0, index)) //if we cancel, mark the menu and set to idle return FALSE; #endif #endif } return TRUE; }
void execute_command(display& disp, const hotkey_command& command, command_executor* executor, int index) { const int zoom_amount = 4; bool map_screenshot = false; if (executor != NULL) { if (!executor->can_execute_command(command, index) || executor->execute_command(command, index)) { return; } } switch (command.id) { case HOTKEY_MINIMAP_DRAW_TERRAIN: preferences::toggle_minimap_draw_terrain(); disp.recalculate_minimap(); break; case HOTKEY_MINIMAP_CODING_TERRAIN: preferences::toggle_minimap_terrain_coding(); disp.recalculate_minimap(); break; case HOTKEY_MINIMAP_CODING_UNIT: preferences::toggle_minimap_movement_coding(); disp.recalculate_minimap(); break; case HOTKEY_MINIMAP_DRAW_UNITS: preferences::toggle_minimap_draw_units(); disp.redraw_minimap(); break; case HOTKEY_MINIMAP_DRAW_VILLAGES: preferences::toggle_minimap_draw_villages(); disp.recalculate_minimap(); break; case HOTKEY_ZOOM_IN: disp.set_zoom(zoom_amount); break; case HOTKEY_ZOOM_OUT: disp.set_zoom(-zoom_amount); break; case HOTKEY_ZOOM_DEFAULT: disp.set_default_zoom(); break; case HOTKEY_FULLSCREEN: preferences::set_fullscreen(!preferences::fullscreen()); break; case HOTKEY_MAP_SCREENSHOT: if (!disp.in_game() && !disp.in_editor()) { break; } map_screenshot = true; // intentional fall-through case HOTKEY_SCREENSHOT: { std::string name = map_screenshot ? _("Map-Screenshot") : _("Screenshot"); std::string filename = get_screenshot_dir() + "/" + name + "_"; filename = get_next_filename(filename, ".bmp"); int size = disp.screenshot(filename, map_screenshot); if (size > 0) { gui2::tscreenshot_notification::display(filename, size, disp.video()); } else { gui2::show_message(disp.video(), _("Screenshot Done"), ""); } break; } case HOTKEY_ANIMATE_MAP: preferences::set_animate_map(!preferences::animate_map()); break; case HOTKEY_MOUSE_SCROLL: preferences::enable_mouse_scroll(!preferences::mouse_scroll_enabled()); break; case HOTKEY_MUTE: { // look if both is not playing static struct before_muted_s { bool playing_sound,playing_music; before_muted_s() : playing_sound(false),playing_music(false){} } before_muted; if (preferences::music_on() || preferences::sound_on()) { // then remember settings and mute both before_muted.playing_sound = preferences::sound_on(); before_muted.playing_music = preferences::music_on(); preferences::set_sound(false); preferences::set_music(false); } else { // then set settings before mute preferences::set_sound(before_muted.playing_sound); preferences::set_music(before_muted.playing_music); } } break; case HOTKEY_QUIT_GAME: { if (disp.in_game()) { DBG_G << "is in game -- showing quit message\n"; const int res = gui2::show_message(disp.video(), _("Quit"), _("Do you really want to quit?"), gui2::tmessage::yes_no_buttons); if (res != gui2::twindow::CANCEL) { throw end_level_exception(QUIT); } } break; } default: DBG_G << "command_executor: unknown command number " << command.id << ", ignoring.\n"; break; } }
void execute_command(display& disp, HOTKEY_COMMAND command, command_executor* executor, int index) { const int zoom_amount = 4; bool map_screenshot = false; if(executor != NULL) { if(!executor->can_execute_command(command, index) || executor->execute_command(command, index)) return; } switch(command) { case HOTKEY_ZOOM_IN: disp.set_zoom(zoom_amount); break; case HOTKEY_ZOOM_OUT: disp.set_zoom(-zoom_amount); break; case HOTKEY_ZOOM_DEFAULT: disp.set_default_zoom(); break; case HOTKEY_FULLSCREEN: preferences::set_fullscreen(!preferences::fullscreen()); break; case HOTKEY_MAP_SCREENSHOT: if (!disp.in_game() && !disp.in_editor()) break; map_screenshot = true; case HOTKEY_SCREENSHOT: { std::string name = map_screenshot ? _("Map-Screenshot") : _("Screenshot"); std::string filename = get_screenshot_dir() + "/" + name + "_"; filename = get_next_filename(filename, ".bmp"); int size = disp.screenshot(filename, map_screenshot); if (size > 0) { std::stringstream res; res << filename << " ( " << utils::si_string(size, true, _("unit_byte^B")) << " )"; gui2::show_message(disp.video(), _("Screenshot done"), res.str()); } else gui2::show_message(disp.video(), _("Screenshot done"), ""); break; } case HOTKEY_ANIMATE_MAP: preferences::set_animate_map(!preferences::animate_map()); break; case HOTKEY_MOUSE_SCROLL: preferences::enable_mouse_scroll(!preferences::mouse_scroll_enabled()); break; case HOTKEY_ACCELERATED: preferences::set_turbo(!preferences::turbo()); break; case HOTKEY_MUTE: { // look if both is not playing static struct before_muted_s { bool playing_sound,playing_music; before_muted_s() : playing_sound(false),playing_music(false){} } before_muted; if (preferences::music_on() || preferences::sound_on()) { //then remember settings and mute both before_muted.playing_sound = preferences::sound_on(); before_muted.playing_music = preferences::music_on(); preferences::set_sound(false); preferences::set_music(false); } else { //then set settings before mute preferences::set_sound(before_muted.playing_sound); preferences::set_music(before_muted.playing_music); } } break; case HOTKEY_QUIT_GAME: { if(disp.in_game()) { DBG_G << "is in game -- showing quit message\n"; const int res = gui2::show_message(disp.video(), _("Quit"), _("Do you really want to quit?"), gui2::tmessage::yes_no_buttons); if(res != gui2::twindow::CANCEL) { throw end_level_exception(QUIT); } } break; } default: DBG_G << "command_executor: unknown command number " << command << ", ignoring.\n"; break; } }