From 29599a82ecc4ea788d788407a100ec7ecdbea3ed Mon Sep 17 00:00:00 2001 From: MysterD Date: Tue, 15 Feb 2022 22:13:10 -0800 Subject: [PATCH] Created TextureInfo struct --- autogen/common.py | 12 ++- autogen/convert_structs.py | 3 +- docs/lua/functions.md | 9 +- docs/lua/structs.md | 16 +++- include/types.h | 11 ++- src/game/characters.c | 9 +- src/game/characters.h | 3 +- src/pc/djui/djui_hud_utils.c | 6 +- src/pc/djui/djui_hud_utils.h | 2 +- src/pc/djui/djui_panel_playerlist.c | 2 +- src/pc/lua/smlua_cobject_autogen.c | 135 ++++++++++++++------------- src/pc/lua/smlua_cobject_autogen.h | 1 + src/pc/lua/smlua_functions_autogen.c | 20 ++-- 13 files changed, 133 insertions(+), 96 deletions(-) diff --git a/autogen/common.py b/autogen/common.py index 082a0413..b866fe7b 100644 --- a/autogen/common.py +++ b/autogen/common.py @@ -18,6 +18,9 @@ def translate_type_to_lvt(ptype): if ptype == 'char': ptype = 'u8' + if 'const ' in ptype: + ptype = ptype.replace('const ', '').strip() + if ('char' in ptype and '[' in ptype): return 'LVT_STRING' @@ -57,15 +60,18 @@ def translate_type_to_lvt(ptype): return 'LVT_???' def translate_type_to_lot(ptype): - if ptype == 'char': - ptype = 'u8' - if ptype == 'const char*': return 'LOT_NONE' if ptype == 'char*' or ('char' in ptype and '[' in ptype): return 'LOT_NONE' + if 'const ' in ptype: + ptype = ptype.replace('const ', '') + + if ptype == 'char': + ptype = 'u8' + if '[' in ptype or '{' in ptype: return 'LOT_???' diff --git a/autogen/convert_structs.py b/autogen/convert_structs.py index cf788629..e2ae36c4 100644 --- a/autogen/convert_structs.py +++ b/autogen/convert_structs.py @@ -57,6 +57,7 @@ override_field_immutable = { "MarioState": [ "playerIndex" ], "Character": [ "*" ], "NetworkPlayer": [ "*" ], + "TextureInfo": [ "*" ], } sLuaManuallyDefinedStructs = [ @@ -188,7 +189,7 @@ def get_struct_field_info(struct, field): lvt = translate_type_to_lvt(ftype) lot = translate_type_to_lot(ftype) - fimmutable = str(lvt == 'LVT_COBJECT' or lvt.endswith('_P')).lower() + fimmutable = str(lvt == 'LVT_COBJECT' or lvt.endswith('_P') or 'const ' in ftype).lower() if sid in override_field_immutable: if fid in override_field_immutable[sid] or '*' in override_field_immutable[sid]: diff --git a/docs/lua/functions.md b/docs/lua/functions.md index 8aa92084..c35d59a5 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -711,17 +711,14 @@ ## [djui_hud_render_texture](#djui_hud_render_texture) ### Lua Example -`djui_hud_render_texture(texture, bitSize, x, y, width, height, scaleW, scaleH)` +`djui_hud_render_texture(texInfo, x, y, scaleW, scaleH)` ### Parameters | Field | Type | | ----- | ---- | -| texture | Pointer | -| bitSize | integer | +| texInfo | [TextureInfo](structs.md#TextureInfo) | | x | number | | y | number | -| width | integer | -| height | integer | | scaleW | number | | scaleH | number | @@ -729,7 +726,7 @@ - None ### C Prototype -`void djui_hud_render_texture(const u8* texture, u32 bitSize, f32 x, f32 y, u32 width, u32 height, f32 scaleW, f32 scaleH);` +`void djui_hud_render_texture(struct TextureInfo* texInfo, f32 x, f32 y, f32 scaleW, f32 scaleH);` [:arrow_up_small:](#) diff --git a/docs/lua/structs.md b/docs/lua/structs.md index e73d38b6..daf5ce1c 100644 --- a/docs/lua/structs.md +++ b/docs/lua/structs.md @@ -37,6 +37,7 @@ - [SPTask](#SPTask) - [SpawnInfo](#SpawnInfo) - [Surface](#Surface) +- [TextureInfo](#TextureInfo) - [TransitionInfo](#TransitionInfo) - [UnusedArea28](#UnusedArea28) - [VblankHandler](#VblankHandler) @@ -174,7 +175,7 @@ | capModelId | integer | read-only | | capWingModelId | integer | read-only | | hudHead | char | read-only | -| hudHeadTexture | Pointer | read-only | +| hudHeadTexture | [TextureInfo](#TextureInfo) | read-only | | modelId | integer | read-only | | name | string | read-only | | soundAttacked | integer | read-only | @@ -771,6 +772,19 @@
+## [TextureInfo](#TextureInfo) + +| Field | Type | Access | +| ----- | ---- | ------ | +| bitSize | const u8 | read-only | +| height | const u32 | read-only | +| texture | Pointer | read-only | +| width | const u32 | read-only | + +[:arrow_up_small:](#) + +
+ ## [TransitionInfo](#TransitionInfo) | Field | Type | Access | diff --git a/include/types.h b/include/types.h index c14bd792..88565f50 100644 --- a/include/types.h +++ b/include/types.h @@ -6,7 +6,6 @@ #include #include "macros.h" -#include "src/game/characters.h" #include "pc/network/version.h" // Certain functions are marked as having return values, but do not @@ -396,6 +395,14 @@ struct MarioState /*????*/ f32 curAnimOffset; }; +struct TextureInfo +{ + const u8* texture; + const u8 bitSize; + const u32 width; + const u32 height; +}; + #define PLAY_MODE_NORMAL 0 #define PLAY_MODE_PAUSED 2 #define PLAY_MODE_CHANGE_AREA 3 @@ -404,4 +411,6 @@ struct MarioState #define MAX_PLAYERS 16 +#include "src/game/characters.h" + #endif // _SM64_TYPES_H_ diff --git a/src/game/characters.c b/src/game/characters.c index 5c13247b..58f36b31 100644 --- a/src/game/characters.c +++ b/src/game/characters.c @@ -10,6 +10,7 @@ #include "pc/configfile.h" #include "audio/external.h" #include "engine/graph_node.h" +#include "types.h" extern Gfx mario_cap_seg3_dl_03022F48[]; extern Gfx luigi_cap_seg3_dl_03022F48[]; @@ -29,7 +30,7 @@ struct Character gCharacters[CT_MAX] = { .type = CT_MARIO, .name = "Mario", .hudHead = ',', - .hudHeadTexture = texture_hud_char_mario_head, + .hudHeadTexture = { .texture = texture_hud_char_mario_head, .bitSize = 8, .width = 16, .height = 16 }, .cameraHudHead = GLYPH_CAM_MARIO_HEAD, .modelId = MODEL_MARIO, .capModelId = MODEL_MARIOS_CAP, @@ -92,7 +93,7 @@ struct Character gCharacters[CT_MAX] = { .type = CT_LUIGI, .name = "Luigi", .hudHead = '.', - .hudHeadTexture = texture_hud_char_luigi_head, + .hudHeadTexture = { .texture = texture_hud_char_luigi_head, .bitSize = 8, .width = 16, .height = 16 }, .cameraHudHead = GLYPH_CAM_LUIGI_HEAD, .modelId = MODEL_LUIGI, .capModelId = MODEL_LUIGIS_CAP, @@ -155,7 +156,7 @@ struct Character gCharacters[CT_MAX] = { .type = CT_TOAD, .name = "Toad", .hudHead = '/', - .hudHeadTexture = texture_hud_char_toad_head, + .hudHeadTexture = { .texture = texture_hud_char_toad_head, .bitSize = 8, .width = 16, .height = 16 }, .cameraHudHead = GLYPH_CAM_TOAD_HEAD, .modelId = MODEL_TOAD_PLAYER, .capModelId = MODEL_TOADS_CAP, @@ -218,7 +219,7 @@ struct Character gCharacters[CT_MAX] = { .type = CT_WALUIGI, .name = "Waluigi", .hudHead = 'z', - .hudHeadTexture = texture_hud_char_waluigi_head, + .hudHeadTexture = { .texture = texture_hud_char_waluigi_head, .bitSize = 8, .width = 16, .height = 16 }, .cameraHudHead = GLYPH_CAM_WALUIGI_HEAD, .modelId = MODEL_WALUIGI, .capModelId = MODEL_WALUIGIS_CAP, diff --git a/src/game/characters.h b/src/game/characters.h index fb2f0483..ece148ab 100644 --- a/src/game/characters.h +++ b/src/game/characters.h @@ -1,6 +1,7 @@ #ifndef CHARACTERS_H #define CHARACTERS_H #include "PR/ultratypes.h" +#include "types.h" // NOTE: do not include any additional headers enum CharacterType { @@ -18,7 +19,7 @@ struct Character { enum CharacterType type; char* name; char hudHead; - const u8* hudHeadTexture; + struct TextureInfo hudHeadTexture; u32 cameraHudHead; u32 modelId; u32 capModelId; diff --git a/src/pc/djui/djui_hud_utils.c b/src/pc/djui/djui_hud_utils.c index 2f0536a1..3b1938d3 100644 --- a/src/pc/djui/djui_hud_utils.c +++ b/src/pc/djui/djui_hud_utils.c @@ -117,7 +117,7 @@ void djui_hud_print_text(const char* message, float x, float y, float scale) { gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); } -void djui_hud_render_texture(const u8* texture, u32 bitSize, f32 x, f32 y, u32 width, u32 height, f32 scaleW, f32 scaleH) { +static void djui_hud_render_texture_raw(const u8* texture, u32 bitSize, u32 width, u32 height, f32 x, f32 y, f32 scaleW, f32 scaleH) { // translate position f32 translatedX = x; f32 translatedY = y; @@ -137,3 +137,7 @@ void djui_hud_render_texture(const u8* texture, u32 bitSize, f32 x, f32 y, u32 w // pop gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); } + +void djui_hud_render_texture(struct TextureInfo* texInfo, f32 x, f32 y, f32 scaleW, f32 scaleH) { + djui_hud_render_texture_raw(texInfo->texture, texInfo->bitSize, texInfo->width, texInfo->width, x, y, scaleW, scaleH); +} diff --git a/src/pc/djui/djui_hud_utils.h b/src/pc/djui/djui_hud_utils.h index bb0d4175..ca534865 100644 --- a/src/pc/djui/djui_hud_utils.h +++ b/src/pc/djui/djui_hud_utils.h @@ -23,6 +23,6 @@ u32 djui_hud_get_screen_height(void); f32 djui_hud_measure_text(const char* message); void djui_hud_print_text(const char* message, float x, float y, float scale); -void djui_hud_render_texture(const u8* texture, u32 bitSize, f32 x, f32 y, u32 width, u32 height, f32 scaleW, f32 scaleH); +void djui_hud_render_texture(struct TextureInfo* texInfo, f32 x, f32 y, f32 scaleW, f32 scaleH); #endif \ No newline at end of file diff --git a/src/pc/djui/djui_panel_playerlist.c b/src/pc/djui/djui_panel_playerlist.c index 09f277d6..14f8b5ac 100644 --- a/src/pc/djui/djui_panel_playerlist.c +++ b/src/pc/djui/djui_panel_playerlist.c @@ -18,7 +18,7 @@ static struct DjuiText* djuiTextLocations[MAX_PLAYERS] = { 0 }; static void playerlist_update_row(u8 i, struct NetworkPlayer* np) { u8 charIndex = np->modelIndex; if (charIndex >= CT_MAX) { charIndex = 0; } - djuiImages[i]->texture = gCharacters[charIndex].hudHeadTexture; + djuiImages[i]->texture = gCharacters[charIndex].hudHeadTexture.texture; u8 visible = np->connected; if (np == gNetworkPlayerServer && gServerSettings.headlessServer) { diff --git a/src/pc/lua/smlua_cobject_autogen.c b/src/pc/lua/smlua_cobject_autogen.c index c69d1aed..d47e9fec 100644 --- a/src/pc/lua/smlua_cobject_autogen.c +++ b/src/pc/lua/smlua_cobject_autogen.c @@ -97,67 +97,67 @@ static struct LuaObjectField sCameraTriggerFields[LUA_CAMERA_TRIGGER_FIELD_COUNT #define LUA_CHARACTER_FIELD_COUNT 59 static struct LuaObjectField sCharacterFields[LUA_CHARACTER_FIELD_COUNT] = { - { "animOffsetEnabled", LVT_U8, offsetof(struct Character, animOffsetEnabled), true, LOT_NONE }, - { "animOffsetFeet", LVT_F32, offsetof(struct Character, animOffsetFeet), true, LOT_NONE }, - { "animOffsetHand", LVT_F32, offsetof(struct Character, animOffsetHand), true, LOT_NONE }, - { "animOffsetLowYPoint", LVT_F32, offsetof(struct Character, animOffsetLowYPoint), true, LOT_NONE }, - { "cameraHudHead", LVT_U32, offsetof(struct Character, cameraHudHead), true, LOT_NONE }, -// { "capEnemyDecalGfx", LVT_???, offsetof(struct Character, capEnemyDecalGfx), true, LOT_??? }, <--- UNIMPLEMENTED -// { "capEnemyGfx", LVT_???, offsetof(struct Character, capEnemyGfx), true, LOT_??? }, <--- UNIMPLEMENTED - { "capEnemyLayer", LVT_U8, offsetof(struct Character, capEnemyLayer), true, LOT_NONE }, - { "capMetalModelId", LVT_U32, offsetof(struct Character, capMetalModelId), true, LOT_NONE }, - { "capMetalWingModelId", LVT_U32, offsetof(struct Character, capMetalWingModelId), true, LOT_NONE }, - { "capModelId", LVT_U32, offsetof(struct Character, capModelId), true, LOT_NONE }, - { "capWingModelId", LVT_U32, offsetof(struct Character, capWingModelId), true, LOT_NONE }, - { "hudHead", LVT_U8, offsetof(struct Character, hudHead), true, LOT_NONE }, - { "hudHeadTexture", LVT_U8_P, offsetof(struct Character, hudHeadTexture), true, LOT_POINTER }, - { "modelId", LVT_U32, offsetof(struct Character, modelId), true, LOT_NONE }, - { "name", LVT_STRING_P, offsetof(struct Character, name), true, LOT_NONE }, - { "soundAttacked", LVT_S32, offsetof(struct Character, soundAttacked), true, LOT_NONE }, - { "soundCoughing1", LVT_S32, offsetof(struct Character, soundCoughing1), true, LOT_NONE }, - { "soundCoughing2", LVT_S32, offsetof(struct Character, soundCoughing2), true, LOT_NONE }, - { "soundCoughing3", LVT_S32, offsetof(struct Character, soundCoughing3), true, LOT_NONE }, - { "soundDoh", LVT_S32, offsetof(struct Character, soundDoh), true, LOT_NONE }, - { "soundDrowning", LVT_S32, offsetof(struct Character, soundDrowning), true, LOT_NONE }, - { "soundDying", LVT_S32, offsetof(struct Character, soundDying), true, LOT_NONE }, - { "soundEeuh", LVT_S32, offsetof(struct Character, soundEeuh), true, LOT_NONE }, - { "soundFreqScale", LVT_F32, offsetof(struct Character, soundFreqScale), true, LOT_NONE }, - { "soundGameOver", LVT_S32, offsetof(struct Character, soundGameOver), true, LOT_NONE }, - { "soundGroundPoundWah", LVT_S32, offsetof(struct Character, soundGroundPoundWah), true, LOT_NONE }, - { "soundHaha", LVT_S32, offsetof(struct Character, soundHaha), true, LOT_NONE }, - { "soundHaha_2", LVT_S32, offsetof(struct Character, soundHaha_2), true, LOT_NONE }, - { "soundHello", LVT_S32, offsetof(struct Character, soundHello), true, LOT_NONE }, - { "soundHereWeGo", LVT_S32, offsetof(struct Character, soundHereWeGo), true, LOT_NONE }, - { "soundHoohoo", LVT_S32, offsetof(struct Character, soundHoohoo), true, LOT_NONE }, - { "soundHrmm", LVT_S32, offsetof(struct Character, soundHrmm), true, LOT_NONE }, - { "soundImaTired", LVT_S32, offsetof(struct Character, soundImaTired), true, LOT_NONE }, - { "soundMamaMia", LVT_S32, offsetof(struct Character, soundMamaMia), true, LOT_NONE }, - { "soundOnFire", LVT_S32, offsetof(struct Character, soundOnFire), true, LOT_NONE }, - { "soundOoof", LVT_S32, offsetof(struct Character, soundOoof), true, LOT_NONE }, - { "soundOoof2", LVT_S32, offsetof(struct Character, soundOoof2), true, LOT_NONE }, - { "soundPanting", LVT_S32, offsetof(struct Character, soundPanting), true, LOT_NONE }, - { "soundPantingCold", LVT_S32, offsetof(struct Character, soundPantingCold), true, LOT_NONE }, - { "soundPressStartToPlay", LVT_S32, offsetof(struct Character, soundPressStartToPlay), true, LOT_NONE }, - { "soundPunchHoo", LVT_S32, offsetof(struct Character, soundPunchHoo), true, LOT_NONE }, - { "soundPunchWah", LVT_S32, offsetof(struct Character, soundPunchWah), true, LOT_NONE }, - { "soundPunchYah", LVT_S32, offsetof(struct Character, soundPunchYah), true, LOT_NONE }, - { "soundSnoring1", LVT_S32, offsetof(struct Character, soundSnoring1), true, LOT_NONE }, - { "soundSnoring2", LVT_S32, offsetof(struct Character, soundSnoring2), true, LOT_NONE }, - { "soundSnoring3", LVT_S32, offsetof(struct Character, soundSnoring3), true, LOT_NONE }, - { "soundSoLongaBowser", LVT_S32, offsetof(struct Character, soundSoLongaBowser), true, LOT_NONE }, - { "soundTwirlBounce", LVT_S32, offsetof(struct Character, soundTwirlBounce), true, LOT_NONE }, - { "soundUh", LVT_S32, offsetof(struct Character, soundUh), true, LOT_NONE }, - { "soundUh2", LVT_S32, offsetof(struct Character, soundUh2), true, LOT_NONE }, - { "soundUh2_2", LVT_S32, offsetof(struct Character, soundUh2_2), true, LOT_NONE }, - { "soundWaaaooow", LVT_S32, offsetof(struct Character, soundWaaaooow), true, LOT_NONE }, - { "soundWah2", LVT_S32, offsetof(struct Character, soundWah2), true, LOT_NONE }, - { "soundWhoa", LVT_S32, offsetof(struct Character, soundWhoa), true, LOT_NONE }, - { "soundYahWahHoo", LVT_S32, offsetof(struct Character, soundYahWahHoo), true, LOT_NONE }, - { "soundYahoo", LVT_S32, offsetof(struct Character, soundYahoo), true, LOT_NONE }, - { "soundYahooWahaYippee", LVT_S32, offsetof(struct Character, soundYahooWahaYippee), true, LOT_NONE }, - { "soundYawning", LVT_S32, offsetof(struct Character, soundYawning), true, LOT_NONE }, - { "torsoRotMult", LVT_F32, offsetof(struct Character, torsoRotMult), true, LOT_NONE }, - { "type", LVT_S32, offsetof(struct Character, type), true, LOT_NONE }, + { "animOffsetEnabled", LVT_U8, offsetof(struct Character, animOffsetEnabled), true, LOT_NONE }, + { "animOffsetFeet", LVT_F32, offsetof(struct Character, animOffsetFeet), true, LOT_NONE }, + { "animOffsetHand", LVT_F32, offsetof(struct Character, animOffsetHand), true, LOT_NONE }, + { "animOffsetLowYPoint", LVT_F32, offsetof(struct Character, animOffsetLowYPoint), true, LOT_NONE }, + { "cameraHudHead", LVT_U32, offsetof(struct Character, cameraHudHead), true, LOT_NONE }, +// { "capEnemyDecalGfx", LVT_???, offsetof(struct Character, capEnemyDecalGfx), true, LOT_??? }, <--- UNIMPLEMENTED +// { "capEnemyGfx", LVT_???, offsetof(struct Character, capEnemyGfx), true, LOT_??? }, <--- UNIMPLEMENTED + { "capEnemyLayer", LVT_U8, offsetof(struct Character, capEnemyLayer), true, LOT_NONE }, + { "capMetalModelId", LVT_U32, offsetof(struct Character, capMetalModelId), true, LOT_NONE }, + { "capMetalWingModelId", LVT_U32, offsetof(struct Character, capMetalWingModelId), true, LOT_NONE }, + { "capModelId", LVT_U32, offsetof(struct Character, capModelId), true, LOT_NONE }, + { "capWingModelId", LVT_U32, offsetof(struct Character, capWingModelId), true, LOT_NONE }, + { "hudHead", LVT_U8, offsetof(struct Character, hudHead), true, LOT_NONE }, + { "hudHeadTexture", LVT_COBJECT, offsetof(struct Character, hudHeadTexture), true, LOT_TEXTUREINFO }, + { "modelId", LVT_U32, offsetof(struct Character, modelId), true, LOT_NONE }, + { "name", LVT_STRING_P, offsetof(struct Character, name), true, LOT_NONE }, + { "soundAttacked", LVT_S32, offsetof(struct Character, soundAttacked), true, LOT_NONE }, + { "soundCoughing1", LVT_S32, offsetof(struct Character, soundCoughing1), true, LOT_NONE }, + { "soundCoughing2", LVT_S32, offsetof(struct Character, soundCoughing2), true, LOT_NONE }, + { "soundCoughing3", LVT_S32, offsetof(struct Character, soundCoughing3), true, LOT_NONE }, + { "soundDoh", LVT_S32, offsetof(struct Character, soundDoh), true, LOT_NONE }, + { "soundDrowning", LVT_S32, offsetof(struct Character, soundDrowning), true, LOT_NONE }, + { "soundDying", LVT_S32, offsetof(struct Character, soundDying), true, LOT_NONE }, + { "soundEeuh", LVT_S32, offsetof(struct Character, soundEeuh), true, LOT_NONE }, + { "soundFreqScale", LVT_F32, offsetof(struct Character, soundFreqScale), true, LOT_NONE }, + { "soundGameOver", LVT_S32, offsetof(struct Character, soundGameOver), true, LOT_NONE }, + { "soundGroundPoundWah", LVT_S32, offsetof(struct Character, soundGroundPoundWah), true, LOT_NONE }, + { "soundHaha", LVT_S32, offsetof(struct Character, soundHaha), true, LOT_NONE }, + { "soundHaha_2", LVT_S32, offsetof(struct Character, soundHaha_2), true, LOT_NONE }, + { "soundHello", LVT_S32, offsetof(struct Character, soundHello), true, LOT_NONE }, + { "soundHereWeGo", LVT_S32, offsetof(struct Character, soundHereWeGo), true, LOT_NONE }, + { "soundHoohoo", LVT_S32, offsetof(struct Character, soundHoohoo), true, LOT_NONE }, + { "soundHrmm", LVT_S32, offsetof(struct Character, soundHrmm), true, LOT_NONE }, + { "soundImaTired", LVT_S32, offsetof(struct Character, soundImaTired), true, LOT_NONE }, + { "soundMamaMia", LVT_S32, offsetof(struct Character, soundMamaMia), true, LOT_NONE }, + { "soundOnFire", LVT_S32, offsetof(struct Character, soundOnFire), true, LOT_NONE }, + { "soundOoof", LVT_S32, offsetof(struct Character, soundOoof), true, LOT_NONE }, + { "soundOoof2", LVT_S32, offsetof(struct Character, soundOoof2), true, LOT_NONE }, + { "soundPanting", LVT_S32, offsetof(struct Character, soundPanting), true, LOT_NONE }, + { "soundPantingCold", LVT_S32, offsetof(struct Character, soundPantingCold), true, LOT_NONE }, + { "soundPressStartToPlay", LVT_S32, offsetof(struct Character, soundPressStartToPlay), true, LOT_NONE }, + { "soundPunchHoo", LVT_S32, offsetof(struct Character, soundPunchHoo), true, LOT_NONE }, + { "soundPunchWah", LVT_S32, offsetof(struct Character, soundPunchWah), true, LOT_NONE }, + { "soundPunchYah", LVT_S32, offsetof(struct Character, soundPunchYah), true, LOT_NONE }, + { "soundSnoring1", LVT_S32, offsetof(struct Character, soundSnoring1), true, LOT_NONE }, + { "soundSnoring2", LVT_S32, offsetof(struct Character, soundSnoring2), true, LOT_NONE }, + { "soundSnoring3", LVT_S32, offsetof(struct Character, soundSnoring3), true, LOT_NONE }, + { "soundSoLongaBowser", LVT_S32, offsetof(struct Character, soundSoLongaBowser), true, LOT_NONE }, + { "soundTwirlBounce", LVT_S32, offsetof(struct Character, soundTwirlBounce), true, LOT_NONE }, + { "soundUh", LVT_S32, offsetof(struct Character, soundUh), true, LOT_NONE }, + { "soundUh2", LVT_S32, offsetof(struct Character, soundUh2), true, LOT_NONE }, + { "soundUh2_2", LVT_S32, offsetof(struct Character, soundUh2_2), true, LOT_NONE }, + { "soundWaaaooow", LVT_S32, offsetof(struct Character, soundWaaaooow), true, LOT_NONE }, + { "soundWah2", LVT_S32, offsetof(struct Character, soundWah2), true, LOT_NONE }, + { "soundWhoa", LVT_S32, offsetof(struct Character, soundWhoa), true, LOT_NONE }, + { "soundYahWahHoo", LVT_S32, offsetof(struct Character, soundYahWahHoo), true, LOT_NONE }, + { "soundYahoo", LVT_S32, offsetof(struct Character, soundYahoo), true, LOT_NONE }, + { "soundYahooWahaYippee", LVT_S32, offsetof(struct Character, soundYahooWahaYippee), true, LOT_NONE }, + { "soundYawning", LVT_S32, offsetof(struct Character, soundYawning), true, LOT_NONE }, + { "torsoRotMult", LVT_F32, offsetof(struct Character, torsoRotMult), true, LOT_NONE }, + { "type", LVT_S32, offsetof(struct Character, type), true, LOT_NONE }, }; #define LUA_CONTROLLER_FIELD_COUNT 10 @@ -466,7 +466,7 @@ static struct LuaObjectField sObjectFields[LUA_OBJECT_FIELD_COUNT] = { { "areaTimerDuration", LVT_U32, offsetof(struct Object, areaTimerDuration), false, LOT_NONE }, // { "areaTimerRunOnceCallback)(void)", LVT_???, offsetof(struct Object, areaTimerRunOnceCallback)(void)), false, LOT_??? }, <--- UNIMPLEMENTED { "areaTimerType", LVT_S32, offsetof(struct Object, areaTimerType), false, LOT_NONE }, -// { "behavior", LVT_???, offsetof(struct Object, behavior), false, LOT_??? }, <--- UNIMPLEMENTED +// { "behavior", LVT_???, offsetof(struct Object, behavior), true, LOT_??? }, <--- UNIMPLEMENTED { "bhvDelayTimer", LVT_S16, offsetof(struct Object, bhvDelayTimer), false, LOT_NONE }, // { "bhvStack", LOT_???, offsetof(struct Object, bhvStack), false, LOT_??? }, <--- UNIMPLEMENTED { "bhvStackIndex", LVT_U32, offsetof(struct Object, bhvStackIndex), false, LOT_NONE }, @@ -474,7 +474,7 @@ static struct LuaObjectField sObjectFields[LUA_OBJECT_FIELD_COUNT] = { // { "collidedObjs", LOT_???, offsetof(struct Object, collidedObjs), false, LOT_??? }, <--- UNIMPLEMENTED // { "collisionData", LVT_???, offsetof(struct Object, collisionData), false, LOT_??? }, <--- UNIMPLEMENTED { "createdThroughNetwork", LVT_U8, offsetof(struct Object, createdThroughNetwork), false, LOT_NONE }, -// { "curBhvCommand", LVT_???, offsetof(struct Object, curBhvCommand), false, LOT_??? }, <--- UNIMPLEMENTED +// { "curBhvCommand", LVT_???, offsetof(struct Object, curBhvCommand), true, LOT_??? }, <--- UNIMPLEMENTED { "globalPlayerIndex", LVT_U8, offsetof(struct Object, globalPlayerIndex), false, LOT_NONE }, { "header", LVT_COBJECT, offsetof(struct Object, header), true, LOT_OBJECTNODE }, { "heldByPlayerIndex", LVT_U32, offsetof(struct Object, heldByPlayerIndex), false, LOT_NONE }, @@ -596,6 +596,14 @@ 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 +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 }, +}; + #define LUA_TRANSITION_INFO_FIELD_COUNT 9 static struct LuaObjectField sTransitionInfoFields[LUA_TRANSITION_INFO_FIELD_COUNT] = { { "focDist", LVT_F32, offsetof(struct TransitionInfo, focDist), false, LOT_NONE }, @@ -697,6 +705,7 @@ struct LuaObjectTable sLuaObjectAutogenTable[LOT_AUTOGEN_MAX - LOT_AUTOGEN_MIN] { LOT_PLAYERGEOMETRY, sPlayerGeometryFields, LUA_PLAYER_GEOMETRY_FIELD_COUNT }, { LOT_SPAWNINFO, sSpawnInfoFields, LUA_SPAWN_INFO_FIELD_COUNT }, { LOT_SURFACE, sSurfaceFields, LUA_SURFACE_FIELD_COUNT }, + { LOT_TEXTUREINFO, sTextureInfoFields, LUA_TEXTURE_INFO_FIELD_COUNT }, { LOT_TRANSITIONINFO, sTransitionInfoFields, LUA_TRANSITION_INFO_FIELD_COUNT }, { LOT_WALLCOLLISIONDATA, sWallCollisionDataFields, LUA_WALL_COLLISION_DATA_FIELD_COUNT }, { LOT_WARPNODE, sWarpNodeFields, LUA_WARP_NODE_FIELD_COUNT }, diff --git a/src/pc/lua/smlua_cobject_autogen.h b/src/pc/lua/smlua_cobject_autogen.h index 77334467..19d38f79 100644 --- a/src/pc/lua/smlua_cobject_autogen.h +++ b/src/pc/lua/smlua_cobject_autogen.h @@ -39,6 +39,7 @@ enum LuaObjectAutogenType { LOT_PLAYERGEOMETRY, LOT_SPAWNINFO, LOT_SURFACE, + LOT_TEXTUREINFO, LOT_TRANSITIONINFO, LOT_WALLCOLLISIONDATA, LOT_WARPNODE, diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index da8b9ca8..d0bc4e03 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -253,26 +253,20 @@ int smlua_func_djui_hud_print_text(lua_State* L) { } int smlua_func_djui_hud_render_texture(lua_State* L) { - if(!smlua_functions_valid_param_count(L, 8)) { return 0; } + if(!smlua_functions_valid_param_count(L, 5)) { return 0; } - const u8* texture = (const u8*)smlua_to_cpointer(L, 1, LVT_U8_P); + struct TextureInfo* texInfo = (struct TextureInfo*)smlua_to_cobject(L, 1, LOT_TEXTUREINFO); if (!gSmLuaConvertSuccess) { return 0; } - u32 bitSize = smlua_to_integer(L, 2); + f32 x = smlua_to_number(L, 2); if (!gSmLuaConvertSuccess) { return 0; } - f32 x = smlua_to_number(L, 3); + f32 y = smlua_to_number(L, 3); if (!gSmLuaConvertSuccess) { return 0; } - f32 y = smlua_to_number(L, 4); + f32 scaleW = smlua_to_number(L, 4); if (!gSmLuaConvertSuccess) { return 0; } - u32 width = smlua_to_integer(L, 5); - if (!gSmLuaConvertSuccess) { return 0; } - u32 height = smlua_to_integer(L, 6); - if (!gSmLuaConvertSuccess) { return 0; } - f32 scaleW = smlua_to_number(L, 7); - if (!gSmLuaConvertSuccess) { return 0; } - f32 scaleH = smlua_to_number(L, 8); + f32 scaleH = smlua_to_number(L, 5); if (!gSmLuaConvertSuccess) { return 0; } - djui_hud_render_texture(texture, bitSize, x, y, width, height, scaleW, scaleH); + djui_hud_render_texture(texInfo, x, y, scaleW, scaleH); return 1; }