1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-19 21:13:05 +01:00
Files
OpenRCT2/src/openrct2/interface/InteractiveConsole.h
James103 1d8dc111f1 Replace 2023 with 2024 in copyright headers (#21139)
Replace all instances of the year 2023 with 2024 in all copyright headers
2024-01-01 12:52:28 +01:00

75 lines
1.8 KiB
C++

/*****************************************************************************
* Copyright (c) 2014-2024 OpenRCT2 developers
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#pragma once
#include "../common.h"
#include "../localisation/FormatCodes.h"
#include <atomic>
#include <future>
#include <queue>
#include <string>
struct DrawPixelInfo;
struct TextInputSession;
enum class ConsoleInput : uint8_t
{
None,
LineClear,
LineExecute,
HistoryPrevious,
HistoryNext,
ScrollPrevious,
ScrollNext,
};
class InteractiveConsole
{
public:
virtual ~InteractiveConsole()
{
}
void Execute(const std::string& s);
void WriteLine(const std::string& s);
void WriteLineError(const std::string& s);
void WriteLineWarning(const std::string& s);
void WriteFormatLine(const char* format, ...);
virtual void Clear() abstract;
virtual void Close() abstract;
virtual void Hide() abstract;
virtual void WriteLine(const std::string& s, FormatToken colourFormat) abstract;
};
class StdInOutConsole final : public InteractiveConsole
{
private:
std::queue<std::tuple<std::promise<void>, std::string>> _evalQueue;
std::atomic<bool> _isPromptShowing{};
public:
void Start();
std::future<void> Eval(const std::string& s);
void ProcessEvalQueue();
void Clear() override;
void Close() override;
void Hide() override
{
}
void WriteLine(const std::string& s)
{
InteractiveConsole::WriteLine(s);
}
void WriteLine(const std::string& s, FormatToken colourFormat) override;
};