1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-23 14:54:30 +01:00

Add script engine and connect to std console

This commit is contained in:
Ted John
2018-03-17 19:31:06 +00:00
parent 27a8597214
commit 43508e0402
6 changed files with 146 additions and 30 deletions

View File

@@ -0,0 +1,45 @@
/*****************************************************************************
* Copyright (c) 2014-2018 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 <future>
#include <queue>
#include <string>
struct duk_hthread;
typedef struct duk_hthread duk_context;
class InteractiveConsole;
namespace OpenRCT2
{
interface IPlatformEnvironment;
}
namespace OpenRCT2::Scripting
{
class ScriptEngine
{
private:
InteractiveConsole& _console;
IPlatformEnvironment& _env;
duk_context * _context;
std::queue<std::tuple<std::promise<void>, std::string>> _evalQueue;
public:
ScriptEngine(InteractiveConsole& console, IPlatformEnvironment& env);
ScriptEngine(ScriptEngine&&) = delete;
~ScriptEngine();
void Update();
std::future<void> Eval(const std::string &s);
};
}