mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-23 06:44:38 +01:00
Replace our own integer types with standard ones
This commit is contained in:
@@ -21,19 +21,19 @@
|
||||
bool gChatOpen = false;
|
||||
static char _chatCurrentLine[CHAT_MAX_MESSAGE_LENGTH];
|
||||
static char _chatHistory[CHAT_HISTORY_SIZE][CHAT_INPUT_SIZE];
|
||||
static uint32 _chatHistoryTime[CHAT_HISTORY_SIZE];
|
||||
static uint32 _chatHistoryIndex = 0;
|
||||
static uint32 _chatCaretTicks = 0;
|
||||
static sint32 _chatLeft;
|
||||
static sint32 _chatTop;
|
||||
static sint32 _chatRight;
|
||||
static sint32 _chatBottom;
|
||||
static sint32 _chatWidth;
|
||||
static sint32 _chatHeight;
|
||||
static uint32_t _chatHistoryTime[CHAT_HISTORY_SIZE];
|
||||
static uint32_t _chatHistoryIndex = 0;
|
||||
static uint32_t _chatCaretTicks = 0;
|
||||
static int32_t _chatLeft;
|
||||
static int32_t _chatTop;
|
||||
static int32_t _chatRight;
|
||||
static int32_t _chatBottom;
|
||||
static int32_t _chatWidth;
|
||||
static int32_t _chatHeight;
|
||||
static TextInputSession * _chatTextInputSession;
|
||||
|
||||
static const char* chat_history_get(uint32 index);
|
||||
static uint32 chat_history_get_time(uint32 index);
|
||||
static const char* chat_history_get(uint32_t index);
|
||||
static uint32_t chat_history_get_time(uint32_t index);
|
||||
static void chat_clear_input();
|
||||
|
||||
void chat_open()
|
||||
@@ -69,7 +69,7 @@ void chat_update()
|
||||
_chatCaretTicks = (_chatCaretTicks + 1) % 30;
|
||||
}
|
||||
|
||||
void chat_draw(rct_drawpixelinfo * dpi, uint8 chatBackgroundColor)
|
||||
void chat_draw(rct_drawpixelinfo * dpi, uint8_t chatBackgroundColor)
|
||||
{
|
||||
if (network_get_mode() == NETWORK_MODE_NONE || network_get_status() != NETWORK_STATUS_CONNECTED || network_get_authstatus() != NETWORK_AUTH_OK) {
|
||||
gChatOpen = false;
|
||||
@@ -85,21 +85,21 @@ void chat_draw(rct_drawpixelinfo * dpi, uint8 chatBackgroundColor)
|
||||
char lineBuffer[CHAT_INPUT_SIZE + 10];
|
||||
char* lineCh = lineBuffer;
|
||||
char* inputLine = _chatCurrentLine;
|
||||
sint32 inputLineHeight = 10;
|
||||
int32_t inputLineHeight = 10;
|
||||
|
||||
// Draw chat window
|
||||
if (gChatOpen) {
|
||||
inputLineHeight = chat_string_wrapped_get_height((void*)&inputLine, _chatWidth - 10);
|
||||
_chatTop -= inputLineHeight;
|
||||
|
||||
for (sint32 i = 0; i < CHAT_HISTORY_SIZE; i++) {
|
||||
for (int32_t i = 0; i < CHAT_HISTORY_SIZE; i++) {
|
||||
if (strlen(chat_history_get(i)) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
safe_strcpy(lineBuffer, chat_history_get(i), sizeof(lineBuffer));
|
||||
|
||||
sint32 lineHeight = chat_string_wrapped_get_height((void*)&lineCh, _chatWidth - 10);
|
||||
int32_t lineHeight = chat_string_wrapped_get_height((void*)&lineCh, _chatWidth - 10);
|
||||
_chatTop -= (lineHeight + 5);
|
||||
}
|
||||
|
||||
@@ -119,13 +119,13 @@ void chat_draw(rct_drawpixelinfo * dpi, uint8 chatBackgroundColor)
|
||||
gfx_fill_rect_inset(dpi, _chatLeft + 1, _chatBottom - inputLineHeight - 5, _chatRight - 1, _chatBottom + 4, chatBackgroundColor, INSET_RECT_FLAG_BORDER_INSET); // Textbox
|
||||
}
|
||||
|
||||
sint32 x = _chatLeft + 5;
|
||||
sint32 y = _chatBottom - inputLineHeight - 20;
|
||||
sint32 stringHeight = 0;
|
||||
int32_t x = _chatLeft + 5;
|
||||
int32_t y = _chatBottom - inputLineHeight - 20;
|
||||
int32_t stringHeight = 0;
|
||||
|
||||
// Draw chat history
|
||||
for (sint32 i = 0; i < CHAT_HISTORY_SIZE; i++, y -= stringHeight) {
|
||||
uint32 expireTime = chat_history_get_time(i) + 10000;
|
||||
for (int32_t i = 0; i < CHAT_HISTORY_SIZE; i++, y -= stringHeight) {
|
||||
uint32_t expireTime = chat_history_get_time(i) + 10000;
|
||||
if (!gChatOpen && platform_get_ticks() > expireTime) {
|
||||
break;
|
||||
}
|
||||
@@ -156,8 +156,8 @@ void chat_draw(rct_drawpixelinfo * dpi, uint8 chatBackgroundColor)
|
||||
if (_chatCaretTicks < 15 && gfx_get_string_width(lineBuffer) < (_chatWidth - 10)) {
|
||||
memcpy(lineBuffer, _chatCurrentLine, _chatTextInputSession->SelectionStart);
|
||||
lineBuffer[_chatTextInputSession->SelectionStart] = 0;
|
||||
sint32 caretX = x + gfx_get_string_width(lineBuffer);
|
||||
sint32 caretY = y + 14;
|
||||
int32_t caretX = x + gfx_get_string_width(lineBuffer);
|
||||
int32_t caretY = y + 14;
|
||||
|
||||
gfx_fill_rect(dpi, caretX, caretY, caretX + 6, caretY + 1, PALETTE_INDEX_56);
|
||||
}
|
||||
@@ -172,7 +172,7 @@ void chat_history_add(const char * src)
|
||||
// Find the start of the text (after format codes)
|
||||
const char * ch = src;
|
||||
const char * nextCh;
|
||||
uint32 codepoint;
|
||||
uint32_t codepoint;
|
||||
while ((codepoint = utf8_get_next(ch, &nextCh)) != 0) {
|
||||
if (!utf8_is_format_code(codepoint)) {
|
||||
break;
|
||||
@@ -193,7 +193,7 @@ void chat_history_add(const char * src)
|
||||
safe_strcat(buffer, srcText, bufferSize);
|
||||
|
||||
// Add to history list
|
||||
sint32 index = _chatHistoryIndex % CHAT_HISTORY_SIZE;
|
||||
int32_t index = _chatHistoryIndex % CHAT_HISTORY_SIZE;
|
||||
memset(_chatHistory[index], 0, CHAT_INPUT_SIZE);
|
||||
memcpy(_chatHistory[index], buffer, std::min<size_t>(strlen(buffer), CHAT_INPUT_SIZE - 1));
|
||||
_chatHistoryTime[index] = platform_get_ticks();
|
||||
@@ -225,12 +225,12 @@ void chat_input(CHAT_INPUT input)
|
||||
}
|
||||
}
|
||||
|
||||
static const char* chat_history_get(uint32 index)
|
||||
static const char* chat_history_get(uint32_t index)
|
||||
{
|
||||
return _chatHistory[(_chatHistoryIndex + CHAT_HISTORY_SIZE - index - 1) % CHAT_HISTORY_SIZE];
|
||||
}
|
||||
|
||||
static uint32 chat_history_get_time(uint32 index)
|
||||
static uint32_t chat_history_get_time(uint32_t index)
|
||||
{
|
||||
return _chatHistoryTime[(_chatHistoryIndex + CHAT_HISTORY_SIZE - index - 1) % CHAT_HISTORY_SIZE];
|
||||
}
|
||||
@@ -242,9 +242,9 @@ static void chat_clear_input()
|
||||
|
||||
// This method is the same as gfx_draw_string_left_wrapped.
|
||||
// But this adjusts the initial Y coordinate depending of the number of lines.
|
||||
sint32 chat_history_draw_string(rct_drawpixelinfo *dpi, void *args, sint32 x, sint32 y, sint32 width)
|
||||
int32_t chat_history_draw_string(rct_drawpixelinfo *dpi, void *args, int32_t x, int32_t y, int32_t width)
|
||||
{
|
||||
sint32 fontSpriteBase, lineHeight, lineY, numLines;
|
||||
int32_t fontSpriteBase, lineHeight, lineY, numLines;
|
||||
|
||||
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
|
||||
|
||||
@@ -258,13 +258,13 @@ sint32 chat_history_draw_string(rct_drawpixelinfo *dpi, void *args, sint32 x, si
|
||||
|
||||
gCurrentFontFlags = 0;
|
||||
|
||||
sint32 expectedY = y - (numLines * lineHeight);
|
||||
int32_t expectedY = y - (numLines * lineHeight);
|
||||
if (expectedY < 50) {
|
||||
return (numLines * lineHeight); // Skip drawing, return total height.
|
||||
}
|
||||
|
||||
lineY = y;
|
||||
for (sint32 line = 0; line <= numLines; ++line) {
|
||||
for (int32_t line = 0; line <= numLines; ++line) {
|
||||
gfx_draw_string(dpi, buffer, TEXT_COLOUR_254, x, lineY - (numLines * lineHeight));
|
||||
buffer = get_string_end(buffer) + 1;
|
||||
lineY += lineHeight;
|
||||
@@ -274,9 +274,9 @@ sint32 chat_history_draw_string(rct_drawpixelinfo *dpi, void *args, sint32 x, si
|
||||
|
||||
// Wrap string without drawing, useful to get the height of a wrapped string.
|
||||
// Almost the same as gfx_draw_string_left_wrapped
|
||||
sint32 chat_string_wrapped_get_height(void *args, sint32 width)
|
||||
int32_t chat_string_wrapped_get_height(void *args, int32_t width)
|
||||
{
|
||||
sint32 fontSpriteBase, lineHeight, lineY, numLines;
|
||||
int32_t fontSpriteBase, lineHeight, lineY, numLines;
|
||||
|
||||
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
|
||||
|
||||
@@ -290,7 +290,7 @@ sint32 chat_string_wrapped_get_height(void *args, sint32 width)
|
||||
gCurrentFontFlags = 0;
|
||||
|
||||
lineY = 0;
|
||||
for (sint32 line = 0; line <= numLines; ++line) {
|
||||
for (int32_t line = 0; line <= numLines; ++line) {
|
||||
buffer = get_string_end(buffer) + 1;
|
||||
lineY += lineHeight;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user