new core version, using events

This commit is contained in:
2026-04-06 10:25:45 +02:00
parent 1bf97efa72
commit d4b4324711
6 changed files with 53 additions and 28 deletions

View File

@@ -1,8 +1,13 @@
#include "AppLayer.h" #include "AppLayer.h"
#include "Application.h" #include "Application.h"
#include "Event.h"
#include "InputEvents.h"
#include "Layer.h" #include "Layer.h"
#include "Log.h"
#include "TestLayer.h" #include "TestLayer.h"
#include "WindowEvents.h"
#include "imgui.h" #include "imgui.h"
#include <string>
AppLayer::AppLayer() : Layer("AppLayer", true) {} AppLayer::AppLayer() : Layer("AppLayer", true) {}
@@ -14,7 +19,7 @@ void AppLayer::OnImGuiRender() {
ImGui::Text("Application avg %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate); ImGui::Text("Application avg %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
if (ImGui::Button("Quit")) { if (ImGui::Button("Quit")) {
Application::Get().SetRunningState(false); SakuraVNE::Application::Get().SetRunningState(false);
} }
ImGui::End(); ImGui::End();
@@ -24,3 +29,15 @@ void AppLayer::OnImGuiRender() {
} }
ImGui::End(); ImGui::End();
} }
void AppLayer::OnEvent(SakuraVNE::Event &event) {
LOG_INFO("{}", event.ToString());
SakuraVNE::EventDispatcher dispatcher(event);
dispatcher.Dispatch<SakuraVNE::MouseButtonPressedEvent>([this](SakuraVNE::MouseButtonPressedEvent &e) { return OnMouseButtonPressed(e); });
dispatcher.Dispatch<SakuraVNE::MouseMovedEvent>([this](SakuraVNE::MouseMovedEvent &e) { return OnMouseMoved(e); });
dispatcher.Dispatch<SakuraVNE::WindowClosedEvent>([this](SakuraVNE::WindowClosedEvent &e) { return OnWindowClosed(e); });
}
bool AppLayer::OnMouseButtonPressed(SakuraVNE::MouseButtonPressedEvent &event) { return false; }
bool AppLayer::OnMouseMoved(SakuraVNE::MouseMovedEvent &event) { return false; }
bool AppLayer::OnWindowClosed(SakuraVNE::WindowClosedEvent &event) { return false; }

View File

@@ -1,13 +1,18 @@
#include "Event.h"
#include "InputEvents.h"
#include "Layer.h" #include "Layer.h"
#include "WindowEvents.h"
class AppLayer : public SakuraVNE::Layer { class AppLayer : public SakuraVNE::Layer {
public: public:
AppLayer(); AppLayer();
virtual ~AppLayer() = default; virtual ~AppLayer() = default;
virtual void OnImGuiRender() override; virtual void OnImGuiRender() override;
virtual void OnEvent(SakuraVNE::Event &event) override;
private: private:
// bool OnMouseButtonPressed(Core::MouseButtonPressedEvent &event); bool OnMouseButtonPressed(SakuraVNE::MouseButtonPressedEvent &event);
// bool OnMouseMoved(Core::MouseMovedEvent &event); bool OnMouseMoved(SakuraVNE::MouseMovedEvent &event);
// bool OnWindowClosed(Core::WindowClosedEvent &event); bool OnWindowClosed(SakuraVNE::WindowClosedEvent &event);
int m_ClickCounter = 0;
}; };

View File

@@ -12,11 +12,11 @@ void Overlay::OnImGuiRender() {
ImGui::Begin("Overlay Transition"); ImGui::Begin("Overlay Transition");
if (ImGui::Button("Overlay Transition")) { if (ImGui::Button("Overlay Transition")) {
auto testLayer = Application::Get().GetLayer<TestLayer>(); auto testLayer = SakuraVNE::Application::Get().GetLayer<TestLayer>();
if (testLayer) { if (testLayer) {
testLayer->TransitionTo<AppLayer>(); testLayer->TransitionTo<AppLayer>();
} else { } else {
auto appLayer = Application::Get().GetLayer<AppLayer>(); auto appLayer = SakuraVNE::Application::Get().GetLayer<AppLayer>();
appLayer->TransitionTo<TestLayer>(); appLayer->TransitionTo<TestLayer>();
} }
} }

View File

@@ -3,13 +3,13 @@
#include "Overlay.h" #include "Overlay.h"
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
AppData appData; SakuraVNE::AppData appData;
appData.name = "Sakura Visual Novel Creator"; appData.name = "Sakura Visual Novel Creator";
appData.windowdata.title = appData.name; appData.windowdata.title = appData.name;
appData.windowdata.width = 1280; appData.windowdata.width = 1280;
appData.windowdata.height = 720; appData.windowdata.height = 720;
Application app(appData); SakuraVNE::Application app(appData);
app.PushLayer<AppLayer>(); app.PushLayer<AppLayer>();
app.PushOverlay<Overlay>(); app.PushOverlay<Overlay>();
app.Run(); app.Run();

View File

@@ -9,8 +9,8 @@ Size=311,180
Collapsed=0 Collapsed=0
[Window][Dear ImGui Demo] [Window][Dear ImGui Demo]
Pos=592,0 Pos=584,0
Size=688,720 Size=696,720
Collapsed=0 Collapsed=0
DockId=0x00000006,0 DockId=0x00000006,0
@@ -36,7 +36,7 @@ Collapsed=0
[Window][Framerate] [Window][Framerate]
Pos=0,0 Pos=0,0
Size=590,364 Size=582,364
Collapsed=0 Collapsed=0
DockId=0x00000009,0 DockId=0x00000009,0
@@ -47,19 +47,20 @@ Collapsed=0
DockId=0x00000008,0 DockId=0x00000008,0
[Window][Overlay Transition] [Window][Overlay Transition]
Pos=506,251 Pos=272,366
Size=365,165 Size=310,354
Collapsed=0 Collapsed=0
DockId=0x0000000C,0
[Window][To TestLayer Transition] [Window][To TestLayer Transition]
Pos=0,366 Pos=0,366
Size=590,354 Size=270,354
Collapsed=0 Collapsed=0
DockId=0x0000000A,0 DockId=0x0000000B,0
[Window][To AppLayer Transition] [Window][To AppLayer Transition]
Pos=0,0 Pos=0,0
Size=1280,720 Size=1280,364
Collapsed=0 Collapsed=0
DockId=0x00000009,0 DockId=0x00000009,0
@@ -134,15 +135,17 @@ Column 1 Width=86
Column 2 Width=86 Column 2 Width=86
[Docking][Data] [Docking][Data]
DockSpace ID=0x08BD597D Window=0x1BBC0F80 Pos=0,0 Size=1280,720 Split=Y DockSpace ID=0x08BD597D Window=0x1BBC0F80 Pos=0,0 Size=1280,720 Split=Y
DockNode ID=0x00000003 Parent=0x08BD597D SizeRef=1280,101 Split=X Selected=0xAA1D0058 DockNode ID=0x00000003 Parent=0x08BD597D SizeRef=1280,101 Split=X Selected=0xAA1D0058
DockNode ID=0x00000001 Parent=0x00000003 SizeRef=618,101 Selected=0xAA1D0058 DockNode ID=0x00000001 Parent=0x00000003 SizeRef=618,101 Selected=0xAA1D0058
DockNode ID=0x00000002 Parent=0x00000003 SizeRef=660,101 Selected=0x561EDE67 DockNode ID=0x00000002 Parent=0x00000003 SizeRef=660,101 Selected=0x561EDE67
DockNode ID=0x00000004 Parent=0x08BD597D SizeRef=1280,617 Split=X DockNode ID=0x00000004 Parent=0x08BD597D SizeRef=1280,617 Split=X
DockNode ID=0x00000005 Parent=0x00000004 SizeRef=590,724 Split=Y Selected=0x0FC82981 DockNode ID=0x00000005 Parent=0x00000004 SizeRef=582,724 Split=Y Selected=0x0FC82981
DockNode ID=0x00000007 Parent=0x00000005 SizeRef=590,360 Split=Y Selected=0x0FC82981 DockNode ID=0x00000007 Parent=0x00000005 SizeRef=590,360 Split=Y Selected=0x0FC82981
DockNode ID=0x00000009 Parent=0x00000007 SizeRef=590,364 CentralNode=1 Selected=0xB300D6F1 DockNode ID=0x00000009 Parent=0x00000007 SizeRef=590,364 CentralNode=1 Selected=0x0FC82981
DockNode ID=0x0000000A Parent=0x00000007 SizeRef=590,354 Selected=0x4443B0A2 DockNode ID=0x0000000A Parent=0x00000007 SizeRef=590,354 Split=X Selected=0x4443B0A2
DockNode ID=0x00000008 Parent=0x00000005 SizeRef=590,358 Selected=0x5259B841 DockNode ID=0x0000000B Parent=0x0000000A SizeRef=270,354 Selected=0x4443B0A2
DockNode ID=0x00000006 Parent=0x00000004 SizeRef=688,724 Selected=0x5E5F7166 DockNode ID=0x0000000C Parent=0x0000000A SizeRef=310,354 Selected=0xD66F58E1
DockNode ID=0x00000008 Parent=0x00000005 SizeRef=590,358 Selected=0x5259B841
DockNode ID=0x00000006 Parent=0x00000004 SizeRef=696,724 Selected=0x5E5F7166