mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-15 20:08:54 +03:00
Reworked file structure
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
#include "EditorModule.h"
|
||||
#include "../../Windows/EditorInterface.h"
|
||||
|
||||
void SelectEntity(int entityId)
|
||||
{
|
||||
if (entityId == -1)
|
||||
{
|
||||
Nuake::EditorInterface::Selection = EditorSelection();
|
||||
return;
|
||||
}
|
||||
|
||||
//Nuake::EditorInterface::Selection = EditorSelection(Nuake::Entity{ (entt::entity)entityId, Nuake::Engine::GetCurrentScene().get() });
|
||||
}
|
||||
|
||||
int GetSelectedEntity()
|
||||
{
|
||||
return -10;
|
||||
}
|
||||
|
||||
void EditorNetAPI::RegisterMethods()
|
||||
{
|
||||
RegisterMethod("Editor.SetSelectedEntityIcall", &SelectEntity);
|
||||
RegisterMethod("Editor.GetSelectedEntityIcall", &GetSelectedEntity);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
#include "Nuake/Scripting/NetModules/NetAPIModule.h"
|
||||
|
||||
class EditorNetAPI : public Nuake::NetAPIModule
|
||||
{
|
||||
public:
|
||||
virtual const std::string GetModuleName() const override { return "Editor"; }
|
||||
|
||||
virtual void RegisterMethods() override;
|
||||
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
#include "ScriptingContext.h"
|
||||
#include "Nuake/Core/String.h"
|
||||
|
||||
#include "Modules/EditorModule.h"
|
||||
|
||||
void ScriptingContext::Initialize()
|
||||
{
|
||||
modules =
|
||||
{
|
||||
CreateRef<EditorNetAPI>()
|
||||
};
|
||||
|
||||
for (auto& m : modules)
|
||||
{
|
||||
m->RegisterMethods();
|
||||
}
|
||||
|
||||
// Load Nuake assembly DLL
|
||||
/*auto loadContext2 = Nuake::ScriptingEngineNet::Get().GetHostInstance()->CreateAssemblyLoadContext("NuakeEditorContext");
|
||||
nuakeAssembly = Nuake::ScriptingEngineNet::Get().ReloadEngineAPI(loadContext2);
|
||||
m_EditorAssembly = loadContext2.LoadAssembly("EditorNet.dll");
|
||||
|
||||
for (const auto& netModule : modules)
|
||||
{
|
||||
for (const auto& [methodName, methodPtr] : netModule->GetMethods())
|
||||
{
|
||||
auto namespaceClassSplit = Nuake::String::Split(methodName, '.');
|
||||
m_EditorAssembly.AddInternalCall("Nuake." + namespaceClassSplit[0], namespaceClassSplit[1], methodPtr);
|
||||
}
|
||||
}
|
||||
|
||||
m_EditorAssembly.UploadInternalCalls();
|
||||
m_EditorAssembly.GetType("Nuake.Editor").InvokeStaticMethod("Initialize");*/
|
||||
}
|
||||
|
||||
void ScriptingContext::PushCommand(const std::string & command, const std::string & arg)
|
||||
{
|
||||
m_EditorAssembly.GetType("Nuake.Editor").InvokeStaticMethod("Initialize");
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
#include "Nuake/Scripting/NetModules/NetAPIModule.h"
|
||||
|
||||
namespace Coral
|
||||
{
|
||||
class HostInstance;
|
||||
class AssemblyLoadContext;
|
||||
class ManagedAssembly;
|
||||
}
|
||||
|
||||
#include "Nuake/Scripting/ScriptingEngineNet.h"
|
||||
|
||||
class ScriptingContext
|
||||
{
|
||||
private:
|
||||
Coral::HostInstance* hostInstance;
|
||||
Coral::AssemblyLoadContext loadContext;
|
||||
|
||||
std::unordered_map<std::string, Coral::AssemblyLoadContext*> loadedAssemblies;
|
||||
std::vector<Ref<Nuake::NetAPIModule>> modules;
|
||||
|
||||
Coral::ManagedAssembly nuakeAssembly; // Nuake DLL
|
||||
Coral::ManagedAssembly m_EditorAssembly; // Editor DLL
|
||||
public:
|
||||
static ScriptingContext& Get()
|
||||
{
|
||||
static ScriptingContext instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
void Initialize();
|
||||
|
||||
void PushCommand(const std::string& command, const std::string& arg);
|
||||
};
|
||||
Reference in New Issue
Block a user