-
Notifications
You must be signed in to change notification settings - Fork 632
Custom Hand DL's for each tunic #6096
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Jameriquiah
wants to merge
4
commits into
HarbourMasters:develop
Choose a base branch
from
Jameriquiah:customtunichands
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+194
−0
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,173 @@ | ||
| #include "soh/Enhancements/cosmetics/CustomTunicDLs.h" | ||
|
|
||
| #include "soh/ResourceManagerHelpers.h" | ||
|
|
||
| #include "variables.h" | ||
| #include "z64item.h" | ||
|
|
||
| #include <string> | ||
| #include <string_view> | ||
| #include <unordered_map> | ||
|
|
||
| namespace { | ||
| constexpr std::string_view kOtrPrefix = "__OTR__"; | ||
|
|
||
| enum class TunicType { | ||
| None, | ||
| Goron, | ||
| Zora, | ||
| }; | ||
|
|
||
| TunicType GetTunicType() { | ||
| s32 tunicEquip = (gSaveContext.equips.equipment & gEquipMasks[EQUIP_TYPE_TUNIC]) >> gEquipShifts[EQUIP_TYPE_TUNIC]; | ||
| switch (tunicEquip) { | ||
| case EQUIP_VALUE_TUNIC_GORON: | ||
| return TunicType::Goron; | ||
| case EQUIP_VALUE_TUNIC_ZORA: | ||
| return TunicType::Zora; | ||
| default: | ||
| return TunicType::None; | ||
| } | ||
| } | ||
|
|
||
| struct RemapEntry { | ||
| std::string_view base; | ||
| std::string_view goron; | ||
| std::string_view zora; | ||
| }; | ||
|
|
||
| constexpr RemapEntry kRemapEntries[] = { | ||
| { "objects/object_link_boy/gLinkAdultLeftHandClosedNearDL", | ||
| "objects/object_link_boy_goron/gLinkAdultLeftHandClosedNearDL", | ||
| "objects/object_link_boy_zora/gLinkAdultLeftHandClosedNearDL" }, | ||
| { "objects/object_link_boy/gLinkAdultLeftHandNearDL", "objects/object_link_boy_goron/gLinkAdultLeftHandNearDL", | ||
| "objects/object_link_boy_zora/gLinkAdultLeftHandNearDL" }, | ||
| { "objects/object_link_boy/gLinkAdultLeftHandOutNearDL", | ||
| "objects/object_link_boy_goron/gLinkAdultLeftHandOutNearDL", | ||
| "objects/object_link_boy_zora/gLinkAdultLeftHandOutNearDL" }, | ||
| { "objects/object_link_boy/gLinkAdultRightHandClosedNearDL", | ||
| "objects/object_link_boy_goron/gLinkAdultRightHandClosedNearDL", | ||
| "objects/object_link_boy_zora/gLinkAdultRightHandClosedNearDL" }, | ||
| { "objects/object_link_boy/gLinkAdultRightHandHoldingOotNearDL", | ||
| "objects/object_link_boy_goron/gLinkAdultRightHandHoldingOotNearDL", | ||
| "objects/object_link_boy_zora/gLinkAdultRightHandHoldingOotNearDL" }, | ||
| { "objects/object_link_boy/gLinkAdultRightHandNearDL", "objects/object_link_boy_goron/gLinkAdultRightHandNearDL", | ||
| "objects/object_link_boy_zora/gLinkAdultRightHandNearDL" }, | ||
| { "objects/object_link_boy/gLinkAdultRightArmOutNearDL", | ||
| "objects/object_link_boy_goron/gLinkAdultRightArmOutNearDL", | ||
| "objects/object_link_boy_zora/gLinkAdultRightArmOutNearDL" }, | ||
| { "objects/object_link_boy/gLinkAdultRightHandOutNearDL", | ||
| "objects/object_link_boy_goron/gLinkAdultRightHandOutNearDL", | ||
| "objects/object_link_boy_zora/gLinkAdultRightHandOutNearDL" }, | ||
| { "objects/object_link_boy/gLinkAdultRightHandHoldingHookshotFarDL", | ||
| "objects/object_link_boy_goron/gLinkAdultRightHandHoldingHookshotFarDL", | ||
| "objects/object_link_boy_zora/gLinkAdultRightHandHoldingHookshotFarDL" }, | ||
| { "objects/object_link_boy/gLinkAdultRightHandHoldingBowFirstPersonDL", | ||
| "objects/object_link_boy_goron/gLinkAdultRightHandHoldingBowFirstPersonDL", | ||
| "objects/object_link_boy_zora/gLinkAdultRightHandHoldingBowFirstPersonDL" }, | ||
| { "objects/object_link_child/gLinkChildLeftFistNearDL", "objects/object_link_child_goron/gLinkChildLeftFistNearDL", | ||
| "objects/object_link_child_zora/gLinkChildLeftFistNearDL" }, | ||
| { "objects/object_link_child/gLinkChildLeftHandHoldingMasterSwordDL", | ||
| "objects/object_link_child_goron/gLinkChildLeftHandHoldingMasterSwordDL", | ||
| "objects/object_link_child_zora/gLinkChildLeftHandHoldingMasterSwordDL" }, | ||
| { "objects/object_link_child/gLinkChildLeftHandNearDL", "objects/object_link_child_goron/gLinkChildLeftHandNearDL", | ||
| "objects/object_link_child_zora/gLinkChildLeftHandNearDL" }, | ||
| { "objects/object_link_child/gLinkChildLeftHandUpNearDL", | ||
| "objects/object_link_child_goron/gLinkChildLeftHandUpNearDL", | ||
| "objects/object_link_child_zora/gLinkChildLeftHandUpNearDL" }, | ||
| { "objects/object_link_child/gLinkChildRightHandClosedNearDL", | ||
| "objects/object_link_child_goron/gLinkChildRightHandClosedNearDL", | ||
| "objects/object_link_child_zora/gLinkChildRightHandClosedNearDL" }, | ||
| { "objects/object_link_child/gLinkChildRightArmStretchedSlingshotDL", | ||
| "objects/object_link_child_goron/gLinkChildRightArmStretchedSlingshotDL", | ||
| "objects/object_link_child_zora/gLinkChildRightArmStretchedSlingshotDL" }, | ||
| { "objects/object_link_child/gLinkChildRightHandNearDL", | ||
| "objects/object_link_child_goron/gLinkChildRightHandNearDL", | ||
| "objects/object_link_child_zora/gLinkChildRightHandNearDL" }, | ||
| { "objects/object_link_child/gLinkChildRightHandHoldingFairyOcarinaNearDL", | ||
| "objects/object_link_child_goron/gLinkChildRightHandHoldingFairyOcarinaNearDL", | ||
| "objects/object_link_child_zora/gLinkChildRightHandHoldingFairyOcarinaNearDL" }, | ||
| { "objects/object_link_child/gLinkChildRightHandAndOotNearDL", | ||
| "objects/object_link_child_goron/gLinkChildRightHandAndOotNearDL", | ||
| "objects/object_link_child_zora/gLinkChildRightHandAndOotNearDL" }, | ||
| { "objects/object_custom_equip/gCustomAdultFPSHandDL", "objects/object_custom_equip/gCustomAdultGoronFPSHandDL", | ||
| "objects/object_custom_equip/gCustomAdultZoraFPSHandDL" }, | ||
| { "objects/object_custom_equip/gCustomChildFPSHandDL", "objects/object_custom_equip/gCustomChildGoronFPSHandDL", | ||
| "objects/object_custom_equip/gCustomChildZoraFPSHandDL" }, | ||
| { "objects/object_link_boy/gLinkAdultLeftIronBootDL", "objects/object_link_boy_goron/gLinkAdultLeftIronBootDL", | ||
| "objects/object_link_boy_zora/gLinkAdultLeftIronBootDL" }, | ||
| { "objects/object_link_boy/gLinkAdultRightIronBootDL", "objects/object_link_boy_goron/gLinkAdultRightIronBootDL", | ||
| "objects/object_link_boy_zora/gLinkAdultRightIronBootDL" }, | ||
| { "objects/object_link_boy/gLinkAdultLeftHoverBootDL", "objects/object_link_boy_goron/gLinkAdultLeftHoverBootDL", | ||
| "objects/object_link_boy_zora/gLinkAdultLeftHoverBootDL" }, | ||
| { "objects/object_link_boy/gLinkAdultRightHoverBootDL", "objects/object_link_boy_goron/gLinkAdultRightHoverBootDL", | ||
| "objects/object_link_boy_zora/gLinkAdultRightHoverBootDL" }, | ||
| }; | ||
|
|
||
| std::string_view StripOtrPrefix(std::string_view path) { | ||
| if (path.starts_with(kOtrPrefix)) { | ||
| return path.substr(kOtrPrefix.size()); | ||
| } | ||
| return path; | ||
| } | ||
|
|
||
| bool TargetExists(std::string_view path) { | ||
| return ResourceMgr_FileExists(path.data()) || | ||
| (ResourceMgr_IsAltAssetsEnabled() && ResourceMgr_FileAltExists(path.data())); | ||
| } | ||
|
|
||
| std::string_view GetRemapTarget(std::string_view view, TunicType tunicType) { | ||
| if (tunicType == TunicType::None) { | ||
| return {}; | ||
| } | ||
|
|
||
| for (const auto& entry : kRemapEntries) { | ||
| if (view == entry.base) { | ||
| return (tunicType == TunicType::Goron) ? entry.goron : entry.zora; | ||
| } | ||
| } | ||
|
|
||
| return {}; | ||
| } | ||
|
|
||
| const char* MakeRemappedPath(std::string_view target, bool hasOtrPrefix) { | ||
| std::string fullPath; | ||
| if (hasOtrPrefix) { | ||
| fullPath.reserve(kOtrPrefix.size() + target.size()); | ||
| fullPath.append(kOtrPrefix); | ||
| fullPath.append(target); | ||
| } else { | ||
| fullPath.assign(target); | ||
| } | ||
|
|
||
| static thread_local std::unordered_map<std::string, std::string> remappedCache; | ||
| auto [it, inserted] = remappedCache.emplace(fullPath, fullPath); | ||
| return it->second.c_str(); | ||
| } | ||
| } // namespace | ||
|
|
||
| const char* CustomTunicDLs_RemapPath(const char* path) { | ||
| if (path == nullptr) { | ||
| return path; | ||
| } | ||
|
|
||
| std::string_view view(path); | ||
| bool hasOtrPrefix = view.starts_with(kOtrPrefix); | ||
| view = StripOtrPrefix(view); | ||
|
|
||
| TunicType tunicType = GetTunicType(); | ||
| if (tunicType == TunicType::None) { | ||
| return path; | ||
| } | ||
|
|
||
| std::string_view target = GetRemapTarget(view, tunicType); | ||
| if (target.empty()) { | ||
| return path; | ||
| } | ||
|
|
||
| if (!TargetExists(target)) { | ||
| return path; | ||
| } | ||
|
|
||
| return MakeRemappedPath(target, hasOtrPrefix); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| #pragma once | ||
|
|
||
| const char* CustomTunicDLs_RemapPath(const char* path); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.