From b3b5ba603ac1deb35910d4c2bb8f62c8c740ab81 Mon Sep 17 00:00:00 2001 From: Dominicentek Date: Fri, 25 Aug 2023 16:55:40 +0200 Subject: [PATCH] add locations --- data/dynos_warps.cpp | 16 +- dynos/locations.bin | Bin 0 -> 5472 bytes src/game/level_update.c | 24 ++- src/game/level_update.h | 6 +- src/saturn/filesystem/saturn_locationfile.cpp | 79 ++++++++++ src/saturn/filesystem/saturn_locationfile.h | 16 ++ src/saturn/filesystem/saturn_projectfile.cpp | 148 ++++++++++++++++-- src/saturn/imgui/saturn_imgui_machinima.cpp | 37 +++++ src/saturn/saturn.cpp | 2 + 9 files changed, 282 insertions(+), 46 deletions(-) create mode 100644 dynos/locations.bin create mode 100644 src/saturn/filesystem/saturn_locationfile.cpp create mode 100644 src/saturn/filesystem/saturn_locationfile.h diff --git a/data/dynos_warps.cpp b/data/dynos_warps.cpp index 06b0242d..e172766b 100644 --- a/data/dynos_warps.cpp +++ b/data/dynos_warps.cpp @@ -287,13 +287,13 @@ static void *DynOS_Warp_UpdateWarp(void *aCmd, bool aIsLevelInitDone) { gMarioSpawnInfo->startAngle[1] = _LevelEntryWarp[6]; gMarioSpawnInfo->startAngle[2] = 0; gMarioSpawnInfo->areaIndex = gCurrAreaIndex; - if (!dynos_override_mario_and_camera) init_mario(); + if (!dynos_override_mario) init_mario(); set_mario_initial_action(gMarioState, sDynosWarpSpawnType, 0); DynOS_Warp_SetParam(gCurrLevelNum, DynOS_Opt_GetValue("dynos_warp_param")); // Init transition - if (!override_mario_and_camera) reset_camera(gCurrentArea->camera); - if (!override_mario_and_camera) init_camera(gCurrentArea->camera); + if (!override_mario) reset_camera(gCurrentArea->camera); + if (!override_mario) init_camera(gCurrentArea->camera); sDelayedWarpOp = WARP_OP_NONE; switch (sDynosWarpSpawnType) { case MARIO_SPAWN_UNKNOWN_03: play_transition(WARP_TRANSITION_FADE_FROM_STAR, 0x10, 0x00, 0x00, 0x00); break; @@ -325,15 +325,11 @@ static void *DynOS_Warp_UpdateWarp(void *aCmd, bool aIsLevelInitDone) { sDynosWarpAreaNum = -1; sDynosWarpActNum = -1; sDynosWarpNodeNum = -1; - if (dynos_override_mario_and_camera) { - dynos_override_mario_and_camera = 0; + if (dynos_override_mario) { + dynos_override_mario = 0; vec3f_copy(gMarioState->pos, overriden_mario_pos); gMarioState->faceAngle[1] = overriden_mario_angle; - if (override_mario_and_camera) { - *gCamera = overriden_camera_struct; - gLakituState = overriden_lakitu_struct; - } - override_mario_and_camera--; + override_mario--; } } diff --git a/dynos/locations.bin b/dynos/locations.bin new file mode 100644 index 0000000000000000000000000000000000000000..149af778a5913a17a59a17cc6d05bebff50fadd9 GIT binary patch literal 5472 zcmZuVdq7lG`sa)ailP{XsFgPtEz1WAZCO5sx#u7h2r^^j8pvh1FtZMGaUKE&HYq}8 zD82|WbF$QYrsa#x5}9*SG}E#)(-hY=(`r+>b%g-0k>e;-<{^`6=9g@G-MW?F{NBPhq4P?3P1%N(1o6S4+ zgrDii2ft=o6}!Os_1rL$;cwV!LOdeppF0J>LZJ5`GRT8`X$a9Zdyuh2DYXOi>Jh^$ zm*Rv;WIDb$sl@40tPUsYgugUV^MM~n^z=PO)%NaiP z3Zi>HY&B^4LoxeqK%*#~mMQ-5ER2-_^1?Yipw&TQU z-z^WKcoq33#>bc#Zxm*ya zPC7jjAbJ$!?7be0Nf>6BFR0ohF9#2!iheX?7y@w(!#7W|=XT1%Xy2t*el{phwHUmS zjDeVi;n$=1q8(n60AkH29yVyDPSp|Oec^Q;{baldKOcN;q%5b05OWn)lh)XB5D+=D z>txOCaFr{L0x1RTFICD>7#??yrj}O;Q%FsRL^H_^%V*VkL~hLLNeHpIHA%LNR4adVr z(lIB8i+(~IkL+%*NPkNS$NFkABiTp=cGWfSAFz^1D*@Sgh@ZL9i-t!bdiH#;Kuv~Y zcLrTM*2~5}M&L@$x2l*mSd+iEKS4@Bq+0lUARFWWx> z^dZjQ{VhXrTActbdxZT~u|@Vk!evGc&MbE*#nu9V&-sl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ho78+Y`3CrEfc zhf8r!Pzj-yx7V?}lj zv>@374tYaQ1_Bn62fM@ysWd7h=1*x2d}oZ*TJ=1s&O_XC!W8^)5sQ1&`V#&%P}s|! z%NS|WN@2l?#p9;)dsmJlZ3yiG1`q*+0c*18NKuKPR#ORPG_u$1J z8%{luA@9u2;7!M?g01sjAoi`QsuTO4_zBqAACK+EtK2gQ9E)<}hz=>%A`6_%!9BD; zt~BtZce80NG_My1Nq(%;1qX-bEOygN^B@{upfI4O^ODwx`i#T1$7tJ-be`#fk9+@Q zX_{S?(%nvrLwu@>!}d$$P|bUUZCXUb>+Va}?9)`Sslx#SxLC4uSPqTKSLK~!hyCI7 zi^Cu6V$HRQOmvyyM=!Q#Zs3rL!~Z%*lN*-vggV44yZ_jZ4rz9R_OD#lEcnTinteractObj = spawnNode->object; gMarioState->usedObj = spawnNode->object; } if (gCurrentArea) { - if (!override_mario_and_camera) reset_camera(gCurrentArea->camera); + if (!override_mario) reset_camera(gCurrentArea->camera); } sWarpDest.type = WARP_TYPE_NOT_WARPING; sDelayedWarpOp = WARP_OP_NONE; @@ -548,8 +546,8 @@ void check_instant_warp(void) { s16 cameraAngle; struct Surface *floor; - if ((gCurrLevelNum == LEVEL_CASTLE - && save_file_get_total_star_count(gCurrSaveFileNum - 1, COURSE_MIN - 1, COURSE_MAX - 1) >= 70) || configUnlockDoors) { + if (gCurrLevelNum == LEVEL_CASTLE + && (save_file_get_total_star_count(gCurrSaveFileNum - 1, COURSE_MIN - 1, COURSE_MAX - 1) >= 70 || configUnlockDoors)) { return; } @@ -1022,14 +1020,10 @@ s32 play_mode_normal(void) { } // Override Mario if loaded from project file - if (override_mario_and_camera) { - override_mario_and_camera--; + if (override_mario) { + override_mario--; vec3f_copy(gMarioState->pos, overriden_mario_pos); gMarioState->faceAngle[1] = overriden_mario_angle; - if (override_mario_and_camera) { - *gCamera = overriden_camera_struct; - gLakituState = overriden_lakitu_struct; - } } return 0; @@ -1219,7 +1213,7 @@ s32 init_level(void) { } if (gCurrentArea != NULL) { - if (!override_mario_and_camera) reset_camera(gCurrentArea->camera); + if (!override_mario) reset_camera(gCurrentArea->camera); if (gCurrDemoInput != NULL) { set_mario_action(gMarioState, ACT_IDLE, 0); diff --git a/src/game/level_update.h b/src/game/level_update.h index b8f1281f..6172a5c6 100644 --- a/src/game/level_update.h +++ b/src/game/level_update.h @@ -102,12 +102,10 @@ struct HudDisplay { extern struct HudDisplay gHudDisplay; extern s8 gShouldNotPlayCastleMusic; -extern u8 override_mario_and_camera; -extern u8 dynos_override_mario_and_camera; +extern u8 override_mario; +extern u8 dynos_override_mario; extern s16 overriden_mario_angle; extern Vec3f overriden_mario_pos; -extern struct Camera overriden_camera_struct; -extern struct LakituState overriden_lakitu_struct; enum HUDDisplayFlag { HUD_DISPLAY_FLAG_LIVES = 0x0001, diff --git a/src/saturn/filesystem/saturn_locationfile.cpp b/src/saturn/filesystem/saturn_locationfile.cpp new file mode 100644 index 00000000..9f4fb4e6 --- /dev/null +++ b/src/saturn/filesystem/saturn_locationfile.cpp @@ -0,0 +1,79 @@ +#include "saturn_format.h" + +#include +#include +#include +extern "C" { +#include "include/types.h" +#include "game/area.h" +#include "game/level_update.h" +} + +std::map>>> locations = {}; + +void saturn_add_location_internal(int level, float x, float y, float z, s16 angle, char* name) { + if (locations.find(level) == locations.end()) { + std::map>> levelLocations; + levelLocations.insert({ std::string(name), { angle, { x, y, z } } }); + locations.insert({ level, levelLocations }); + } + else { + std::string locationName = std::string(name); + if (locations[level].find(name) == locations[level].end()) locations[level].insert({ locationName, { angle, { x, y, z } } }); + else { + locations[level][locationName].first = angle; + locations[level][locationName].second[0] = x; + locations[level][locationName].second[1] = y; + locations[level][locationName].second[2] = z; + } + } +} +void saturn_location_data_handler(SaturnFormatStream* stream, int version) { + int count = saturn_format_read_int32(stream); + for (int i = 0; i < count; i++) { + int level = saturn_format_read_int16(stream); + s16 angle = saturn_format_read_int16(stream); + float x = saturn_format_read_float(stream); + float y = saturn_format_read_float(stream); + float z = saturn_format_read_float(stream); + char name[257]; + saturn_format_read_string(stream, name); + name[256] = 0; + saturn_add_location_internal(level, x, y, z, angle, name); + } +} +void saturn_load_locations() { + saturn_format_input("dynos/locations.bin", "STLC", { + { "DATA", saturn_location_data_handler } + }); +} +void saturn_save_locations() { + SaturnFormatStream stream = saturn_format_output("STLC", 1); + saturn_format_new_section(&stream, "DATA"); + int count = 0; + for (auto& levelEntry : locations) { + for (auto& locationEntry : levelEntry.second) { + count++; + } + } + saturn_format_write_int32(&stream, count); + for (auto& levelEntry : locations) { + for (auto& locationEntry : levelEntry.second) { + saturn_format_write_int16(&stream, levelEntry.first); + saturn_format_write_int16(&stream, locationEntry.second.first); + saturn_format_write_float(&stream, locationEntry.second.second[0]); + saturn_format_write_float(&stream, locationEntry.second.second[1]); + saturn_format_write_float(&stream, locationEntry.second.second[2]); + saturn_format_write_string(&stream, (char*)locationEntry.first.c_str()); + } + } + saturn_format_close_section(&stream); + saturn_format_write("dynos/locations.bin", &stream); +} +std::map>>* saturn_get_locations() { + int level = (gCurrLevelNum << 8) | gCurrAreaIndex; + return &locations[level]; +} +void saturn_add_location(char* name) { + saturn_add_location_internal((gCurrLevelNum << 8) | gCurrAreaIndex, gMarioState->pos[0], gMarioState->pos[1], gMarioState->pos[2], gMarioState->faceAngle[1], name); +} \ No newline at end of file diff --git a/src/saturn/filesystem/saturn_locationfile.h b/src/saturn/filesystem/saturn_locationfile.h new file mode 100644 index 00000000..473879d1 --- /dev/null +++ b/src/saturn/filesystem/saturn_locationfile.h @@ -0,0 +1,16 @@ +#ifndef SaturnLocationFile +#define SaturnLocationFile + +#include +#include +#include +extern "C" { +#include "include/types.h" +} + +void saturn_load_locations(); +void saturn_save_locations(); +std::map>>* saturn_get_locations(); +void saturn_add_location(char* name); + +#endif \ No newline at end of file diff --git a/src/saturn/filesystem/saturn_projectfile.cpp b/src/saturn/filesystem/saturn_projectfile.cpp index 2bd64f5d..9bb935df 100644 --- a/src/saturn/filesystem/saturn_projectfile.cpp +++ b/src/saturn/filesystem/saturn_projectfile.cpp @@ -111,20 +111,16 @@ void saturn_project_game_handler(SaturnFormatStream* stream, int version) { u8 level = saturn_format_read_int8(stream); spin_mult = saturn_format_read_float(stream); if (version == 1) { - overriden_camera_struct = *gCamera; - overriden_lakitu_struct = gLakituState; gCamera->pos[0] = saturn_format_read_float(stream); gCamera->pos[1] = saturn_format_read_float(stream); gCamera->pos[2] = saturn_format_read_float(stream); float yaw = saturn_format_read_float(stream); float pitch = saturn_format_read_float(stream); vec3f_set_dist_and_angle(gCamera->pos, gCamera->focus, 100, (s16)pitch, (s16)yaw); - vec3f_copy(overriden_camera_struct.pos, gCamera->pos); - vec3f_copy(overriden_camera_struct.focus, gCamera->focus); - vec3f_copy(overriden_lakitu_struct.goalPos, gCamera->pos); - vec3f_copy(overriden_lakitu_struct.goalFocus, gCamera->focus); - vec3f_copy(overriden_lakitu_struct.pos, gCamera->pos); - vec3f_copy(overriden_lakitu_struct.focus, gCamera->focus); + vec3f_copy(gLakituState.goalPos, gCamera->pos); + vec3f_copy(gLakituState.goalFocus, gCamera->focus); + vec3f_copy(gLakituState.pos, gCamera->pos); + vec3f_copy(gLakituState.focus, gCamera->focus); } camVelSpeed = saturn_format_read_float(stream); camVelRSpeed = saturn_format_read_float(stream); @@ -160,10 +156,10 @@ void saturn_project_game_handler(SaturnFormatStream* stream, int version) { } k_previous_frame = -1; u8 lvlID = (level >> 2) & 63; - if (lvlID != get_saturn_level_id(gCurrLevelNum) || (level & 3) != gCurrAreaIndex) { - warp_to_level(lvlID, level & 3, act); - if (lvlID == 0) dynos_override_mario_and_camera = 1; - override_mario_and_camera = 3; // We override for 3 frames otherwise it breaks :/ + if (lvlID != get_saturn_level_id(gCurrLevelNum) || (level & 3) != gCurrAreaIndex - 1) { + warp_to_level(lvlID, (level & 3) + 1, act); + if (lvlID == 0) dynos_override_mario = 1; + override_mario = 3; // We override for 3 frames otherwise it breaks :/ } } @@ -212,8 +208,67 @@ void saturn_project_keyframe_handler(SaturnFormatStream* stream, int version) { } void saturn_project_camera_handler(SaturnFormatStream* stream, int version) { - saturn_format_read_any(stream, &overriden_camera_struct, sizeof(struct Camera)); - saturn_format_read_any(stream, &overriden_lakitu_struct, sizeof(struct LakituState)); + gCamera->areaCenX = saturn_format_read_int32(stream); + gCamera->areaCenY = saturn_format_read_int32(stream); + gCamera->areaCenZ = saturn_format_read_int32(stream); + gCamera->cutscene = saturn_format_read_int8(stream); + gCamera->defMode = saturn_format_read_int8(stream); + gCamera->doorStatus = saturn_format_read_int8(stream); + gCamera->focus[0] = saturn_format_read_float(stream); + gCamera->focus[1] = saturn_format_read_float(stream); + gCamera->focus[2] = saturn_format_read_float(stream); + gCamera->mode = saturn_format_read_int8(stream); + gCamera->nextYaw = saturn_format_read_int16(stream); + gCamera->pos[0] = saturn_format_read_float(stream); + gCamera->pos[1] = saturn_format_read_float(stream); + gCamera->pos[2] = saturn_format_read_float(stream); + gCamera->yaw = saturn_format_read_int16(stream); + gLakituState.curFocus[0] = saturn_format_read_float(stream); + gLakituState.curFocus[1] = saturn_format_read_float(stream); + gLakituState.curFocus[2] = saturn_format_read_float(stream); + gLakituState.curPos[0] = saturn_format_read_float(stream); + gLakituState.curPos[1] = saturn_format_read_float(stream); + gLakituState.curPos[2] = saturn_format_read_float(stream); + gLakituState.defMode = saturn_format_read_int8(stream); + gLakituState.focHSpeed = saturn_format_read_float(stream); + gLakituState.focus[0] = saturn_format_read_float(stream); + gLakituState.focus[1] = saturn_format_read_float(stream); + gLakituState.focus[2] = saturn_format_read_float(stream); + gLakituState.focusDistance = saturn_format_read_float(stream); + gLakituState.focVSpeed = saturn_format_read_float(stream); + gLakituState.goalFocus[0] = saturn_format_read_float(stream); + gLakituState.goalFocus[1] = saturn_format_read_float(stream); + gLakituState.goalFocus[2] = saturn_format_read_float(stream); + gLakituState.goalPos[0] = saturn_format_read_float(stream); + gLakituState.goalPos[1] = saturn_format_read_float(stream); + gLakituState.goalPos[2] = saturn_format_read_float(stream); + gLakituState.keyDanceRoll = saturn_format_read_int16(stream); + gLakituState.lastFrameAction = saturn_format_read_int32(stream); + gLakituState.mode = saturn_format_read_int8(stream); + gLakituState.nextYaw = saturn_format_read_int16(stream); + gLakituState.oldPitch = saturn_format_read_int16(stream); + gLakituState.oldRoll = saturn_format_read_int16(stream); + gLakituState.oldYaw = saturn_format_read_int16(stream); + gLakituState.pos[0] = saturn_format_read_float(stream); + gLakituState.pos[1] = saturn_format_read_float(stream); + gLakituState.pos[2] = saturn_format_read_float(stream); + gLakituState.posHSpeed = saturn_format_read_float(stream); + gLakituState.posVSpeed = saturn_format_read_float(stream); + gLakituState.roll = saturn_format_read_int16(stream); + gLakituState.shakeMagnitude[0] = saturn_format_read_int16(stream); + gLakituState.shakeMagnitude[1] = saturn_format_read_int16(stream); + gLakituState.shakeMagnitude[2] = saturn_format_read_int16(stream); + gLakituState.shakePitchDecay = saturn_format_read_int16(stream); + gLakituState.shakePitchPhase = saturn_format_read_int16(stream); + gLakituState.shakePitchVel = saturn_format_read_int16(stream); + gLakituState.shakeRollDecay = saturn_format_read_int16(stream); + gLakituState.shakeRollPhase = saturn_format_read_int16(stream); + gLakituState.shakeRollVel = saturn_format_read_int16(stream); + gLakituState.shakeYawDecay = saturn_format_read_int16(stream); + gLakituState.shakeYawPhase = saturn_format_read_int16(stream); + gLakituState.shakeYawVel = saturn_format_read_int16(stream); + gLakituState.skipCameraInterpolationTimestamp = saturn_format_read_int32(stream); + gLakituState.yaw = saturn_format_read_int16(stream); } void saturn_load_project(char* filename) { @@ -266,7 +321,7 @@ void saturn_save_project(char* filename) { walkpoint |= (gLevelEnv & 1) << 7; saturn_format_write_int16(&stream, flags); saturn_format_write_int8(&stream, walkpoint); - saturn_format_write_int8(&stream, (get_saturn_level_id(gCurrLevelNum) << 2) | gCurrAreaIndex); + saturn_format_write_int8(&stream, (get_saturn_level_id(gCurrLevelNum) << 2) | (gCurrAreaIndex - 1)); saturn_format_write_float(&stream, spin_mult); /* Version 1 saturn_format_write_float(&stream, gLakituState.pos[0]); @@ -307,8 +362,67 @@ void saturn_save_project(char* filename) { saturn_format_write_int8(&stream, gCurrActNum); saturn_format_close_section(&stream); saturn_format_new_section(&stream, SATURN_PROJECT_CAMERA_IDENTIFIER); - saturn_format_write_any(&stream, gCamera, sizeof(*gCamera)); - saturn_format_write_any(&stream, &gLakituState, sizeof(gLakituState)); + saturn_format_write_float(&stream, gCamera->areaCenX); + saturn_format_write_float(&stream, gCamera->areaCenY); + saturn_format_write_float(&stream, gCamera->areaCenZ); + saturn_format_write_int8(&stream, gCamera->cutscene); + saturn_format_write_int8(&stream, gCamera->defMode); + saturn_format_write_int8(&stream, gCamera->doorStatus); + saturn_format_write_float(&stream, gCamera->focus[0]); + saturn_format_write_float(&stream, gCamera->focus[1]); + saturn_format_write_float(&stream, gCamera->focus[2]); + saturn_format_write_int8(&stream, gCamera->mode); + saturn_format_write_int16(&stream, gCamera->nextYaw); + saturn_format_write_float(&stream, gCamera->pos[0]); + saturn_format_write_float(&stream, gCamera->pos[1]); + saturn_format_write_float(&stream, gCamera->pos[2]); + saturn_format_write_int16(&stream, gCamera->yaw); + saturn_format_write_float(&stream, gLakituState.curFocus[0]); + saturn_format_write_float(&stream, gLakituState.curFocus[1]); + saturn_format_write_float(&stream, gLakituState.curFocus[2]); + saturn_format_write_float(&stream, gLakituState.curPos[0]); + saturn_format_write_float(&stream, gLakituState.curPos[1]); + saturn_format_write_float(&stream, gLakituState.curPos[2]); + saturn_format_write_int8(&stream, gLakituState.defMode); + saturn_format_write_float(&stream, gLakituState.focHSpeed); + saturn_format_write_float(&stream, gLakituState.focus[0]); + saturn_format_write_float(&stream, gLakituState.focus[1]); + saturn_format_write_float(&stream, gLakituState.focus[2]); + saturn_format_write_float(&stream, gLakituState.focusDistance); + saturn_format_write_float(&stream, gLakituState.focVSpeed); + saturn_format_write_float(&stream, gLakituState.goalFocus[0]); + saturn_format_write_float(&stream, gLakituState.goalFocus[1]); + saturn_format_write_float(&stream, gLakituState.goalFocus[2]); + saturn_format_write_float(&stream, gLakituState.goalPos[0]); + saturn_format_write_float(&stream, gLakituState.goalPos[1]); + saturn_format_write_float(&stream, gLakituState.goalPos[2]); + saturn_format_write_int16(&stream, gLakituState.keyDanceRoll); + saturn_format_write_int32(&stream, gLakituState.lastFrameAction); + saturn_format_write_int8(&stream, gLakituState.mode); + saturn_format_write_int16(&stream, gLakituState.nextYaw); + saturn_format_write_int16(&stream, gLakituState.oldPitch); + saturn_format_write_int16(&stream, gLakituState.oldRoll); + saturn_format_write_int16(&stream, gLakituState.oldYaw); + saturn_format_write_float(&stream, gLakituState.pos[0]); + saturn_format_write_float(&stream, gLakituState.pos[1]); + saturn_format_write_float(&stream, gLakituState.pos[2]); + saturn_format_write_float(&stream, gLakituState.posHSpeed); + saturn_format_write_float(&stream, gLakituState.posVSpeed); + saturn_format_write_int16(&stream, gLakituState.roll); + saturn_format_write_int16(&stream, gLakituState.shakeMagnitude[0]); + saturn_format_write_int16(&stream, gLakituState.shakeMagnitude[1]); + saturn_format_write_int16(&stream, gLakituState.shakeMagnitude[2]); + saturn_format_write_int16(&stream, gLakituState.shakePitchDecay); + saturn_format_write_int16(&stream, gLakituState.shakePitchPhase); + saturn_format_write_int16(&stream, gLakituState.shakePitchVel); + saturn_format_write_int16(&stream, gLakituState.shakeRollDecay); + saturn_format_write_int16(&stream, gLakituState.shakeRollPhase); + saturn_format_write_int16(&stream, gLakituState.shakeRollVel); + saturn_format_write_int16(&stream, gLakituState.shakeYawDecay); + saturn_format_write_int16(&stream, gLakituState.shakeYawPhase); + saturn_format_write_int16(&stream, gLakituState.shakeYawVel); + saturn_format_write_int32(&stream, gLakituState.skipCameraInterpolationTimestamp); + saturn_format_write_int16(&stream, gLakituState.yaw); saturn_format_close_section(&stream); for (auto& entry : k_frame_keys) { saturn_format_new_section(&stream, SATURN_PROJECT_TIMELINE_IDENTIFIER); diff --git a/src/saturn/imgui/saturn_imgui_machinima.cpp b/src/saturn/imgui/saturn_imgui_machinima.cpp index 8c25eff5..e463d118 100644 --- a/src/saturn/imgui/saturn_imgui_machinima.cpp +++ b/src/saturn/imgui/saturn_imgui_machinima.cpp @@ -16,6 +16,7 @@ #include "saturn/saturn_obj_def.h" #include "saturn_imgui.h" #include "saturn/imgui/saturn_imgui_chroma.h" +#include "saturn/filesystem/saturn_locationfile.h" #include "pc/controller/controller_keyboard.h" #include @@ -55,6 +56,9 @@ int obj_beh_params[4]; int obj_model; int obj_beh; +int current_location_index = 0; +char location_name[256]; + s16 levelList[] = { LEVEL_SA, LEVEL_CASTLE_GROUNDS, LEVEL_CASTLE, LEVEL_CASTLE_COURTYARD, LEVEL_BOB, LEVEL_WF, LEVEL_PSS, LEVEL_TOTWC, LEVEL_JRB, LEVEL_CCM, @@ -254,6 +258,39 @@ void imgui_machinima_quick_options() { // Erase existing timelines k_frame_keys.clear(); } + + auto locations = saturn_get_locations(); + bool do_save = false; + std::vector forRemoval = {}; + if (ImGui::BeginMenu("Locations")) { + for (auto& entry : *locations) { + if (ImGui::Button((std::string(ICON_FK_PLAY "###warp_to_location_") + entry.first).c_str())) { + gMarioState->pos[0] = entry.second.second[0]; + gMarioState->pos[1] = entry.second.second[1]; + gMarioState->pos[2] = entry.second.second[2]; + gMarioState->faceAngle[1] = entry.second.first; + do_save = true; + } + ImGui::SameLine(); + if (ImGui::Button((std::string(ICON_FK_TRASH "###delete_location_") + entry.first).c_str())) { + forRemoval.push_back(entry.first); + do_save = true; + } + ImGui::SameLine(); + ImGui::Text(entry.first.c_str()); + } + if (ImGui::Button(ICON_FK_PLUS "###add_location")) { + saturn_add_location(location_name); + do_save = true; + } + ImGui::SameLine(); + ImGui::InputText("###location_input", location_name, 256); + ImGui::EndMenu(); + } + for (std::string key : forRemoval) { + locations->erase(key); + } + if (do_save) saturn_save_locations(); } if (mario_exists) { ImGui::Separator(); diff --git a/src/saturn/saturn.cpp b/src/saturn/saturn.cpp index 1eb0cacf..e1d99d09 100644 --- a/src/saturn/saturn.cpp +++ b/src/saturn/saturn.cpp @@ -13,6 +13,7 @@ #include "pc/configfile.h" #include "saturn/filesystem/saturn_projectfile.h" #include "saturn/imgui/saturn_imgui_dynos.h" +#include "saturn/filesystem/saturn_locationfile.h" bool mario_exists; @@ -571,6 +572,7 @@ const char* saturn_get_stage_name(int courseNum) { void saturn_do_load() { saturn_imgui_init(); + saturn_load_locations(); } void saturn_on_splash_finish() { splash_finished = true;