From 68f3203587cb016847e96f0dd58077267c287e26 Mon Sep 17 00:00:00 2001 From: MysterD Date: Wed, 16 Mar 2022 22:43:43 -0700 Subject: [PATCH] Allow people to disabled downloaded models (from mods) --- data/dynos.cpp.h | 1 + data/dynos_gfx_update.cpp | 14 +++++++++++++- data/dynos_misc.cpp | 7 ++++++- src/pc/configfile.c | 8 +++++--- src/pc/configfile.h | 3 ++- src/pc/djui/djui_panel_display.c | 6 +++++- 6 files changed, 32 insertions(+), 7 deletions(-) diff --git a/data/dynos.cpp.h b/data/dynos.cpp.h index 8d8bd82b7..94bc6c34e 100644 --- a/data/dynos.cpp.h +++ b/data/dynos.cpp.h @@ -666,6 +666,7 @@ s32 DynOS_String_Width(const u8 *aStr64); #ifdef COOP void DynOS_Geo_AddActorCustom(const SysPath &aPackFolder, const char *aActorName); const void *DynOS_Geo_GetActorLayoutFromName(const char *aActorName); +bool DynOS_Geo_IsCustomActor(s32 aIndex); #endif s32 DynOS_Geo_GetActorCount(); diff --git a/data/dynos_gfx_update.cpp b/data/dynos_gfx_update.cpp index 9116ebe96..365d0fb01 100644 --- a/data/dynos_gfx_update.cpp +++ b/data/dynos_gfx_update.cpp @@ -3,6 +3,9 @@ extern "C" { #include "object_fields.h" #include "game/level_update.h" #include "game/object_list_processor.h" +#ifdef COOP +#include "pc/configfile.h" +#endif } // @@ -129,8 +132,17 @@ void DynOS_Gfx_Update() { // Replace the object's model and animations ActorGfx *_ActorGfx = &DynOS_Gfx_GetActorList()[_ActorIndex]; +#ifdef COOP + if (configDisableDownloadedModels && _ActorGfx->mPackIndex == 99) { + extern const GeoLayout error_model_geo[]; + s32 actorIndex = DynOS_Geo_IsCustomActor(_ActorIndex) ? DynOS_Geo_GetActorIndex(error_model_geo) : _ActorIndex; + const void* geoLayout = DynOS_Geo_GetActorLayout(actorIndex); + _ActorGfx->mPackIndex = -1; + _ActorGfx->mGfxData = NULL; + _ActorGfx->mGraphNode = (GraphNode *) DynOS_Geo_GetGraphNode(geoLayout, true); + } +#endif for (s32 i = 0; i != pDynosPacks.Count(); ++i) { - // If enabled and no pack is selected // load the pack's model and replace the default actor's model if (_Enabled[i] && _ActorGfx->mPackIndex == -1) { diff --git a/data/dynos_misc.cpp b/data/dynos_misc.cpp index 63adefe9c..583f86a5f 100644 --- a/data/dynos_misc.cpp +++ b/data/dynos_misc.cpp @@ -380,7 +380,7 @@ void DynOS_Geo_AddActorCustom(const SysPath &aPackFolder, const char *aActorName // Alloc and init the actors gfx list Array &pActorGfxList = DynOS_Gfx_GetActorList(); pActorGfxList.Resize(DynOS_Geo_GetActorCount()); - pActorGfxList[index].mPackIndex = -1; + pActorGfxList[index].mPackIndex = 99; pActorGfxList[index].mGfxData = _GfxData; pActorGfxList[index].mGraphNode = (GraphNode *) DynOS_Geo_GetGraphNode(geoLayout, true); } @@ -420,6 +420,11 @@ s32 DynOS_Geo_GetActorIndex(const void *aGeoLayout) { return -1; } +bool DynOS_Geo_IsCustomActor(s32 aIndex) { + s32 arrayCount = (s32) (sizeof(sDynosActors) / (2 * sizeof(sDynosActors[0]))); + return aIndex >= arrayCount; +} + #else // NORMAL DYNOS s32 DynOS_Geo_GetActorCount() { diff --git a/src/pc/configfile.c b/src/pc/configfile.c index 4866eea76..d7b6f210e 100644 --- a/src/pc/configfile.c +++ b/src/pc/configfile.c @@ -113,9 +113,8 @@ bool configCameraMouse = false; bool configSkipIntro = 0; bool configShareLives = 0; bool configEnableCheats = 0; -bool configDisablePopups = 0; bool configBubbleDeath = true; -unsigned int configAmountofPlayers = 16; +unsigned int configAmountofPlayers = 16; bool configHUD = true; #ifdef DISCORDRPC bool configDiscordRPC = true; @@ -134,6 +133,8 @@ unsigned int configPlayerModel = 0; unsigned int configPlayerPalette = 0; unsigned int config60Fps = 1; unsigned int configDrawDistance = 5; +bool configDisablePopups = 0; +bool configDisableDownloadedModels = 0; static const struct ConfigOption options[] = { {.name = "fullscreen", .type = CONFIG_TYPE_BOOL, .boolValue = &configWindow.fullscreen}, @@ -187,7 +188,6 @@ static const struct ConfigOption options[] = { {.name = "bettercam_degrade", .type = CONFIG_TYPE_UINT, .uintValue = &configCameraDegrade}, #endif {.name = "skip_intro", .type = CONFIG_TYPE_BOOL, .boolValue = &configSkipIntro}, - {.name = "enable_popups", .type = CONFIG_TYPE_BOOL, .boolValue = &configDisablePopups}, {.name = "enable_cheats", .type = CONFIG_TYPE_BOOL, .boolValue = &configEnableCheats}, #ifdef DISCORDRPC {.name = "discordrpc_enable", .type = CONFIG_TYPE_BOOL, .boolValue = &configDiscordRPC}, @@ -212,6 +212,8 @@ static const struct ConfigOption options[] = { {.name = "coop_player_palette", .type = CONFIG_TYPE_UINT , .uintValue = &configPlayerPalette}, {.name = "coop_stay_in_level_after_star", .type = CONFIG_TYPE_UINT , .uintValue = &configStayInLevelAfterStar}, {.name = "share_lives", .type = CONFIG_TYPE_BOOL , .boolValue = &configShareLives}, + {.name = "disable_popups", .type = CONFIG_TYPE_BOOL , .boolValue = &configDisablePopups}, + {.name = "disable_downloaded_models", .type = CONFIG_TYPE_BOOL , .boolValue = &configDisableDownloadedModels}, }; // FunctionConfigOption functions diff --git a/src/pc/configfile.h b/src/pc/configfile.h index b27490e7c..e1f54e6f0 100644 --- a/src/pc/configfile.h +++ b/src/pc/configfile.h @@ -71,7 +71,6 @@ extern bool configHUD; extern bool configSkipIntro; extern bool configShareLives; extern bool configEnableCheats; -extern bool configDisablePopups; extern bool configBubbleDeath; extern unsigned int configAmountofPlayers; #ifdef DISCORDRPC @@ -90,6 +89,8 @@ extern unsigned int configPlayerModel; extern unsigned int configPlayerPalette; extern unsigned int config60Fps; extern unsigned int configDrawDistance; +extern bool configDisablePopups; +extern bool configDisableDownloadedModels; void configfile_load(const char *filename); void configfile_save(const char *filename); diff --git a/src/pc/djui/djui_panel_display.c b/src/pc/djui/djui_panel_display.c index 4feb1867d..aec8befa9 100644 --- a/src/pc/djui/djui_panel_display.c +++ b/src/pc/djui/djui_panel_display.c @@ -7,7 +7,7 @@ static void djui_panel_display_apply(UNUSED struct DjuiBase* caller) { } void djui_panel_display_create(struct DjuiBase* caller) { - f32 bodyHeight = 32 * 7 + 64 * 2 + 16 * 8; + f32 bodyHeight = 32 * 8 + 64 * 2 + 16 * 9; struct DjuiBase* defaultBase = NULL; struct DjuiThreePanel* panel = djui_panel_menu_create(bodyHeight, "\\#ff0800\\D\\#1be700\\I\\#00b3ff\\S\\#ffef00\\P\\#ff0800\\L\\#1be700\\A\\#00b3ff\\Y"); @@ -33,6 +33,10 @@ void djui_panel_display_create(struct DjuiBase* caller) { djui_base_set_size_type(&checkbox5->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); djui_base_set_size(&checkbox5->base, 1.0f, 32); + struct DjuiCheckbox* checkbox6 = djui_checkbox_create(&body->base, "Disable Downloaded Models", &configDisableDownloadedModels); + djui_base_set_size_type(&checkbox6->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); + djui_base_set_size(&checkbox6->base, 1.0f, 32); + char* filterChoices[3] = { "Nearest", "Linear", "Tripoint" }; struct DjuiSelectionbox* selectionbox1 = djui_selectionbox_create(&body->base, "Filtering", filterChoices, 3, &configFiltering); djui_base_set_size_type(&selectionbox1->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);