From 9ec3fbc39b7fec87b9f4947d4d2ea2ed29083eb9 Mon Sep 17 00:00:00 2001 From: Wirlie Date: Tue, 21 Jun 2016 01:48:14 -0500 Subject: [PATCH] Chat: Add colour scheme (themes) + 3d edge style. --- data/language/en-GB.txt | 1 + src/interface/Theme.cpp | 1 + src/interface/chat.c | 50 +++++++++++++++++++++++++++-------- src/interface/window.h | 1 + src/localisation/string_ids.h | 1 + src/windows/themes.c | 1 + 6 files changed, 44 insertions(+), 11 deletions(-) diff --git a/data/language/en-GB.txt b/data/language/en-GB.txt index b2c58def40..2ab14955eb 100644 --- a/data/language/en-GB.txt +++ b/data/language/en-GB.txt @@ -4221,6 +4221,7 @@ STR_5909 :{SMALLFONT}{BLACK}Allows changing ride type freely. May cause crash STR_5910 :Apply STR_5911 :See-Through Paths STR_5912 :See-through paths toggle +STR_5913 :Chat ############# # Scenarios # diff --git a/src/interface/Theme.cpp b/src/interface/Theme.cpp index 77bedbad39..9404cafb0e 100644 --- a/src/interface/Theme.cpp +++ b/src/interface/Theme.cpp @@ -173,6 +173,7 @@ WindowThemeDesc WindowThemeDescriptors[] = { THEME_WC(WC_PLAYER), STR_THEMES_WINDOW_PLAYER, COLOURS_3(COLOUR_LIGHT_BLUE, COLOUR_LIGHT_BLUE, COLOUR_LIGHT_BLUE ) }, { THEME_WC(WC_NETWORK_STATUS), STR_THEMES_WINDOW_NETWORK_STATUS, COLOURS_1(COLOUR_LIGHT_BLUE ) }, { THEME_WC(WC_SERVER_LIST), STR_SERVER_LIST, COLOURS_2(COLOUR_LIGHT_BLUE, COLOUR_LIGHT_BLUE ) }, + { THEME_WC(WC_CHAT), STR_CHAT, COLOURS_1(TRANSLUCENT(COLOUR_GREY) ) }, }; #pragma endregion diff --git a/src/interface/chat.c b/src/interface/chat.c index e74811e7b0..b46eb5ee46 100644 --- a/src/interface/chat.c +++ b/src/interface/chat.c @@ -22,6 +22,7 @@ #include "../platform/platform.h" #include "chat.h" #include "../util/util.h" +#include "../interface/themes.h" #define CHAT_HISTORY_SIZE 10 #define CHAT_INPUT_SIZE 256 @@ -93,18 +94,48 @@ void chat_draw(rct_drawpixelinfo * dpi) _chatBottom = gScreenHeight - 45; char lineBuffer[CHAT_INPUT_SIZE + 10]; char* lineCh = lineBuffer; - int x = _chatLeft; + int x = _chatLeft + 5; int y = _chatBottom - (15 * 2); + uint8 chatBackgroundColor = theme_get_colour(WC_CHAT, 0); gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM; gCurrentFontFlags = 0; - if (gChatOpen) { - gfx_set_dirty_blocks(_chatLeft - 3, _chatTop - 3, _chatRight + 3, _chatBottom + 3); //Background area + Textbox - gfx_fill_rect(dpi, _chatLeft - 3, _chatTop - 3, _chatRight + 3, _chatBottom - 15, 0x2000000 | 46); //Draw background below text only if the chat is opened. - gfx_fill_rect(dpi, _chatLeft - 3, _chatTop - 3, _chatRight + 3, _chatTop - 2, 11); //Border top - gfx_fill_rect(dpi, _chatLeft - 3, _chatBottom + 2, _chatRight + 3, _chatBottom + 3, 11); //Border bottom - gfx_fill_rect(dpi, _chatRight + 2, _chatTop - 3, _chatRight + 3, _chatBottom + 3, 11); //Border right - gfx_fill_rect(dpi, _chatLeft - 3, _chatTop - 3, _chatLeft - 2, _chatBottom + 3, 11); //Border left + gfx_set_dirty_blocks(_chatLeft, _chatTop - 5, _chatRight, _chatBottom + 5); //Background area + Textbox + gfx_fill_rect( + dpi, + _chatLeft, + _chatTop - 5, + _chatRight, + _chatBottom + 5, + 0x2000000 | 51 + ); //Simulate window background (gray background). + gfx_fill_rect_inset( + dpi, + _chatLeft, + _chatTop - 5, + _chatRight, + _chatBottom + 5, + chatBackgroundColor, + 0x10 + ); + gfx_fill_rect_inset( + dpi, + _chatLeft + 1, + _chatTop - 4, + _chatRight - 1, + _chatBottom + 4, + chatBackgroundColor, + 0x20 + ); + gfx_fill_rect_inset( + dpi, + x - 1, + _chatBottom - 15, + _chatRight + 1, + _chatBottom + 1, + chatBackgroundColor, + 0x20 + ); //Textbox } for (int i = 0; i < CHAT_HISTORY_SIZE; i++, y -= 15) { if (!gChatOpen && SDL_TICKS_PASSED(SDL_GetTicks(), chat_history_get_time(i) + 10000)) { @@ -119,9 +150,6 @@ void chat_draw(rct_drawpixelinfo * dpi) lineCh = utf8_write_codepoint(lineCh, FORMAT_CELADON); safe_strcpy(lineCh, _chatCurrentLine, CHAT_INPUT_SIZE); y = _chatBottom - 15; - - gfx_fill_rect(dpi, x - 1, y, _chatRight + 1, y + 16, 0x2000000 | 46); // Textbox background - gfx_fill_rect(dpi, x - 3, y - 1, _chatRight + 3, y, 10); //Textbox border top gfx_draw_string(dpi, lineBuffer, 255, x, y + 3); if (_chatCaretTicks < 15) { memcpy(lineBuffer, _chatCurrentLine, gTextInput.selection_offset); diff --git a/src/interface/window.h b/src/interface/window.h index 7ea08d9ee1..2d8ded764e 100644 --- a/src/interface/window.h +++ b/src/interface/window.h @@ -470,6 +470,7 @@ enum { WC_STAFF = 220, WC_EDITOR_TRACK_BOTTOM_TOOLBAR = 221, WC_EDITOR_SCENARIO_BOTTOM_TOOLBAR = 222, + WC_CHAT = 223, }; enum PROMPT_MODE { diff --git a/src/localisation/string_ids.h b/src/localisation/string_ids.h index 8f417e5074..04c92949fd 100644 --- a/src/localisation/string_ids.h +++ b/src/localisation/string_ids.h @@ -3345,6 +3345,7 @@ enum { STR_APPLY = 5910, STR_SEE_THROUGH_PATHS = 5911, STR_SHORTCUT_SEE_THROUGH_PATHS_TOGGLE = 5912, + STR_CHAT = 5913, // Have to include resource strings (from scenarios and objects) for the time being now that language is partially working STR_COUNT = 32768 diff --git a/src/windows/themes.c b/src/windows/themes.c index 443be56e3d..e973c664b3 100644 --- a/src/windows/themes.c +++ b/src/windows/themes.c @@ -245,6 +245,7 @@ static rct_windowclass window_themes_tab_6_classes[] = { WC_SERVER_LIST, WC_MULTIPLAYER, WC_PLAYER, + WC_CHAT, }; static rct_windowclass window_themes_tab_7_classes[] = {