mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-27 16:54:52 +01:00
Create new in-game console class
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -25,16 +25,6 @@
|
||||
|
||||
struct rct_drawpixelinfo;
|
||||
|
||||
class StdInOutConsole
|
||||
{
|
||||
private:
|
||||
std::queue<std::tuple<std::promise<void>, std::string>> _evalQueue;
|
||||
public:
|
||||
void Start();
|
||||
std::future<void> Eval(const std::string &s);
|
||||
void ProcessEvalQueue();
|
||||
};
|
||||
|
||||
enum CONSOLE_INPUT
|
||||
{
|
||||
CONSOLE_INPUT_NONE,
|
||||
@@ -46,24 +36,74 @@ enum CONSOLE_INPUT
|
||||
CONSOLE_INPUT_SCROLL_NEXT,
|
||||
};
|
||||
|
||||
class InteractiveConsole
|
||||
{
|
||||
public:
|
||||
virtual ~InteractiveConsole() { }
|
||||
|
||||
sint32 cc_clear(const utf8 **argv, sint32 argc);
|
||||
|
||||
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 std::string &format, ...);
|
||||
|
||||
virtual void Clear() abstract;
|
||||
virtual void Close() abstract;
|
||||
virtual void WriteLine(const std::string &s, uint32 colourFormat) abstract;
|
||||
};
|
||||
|
||||
class InGameConsole : public InteractiveConsole
|
||||
{
|
||||
public:
|
||||
InGameConsole();
|
||||
|
||||
void Clear() override;
|
||||
void Open();
|
||||
void Close() override;
|
||||
void Toggle();
|
||||
void WriteLine(const std::string &s, uint32 colourFormat) override;
|
||||
|
||||
void Input(CONSOLE_INPUT input);
|
||||
void RefreshCaret();
|
||||
void Scroll(sint32 linesToScroll);
|
||||
|
||||
void Update();
|
||||
void Draw(rct_drawpixelinfo * dpi);
|
||||
|
||||
private:
|
||||
void ClearInput();
|
||||
void ClearLine();
|
||||
void HistoryAdd(const utf8 * src);
|
||||
void WritePrompt();
|
||||
void ScrollToEnd();
|
||||
void Invalidate();
|
||||
};
|
||||
|
||||
class StdInOutConsole : public InteractiveConsole
|
||||
{
|
||||
private:
|
||||
std::queue<std::tuple<std::promise<void>, std::string>> _evalQueue;
|
||||
public:
|
||||
void Start();
|
||||
std::future<void> Eval(const std::string &s);
|
||||
void ProcessEvalQueue();
|
||||
|
||||
void Clear() override;
|
||||
void Close() override;
|
||||
void WriteLine(const std::string &s, uint32 colourFormat) override;
|
||||
};
|
||||
|
||||
// Old pass-through functions for in-game console
|
||||
extern bool gConsoleOpen;
|
||||
|
||||
void console_open();
|
||||
void console_close();
|
||||
void console_toggle();
|
||||
|
||||
void console_update();
|
||||
void console_draw(rct_drawpixelinfo *dpi);
|
||||
|
||||
void console_input(CONSOLE_INPUT input);
|
||||
void console_write(const utf8 *src);
|
||||
void console_writeline(const utf8 * src, uint32 colourFormat = FORMAT_WINDOW_COLOUR_2);
|
||||
void console_writeline_error(const utf8 *src);
|
||||
void console_writeline_warning(const utf8 *src);
|
||||
void console_printf(const utf8 *format, ...);
|
||||
void console_execute(const utf8 *src);
|
||||
void console_execute_silent(const utf8 *src);
|
||||
void console_clear();
|
||||
void console_clear_line();
|
||||
void console_refresh_caret();
|
||||
void console_scroll(sint32 delta);
|
||||
|
||||
Reference in New Issue
Block a user