feat: add basic canvas / improve inspector
This commit is contained in:
@@ -6,10 +6,10 @@
|
||||
#include <destrum/App.h>
|
||||
#include <destrum/Scene/SceneManager.h>
|
||||
#include <destrum/Graphics/RenderResources.h>
|
||||
#include <destrum/Util/RectGizmo.h>
|
||||
#include <destrum/Util/TransformGizmo.h>
|
||||
|
||||
#include "destrum/Graphics/Resources/Cubemap.h"
|
||||
#include "destrum/Graphics/Resources/Font.h"
|
||||
#include "destrum/ObjectModel/GameObject.h"
|
||||
|
||||
#include <scenes/MainScene.h>
|
||||
@@ -31,7 +31,6 @@ public:
|
||||
|
||||
private:
|
||||
void setupSkybox();
|
||||
void drawCrosshair();
|
||||
void updateViewMode();
|
||||
[[nodiscard]] CameraComponent* getSceneCamera() const;
|
||||
[[nodiscard]] Camera& getViewCamera();
|
||||
@@ -59,8 +58,8 @@ private:
|
||||
MainSceneObjects mainScene{};
|
||||
|
||||
ImageID debug2DTexture{NULL_IMAGE_ID};
|
||||
Font hudFont;
|
||||
TransformGizmo transformGizmo;
|
||||
RectGizmo rectGizmo;
|
||||
|
||||
char scenePath[512]{"scenes/debug_scene.json"};
|
||||
char newSceneName[128]{"EmptyScene"};
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef LIGHTKEEPER_CHECKPOINT_H
|
||||
#define LIGHTKEEPER_CHECKPOINT_H
|
||||
|
||||
#include <glm/vec3.hpp>
|
||||
|
||||
#include <destrum/ObjectModel/Component.h>
|
||||
|
||||
class Checkpoint final : public Component {
|
||||
public:
|
||||
explicit Checkpoint(GameObject& parent);
|
||||
|
||||
std::string GetTypeName() const override { return "Checkpoint"; }
|
||||
|
||||
void OnTriggerEnter(GameObject* other) override;
|
||||
|
||||
nlohmann::json Serialize() const override;
|
||||
void Deserialize(const nlohmann::json& data) override;
|
||||
void ImGuiInspector() override;
|
||||
|
||||
void SetSpawnOffset(const glm::vec3& offset) { m_SpawnOffset = offset; }
|
||||
[[nodiscard]] glm::vec3 GetSpawnPoint() const;
|
||||
|
||||
private:
|
||||
glm::vec3 m_SpawnOffset{0.0f};
|
||||
};
|
||||
|
||||
#endif // LIGHTKEEPER_CHECKPOINT_H
|
||||
@@ -0,0 +1,43 @@
|
||||
#ifndef LIGHTKEEPER_CROSSHAIRUI_H
|
||||
#define LIGHTKEEPER_CROSSHAIRUI_H
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <destrum/ObjectModel/Component.h>
|
||||
#include <destrum/ObjectModel/ObjectRef.h>
|
||||
|
||||
// Shows the crosshair while the player is possessed, tints and grows it and shows the focus
|
||||
// indicator while the player looks at an Interactable
|
||||
class CrosshairUI final : public Component {
|
||||
public:
|
||||
explicit CrosshairUI(GameObject& parent);
|
||||
|
||||
std::string GetTypeName() const override { return "CrosshairUI"; }
|
||||
|
||||
void LateUpdate(float dt) override;
|
||||
|
||||
nlohmann::json Serialize() const override;
|
||||
void Deserialize(const nlohmann::json& data) override;
|
||||
void ResolveReferences(const ObjectMap& objects) override;
|
||||
void ImGuiInspector() override;
|
||||
|
||||
void SetPlayer(const GameObject& player) { m_Player = ObjectRef(player); }
|
||||
void SetCrosshair(const GameObject& crosshair) { m_Crosshair = ObjectRef(crosshair); }
|
||||
void SetFocusIndicator(const GameObject& indicator) { m_FocusIndicator = ObjectRef(indicator); }
|
||||
|
||||
[[nodiscard]] const ObjectRef& GetPlayer() const { return m_Player; }
|
||||
[[nodiscard]] const ObjectRef& GetCrosshair() const { return m_Crosshair; }
|
||||
[[nodiscard]] const ObjectRef& GetFocusIndicator() const { return m_FocusIndicator; }
|
||||
|
||||
private:
|
||||
ObjectRef m_Player;
|
||||
ObjectRef m_Crosshair;
|
||||
ObjectRef m_FocusIndicator;
|
||||
|
||||
glm::vec4 m_Color{1.0f, 1.0f, 1.0f, 0.8f};
|
||||
glm::vec4 m_FocusedColor{1.0f, 0.8f, 0.25f, 1.0f};
|
||||
float m_Size{10.0f};
|
||||
float m_FocusedSize{16.0f};
|
||||
};
|
||||
|
||||
#endif // LIGHTKEEPER_CROSSHAIRUI_H
|
||||
@@ -39,6 +39,7 @@ public:
|
||||
[[nodiscard]] float GetMouseSensitivity() const { return m_MouseSensitivity; }
|
||||
|
||||
[[nodiscard]] bool IsGrounded() const { return m_Grounded; }
|
||||
void Teleport(const glm::vec3& worldPosition);
|
||||
|
||||
[[nodiscard]] Interactable* GetFocusedInteractable() const { return m_FocusedInteractable; }
|
||||
[[nodiscard]] glm::vec3 GetLookDirection() const;
|
||||
|
||||
@@ -1,21 +1,31 @@
|
||||
#ifndef LIGHTKEEPER_GAMECOMPONENTLIST_H
|
||||
#define LIGHTKEEPER_GAMECOMPONENTLIST_H
|
||||
|
||||
#include <components/Checkpoint.h>
|
||||
#include <components/CrosshairUI.h>
|
||||
#include <components/Door.h>
|
||||
#include <components/FirstPersonController.h>
|
||||
#include <components/InteractableButton.h>
|
||||
#include <components/LightToggle.h>
|
||||
#include <components/MovingPlatform.h>
|
||||
#include <components/PlayerRespawn.h>
|
||||
#include <components/PrintComponent.h>
|
||||
#include <components/TriggerLoggerComponent.h>
|
||||
#include <components/WinGoal.h>
|
||||
#include <components/WinScreenUI.h>
|
||||
|
||||
#define LIGHTKEEPER_GAME_COMPONENTS(X) \
|
||||
X(Checkpoint) \
|
||||
X(CrosshairUI) \
|
||||
X(Door) \
|
||||
X(FirstPersonController) \
|
||||
X(InteractableButton) \
|
||||
X(LightToggle) \
|
||||
X(MovingPlatform) \
|
||||
X(PlayerRespawn) \
|
||||
X(PrintComponent) \
|
||||
X(TriggerLoggerComponent)
|
||||
X(TriggerLoggerComponent) \
|
||||
X(WinGoal) \
|
||||
X(WinScreenUI)
|
||||
|
||||
#endif // LIGHTKEEPER_GAMECOMPONENTLIST_H
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
#ifndef LIGHTKEEPER_PLAYERRESPAWN_H
|
||||
#define LIGHTKEEPER_PLAYERRESPAWN_H
|
||||
|
||||
#include <glm/vec3.hpp>
|
||||
|
||||
#include <destrum/ObjectModel/Component.h>
|
||||
|
||||
class PlayerRespawn final : public Component {
|
||||
public:
|
||||
explicit PlayerRespawn(GameObject& parent);
|
||||
|
||||
std::string GetTypeName() const override { return "PlayerRespawn"; }
|
||||
|
||||
void Start() override;
|
||||
void FixedUpdate(float fixedDt) override;
|
||||
|
||||
nlohmann::json Serialize() const override;
|
||||
void Deserialize(const nlohmann::json& data) override;
|
||||
void ImGuiInspector() override;
|
||||
|
||||
void SetRespawnPoint(const glm::vec3& worldPosition);
|
||||
[[nodiscard]] const glm::vec3& GetRespawnPoint() const { return m_RespawnPoint; }
|
||||
|
||||
void SetKillHeight(float height) { m_KillHeight = height; }
|
||||
[[nodiscard]] float GetKillHeight() const { return m_KillHeight; }
|
||||
|
||||
void Respawn();
|
||||
|
||||
private:
|
||||
glm::vec3 m_RespawnPoint{0.0f};
|
||||
bool m_HasRespawnPoint{false};
|
||||
float m_KillHeight{-15.0f};
|
||||
};
|
||||
|
||||
#endif // LIGHTKEEPER_PLAYERRESPAWN_H
|
||||
@@ -0,0 +1,26 @@
|
||||
#ifndef LIGHTKEEPER_WINGOAL_H
|
||||
#define LIGHTKEEPER_WINGOAL_H
|
||||
|
||||
#include <components/Activatable.h>
|
||||
|
||||
class WinGoal final : public Activatable {
|
||||
public:
|
||||
explicit WinGoal(GameObject& parent);
|
||||
|
||||
std::string GetTypeName() const override { return "WinGoal"; }
|
||||
|
||||
nlohmann::json Serialize() const override;
|
||||
void Deserialize(const nlohmann::json& data) override;
|
||||
void ImGuiInspector() override;
|
||||
|
||||
[[nodiscard]] bool IsReached() const { return m_Reached; }
|
||||
void Reset() { m_Reached = false; }
|
||||
|
||||
protected:
|
||||
void OnActivate(GameObject& instigator) override;
|
||||
|
||||
private:
|
||||
bool m_Reached{false};
|
||||
};
|
||||
|
||||
#endif // LIGHTKEEPER_WINGOAL_H
|
||||
@@ -0,0 +1,32 @@
|
||||
#ifndef LIGHTKEEPER_WINSCREENUI_H
|
||||
#define LIGHTKEEPER_WINSCREENUI_H
|
||||
|
||||
#include <destrum/ObjectModel/Component.h>
|
||||
#include <destrum/ObjectModel/ObjectRef.h>
|
||||
|
||||
// Keeps the screen object active while the goal's WinGoal is reached
|
||||
class WinScreenUI final : public Component {
|
||||
public:
|
||||
explicit WinScreenUI(GameObject& parent);
|
||||
|
||||
std::string GetTypeName() const override { return "WinScreenUI"; }
|
||||
|
||||
void LateUpdate(float dt) override;
|
||||
|
||||
nlohmann::json Serialize() const override;
|
||||
void Deserialize(const nlohmann::json& data) override;
|
||||
void ResolveReferences(const ObjectMap& objects) override;
|
||||
void ImGuiInspector() override;
|
||||
|
||||
void SetGoal(const GameObject& goal) { m_Goal = ObjectRef(goal); }
|
||||
void SetScreen(const GameObject& screen) { m_Screen = ObjectRef(screen); }
|
||||
|
||||
[[nodiscard]] const ObjectRef& GetGoal() const { return m_Goal; }
|
||||
[[nodiscard]] const ObjectRef& GetScreen() const { return m_Screen; }
|
||||
|
||||
private:
|
||||
ObjectRef m_Goal;
|
||||
ObjectRef m_Screen;
|
||||
};
|
||||
|
||||
#endif // LIGHTKEEPER_WINSCREENUI_H
|
||||
@@ -19,7 +19,7 @@ struct MainSceneObjects {
|
||||
MaterialID sphereMaterial{};
|
||||
};
|
||||
|
||||
// Sun, ground, parkour course, models, trigger zone and the player
|
||||
// Sun, ground, parkour course, models, trigger zone, the player and the HUD
|
||||
MainSceneObjects BuildMainScene(Scene& scene, GfxDevice& gfxDevice, RenderResources& resources);
|
||||
|
||||
#endif // LIGHTKEEPER_MAINSCENE_H
|
||||
|
||||
Reference in New Issue
Block a user