Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/lscholte/2ship2harkinian
Browse files Browse the repository at this point in the history
…into deku-guard-search-balls

# Conflicts:
#	mm/2s2h/GameInteractor/GameInteractor.h
  • Loading branch information
lscholte committed Nov 26, 2024
2 parents d93a939 + 7c222f9 commit 1c3167b
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 9 deletions.
8 changes: 8 additions & 0 deletions mm/2s2h/BenGui/BenMenuBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,11 @@ void DrawEnhancementsMenu() {
{ .tooltip = "Fixes a bug that results in the Ikana Great Fairy fountain looking "
"green instead of yellow, this was fixed in the EU version" });

UIWidgets::CVarCheckbox("Fix Completed Heart Container Audio",
"gEnhancements.Fixes.CompletedHeartContainerAudio",
{ .tooltip = "Fixes a bug that results in the wrong audio playing upon "
"receiving a 4th piece of heart to fill a new heart container." });

if (UIWidgets::CVarCheckbox(
"Fix Texture overflow OOB", "gEnhancements.Fixes.FixTexturesOOB",
{ .tooltip = "Fixes textures that normally overflow to be patched with the correct size or format",
Expand Down Expand Up @@ -833,6 +838,9 @@ void DrawCheatsMenu() {
UIWidgets::CVarCheckbox("No Clip", "gCheats.NoClip");
UIWidgets::CVarCheckbox("Unbreakable Razor Sword", "gCheats.UnbreakableRazorSword");
UIWidgets::CVarCheckbox("Unrestricted Items", "gCheats.UnrestrictedItems");
UIWidgets::CVarCheckbox("Hookshot Anywhere", "gCheats.HookshotAnywhere",
{ .tooltip = "Allows most surfaces to be hookshot-able" });

if (UIWidgets::CVarCheckbox("Moon Jump on L", "gCheats.MoonJumpOnL",
{ .tooltip = "Holding L makes you float into the air" })) {
RegisterMoonJumpOnL();
Expand Down
8 changes: 7 additions & 1 deletion mm/2s2h/BenGui/SearchableMenuItems.h
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,8 @@ void AddEnhancements() {
"Allows to Razor Sword to be used indefinitely without dulling its blade.", WIDGET_CVAR_CHECKBOX },
{ "Unrestricted Items", "gCheats.UnrestrictedItems", "Allows all Forms to use all Items.",
WIDGET_CVAR_CHECKBOX },
{ "Hookshot Anywhere", "gCheats.HookshotAnywhere", "Allows most surfaces to be hookshot-able",
WIDGET_CVAR_CHECKBOX },
{ "Moon Jump on L",
"gCheats.MoonJumpOnL",
"Holding L makes you float into the air.",
Expand Down Expand Up @@ -1381,7 +1383,11 @@ void AddEnhancements() {
.widgetTooltip = "Fixes textures that normally overflow to be patched with the correct size or format",
.widgetType = WIDGET_CVAR_CHECKBOX,
.widgetOptions = { .defaultVariant = true },
.widgetCallback = [](widgetInfo& info) { GfxPatcher_ApplyOverflowTexturePatches(); } } } } });
.widgetCallback = [](widgetInfo& info) { GfxPatcher_ApplyOverflowTexturePatches(); } },
{ "Fix Completed Heart Container Audio", "gEnhancements.Fixes.CompletedHeartContainerAudio",
"Fixes a bug that results in the wrong audio playing upon receiving a 4th piece of heart to "
"fill a new heart container.",
WIDGET_CVAR_CHECKBOX } } } });
enhancementsSidebar.push_back(
{ "Restorations",
3,
Expand Down
30 changes: 27 additions & 3 deletions mm/2s2h/BenGui/UIWidgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <unordered_map>
#include <libultraship/libultra/types.h>
#include "2s2h/ShipUtils.h"
#include <spdlog/fmt/fmt.h>

namespace UIWidgets {
// Automatically adds newlines to break up text longer than a specified number of characters
Expand Down Expand Up @@ -534,7 +535,7 @@ void DrawFlagArray32(const std::string& name, uint32_t& flags) {
ImGui::PushID(flagIndex);
uint32_t bitMask = 1 << flagIndex;
bool flag = (flags & bitMask) != 0;
std::string label = std::to_string(flagIndex);
std::string label = fmt::format("0x{:02X} ({})", flagIndex, flagIndex);
if (UIWidgets::Checkbox(label.c_str(), &flag,
{ .tooltip = label.c_str(), .labelPosition = LabelPosition::None })) {
if (flag) {
Expand All @@ -557,7 +558,7 @@ void DrawFlagArray16(const std::string& name, uint16_t& flags) {
ImGui::PushID(flagIndex);
uint16_t bitMask = 1 << flagIndex;
bool flag = (flags & bitMask) != 0;
std::string label = std::to_string(flagIndex);
std::string label = fmt::format("0x{:02X} ({})", flagIndex, flagIndex);
if (UIWidgets::Checkbox(label.c_str(), &flag,
{ .tooltip = label.c_str(), .labelPosition = LabelPosition::None })) {
if (flag) {
Expand All @@ -580,7 +581,30 @@ void DrawFlagArray8(const std::string& name, uint8_t& flags) {
ImGui::PushID(flagIndex);
uint8_t bitMask = 1 << flagIndex;
bool flag = (flags & bitMask) != 0;
std::string label = std::to_string(flagIndex);
std::string label = fmt::format("0x{:02X} ({})", flagIndex, flagIndex);
if (UIWidgets::Checkbox(label.c_str(), &flag,
{ .tooltip = label.c_str(), .labelPosition = LabelPosition::None })) {
if (flag) {
flags |= bitMask;
} else {
flags &= ~bitMask;
}
}
ImGui::PopID();
}
ImGui::PopID();
}

void DrawFlagArray8Mask(const std::string& name, uint8_t& flags) {
ImGui::PushID(name.c_str());
for (int8_t flagIndex = 0; flagIndex < 8; flagIndex++) {
if ((flagIndex % 8) != 0) {
ImGui::SameLine();
}
ImGui::PushID(flagIndex);
uint8_t bitMask = 1 << flagIndex;
bool flag = (flags & bitMask) != 0;
std::string label = fmt::format("0x{:02X} ({})", bitMask, flagIndex);
if (UIWidgets::Checkbox(label.c_str(), &flag,
{ .tooltip = label.c_str(), .labelPosition = LabelPosition::None })) {
if (flag) {
Expand Down
1 change: 1 addition & 0 deletions mm/2s2h/BenGui/UIWidgets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ namespace UIWidgets {
void DrawFlagArray32(const std::string& name, uint32_t& flags);
void DrawFlagArray16(const std::string& name, uint16_t& flags);
void DrawFlagArray8(const std::string& name, uint8_t& flags);
void DrawFlagArray8Mask(const std::string& name, uint8_t& flags);
}

#endif /* UIWidgets_hpp */
2 changes: 1 addition & 1 deletion mm/2s2h/DeveloperTools/SaveEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1722,7 +1722,7 @@ void DrawFlagsTab() {
ImGui::PushID(i);
ImGui::Text("%02d", i);
ImGui::SameLine();
UIWidgets::DrawFlagArray8("##", gSaveContext.save.saveInfo.weekEventReg[i]);
UIWidgets::DrawFlagArray8Mask("##", gSaveContext.save.saveInfo.weekEventReg[i]);
ImGui::PopID();
}
break;
Expand Down
1 change: 1 addition & 0 deletions mm/2s2h/Enhancements/Cheats/Cheats.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ void RegisterTimeStopInTemples();
void RegisterUnbreakableRazorSword();
void RegisterUnrestrictedItems();
void RegisterElegyAnywhere();
void RegisterHookshotAnywhere();

#endif // CHEATS_H
10 changes: 10 additions & 0 deletions mm/2s2h/Enhancements/Cheats/HookshotAnywhere.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <libultraship/bridge.h>
#include "GameInteractor/GameInteractor.h"

void RegisterHookshotAnywhere() {
REGISTER_VB_SHOULD(VB_BE_HOOKSHOT_SURFACE, {
if (CVarGetInteger("gCheats.HookshotAnywhere", 0)) {
*should = true;
}
});
}
2 changes: 2 additions & 0 deletions mm/2s2h/Enhancements/Enhancements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ void InitEnhancements() {
RegisterUnrestrictedItems();
RegisterTimeStopInTemples();
RegisterElegyAnywhere();
RegisterHookshotAnywhere();

// Clock
RegisterTextBasedClock();
Expand All @@ -35,6 +36,7 @@ void InitEnhancements() {
// Fixes
RegisterFierceDeityZTargetMovement();
RegisterTwoHandedSwordSpinAttack();
RegisterCompletedHeartContainerAudio();

// Graphics
RegisterDisableBlackBars();
Expand Down
16 changes: 16 additions & 0 deletions mm/2s2h/Enhancements/Fixes/CompletedHeartContainerAudio.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <libultraship/bridge.h>
#include "2s2h/GameInteractor/GameInteractor.h"

extern "C" {
#include "variables.h"
}

void RegisterCompletedHeartContainerAudio() {
REGISTER_VB_SHOULD(VB_PLAY_HEART_CONTAINER_GET_FANFARE, {
GetItemId getItemId = (GetItemId)va_arg(args, int);
if (CVarGetInteger("gEnhancements.Fixes.CompletedHeartContainerAudio", 0) && getItemId == GI_HEART_PIECE &&
GET_QUEST_HEART_PIECE_COUNT == 0) {
*should = true;
}
});
}
1 change: 1 addition & 0 deletions mm/2s2h/Enhancements/Fixes/Fixes.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef ENHANCEMENTS_FIXES_H
#define ENHANCEMENTS_FIXES_H

void RegisterCompletedHeartContainerAudio();
void RegisterFierceDeityZTargetMovement();

#endif // ENHANCEMENTS_FIXES_H
2 changes: 2 additions & 0 deletions mm/2s2h/GameInteractor/GameInteractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ typedef enum {
VB_CHECK_HELD_ITEM_BUTTON_PRESS,
VB_MAGIC_SPIN_ATTACK_CHECK_FORM,
VB_TRANSFORM_THUNDER_MATRIX,
VB_PLAY_HEART_CONTAINER_GET_FANFARE,
VB_BE_HOOKSHOT_SURFACE,
VB_DEKU_GUARD_SHOW_SEARCH_BALLS,
} GIVanillaBehavior;

Expand Down
6 changes: 4 additions & 2 deletions mm/src/code/z_bgcheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
#include "fixed_point.h"
#include "vt.h"
#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h"
#include <stdio.h>

#include <stdio.h>
#include "2s2h/BenPort.h"
#include "2s2h/GameInteractor/GameInteractor.h"

#define DYNA_RAYCAST_FLOORS 1
#define DYNA_RAYCAST_WALLS 2
Expand Down Expand Up @@ -4276,7 +4277,8 @@ u32 SurfaceType_GetEcho(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId)
}

u32 SurfaceType_IsHookshotSurface(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
return SurfaceType_GetData(colCtx, poly, bgId, 1) >> 17 & 1;
return GameInteractor_Should(VB_BE_HOOKSHOT_SURFACE, SurfaceType_GetData(colCtx, poly, bgId, 1) >> 17 & 1, poly,
bgId);
}

s32 SurfaceType_IsIgnoredByEntities(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
Expand Down
5 changes: 3 additions & 2 deletions mm/src/overlays/actors/ovl_player_actor/z_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -13521,8 +13521,9 @@ s32 func_808482E0(PlayState* play, Player* this) {
} else {
s32 seqId;

if ((this->getItemId == GI_HEART_CONTAINER) ||
((this->getItemId == GI_HEART_PIECE) && EQ_MAX_QUEST_HEART_PIECE_COUNT)) {
bool vanillaCondition = (this->getItemId == GI_HEART_CONTAINER) ||
((this->getItemId == GI_HEART_PIECE) && EQ_MAX_QUEST_HEART_PIECE_COUNT);
if (GameInteractor_Should(VB_PLAY_HEART_CONTAINER_GET_FANFARE, vanillaCondition, this->getItemId)) {
seqId = NA_BGM_GET_HEART | 0x900;
} else {
s32 var_v1;
Expand Down

0 comments on commit 1c3167b

Please sign in to comment.