(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)

pull/155/head
darkvater 20 years ago
parent 56fa1a8534
commit 5505a10b80

File diff suppressed because it is too large Load Diff

@ -1,63 +1,82 @@
// ** console ** //
enum {
ICONSOLE_OPENED=0,
ICONSOLE_CLOSED,
ICONSOLE_OPENING,
ICONSOLE_CLOSING,
} _iconsole_modes;
// ** console parser ** //
enum {
ICONSOLE_VAR_NONE=0,
ICONSOLE_VAR_BOOLEAN,
ICONSOLE_VAR_BYTE,
ICONSOLE_VAR_UINT16,
ICONSOLE_VAR_UINT32,
ICONSOLE_VAR_INT16,
ICONSOLE_VAR_INT32,
ICONSOLE_VAR_STRING,
ICONSOLE_VAR_VARPTR,
ICONSOLE_VAR_POINTER,
ICONSOLE_VAR_UNKNOWN
} _iconsole_var_types;
typedef struct {
// -------------- //
void * addr;
byte * name;
// -------------- //
void * _next;
} _iconsole_cmd;
typedef struct {
// --------------- //
void * addr;
byte * name;
byte type;
// -------------- //
void * _next;
} _iconsole_var;
// ** ttd.c functions ** //
void SetDebugString(const char *s);
// ** console functions ** //
void IConsoleClearCommand();
void IConsoleInit();
void IConsoleClear();
void IConsoleFree();
void IConsoleResize();
void IConsoleSwitch();
void IConsoleClose();
void IConsoleOpen();
void IConsolePrint(byte color_code, byte* string);
void IConsolePrintF(byte color_code, const char *s, ...);
void IConsoleDebug(byte* string);
void IConsoleError(byte* string);
void IConsoleCmdRegister(byte * name, void * addr);
void IConsoleVarRegister(byte * name, void * addr, byte type);
void IConsoleCmdExec(byte * cmdstr);
// ** console ** //
enum {
ICONSOLE_OPENED=0,
ICONSOLE_CLOSED,
ICONSOLE_OPENING,
ICONSOLE_CLOSING,
} _iconsole_modes;
// ** console parser ** //
enum {
ICONSOLE_VAR_NONE=0,
ICONSOLE_VAR_BOOLEAN,
ICONSOLE_VAR_BYTE,
ICONSOLE_VAR_UINT16,
ICONSOLE_VAR_UINT32,
ICONSOLE_VAR_INT16,
ICONSOLE_VAR_INT32,
ICONSOLE_VAR_STRING,
ICONSOLE_VAR_POINTER,
ICONSOLE_VAR_UNKNOWN
} _iconsole_var_types;
typedef struct {
// -------------- //
void * addr;
byte * name;
// -------------- //
void * _next;
} _iconsole_cmd;
typedef struct {
// --------------- //
void * addr;
byte * name;
byte type;
// -------------- //
void * _next;
bool _malloc;
} _iconsole_var;
// ** ttd.c functions ** //
void SetDebugString(const char *s);
// ** console functions ** //
void IConsoleClearCommand();
void IConsoleInit();
void IConsoleClear();
void IConsoleFree();
void IConsoleResize();
void IConsoleSwitch();
void IConsoleClose();
void IConsoleOpen();
// ** console output ** //
void IConsolePrint(byte color_code, byte* string);
void IConsolePrintF(byte color_code, const char *s, ...);
void IConsoleDebug(byte* string);
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_CTRL | 'S': _make_screenshot = 1; 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;
}
} break;

@ -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)
#if defined(WIN32)
if (sym->scancode == 41) key |= WKC_BACKQUOTE;
#else
if (sym->scancode == 49) key |= WKC_BACKQUOTE;
#endif
// META are the command keys on mac
if (sym->mod & KMOD_META) key |= WKC_META;
if (sym->mod & KMOD_SHIFT) key |= WKC_SHIFT;

@ -107,6 +107,8 @@ static const VkMapping _vk_mapping[] = {
AM('A','Z','A','Z'),
AM('0','9','0','9'),
AS(220, WKC_BACKQUOTE),
AS(VK_ESCAPE, WKC_ESC),
AS(VK_BACK, WKC_BACKSPACE),
AM(VK_INSERT,VK_DELETE,WKC_INSERT, WKC_DELETE),
@ -136,10 +138,13 @@ static uint MapWindowsKey(uint key)
do {
map++;
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);
key = key - from + map->map_to;
if (GetAsyncKeyState(VK_SHIFT)<0) key |= WKC_SHIFT;
if (GetAsyncKeyState(VK_CONTROL)<0) key |= WKC_CTRL;
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:
_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) {
_double_size ^= 1;
_wnd.double_size = _double_size;
ClientSizeChanged(_wnd.width, _wnd.height);
MarkWholeScreenDirty();
}
break;
break;
case WM_CHAR:
_pressed_key |= wParam;
break;
case WM_SYSKEYDOWN:
switch(wParam) {

Loading…
Cancel
Save