mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-12-21 23:58:51 -05:00
Fix: Prevent patching custom models (#3367)
* fix prevent patching custom models * prevent patching chests textures for custom chest models * add tooltip for cosmetic editor about custom models * chest texture handling for alt toggles
This commit is contained in:
parent
bf31f2b330
commit
e66eb8756d
@ -1767,6 +1767,10 @@ void CosmeticsEditorWindow::DrawElement() {
|
||||
ImGui::SameLine();
|
||||
UIWidgets::EnhancementCombobox("gCosmetics.DefaultColorScheme", colorSchemes, COLORSCHEME_N64);
|
||||
UIWidgets::EnhancementCheckbox("Advanced Mode", "gCosmetics.AdvancedMode");
|
||||
UIWidgets::InsertHelpHoverText(
|
||||
"Some cosmetic options may not apply if you have any mods that provide custom models for the cosmetic option.\n\n"
|
||||
"For example, if you have custom Link model, then the Link's Hair color option will most likely not apply."
|
||||
);
|
||||
if (CVarGetInteger("gCosmetics.AdvancedMode", 0)) {
|
||||
if (ImGui::Button("Lock All Advanced", ImVec2(ImGui::GetContentRegionAvail().x / 2, 30.0f))) {
|
||||
for (auto& [id, cosmeticOption] : cosmeticOptions) {
|
||||
|
@ -1569,6 +1569,11 @@ extern "C" Gfx* ResourceMgr_LoadGfxByName(const char* path)
|
||||
return (Gfx*)&res->Instructions[0];
|
||||
}
|
||||
|
||||
extern "C" uint8_t ResourceMgr_FileIsCustomByName(const char* path) {
|
||||
auto res = std::static_pointer_cast<LUS::DisplayList>(GetResourceByNameHandlingMQ(path));
|
||||
return res->GetInitData()->IsCustom;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
int index;
|
||||
Gfx instruction;
|
||||
@ -1600,6 +1605,11 @@ extern "C" void ResourceMgr_PatchGfxByName(const char* path, const char* patchNa
|
||||
// index /= 2;
|
||||
// }
|
||||
|
||||
// Do not patch custom assets as they most likely do not have the same instructions as authentic assets
|
||||
if (res->GetInitData()->IsCustom) {
|
||||
return;
|
||||
}
|
||||
|
||||
Gfx* gfx = (Gfx*)&res->Instructions[index];
|
||||
|
||||
if (!originalGfx.contains(path) || !originalGfx[path].contains(patchName)) {
|
||||
@ -1616,6 +1626,11 @@ extern "C" void ResourceMgr_PatchGfxCopyCommandByName(const char* path, const ch
|
||||
auto res = std::static_pointer_cast<LUS::DisplayList>(
|
||||
LUS::Context::GetInstance()->GetResourceManager()->LoadResource(path));
|
||||
|
||||
// Do not patch custom assets as they most likely do not have the same instructions as authentic assets
|
||||
if (res->GetInitData()->IsCustom) {
|
||||
return;
|
||||
}
|
||||
|
||||
Gfx* destinationGfx = (Gfx*)&res->Instructions[destinationIndex];
|
||||
Gfx sourceGfx = res->Instructions[sourceIndex];
|
||||
|
||||
|
@ -101,6 +101,7 @@ AnimationHeaderCommon* ResourceMgr_LoadAnimByName(const char* path);
|
||||
char* ResourceMgr_GetNameByCRC(uint64_t crc, char* alloc);
|
||||
Gfx* ResourceMgr_LoadGfxByCRC(uint64_t crc);
|
||||
Gfx* ResourceMgr_LoadGfxByName(const char* path);
|
||||
uint8_t ResourceMgr_FileIsCustomByName(const char* path);
|
||||
void ResourceMgr_PatchGfxByName(const char* path, const char* patchName, int index, Gfx instruction);
|
||||
void ResourceMgr_UnpatchGfxByName(const char* path, const char* patchName);
|
||||
char* ResourceMgr_LoadArrayByNameAsVec3s(const char* path);
|
||||
|
@ -532,6 +532,8 @@ void DrawEnhancementsMenu() {
|
||||
" - Small keys: Small silver chest\n"
|
||||
" - Boss keys: Vanilla size and texture\n"
|
||||
" - Skulltula Tokens: Small skulltula chest\n"
|
||||
"\n"
|
||||
"NOTE: Textures will not apply if you are using a mod pack with a custom chest model."
|
||||
);
|
||||
if (CVarGetInteger("gChestSizeAndTextureMatchesContents", CSMC_DISABLED) != CSMC_DISABLED) {
|
||||
UIWidgets::PaddedEnhancementCheckbox("Chests of Agony", "gChestSizeDependsStoneOfAgony", true, false);
|
||||
|
@ -88,6 +88,7 @@ Gfx gKeyTreasureChestChestFrontDL[128] = {0};
|
||||
Gfx gChristmasRedTreasureChestChestFrontDL[128] = {0};
|
||||
Gfx gChristmasGreenTreasureChestChestFrontDL[128] = {0};
|
||||
u8 hasCreatedRandoChestTextures = 0;
|
||||
u8 hasCustomChestDLs = 0;
|
||||
u8 hasChristmasChestTexturesAvailable = 0;
|
||||
|
||||
void EnBox_SetupAction(EnBox* this, EnBoxActionFunc actionFunc) {
|
||||
@ -690,7 +691,7 @@ void EnBox_UpdateSizeAndTexture(EnBox* this, PlayState* play) {
|
||||
}
|
||||
|
||||
// Change texture
|
||||
if (!isVanilla && (csmc == CSMC_BOTH || csmc == CSMC_TEXTURE)) {
|
||||
if (!isVanilla && hasCreatedRandoChestTextures && !hasCustomChestDLs && (csmc == CSMC_BOTH || csmc == CSMC_TEXTURE)) {
|
||||
switch (getItemCategory) {
|
||||
case ITEM_CATEGORY_MAJOR:
|
||||
this->boxBodyDL = gGoldTreasureChestChestFrontDL;
|
||||
@ -725,7 +726,7 @@ void EnBox_UpdateSizeAndTexture(EnBox* this, PlayState* play) {
|
||||
}
|
||||
}
|
||||
|
||||
if (CVarGetInteger("gLetItSnow", 0) && hasChristmasChestTexturesAvailable) {
|
||||
if (CVarGetInteger("gLetItSnow", 0) && hasChristmasChestTexturesAvailable && hasCreatedRandoChestTextures && !hasCustomChestDLs) {
|
||||
if (this->dyna.actor.scale.x == 0.01f) {
|
||||
this->boxBodyDL = gChristmasRedTreasureChestChestFrontDL;
|
||||
this->boxLidDL = gChristmasRedTreasureChestChestSideAndLidDL;
|
||||
@ -767,7 +768,18 @@ void EnBox_UpdateSizeAndTexture(EnBox* this, PlayState* play) {
|
||||
}
|
||||
|
||||
void EnBox_CreateExtraChestTextures() {
|
||||
// Don't patch textures for custom chest models, as they do not import textures the exact same way as vanilla chests
|
||||
// OTRTODO: Make it so model packs can provide a unique DL per chest type, instead of us copying the brown chest and attempting to patch
|
||||
if (ResourceMgr_FileIsCustomByName(gTreasureChestChestFrontDL) ||
|
||||
ResourceMgr_FileIsCustomByName(gTreasureChestChestSideAndLidDL)) {
|
||||
hasCustomChestDLs = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
hasCustomChestDLs = 0;
|
||||
|
||||
if (hasCreatedRandoChestTextures) return;
|
||||
|
||||
Gfx gTreasureChestChestTextures[] = {
|
||||
gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, gSkullTreasureChestFrontTex),
|
||||
gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, gSkullTreasureChestSideAndTopTex),
|
||||
|
Loading…
Reference in New Issue
Block a user