2021-05-25 16:24:05 +00:00
|
|
|
#pragma once
|
|
|
|
|
2021-05-26 16:23:44 +00:00
|
|
|
#include <set>
|
|
|
|
#include <string_view>
|
|
|
|
|
|
|
|
#include "RetroTypes.hpp"
|
2021-05-27 01:35:46 +00:00
|
|
|
#include "Runtime/World/CActor.hpp"
|
2021-05-27 04:56:25 +00:00
|
|
|
#include "Runtime/World/CEntity.hpp"
|
2021-05-31 05:14:07 +00:00
|
|
|
#include "Runtime/ImGuiPlayerLoadouts.hpp"
|
2021-05-27 04:56:25 +00:00
|
|
|
|
|
|
|
#include "hecl/CVarCommons.hpp"
|
|
|
|
#include "hecl/CVarManager.hpp"
|
2021-05-26 16:23:44 +00:00
|
|
|
|
2021-07-12 00:58:16 +00:00
|
|
|
#include <zeus/CEulerAngles.hpp>
|
|
|
|
|
2021-05-25 16:24:05 +00:00
|
|
|
namespace metaforce {
|
2021-05-26 16:23:44 +00:00
|
|
|
void ImGuiStringViewText(std::string_view text);
|
2021-05-27 04:56:25 +00:00
|
|
|
void ImGuiTextCenter(std::string_view text);
|
2021-05-31 20:09:58 +00:00
|
|
|
std::string ImGuiLoadStringTable(CAssetId stringId, int idx);
|
2021-05-26 16:23:44 +00:00
|
|
|
|
2021-05-27 01:35:46 +00:00
|
|
|
struct ImGuiEntityEntry {
|
|
|
|
TUniqueId uid = kInvalidUniqueId;
|
|
|
|
CEntity* ent = nullptr;
|
|
|
|
std::string_view type;
|
|
|
|
std::string_view name;
|
|
|
|
bool active = false;
|
|
|
|
bool isActor = false;
|
|
|
|
|
2021-05-27 04:56:25 +00:00
|
|
|
ImGuiEntityEntry() = default;
|
2021-05-27 01:35:46 +00:00
|
|
|
ImGuiEntityEntry(TUniqueId uid, CEntity* ent, std::string_view type, std::string_view name, bool active)
|
|
|
|
: uid(uid), ent(ent), type(type), name(name), active(active) {}
|
|
|
|
|
2021-05-27 15:52:05 +00:00
|
|
|
[[nodiscard]] CActor* AsActor() const { return isActor ? static_cast<CActor*>(ent) : nullptr; }
|
2021-05-27 01:35:46 +00:00
|
|
|
};
|
|
|
|
|
2021-05-25 16:24:05 +00:00
|
|
|
class ImGuiConsole {
|
|
|
|
public:
|
2021-05-26 16:23:44 +00:00
|
|
|
static std::set<TUniqueId> inspectingEntities;
|
2021-06-06 23:53:41 +00:00
|
|
|
static std::array<ImGuiEntityEntry, kMaxEntities> entities;
|
2021-05-31 05:14:07 +00:00
|
|
|
static ImGuiPlayerLoadouts loadouts;
|
2021-05-26 16:23:44 +00:00
|
|
|
|
2021-05-27 04:56:25 +00:00
|
|
|
ImGuiConsole(hecl::CVarManager& cvarMgr, hecl::CVarCommons& cvarCommons)
|
|
|
|
: m_cvarMgr(cvarMgr), m_cvarCommons(cvarCommons) {}
|
2021-05-27 01:35:46 +00:00
|
|
|
void PreUpdate();
|
|
|
|
void PostUpdate();
|
2021-05-30 19:03:35 +00:00
|
|
|
void Shutdown();
|
|
|
|
void ShowAboutWindow(bool canClose, std::string_view errorString = ""sv);
|
2021-05-27 01:35:46 +00:00
|
|
|
|
|
|
|
static void BeginEntityRow(const ImGuiEntityEntry& entry);
|
|
|
|
static void EndEntityRow(const ImGuiEntityEntry& entry);
|
|
|
|
|
|
|
|
private:
|
2021-05-27 04:56:25 +00:00
|
|
|
hecl::CVarManager& m_cvarMgr;
|
|
|
|
hecl::CVarCommons& m_cvarCommons;
|
|
|
|
|
|
|
|
bool m_showInspectWindow = false;
|
|
|
|
bool m_showDemoWindow = false;
|
|
|
|
bool m_showAboutWindow = false;
|
2021-05-27 14:26:13 +00:00
|
|
|
bool m_showItemsWindow = false;
|
2021-05-27 20:55:30 +00:00
|
|
|
bool m_showLayersWindow = false;
|
2021-05-31 00:15:22 +00:00
|
|
|
bool m_showConsoleVariablesWindow = false;
|
2021-07-12 00:58:16 +00:00
|
|
|
bool m_showPlayerTransformEditor = false;
|
|
|
|
std::optional<zeus::CVector3f> m_savedLocation;
|
|
|
|
std::optional<zeus::CEulerAngles> m_savedRotation;
|
2021-05-27 04:56:25 +00:00
|
|
|
|
|
|
|
bool m_paused = false;
|
|
|
|
bool m_stepFrame = false;
|
2021-05-31 01:44:02 +00:00
|
|
|
bool m_isVisible = false;
|
2021-05-27 04:56:25 +00:00
|
|
|
|
|
|
|
bool m_inspectActiveOnly = false;
|
2021-05-28 15:57:23 +00:00
|
|
|
bool m_inspectCurrentAreaOnly = false;
|
2021-05-31 01:23:20 +00:00
|
|
|
|
2021-06-02 11:49:03 +00:00
|
|
|
std::string m_inspectFilterText;
|
|
|
|
std::string m_layersFilterText;
|
|
|
|
std::string m_cvarFiltersText;
|
2021-05-27 04:56:25 +00:00
|
|
|
|
|
|
|
// Debug overlays
|
|
|
|
bool m_frameCounter = m_cvarCommons.m_debugOverlayShowFrameCounter->toBoolean();
|
|
|
|
bool m_frameRate = m_cvarCommons.m_debugOverlayShowFramerate->toBoolean();
|
|
|
|
bool m_inGameTime = m_cvarCommons.m_debugOverlayShowInGameTime->toBoolean();
|
|
|
|
bool m_roomTimer = m_cvarCommons.m_debugOverlayShowRoomTimer->toBoolean();
|
|
|
|
bool m_playerInfo = m_cvarCommons.m_debugOverlayPlayerInfo->toBoolean();
|
|
|
|
bool m_worldInfo = m_cvarCommons.m_debugOverlayWorldInfo->toBoolean();
|
|
|
|
bool m_areaInfo = m_cvarCommons.m_debugOverlayAreaInfo->toBoolean();
|
2021-05-31 00:29:27 +00:00
|
|
|
bool m_layerInfo = m_cvarCommons.m_debugOverlayLayerInfo->toBoolean();
|
2021-05-27 04:56:25 +00:00
|
|
|
bool m_randomStats = m_cvarCommons.m_debugOverlayShowRandomStats->toBoolean();
|
|
|
|
bool m_resourceStats = m_cvarCommons.m_debugOverlayShowResourceStats->toBoolean();
|
2021-05-30 07:52:20 +00:00
|
|
|
bool m_showInput = m_cvarCommons.m_debugOverlayShowInput->toBoolean();
|
2021-05-31 01:23:20 +00:00
|
|
|
bool m_developer = m_cvarMgr.findCVar("developer")->toBoolean();
|
|
|
|
bool m_cheats = m_cvarMgr.findCVar("cheats")->toBoolean();
|
|
|
|
bool m_isInitialized = false;
|
2021-05-27 04:56:25 +00:00
|
|
|
|
|
|
|
int m_debugOverlayCorner = 2; // bottom-left
|
2021-06-06 21:22:59 +00:00
|
|
|
int m_inputOverlayCorner = 3; // bottom-right
|
2021-05-27 04:56:25 +00:00
|
|
|
const void* m_currentRoom = nullptr;
|
|
|
|
double m_lastRoomTime = 0.f;
|
|
|
|
double m_currentRoomStart = 0.f;
|
2021-05-31 15:03:41 +00:00
|
|
|
float m_menuHintTime = 5.f;
|
2022-02-09 08:54:53 +00:00
|
|
|
std::string m_controllerName;
|
|
|
|
u32 m_whichController = -1;
|
2021-05-27 04:56:25 +00:00
|
|
|
|
|
|
|
void ShowAppMainMenuBar(bool canInspect);
|
|
|
|
void ShowMenuGame();
|
|
|
|
bool ShowEntityInfoWindow(TUniqueId uid);
|
|
|
|
void ShowInspectWindow(bool* isOpen);
|
|
|
|
void LerpDebugColor(CActor* act);
|
|
|
|
void UpdateEntityEntries();
|
|
|
|
void ShowDebugOverlay();
|
2021-05-27 14:26:13 +00:00
|
|
|
void ShowItemsWindow();
|
2021-05-27 20:55:30 +00:00
|
|
|
void ShowLayersWindow();
|
2021-05-31 00:15:22 +00:00
|
|
|
void ShowConsoleVariablesWindow();
|
2021-05-31 15:03:41 +00:00
|
|
|
void ShowMenuHint();
|
2021-06-06 21:22:59 +00:00
|
|
|
void ShowInputViewer();
|
2021-06-06 23:58:27 +00:00
|
|
|
void SetOverlayWindowLocation(int corner) const;
|
|
|
|
void ShowCornerContextMenu(int& corner, int avoidCorner) const;
|
2021-07-12 00:58:16 +00:00
|
|
|
void ShowPlayerTransformEditor();
|
2021-05-25 16:24:05 +00:00
|
|
|
};
|
2021-05-25 19:58:18 +00:00
|
|
|
} // namespace metaforce
|