mirror of
https://github.com/antopilo/Nuake.git
synced 2026-01-01 05:48:14 +03:00
Now bindings works automatically and is smoooth, aslo strings work now
This commit is contained in:
@@ -91,6 +91,11 @@ LaunchSettings ParseLaunchSettings(const std::vector<std::string>& arguments)
|
||||
launchSettings.monitor = stoi(arguments[i + 1]);
|
||||
}
|
||||
}
|
||||
else if (arg == "--generate-bindings")
|
||||
{
|
||||
// Set editor window monitor
|
||||
launchSettings.generateBindings = true;
|
||||
}
|
||||
else if (argumentSize == 2 && Nuake::FileSystem::FileExists(arg))
|
||||
{
|
||||
if (Nuake::String::EndsWith(arg, ".project"))
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "Nuake/UI/NuakeUI.h"
|
||||
#include "Nuake/UI/UIInputManager.h"
|
||||
#include "Nuake/Modules/ModuleDB.h"
|
||||
|
||||
void EditorApplication::OnInit()
|
||||
{
|
||||
@@ -14,7 +15,14 @@ void EditorApplication::OnInit()
|
||||
Engine::Init();
|
||||
|
||||
// Register bakers, these can convert files into nuake resources
|
||||
|
||||
if (m_LaunchSettings.generateBindings)
|
||||
{
|
||||
ModuleDB::Get().GenerateModuleAPI();
|
||||
|
||||
Logger::Log("Generated Bindings");
|
||||
m_Window->Close();
|
||||
return;
|
||||
}
|
||||
|
||||
m_Window = Engine::GetCurrentWindow();
|
||||
m_Window->SetSize({ m_Specification.WindowWidth, m_Specification.WindowHeight });
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
struct LaunchSettings
|
||||
{
|
||||
int32_t monitor = 1;
|
||||
bool generateBindings = false;
|
||||
Nuake::Vector2 resolution = { 1100, 630 };
|
||||
std::string windowTitle = "Nuake Editor ";
|
||||
std::string projectPath;
|
||||
|
||||
@@ -100,4 +100,3 @@ project "Editor"
|
||||
filter "configurations:Release"
|
||||
runtime "Release"
|
||||
optimize "on"
|
||||
|
||||
|
||||
@@ -163,12 +163,12 @@ namespace Nuake
|
||||
const float scaledFixedTimestep = fixedUpdateRate * timeScale;
|
||||
currentWindow->FixedUpdate(scaledFixedTimestep);
|
||||
|
||||
Modules::FixedUpdate(scaledFixedTimestep);
|
||||
ModuleDB::Get().FixedUpdate(scaledFixedTimestep);
|
||||
|
||||
fixedUpdateDifference -= fixedUpdateRate;
|
||||
}
|
||||
|
||||
Modules::Update(scaledTimeStep);
|
||||
ModuleDB::Get().Update(scaledTimeStep);
|
||||
|
||||
Input::Update();
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace Nuake {
|
||||
bool VSync = true;
|
||||
std::string WorkingDirectory = "";
|
||||
bool Headless = false;
|
||||
bool GenerateBindings = false;
|
||||
};
|
||||
|
||||
class Application
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
|
||||
using namespace Nuake;
|
||||
|
||||
void HelloWorld()
|
||||
{
|
||||
Logger::Log("Hello World");
|
||||
}
|
||||
|
||||
float Volume = 1.0f;
|
||||
void SetVolume(float volume)
|
||||
{
|
||||
@@ -22,6 +27,11 @@ void SetMuted(bool muted)
|
||||
Muted = muted;
|
||||
}
|
||||
|
||||
void SetName(const std::string& name)
|
||||
{
|
||||
Logger::Log("SetName: " + name);
|
||||
}
|
||||
|
||||
NUAKEMODULE(AudioModule)
|
||||
void AudioModule_Startup()
|
||||
{
|
||||
@@ -37,6 +47,8 @@ void AudioModule_Startup()
|
||||
// Exposed functions(scripting API)
|
||||
module.BindFunction<SetVolume>("SetVolume", "volume");
|
||||
module.BindFunction<SetMuted>("SetMuted", "muted");
|
||||
module.BindFunction<HelloWorld>("HelloWorld");
|
||||
module.BindFunction<SetName>("SetName", "name");
|
||||
|
||||
// Register custom component & system
|
||||
module.RegisterComponent<Audio::AudioEmitterComponent>();
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
void ExampleModuleLog(const std::string& hi)
|
||||
void ExampleModuleLog(NativeString hi)
|
||||
{
|
||||
Nuake::Logger::Log(hi, "ExampleModule", Nuake::VERBOSE);
|
||||
}
|
||||
@@ -81,7 +81,7 @@ void ExampleModule_Startup()
|
||||
|
||||
// This is to expose functions to the rest of the engine
|
||||
module.BindFunction<ExampleFunction>("ExampleFunction");
|
||||
module.BindFunction<ExampleModuleLog>("ExampleModuleLog", "hi");
|
||||
module.BindFunction<ExampleModuleLog>("ExampleModuleLog16", "hi2");
|
||||
|
||||
// The module can hook to certain events
|
||||
module.OnUpdate.AddStatic([](float ts)
|
||||
|
||||
@@ -35,7 +35,7 @@ json ModuleDB::GenerateModuleAPI()
|
||||
{
|
||||
std::string argType = std::string(func.arg(k).info().name());
|
||||
|
||||
if (argType == "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >")
|
||||
if (argType == "class Coral::String" || argType == "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >")
|
||||
{
|
||||
argType = "string";
|
||||
}
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
|
||||
#include <entt/entt.hpp>
|
||||
|
||||
#include <Coral/String.hpp>
|
||||
|
||||
using NativeString = Coral::String;
|
||||
|
||||
class ModuleInstance
|
||||
{
|
||||
public:
|
||||
@@ -104,9 +108,12 @@ public: \
|
||||
} \
|
||||
\
|
||||
|
||||
|
||||
|
||||
#define NUAKEMODULE(moduleName) \
|
||||
using TypeNameMap = std::map<entt::id_type, std::string>; \
|
||||
\
|
||||
\
|
||||
class moduleName : public ModuleInstance \
|
||||
{ \
|
||||
public: \
|
||||
@@ -212,6 +219,24 @@ namespace Nuake
|
||||
return *(T*)std::any_cast<ModuleInstance*>(Modules[unmangledName]);
|
||||
}
|
||||
|
||||
void FixedUpdate(float ts)
|
||||
{
|
||||
for (auto& moduleName : GetModules())
|
||||
{
|
||||
auto& module = GetBaseImpl(moduleName);
|
||||
module.OnFixedUpdate.Broadcast(ts);
|
||||
}
|
||||
}
|
||||
|
||||
void Update(float ts)
|
||||
{
|
||||
for (auto& moduleName : GetModules())
|
||||
{
|
||||
auto& module = GetBaseImpl(moduleName);
|
||||
module.OnUpdate.Broadcast(ts);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T& GetModule()
|
||||
{
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include "ExampleModule/ExampleModule.h"
|
||||
|
||||
#include "Nuake/Core/Logger.h"
|
||||
#include "Nuake/Modules/ModuleDB.h"
|
||||
|
||||
void Nuake::Modules::StartupModules()
|
||||
{
|
||||
@@ -18,26 +17,6 @@ void Nuake::Modules::StartupModules()
|
||||
ExampleModule_Startup();
|
||||
}
|
||||
|
||||
void Nuake::Modules::FixedUpdate(float ts)
|
||||
{
|
||||
auto& moduleDB = ModuleDB::Get();
|
||||
for (auto& moduleName : moduleDB.GetModules())
|
||||
{
|
||||
auto& module = moduleDB.GetBaseImpl(moduleName);
|
||||
module.OnFixedUpdate.Broadcast(ts);
|
||||
}
|
||||
}
|
||||
|
||||
void Nuake::Modules::Update(float ts)
|
||||
{
|
||||
auto& moduleDB = ModuleDB::Get();
|
||||
for (auto& moduleName : moduleDB.GetModules())
|
||||
{
|
||||
auto& module = moduleDB.GetBaseImpl(moduleName);
|
||||
module.OnUpdate.Broadcast(ts);
|
||||
}
|
||||
}
|
||||
|
||||
void Nuake::Modules::ShutdownModules()
|
||||
{
|
||||
Logger::Log("Shutting down AssimpModule", "modules");
|
||||
|
||||
@@ -12,8 +12,6 @@ namespace Nuake
|
||||
|
||||
public:
|
||||
static void StartupModules();
|
||||
static void FixedUpdate(float ts);
|
||||
static void Update(float ts);
|
||||
static void ShutdownModules();
|
||||
};
|
||||
}
|
||||
@@ -72,7 +72,6 @@ namespace Nuake
|
||||
|
||||
// Check if we have an .sln in the project.
|
||||
const std::string absoluteAssemblyPath = FileSystem::Root + m_NetDirectory + "/" + m_EngineAssemblyName;
|
||||
|
||||
if (!FileSystem::FileExists(m_EngineAssemblyName, true))
|
||||
{
|
||||
isInitialized = false;
|
||||
|
||||
@@ -46,6 +46,11 @@ GLFWwindow* Window::GetHandle()
|
||||
return this->window;
|
||||
}
|
||||
|
||||
void Window::Close()
|
||||
{
|
||||
glfwSetWindowShouldClose(this->window, true);
|
||||
}
|
||||
|
||||
bool Window::ShouldClose()
|
||||
{
|
||||
return glfwWindowShouldClose(this->window);
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace Nuake
|
||||
public:
|
||||
GLFWwindow* GetHandle();
|
||||
|
||||
void Close();
|
||||
bool ShouldClose();
|
||||
|
||||
int Init();
|
||||
|
||||
@@ -17,5 +17,19 @@ namespace Nuake.Net
|
||||
Internals.AudioModuleSetMutedICall(muted);
|
||||
}
|
||||
}
|
||||
public static void HelloWorld()
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
Internals.AudioModuleHelloWorldICall();
|
||||
}
|
||||
}
|
||||
public static void SetName(string name)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
Internals.AudioModuleSetNameICall(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,11 +10,11 @@ namespace Nuake.Net
|
||||
Internals.ExampleModuleExampleFunctionICall();
|
||||
}
|
||||
}
|
||||
public static void ExampleModuleLog(string hi)
|
||||
public static void ExampleModuleLog16(string hi2)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
Internals.ExampleModuleExampleModuleLogICall(hi);
|
||||
Internals.ExampleModuleExampleModuleLog16ICall(hi2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,12 @@ public class Internals
|
||||
// AudioModule
|
||||
internal static unsafe delegate*<float,void>AudioModuleSetVolumeICall;
|
||||
internal static unsafe delegate*<bool,void>AudioModuleSetMutedICall;
|
||||
internal static unsafe delegate*<void>AudioModuleHelloWorldICall;
|
||||
internal static unsafe delegate*<NativeString,void>AudioModuleSetNameICall;
|
||||
|
||||
// ExampleModule
|
||||
internal static unsafe delegate*<void>ExampleModuleExampleFunctionICall;
|
||||
internal static unsafe delegate*<NativeString,void>ExampleModuleExampleModuleLogICall;
|
||||
internal static unsafe delegate*<NativeString,void>ExampleModuleExampleModuleLog16ICall;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,3 +27,11 @@ project "NuakeNet"
|
||||
"Coral.Managed"
|
||||
}
|
||||
|
||||
prebuildcommands {
|
||||
'dotnet dotnet run --project %{wks.location}NuakeNetGenerator/NuakeNetGenerator.csproj'
|
||||
}
|
||||
|
||||
postbuildcommands {
|
||||
'{COPYFILE} "%{wks.location}NuakeNet/Build/%{cfg.buildcfg}/Binaries/NuakeNet.dll" "%{wks.location}Editor/Build/%{cfg.buildcfg}/Binaries/NuakeNet.dll"'
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user