Files
Nuake/Editor/Source/Editor/Events/EditorRequests.h
2025-01-31 18:04:43 -05:00

44 lines
927 B
C++

#include <Nuake/Core/Core.h>
#include <Nuake/Core/MulticastDelegate.h>
#include <string>
namespace Nuake
{
class Scene;
class File;
}
// This is all the commands that the editor can receive from anywhere in the UI
class EditorRequests
{
private:
MulticastDelegate<Ref<Nuake::File>> requestLoadScene;
MulticastDelegate<std::string> requestCloseEditorWindow;
EditorRequests() = default;
~EditorRequests() = default;
public:
static EditorRequests& Get()
{
static EditorRequests instance;
return instance;
}
public:
// Broadcast requests
void RequestLoadScene(Ref<Nuake::File> sceneFile)
{
requestLoadScene.Broadcast(sceneFile);
}
void RequestCloseEditorWindow(std::string windowId)
{
requestCloseEditorWindow.Broadcast(windowId.c_str());
}
// Subcribe to requests
auto& OnRequestCloseEditorWindow() { return requestCloseEditorWindow; }
auto& OnRequestLoadScene() { return requestLoadScene; }
};