From 8c8b7e91a374f690d19fc970750752f0a7b15085 Mon Sep 17 00:00:00 2001 From: Agent X <44549182+AgentXLP@users.noreply.github.com> Date: Sun, 29 Dec 2024 14:38:45 -0500 Subject: [PATCH] Update some things --- autogen/lua_definitions/manual.lua | 4 +- docs/lua/guides/hooks.md | 5 +- mods/character-select-coop/a-utils.lua | 7 +-- mods/character-select-coop/main.lua | 29 +++++++++-- mods/character-select-coop/n-hud.lua | 66 +++++++++++++------------- src/game/rendering_graph_node.c | 3 +- 6 files changed, 68 insertions(+), 46 deletions(-) diff --git a/autogen/lua_definitions/manual.lua b/autogen/lua_definitions/manual.lua index ec06b4008..323dea0d3 100644 --- a/autogen/lua_definitions/manual.lua +++ b/autogen/lua_definitions/manual.lua @@ -423,8 +423,8 @@ function get_exclamation_box_contents() -- ... end ----@param node GraphNode | FnGraphNode ----@return GraphNode | GraphNodeAnimatedPart | GraphNodeBackground | GraphNodeBillboard | GraphNodeCamera | GraphNodeCullingRadius | GraphNodeDisplayList | GraphNodeGenerated | GraphNodeHeldObject | GraphNodeLevelOfDetail | GraphNodeMasterList | GraphNodeObject | GraphNodeObjectParent | GraphNodeOrthoProjection | GraphNodePerspective | GraphNodeRotation | GraphNodeScale | GraphNodeShadow | GraphNodeStart | GraphNodeSwitchCase | GraphNodeTranslation | GraphNodeTranslationRotation +--- @param node GraphNode | FnGraphNode +--- @return GraphNode | GraphNodeAnimatedPart | GraphNodeBackground | GraphNodeBillboard | GraphNodeCamera | GraphNodeCullingRadius | GraphNodeDisplayList | GraphNodeGenerated | GraphNodeHeldObject | GraphNodeLevelOfDetail | GraphNodeMasterList | GraphNodeObject | GraphNodeObjectParent | GraphNodeOrthoProjection | GraphNodePerspective | GraphNodeRotation | GraphNodeScale | GraphNodeShadow | GraphNodeStart | GraphNodeSwitchCase | GraphNodeTranslation | GraphNodeTranslationRotation --- Returns the specific GraphNode(...) the node is part of. --- Basically the reverse of `.node` or `.fnNode`. function cast_graph_node(node) diff --git a/docs/lua/guides/hooks.md b/docs/lua/guides/hooks.md index 8459e3795..ac905eda7 100644 --- a/docs/lua/guides/hooks.md +++ b/docs/lua/guides/hooks.md @@ -134,11 +134,14 @@ The lua functions sent to `hook_event()` will be automatically called by SM64 wh | HOOK_ON_OBJECT_LOAD | Called when an object is spawned in | [Object](../structs.md#Object) obj | | HOOK_ON_PLAY_SOUND | Called when a sound is going to play, return a `SOUND_*` constant or `NO_SOUND` to override the sound | `integer` soundBits, `Vec3f` pos | | HOOK_ON_SEQ_LOAD | Called when a sequence is going to play, return a `SEQ_*` constant to override the sequence. `SEQ_SOUND_PLAYER` (0) is silence. | `integer` player, `integer` seqID | -| HOOK_ON_ATTACK_OBJECT | Called when a player attacks an object. May be double-fired in some cases, you'll need to write special code for this | [MarioState](structs.md#MarioState) attacker, [Object](structs.md#Object) victim, `integer` interactionId | +| HOOK_ON_ATTACK_OBJECT | Called when a player attacks an object. May be double-fired in some cases, you'll need to write special code for this | [MarioState](../structs.md#MarioState) attacker, [Object](../structs.md#Object) victim, `integer` interactionId | | HOOK_ON_LANGUAGE_CHANGED | Called when the language is changed | `string` language | | HOOK_ON_MODS_LOADED | Called directly after every mod file is loaded in by smlua | None | | HOOK_ON_NAMETAGS_RENDER | Called when nametags are rendered. Return a `string` to change what renders on the nametag, return an empty `string` to render nothing. | `string` playerIndex | | HOOK_ON_DJUI_THEME_CHANGED | Called when the DJUI theme is changed. Run `djui_menu_get_theme()` to get the new theme. | None | +| HOOK_ON_GEO_PROCESS | Called when a GeoLayout is processed **Note:** You must set the `hookProcess` field of the graph node to a non-zero value | [GraphNode](../structs.md#GraphNode) graphNode, `integer` matStackIndex | +| HOOK_BEFORE_GEO_PROCESS | Called before a GeoLayout is processed **Note:** You must set the `hookProcess` field of the graph node to a non-zero value | [GraphNode](../structs.md#GraphNode) graphNode, `integer` matStackIndex | +| HOOK_ON_GEO_PROCESS_CHILDREN | Called when the children of a GeoLayout node is processed **Note:** You must set the `hookProcess` field of the parent graph node to a non-zero value | [GraphNode](../structs.md#GraphNode) graphNode, `integer` matStackIndex | ### Parameters diff --git a/mods/character-select-coop/a-utils.lua b/mods/character-select-coop/a-utils.lua index b78d9ae43..aae5e1fab 100644 --- a/mods/character-select-coop/a-utils.lua +++ b/mods/character-select-coop/a-utils.lua @@ -20,7 +20,8 @@ local dependacyFiles = { } local legacyFiles = { "voice.lua", - "palettes.lua" + "palettes.lua", + "z-anims.lua", } -- Check for Missing Files @@ -54,8 +55,8 @@ if foundLegacyFiles then end MOD_VERSION_API = 1 -MOD_VERSION_MAJOR = 11 -MOD_VERSION_MINOR = 3 +MOD_VERSION_MAJOR = 12 +MOD_VERSION_MINOR = 0 MOD_VERSION_INDEV = true MOD_VERSION_STRING = tostring(MOD_VERSION_API) .. "." .. tostring(MOD_VERSION_MAJOR) .. (MOD_VERSION_MINOR > 0 and ("." .. tostring(MOD_VERSION_MINOR)) or "") .. (MOD_VERSION_INDEV and " (In-Dev)" or "") diff --git a/mods/character-select-coop/main.lua b/mods/character-select-coop/main.lua index 6867467b9..f9ff01631 100644 --- a/mods/character-select-coop/main.lua +++ b/mods/character-select-coop/main.lua @@ -1,5 +1,5 @@ -- name: Character Select --- description:\\#ffff33\\-- Character Select Coop v1.11.3 --\n\n\\#dcdcdc\\A Library / API made to make adding and using Custom Characters as simple as possible!\nUse\\#ffff33\\ /char-select\\#dcdcdc\\ to get started!\n\nCreated by:\\#008800\\ Squishy6094\n\n\\#AAAAFF\\Updates can be found on\nCharacter Select's Github:\n\\#6666FF\\Squishy6094/character-select-coop +-- description:\\#ffff33\\-- Character Select Coop v1.12 --\n\n\\#dcdcdc\\A Library / API made to make adding and using Custom Characters as simple as possible!\nUse\\#ffff33\\ /char-select\\#dcdcdc\\ to get started!\n\nCreated by:\\#008800\\ Squishy6094\n\n\\#AAAAFF\\Updates can be found on\nCharacter Select's Github:\n\\#6666FF\\Squishy6094/character-select-coop -- pausable: false -- category: cs @@ -863,8 +863,9 @@ local TEXT_MOVESET_RESTRICTED = "Movesets are Restricted" local TEXT_PALETTE_RESTRICTED = "Palettes are Restricted" local TEXT_MOVESET_AND_PALETTE_RESTRICTED = "Moveset and Palettes are Restricted" local TEXT_CHAR_LOCKED = "Locked" +-- Easter Egg if you get lucky loading the mod +-- Referencing the original sm64ex DynOS options by PeachyPeach >v< if math_random(100) == 64 then - -- Easter Egg if you get lucky loading the mod Referencing the original sm64ex DynOS options by PeachyPeach >v< TEXT_PAUSE_Z_OPEN = "Z - DynOS" TEXT_PAUSE_CURR_CHAR = "Model: " end @@ -1736,9 +1737,14 @@ local function chat_command(msg) msg = string_lower(msg) -- Open Menu Check - if msg == "" or msg == "menu" then - menu = not menu - return true + if (msg == "" or msg == "menu") then + if menu_is_allowed(gMarioStates[0]) then + menu = not menu + return true + else + djui_chat_message_create(TEXT_PAUSE_UNAVALIBLE) + return true + end end -- Help Prompt Check @@ -1798,3 +1804,16 @@ local function chat_command(msg) end hook_chat_command("char-select", "- Opens the Character Select Menu", chat_command) + +--[[ +local function mod_menu_open_cs() + local m = gMarioStates[0] + if menu_is_allowed(m) then + gMarioStates[0].controller.buttonPressed = START_BUTTON + menu = true + else + play_sound(SOUND_MENU_CAMERA_BUZZ, m.pos) + end +end +hook_mod_menu_button("Open Menu", mod_menu_open_cs) +]] \ No newline at end of file diff --git a/mods/character-select-coop/n-hud.lua b/mods/character-select-coop/n-hud.lua index 123920c5d..b5e86a0e5 100644 --- a/mods/character-select-coop/n-hud.lua +++ b/mods/character-select-coop/n-hud.lua @@ -539,23 +539,31 @@ function zero_index_to_one_index(table) return tableOne end -local packFilterTotal = 0 +local activeNonCSMods = {} +local nonCSModPosition = 0 +local CSPacks = 0 for i = 0, #gActiveMods do - if remove_color(gActiveMods[i].name):sub(1, 4) == "[CS]" then - packFilterTotal = packFilterTotal + 1 + if gActiveMods[i].name == "Character Select" then + table.insert(activeNonCSMods, tostring(gActiveMods[i].name)) + nonCSModPosition = #activeNonCSMods + elseif (remove_color(gActiveMods[i].name):sub(1, 4) ~= "[CS]" and gActiveMods[i].category ~= "cs") then + table.insert(activeNonCSMods, tostring(gActiveMods[i].name)) + else + CSPacks = CSPacks + 1 end end + +activeNonCSMods[nonCSModPosition] = "Character Select (+"..CSPacks..")" + function render_playerlist_and_modlist() -- DjuiTheme Data - local sDjuiTheme = djui_menu_get_theme() local hudFont = sDjuiTheme.panels.hudFontHeader local rectColor = sDjuiTheme.threePanels.rectColor local borderColor = sDjuiTheme.threePanels.borderColor -- PlayerList - playerListWidth = 710 playerListHeight = (16 * 32) + (16 - 1) * 4 + (32 + 16) + 32 + 32 local x = djui_hud_get_screen_width()/2 - playerListWidth/2 @@ -615,8 +623,7 @@ function render_playerlist_and_modlist() -- ModList local modListWidth = 280 - local modsCount = #gActiveMods - packFilterTotal - local modListHeight = ((modsCount + 1) * 32) + ((modsCount + 1) - 1) * 4 + (32 + 16) + 32 + 32 + local modListHeight = (#activeNonCSMods * 32) + (#activeNonCSMods - 1) * 4 + (32 + 16) + 32 + 32 local mX = djui_hud_get_screen_width()/2 + 363 local mY = djui_hud_get_screen_height()/2 - modListHeight/2 @@ -625,36 +632,27 @@ function render_playerlist_and_modlist() djui_hud_render_header_box(modsString, 0, 0xff, 0xff, 0xff, 0xff, 1, mX, mY, modListWidth, modListHeight, rectColor, borderColor) djui_hud_set_font(FONT_USER) - local packFilter = 0 - for i = 0, #gActiveMods do - -- Filter CS Packs out of modlist - if remove_color(gActiveMods[i].name):sub(1, 4) == "[CS]" then - packFilter = packFilter + 1 - else - local i = i - packFilter - v = (i % 2) ~= 0 and 16 or 32 - djui_hud_set_color(v, v, v, 128) - local entryWidth = modListWidth - ((8 + listMargins) * 2) - local entryHeight = 32 - local entryX = mX + 8 + listMargins - local entryY = mY + 124 + 0 + ((entryHeight + 4) * (i - 1)) - djui_hud_render_rect(entryX, entryY, entryWidth, entryHeight) - local modName = gActiveMods[i].name - if modName == "Character Select" and packFilterTotal > 0 then - modName = modName.." (+"..packFilterTotal..")" + for i = 0, #activeNonCSMods - 1 do + --local i = i - packFilter + v = (i % 2) ~= 0 and 16 or 32 + djui_hud_set_color(v, v, v, 128) + local entryWidth = modListWidth - ((8 + listMargins) * 2) + local entryHeight = 32 + local entryX = mX + 8 + listMargins + local entryY = mY + 124 + 0 + ((entryHeight + 4) * (i - 1)) + djui_hud_render_rect(entryX, entryY, entryWidth, entryHeight) + local modName = activeNonCSMods[i + 1] + local stringSubCount = 23 + local inColor = false + for i = 1, #modName do + if modName:sub(i, i) == "\\" then + inColor = not inColor end - local stringSubCount = 23 - local inColor = false - for i = 1, #modName do - if modName:sub(i, i) == "\\" then - inColor = not inColor - end - if inColor then - stringSubCount = stringSubCount + 1 - end + if inColor then + stringSubCount = stringSubCount + 1 end - djui_hud_print_text_with_color(modName:sub(1, stringSubCount), entryX, entryY, 1, 0xdc, 0xdc, 0xdc, 255) end + djui_hud_print_text_with_color(modName:sub(1, stringSubCount), entryX, entryY, 1, 0xdc, 0xdc, 0xdc, 255) end end diff --git a/src/game/rendering_graph_node.c b/src/game/rendering_graph_node.c index 0cf4a7d6f..61b33e405 100644 --- a/src/game/rendering_graph_node.c +++ b/src/game/rendering_graph_node.c @@ -1494,6 +1494,7 @@ void geo_try_process_children(struct GraphNode *node) { } } +#define MAX_GRAPH_NODE_DEPTH 5000 /** * Process a generic geo node and its siblings. * The first argument is the start node, and all its siblings will @@ -1533,7 +1534,7 @@ void geo_process_node_and_siblings(struct GraphNode *firstNode) { } // Break out of endless loops - if (++depthSanity > 5000) { + if (++depthSanity > MAX_GRAPH_NODE_DEPTH) { LOG_ERROR("Graph Node too deep!"); break; }