Compare commits

...

14 Commits

10 changed files with 133 additions and 50 deletions

2
.gitmodules vendored
View File

@@ -4,4 +4,4 @@
branch = develop
[submodule "libs/SakuraCore"]
path = libs/SakuraCore
url = http://rpiserver.ddns.net:3000/htamas1210/SakuraCore.git
url = https://spaceglitter.spacestation.hu/htamas1210/SakuraCore.git

View File

@@ -1,7 +1,13 @@
#include "AppLayer.h"
#include "Application.h"
#include "Event.h"
#include "InputEvents.h"
#include "Layer.h"
#include "Log.h"
#include "TestLayer.h"
#include "WindowEvents.h"
#include "imgui.h"
#include <string>
AppLayer::AppLayer() : Layer("AppLayer", true) {}
@@ -13,7 +19,25 @@ void AppLayer::OnImGuiRender() {
ImGui::Text("Application avg %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
if (ImGui::Button("Quit")) {
Application::Get().SetRunningState(false);
SakuraVNE::Application::Get().SetRunningState(false);
}
ImGui::End();
ImGui::Begin("To TestLayer Transition");
if (ImGui::Button("Transition")) {
TransitionTo<TestLayer>();
}
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 "WindowEvents.h"
class AppLayer : public SakuraVNE::Layer {
public:
AppLayer();
virtual ~AppLayer() = default;
virtual void OnImGuiRender() override;
virtual void OnEvent(SakuraVNE::Event &event) override;
private:
// bool OnMouseButtonPressed(Core::MouseButtonPressedEvent &event);
// bool OnMouseMoved(Core::MouseMovedEvent &event);
// bool OnWindowClosed(Core::WindowClosedEvent &event);
bool OnMouseButtonPressed(SakuraVNE::MouseButtonPressedEvent &event);
bool OnMouseMoved(SakuraVNE::MouseMovedEvent &event);
bool OnWindowClosed(SakuraVNE::WindowClosedEvent &event);
int m_ClickCounter = 0;
};

24
SakuraVNE/src/Overlay.cpp Normal file
View File

@@ -0,0 +1,24 @@
#include "Overlay.h"
#include "AppLayer.h"
#include "Application.h"
#include "Layer.h"
#include "TestLayer.h"
#include "imgui.h"
Overlay::Overlay() : Layer("Overlay", true) {}
void Overlay::OnImGuiRender() {
ImGuiIO &io = ImGui::GetIO();
ImGui::Begin("Overlay Transition");
if (ImGui::Button("Overlay Transition")) {
auto testLayer = SakuraVNE::Application::Get().GetLayer<TestLayer>();
if (testLayer) {
testLayer->TransitionTo<AppLayer>();
} else {
auto appLayer = SakuraVNE::Application::Get().GetLayer<AppLayer>();
appLayer->TransitionTo<TestLayer>();
}
}
ImGui::End();
}

11
SakuraVNE/src/Overlay.h Normal file
View File

@@ -0,0 +1,11 @@
#pragma once
#include "Layer.h"
class Overlay : public SakuraVNE::Layer {
public:
Overlay();
virtual ~Overlay() = default;
virtual void OnImGuiRender() override;
};

View File

@@ -0,0 +1,16 @@
#include "TestLayer.h"
#include "AppLayer.h"
#include "Layer.h"
#include "imgui.h"
TestLayer::TestLayer() : Layer("TestLayer", true) {}
void TestLayer::OnImGuiRender() {
ImGuiIO &io = ImGui::GetIO();
ImGui::Begin("To AppLayer Transition");
if (ImGui::Button("Transition")) {
TransitionTo<AppLayer>();
}
ImGui::End();
}

11
SakuraVNE/src/TestLayer.h Normal file
View File

@@ -0,0 +1,11 @@
#pragma once
#include "Layer.h"
class TestLayer : public SakuraVNE::Layer {
public:
TestLayer();
virtual ~TestLayer() = default;
virtual void OnImGuiRender() override;
};

View File

@@ -1,15 +1,20 @@
#include "AppLayer.h"
#include "Application.h"
#include "Overlay.h"
#include "SDL3/SDL_main.h"
#include "SDL3/SDL_video.h"
int main(int argc, char *argv[]) {
AppData appData;
SakuraVNE::AppData appData;
appData.name = "Sakura Visual Novel Creator";
appData.windowdata.windowFlags = (SDL_WindowFlags)(SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIGH_PIXEL_DENSITY);
appData.windowdata.title = appData.name;
appData.windowdata.width = 1280;
appData.windowdata.height = 720;
Application app(appData);
SakuraVNE::Application app(appData);
app.PushLayer<AppLayer>();
app.PushOverlay<Overlay>();
app.Run();
return 0;

View File

@@ -1,53 +1,40 @@
[Window][Debug##Default]
Pos=60,60
Size=400,400
Collapsed=0
[Window][Hello World!]
Pos=147,38
Size=311,180
Collapsed=0
[Window][Dear ImGui Demo]
Pos=730,0
Size=550,720
Collapsed=0
DockId=0x00000007,0
[Window][Test window]
Size=618,101
Collapsed=0
DockId=0x00000001,0
[Window][Delta time]
Pos=60,60
Size=178,67
Collapsed=0
[Window][Calculated Delta time]
Size=1280,101
Collapsed=0
DockId=0x00000002,0
[Window][WindowOverViewport_11111111]
Pos=0,0
Size=1280,720
Collapsed=0
[Window][Debug##Default]
Pos=60,60
Size=400,400
Collapsed=0
[Window][Framerate]
Pos=0,0
Size=442,720
Size=728,458
Collapsed=0
DockId=0x00000001,0
[Window][Dear ImGui Demo]
Pos=730,0
Size=550,720
Collapsed=0
DockId=0x00000004,0
[Window][To TestLayer Transition]
Pos=0,460
Size=728,260
Collapsed=0
DockId=0x00000002,0
[Window][Overlay Transition]
Pos=543,330
Size=301,164
Collapsed=0
DockId=0x00000006,0
[Docking][Data]
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=0x00000001 Parent=0x00000003 SizeRef=618,101 Selected=0xAA1D0058
DockNode ID=0x00000002 Parent=0x00000003 SizeRef=660,101 Selected=0x561EDE67
DockNode ID=0x00000004 Parent=0x08BD597D SizeRef=1280,617 Split=X
DockNode ID=0x00000005 Parent=0x00000004 SizeRef=728,720 Split=X
DockNode ID=0x00000006 Parent=0x00000005 SizeRef=442,617 Selected=0x0FC82981
DockNode ID=0x00000008 Parent=0x00000005 SizeRef=284,617 CentralNode=1
DockNode ID=0x00000007 Parent=0x00000004 SizeRef=550,720 Selected=0x5E5F7166
DockSpace ID=0x08BD597D Window=0x1BBC0F80 Pos=0,0 Size=1280,720 Split=X
DockNode ID=0x00000003 Parent=0x08BD597D SizeRef=728,720 Split=Y
DockNode ID=0x00000001 Parent=0x00000003 SizeRef=1280,458 CentralNode=1 Selected=0x0FC82981
DockNode ID=0x00000002 Parent=0x00000003 SizeRef=1280,260 Selected=0x4443B0A2
DockNode ID=0x00000004 Parent=0x08BD597D SizeRef=550,720 Selected=0x5E5F7166