diff --git a/mm/2s2h/BenGui/BenMenuBar.cpp b/mm/2s2h/BenGui/BenMenuBar.cpp index 5e8ef6e79..4c45c36f0 100644 --- a/mm/2s2h/BenGui/BenMenuBar.cpp +++ b/mm/2s2h/BenGui/BenMenuBar.cpp @@ -9,6 +9,7 @@ #include "2s2h/Enhancements/Enhancements.h" #include "2s2h/Enhancements/Graphics/MotionBlur.h" #include "2s2h/DeveloperTools/DeveloperTools.h" +#include "2s2h/DeveloperTools/WarpPoint.h" #include "HudEditor.h" extern bool ShouldClearTextureCacheAtEndOfFrame; @@ -408,6 +409,7 @@ void DrawDeveloperToolsMenu() { } } } + RenderWarpPointSection(); ImGui::Separator(); if (mCollisionViewerWindow) { UIWidgets::WindowButton("Collision Viewer", "gWindows.CollisionViewer", mCollisionViewerWindow, diff --git a/mm/2s2h/DeveloperTools/WarpPoint.cpp b/mm/2s2h/DeveloperTools/WarpPoint.cpp new file mode 100644 index 000000000..d74573335 --- /dev/null +++ b/mm/2s2h/DeveloperTools/WarpPoint.cpp @@ -0,0 +1,70 @@ +#include "WarpPoint.h" + +#include +#include "2s2h/BenGui/UIWidgets.hpp" +#include "window/gui/IconsFontAwesome4.h" + +extern "C" { +#include "z64.h" +#include "macros.h" +#include "functions.h" +extern PlayState* gPlayState; +extern SaveContext gSaveContext; +} + +#define CV "gDeveloperTools.WarpPoint." + +// 2S2H Added columns to scene table: entranceSceneId, betterMapSelectIndex, humanName +#define DEFINE_SCENE(_name, enumValue, _textId, _drawConfig, _restrictionFlags, _persistentCycleFlags, _entranceSceneId, _betterMapSelectIndex, humanName) \ + { enumValue, humanName }, +#define DEFINE_SCENE_UNSET(_enumValue) + +std::unordered_map warpPointSceneList = { +#include "tables/scene_table.h" +}; + +#undef DEFINE_SCENE +#undef DEFINE_SCENE_UNSET + +void RenderWarpPointSection() { + if (gPlayState == NULL) return; + + if (UIWidgets::Button("Set Warp Point")) { + Player* player = GET_PLAYER(gPlayState); + + CVarSetInteger(CV "Entrance", gSaveContext.save.entrance); + CVarSetInteger(CV "Room", gPlayState->roomCtx.curRoom.num); + CVarSetFloat(CV "X", player->actor.world.pos.x); + CVarSetFloat(CV "Y", player->actor.world.pos.y); + CVarSetFloat(CV "Z", player->actor.world.pos.z); + CVarSetFloat(CV "Rotation", player->actor.shape.rot.y); + CVarSetInteger(CV "Saved", 1); + } + if (CVarGetInteger(CV "Saved", 0)) { + u32 sceneId = Entrance_GetSceneIdAbsolute(CVarGetInteger(CV "Entrance", ENTRANCE(SOUTH_CLOCK_TOWN, 0))); + ImGui::AlignTextToFramePadding(); + ImGui::Text("%s Room %d", warpPointSceneList[sceneId], CVarGetInteger(CV "Room", 0)); + ImGui::SameLine(); + if (UIWidgets::Button(ICON_FA_TIMES, { .size = UIWidgets::Sizes::Inline })) { + CVarClear(CV "Entrance"); + CVarClear(CV "Room"); + CVarClear(CV "X"); + CVarClear(CV "Y"); + CVarClear(CV "Z"); + CVarClear(CV "Rotation"); + CVarClear(CV "Saved"); + } + ImGui::SameLine(); + if (UIWidgets::Button("Warp", { .size = UIWidgets::Sizes::Inline })) { + Vec3f pos = { CVarGetFloat(CV "X", 0.0f), + CVarGetFloat(CV "Y", 0.0f), + CVarGetFloat(CV "Z", 0.0f) }; + + Play_SetRespawnData(&gPlayState->state, RESPAWN_MODE_DOWN, + CVarGetInteger(CV "Entrance", ENTRANCE(SOUTH_CLOCK_TOWN, 0)), + CVarGetInteger(CV "Room", 0), PLAYER_PARAMS(0xFF, PLAYER_INITMODE_D), + &pos, CVarGetFloat(CV "Rotation", 0.0f)); + func_80169EFC(&gPlayState->state); + } + } +} diff --git a/mm/2s2h/DeveloperTools/WarpPoint.h b/mm/2s2h/DeveloperTools/WarpPoint.h new file mode 100644 index 000000000..5a6a10883 --- /dev/null +++ b/mm/2s2h/DeveloperTools/WarpPoint.h @@ -0,0 +1,6 @@ +#ifndef DEVELOPER_TOOLS_WARP_POINT_H +#define DEVELOPER_TOOLS_WARP_POINT_H + +void RenderWarpPointSection(); + +#endif // DEVELOPER_TOOLS_WARP_POINT_H