diff --git a/src/bgm/bgm.cpp b/src/bgm/bgm.cpp index 5d3c3d1..455a1b5 100644 --- a/src/bgm/bgm.cpp +++ b/src/bgm/bgm.cpp @@ -1,6 +1,8 @@ #include "bgm.h" #include "../rlImGui/utils.h" +#include + std::string BgmPlayer::rsc; pxtnService BgmPlayer::pxtn; FILE *BgmPlayer::handle = nullptr; diff --git a/src/ed/editor.cpp b/src/ed/editor.cpp index 80e5bc1..1b3fc13 100644 --- a/src/ed/editor.cpp +++ b/src/ed/editor.cpp @@ -5,6 +5,8 @@ #include "../rlImGui/utils.h" #include "imgui.h" #include "raylib.h" + +#include #include void Editor::Init() @@ -375,7 +377,6 @@ void Editor::InitSubeditors() void Editor::LoadTileset(std::string tilesetName) { - printf("%s\n", tilesetName.c_str()); Tileset t; t.Load(rsc, tilesetName); tilesets[tilesetName] = t; @@ -1065,7 +1066,7 @@ void Editor::CheckZoom() void Editor::CheckEntityDelete() { - if (entityEditor.editingEntity && IsKeyPressed(KEY_DELETE)) + if (entityEditor.editingEntity && (IsKeyPressed(KEY_DELETE) || IsKeyPressed(KEY_BACKSPACE))) { entityEditor.editingEntity->beingEdited = false; Entity* e = entityEditor.editingEntity; diff --git a/src/ed/profileEditor.cpp b/src/ed/profileEditor.cpp index db1561f..cd0ce1c 100644 --- a/src/ed/profileEditor.cpp +++ b/src/ed/profileEditor.cpp @@ -345,7 +345,7 @@ void ProfileEditor::DrawGeneralSettings(int itemWidth) profile->lastDay = time.tm_mday; } ImGuiTooltip("The date of when the user last played the game."); - + // Last time. ImGui::PushItemWidth(itemWidth); ImGui::InputScalar("Last Play Hour", ImGuiDataType_U8, &profile->lastHour); @@ -491,7 +491,35 @@ void ProfileEditor::DrawGameProfile(int itemWidth) void ProfileEditor::DrawSaveInfo(int itemWidth, int save) { - // Dummy. - ImGui::Text("Dummy"); + // Setup. + ImGui::PushItemWidth(itemWidth); + ProfileSave& p = ed->profile.saves[save]; + + // Save date. + tm time; + time.tm_year = p.year - 1900; + time.tm_mon = p.month - 1; + time.tm_mday = p.day; + time.tm_hour = 0; + time.tm_min = 0; + time.tm_sec = 0; + if (ImGui::DateChooser("Save Date##GeneralSettings", time, "%m-%d-%Y")) + { + p.year = time.tm_year + 1900; + p.month = time.tm_mon + 1; + p.day = time.tm_mday; + } + ImGuiTooltip("The date of when the save was last modified."); + + // Save time. + ImGui::InputScalar("Save Hour", ImGuiDataType_U8, &p.hour); + ImGuiTooltip("The hour when the game was saved."); + ImGui::InputScalar("Save Minute", ImGuiDataType_U8, &p.minute); + ImGuiTooltip("The minute when the game was saved."); + ImGui::InputScalar("Save Second", ImGuiDataType_U8, &p.second); + ImGuiTooltip("The second when the game was saved."); + + // Finish. + ImGui::PopItemWidth(); } \ No newline at end of file diff --git a/src/ed/toolbar.cpp b/src/ed/toolbar.cpp index b6e16f6..c74be34 100644 --- a/src/ed/toolbar.cpp +++ b/src/ed/toolbar.cpp @@ -121,7 +121,7 @@ void Toolbar::DrawUI() { ed->isPlacingEntity = !ed->isPlacingEntity; } - Tooltip("Click after hitting to place an entity or again to cancel.\nHolding shift while placing will allow you to place multiple.\nPressing the delete key will delete the selected entity."); + Tooltip("Click after hitting to place an entity or again to cancel.\nHolding shift while placing will allow you to place multiple.\nPressing the delete or backspace key will delete the selected entity."); } ImGui::End(); diff --git a/src/px/profile.cpp b/src/px/profile.cpp index 9c06570..284ef0f 100644 --- a/src/px/profile.cpp +++ b/src/px/profile.cpp @@ -142,60 +142,33 @@ void Profile::SaveLastIdx(std::string rsc_k) f.Close(); } -// TODO: GAME SAVE CODE!!! - void Profile::LoadProfileSave(std::string rsc_k, u8 num) { - /* - 00 - Header, 8 - 08 - Save year, 1 - 09 - Save month, 1 - 0A - Save day, 1 - 0B - Save hour, 1 - 0C - Save minute, 1 - 0D - Save second, 1 - 0E - Zeros, 2 - 10 - Profile icon, 4 - 14 - Total playtime in frames for menu, 4 - 18 - Display money, 4 - 1C - Display lives, 2 - 1E - Display hearts, 2 - 20 - UNKNOWN, is 2 in my Omake save but 0 for rest, 2 - 22 - Mission description, 82 - A4 - Items to display, 4[8] - C4 - Total playtime in frames, 4 - C8 - Number of flag bytes, 4 - CC - Flags, 800 - 8CC - Items in hand, 4[4] - 8DC - Currently held item, 1 - 8DD - Weapons in hand, Weapons[8] - 8FD - Number of lives, 2 - 8FF - Money, 4 - 903 - UNKNOWN (0 or 2?), 2 - 905 - UNKNOWN (D, 4, 28, etc.), 2 - 907 - Current HP, 2 - 909 - Total HP, 2 - 90B - UNKNOWN (always 1?), 1 - 90C - On gameover level, 10 - 940 - Current level, C - 94C - UNKNOWN (always 72?), 2 - UNK - 965 - X position of some kind, 4 - 969 - Y position of some kind, 4 - 96D - UNKNOWN (always 0?), 2 - 96F - Player facing right, 4 - UNK - 974 - Checkpoint stage, 10 - 984 - Shop teleporter string parameter, ? - UNK + // Setup. + if (!FileExists(rsc_k, "profile" + std::to_string(num))) return; + GFile f = GetGFile(rsc_k, "profile" + std::to_string(num)); + ProfileSave p; - struct Weapons { - 00 - Item ID, 1 - 01 - Item level, 1 - 02 - Zeroes, 2 (Last byte may be set sometimes, but idk what to?) - } - */ + // Read data. + f.ReadU64(); + p.year = f.ReadU8(); + p.month = f.ReadU8(); + p.day = f.ReadU8(); + p.hour = f.ReadU8(); + p.minute = f.ReadU8(); + p.second = f.ReadU8(); + f.ReadU16(); + p.profileIcon = f.ReadU32(); + p.displayPlaytime = f.ReadU32(); + p.displayMoney = f.ReadU32(); + p.displayLives = f.ReadU16(); + p.displayHearts = f.ReadU16(); + p.unk1 = f.ReadU16(); + + // Set data. + saves[num] = p; + f.Close(); } diff --git a/src/px/profile.h b/src/px/profile.h index 9bbee00..fb782e6 100644 --- a/src/px/profile.h +++ b/src/px/profile.h @@ -7,10 +7,106 @@ #include "../gbin/gfile.h" #include "raylib.h" +/* + 00 - Header, 8 + 08 - Save year, 1 + 09 - Save month, 1 + 0A - Save day, 1 + 0B - Save hour, 1 + 0C - Save minute, 1 + 0D - Save second, 1 + 0E - Zeros, 2 + 10 - Profile icon, 4 + 14 - Total playtime in frames for menu, 4 + 18 - Display money, 4 + 1C - Display lives, 2 + 1E - Display hearts, 2 + 20 - UNKNOWN, is 2 in my Omake save but 0 for rest, 2 + 22 - Mission description, 82 + A4 - Items to display, 4[8] + C4 - Total playtime in frames, 4 + C8 - Number of flag bytes, 4 + CC - Flags, 800 + 8CC - Items in hand, 4[4] + 8DC - Currently held item, 1 + 8DD - Weapons in hand, Weapons[8] + 8FD - Number of lives, 2 + 8FF - Money, 4 + 903 - UNKNOWN (0 or 2?), 2 + 905 - UNKNOWN (D, 4, 28, etc.), 2 + 907 - Current HP, 2 + 909 - Total HP, 2 + 90B - UNKNOWN (always 1?), 1 + 90C - On gameover level, 10 + 940 - Current level, C + 94C - UNKNOWN (always 72?), 2 + UNK + 965 - X position of some kind, 4 + 969 - Y position of some kind, 4 + 96D - UNKNOWN (always 0?), 2 + 96F - Player facing right, 4 + UNK + 974 - Checkpoint stage, 10 + 984 - Shop teleporter string parameter, ? + UNK + + struct Weapons { + 00 - Item ID, 1 + 01 - Item level, 1 + 02 - Zeroes, 2 (Last byte may be set sometimes, but idk what to?) + } +*/ + +// A weapon. +struct Weapon +{ + u8 itemId = 0; + u8 itemLevel = 0; + u8 unk1 = 0; + u8 unk2 = 0; +}; + // Kero blaster save. struct ProfileSave { - + u8 year; + u8 month; + u8 day; + u8 hour; + u8 minute; + u8 second; + u32 profileIcon; + u32 displayPlaytime; + u32 displayMoney; + u16 displayLives; + u16 displayHearts; + u16 unk1; + std::string missionDescription; + u32 displayItems[8]; + u32 playtime; + u8 flags[0x800]; + u32 itemsInHand[4]; + u8 currWeapon; + Weapon weapons[8]; + u16 lives; + u32 money; + u16 unk2; + u16 unk3; + u16 currentHp; + u16 totalHp; + u8 unk4; + std::string onGameoverLevel; + std::string currentLevel; + u16 unk5; + u8 unk6[0x19]; + u32 xPos; + u32 yPos; + u16 unk7; + u32 facingDirection; + u8 unk8[5]; + std::string checkpointStage; + std::string checkpointTeleporterParameter; + // TODO!!! }; // Kero blaster profile. @@ -50,7 +146,7 @@ struct Profile u8 joystickWeaponSwitchRight = 4; u8 joystickMenu = 2; u8 gameProfile[NUM_GAME_FLAGS]; - std::vector saves = std::vector(); + ProfileSave saves[NUM_SAVES]; // If a file exists in the profile folder. bool FileExists(std::string rsc_k, std::string name); @@ -114,7 +210,7 @@ struct Profile // Save the last time used. void SaveLastTime(std::string rsc_k); - + // Load the last key config used. void LoadKeyConfig(std::string rsc_k);