Changeset - r16716:3e55fd43d2b2
[Not reviewed]
master
0 1 0
planetmaker - 14 years ago 2010-12-10 23:38:26
planetmaker@openttd.org
(svn r21459) -Feature(tte) [FS#3217]: Hotkey Ctrl+W for returning to the main menu
1 file changed with 25 insertions and 9 deletions:
0 comments (0 inline, 0 general)
src/main_gui.cpp
Show inline comments
 
@@ -29,12 +29,14 @@
 
#include "company_func.h"
 
#include "toolbar_gui.h"
 
#include "statusbar_gui.h"
 
#include "tilehighlight_func.h"
 
#include "hotkeys.h"
 

	
 
#include "saveload/saveload.h"
 

	
 
#include "network/network.h"
 
#include "network/network_func.h"
 
#include "network/network_gui.h"
 
#include "network/network_base.h"
 

	
 
#include "table/sprites.h"
 
@@ -214,12 +216,13 @@ static const WindowDesc _main_window_des
 
	0,
 
	_nested_main_window_widgets, lengthof(_nested_main_window_widgets)
 
);
 

	
 
enum {
 
	GHK_QUIT,
 
	GHK_ABANDON,
 
	GHK_CONSOLE,
 
	GHK_BOUNDING_BOXES,
 
	GHK_CENTER,
 
	GHK_CENTER_ZOOM,
 
	GHK_RESET_OBJECT_TO_PLACE,
 
	GHK_DELETE_WINDOWS,
 
@@ -280,22 +283,33 @@ struct MainWindow : Window
 
		/* Disable all key shortcuts, except quit shortcuts when
 
		 * generating the world, otherwise they create threading
 
		 * problem during the generating, resulting in random
 
		 * assertions that are hard to trigger and debug */
 
		if (IsGeneratingWorld()) return ES_NOT_HANDLED;
 

	
 
		if (num == GHK_CONSOLE) {
 
			IConsoleSwitch();
 
			return ES_HANDLED;
 
		}
 
		switch (num) {
 
			case GHK_ABANDON:
 
				/* No point returning from the main menu to itself */
 
				if (_game_mode == GM_MENU) return ES_HANDLED;
 
				if (_settings_client.gui.autosave_on_exit) {
 
					DoExitSave();
 
					_switch_mode = SM_MENU;
 
				} else {
 
					AskExitToGameMenu();
 
				}
 
				return ES_HANDLED;
 

	
 
		if (num == GHK_BOUNDING_BOXES) {
 
			extern bool _draw_bounding_boxes;
 
			_draw_bounding_boxes = !_draw_bounding_boxes;
 
			MarkWholeScreenDirty();
 
			return ES_HANDLED;
 
			case GHK_CONSOLE:
 
				IConsoleSwitch();
 
				return ES_HANDLED;
 

	
 
			case GHK_BOUNDING_BOXES:
 
				extern bool _draw_bounding_boxes;
 
				_draw_bounding_boxes = !_draw_bounding_boxes;
 
				MarkWholeScreenDirty();
 
				return ES_HANDLED;
 
		}
 

	
 
		if (_game_mode == GM_MENU) return ES_NOT_HANDLED;
 

	
 
		switch (num) {
 
			case GHK_CENTER:
 
@@ -434,19 +448,21 @@ struct MainWindow : Window
 
	}
 

	
 
	static Hotkey<MainWindow> global_hotkeys[];
 
};
 

	
 
const uint16 _ghk_quit_keys[] = {'Q' | WKC_CTRL, 'Q' | WKC_META, 0};
 
const uint16 _ghk_abandon_keys[] = {'W' | WKC_CTRL, 'W' | WKC_META, 0};
 
const uint16 _ghk_chat_keys[] = {WKC_RETURN, 'T', 0};
 
const uint16 _ghk_chat_all_keys[] = {WKC_SHIFT | WKC_RETURN, WKC_SHIFT | 'T', 0};
 
const uint16 _ghk_chat_company_keys[] = {WKC_CTRL | WKC_RETURN, WKC_CTRL | 'T', 0};
 
const uint16 _ghk_chat_server_keys[] = {WKC_CTRL | WKC_SHIFT | WKC_RETURN, WKC_CTRL | WKC_SHIFT | 'T', 0};
 

	
 
Hotkey<MainWindow> MainWindow::global_hotkeys[] = {
 
	Hotkey<MainWindow>(_ghk_quit_keys, "quit", GHK_QUIT),
 
	Hotkey<MainWindow>(_ghk_abandon_keys, "abandon", GHK_ABANDON),
 
	Hotkey<MainWindow>(WKC_BACKQUOTE, "console", GHK_CONSOLE),
 
	Hotkey<MainWindow>('B' | WKC_CTRL, "bounding_boxes", GHK_BOUNDING_BOXES),
 
	Hotkey<MainWindow>('C', "center", GHK_CENTER),
 
	Hotkey<MainWindow>('Z', "center_zoom", GHK_CENTER_ZOOM),
 
	Hotkey<MainWindow>(WKC_ESC, "reset_object_to_place", GHK_RESET_OBJECT_TO_PLACE),
 
	Hotkey<MainWindow>(WKC_DELETE, "delete_windows", GHK_DELETE_WINDOWS),
0 comments (0 inline, 0 general)