metaforce/Runtime/ImGuiConsole.hpp

169 lines
5.9 KiB
C++
Raw Permalink Normal View History

2021-05-25 09:24:05 -07:00
#pragma once
2021-05-26 09:23:44 -07:00
#include <set>
#include <string_view>
2023-10-22 09:21:20 -07:00
#include <deque>
2021-05-26 09:23:44 -07:00
#include "Runtime/RetroTypes.hpp"
#include "Runtime/World/CActor.hpp"
2021-05-26 21:56:25 -07:00
#include "Runtime/World/CEntity.hpp"
2021-05-30 22:14:07 -07:00
#include "Runtime/ImGuiPlayerLoadouts.hpp"
#include "Runtime/ImGuiControllerConfig.hpp"
2021-05-26 21:56:25 -07:00
#include "Runtime/ConsoleVariables/CVarCommons.hpp"
#include "Runtime/ConsoleVariables/CVarManager.hpp"
2021-05-26 09:23:44 -07:00
2021-07-11 17:58:16 -07:00
#include <zeus/CEulerAngles.hpp>
2022-05-27 12:52:16 -07:00
#if __APPLE__
#include <TargetConditionals.h>
#endif
2021-05-25 09:24:05 -07:00
namespace metaforce {
2021-05-26 09:23:44 -07:00
void ImGuiStringViewText(std::string_view text);
2021-05-26 21:56:25 -07:00
void ImGuiTextCenter(std::string_view text);
std::string ImGuiLoadStringTable(CAssetId stringId, int idx);
2021-05-26 09:23:44 -07: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-26 21:56:25 -07:00
ImGuiEntityEntry() = default;
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) {}
[[nodiscard]] CActor* AsActor() const { return isActor ? static_cast<CActor*>(ent) : nullptr; }
};
2022-05-27 12:52:16 -07:00
struct Toast {
std::string message;
float remain;
float current = 0.f;
Toast(std::string message, float duration) noexcept : message(std::move(message)), remain(duration) {}
};
2021-05-25 09:24:05 -07:00
class ImGuiConsole {
public:
2021-05-26 09:23:44 -07:00
static std::set<TUniqueId> inspectingEntities;
2021-06-06 16:53:41 -07:00
static std::array<ImGuiEntityEntry, kMaxEntities> entities;
2021-05-30 22:14:07 -07:00
static ImGuiPlayerLoadouts loadouts;
2021-05-26 09:23:44 -07:00
ImGuiConsole(CVarManager& cvarMgr, CVarCommons& cvarCommons);
void PreUpdate();
void PostUpdate();
void Shutdown();
static void BeginEntityRow(const ImGuiEntityEntry& entry);
static void EndEntityRow(const ImGuiEntityEntry& entry);
2022-05-27 12:52:16 -07:00
void ControllerAdded(uint32_t idx);
void ControllerRemoved(uint32_t idx);
2022-08-09 15:29:12 -07:00
void ToggleVisible();
2022-05-27 12:52:16 -07:00
std::optional<std::string> m_errorString;
std::optional<std::string> m_gameDiscSelected;
bool m_quitRequested = false;
private:
CVarManager& m_cvarMgr;
CVarCommons& m_cvarCommons;
2021-05-26 21:56:25 -07:00
bool m_showInspectWindow = false;
bool m_showDemoWindow = false;
bool m_showAboutWindow = false;
2021-05-27 07:26:13 -07:00
bool m_showItemsWindow = false;
2021-05-27 13:55:30 -07:00
bool m_showLayersWindow = false;
2021-05-30 17:15:22 -07:00
bool m_showConsoleVariablesWindow = false;
2021-07-11 17:58:16 -07:00
bool m_showPlayerTransformEditor = false;
bool m_showPreLaunchSettingsWindow = false;
2021-07-11 17:58:16 -07:00
std::optional<zeus::CVector3f> m_savedLocation;
std::optional<zeus::CEulerAngles> m_savedRotation;
2021-05-26 21:56:25 -07:00
bool m_paused = false;
bool m_stepFrame = false;
bool m_isVisible = false;
2021-05-26 21:56:25 -07:00
bool m_inspectActiveOnly = false;
2021-05-28 08:57:23 -07:00
bool m_inspectCurrentAreaOnly = false;
2021-05-30 18:23:20 -07:00
std::string m_inspectFilterText;
std::string m_layersFilterText;
std::string m_cvarFiltersText;
std::string m_lastDiscPath = m_cvarCommons.m_lastDiscPath->toLiteral();
2021-05-26 21:56:25 -07:00
// Debug overlays
bool m_frameCounter = m_cvarCommons.m_debugOverlayShowFrameCounter->toBoolean();
2022-05-27 12:52:16 -07:00
#if TARGET_OS_TV
bool m_frameRate = true;
#else
2021-05-26 21:56:25 -07:00
bool m_frameRate = m_cvarCommons.m_debugOverlayShowFramerate->toBoolean();
2022-05-27 12:52:16 -07:00
#endif
2021-05-26 21:56:25 -07:00
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-30 17:29:27 -07:00
bool m_layerInfo = m_cvarCommons.m_debugOverlayLayerInfo->toBoolean();
2021-05-26 21:56:25 -07:00
bool m_randomStats = m_cvarCommons.m_debugOverlayShowRandomStats->toBoolean();
bool m_resourceStats = m_cvarCommons.m_debugOverlayShowResourceStats->toBoolean();
bool m_showInput = m_cvarCommons.m_debugOverlayShowInput->toBoolean();
bool m_drawAiPath = m_cvarCommons.m_debugToolDrawAiPath->toBoolean();
bool m_drawCollisionActors = m_cvarCommons.m_debugToolDrawCollisionActors->toBoolean();
bool m_drawPlatformCollision = m_cvarCommons.m_debugToolDrawPlatformCollision->toBoolean();
bool m_drawMazePath = m_cvarCommons.m_debugToolDrawMazePath->toBoolean();
bool m_drawLighting = m_cvarCommons.m_debugToolDrawLighting->toBoolean();
2022-05-27 12:52:16 -07:00
#if TARGET_OS_IOS
bool m_pipelineInfo = false;
2022-07-29 13:16:55 -07:00
bool m_drawCallInfo = false;
bool m_bufferInfo = false;
2022-05-27 12:52:16 -07:00
#else
bool m_pipelineInfo = m_cvarCommons.m_debugOverlayPipelineInfo->toBoolean(); // TODO cvar
bool m_drawCallInfo = m_cvarCommons.m_debugOverlayDrawCallInfo->toBoolean(); // TODO cvar
bool m_bufferInfo = m_cvarCommons.m_debugOverlayBufferInfo->toBoolean(); // TODO cvar
2022-05-27 12:52:16 -07:00
#endif
2021-05-30 18:23:20 -07:00
bool m_developer = m_cvarMgr.findCVar("developer")->toBoolean();
bool m_cheats = m_cvarMgr.findCVar("cheats")->toBoolean();
bool m_isInitialized = false;
bool m_isLaunchInitialized = false;
2021-05-26 21:56:25 -07:00
int m_debugOverlayCorner = m_cvarCommons.m_debugOverlayCorner->toSigned();
int m_inputOverlayCorner = m_cvarCommons.m_debugInputOverlayCorner->toSigned();
2021-05-26 21:56:25 -07:00
const void* m_currentRoom = nullptr;
double m_lastRoomTime = 0.f;
double m_currentRoomStart = 0.f;
2022-05-27 12:52:16 -07:00
std::deque<Toast> m_toasts;
std::string m_controllerName;
u32 m_whichController = -1;
2021-05-26 21:56:25 -07:00
bool m_controllerConfigVisible = false;
ImGuiControllerConfig m_controllerConfig;
void ShowAboutWindow(bool preLaunch);
void ShowAppMainMenuBar(bool canInspect, bool preLaunch);
2021-05-26 21:56:25 -07:00
void ShowMenuGame();
bool ShowEntityInfoWindow(TUniqueId uid);
void ShowInspectWindow(bool* isOpen);
void LerpDebugColor(CActor* act);
void UpdateEntityEntries();
void ShowDebugOverlay();
2021-05-27 07:26:13 -07:00
void ShowItemsWindow();
2021-05-27 13:55:30 -07:00
void ShowLayersWindow();
2021-05-30 17:15:22 -07:00
void ShowConsoleVariablesWindow();
2022-05-27 12:52:16 -07:00
void ShowToasts();
2021-06-06 14:22:59 -07:00
void ShowInputViewer();
2021-06-06 16:58:27 -07:00
void SetOverlayWindowLocation(int corner) const;
bool ShowCornerContextMenu(int& corner, int avoidCorner) const;
2021-07-11 17:58:16 -07:00
void ShowPlayerTransformEditor();
2022-05-03 16:36:30 -07:00
void ShowPipelineProgress();
void ShowPreLaunchSettingsWindow();
2021-05-25 09:24:05 -07:00
};
2022-08-09 15:28:42 -07:00
AuroraBackend backend_from_string(const std::string& str);
std::string_view backend_to_string(AuroraBackend backend);
std::string_view backend_name(AuroraBackend backend);
2021-05-25 12:58:18 -07:00
} // namespace metaforce