Add flag, equipment, and quest status editors (#164)

This commit is contained in:
Rozelette 2022-04-17 10:24:43 -05:00 committed by GitHub
parent 1dcd24e7e2
commit a11038f515
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 1281 additions and 309 deletions

View File

@ -179,21 +179,46 @@ namespace SohImGui {
stbi_image_free(img_data);
}
void LoadResource(const std::string& name, const std::string& path) {
void LoadResource(const std::string& name, const std::string& path, const ImVec4& tint) {
GfxRenderingAPI* api = gfx_get_current_rendering_api();
const auto res = static_cast<Ship::Texture*>(GlobalCtx2::GetInstance()->GetResourceManager()->LoadResource(normalize(path)).get());
if (res->texType != Ship::TextureType::RGBA32bpp) {
std::vector<uint8_t> texBuffer;
texBuffer.reserve(res->width * res->height * 4);
switch (res->texType) {
case Ship::TextureType::RGBA32bpp:
texBuffer.assign(res->imageData, res->imageData + (res->width * res->height * 4));
break;
case Ship::TextureType::GrayscaleAlpha8bpp:
for (int32_t i = 0; i < res->width * res->height; i++) {
uint8_t ia = res->imageData[i];
uint8_t color = ((ia >> 4) & 0xF) * 255 / 15;
uint8_t alpha = (ia & 0xF) * 255 / 15;
texBuffer.push_back(color);
texBuffer.push_back(color);
texBuffer.push_back(color);
texBuffer.push_back(alpha);
}
break;
default:
// TODO convert other image types
SPDLOG_WARN("SohImGui::LoadResource: Attempting to load unsupporting image type %s", path.c_str());
return;
}
for (size_t pixel = 0; pixel < texBuffer.size() / 4; pixel++) {
texBuffer[pixel * 4 + 0] *= tint.x;
texBuffer[pixel * 4 + 1] *= tint.y;
texBuffer[pixel * 4 + 2] *= tint.z;
texBuffer[pixel * 4 + 3] *= tint.w;
}
const auto asset = new GameAsset{ api->new_texture() };
api->select_texture(0, asset->textureId);
api->set_sampler_parameters(0, false, 0, 0);
api->upload_texture(res->imageData, res->width, res->height);
api->upload_texture(texBuffer.data(), res->width, res->height);
DefaultAssets[name] = asset;
}

View File

@ -1,5 +1,6 @@
#pragma once
#include "Lib/ImGui/imgui.h"
#include "SohConsole.h"
struct GameAsset {
@ -63,7 +64,7 @@ namespace SohImGui {
void ShowCursor(bool hide, Dialogues w);
void BindCmd(const std::string& cmd, CommandEntry entry);
void AddWindow(const std::string& category, const std::string& name, WindowDrawFunc drawFunc);
void LoadResource(const std::string& name, const std::string& path);
void LoadResource(const std::string& name, const std::string& path, const ImVec4& tint = ImVec4(1, 1, 1, 1));
ImTextureID GetTextureByID(int id);
ImTextureID GetTextureByName(const std::string& name);
}

View File

@ -185,6 +185,7 @@
<ClCompile Include="soh\gu_pc.c" />
<ClCompile Include="soh\OTRGlobals.cpp" />
<ClCompile Include="soh\stubs.c" />
<ClCompile Include="soh\util.cpp" />
<ClCompile Include="soh\z_message_OTR.cpp" />
<ClCompile Include="soh\z_play_otr.cpp" />
<ClCompile Include="soh\z_scene_otr.cpp" />
@ -928,6 +929,7 @@
<ClInclude Include="soh\Enhancements\debugger\debugSaveEditor.h" />
<ClInclude Include="soh\gameconsole.h" />
<ClInclude Include="soh\OTRGlobals.h" />
<ClInclude Include="soh\util.h" />
<ClInclude Include="src\overlays\actors\ovl_Arms_Hook\z_arms_hook.h" />
<ClInclude Include="src\overlays\actors\ovl_Arrow_Fire\z_arrow_fire.h" />
<ClInclude Include="src\overlays\actors\ovl_Arrow_Ice\z_arrow_ice.h" />

View File

@ -2181,6 +2181,9 @@
<ClCompile Include="soh\Enhancements\debugger\debugSaveEditor.cpp">
<Filter>Source Files\soh\Enhancements\debugger</Filter>
</ClCompile>
<ClCompile Include="soh\util.cpp">
<Filter>Source Files\soh</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\overlays\actors\ovl_kaleido_scope\z_kaleido_scope.h">
@ -3728,6 +3731,9 @@
<ClInclude Include="soh\Enhancements\debugger\debugSaveEditor.h">
<Filter>Header Files\soh\Enhancements\debugger</Filter>
</ClInclude>
<ClInclude Include="soh\util.h">
<Filter>Header Files\soh</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="include\macro.inc">

File diff suppressed because it is too large Load Diff

314
soh/soh/util.cpp Normal file
View File

@ -0,0 +1,314 @@
#include "util.h"
#include <vector>
std::vector<std::string> sceneNames = {
"Inside the Deku Tree",
"Dodongo's Cavern",
"Inside Jabu-Jabu's Belly",
"Forest Temple",
"Fire Temple",
"Water Temple",
"Spirit Temple",
"Shadow Temple",
"Bottom of the Well",
"Ice Cavern",
"Ganon's Tower",
"Gerudo Training Ground",
"Thieves' Hideout",
"Inside Ganon's Castle",
"Ganon's Tower (Collapsing)",
"Inside Ganon's Castle (Collapsing)",
"Treasure Box Shop",
"Gohma's Lair",
"King Dodongo's Lair",
"Barinade's Lair",
"Phantom Ganon's Lair",
"Volvagia's Lair",
"Morpha's Lair",
"Twinrova's Lair & Nabooru's Mini-Boss Room",
"Bongo Bongo's Lair",
"Ganondorf's Lair",
"Tower Collapse Exterior",
"Market Entrance (Child - Day)",
"Market Entrance (Child - Night)",
"Market Entrance (Ruins)",
"Back Alley (Child - Day)",
"Back Alley (Child - Night)",
"Market (Child - Day)",
"Market (Child - Night)",
"Market (Ruins)",
"Temple of Time Exterior (Child - Day)",
"Temple of Time Exterior (Child - Night)",
"Temple of Time Exterior (Ruins)",
"Know-It-All Brothers' House",
"House of Twins",
"Mido's House",
"Saria's House",
"Carpenter Boss's House",
"Back Alley House (Man in Green)",
"Bazaar",
"Kokiri Shop",
"Goron Shop",
"Zora Shop",
"Kakariko Potion Shop",
"Market Potion Shop",
"Bombchu Shop",
"Happy Mask Shop",
"Link's House",
"Back Alley House (Dog Lady)",
"Stable",
"Impa's House",
"Lakeside Laboratory",
"Carpenters' Tent",
"Gravekeeper's Hut",
"Great Fairy's Fountain (Upgrades)",
"Fairy's Fountain",
"Great Fairy's Fountain (Spells)",
"Grottos",
"Grave (Redead)",
"Grave (Fairy's Fountain)",
"Royal Family's Tomb",
"Shooting Gallery",
"Temple of Time",
"Chamber of the Sages",
"Castle Hedge Maze (Day)",
"Castle Hedge Maze (Night)",
"Cutscene Map",
"Dampé's Grave & Windmill",
"Fishing Pond",
"Castle Courtyard",
"Bombchu Bowling Alley",
"Ranch House & Silo",
"Guard House",
"Granny's Potion Shop",
"Ganon's Tower Collapse & Battle Arena",
"House of Skulltula",
"Spot 00 - Hyrule Field",
"Spot 01 - Kakariko Village",
"Spot 02 - Graveyard",
"Spot 03 - Zora's River",
"Spot 04 - Kokiri Forest",
"Spot 05 - Sacred Forest Meadow",
"Spot 06 - Lake Hylia",
"Spot 07 - Zora's Domain",
"Spot 08 - Zora's Fountain",
"Spot 09 - Gerudo Valley",
"Spot 10 - Lost Woods",
"Spot 11 - Desert Colossus",
"Spot 12 - Gerudo's Fortress",
"Spot 13 - Haunted Wasteland",
"Spot 15 - Hyrule Castle",
"Spot 16 - Death Mountain Trail",
"Spot 17 - Death Mountain Crater",
"Spot 18 - Goron City",
"Spot 20 - Lon Lon Ranch",
"Ganon's Castle Exterior",
"Jungle Gym",
"Ganondorf Test Room",
"Depth Test",
"Stalfos Mini-Boss Room",
"Stalfos Boss Room",
"Sutaru",
"Castle Hedge Maze (Early)",
"Sasa Test",
"Treasure Chest Room",
};
std::vector<std::string> itemNames = {
"Deku Stick",
"Deku Nut",
"Bomb",
"Fairy Bow",
"Fire Arrow",
"Din's Fire",
"Fairy Slingshot",
"Fairy Ocarina",
"Ocarina of Time",
"Bombchu",
"Hookshot",
"Longshot",
"Ice Arrow",
"Farore's Wind",
"Boomerang",
"Lens of Truth",
"Magic Bean",
"Megaton Hammer",
"Light Arrow",
"Nayru's Love",
"Empty Bottle",
"Red Potion",
"Green Potion",
"Blue Potion",
"Bottled Fairy",
"Fish",
"Lon Lon Milk & Bottle",
"Ruto's Letter",
"Blue Fire",
"Bug",
"Big Poe",
"Lon Lon Milk (Half)",
"Poe",
"Weird Egg",
"Chicken",
"Zelda's Letter",
"Keaton Mask",
"Skull Mask",
"Spooky Mask",
"Bunny Hood",
"Goron Mask",
"Zora Mask",
"Gerudo Mask",
"Mask of Truth",
"SOLD OUT",
"Pocket Egg",
"Pocket Cucco",
"Cojiro",
"Odd Mushroom",
"Odd Potion",
"Poacher's Saw",
"Goron's Sword (Broken)",
"Prescription",
"Eyeball Frog",
"Eye Drops",
"Claim Check",
"Fairy Bow & Fire Arrow",
"Fairy Bow & Ice Arrow",
"Fairy Bow & Light Arrow",
"Kokiri Sword",
"Master Sword",
"Giant's Knife & Biggoron's Sword",
"Deku Shield",
"Hylian Shield",
"Mirror Shield",
"Kokiri Tunic",
"Goron Tunic",
"Zora Tunic",
"Kokiri Boots",
"Iron Boots",
"Hover Boots",
"Bullet Bag (30)",
"Bullet Bag (40)",
"Bullet Bag (50)",
"Quiver (30)",
"Big Quiver (40)",
"Biggest Quiver (50)",
"Bomb Bag (20)",
"Big Bomb Bag (30)",
"Biggest Bomb Bag (40)",
"Goron's Bracelet",
"Silver Gauntlets",
"Golden Gauntlets",
"Silver Scale",
"Golden Scale",
"Giant's Knife (Broken)",
"Adult's Wallet",
"Giant's Wallet",
"Deku Seeds (5)",
"Fishing Pole",
"Minuet of Forest",
"Bolero of Fire",
"Serenade of Water",
"Requiem of Spirit",
"Nocturne of Shadow",
"Prelude of Light",
"Zelda's Lullaby",
"Epona's Song",
"Saria's Song",
"Sun's Song",
"Song of Time",
"Song of Storms",
"Forest Medallion",
"Fire Medallion",
"Water Medallion",
"Spirit Medallion",
"Shadow Medallion",
"Light Medallion",
"Kokiri's Emerald",
"Goron's Ruby",
"Zora's Sapphire",
"Stone of Agony",
"Gerudo's Card",
"Gold Skulltula Token",
"Heart Container",
"Piece of Heart [?]",
"Big Key",
"Compass",
"Dungeon Map",
"Small Key",
"Small Magic Jar",
"Large Magic Jar",
"Piece of Heart",
"[Removed]",
"[Removed]",
"[Removed]",
"[Removed]",
"[Removed]",
"[Removed]",
"[Removed]",
"Lon Lon Milk",
"Recovery Heart",
"Green Rupee",
"Blue Rupee",
"Red Rupee",
"Purple Rupee",
"Huge Rupee",
"[Removed]",
"Deku Sticks (5)",
"Deku Sticks (10)",
"Deku Nuts (5)",
"Deku Nuts (10)",
"Bombs (5)",
"Bombs (10)",
"Bombs (20)",
"Bombs (30)",
"Arrows (Small)",
"Arrows (Medium)",
"Arrows (Large)",
"Deku Seeds (30)",
"Bombchu (5)",
"Bombchu (20)",
"Deku Stick Upgrade (20)",
"Deku Stick Upgrade (30)",
"Deku Nut Upgrade (30)",
"Deku Nut Upgrade (40)",
};
std::vector<std::string> questItemNames = {
"Forest Medallion",
"Fire Medallion",
"Water Medallion",
"Spirit Medallion",
"Shadow Medallion",
"Light Medallion",
"Minuet of Forest",
"Bolero of Fire",
"Serenade of Water",
"Requiem of Spirit",
"Nocturne of Shadow",
"Prelude of Light",
"Zelda's Lullaby",
"Epona's Song",
"Saria's Song",
"Sun's Song",
"Song of Time",
"Song of Storms",
"Kokiri's Emerald",
"Goron's Ruby",
"Zora's Sapphire",
"Stone of Agony",
"Gerudo's Card",
"Gold Skulltula Token",
};
const std::string& SohUtils::GetSceneName(int32_t scene) {
return sceneNames[scene];
}
const std::string& SohUtils::GetItemName(int32_t item) {
return itemNames[item];
}
const std::string& SohUtils::GetQuestItemName(int32_t item) {
return questItemNames[item];
}

11
soh/soh/util.h Normal file
View File

@ -0,0 +1,11 @@
#pragma once
#include <string>
#include <stdint.h>
namespace SohUtils {
const std::string& GetSceneName(int32_t scene);
const std::string& GetItemName(int32_t item);
const std::string& GetQuestItemName(int32_t item);
} // namespace SohUtils