mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-15 20:08:54 +03:00
Code cleanup scripting
This commit is contained in:
@@ -2,23 +2,24 @@
|
||||
#include <cstdint>
|
||||
#include <xhash>
|
||||
|
||||
namespace Nuake {
|
||||
|
||||
namespace Nuake
|
||||
{
|
||||
class UUID
|
||||
{
|
||||
private:
|
||||
uint64_t m_UUID;
|
||||
|
||||
public:
|
||||
UUID();
|
||||
UUID(uint64_t uuid);
|
||||
UUID(const UUID&) = default;
|
||||
|
||||
operator uint64_t() const { return m_UUID; }
|
||||
private:
|
||||
uint64_t m_UUID;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
namespace std {
|
||||
namespace std
|
||||
{
|
||||
template<>
|
||||
struct hash<Nuake::UUID>
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include "src/Core/Core.h"
|
||||
#include "src/Core/Maths.h"
|
||||
|
||||
@@ -15,9 +14,9 @@
|
||||
#include "src/Scene/Systems/System.h"
|
||||
|
||||
#include "src/Resource/UUID.h"
|
||||
#include "src/Resource/Resource.h"
|
||||
|
||||
namespace Nuake {
|
||||
namespace Nuake
|
||||
{
|
||||
class Entity;
|
||||
class SceneRenderer;
|
||||
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
#include "ScriptingEngine.h"
|
||||
#include "WrenScript.h"
|
||||
#include "../Core/FileSystem.h"
|
||||
#include <src/Scripting/Modules/ScriptModule.h>
|
||||
#include <src/Scripting/Modules/EngineModule.h>
|
||||
#include <src/Scripting/Modules/SceneModule.h>
|
||||
#include <src/Scripting/Modules/MathModule.h>
|
||||
#include <src/Scripting/Modules/InputModule.h>
|
||||
#include <src/Scripting/Modules/PhysicsModule.h>
|
||||
#include "src/Core/FileSystem.h"
|
||||
|
||||
#include "src/Scripting/VM.h"
|
||||
#include "src/Scripting/Modules/ScriptModule.h"
|
||||
#include "src/Scripting/Modules/EngineModule.h"
|
||||
#include "src/Scripting/Modules/SceneModule.h"
|
||||
#include "src/Scripting/Modules/MathModule.h"
|
||||
#include "src/Scripting/Modules/InputModule.h"
|
||||
#include "src/Scripting/Modules/PhysicsModule.h"
|
||||
|
||||
namespace Nuake {
|
||||
WrenVM* ScriptingEngine::m_WrenVM;
|
||||
Ref<VM> ScriptingEngine::m_VM;
|
||||
|
||||
std::map<std::string, Ref<WrenScript>> ScriptingEngine::m_Scripts;
|
||||
std::map<std::string, Ref<ScriptModule>> ScriptingEngine::Modules;
|
||||
@@ -162,6 +164,7 @@ namespace Nuake {
|
||||
config.writeFn = &writeFn;
|
||||
config.bindForeignMethodFn = &bindForeignMethod;
|
||||
|
||||
m_VM = CreateRef<VM>();
|
||||
m_WrenVM = wrenNewVM(&config);
|
||||
|
||||
Logger::Log("Registing Scripting Modules");
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
#pragma once
|
||||
#include "src/Core/Core.h"
|
||||
#include "src/Core/Timestep.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include "src/Core/Core.h"
|
||||
|
||||
#include "src/Vendors/wren/src/include/wren.hpp"
|
||||
#include "src/Core/Timestep.h"
|
||||
|
||||
namespace Nuake
|
||||
{
|
||||
class WrenScript;
|
||||
class ScriptModule;
|
||||
|
||||
class ScriptingEngine
|
||||
{
|
||||
private:
|
||||
@@ -18,7 +21,12 @@ namespace Nuake
|
||||
static std::vector<std::string> m_LoadedScripts;
|
||||
static std::map<std::string, Ref<WrenScript>> m_Scripts;
|
||||
static std::map<std::string, Ref<ScriptModule>> Modules;
|
||||
|
||||
public:
|
||||
static void Init();
|
||||
static void RunCode(const std::string& code);
|
||||
static void Close();
|
||||
|
||||
static Ref<WrenScript> RegisterScript(const std::string& path, const std::string& mod);
|
||||
static bool IsScriptImported(const std::string& path);
|
||||
static void ImportScript(const std::string& path);
|
||||
@@ -26,11 +34,6 @@ namespace Nuake
|
||||
static void InitScript(Ref<WrenScript> script);
|
||||
static void UpdateScript(Ref<WrenScript> script, Timestep timestep);
|
||||
static void ExitScript(Ref<WrenScript> script);
|
||||
static void Init();
|
||||
static void RunCode(const std::string& code);
|
||||
static void Close();
|
||||
|
||||
|
||||
|
||||
static WrenForeignMethodFn bindForeignMethod(
|
||||
WrenVM* vm,
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
#include "VM.h"
|
||||
|
||||
namespace Nuake {
|
||||
VM::VM()
|
||||
{
|
||||
WrenConfiguration config;
|
||||
wrenInitConfiguration(&config);
|
||||
|
||||
//config.loadModuleFn = &myLoadModule;
|
||||
//config.errorFn = &errorFn;
|
||||
//config.writeFn = &writeFn;
|
||||
//config.bindForeignMethodFn = &bindForeignMethod;
|
||||
|
||||
m_VM = wrenNewVM(&config);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
#pragma once
|
||||
#include <src/Vendors/wren/src/include/wren.h>
|
||||
|
||||
namespace Nuake {
|
||||
class VM
|
||||
{
|
||||
VM();
|
||||
|
||||
inline WrenVM* GetVM();
|
||||
private:
|
||||
WrenVM* m_VM;
|
||||
};
|
||||
}
|
||||
@@ -2,10 +2,12 @@
|
||||
|
||||
#include "src/Core/Logger.h"
|
||||
#include "src/Core/String.h"
|
||||
#include "src/Core/FileSystem.h"
|
||||
|
||||
#include <src/Vendors/wren/src/include/wren.h>
|
||||
|
||||
namespace Nuake {
|
||||
namespace Nuake
|
||||
{
|
||||
WrenScript::WrenScript(Ref<File> file, bool isEntity)
|
||||
{
|
||||
mFile = file;
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
#pragma once
|
||||
#include "ScriptingEngine.h"
|
||||
|
||||
#include "src/Core/FileSystem.h"
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
struct WrenHandle;
|
||||
|
||||
namespace Nuake {
|
||||
namespace Nuake
|
||||
{
|
||||
class File;
|
||||
class WrenScript
|
||||
{
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user