mirror of https://github.com/OpenTTD/OpenTTD
(svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
parent
56fa1a8534
commit
5505a10b80
145
console.h
145
console.h
|
@ -1,63 +1,82 @@
|
||||||
// ** console ** //
|
// ** console ** //
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ICONSOLE_OPENED=0,
|
ICONSOLE_OPENED=0,
|
||||||
ICONSOLE_CLOSED,
|
ICONSOLE_CLOSED,
|
||||||
ICONSOLE_OPENING,
|
ICONSOLE_OPENING,
|
||||||
ICONSOLE_CLOSING,
|
ICONSOLE_CLOSING,
|
||||||
} _iconsole_modes;
|
} _iconsole_modes;
|
||||||
|
|
||||||
// ** console parser ** //
|
// ** console parser ** //
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ICONSOLE_VAR_NONE=0,
|
ICONSOLE_VAR_NONE=0,
|
||||||
ICONSOLE_VAR_BOOLEAN,
|
ICONSOLE_VAR_BOOLEAN,
|
||||||
ICONSOLE_VAR_BYTE,
|
ICONSOLE_VAR_BYTE,
|
||||||
ICONSOLE_VAR_UINT16,
|
ICONSOLE_VAR_UINT16,
|
||||||
ICONSOLE_VAR_UINT32,
|
ICONSOLE_VAR_UINT32,
|
||||||
ICONSOLE_VAR_INT16,
|
ICONSOLE_VAR_INT16,
|
||||||
ICONSOLE_VAR_INT32,
|
ICONSOLE_VAR_INT32,
|
||||||
ICONSOLE_VAR_STRING,
|
ICONSOLE_VAR_STRING,
|
||||||
ICONSOLE_VAR_VARPTR,
|
ICONSOLE_VAR_POINTER,
|
||||||
ICONSOLE_VAR_POINTER,
|
ICONSOLE_VAR_UNKNOWN
|
||||||
ICONSOLE_VAR_UNKNOWN
|
} _iconsole_var_types;
|
||||||
} _iconsole_var_types;
|
|
||||||
|
typedef struct {
|
||||||
typedef struct {
|
// -------------- //
|
||||||
// -------------- //
|
void * addr;
|
||||||
void * addr;
|
byte * name;
|
||||||
byte * name;
|
// -------------- //
|
||||||
// -------------- //
|
void * _next;
|
||||||
void * _next;
|
} _iconsole_cmd;
|
||||||
} _iconsole_cmd;
|
|
||||||
|
typedef struct {
|
||||||
typedef struct {
|
// --------------- //
|
||||||
// --------------- //
|
void * addr;
|
||||||
void * addr;
|
byte * name;
|
||||||
byte * name;
|
byte type;
|
||||||
byte type;
|
// -------------- //
|
||||||
// -------------- //
|
void * _next;
|
||||||
void * _next;
|
bool _malloc;
|
||||||
} _iconsole_var;
|
} _iconsole_var;
|
||||||
|
|
||||||
// ** ttd.c functions ** //
|
// ** ttd.c functions ** //
|
||||||
void SetDebugString(const char *s);
|
void SetDebugString(const char *s);
|
||||||
|
|
||||||
// ** console functions ** //
|
// ** console functions ** //
|
||||||
|
|
||||||
void IConsoleClearCommand();
|
void IConsoleClearCommand();
|
||||||
void IConsoleInit();
|
void IConsoleInit();
|
||||||
void IConsoleClear();
|
void IConsoleClear();
|
||||||
void IConsoleFree();
|
void IConsoleFree();
|
||||||
void IConsoleResize();
|
void IConsoleResize();
|
||||||
void IConsoleSwitch();
|
void IConsoleSwitch();
|
||||||
void IConsoleClose();
|
void IConsoleClose();
|
||||||
void IConsoleOpen();
|
void IConsoleOpen();
|
||||||
void IConsolePrint(byte color_code, byte* string);
|
|
||||||
void IConsolePrintF(byte color_code, const char *s, ...);
|
// ** console output ** //
|
||||||
void IConsoleDebug(byte* string);
|
|
||||||
void IConsoleError(byte* string);
|
void IConsolePrint(byte color_code, byte* string);
|
||||||
void IConsoleCmdRegister(byte * name, void * addr);
|
void IConsolePrintF(byte color_code, const char *s, ...);
|
||||||
void IConsoleVarRegister(byte * name, void * addr, byte type);
|
void IConsoleDebug(byte* string);
|
||||||
void IConsoleCmdExec(byte * cmdstr);
|
void IConsoleError(byte* string);
|
||||||
|
|
||||||
|
// *** Commands *** //
|
||||||
|
|
||||||
|
void IConsoleCmdRegister(byte * name, void * addr);
|
||||||
|
void* IConsoleCmdGetAddr(byte * name);
|
||||||
|
|
||||||
|
// *** Variables *** //
|
||||||
|
|
||||||
|
void IConsoleVarRegister(byte * name, void * addr, byte type);
|
||||||
|
void IConsoleVarInsert(_iconsole_var * var, byte * name);
|
||||||
|
_iconsole_var * IConsoleVarGet(byte * name);
|
||||||
|
_iconsole_var * IConsoleVarAlloc(byte type);
|
||||||
|
void IConsoleVarFree(_iconsole_var * var);
|
||||||
|
void IConsoleVarSetString(_iconsole_var * var, byte * string);
|
||||||
|
void IConsoleVarSetValue(_iconsole_var * var, int value);
|
||||||
|
void IConsoleVarDump(_iconsole_var * var, byte * dump_desc);
|
||||||
|
|
||||||
|
// *** Parser *** //
|
||||||
|
|
||||||
|
void IConsoleCmdExec(byte * cmdstr);
|
||||||
|
|
|
@ -1689,7 +1689,7 @@ static void MainToolbarWndProc(Window *w, WindowEvent *e)
|
||||||
case WKC_SHIFT | WKC_F12: ShowMusicWindow(); break;
|
case WKC_SHIFT | WKC_F12: ShowMusicWindow(); break;
|
||||||
case WKC_CTRL | 'S': _make_screenshot = 1; break;
|
case WKC_CTRL | 'S': _make_screenshot = 1; break;
|
||||||
case WKC_CTRL | 'G': _make_screenshot = 2; break;
|
case WKC_CTRL | 'G': _make_screenshot = 2; break;
|
||||||
case WKC_BACKQUOTE: IConsoleSwitch(); e->keypress.keycode=0; break;
|
case WKC_BACKQUOTE: IConsoleSwitch(); e->keypress.cont=false; break;
|
||||||
case WKC_CTRL | WKC_ALT | 'C': if(!_networking) ShowCheatWindow(); break;
|
case WKC_CTRL | WKC_ALT | 'C': if(!_networking) ShowCheatWindow(); break;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
5
sdl.c
5
sdl.c
|
@ -385,8 +385,11 @@ static uint32 ConvertSdlKeyIntoMy(SDL_keysym *sym)
|
||||||
}
|
}
|
||||||
|
|
||||||
// check scancode for BACKQUOTE key, because we want the key left of "1", not anything else (on non-US keyboards)
|
// check scancode for BACKQUOTE key, because we want the key left of "1", not anything else (on non-US keyboards)
|
||||||
|
#if defined(WIN32)
|
||||||
|
if (sym->scancode == 41) key |= WKC_BACKQUOTE;
|
||||||
|
#else
|
||||||
if (sym->scancode == 49) key |= WKC_BACKQUOTE;
|
if (sym->scancode == 49) key |= WKC_BACKQUOTE;
|
||||||
|
#endif
|
||||||
// META are the command keys on mac
|
// META are the command keys on mac
|
||||||
if (sym->mod & KMOD_META) key |= WKC_META;
|
if (sym->mod & KMOD_META) key |= WKC_META;
|
||||||
if (sym->mod & KMOD_SHIFT) key |= WKC_SHIFT;
|
if (sym->mod & KMOD_SHIFT) key |= WKC_SHIFT;
|
||||||
|
|
26
win32.c
26
win32.c
|
@ -107,6 +107,8 @@ static const VkMapping _vk_mapping[] = {
|
||||||
AM('A','Z','A','Z'),
|
AM('A','Z','A','Z'),
|
||||||
AM('0','9','0','9'),
|
AM('0','9','0','9'),
|
||||||
|
|
||||||
|
AS(220, WKC_BACKQUOTE),
|
||||||
|
|
||||||
AS(VK_ESCAPE, WKC_ESC),
|
AS(VK_ESCAPE, WKC_ESC),
|
||||||
AS(VK_BACK, WKC_BACKSPACE),
|
AS(VK_BACK, WKC_BACKSPACE),
|
||||||
AM(VK_INSERT,VK_DELETE,WKC_INSERT, WKC_DELETE),
|
AM(VK_INSERT,VK_DELETE,WKC_INSERT, WKC_DELETE),
|
||||||
|
@ -136,10 +138,13 @@ static uint MapWindowsKey(uint key)
|
||||||
do {
|
do {
|
||||||
map++;
|
map++;
|
||||||
from = map->vk_from;
|
from = map->vk_from;
|
||||||
if (from == 0) return 0; // Unknown key pressed.
|
if (from == 0) {
|
||||||
|
return 0; // Unknown key pressed.
|
||||||
|
}
|
||||||
} while ((uint)(key - from) > map->vk_count);
|
} while ((uint)(key - from) > map->vk_count);
|
||||||
|
|
||||||
key = key - from + map->map_to;
|
key = key - from + map->map_to;
|
||||||
|
|
||||||
if (GetAsyncKeyState(VK_SHIFT)<0) key |= WKC_SHIFT;
|
if (GetAsyncKeyState(VK_SHIFT)<0) key |= WKC_SHIFT;
|
||||||
if (GetAsyncKeyState(VK_CONTROL)<0) key |= WKC_CTRL;
|
if (GetAsyncKeyState(VK_CONTROL)<0) key |= WKC_CTRL;
|
||||||
if (GetAsyncKeyState(VK_MENU)<0) key |= WKC_ALT;
|
if (GetAsyncKeyState(VK_MENU)<0) key |= WKC_ALT;
|
||||||
|
@ -275,18 +280,27 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_KEYDOWN:
|
case WM_KEYDOWN:
|
||||||
_pressed_key = MapWindowsKey(wParam) << 16;
|
{
|
||||||
|
// this is the rewritten ascii input function
|
||||||
|
// it disables windows deadkey handling --> more linux like :D
|
||||||
|
unsigned short w = 0;
|
||||||
|
int r = 0;
|
||||||
|
byte ks[256];
|
||||||
|
unsigned int scan=0;
|
||||||
|
GetKeyboardState(ks);
|
||||||
|
r=ToAscii(wParam,scan,ks,&w,0);
|
||||||
|
if (r=0) w=0;
|
||||||
|
|
||||||
|
_pressed_key = w | MapWindowsKey(wParam) << 16;
|
||||||
|
}
|
||||||
if ((_pressed_key>>16) == ('D' | WKC_CTRL) && !_wnd.fullscreen) {
|
if ((_pressed_key>>16) == ('D' | WKC_CTRL) && !_wnd.fullscreen) {
|
||||||
_double_size ^= 1;
|
_double_size ^= 1;
|
||||||
_wnd.double_size = _double_size;
|
_wnd.double_size = _double_size;
|
||||||
ClientSizeChanged(_wnd.width, _wnd.height);
|
ClientSizeChanged(_wnd.width, _wnd.height);
|
||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_CHAR:
|
|
||||||
_pressed_key |= wParam;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_SYSKEYDOWN:
|
case WM_SYSKEYDOWN:
|
||||||
switch(wParam) {
|
switch(wParam) {
|
||||||
|
|
Loading…
Reference in New Issue