From 802affd8397079ffe406d4f945c545450aa822e9 Mon Sep 17 00:00:00 2001 From: Agent X <44549182+Agent-11@users.noreply.github.com> Date: Sat, 11 Nov 2023 12:15:32 -0500 Subject: [PATCH] ENHANCE_LEVEL_TEXTURES and make all DynOS textures overridable in Lua --- Makefile | 8 ++ autogen/convert_functions.py | 47 ++++++++++++ autogen/lua_definitions/manual.lua | 40 +++++++--- autogen/lua_definitions/structs.lua | 1 + data/dynos.c.h | 2 + data/dynos.cpp.h | 2 + data/dynos_c.cpp | 8 ++ data/dynos_mgr_builtin_externs.h | 2 + data/dynos_mgr_builtin_tex.cpp | 5 ++ data/dynos_mgr_tex.cpp | 50 +++++++++++++ docs/lua/functions.md | 47 ++++++++++++ docs/lua/structs.md | 1 + include/types.h | 1 + levels/castle_courtyard/0_custom.rgba16.png | Bin 0 -> 646 bytes levels/castle_courtyard/areas/1/1/model.inc.c | 43 +++++++++++ levels/castle_courtyard/texture.inc.c | 5 +- levels/castle_grounds/6_custom.rgba16.png | Bin 0 -> 646 bytes levels/castle_grounds/areas/1/2/model.inc.c | 9 +++ levels/castle_grounds/texture.inc.c | 4 + src/game/characters.c | 10 +-- src/pc/djui/djui_hud_utils.c | 28 +++---- src/pc/lua/smlua_cobject_autogen.c | 11 +-- src/pc/lua/smlua_functions.c | 70 ++++++++++++++++++ src/pc/lua/smlua_utils.c | 12 +++ src/pc/lua/smlua_utils.h | 1 + 25 files changed, 372 insertions(+), 35 deletions(-) create mode 100644 levels/castle_courtyard/0_custom.rgba16.png create mode 100644 levels/castle_grounds/6_custom.rgba16.png diff --git a/Makefile b/Makefile index 907b37e2..ef11a3fb 100644 --- a/Makefile +++ b/Makefile @@ -36,6 +36,8 @@ TARGET_BITS ?= 0 # Disable texture fixes by default (helps with them purists) TEXTURE_FIX ?= 0 +# Enable level texture enhancements by default (Castle Grounds and Castle Courtyard recolorable texture hills) +ENHANCE_LEVEL_TEXTURES ?= 1 # Enable Discord Game SDK (used for Discord invites) DISCORD_SDK ?= 1 # Enable CoopNet SDK (used for CoopNet server hosting) @@ -1070,6 +1072,12 @@ ifeq ($(TEXTURE_FIX),1) CFLAGS += -DTEXTURE_FIX endif +# Check for enhance level textures option +ifeq ($(ENHANCE_LEVEL_TEXTURES),1) + CC_CHECK_CFLAGS += -DENHANCE_LEVEL_TEXTURES + CFLAGS += -DENHANCE_LEVEL_TEXTURES +endif + # Check for no bzero/bcopy workaround option ifeq ($(NO_BZERO_BCOPY),1) CC_CHECK_CFLAGS += -DNO_BZERO_BCOPY diff --git a/autogen/convert_functions.py b/autogen/convert_functions.py index 923418f6..8632a891 100644 --- a/autogen/convert_functions.py +++ b/autogen/convert_functions.py @@ -301,6 +301,8 @@ manual_index_documentation = """ - [djui_hud_render_texture_tile](#djui_hud_render_texture_tile) - [djui_hud_render_texture_interpolated](#djui_hud_render_texture_interpolated) - [djui_hud_render_texture_tile_interpolated](#djui_hud_render_texture_tile_interpolated) + - [texture_override_set](#texture_override_set) + - [texture_override_reset](#texture_override_reset) - [smlua_anim_util_register_animation](#smlua_anim_util_register_animation) - [level_script_parse](#level_script_parse) - [set_exclamation_box_contents](#set_exclamation_box_contents) @@ -540,6 +542,51 @@ Renders an interpolated tile of a texture to the screen.
+## [texture_override_reset](#texture_override_reset) + +Resets an overridden texture. + +### Lua Example +`texture_override_reset("outside_09004000")` + +### Parameters +| Field | Type | +| ----- | ---- | +| textureName | `string` | + +### Returns +- None + +### C Prototype +`void dynos_texture_override_reset(const char* textureName);` + +[:arrow_up_small:](#) + +
+ +## [texture_override_set](#texture_override_set) + +Overrides a texture with a custom `TextureInfo`. + +### Lua Example +`texture_override_set("outside_09004000", overrideTexInfo)` + +### Parameters +| Field | Type | +| ----- | ---- | +| textureName | `string` | +| overrideTexInfo | [TextureInfo](structs.md#TextureInfo) | + +### Returns +- None + +### C Prototype +`void dynos_texture_override_set(const char* textureName, struct TextureInfo* overrideTexInfo);` + +[:arrow_up_small:](#) + +
+ ## [smlua_anim_util_register_animation](#smlua_anim_util_register_animation) Register a new Lua animation. diff --git a/autogen/lua_definitions/manual.lua b/autogen/lua_definitions/manual.lua index 3f77c6da..13681b95 100644 --- a/autogen/lua_definitions/manual.lua +++ b/autogen/lua_definitions/manual.lua @@ -164,33 +164,35 @@ function network_init_object(object, standardSync, fieldTable) -- ... end ---- @param object Object ---- @param reliable boolean +--- @param object Object Object to sync +--- @param reliable boolean Whether or not the game should try to resend the packet in case its lost, good for important packets --- @return nil --- Sends a sync packet to sync up the object with everyone else function network_send_object(object, reliable) -- ... end ---- @param reliable boolean ---- @param dataTable table +--- @param reliable boolean Whether or not the game should try to resend the packet in case its lost, good for important packets +--- @param dataTable table Table of values to be included in the packet --- @return nil ---- Note: `dataTable` can only contain strings, integers, numbers, booleans, and nil +--- `dataTable` can only contain strings, integers, numbers, booleans, and nil function network_send(reliable, dataTable) -- ... end ---- @param toLocalIndex integer ---- @param reliable boolean ---- @param dataTable table +--- @param toLocalIndex integer The local index to send the packet to +--- @param reliable boolean Whether or not the game should try to resend the packet in case its lost, good for important packets +--- @param dataTable table Table of values to be included in the packet --- @return nil ---- Note: `dataTable` can only contain strings, integers, numbers, booleans, and nil +--- `dataTable` can only contain strings, integers, numbers, booleans, and nil function network_send_to(toLocalIndex, reliable, dataTable) -- ... end --- @param textureName string --- @return TextureInfo +--- Gets the `TextureInfo` of a texture by name +--- - Note: This also works with vanilla textures function get_texture_info(textureName) -- ... end @@ -201,6 +203,7 @@ end --- @param scaleW number --- @param scaleH number --- @return nil +--- Renders a texture to the screen function djui_hud_render_texture(texInfo, x, y, scaleW, scaleH) -- ... end @@ -215,6 +218,7 @@ end --- @param tileW number --- @param tileH number --- @return nil +--- Renders a tile of a texture to the screen function djui_hud_render_texture_tile(texInfo, x, y, scaleW, scaleH, tileX, tileY, tileW, tileH) -- ... end @@ -229,6 +233,7 @@ end --- @param scaleW number --- @param scaleH number --- @return nil +--- Renders an interpolated texture to the screen function djui_hud_render_texture_interpolated(texInfo, prevX, prevY, prevScaleW, prevScaleH, x, y, scaleW, scaleH) -- ... end @@ -247,10 +252,26 @@ end --- @param tileW number --- @param tileH number --- @return nil +--- Renders an interpolated tile of a texture to the screen function djui_hud_render_texture_tile_interpolated(texInfo, prevX, prevY, prevScaleW, prevScaleH, x, y, scaleW, scaleH, tileX, tileY, tileW, tileH) -- ... end +--- @param textureName string +--- @param overrideTexInfo TextureInfo +--- @return nil +--- Overrides a texture with a custom `TextureInfo` +function texture_override_set(textureName, overrideTexInfo) + -- ... +end + +--- @param textureName string +--- @return nil +--- Resets an overridden texture +function texture_override_reset(textureName) + -- ... +end + --- @param name string --- @param flags integer --- @param animYTransDivisor integer @@ -260,6 +281,7 @@ end --- @param values table --- @param index table --- @return nil +--- Registers an animation that can be used in objects if `smlua_anim_util_set_animation` is called function smlua_anim_util_register_animation(name, flags, animYTransDivisor, startFrame, loopStart, loopEnd, values, index) -- ... end diff --git a/autogen/lua_definitions/structs.lua b/autogen/lua_definitions/structs.lua index 3183e263..e422de56 100644 --- a/autogen/lua_definitions/structs.lua +++ b/autogen/lua_definitions/structs.lua @@ -2085,6 +2085,7 @@ --- @class TextureInfo --- @field public bitSize integer --- @field public height integer +--- @field public name string --- @field public texture Pointer_integer --- @field public width integer diff --git a/data/dynos.c.h b/data/dynos.c.h index ad8df9f7..3eb16b44 100644 --- a/data/dynos.c.h +++ b/data/dynos.c.h @@ -47,6 +47,8 @@ Collision* dynos_collision_get(const char* collisionName); // -- textures -- // void dynos_add_texture(const char *filePath, const char* textureName); bool dynos_texture_get(const char* textureName, struct TextureInfo* outTextureInfo); +void dynos_texture_override_set(const char* textureName, struct TextureInfo* overrideTextureInfo); +void dynos_texture_override_reset(const char* textureName); // -- movtexqcs -- // void dynos_movtexqc_register(const char* name, s16 level, s16 area, s16 type); diff --git a/data/dynos.cpp.h b/data/dynos.cpp.h index 876372f3..5cceedc7 100644 --- a/data/dynos.cpp.h +++ b/data/dynos.cpp.h @@ -910,6 +910,8 @@ void DynOS_Tex_Activate(DataNode* aNode, bool aCustomTexture); void DynOS_Tex_Deactivate(DataNode* aNode); void DynOS_Tex_AddCustom(const SysPath &aFilename, const char *aTexName); bool DynOS_Tex_Get(const char* aTexName, struct TextureInfo* aOutTexInfo); +void DynOS_Tex_Override_Set(const char* textureName, struct TextureInfo* aOverrideTexInfo); +void DynOS_Tex_Override_Reset(const char* textureName); void DynOS_Tex_ModShutdown(); // diff --git a/data/dynos_c.cpp b/data/dynos_c.cpp index 12261ff3..4d82906e 100644 --- a/data/dynos_c.cpp +++ b/data/dynos_c.cpp @@ -148,6 +148,14 @@ bool dynos_texture_get(const char* textureName, struct TextureInfo* outTextureIn return DynOS_Tex_Get(textureName, outTextureInfo); } +void dynos_texture_override_set(const char* textureName, struct TextureInfo* overrideTextureInfo) { + DynOS_Tex_Override_Set(textureName, overrideTextureInfo); +} + +void dynos_texture_override_reset(const char* textureName) { + DynOS_Tex_Override_Reset(textureName); +} + // -- movtexqcs -- // void dynos_movtexqc_register(const char* name, s16 level, s16 area, s16 type) { diff --git a/data/dynos_mgr_builtin_externs.h b/data/dynos_mgr_builtin_externs.h index ebeffe64..aacc419c 100644 --- a/data/dynos_mgr_builtin_externs.h +++ b/data/dynos_mgr_builtin_externs.h @@ -1177,12 +1177,14 @@ extern ALIGNED8 const Texture bowser_2_seg7_texture_07000000[]; extern ALIGNED8 const Texture bowser_3_seg7_texture_07000000[]; extern ALIGNED8 const Texture bowser_3_seg7_texture_07000800[]; extern ALIGNED8 const Texture bowser_3_seg7_texture_07001000[]; +extern ALIGNED8 const Texture castle_courtyard_seg7_texture_07000000[]; extern ALIGNED8 const Texture castle_grounds_seg7_texture_0700C9E8[]; extern ALIGNED8 const Texture castle_grounds_seg7_texture_0700D9E8[]; extern ALIGNED8 const Texture castle_grounds_seg7_us_texture_0700EAE8[]; extern ALIGNED8 const Texture castle_grounds_seg7_texture_07000000[]; extern ALIGNED8 const Texture castle_grounds_seg7_texture_07001000[]; extern ALIGNED8 const Texture castle_grounds_seg7_texture_07002000[]; +extern ALIGNED8 const Texture castle_grounds_seg7_texture_07003000[]; extern ALIGNED8 const Texture texture_castle_light[]; extern ALIGNED8 const Texture inside_castle_seg7_texture_07000800[]; extern ALIGNED8 const Texture inside_castle_seg7_texture_07001000[]; diff --git a/data/dynos_mgr_builtin_tex.cpp b/data/dynos_mgr_builtin_tex.cpp index 783e0377..a184e454 100644 --- a/data/dynos_mgr_builtin_tex.cpp +++ b/data/dynos_mgr_builtin_tex.cpp @@ -2321,6 +2321,11 @@ static const struct BuiltinTexInfo sDynosBuiltinTexs[] = { //define_builtin_tex(texture_menu_kurs_upper, "levels/menu/main_menu_seg7_eu.0DDA0.rgba16.png"), //define_builtin_tex(texture_menu_course_lower, "levels/menu/main_menu_seg7_eu.0EDA0.rgba16.png"), +#ifdef ENHANCE_LEVEL_TEXTURES + define_builtin_tex(castle_courtyard_seg7_texture_07000000, "levels/castle_courtyard/0_custom.rgba16.png", 32, 64, 16), + define_builtin_tex(castle_grounds_seg7_texture_07003000, "levels/castle_grounds/6_custom.rgba16.png", 32, 64, 16), +#endif + #ifdef VERSION_EU define_builtin_tex(texture_menu_font_char_D, "levels/menu/main_menu_seg7_eu.0AF80.ia8.png", 8, 8, 16), define_builtin_tex(texture_menu_font_char_comma, "levels/menu/main_menu_seg7_eu.0B640.ia8.png", 8, 8, 16), diff --git a/data/dynos_mgr_tex.cpp b/data/dynos_mgr_tex.cpp index f7a197a6..6568b34f 100644 --- a/data/dynos_mgr_tex.cpp +++ b/data/dynos_mgr_tex.cpp @@ -15,6 +15,11 @@ static std::map& DynosOverrideTextures( return sDynosOverrideTextures; } +static std::map& DynosOverrideLuaTextures() { + static std::map sDynosOverrideLuaTextures; + return sDynosOverrideLuaTextures; +} + // static set static std::set *>& DynosValidTextures() { static std::set *> sDynosValidTextures; @@ -298,6 +303,11 @@ void DynOS_Tex_Update() { // static DataNode *DynOS_Tex_RetrieveNode(void *aPtr) { + auto _LuaOverride = DynosOverrideLuaTextures()[(const Texture*)aPtr]; + if (_LuaOverride && _LuaOverride->node) { + return _LuaOverride->node; + } + auto _Override = DynosOverrideTextures()[(const Texture*)aPtr]; if (_Override && _Override->node) { return _Override->node; @@ -343,6 +353,16 @@ static Array*>>& DynosCustomTexs() { return sDynosCustomTexs; } +static DataNode *DynOS_Lua_Tex_RetrieveNode(const char* aName) { + auto& _DynosCustomTexs = DynosCustomTexs(); + for (s32 i = 0; i < _DynosCustomTexs.Count(); ++i) { + if (!strcmp(_DynosCustomTexs[i].first, aName)) { + return _DynosCustomTexs[i].second; + } + } + return NULL; +} + void DynOS_Tex_Activate(DataNode* aNode, bool aCustomTexture) { if (!aNode) { return; } @@ -457,6 +477,7 @@ bool DynOS_Tex_Get(const char* aTexName, struct TextureInfo* aOutTexInfo) { aOutTexInfo->width = _Data->mRawWidth; aOutTexInfo->height = _Data->mRawHeight; aOutTexInfo->texture = _Data->mRawData.begin(); + aOutTexInfo->name = aTexName; return true; } } @@ -468,10 +489,39 @@ bool DynOS_Tex_Get(const char* aTexName, struct TextureInfo* aOutTexInfo) { aOutTexInfo->width = info->width; aOutTexInfo->height = info->height; aOutTexInfo->texture = (u8*)info->pointer; + aOutTexInfo->name = aTexName; return true; } +void DynOS_Tex_Override_Set(const char* aTexName, struct TextureInfo* aOverrideTexInfo) { + // Override texture + const Texture* _BuiltinTex = DynOS_Builtin_Tex_GetFromName(aTexName); + DataNode* _Node = DynOS_Lua_Tex_RetrieveNode(aOverrideTexInfo->name); + if (!_BuiltinTex || !_Node) { return; } + + auto& _DynosOverrideLuaTextures = DynosOverrideLuaTextures(); + struct OverrideTexture* _Override = new OverrideTexture(); + _Override->customTexture = false; + _Override->node = _Node; + _DynosOverrideLuaTextures[_BuiltinTex] = _Override; +} + +void DynOS_Tex_Override_Reset(const char* aTexName) { + // Override texture + const Texture* _BuiltinTex = DynOS_Builtin_Tex_GetFromName(aTexName); + if (!_BuiltinTex) { return; } + + auto& _DynosOverrideLuaTextures = DynosOverrideLuaTextures(); + auto _Override = _DynosOverrideLuaTextures[_BuiltinTex]; + if (_Override) { + _DynosOverrideLuaTextures.erase(_BuiltinTex); + } +} + void DynOS_Tex_ModShutdown() { + auto& _DynosOverrideLuaTextures = DynosOverrideLuaTextures(); + _DynosOverrideLuaTextures.clear(); + auto& _DynosCustomTexs = DynosCustomTexs(); while (_DynosCustomTexs.Count() > 0) { auto& pair = _DynosCustomTexs[0]; diff --git a/docs/lua/functions.md b/docs/lua/functions.md index 6b692166..798b3ba2 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -19,6 +19,8 @@ - [djui_hud_render_texture_tile](#djui_hud_render_texture_tile) - [djui_hud_render_texture_interpolated](#djui_hud_render_texture_interpolated) - [djui_hud_render_texture_tile_interpolated](#djui_hud_render_texture_tile_interpolated) + - [texture_override_set](#texture_override_set) + - [texture_override_reset](#texture_override_reset) - [smlua_anim_util_register_animation](#smlua_anim_util_register_animation) - [level_script_parse](#level_script_parse) - [set_exclamation_box_contents](#set_exclamation_box_contents) @@ -2019,6 +2021,51 @@ Renders an interpolated tile of a texture to the screen.
+## [texture_override_reset](#texture_override_reset) + +Resets an overridden texture. + +### Lua Example +`texture_override_reset("outside_09004000")` + +### Parameters +| Field | Type | +| ----- | ---- | +| textureName | `string` | + +### Returns +- None + +### C Prototype +`void dynos_texture_override_reset(const char* textureName);` + +[:arrow_up_small:](#) + +
+ +## [texture_override_set](#texture_override_set) + +Overrides a texture with a custom `TextureInfo`. + +### Lua Example +`texture_override_set("outside_09004000", overrideTexInfo)` + +### Parameters +| Field | Type | +| ----- | ---- | +| textureName | `string` | +| overrideTexInfo | [TextureInfo](structs.md#TextureInfo) | + +### Returns +- None + +### C Prototype +`void dynos_texture_override_set(const char* textureName, struct TextureInfo* overrideTexInfo);` + +[:arrow_up_small:](#) + +
+ ## [smlua_anim_util_register_animation](#smlua_anim_util_register_animation) Register a new Lua animation. diff --git a/docs/lua/structs.md b/docs/lua/structs.md index 20ad7cef..c001c250 100644 --- a/docs/lua/structs.md +++ b/docs/lua/structs.md @@ -2652,6 +2652,7 @@ | ----- | ---- | ------ | | bitSize | `integer` | read-only | | height | `integer` | read-only | +| name | `string` | read-only | | texture | `Pointer` <`integer`> | read-only | | width | `integer` | read-only | diff --git a/include/types.h b/include/types.h index 876b6715..deeb9f3c 100644 --- a/include/types.h +++ b/include/types.h @@ -433,6 +433,7 @@ struct TextureInfo u8 bitSize; u32 width; u32 height; + const char* name; }; #define PLAY_MODE_NORMAL 0 diff --git a/levels/castle_courtyard/0_custom.rgba16.png b/levels/castle_courtyard/0_custom.rgba16.png new file mode 100644 index 0000000000000000000000000000000000000000..c393c2e7696be5aac25d905a941274bfc6a9e31c GIT binary patch literal 646 zcmV;10(t$3P)Px#1ZP1_K>z@;j|==^1poj5IZ#YgMIu@iC1@2UZxtwa6)AodD}@y-ixn=D6)&0< zF`*SPs1-A>6*aaMHoX==Wr7CX}xBw-ai+7?!TbX@=d010qNS#tmY4#NNd4#NS* zZ>VGd00GuXL_t(YOO2FCcEd0XLtSTRGdsEeVGDqyNXc3R3%@?&2c$&0%kr}xj;HhQ z-{pF{-yhHCtCs=r1v~=S^rV(I00mTF+k$w04@3#RO@9u+AAsQ$#qWWvk*a`23^zd_ zn`lK+4){$?A_~9~b71wGQoyc>(xep_`~t85?cOJl0lS|=OsIgrPW8Y(z#-DLtWDggg<<~eR8UZCGB!eFHQJ4=CdZfammeuz(;Eh@EVHAqbS6 z48H>7I!N+G5WuiBh;ol6Pq2Rv3>bU^d}m`__zr4+IG}S@AQeDF`0Esa7Quz$yU*t% zPig=T8W9!H=MTV(SQlf0{Ib^Wn3!OG0v%z1Z?%9if&k*V)tZLQ!A(dB1hmu>AQFb9 zb`!EMO8{32^QK=Aew+IES)c_NpeF&V5kL}p3Q!FLNHhitAlACySt$U&hB@HFOu#+K gb~1q4rSy9J12K1A7j-`WrT_o{07*qoM6N<$f@xg)D*ylh literal 0 HcmV?d00001 diff --git a/levels/castle_courtyard/areas/1/1/model.inc.c b/levels/castle_courtyard/areas/1/1/model.inc.c index 79c2d8ef..92740eba 100644 --- a/levels/castle_courtyard/areas/1/1/model.inc.c +++ b/levels/castle_courtyard/areas/1/1/model.inc.c @@ -692,6 +692,22 @@ static const Vtx castle_courtyard_seg7_vertex_07002180[] = { // 0x070021C0 - 0x070022A0 static const Vtx castle_courtyard_seg7_vertex_070021C0[] = { +#ifdef ENHANCE_LEVEL_TEXTURES + {{{ -4095, 728, -3378}, 0, { 192, 2084}, {0xff, 0xff, 0xff, 0xff}}}, + {{{ -4486, 1000, -2810}, 0, { 364, 1576}, {0xff, 0xff, 0xff, 0xff}}}, + {{{ -3583, 512, -3071}, 0, { 36, 1792}, {0xff, 0xff, 0xff, 0xff}}}, + {{{ -3583, 614, -2047}, 0, { 96, 868}, {0xff, 0xff, 0xff, 0xff}}}, + {{{ -4914, 898, -2047}, 0, { 482, 1040}, {0xff, 0xff, 0xff, 0xff}}}, + {{{ -4709, 1382, -1228}, 0, { 556, 120}, {0xff, 0xff, 0xff, 0xff}}}, + {{{ -3583, 614, -1228}, 0, { 130, 160}, {0xff, 0xff, 0xff, 0xff}}}, + {{{ -3583, 512, -511}, 0, { 138, -424}, {0xff, 0xff, 0xff, 0xff}}}, + {{{ -4699, 1280, -501}, 0, { 564, -480}, {0xff, 0xff, 0xff, 0xff}}}, + {{{ -4455, 1638, 434}, 0, { 610, -1464}, {0xff, 0xff, 0xff, 0xff}}}, + {{{ -3583, 614, 307}, 0, { 192, -1172}, {0xff, 0xff, 0xff, 0xff}}}, + {{{ -4147, 1690, 755}, 0, { 556, -1820}, {0xff, 0xff, 0xff, 0xff}}}, + {{{ -3839, 1638, 1075}, 0, { 482, -2144}, {0xff, 0xff, 0xff, 0xff}}}, + {{{ -3071, 614, 717}, 0, { 80, -1628}, {0xff, 0xff, 0xff, 0xff}}}, +#else {{{ -4095, 728, -3378}, 0, { 192, 2084}, {0x30, 0xdb, 0x02, 0xff}}}, {{{ -4486, 1000, -2810}, 0, { 364, 1576}, {0x30, 0xdb, 0x02, 0xff}}}, {{{ -3583, 512, -3071}, 0, { 36, 1792}, {0x30, 0xdb, 0x02, 0xff}}}, @@ -706,10 +722,27 @@ static const Vtx castle_courtyard_seg7_vertex_070021C0[] = { {{{ -4147, 1690, 755}, 0, { 556, -1820}, {0x30, 0xdb, 0x02, 0xff}}}, {{{ -3839, 1638, 1075}, 0, { 482, -2144}, {0x30, 0xdb, 0x02, 0xff}}}, {{{ -3071, 614, 717}, 0, { 80, -1628}, {0x30, 0xdb, 0x02, 0xff}}}, +#endif }; // 0x070022A0 - 0x07002380 static const Vtx castle_courtyard_seg7_vertex_070022A0[] = { +#ifdef ENHANCE_LEVEL_TEXTURES + {{{ 4545, 666, -1135}, 0, { 614, 2096}, {0xff, 0xff, 0xff, 0xff}}}, + {{{ 3584, 614, -1228}, 0, { 62, 1720}, {0xff, 0xff, 0xff, 0xff}}}, + {{{ 3584, 512, -511}, 0, { 124, 1020}, {0xff, 0xff, 0xff, 0xff}}}, + {{{ -3839, 1638, 1075}, 0, { 482, -2144}, {0xff, 0xff, 0xff, 0xff}}}, + {{{ -3071, 1126, 1434}, 0, { 208, -2428}, {0xff, 0xff, 0xff, 0xff}}}, + {{{ -3071, 614, 717}, 0, { 80, -1628}, {0xff, 0xff, 0xff, 0xff}}}, + {{{ -2559, 512, 717}, 0, { -64, -1696}, {0xff, 0xff, 0xff, 0xff}}}, + {{{ -2559, 1024, 1434}, 0, { 62, -2496}, {0xff, 0xff, 0xff, 0xff}}}, + {{{ 3584, 614, 307}, 0, { 284, 240}, {0xff, 0xff, 0xff, 0xff}}}, + {{{ 4198, 1126, 307}, 0, { 820, 584}, {0xff, 0xff, 0xff, 0xff}}}, + {{{ 3651, 1000, 987}, 0, { 574, -348}, {0xff, 0xff, 0xff, 0xff}}}, + {{{ 3072, 614, 717}, 0, { 68, -404}, {0xff, 0xff, 0xff, 0xff}}}, + {{{ 4318, 1024, -460}, 0, { 732, 1376}, {0xff, 0xff, 0xff, 0xff}}}, + {{{ 3584, 614, -2047}, 0, { -54, 2508}, {0xff, 0xff, 0xff, 0xff}}}, +#else {{{ 4545, 666, -1135}, 0, { 614, 2096}, {0x30, 0xdb, 0x02, 0xff}}}, {{{ 3584, 614, -1228}, 0, { 62, 1720}, {0x30, 0xdb, 0x02, 0xff}}}, {{{ 3584, 512, -511}, 0, { 124, 1020}, {0x30, 0xdb, 0x02, 0xff}}}, @@ -724,6 +757,7 @@ static const Vtx castle_courtyard_seg7_vertex_070022A0[] = { {{{ 3072, 614, 717}, 0, { 68, -404}, {0x30, 0xdb, 0x02, 0xff}}}, {{{ 4318, 1024, -460}, 0, { 732, 1376}, {0x30, 0xdb, 0x02, 0xff}}}, {{{ 3584, 614, -2047}, 0, { -54, 2508}, {0x30, 0xdb, 0x02, 0xff}}}, +#endif }; // 0x07002380 - 0x07002470 @@ -1382,7 +1416,11 @@ static const Gfx castle_courtyard_seg7_dl_070041A0[] = { // 0x070041D8 - 0x07004370 static const Gfx castle_courtyard_seg7_dl_070041D8[] = { +#ifdef ENHANCE_LEVEL_TEXTURES + gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, castle_courtyard_seg7_texture_07000000), +#else gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, outside_09004800), +#endif gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 32 * 64 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES)), gsSPVertex(castle_courtyard_seg7_vertex_070021C0, 14, 0), @@ -1398,6 +1436,11 @@ static const Gfx castle_courtyard_seg7_dl_070041D8[] = { gsSP2Triangles( 8, 9, 2, 0x0, 8, 10, 9, 0x0), gsSP2Triangles( 8, 11, 10, 0x0, 9, 12, 2, 0x0), gsSP2Triangles(12, 0, 2, 0x0, 13, 1, 0, 0x0), +#ifdef ENHANCE_LEVEL_TEXTURES + gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, outside_09004800), + gsDPLoadSync(), + gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 32 * 64 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES)), +#endif gsSPVertex(castle_courtyard_seg7_vertex_07002380, 15, 0), gsSP2Triangles( 0, 1, 2, 0x0, 1, 3, 2, 0x0), gsSP2Triangles( 4, 5, 6, 0x0, 7, 8, 6, 0x0), diff --git a/levels/castle_courtyard/texture.inc.c b/levels/castle_courtyard/texture.inc.c index 9bebe774..8b9edf50 100644 --- a/levels/castle_courtyard/texture.inc.c +++ b/levels/castle_courtyard/texture.inc.c @@ -1,2 +1,3 @@ -// Blank File - +ALIGNED8 const Texture castle_courtyard_seg7_texture_07000000[] = { +#include "levels/castle_courtyard/0_custom.rgba16.inc.c" +}; diff --git a/levels/castle_grounds/6_custom.rgba16.png b/levels/castle_grounds/6_custom.rgba16.png new file mode 100644 index 0000000000000000000000000000000000000000..c393c2e7696be5aac25d905a941274bfc6a9e31c GIT binary patch literal 646 zcmV;10(t$3P)Px#1ZP1_K>z@;j|==^1poj5IZ#YgMIu@iC1@2UZxtwa6)AodD}@y-ixn=D6)&0< zF`*SPs1-A>6*aaMHoX==Wr7CX}xBw-ai+7?!TbX@=d010qNS#tmY4#NNd4#NS* zZ>VGd00GuXL_t(YOO2FCcEd0XLtSTRGdsEeVGDqyNXc3R3%@?&2c$&0%kr}xj;HhQ z-{pF{-yhHCtCs=r1v~=S^rV(I00mTF+k$w04@3#RO@9u+AAsQ$#qWWvk*a`23^zd_ zn`lK+4){$?A_~9~b71wGQoyc>(xep_`~t85?cOJl0lS|=OsIgrPW8Y(z#-DLtWDggg<<~eR8UZCGB!eFHQJ4=CdZfammeuz(;Eh@EVHAqbS6 z48H>7I!N+G5WuiBh;ol6Pq2Rv3>bU^d}m`__zr4+IG}S@AQeDF`0Esa7Quz$yU*t% zPig=T8W9!H=MTV(SQlf0{Ib^Wn3!OG0v%z1Z?%9if&k*V)tZLQ!A(dB1hmu>AQFb9 zb`!EMO8{32^QK=Aew+IES)c_NpeF&V5kL}p3Q!FLNHhitAlACySt$U&hB@HFOu#+K gb~1q4rSy9J12K1A7j-`WrT_o{07*qoM6N<$f@xg)D*ylh literal 0 HcmV?d00001 diff --git a/levels/castle_grounds/areas/1/2/model.inc.c b/levels/castle_grounds/areas/1/2/model.inc.c index d778edd3..9ec78c27 100644 --- a/levels/castle_grounds/areas/1/2/model.inc.c +++ b/levels/castle_grounds/areas/1/2/model.inc.c @@ -42,8 +42,13 @@ static const Lights1 castle_grounds_seg7_lights_07006F68 = gdSPDefLights1( // 0x07006F80 - 0x07006F98 static const Lights1 castle_grounds_seg7_lights_07006F80 = gdSPDefLights1( +#ifdef ENHANCE_LEVEL_TEXTURES + 0x55, 0x55, 0x55, + 0xff, 0xff, 0x0ff, 0x28, 0x28, 0x28 +#else 0x13, 0x57, 0x00, 0x30, 0xdb, 0x02, 0x28, 0x28, 0x28 +#endif ); // 0x07006F98 - 0x07006FD8 @@ -854,7 +859,11 @@ static const Gfx castle_grounds_seg7_dl_07009010[] = { // 0x07009330 - 0x07009568 static const Gfx castle_grounds_seg7_dl_07009330[] = { +#ifdef ENHANCE_LEVEL_TEXTURES + gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, castle_grounds_seg7_texture_07003000), +#else gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, outside_09004800), +#endif gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 32 * 64 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES)), gsSPLight(&castle_grounds_seg7_lights_07006F80.l, 1), diff --git a/levels/castle_grounds/texture.inc.c b/levels/castle_grounds/texture.inc.c index b767a091..b293c752 100644 --- a/levels/castle_grounds/texture.inc.c +++ b/levels/castle_grounds/texture.inc.c @@ -12,3 +12,7 @@ ALIGNED8 const Texture castle_grounds_seg7_texture_07001000[] = { ALIGNED8 const Texture castle_grounds_seg7_texture_07002000[] = { #include "levels/castle_grounds/2.rgba16.inc.c" }; + +ALIGNED8 const Texture castle_grounds_seg7_texture_07003000[] = { +#include "levels/castle_grounds/6_custom.rgba16.inc.c" +}; diff --git a/src/game/characters.c b/src/game/characters.c index 75f0762d..6849e41b 100644 --- a/src/game/characters.c +++ b/src/game/characters.c @@ -34,7 +34,7 @@ struct Character gCharacters[CT_MAX] = { .type = CT_MARIO, .name = "Mario", .hudHead = '(', - .hudHeadTexture = { .texture = (u8*)texture_hud_char_mario_head, .bitSize = 8, .width = 16, .height = 16 }, + .hudHeadTexture = { .texture = (u8*)texture_hud_char_mario_head, .bitSize = 8, .width = 16, .height = 16, .name = "texture_hud_char_mario_head" }, .cameraHudHead = GLYPH_CAM_MARIO_HEAD, .modelId = MODEL_MARIO, .capModelId = MODEL_MARIOS_CAP, @@ -311,7 +311,7 @@ struct Character gCharacters[CT_MAX] = { .type = CT_LUIGI, .name = "Luigi", .hudHead = ')', - .hudHeadTexture = { .texture = (u8*)texture_hud_char_luigi_head, .bitSize = 8, .width = 16, .height = 16 }, + .hudHeadTexture = { .texture = (u8*)texture_hud_char_luigi_head, .bitSize = 8, .width = 16, .height = 16, .name = "texture_hud_char_luigi_head" }, .cameraHudHead = GLYPH_CAM_LUIGI_HEAD, .modelId = MODEL_LUIGI, .capModelId = MODEL_LUIGIS_CAP, @@ -588,7 +588,7 @@ struct Character gCharacters[CT_MAX] = { .type = CT_TOAD, .name = "Toad", .hudHead = '|', - .hudHeadTexture = { .texture = (u8*)texture_hud_char_toad_head, .bitSize = 8, .width = 16, .height = 16 }, + .hudHeadTexture = { .texture = (u8*)texture_hud_char_toad_head, .bitSize = 8, .width = 16, .height = 16, .name = "texture_hud_char_toad_head" }, .cameraHudHead = GLYPH_CAM_TOAD_HEAD, .modelId = MODEL_TOAD_PLAYER, .capModelId = MODEL_TOADS_CAP, @@ -865,7 +865,7 @@ struct Character gCharacters[CT_MAX] = { .type = CT_WALUIGI, .name = "Waluigi", .hudHead = ']', - .hudHeadTexture = { .texture = (u8*)texture_hud_char_waluigi_head, .bitSize = 8, .width = 16, .height = 16 }, + .hudHeadTexture = { .texture = (u8*)texture_hud_char_waluigi_head, .bitSize = 8, .width = 16, .height = 16, .name = "texture_hud_char_waluigi_head" }, .cameraHudHead = GLYPH_CAM_WALUIGI_HEAD, .modelId = MODEL_WALUIGI, .capModelId = MODEL_WALUIGIS_CAP, @@ -1145,7 +1145,7 @@ struct Character gCharacters[CT_MAX] = { .type = CT_WARIO, .name = "Wario", .hudHead = '[', - .hudHeadTexture = { .texture = (u8*)texture_hud_char_wario_head, .bitSize = 8, .width = 16, .height = 16 }, + .hudHeadTexture = { .texture = (u8*)texture_hud_char_wario_head, .bitSize = 8, .width = 16, .height = 16, .name = "texture_hud_char_wario_head" }, .cameraHudHead = GLYPH_CAM_WARIO_HEAD, .modelId = MODEL_WARIO, .capModelId = MODEL_WARIOS_CAP, diff --git a/src/pc/djui/djui_hud_utils.c b/src/pc/djui/djui_hud_utils.c index ba82ccaa..d88e2659 100644 --- a/src/pc/djui/djui_hud_utils.c +++ b/src/pc/djui/djui_hud_utils.c @@ -49,20 +49,20 @@ extern ALIGNED8 const u8 texture_hud_char_apostrophe[]; extern ALIGNED8 const u8 texture_hud_char_double_quote[]; struct GlobalTextures gGlobalTextures = { - .camera = { .texture = (u8*)texture_hud_char_camera, .bitSize = 8, .width = 16, .height = 16 }, - .lakitu = { .texture = (u8*)texture_hud_char_lakitu, .bitSize = 8, .width = 16, .height = 16 }, - .no_camera = { .texture = (u8*)texture_hud_char_no_camera, .bitSize = 8, .width = 16, .height = 16 }, - .arrow_up = { .texture = (u8*)texture_hud_char_arrow_up, .bitSize = 8, .width = 8, .height = 8 }, - .arrow_down = { .texture = (u8*)texture_hud_char_arrow_down, .bitSize = 8, .width = 8, .height = 8 }, - .coin = { .texture = (u8*)texture_hud_char_coin, .bitSize = 8, .width = 16, .height = 16 }, - .star = { .texture = (u8*)texture_hud_char_star, .bitSize = 8, .width = 16, .height = 16 }, - .apostrophe = { .texture = (u8*)texture_hud_char_apostrophe, .bitSize = 8, .width = 16, .height = 16 }, - .double_quote = { .texture = (u8*)texture_hud_char_double_quote, .bitSize = 8, .width = 16, .height = 16 }, - .mario_head = { .texture = (u8*)texture_hud_char_mario_head, .bitSize = 8, .width = 16, .height = 16 }, - .luigi_head = { .texture = (u8*)texture_hud_char_luigi_head, .bitSize = 8, .width = 16, .height = 16 }, - .toad_head = { .texture = (u8*)texture_hud_char_toad_head, .bitSize = 8, .width = 16, .height = 16 }, - .waluigi_head = { .texture = (u8*)texture_hud_char_waluigi_head, .bitSize = 8, .width = 16, .height = 16 }, - .wario_head = { .texture = (u8*)texture_hud_char_wario_head, .bitSize = 8, .width = 16, .height = 16 } + .camera = { .texture = (u8*)texture_hud_char_camera, .bitSize = 8, .width = 16, .height = 16, "texture_hud_char_camera" }, + .lakitu = { .texture = (u8*)texture_hud_char_lakitu, .bitSize = 8, .width = 16, .height = 16, "texture_hud_char_lakitu" }, + .no_camera = { .texture = (u8*)texture_hud_char_no_camera, .bitSize = 8, .width = 16, .height = 16, "texture_hud_char_no_camera" }, + .arrow_up = { .texture = (u8*)texture_hud_char_arrow_up, .bitSize = 8, .width = 8, .height = 8, "texture_hud_char_arrow_up" }, + .arrow_down = { .texture = (u8*)texture_hud_char_arrow_down, .bitSize = 8, .width = 8, .height = 8, "texture_hud_char_arrow_down" }, + .coin = { .texture = (u8*)texture_hud_char_coin, .bitSize = 8, .width = 16, .height = 16, "texture_hud_char_coin" }, + .star = { .texture = (u8*)texture_hud_char_star, .bitSize = 8, .width = 16, .height = 16, "texture_hud_char_star" }, + .apostrophe = { .texture = (u8*)texture_hud_char_apostrophe, .bitSize = 8, .width = 16, .height = 16, "texture_hud_char_apostrophe" }, + .double_quote = { .texture = (u8*)texture_hud_char_double_quote, .bitSize = 8, .width = 16, .height = 16, "texture_hud_char_double_quote" }, + .mario_head = { .texture = (u8*)texture_hud_char_mario_head, .bitSize = 8, .width = 16, .height = 16, "texture_hud_char_mario_head" }, + .luigi_head = { .texture = (u8*)texture_hud_char_luigi_head, .bitSize = 8, .width = 16, .height = 16, "texture_hud_char_luigi_head" }, + .toad_head = { .texture = (u8*)texture_hud_char_toad_head, .bitSize = 8, .width = 16, .height = 16, "texture_hud_char_toad_head" }, + .waluigi_head = { .texture = (u8*)texture_hud_char_waluigi_head, .bitSize = 8, .width = 16, .height = 16, "texture_hud_char_waluigi_head" }, + .wario_head = { .texture = (u8*)texture_hud_char_wario_head, .bitSize = 8, .width = 16, .height = 16, "texture_hud_char_wario_head" } }; static void djui_hud_position_translate(f32* x, f32* y) { diff --git a/src/pc/lua/smlua_cobject_autogen.c b/src/pc/lua/smlua_cobject_autogen.c index 2ceb802b..ec494953 100644 --- a/src/pc/lua/smlua_cobject_autogen.c +++ b/src/pc/lua/smlua_cobject_autogen.c @@ -2286,12 +2286,13 @@ static struct LuaObjectField sSurfaceFields[LUA_SURFACE_FIELD_COUNT] = { { "vertex3", LVT_COBJECT, offsetof(struct Surface, vertex3), true, LOT_VEC3S }, }; -#define LUA_TEXTURE_INFO_FIELD_COUNT 4 +#define LUA_TEXTURE_INFO_FIELD_COUNT 5 static struct LuaObjectField sTextureInfoFields[LUA_TEXTURE_INFO_FIELD_COUNT] = { - { "bitSize", LVT_U8, offsetof(struct TextureInfo, bitSize), true, LOT_NONE }, - { "height", LVT_U32, offsetof(struct TextureInfo, height), true, LOT_NONE }, - { "texture", LVT_U8_P, offsetof(struct TextureInfo, texture), true, LOT_POINTER }, - { "width", LVT_U32, offsetof(struct TextureInfo, width), true, LOT_NONE }, + { "bitSize", LVT_U8, offsetof(struct TextureInfo, bitSize), true, LOT_NONE }, + { "height", LVT_U32, offsetof(struct TextureInfo, height), true, LOT_NONE }, + { "name", LVT_STRING_P, offsetof(struct TextureInfo, name), true, LOT_NONE }, + { "texture", LVT_U8_P, offsetof(struct TextureInfo, texture), true, LOT_POINTER }, + { "width", LVT_U32, offsetof(struct TextureInfo, width), true, LOT_NONE }, }; #define LUA_TRANSITION_INFO_FIELD_COUNT 9 diff --git a/src/pc/lua/smlua_functions.c b/src/pc/lua/smlua_functions.c index d401c974..7ccba388 100644 --- a/src/pc/lua/smlua_functions.c +++ b/src/pc/lua/smlua_functions.c @@ -341,6 +341,10 @@ int smlua_func_get_texture_info(lua_State* L) { lua_pushinteger(L, texInfo.height); lua_settable(L, -3); + lua_pushstring(L, "name"); + lua_pushstring(L, texInfo.name); + lua_settable(L, -3); + return 1; } @@ -372,6 +376,9 @@ int smlua_func_djui_hud_render_texture(lua_State* L) { tmpTexInfo.height = smlua_get_integer_field(top+1, "height"); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1's 'height' field"); return 0; } + tmpTexInfo.name = smlua_get_string_field(top+1, "name"); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1's 'name' field"); return 0; } + lua_settop(L, top); } @@ -417,6 +424,9 @@ int smlua_func_djui_hud_render_texture_tile(lua_State* L) { tmpTexInfo.height = smlua_get_integer_field(top+1, "height"); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1's 'height' field"); return 0; } + tmpTexInfo.name = smlua_get_string_field(top+1, "name"); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1's 'name' field"); return 0; } + lua_settop(L, top); } @@ -470,6 +480,9 @@ int smlua_func_djui_hud_render_texture_interpolated(lua_State* L) { tmpTexInfo.height = smlua_get_integer_field(top+1, "height"); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1's 'height' field"); return 0; } + tmpTexInfo.name = smlua_get_string_field(top+1, "name"); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1's 'name' field"); return 0; } + lua_settop(L, top); } @@ -523,6 +536,9 @@ int smlua_func_djui_hud_render_texture_tile_interpolated(lua_State* L) { tmpTexInfo.height = smlua_get_integer_field(top+1, "height"); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1's 'height' field"); return 0; } + tmpTexInfo.name = smlua_get_string_field(top+1, "name"); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1's 'name' field"); return 0; } + lua_settop(L, top); } @@ -556,6 +572,58 @@ int smlua_func_djui_hud_render_texture_tile_interpolated(lua_State* L) { return 1; } +int smlua_func_texture_override_set(lua_State* L) { + if (!smlua_functions_valid_param_count(L, 2)) { return 0; } + + const char* textureName = smlua_to_string(L, 1); + + struct TextureInfo tmpOverrideTexInfo = { 0 }; + struct TextureInfo* overrideTexInfo = &tmpOverrideTexInfo; + + if (smlua_is_cobject(L, 2, LOT_TEXTUREINFO)) { + overrideTexInfo = (struct TextureInfo*)smlua_to_cobject(L, 2, LOT_TEXTUREINFO); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 2"); return 0; } + } else { + int top = lua_gettop(L); + lua_pushvalue(L, 2); + + lua_pushstring(L, "texture"); + lua_gettable(L, top+1); + tmpOverrideTexInfo.texture = smlua_to_cpointer(L, lua_gettop(L), LVT_U8_P); + lua_pop(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 2's 'texture' field"); return 0; } + + tmpOverrideTexInfo.bitSize = smlua_get_integer_field(top+1, "bitSize"); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 2's 'bitSize' field"); return 0; } + + tmpOverrideTexInfo.width = smlua_get_integer_field(top+1, "width"); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 2's 'width' field"); return 0; } + + tmpOverrideTexInfo.height = smlua_get_integer_field(top+1, "height"); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 2's 'height' field"); return 0; } + + tmpOverrideTexInfo.name = smlua_get_string_field(top+1, "name"); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 2's 'name' field"); return 0; } + + lua_settop(L, top); + } + + dynos_texture_override_set(textureName, overrideTexInfo); + + return 1; +} + +int smlua_func_texture_override_reset(lua_State* L) { + if (!smlua_functions_valid_param_count(L, 1)) { return 0; } + + const char* textureName = smlua_to_string(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; } + + dynos_texture_override_reset(textureName); + + return 1; +} + //////////////////////////////// // level script preprocessing // //////////////////////////////// @@ -838,6 +906,8 @@ void smlua_bind_functions(void) { smlua_bind_function(L, "djui_hud_render_texture_tile", smlua_func_djui_hud_render_texture_tile); smlua_bind_function(L, "djui_hud_render_texture_interpolated", smlua_func_djui_hud_render_texture_interpolated); smlua_bind_function(L, "djui_hud_render_texture_tile_interpolated", smlua_func_djui_hud_render_texture_tile_interpolated); + smlua_bind_function(L, "texture_override_set", smlua_func_texture_override_set); + smlua_bind_function(L, "texture_override_reset", smlua_func_texture_override_reset); smlua_bind_function(L, "level_script_parse", smlua_func_level_script_parse); smlua_bind_function(L, "smlua_anim_util_register_animation", smlua_func_smlua_anim_util_register_animation); smlua_bind_function(L, "set_exclamation_box_new_contents", smlua_func_set_exclamation_box_new_contents); diff --git a/src/pc/lua/smlua_utils.c b/src/pc/lua/smlua_utils.c index 86312241..0fe0a193 100644 --- a/src/pc/lua/smlua_utils.c +++ b/src/pc/lua/smlua_utils.c @@ -525,6 +525,18 @@ lua_Number smlua_get_number_field(int index, const char* name) { return val; } +const char* smlua_get_string_field(int index, const char* name) { + if (lua_type(gLuaState, index) != LUA_TTABLE) { + LOG_LUA_LINE("smlua_get_string_field received improper type '%d'", lua_type(gLuaState, index)); + gSmLuaConvertSuccess = false; + return 0; + } + lua_getfield(gLuaState, index, name); + const char* val = smlua_to_string(gLuaState, -1); + lua_pop(gLuaState, 1); + return val; +} + LuaFunction smlua_get_function_field(int index, const char *name) { if (lua_type(gLuaState, index) != LUA_TTABLE) { LOG_LUA_LINE("smlua_get_function_field received improper type '%d'", lua_type(gLuaState, index)); diff --git a/src/pc/lua/smlua_utils.h b/src/pc/lua/smlua_utils.h index e8cfefee..b9246855 100644 --- a/src/pc/lua/smlua_utils.h +++ b/src/pc/lua/smlua_utils.h @@ -40,6 +40,7 @@ void smlua_push_lnt(struct LSTNetworkType* lnt); lua_Integer smlua_get_integer_field(int index, const char* name); lua_Number smlua_get_number_field(int index, const char* name); +const char* smlua_get_string_field(int index, const char* name); LuaFunction smlua_get_function_field(int index, const char *name); const char* smlua_lnt_to_str(struct LSTNetworkType* lnt);