mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-11 10:02:27 +01:00
This commit fixes the graphics bug #23348 by introducing an asynchronous command completion signalling system in InteractiveConsole. This causes the console to stop accepting new inputs while a command is being executed. The console command system was also refactored to reduce code duplication and remove return codes, which were unused and also poor error handling.
This commit is contained in:
committed by
GitHub
parent
6ee798337a
commit
a3691982b3
@@ -246,6 +246,7 @@ Appreciation for contributors who have provided substantial work, but are no lon
|
||||
* Mike Harvey (harvito)
|
||||
* Robert Yan (lewyche)
|
||||
* Tom Matalenas (tmatale)
|
||||
* Brendan Heinonen (staticinvocation)
|
||||
|
||||
## Toolchain
|
||||
* (Balletie) - macOS
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
- Improved: [#23350] Increased the maximum width of the ride graph window.
|
||||
- Improved: [#23404] Folders are now paired with an icon in the load/save window.
|
||||
- Fix: [#23286] Currency formatted incorrectly in the in game console.
|
||||
- Fix: [#23348] Console set commands don't print output properly.
|
||||
|
||||
0.4.17 (2024-12-08)
|
||||
------------------------------------------------------------------------
|
||||
|
||||
@@ -54,6 +54,12 @@ void InGameConsole::WritePrompt()
|
||||
|
||||
void InGameConsole::Input(ConsoleInput input)
|
||||
{
|
||||
if (_isCommandAwaitingCompletion)
|
||||
{
|
||||
// Do not process input while a command is running
|
||||
return;
|
||||
}
|
||||
|
||||
switch (input)
|
||||
{
|
||||
case ConsoleInput::LineClear:
|
||||
@@ -69,7 +75,14 @@ void InGameConsole::Input(ConsoleInput input)
|
||||
_consoleLines.back().append(_consoleCurrentLine);
|
||||
|
||||
Execute(_consoleCurrentLine);
|
||||
WritePrompt();
|
||||
if (IsExecuting())
|
||||
{
|
||||
_isCommandAwaitingCompletion = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
WritePrompt();
|
||||
}
|
||||
ClearInput();
|
||||
RefreshCaret();
|
||||
}
|
||||
@@ -271,6 +284,12 @@ void InGameConsole::Update()
|
||||
}
|
||||
}
|
||||
|
||||
if (_isCommandAwaitingCompletion && !IsExecuting())
|
||||
{
|
||||
WritePrompt();
|
||||
_isCommandAwaitingCompletion = false;
|
||||
}
|
||||
|
||||
// Flash the caret
|
||||
_consoleCaretTicks = (_consoleCaretTicks + 1) % 30;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace OpenRCT2::Ui
|
||||
|
||||
bool _isInitialised = false;
|
||||
bool _isOpen = false;
|
||||
bool _isCommandAwaitingCompletion = false;
|
||||
ScreenCoordsXY _consoleTopLeft;
|
||||
ScreenCoordsXY _consoleBottomRight;
|
||||
ScreenCoordsXY _lastMainViewport;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "../localisation/FormatCodes.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
@@ -30,6 +31,9 @@ enum class ConsoleInput : uint8_t
|
||||
|
||||
class InteractiveConsole
|
||||
{
|
||||
private:
|
||||
std::atomic_flag _commandExecuting;
|
||||
|
||||
public:
|
||||
virtual ~InteractiveConsole()
|
||||
{
|
||||
@@ -41,6 +45,11 @@ public:
|
||||
void WriteLineWarning(const std::string& s);
|
||||
void WriteFormatLine(const char* format, ...);
|
||||
|
||||
void BeginAsyncExecution();
|
||||
void EndAsyncExecution();
|
||||
|
||||
bool IsExecuting();
|
||||
|
||||
virtual void Clear() = 0;
|
||||
virtual void Close() = 0;
|
||||
virtual void Hide() = 0;
|
||||
|
||||
Reference in New Issue
Block a user