Remove need of SDL in chat.c

This commit is contained in:
Ted John 2017-06-10 16:19:46 +01:00
parent a9e5a58d28
commit 9cd8fd1498
3 changed files with 33 additions and 8 deletions

View File

@ -1419,6 +1419,22 @@ static void input_handle_console(sint32 key)
}
}
static void input_handle_chat(sint32 key)
{
CHAT_INPUT input = CHAT_INPUT_NONE;
switch (key) {
case SDL_SCANCODE_ESCAPE:
input = CHAT_INPUT_CLOSE;
break;
case SDL_SCANCODE_RETURN:
input = CHAT_INPUT_SEND;
break;
}
if (input != CHAT_INPUT_NONE) {
chat_input(input);
}
}
/**
*
* rct2: 0x006E3B43
@ -1540,7 +1556,7 @@ void game_handle_keyboard_input()
input_handle_console(key);
continue;
} else if (gChatOpen) {
chat_input(key);
input_handle_chat(key);
continue;
}

View File

@ -215,19 +215,21 @@ void chat_history_add(const char * src)
Mixer_Play_Effect(SOUND_NEWS_ITEM, 0, SDL_MIX_MAXVOLUME, 0, 1.5f, true);
}
void chat_input(sint32 c)
void chat_input(CHAT_INPUT input)
{
switch (c) {
case SDL_SCANCODE_RETURN:
switch (input) {
case CHAT_INPUT_SEND:
if (strlen(_chatCurrentLine) > 0) {
network_send_chat(_chatCurrentLine);
}
chat_clear_input();
chat_close();
return;
case SDL_SCANCODE_ESCAPE:
break;
case CHAT_INPUT_CLOSE:
chat_close();
return;
break;
default:
break;
}
}

View File

@ -25,6 +25,13 @@
#define CHAT_MAX_MESSAGE_LENGTH 200
#define CHAT_MAX_WINDOW_WIDTH 600
typedef enum CHAT_INPUT
{
CHAT_INPUT_NONE,
CHAT_INPUT_SEND,
CHAT_INPUT_CLOSE,
} CHAT_INPUT;
extern bool gChatOpen;
void chat_open();
@ -36,7 +43,7 @@ void chat_update();
void chat_draw(rct_drawpixelinfo * dpi);
void chat_history_add(const char *src);
void chat_input(sint32 c);
void chat_input(CHAT_INPUT input);
sint32 chat_string_wrapped_get_height(void *args, sint32 width);
sint32 chat_history_draw_string(rct_drawpixelinfo *dpi, void *args, sint32 x, sint32 y, sint32 width);