mirror of https://github.com/OpenRCT2/OpenRCT2.git
Fixed console cursor rendering. (#13025)
Co-authored-by: Tulio Leao <tupaschoal@gmail.com>
This commit is contained in:
parent
61b510db66
commit
2524e9201a
|
@ -11,6 +11,7 @@
|
|||
- Fix: [#8957] Error title missing when building with insufficient funds
|
||||
- Fix: [#10186] Placing multiple saved rides ignores design name (original bug).
|
||||
- Fix: [#13021] Mowed grass and weeds don't show up in extra zoom levels.
|
||||
- Fix: [#13024] Console cursor does not correctly render at current cursor position.
|
||||
- Fix: [#13029] Not all Junior Roller Coaster pieces are shown when "Show all track pieces" cheat is enabled.
|
||||
- Fix: [#13044] Rides in RCT1 saves all have "0 customers per hour".
|
||||
- Fix: [#13074] Entrance and exit ghosts for mazes not being removed.
|
||||
|
|
|
@ -93,7 +93,7 @@ void TextComposition::HandleMessage(const SDL_Event* e)
|
|||
Insert(newText);
|
||||
Memory::Free(newText);
|
||||
|
||||
console.RefreshCaret();
|
||||
console.RefreshCaret(_session.SelectionStart);
|
||||
window_update_textbox();
|
||||
}
|
||||
break;
|
||||
|
@ -126,7 +126,7 @@ void TextComposition::HandleMessage(const SDL_Event* e)
|
|||
if (key == SDLK_BACKSPACE && (modifier & KEYBOARD_PRIMARY_MODIFIER))
|
||||
{
|
||||
Clear();
|
||||
console.RefreshCaret();
|
||||
console.RefreshCaret(_session.SelectionStart);
|
||||
window_update_textbox();
|
||||
}
|
||||
|
||||
|
@ -141,17 +141,17 @@ void TextComposition::HandleMessage(const SDL_Event* e)
|
|||
_session.SelectionSize = endOffset - _session.SelectionStart;
|
||||
Delete();
|
||||
|
||||
console.RefreshCaret();
|
||||
console.RefreshCaret(_session.SelectionStart);
|
||||
window_update_textbox();
|
||||
}
|
||||
break;
|
||||
case SDLK_HOME:
|
||||
CursorHome();
|
||||
console.RefreshCaret();
|
||||
console.RefreshCaret(_session.SelectionStart);
|
||||
break;
|
||||
case SDLK_END:
|
||||
CursorEnd();
|
||||
console.RefreshCaret();
|
||||
console.RefreshCaret(_session.SelectionStart);
|
||||
break;
|
||||
case SDLK_DELETE:
|
||||
{
|
||||
|
@ -160,7 +160,7 @@ void TextComposition::HandleMessage(const SDL_Event* e)
|
|||
_session.SelectionSize = _session.SelectionStart - startOffset;
|
||||
_session.SelectionStart = startOffset;
|
||||
Delete();
|
||||
console.RefreshCaret();
|
||||
console.RefreshCaret(_session.SelectionStart);
|
||||
window_update_textbox();
|
||||
break;
|
||||
}
|
||||
|
@ -169,11 +169,11 @@ void TextComposition::HandleMessage(const SDL_Event* e)
|
|||
break;
|
||||
case SDLK_LEFT:
|
||||
CursorLeft();
|
||||
console.RefreshCaret();
|
||||
console.RefreshCaret(_session.SelectionStart);
|
||||
break;
|
||||
case SDLK_RIGHT:
|
||||
CursorRight();
|
||||
console.RefreshCaret();
|
||||
console.RefreshCaret(_session.SelectionStart);
|
||||
break;
|
||||
case SDLK_c:
|
||||
if ((modifier & KEYBOARD_PRIMARY_MODIFIER) && _session.Length)
|
||||
|
|
|
@ -134,9 +134,13 @@ void InGameConsole::ScrollToEnd()
|
|||
_consoleScrollPos = std::max<int32_t>(0, static_cast<int32_t>(_consoleLines.size()) - maxLines);
|
||||
}
|
||||
|
||||
void InGameConsole::RefreshCaret()
|
||||
void InGameConsole::RefreshCaret(size_t position)
|
||||
{
|
||||
_consoleCaretTicks = 0;
|
||||
_selectionStart = position;
|
||||
char tempString[TEXT_INPUT_SIZE] = { 0 };
|
||||
std::memcpy(tempString, &_consoleCurrentLine, _selectionStart);
|
||||
_caretScreenPosX = gfx_get_string_width(tempString);
|
||||
}
|
||||
|
||||
void InGameConsole::Scroll(int32_t linesToScroll)
|
||||
|
@ -325,10 +329,9 @@ void InGameConsole::Draw(rct_drawpixelinfo* dpi) const
|
|||
// Draw caret
|
||||
if (_consoleCaretTicks < CONSOLE_CARET_FLASH_THRESHOLD)
|
||||
{
|
||||
auto caret = screenCoords + ScreenCoordsXY{ gfx_get_string_width(_consoleCurrentLine), lineHeight };
|
||||
|
||||
auto caret = screenCoords + ScreenCoordsXY{ _caretScreenPosX, lineHeight };
|
||||
uint8_t caretColour = ColourMapA[BASE_COLOUR(textColour)].lightest;
|
||||
gfx_fill_rect(dpi, { caret, caret + ScreenCoordsXY{ CONSOLE_CARET_WIDTH, 0 } }, caretColour);
|
||||
gfx_fill_rect(dpi, { caret, caret + ScreenCoordsXY{ CONSOLE_CARET_WIDTH, 1 } }, caretColour);
|
||||
}
|
||||
|
||||
// What about border colours?
|
||||
|
|
|
@ -35,6 +35,8 @@ namespace OpenRCT2::Ui
|
|||
utf8 _consoleHistory[CONSOLE_HISTORY_SIZE][CONSOLE_INPUT_SIZE];
|
||||
int32_t _consoleHistoryIndex = 0;
|
||||
int32_t _consoleHistoryCount = 0;
|
||||
size_t _selectionStart = 0;
|
||||
int32_t _caretScreenPosX = 0;
|
||||
|
||||
public:
|
||||
InGameConsole();
|
||||
|
@ -53,7 +55,7 @@ namespace OpenRCT2::Ui
|
|||
void WriteLine(const std::string& s, uint32_t colourFormat) override;
|
||||
|
||||
void Input(ConsoleInput input);
|
||||
void RefreshCaret();
|
||||
void RefreshCaret(size_t position = 0);
|
||||
void Scroll(int32_t linesToScroll);
|
||||
|
||||
void Update();
|
||||
|
|
Loading…
Reference in New Issue