From f0f104097da333c0d6e5be98c5d02620b0a86842 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Sat, 23 Jul 2016 19:15:07 -0400 Subject: [PATCH] finish / fix ecb08952e56b753f03efd76827e0c0cec99fd149 must have accidentally reverted Keys.h halfway through making it? --- src/PowderToy.h | 1 + src/PowderToyRenderer.cpp | 1 + src/PowderToySDL.cpp | 5 + src/gui/game/PropertyTool.cpp | 4 +- src/gui/game/ToolButton.cpp | 7 +- src/gui/interface/AvatarButton.cpp | 3 +- src/gui/interface/Keys.h | 438 +++++++++++++++------- src/gui/interface/Label.cpp | 3 +- src/gui/interface/SaveButton.cpp | 3 +- src/gui/interface/Textbox.cpp | 17 +- src/gui/interface/Window.cpp | 56 +-- src/gui/localbrowser/LocalBrowserView.cpp | 11 +- src/gui/login/LoginView.cpp | 2 +- src/gui/preview/PreviewView.cpp | 2 +- src/gui/search/SearchView.cpp | 11 +- src/gui/tags/TagsView.cpp | 4 +- 16 files changed, 381 insertions(+), 187 deletions(-) diff --git a/src/PowderToy.h b/src/PowderToy.h index 4243e3821..a76a95b50 100644 --- a/src/PowderToy.h +++ b/src/PowderToy.h @@ -7,3 +7,4 @@ std::string ClipboardPull(); int GetModifiers(); bool LoadWindowPosition(int scale); void SetCursorEnabled(int enabled); +unsigned int GetTicks(); diff --git a/src/PowderToyRenderer.cpp b/src/PowderToyRenderer.cpp index 572358eda..3f01c1cd5 100644 --- a/src/PowderToyRenderer.cpp +++ b/src/PowderToyRenderer.cpp @@ -22,6 +22,7 @@ void ClipboardPush(std::string) {} std::string ClipboardPull() { return ""; } int GetModifiers() { return 0; } void SetCursorEnabled(int enabled) {} +unsigned int GetTicks() { return 0; } void readFile(std::string filename, std::vector & storage) { diff --git a/src/PowderToySDL.cpp b/src/PowderToySDL.cpp index 186a42b43..3d88ecefd 100644 --- a/src/PowderToySDL.cpp +++ b/src/PowderToySDL.cpp @@ -519,6 +519,11 @@ void SetCursorEnabled(int enabled) SDL_ShowCursor(enabled); } +unsigned int GetTicks() +{ + return SDL_GetTicks(); +} + std::map readArguments(int argc, char * argv[]) { std::map arguments; diff --git a/src/gui/game/PropertyTool.cpp b/src/gui/game/PropertyTool.cpp index 33178e2e3..d261fde58 100644 --- a/src/gui/game/PropertyTool.cpp +++ b/src/gui/game/PropertyTool.cpp @@ -236,9 +236,9 @@ void PropertyWindow::OnDraw() void PropertyWindow::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt) { - if (key == KEY_UP) + if (key == SDLK_UP) property->SetOption(property->GetOption().second-1); - else if (key == KEY_DOWN) + else if (key == SDLK_DOWN) property->SetOption(property->GetOption().second+1); } diff --git a/src/gui/game/ToolButton.cpp b/src/gui/game/ToolButton.cpp index a80e05cdc..e14bc8f0b 100644 --- a/src/gui/game/ToolButton.cpp +++ b/src/gui/game/ToolButton.cpp @@ -1,5 +1,6 @@ #include "ToolButton.h" #include "gui/interface/Keys.h" +#include "gui/interface/Mouse.h" #include "Favorite.h" ToolButton::ToolButton(ui::Point position, ui::Point size, std::string text_, std::string toolIdentifier, std::string toolTip): @@ -25,11 +26,11 @@ void ToolButton::OnMouseUnclick(int x, int y, unsigned int button) if(isButtonDown) { isButtonDown = false; - if(button == BUTTON_LEFT) + if(button == SDL_BUTTON_LEFT) SetSelectionState(0); - if(button == BUTTON_RIGHT) + if(button == SDL_BUTTON_RIGHT) SetSelectionState(1); - if(button == BUTTON_MIDDLE) + if(button == SDL_BUTTON_MIDDLE) SetSelectionState(2); DoAction(); } diff --git a/src/gui/interface/AvatarButton.cpp b/src/gui/interface/AvatarButton.cpp index e17ab89ab..8fa15bb2c 100644 --- a/src/gui/interface/AvatarButton.cpp +++ b/src/gui/interface/AvatarButton.cpp @@ -9,6 +9,7 @@ #include "graphics/Graphics.h" #include "ContextMenu.h" #include "Keys.h" +#include "Mouse.h" namespace ui { @@ -79,7 +80,7 @@ void AvatarButton::OnContextMenuAction(int item) void AvatarButton::OnMouseClick(int x, int y, unsigned int button) { - if(button == BUTTON_RIGHT) + if(button == SDL_BUTTON_RIGHT) { if(menu) menu->Show(GetScreenPos() + ui::Point(x, y)); diff --git a/src/gui/interface/Keys.h b/src/gui/interface/Keys.h index bb9219f27..f2ad12b81 100644 --- a/src/gui/interface/Keys.h +++ b/src/gui/interface/Keys.h @@ -1,146 +1,326 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga -#if defined(USE_SDL) -#ifdef SDL_INC -#include "SDL/SDL.h" -#else -#include "SDL.h" -#endif -#define KEY_UNKNOWN SDLK_UNKNOWN -#define KEY_UP SDLK_UP -#define KEY_NUM_UP SDLK_KP8 -#define KEY_DOWN SDLK_DOWN -#define KEY_NUM_DOWN SDLK_KP2 -#define KEY_RIGHT SDLK_RIGHT -#define KEY_NUM_RIGHT SDLK_KP6 -#define KEY_LEFT SDLK_LEFT -#define KEY_NUM_LEFT SDLK_KP4 -#define KEY_HOME SDLK_HOME -#define KEY_NUM_HOME SDLK_KP7 -#define KEY_END SDLK_END -#define KEY_NUM_END SDLK_KP1 -#define KEY_NUM_INS SDLK_KP0 -#define KEY_NUM_PGUP SDLK_KP9 -#define KEY_NUM_PGDOWN SDLK_KP3 -#define KEY_NUM_PERIOD SDLK_KP_PERIOD -#define KEY_BACKSPACE SDLK_BACKSPACE -#define KEY_DELETE SDLK_DELETE -#define KEY_TAB SDLK_TAB -#define KEY_RETURN SDLK_RETURN -#define KEY_ENTER SDLK_KP_ENTER -#define KEY_ESCAPE SDLK_ESCAPE -#define KEY_INSERT SDLK_INSERT + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. -#define KEY_NUM_5 SDLK_KP5 + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. -#define KEY_LCTRL SDLK_LCTRL -#define KEY_LALT SDLK_LALT -#define KEY_LSHIFT SDLK_LSHIFT -#define KEY_RCTRL SDLK_RCTRL -#define KEY_RALT SDLK_RALT -#define KEY_RSHIFT SDLK_RSHIFT + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -#define KEY_MOD_NONE KMOD_NONE -#define KEY_MOD_LSHIFT KMOD_LSHIFT -#define KEY_MOD_RSHIFT KMOD_RSHIFT -#define KEY_MOD_LCONTROL KMOD_LCTRL -#define KEY_MOD_RCONTROL KMOD_RCTRL -#define KEY_MOD_LALT KMOD_LALT -#define KEY_MOD_RALT KMOD_RALT -#define KEY_MOD_LMETA KMOD_LMETA -#define KEY_MOD_RMETA KMOD_RMETA -#define KEY_MOD_NUM KMOD_NUM -#define KEY_MOD_CAPS KMOD_CAPS -#define KEY_MOD_MODE KMOD_MODE -#define KEY_MOD_RESERVED KMOD_RESERVED + Sam Lantinga + slouken@libsdl.org +*/ -#ifdef MACOSX -#define KEY_MOD_CONTROL (KEY_MOD_RCONTROL | KEY_MOD_LCONTROL | KEY_MOD_LMETA | KEY_MOD_RMETA) -#else -#define KEY_MOD_CONTROL (KEY_MOD_RCONTROL | KEY_MOD_LCONTROL) -#endif -#define KEY_MOD_ALT (KEY_MOD_RALT | KEY_MOD_LALT) -#define KEY_MOD_SHIFT (KEY_MOD_RSHIFT | KEY_MOD_LSHIFT) +#ifndef _SDL_keysym_h +#define _SDL_keysym_h -#define KEY_a SDLK_a -#define KEY_d SDLK_d -#define KEY_s SDLK_s -#define KEY_w SDLK_w +/** What we really want is a mapping of every raw key on the keyboard. + * To support international keyboards, we use the range 0xA1 - 0xFF + * as international virtual keycodes. We'll follow in the footsteps of X11... + * @brief The names of the keys + */ +typedef enum { + /** @name ASCII mapped keysyms + * The keyboard syms have been cleverly chosen to map to ASCII + */ + /*@{*/ + SDLK_UNKNOWN = 0, + SDLK_FIRST = 0, + SDLK_BACKSPACE = 8, + SDLK_TAB = 9, + SDLK_CLEAR = 12, + SDLK_RETURN = 13, + SDLK_PAUSE = 19, + SDLK_ESCAPE = 27, + SDLK_SPACE = 32, + SDLK_EXCLAIM = 33, + SDLK_QUOTEDBL = 34, + SDLK_HASH = 35, + SDLK_DOLLAR = 36, + SDLK_AMPERSAND = 38, + SDLK_QUOTE = 39, + SDLK_LEFTPAREN = 40, + SDLK_RIGHTPAREN = 41, + SDLK_ASTERISK = 42, + SDLK_PLUS = 43, + SDLK_COMMA = 44, + SDLK_MINUS = 45, + SDLK_PERIOD = 46, + SDLK_SLASH = 47, + SDLK_0 = 48, + SDLK_1 = 49, + SDLK_2 = 50, + SDLK_3 = 51, + SDLK_4 = 52, + SDLK_5 = 53, + SDLK_6 = 54, + SDLK_7 = 55, + SDLK_8 = 56, + SDLK_9 = 57, + SDLK_COLON = 58, + SDLK_SEMICOLON = 59, + SDLK_LESS = 60, + SDLK_EQUALS = 61, + SDLK_GREATER = 62, + SDLK_QUESTION = 63, + SDLK_AT = 64, + /* + Skip uppercase letters + */ + SDLK_LEFTBRACKET = 91, + SDLK_BACKSLASH = 92, + SDLK_RIGHTBRACKET = 93, + SDLK_CARET = 94, + SDLK_UNDERSCORE = 95, + SDLK_BACKQUOTE = 96, + SDLK_a = 97, + SDLK_b = 98, + SDLK_c = 99, + SDLK_d = 100, + SDLK_e = 101, + SDLK_f = 102, + SDLK_g = 103, + SDLK_h = 104, + SDLK_i = 105, + SDLK_j = 106, + SDLK_k = 107, + SDLK_l = 108, + SDLK_m = 109, + SDLK_n = 110, + SDLK_o = 111, + SDLK_p = 112, + SDLK_q = 113, + SDLK_r = 114, + SDLK_s = 115, + SDLK_t = 116, + SDLK_u = 117, + SDLK_v = 118, + SDLK_w = 119, + SDLK_x = 120, + SDLK_y = 121, + SDLK_z = 122, + SDLK_DELETE = 127, + /* End of ASCII mapped keysyms */ + /*@}*/ -#define KEY_F1 SDLK_F1 -#define KEY_F2 SDLK_F2 -#define KEY_F3 SDLK_F3 -#define KEY_F5 SDLK_F5 + /** @name International keyboard syms */ + /*@{*/ + SDLK_WORLD_0 = 160, /* 0xA0 */ + SDLK_WORLD_1 = 161, + SDLK_WORLD_2 = 162, + SDLK_WORLD_3 = 163, + SDLK_WORLD_4 = 164, + SDLK_WORLD_5 = 165, + SDLK_WORLD_6 = 166, + SDLK_WORLD_7 = 167, + SDLK_WORLD_8 = 168, + SDLK_WORLD_9 = 169, + SDLK_WORLD_10 = 170, + SDLK_WORLD_11 = 171, + SDLK_WORLD_12 = 172, + SDLK_WORLD_13 = 173, + SDLK_WORLD_14 = 174, + SDLK_WORLD_15 = 175, + SDLK_WORLD_16 = 176, + SDLK_WORLD_17 = 177, + SDLK_WORLD_18 = 178, + SDLK_WORLD_19 = 179, + SDLK_WORLD_20 = 180, + SDLK_WORLD_21 = 181, + SDLK_WORLD_22 = 182, + SDLK_WORLD_23 = 183, + SDLK_WORLD_24 = 184, + SDLK_WORLD_25 = 185, + SDLK_WORLD_26 = 186, + SDLK_WORLD_27 = 187, + SDLK_WORLD_28 = 188, + SDLK_WORLD_29 = 189, + SDLK_WORLD_30 = 190, + SDLK_WORLD_31 = 191, + SDLK_WORLD_32 = 192, + SDLK_WORLD_33 = 193, + SDLK_WORLD_34 = 194, + SDLK_WORLD_35 = 195, + SDLK_WORLD_36 = 196, + SDLK_WORLD_37 = 197, + SDLK_WORLD_38 = 198, + SDLK_WORLD_39 = 199, + SDLK_WORLD_40 = 200, + SDLK_WORLD_41 = 201, + SDLK_WORLD_42 = 202, + SDLK_WORLD_43 = 203, + SDLK_WORLD_44 = 204, + SDLK_WORLD_45 = 205, + SDLK_WORLD_46 = 206, + SDLK_WORLD_47 = 207, + SDLK_WORLD_48 = 208, + SDLK_WORLD_49 = 209, + SDLK_WORLD_50 = 210, + SDLK_WORLD_51 = 211, + SDLK_WORLD_52 = 212, + SDLK_WORLD_53 = 213, + SDLK_WORLD_54 = 214, + SDLK_WORLD_55 = 215, + SDLK_WORLD_56 = 216, + SDLK_WORLD_57 = 217, + SDLK_WORLD_58 = 218, + SDLK_WORLD_59 = 219, + SDLK_WORLD_60 = 220, + SDLK_WORLD_61 = 221, + SDLK_WORLD_62 = 222, + SDLK_WORLD_63 = 223, + SDLK_WORLD_64 = 224, + SDLK_WORLD_65 = 225, + SDLK_WORLD_66 = 226, + SDLK_WORLD_67 = 227, + SDLK_WORLD_68 = 228, + SDLK_WORLD_69 = 229, + SDLK_WORLD_70 = 230, + SDLK_WORLD_71 = 231, + SDLK_WORLD_72 = 232, + SDLK_WORLD_73 = 233, + SDLK_WORLD_74 = 234, + SDLK_WORLD_75 = 235, + SDLK_WORLD_76 = 236, + SDLK_WORLD_77 = 237, + SDLK_WORLD_78 = 238, + SDLK_WORLD_79 = 239, + SDLK_WORLD_80 = 240, + SDLK_WORLD_81 = 241, + SDLK_WORLD_82 = 242, + SDLK_WORLD_83 = 243, + SDLK_WORLD_84 = 244, + SDLK_WORLD_85 = 245, + SDLK_WORLD_86 = 246, + SDLK_WORLD_87 = 247, + SDLK_WORLD_88 = 248, + SDLK_WORLD_89 = 249, + SDLK_WORLD_90 = 250, + SDLK_WORLD_91 = 251, + SDLK_WORLD_92 = 252, + SDLK_WORLD_93 = 253, + SDLK_WORLD_94 = 254, + SDLK_WORLD_95 = 255, /* 0xFF */ + /*@}*/ -#define BUTTON_LEFT SDL_BUTTON_LEFT -#define BUTTON_MIDDLE SDL_BUTTON_MIDDLE -#define BUTTON_RIGHT SDL_BUTTON_RIGHT + /** @name Numeric keypad */ + /*@{*/ + SDLK_KP0 = 256, + SDLK_KP1 = 257, + SDLK_KP2 = 258, + SDLK_KP3 = 259, + SDLK_KP4 = 260, + SDLK_KP5 = 261, + SDLK_KP6 = 262, + SDLK_KP7 = 263, + SDLK_KP8 = 264, + SDLK_KP9 = 265, + SDLK_KP_PERIOD = 266, + SDLK_KP_DIVIDE = 267, + SDLK_KP_MULTIPLY = 268, + SDLK_KP_MINUS = 269, + SDLK_KP_PLUS = 270, + SDLK_KP_ENTER = 271, + SDLK_KP_EQUALS = 272, + /*@}*/ -#else + /** @name Arrows + Home/End pad */ + /*@{*/ + SDLK_UP = 273, + SDLK_DOWN = 274, + SDLK_RIGHT = 275, + SDLK_LEFT = 276, + SDLK_INSERT = 277, + SDLK_HOME = 278, + SDLK_END = 279, + SDLK_PAGEUP = 280, + SDLK_PAGEDOWN = 281, + /*@}*/ -#define KEY_UNKNOWN 0 -#define KEY_UP 1 -#define KEY_NUM_UP 47 -#define KEY_DOWN 2 -#define KEY_NUM_DOWN 48 -#define KEY_RIGHT 3 -#define KEY_NUM_RIGHT 49 -#define KEY_LEFT 4 -#define KEY_NUM_LEFT 50 -#define KEY_HOME 5 -#define KEY_NUM_HOME 51 -#define KEY_END 6 -#define KEY_NUM_END 47 -#define KEY_BACKSPACE 7 -#define KEY_DELETE 8 -#define KEY_TAB 9 -#define KEY_RETURN 10 -#define KEY_ENTER 11 -#define KEY_ESCAPE 12 -#define KEY_INSERT 46 + /** @name Function keys */ + /*@{*/ + SDLK_F1 = 282, + SDLK_F2 = 283, + SDLK_F3 = 284, + SDLK_F4 = 285, + SDLK_F5 = 286, + SDLK_F6 = 287, + SDLK_F7 = 288, + SDLK_F8 = 289, + SDLK_F9 = 290, + SDLK_F10 = 291, + SDLK_F11 = 292, + SDLK_F12 = 293, + SDLK_F13 = 294, + SDLK_F14 = 295, + SDLK_F15 = 296, + /*@}*/ -#define KEY_NUM_INS 52 -#define KEY_NUM_PGUP 53 -#define KEY_NUM_PGDOWN 54 -#define KEY_NUM_PERIOD 55 -#define KEY_NUM_5 56 + /** @name Key state modifier keys */ + /*@{*/ + SDLK_NUMLOCK = 300, + SDLK_CAPSLOCK = 301, + SDLK_SCROLLOCK = 302, + SDLK_RSHIFT = 303, + SDLK_LSHIFT = 304, + SDLK_RCTRL = 305, + SDLK_LCTRL = 306, + SDLK_RALT = 307, + SDLK_LALT = 308, + SDLK_RMETA = 309, + SDLK_LMETA = 310, + SDLK_LSUPER = 311, /**< Left "Windows" key */ + SDLK_RSUPER = 312, /**< Right "Windows" key */ + SDLK_MODE = 313, /**< "Alt Gr" key */ + SDLK_COMPOSE = 314, /**< Multi-key compose key */ + /*@}*/ -#define KEY_LCTRL 13 -#define KEY_LALT 14 -#define KEY_LSHIFT 15 -#define KEY_RCTRL 43 -#define KEY_RALT 44 -#define KEY_RSHIFT 45 + /** @name Miscellaneous function keys */ + /*@{*/ + SDLK_HELP = 315, + SDLK_PRINT = 316, + SDLK_SYSREQ = 317, + SDLK_BREAK = 318, + SDLK_MENU = 319, + SDLK_POWER = 320, /**< Power Macintosh power key */ + SDLK_EURO = 321, /**< Some european keyboards */ + SDLK_UNDO = 322, /**< Atari keyboard has Undo */ + /*@}*/ -#define KEY_MOD_NONE 30 -#define KEY_MOD_LSHIFT 31 -#define KEY_MOD_RSHIFT 32 -#define KEY_MOD_LCONTROL 33 -#define KEY_MOD_RCONTROL 34 -#define KEY_MOD_LALT 35 -#define KEY_MOD_RALT 36 -#define KEY_MOD_LMETA 37 -#define KEY_MOD_RMETA 38 -#define KEY_MOD_NUM 39 -#define KEY_MOD_CAPS 40 -#define KEY_MOD_MODE 41 -#define KEY_MOD_RESERVED 42 + /* Add any other keys here */ -#define KEY_MOD_CONTROL 16 -#define KEY_MOD_ALT 17 -#define KEY_MOD_SHIFT 18 + SDLK_LAST +} SDLKey; -#define KEY_a 22 -#define KEY_d 23 -#define KEY_s 24 -#define KEY_w 25 +/** Enumeration of valid key mods (possibly OR'd together) */ +typedef enum { + KMOD_NONE = 0x0000, + KMOD_LSHIFT= 0x0001, + KMOD_RSHIFT= 0x0002, + KMOD_LCTRL = 0x0040, + KMOD_RCTRL = 0x0080, + KMOD_LALT = 0x0100, + KMOD_RALT = 0x0200, + KMOD_LMETA = 0x0400, + KMOD_RMETA = 0x0800, + KMOD_NUM = 0x1000, + KMOD_CAPS = 0x2000, + KMOD_MODE = 0x4000, + KMOD_RESERVED = 0x8000 +} SDLMod; -#define KEY_F1 26 -#define KEY_F2 27 -#define KEY_F3 28 -#define KEY_F5 29 +#define KMOD_CTRL (KMOD_LCTRL|KMOD_RCTRL) +#define KMOD_SHIFT (KMOD_LSHIFT|KMOD_RSHIFT) +#define KMOD_ALT (KMOD_LALT|KMOD_RALT) +#define KMOD_META (KMOD_LMETA|KMOD_RMETA) -#define BUTTON_LEFT 19 -#define BUTTON_MIDDLE 20 -#define BUTTON_RIGHT 21 - -#endif +#endif /* _SDL_keysym_h */ diff --git a/src/gui/interface/Label.cpp b/src/gui/interface/Label.cpp index c7da89cbe..4c274513b 100644 --- a/src/gui/interface/Label.cpp +++ b/src/gui/interface/Label.cpp @@ -4,6 +4,7 @@ #include "Point.h" #include "Label.h" #include "Keys.h" +#include "Mouse.h" #include "ContextMenu.h" using namespace ui; @@ -188,7 +189,7 @@ void Label::OnContextMenuAction(int item) void Label::OnMouseClick(int x, int y, unsigned button) { - if(button == BUTTON_RIGHT) + if(button == SDL_BUTTON_RIGHT) { if(menu) menu->Show(GetScreenPos() + ui::Point(x, y)); diff --git a/src/gui/interface/SaveButton.cpp b/src/gui/interface/SaveButton.cpp index d0d8e0b43..9b5fdf97f 100644 --- a/src/gui/interface/SaveButton.cpp +++ b/src/gui/interface/SaveButton.cpp @@ -10,6 +10,7 @@ #include "Format.h" #include "ContextMenu.h" #include "Keys.h" +#include "Mouse.h" namespace ui { @@ -343,7 +344,7 @@ void SaveButton::OnContextMenuAction(int item) void SaveButton::OnMouseClick(int x, int y, unsigned int button) { - if(button == BUTTON_RIGHT) + if(button == SDL_BUTTON_RIGHT) { if(menu) menu->Show(GetScreenPos() + ui::Point(x, y)); diff --git a/src/gui/interface/Textbox.cpp b/src/gui/interface/Textbox.cpp index ddc56ec96..a0539446a 100644 --- a/src/gui/interface/Textbox.cpp +++ b/src/gui/interface/Textbox.cpp @@ -7,6 +7,7 @@ #include "gui/interface/Point.h" #include "gui/interface/Textbox.h" #include "gui/interface/Keys.h" +#include "gui/interface/Mouse.h" #include "ContextMenu.h" using namespace ui; @@ -328,25 +329,25 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool { switch(key) { - case KEY_HOME: + case SDLK_HOME: cursor = 0; ClearSelection(); break; - case KEY_END: + case SDLK_END: cursor = backingText.length(); ClearSelection(); break; - case KEY_LEFT: + case SDLK_LEFT: if(cursor > 0) cursor--; ClearSelection(); break; - case KEY_RIGHT: + case SDLK_RIGHT: if (cursor < (int)backingText.length()) cursor++; ClearSelection(); break; - case KEY_DELETE: + case SDLK_DELETE: if(ReadOnly) break; if (HasSelection()) @@ -367,7 +368,7 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool } ClearSelection(); break; - case KEY_BACKSPACE: + case SDLK_BACKSPACE: if (ReadOnly) break; if (HasSelection()) @@ -394,7 +395,7 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool } ClearSelection(); break; - case KEY_RETURN: + case SDLK_RETURN: character = '\n'; default: if (CharacterValid(character) && !ReadOnly) @@ -480,7 +481,7 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool void Textbox::OnMouseClick(int x, int y, unsigned button) { - if(button != BUTTON_RIGHT) + if (button != SDL_BUTTON_RIGHT) { mouseDown = true; cursor = Graphics::CharIndexAtPosition(multiline?((char*)textLines.c_str()):((char*)text.c_str()), x-textPosition.X, y-textPosition.Y); diff --git a/src/gui/interface/Window.cpp b/src/gui/interface/Window.cpp index 393fa6855..b5253af4d 100644 --- a/src/gui/interface/Window.cpp +++ b/src/gui/interface/Window.cpp @@ -265,7 +265,7 @@ void Window::DoTick(float dt) void Window::DoKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt) { #ifdef DEBUG - if (key == KEY_TAB && ctrl) + if (key == SDLK_TAB && ctrl) debugMode = !debugMode; if (debugMode) { @@ -273,38 +273,38 @@ void Window::DoKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool a { if (shift) { - if (key == KEY_UP) + if (key == SDLK_UP) focusedComponent_->Size.Y--; - if (key == KEY_DOWN) + if (key == SDLK_DOWN) focusedComponent_->Size.Y++; - if (key == KEY_LEFT) + if (key == SDLK_LEFT) focusedComponent_->Size.X--; - if (key == KEY_RIGHT) + if (key == SDLK_RIGHT) focusedComponent_->Size.X++; } if (ctrl) { - if (key == KEY_UP) + if (key == SDLK_UP) focusedComponent_->Size.Y++; - if (key == KEY_DOWN) + if (key == SDLK_DOWN) focusedComponent_->Size.Y--; - if (key == KEY_LEFT) + if (key == SDLK_LEFT) focusedComponent_->Size.X++; - if (key == KEY_RIGHT) + if (key == SDLK_RIGHT) focusedComponent_->Size.X--; } if (!shift) { - if (key == KEY_UP) + if (key == SDLK_UP) focusedComponent_->Position.Y--; - if (key == KEY_DOWN) + if (key == SDLK_DOWN) focusedComponent_->Position.Y++; - if (key == KEY_LEFT) + if (key == SDLK_LEFT) focusedComponent_->Position.X--; - if (key == KEY_RIGHT) + if (key == SDLK_RIGHT) focusedComponent_->Position.X++; } - if (key == KEY_DELETE) + if (key == SDLK_DELETE) { RemoveComponent(focusedComponent_); halt = false; @@ -314,35 +314,35 @@ void Window::DoKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool a { if (shift) { - if (key == KEY_UP) + if (key == SDLK_UP) Size.Y--; - if (key == KEY_DOWN) + if (key == SDLK_DOWN) Size.Y++; - if (key == KEY_LEFT) + if (key == SDLK_LEFT) Size.X--; - if (key == KEY_RIGHT) + if (key == SDLK_RIGHT) Size.X++; } if (ctrl) { - if (key == KEY_UP) + if (key == SDLK_UP) Size.Y++; - if (key == KEY_DOWN) + if (key == SDLK_DOWN) Size.Y--; - if (key == KEY_LEFT) + if (key == SDLK_LEFT) Size.X++; - if (key == KEY_RIGHT) + if (key == SDLK_RIGHT) Size.X--; } if (!shift) { - if (key == KEY_UP) + if (key == SDLK_UP) Position.Y--; - if (key == KEY_DOWN) + if (key == SDLK_DOWN) Position.Y++; - if( key == KEY_LEFT) + if( key == SDLK_LEFT) Position.X--; - if (key == KEY_RIGHT) + if (key == SDLK_RIGHT) Position.X++; } } @@ -359,10 +359,10 @@ void Window::DoKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool a if (!stop) OnKeyPress(key, character, shift, ctrl, alt); - if (key == KEY_ESCAPE) + if (key == SDLK_ESCAPE) OnTryExit(Escape); - if (key == KEY_ENTER || key == KEY_RETURN) + if (key == SDLK_KP_ENTER || key == SDLK_RETURN) OnTryOkay(Enter); if (destruct) diff --git a/src/gui/localbrowser/LocalBrowserView.cpp b/src/gui/localbrowser/LocalBrowserView.cpp index 0f3089f84..7e5be12f2 100644 --- a/src/gui/localbrowser/LocalBrowserView.cpp +++ b/src/gui/localbrowser/LocalBrowserView.cpp @@ -2,6 +2,7 @@ #include "client/Client.h" #include "Format.h" #include "LocalBrowserView.h" +#include "PowderToy.h" #include "gui/interface/Button.h" #include "gui/interface/Textbox.h" @@ -115,7 +116,7 @@ void LocalBrowserView::textChanged() pageTextbox->SetText(format::NumberToString(pageCount)); changed = true; #ifdef USE_SDL - lastChanged = SDL_GetTicks()+600; + lastChanged = GetTicks()+600; #endif } @@ -123,7 +124,7 @@ void LocalBrowserView::OnTick(float dt) { c->Update(); #ifdef USE_SDL - if (changed && lastChanged < SDL_GetTicks()) + if (changed && lastChanged < GetTicks()) { changed = false; c->SetPage(std::max(format::StringToNumber(pageTextbox->GetText()), 0)); @@ -270,15 +271,15 @@ void LocalBrowserView::OnMouseWheel(int x, int y, int d) void LocalBrowserView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt) { - if(key == KEY_ESCAPE) + if (key == SDLK_ESCAPE) c->Exit(); - else if (key == KEY_LCTRL || key == KEY_RCTRL) + else if (key == SDLK_LCTRL || key == SDLK_RCTRL) c->SetMoveToFront(false); } void LocalBrowserView::OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt) { - if (key == KEY_LCTRL || key == KEY_RCTRL) + if (key == SDLK_LCTRL || key == SDLK_RCTRL) c->SetMoveToFront(true); } diff --git a/src/gui/login/LoginView.cpp b/src/gui/login/LoginView.cpp index c7b5fdd53..c9db04e3f 100644 --- a/src/gui/login/LoginView.cpp +++ b/src/gui/login/LoginView.cpp @@ -76,7 +76,7 @@ void LoginView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, boo { switch(key) { - case KEY_TAB: + case SDLK_TAB: if(IsFocused(usernameField)) FocusComponent(passwordField); else diff --git a/src/gui/preview/PreviewView.cpp b/src/gui/preview/PreviewView.cpp index e45989f86..ea66f17ee 100644 --- a/src/gui/preview/PreviewView.cpp +++ b/src/gui/preview/PreviewView.cpp @@ -409,7 +409,7 @@ void PreviewView::OnMouseUp(int x, int y, unsigned int button) void PreviewView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt) { - if ((key == KEY_ENTER || key == KEY_RETURN) && (!addCommentBox || !addCommentBox->IsFocused())) + if ((key == SDLK_KP_ENTER || key == SDLK_RETURN) && (!addCommentBox || !addCommentBox->IsFocused())) openButton->DoAction(); } diff --git a/src/gui/search/SearchView.cpp b/src/gui/search/SearchView.cpp index 74a3a14c7..cbb190ab1 100644 --- a/src/gui/search/SearchView.cpp +++ b/src/gui/search/SearchView.cpp @@ -11,6 +11,7 @@ #include "gui/interface/Spinner.h" #include "Misc.h" #include "Format.h" +#include "PowderToy.h" SearchView::SearchView(): ui::Window(ui::Point(0, 0), ui::Point(WINDOWW, WINDOWH)), @@ -278,7 +279,7 @@ void SearchView::textChanged() pageTextbox->SetText(format::NumberToString(pageCount)); changed = true; #ifdef USE_SDL - lastChanged = SDL_GetTicks()+600; + lastChanged = GetTicks()+600; #endif } @@ -765,7 +766,7 @@ void SearchView::OnTick(float dt) { c->Update(); #ifdef USE_SDL - if (changed && lastChanged < SDL_GetTicks()) + if (changed && lastChanged < GetTicks()) { changed = false; c->SetPage(std::max(format::StringToNumber(pageTextbox->GetText()), 0)); @@ -784,14 +785,14 @@ void SearchView::OnMouseWheel(int x, int y, int d) } void SearchView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt) { - if (key == KEY_ESCAPE) + if (key == SDLK_ESCAPE) c->Exit(); - else if (key == KEY_LCTRL || key == KEY_RCTRL) + else if (key == SDLK_LCTRL || key == SDLK_RCTRL) c->InstantOpen(true); } void SearchView::OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt) { - if (key == KEY_LCTRL || key == KEY_RCTRL) + if (key == SDLK_LCTRL || key == SDLK_RCTRL) c->InstantOpen(false); } diff --git a/src/gui/tags/TagsView.cpp b/src/gui/tags/TagsView.cpp index cde1e3ee4..b17e893b2 100644 --- a/src/gui/tags/TagsView.cpp +++ b/src/gui/tags/TagsView.cpp @@ -134,8 +134,8 @@ void TagsView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool { switch(key) { - case KEY_ENTER: - case KEY_RETURN: + case SDLK_KP_ENTER: + case SDLK_RETURN: if(IsFocused(tagInput)) { addTag();