mirror of
https://github.com/rosebudai/OpenRCT2-Web.git
synced 2026-12-05 12:45:14 +01:00
54 lines
1.3 KiB
C++
54 lines
1.3 KiB
C++
/*****************************************************************************
|
|
* 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 "Plugin.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;
|
|
bool _initialised{};
|
|
duk_context * _context{};
|
|
std::queue<std::tuple<std::promise<void>, std::string>> _evalQueue;
|
|
std::vector<Plugin> _plugins;
|
|
|
|
public:
|
|
ScriptEngine(InteractiveConsole& console, IPlatformEnvironment& env);
|
|
ScriptEngine(ScriptEngine&) = delete;
|
|
~ScriptEngine();
|
|
|
|
void Update();
|
|
std::future<void> Eval(const std::string &s);
|
|
|
|
private:
|
|
void Initialise();
|
|
void LoadPlugins();
|
|
void StartPlugins();
|
|
};
|
|
}
|