From 8f28eb2e0dab5be8ac6fb2963aed2205c308c3c4 Mon Sep 17 00:00:00 2001 From: Agent X <44549182+Agent-11@users.noreply.github.com> Date: Mon, 18 Dec 2023 16:22:42 -0500 Subject: [PATCH] Fix bugs and make mod import go to AppData --- Makefile | 7 ++++--- mods/char-select-cjes-and-vl/main.lua | 8 ++++---- src/game/level_update.c | 3 ++- src/pc/mods/mod_import.c | 8 ++++---- tools/remove_built_in_mods.py | 15 +++++++++++++++ 5 files changed, 29 insertions(+), 12 deletions(-) create mode 100644 tools/remove_built_in_mods.py diff --git a/Makefile b/Makefile index e3222228..8a041f48 100644 --- a/Makefile +++ b/Makefile @@ -627,6 +627,9 @@ _ := $(shell rm -rf ./$(BUILD_DIR)/$(LANG_DIR)) MOD_DIR := mods +# Remove old mod dir +_ := $(PYTHON) $(TOOLS_DIR)/remove_built_in_mods.py + # Automatic dependency files DEP_FILES := $(O_FILES:.o=.d) $(ULTRA_O_FILES:.o=.d) $(GODDARD_O_FILES:.o=.d) $(BUILD_DIR)/$(LD_SCRIPT).d @@ -1170,9 +1173,7 @@ $(BUILD_DIR)/$(LANG_DIR): @$(CP) -f -r $(LANG_DIR) $(BUILD_DIR) $(BUILD_DIR)/$(MOD_DIR): - @if [ ! -d "$(BUILD_DIR)/$(MOD_DIR)" ]; then \ - $(CP) -f -r $(MOD_DIR) $(BUILD_DIR); \ - fi + $(CP) -f -r $(MOD_DIR) $(BUILD_DIR) # Extra object file dependencies diff --git a/mods/char-select-cjes-and-vl/main.lua b/mods/char-select-cjes-and-vl/main.lua index 504122e4..d89f7307 100644 --- a/mods/char-select-cjes-and-vl/main.lua +++ b/mods/char-select-cjes-and-vl/main.lua @@ -1,16 +1,16 @@ --- name: [CS] Vl and Cjes Luigi +-- name: [CS] VL-Tone & Cjes Luigi -- description: A character swap mod using the Character Select's API. local E_MODEL_VL = smlua_model_util_get_id("vl_geo") local E_MODEL_CJES = smlua_model_util_get_id("cjes_geo") -local TEXT_MOD_NAME = "Vl and Cjes Luigi" +local TEXT_MOD_NAME = "VL-Tone & Cjes Luigi" local TEX_LUIGI = get_texture_info("luigi-icon") if _G.charSelectExists then - _G.charSelect.character_add("VL Luigi", {" A fanmade model of Luigi.", "The model was created for the", "program Toad's Tool 64, a romhack editor.", "This model is a nostalgic throwback to", "many players in the SM64 Community!"}, "VL Tone", {r = 0, g = 152, b = 0}, E_MODEL_VL, CT_LUIGI, TEX_LUIGI) + _G.charSelect.character_add("VL-Tone Luigi", {" A fanmade model of Luigi.", "The model was created for the", "program Toad's Tool 64, a romhack editor.", "This model is a nostalgic throwback to", "many players in the SM64 Community!"}, "VL-Tone", {r = 0, g = 152, b = 0}, E_MODEL_VL, CT_LUIGI, TEX_LUIGI) _G.charSelect.character_add("Cjes Luigi", {"Another fanmade Luigi model.", "The model originates from Super", "Luigi 64 in 2015.", "This model originally was the", "main Luigi model for ex-Coop before", "the giga leak occured in 2020 and", "eventually replaced it." }, "Cjes", {r = 0, g = 152, b = 0}, E_MODEL_CJES, CT_LUIGI, TEX_LUIGI) else - djui_popup_create("\\#ffffdc\\\n"..TEXT_MOD_NAME.."\nRequires the Character Select Mod\nto use as a Library!\n\nPlease turn on the Character Select Mod\nand Restart the Room!", 6) + djui_popup_create("\\#ffffdc\\\n"..TEXT_MOD_NAME.."\nRequires the Character Select Mod\nto use as a Library!\n\nPlease turn on the Character Select Mod\nand Restart the Room!", 6) end \ No newline at end of file diff --git a/src/game/level_update.c b/src/game/level_update.c index be50b523..7a9580ee 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -247,8 +247,9 @@ u16 level_control_timer(s32 timerOp) { u32 pressed_pause(void) { u32 dialogActive = get_dialog_id() >= 0; u32 intangible = (gMarioState->action & ACT_FLAG_INTANGIBLE) != 0; + u32 firstPerson = gMarioState->action == ACT_FIRST_PERSON; - if (!intangible && !dialogActive && !gWarpTransition.isActive && sDelayedWarpOp == WARP_OP_NONE + if (!intangible && !dialogActive && !firstPerson && !gWarpTransition.isActive && sDelayedWarpOp == WARP_OP_NONE && (gPlayer1Controller->buttonPressed & START_BUTTON)) { return TRUE; } diff --git a/src/pc/mods/mod_import.c b/src/pc/mods/mod_import.c index 2eb183de..2833dd5c 100644 --- a/src/pc/mods/mod_import.c +++ b/src/pc/mods/mod_import.c @@ -11,7 +11,7 @@ static bool mod_import_lua(char* src) { char dst[SYS_MAX_PATH] = { 0 }; - if (!concat_path(dst, (char*)MOD_DIRECTORY, path_basename(src))) { + if (!concat_path(dst, (char*)fs_get_write_path(MOD_DIRECTORY), path_basename(src))) { LOG_ERROR("Failed to concat path for lua mod import"); return false; } @@ -93,13 +93,13 @@ static bool mod_import_zip(char* path, bool* isLua, bool* isDynos) { char dstDirectory[SYS_MAX_PATH] = { 0 }; char dst[SYS_MAX_PATH] = { 0 }; if (*isLua) { - snprintf(dstDirectory, SYS_MAX_PATH, "%s", (char*)MOD_DIRECTORY); + snprintf(dstDirectory, SYS_MAX_PATH, "%s", (char*)fs_get_write_path(MOD_DIRECTORY)); } else if (*isDynos) { - char* dynosPath = (char*)DYNOS_RES_FOLDER; + char* dynosPath = (char*)fs_get_write_path(DYNOS_RES_FOLDER); if (!fs_sys_dir_exists(dynosPath)) { fs_sys_mkdir(dynosPath); } - snprintf(dstDirectory, SYS_MAX_PATH, "%s", (char*)DYNOS_PACKS_FOLDER); + snprintf(dstDirectory, SYS_MAX_PATH, "%s", (char*)fs_get_write_path(DYNOS_PACKS_FOLDER)); } else { LOG_ERROR("Could not figure out what type of mod this is"); mz_zip_reader_end(&zip_archive); diff --git a/tools/remove_built_in_mods.py b/tools/remove_built_in_mods.py new file mode 100644 index 00000000..2b805374 --- /dev/null +++ b/tools/remove_built_in_mods.py @@ -0,0 +1,15 @@ +import os +import sys + +if not os.path.exists("build/us_pc/mods"): + sys.exit(0) + +built_in_mods = [] + +for mod in os.listdir("mods"): + if os.path.isdir(mod) or (os.path.isfile(mod) and mod.endswith(".lua")): + built_in_mods.append(mod) + +for mod in os.listdir("build/us_pc/mods"): + if mod in built_in_mods: + os.remove(mod) \ No newline at end of file