migrate main
This commit is contained in:
50
include/td/display/Display.h
Normal file
50
include/td/display/Display.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <SDL3/SDL_keycode.h>
|
||||
#include <SDL3/SDL_video.h>
|
||||
#include <td/common/StateMachine.h>
|
||||
#include <td/misc/Signal.h>
|
||||
|
||||
namespace td {
|
||||
|
||||
class Display : public StateMachine<Display, void, float> {
|
||||
private:
|
||||
SDL_Window* m_Window;
|
||||
SDL_GLContext m_GLContext;
|
||||
|
||||
int m_LastWidth, m_LastHeight;
|
||||
float m_AspectRatio;
|
||||
|
||||
bool m_ShouldClose;
|
||||
|
||||
public:
|
||||
utils::Signal<float> OnAspectRatioChange;
|
||||
utils::Signal<SDL_Keycode> OnKeyDown;
|
||||
|
||||
Display(int a_Width, int a_Height, const std::string& a_Title);
|
||||
~Display();
|
||||
|
||||
void PollEvents();
|
||||
void Update(float a_Delta) override;
|
||||
void Close();
|
||||
|
||||
bool IsCloseRequested() {
|
||||
return m_ShouldClose;
|
||||
}
|
||||
|
||||
float GetAspectRatio() {
|
||||
return m_AspectRatio;
|
||||
}
|
||||
|
||||
int GetWindowWidth() {
|
||||
return m_LastWidth;
|
||||
}
|
||||
|
||||
int GetWindowHeight() {
|
||||
return m_LastHeight;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace td
|
||||
16
include/td/display/DisplayState.h
Normal file
16
include/td/display/DisplayState.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <td/display/Display.h>
|
||||
#include <td/misc/SlotGuard.h>
|
||||
|
||||
namespace td {
|
||||
class DisplayState : public Display::State, private utils::SlotGuard {
|
||||
public:
|
||||
DisplayState(Display& a_Display);
|
||||
virtual ~DisplayState() {}
|
||||
|
||||
protected:
|
||||
virtual void OnAspectRatioChange(float a_Ratio) {}
|
||||
virtual void OnKeyDown(SDL_Keycode a_Key) {}
|
||||
};
|
||||
} // namespace td
|
||||
33
include/td/display/state/DebugWorldState.h
Normal file
33
include/td/display/state/DebugWorldState.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include <client/Client.h>
|
||||
#include <server/Server.h>
|
||||
#include <td/display/DisplayState.h>
|
||||
#include <td/render/Renderer.h>
|
||||
#include <td/simulation/ClientSimulation.h>
|
||||
|
||||
namespace td {
|
||||
|
||||
class ClientHandler;
|
||||
|
||||
class DebugWorldState : public DisplayState {
|
||||
private:
|
||||
render::RenderPipeline m_Renderer;
|
||||
std::unique_ptr<client::Client> m_Client;
|
||||
std::unique_ptr<server::Server> m_Server;
|
||||
std::unique_ptr<sim::ClientSimulation> m_Simulation;
|
||||
render::Camera m_Camera;
|
||||
std::unique_ptr<ClientHandler> m_ClientHandler;
|
||||
|
||||
public:
|
||||
DebugWorldState(Display& a_Display);
|
||||
~DebugWorldState();
|
||||
|
||||
virtual void Update(float a_Delta) override;
|
||||
|
||||
protected:
|
||||
virtual void OnAspectRatioChange(float a_Ratio) override;
|
||||
virtual void OnKeyDown(SDL_Keycode a_Key) override;
|
||||
};
|
||||
|
||||
} // namespace td
|
||||
Reference in New Issue
Block a user