mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-06 06:32:56 +01:00
Remove need of SDL in console.c
This commit is contained in:
@@ -1397,6 +1397,28 @@ static void input_update_tooltip(rct_window *w, rct_widgetindex widgetIndex, sin
|
||||
|
||||
#pragma region Keyboard input
|
||||
|
||||
static void input_handle_console(sint32 key)
|
||||
{
|
||||
CONSOLE_INPUT input = CONSOLE_INPUT_NONE;
|
||||
switch (key) {
|
||||
case SDL_SCANCODE_ESCAPE:
|
||||
input = CONSOLE_INPUT_LINE_CLEAR;
|
||||
break;
|
||||
case SDL_SCANCODE_RETURN:
|
||||
input = CONSOLE_INPUT_LINE_EXECUTE;
|
||||
break;
|
||||
case SDL_SCANCODE_UP:
|
||||
input = CONSOLE_INPUT_HISTORY_PREVIOUS;
|
||||
break;
|
||||
case SDL_SCANCODE_DOWN:
|
||||
input = CONSOLE_INPUT_HISTORY_NEXT;
|
||||
break;
|
||||
}
|
||||
if (input != CONSOLE_INPUT_NONE) {
|
||||
console_input(input);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006E3B43
|
||||
@@ -1439,7 +1461,7 @@ void title_handle_keyboard_input()
|
||||
}
|
||||
continue;
|
||||
} else if (gConsoleOpen) {
|
||||
console_input(key);
|
||||
input_handle_console(key);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1515,7 +1537,7 @@ void game_handle_keyboard_input()
|
||||
}
|
||||
continue;
|
||||
} else if (gConsoleOpen) {
|
||||
console_input(key);
|
||||
input_handle_console(key);
|
||||
continue;
|
||||
} else if (gChatOpen) {
|
||||
chat_input(key);
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#pragma endregion
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <SDL_scancode.h>
|
||||
|
||||
#include "../config/Config.h"
|
||||
#include "../Context.h"
|
||||
@@ -251,14 +250,14 @@ void console_draw(rct_drawpixelinfo *dpi)
|
||||
gfx_fill_rect(dpi, _consoleLeft, _consoleBottom - 0, _consoleRight, _consoleBottom - 0, PALETTE_INDEX_12);
|
||||
}
|
||||
|
||||
void console_input(sint32 c)
|
||||
void console_input(CONSOLE_INPUT input)
|
||||
{
|
||||
switch (c) {
|
||||
case SDL_SCANCODE_ESCAPE:
|
||||
switch (input) {
|
||||
case CONSOLE_INPUT_LINE_CLEAR:
|
||||
console_clear_input();
|
||||
console_refresh_caret();
|
||||
break;
|
||||
case SDL_SCANCODE_RETURN:
|
||||
case CONSOLE_INPUT_LINE_EXECUTE:
|
||||
if (_consoleCurrentLine[0] != 0) {
|
||||
console_history_add(_consoleCurrentLine);
|
||||
console_execute(_consoleCurrentLine);
|
||||
@@ -267,7 +266,7 @@ void console_input(sint32 c)
|
||||
console_refresh_caret();
|
||||
}
|
||||
break;
|
||||
case SDL_SCANCODE_UP:
|
||||
case CONSOLE_INPUT_HISTORY_PREVIOUS:
|
||||
if (_consoleHistoryIndex > 0) {
|
||||
_consoleHistoryIndex--;
|
||||
memcpy(_consoleCurrentLine, _consoleHistory[_consoleHistoryIndex], 256);
|
||||
@@ -276,7 +275,7 @@ void console_input(sint32 c)
|
||||
_consoleTextInputSession->Length = utf8_length(_consoleTextInputSession->Buffer);
|
||||
_consoleTextInputSession->SelectionStart = strlen(_consoleCurrentLine);
|
||||
break;
|
||||
case SDL_SCANCODE_DOWN:
|
||||
case CONSOLE_INPUT_HISTORY_NEXT:
|
||||
if (_consoleHistoryIndex < _consoleHistoryCount - 1) {
|
||||
_consoleHistoryIndex++;
|
||||
memcpy(_consoleCurrentLine, _consoleHistory[_consoleHistoryIndex], 256);
|
||||
@@ -288,6 +287,8 @@ void console_input(sint32 c)
|
||||
console_clear_input();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,15 @@
|
||||
#include "../common.h"
|
||||
#include "../drawing/drawing.h"
|
||||
|
||||
typedef enum CONSOLE_INPUT
|
||||
{
|
||||
CONSOLE_INPUT_NONE,
|
||||
CONSOLE_INPUT_LINE_CLEAR,
|
||||
CONSOLE_INPUT_LINE_EXECUTE,
|
||||
CONSOLE_INPUT_HISTORY_PREVIOUS,
|
||||
CONSOLE_INPUT_HISTORY_NEXT,
|
||||
} CONSOLE_INPUT;
|
||||
|
||||
extern bool gConsoleOpen;
|
||||
|
||||
void console_open();
|
||||
@@ -29,7 +38,7 @@ void console_toggle();
|
||||
void console_update();
|
||||
void console_draw(rct_drawpixelinfo *dpi);
|
||||
|
||||
void console_input(sint32 c);
|
||||
void console_input(CONSOLE_INPUT input);
|
||||
void console_write(const utf8 *src);
|
||||
void console_writeline(const utf8 *src);
|
||||
void console_writeline_error(const utf8 *src);
|
||||
|
||||
Reference in New Issue
Block a user