Now bindings works automatically and is smoooth, aslo strings work now
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user