chore: refactor and tidying tests
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#include "angelscript.h"
|
||||
#include <string>
|
||||
|
||||
class ScriptBindings {
|
||||
public:
|
||||
static void RegisterAll(asIScriptEngine* engine);
|
||||
|
||||
private:
|
||||
static void Print(asIScriptGeneric* gen);
|
||||
// Log(level, message) - generic to get script context
|
||||
static void Log(asIScriptGeneric* gen);
|
||||
static void AS_DrawText(const std::string &text, int x, int y, int fontSize, unsigned int color);
|
||||
};
|
||||
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
#include "angelscript.h"
|
||||
#include "scriptbuilder.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class ScriptEngine {
|
||||
public:
|
||||
ScriptEngine();
|
||||
~ScriptEngine();
|
||||
|
||||
bool Initialize();
|
||||
void Shutdown();
|
||||
bool CompileScript(const std::string& filename);
|
||||
void CallScriptFunction(asIScriptFunction* func, float dt = 0.0f);
|
||||
void GarbageCollect();
|
||||
|
||||
// Add a path used to resolve #include directives in scripts
|
||||
void AddIncludePath(const std::string& path);
|
||||
|
||||
// Try to preserve script state across hot-reloads by calling optional
|
||||
// __SerializeState()/__DeserializeState() hooks in the script module.
|
||||
std::string CaptureScriptState();
|
||||
void RestoreScriptState(const std::string &state);
|
||||
|
||||
asIScriptEngine* GetEngine() const { return engine; }
|
||||
asIScriptFunction* GetUpdateFunction() const { return updateFunc; }
|
||||
asIScriptFunction* GetDrawFunction() const { return drawFunc; }
|
||||
|
||||
private:
|
||||
asIScriptEngine* engine;
|
||||
asIScriptFunction* updateFunc;
|
||||
asIScriptFunction* drawFunc;
|
||||
asIScriptModule* currentModule;
|
||||
bool hasValidScript;
|
||||
std::vector<std::string> includePaths;
|
||||
|
||||
static void MessageCallback(const asSMessageInfo* msg, void* param);
|
||||
static int IncludeCallback(const char* include, const char* from, CScriptBuilder* builder, void* userParam);
|
||||
std::string ReadFile(const std::string& filename);
|
||||
void ClearCachedFunctions();
|
||||
};
|
||||
Reference in New Issue
Block a user