mirror of https://github.com/OpenRCT2/OpenRCT2.git
Chat: Improve 3d edge style + initial test for clipping the text.
This commit is contained in:
parent
9ec3fbc39b
commit
c52747bc93
|
@ -25,7 +25,7 @@
|
|||
#include "../interface/themes.h"
|
||||
|
||||
#define CHAT_HISTORY_SIZE 10
|
||||
#define CHAT_INPUT_SIZE 256
|
||||
#define CHAT_INPUT_SIZE 150
|
||||
|
||||
bool gChatOpen = false;
|
||||
char _chatCurrentLine[CHAT_INPUT_SIZE];
|
||||
|
@ -81,8 +81,13 @@ void chat_draw(rct_drawpixelinfo * dpi)
|
|||
gChatOpen = false;
|
||||
return;
|
||||
}
|
||||
|
||||
_chatLeft = 10;
|
||||
_chatTop = gScreenHeight - 45;
|
||||
_chatRight = gScreenWidth - 10;
|
||||
_chatBottom = gScreenHeight - 45;
|
||||
|
||||
//Dynamic background (auto-resizable, depending of the chat history).
|
||||
if (_chatHistoryIndex < CHAT_HISTORY_SIZE && _chatHistoryIndex > 5) {
|
||||
_chatTop -= ((_chatHistoryIndex + 1) * 15);
|
||||
} else if (_chatHistoryIndex <= 5) {
|
||||
|
@ -90,17 +95,17 @@ void chat_draw(rct_drawpixelinfo * dpi)
|
|||
} else {
|
||||
_chatTop -= ((CHAT_HISTORY_SIZE + 1) * 15);
|
||||
}
|
||||
_chatRight = gScreenWidth - 10;
|
||||
_chatBottom = gScreenHeight - 45;
|
||||
char lineBuffer[CHAT_INPUT_SIZE + 10];
|
||||
char* lineCh = lineBuffer;
|
||||
int x = _chatLeft + 5;
|
||||
int y = _chatBottom - (15 * 2);
|
||||
|
||||
//Max width
|
||||
if (_chatRight > 500) {
|
||||
_chatRight = 500;
|
||||
}
|
||||
|
||||
uint8 chatBackgroundColor = theme_get_colour(WC_CHAT, 0);
|
||||
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
|
||||
gCurrentFontFlags = 0;
|
||||
|
||||
if (gChatOpen) {
|
||||
gfx_set_dirty_blocks(_chatLeft, _chatTop - 5, _chatRight, _chatBottom + 5); //Background area + Textbox
|
||||
//TODO: Cleanup
|
||||
gfx_fill_rect(
|
||||
dpi,
|
||||
_chatLeft,
|
||||
|
@ -108,7 +113,7 @@ void chat_draw(rct_drawpixelinfo * dpi)
|
|||
_chatRight,
|
||||
_chatBottom + 5,
|
||||
0x2000000 | 51
|
||||
); //Simulate window background (gray background).
|
||||
);
|
||||
gfx_fill_rect_inset(
|
||||
dpi,
|
||||
_chatLeft,
|
||||
|
@ -129,28 +134,53 @@ void chat_draw(rct_drawpixelinfo * dpi)
|
|||
);
|
||||
gfx_fill_rect_inset(
|
||||
dpi,
|
||||
x - 1,
|
||||
_chatBottom - 15,
|
||||
_chatRight + 1,
|
||||
_chatBottom + 1,
|
||||
_chatLeft + 1,
|
||||
_chatTop - 4,
|
||||
_chatRight - 1,
|
||||
_chatBottom - 16,
|
||||
chatBackgroundColor,
|
||||
0x20
|
||||
0x30
|
||||
);
|
||||
gfx_fill_rect_inset(
|
||||
dpi,
|
||||
_chatLeft + 1,
|
||||
_chatBottom - 15,
|
||||
_chatRight - 1,
|
||||
_chatBottom + 4,
|
||||
chatBackgroundColor,
|
||||
0x30
|
||||
); //Textbox
|
||||
}
|
||||
|
||||
char lineBuffer[CHAT_INPUT_SIZE + 10];
|
||||
char* lineCh = lineBuffer;
|
||||
int x = _chatLeft + 5;
|
||||
int y = _chatBottom - (15 * 2);
|
||||
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
|
||||
gCurrentFontFlags = 0;
|
||||
|
||||
for (int i = 0; i < CHAT_HISTORY_SIZE; i++, y -= 15) {
|
||||
if (!gChatOpen && SDL_TICKS_PASSED(SDL_GetTicks(), chat_history_get_time(i) + 10000)) {
|
||||
break;
|
||||
}
|
||||
|
||||
safe_strcpy(lineBuffer, chat_history_get(i), CHAT_INPUT_SIZE + 10);
|
||||
gfx_set_dirty_blocks(x, y, x + gfx_get_string_width(lineBuffer), y + 12);
|
||||
|
||||
gfx_clip_string(lineBuffer, _chatRight - _chatLeft - 10);
|
||||
|
||||
gfx_set_dirty_blocks(x, y, x + gfx_get_string_width(lineBuffer), y + 12); //clipping text not yet implemented, this is still required
|
||||
gfx_draw_string(dpi, lineBuffer, 255, x, y);
|
||||
}
|
||||
|
||||
if (gChatOpen) {
|
||||
lineCh = utf8_write_codepoint(lineCh, FORMAT_OUTLINE);
|
||||
lineCh = utf8_write_codepoint(lineCh, FORMAT_CELADON);
|
||||
safe_strcpy(lineCh, _chatCurrentLine, CHAT_INPUT_SIZE);
|
||||
y = _chatBottom - 15;
|
||||
|
||||
gfx_set_dirty_blocks(x, y, x + gfx_get_string_width(lineBuffer), y + 12);
|
||||
gfx_draw_string(dpi, lineBuffer, 255, x, y + 3);
|
||||
|
||||
if (_chatCaretTicks < 15) {
|
||||
memcpy(lineBuffer, _chatCurrentLine, gTextInput.selection_offset);
|
||||
lineBuffer[gTextInput.selection_offset] = 0;
|
||||
|
|
Loading…
Reference in New Issue