From f0da60fa166e04d5ec22556a15d6a8dd3d78a0aa Mon Sep 17 00:00:00 2001 From: Agent X <44549182+AgentXLP@users.noreply.github.com> Date: Wed, 17 Jul 2024 15:08:38 -0400 Subject: [PATCH] Update Character Select to v1.9.1 --- mods/character-select-coop/a-utils.lua | 4 +- mods/character-select-coop/main.lua | 13 +----- mods/character-select-coop/n-hud.lua | 61 +++++++++++++++++++------- mods/character-select-coop/o-api.lua | 5 +++ mods/character-select-coop/z-voice.lua | 2 +- 5 files changed, 55 insertions(+), 30 deletions(-) diff --git a/mods/character-select-coop/a-utils.lua b/mods/character-select-coop/a-utils.lua index cd6dfcd9..7f613dc4 100644 --- a/mods/character-select-coop/a-utils.lua +++ b/mods/character-select-coop/a-utils.lua @@ -4,7 +4,7 @@ if VERSION_NUMBER < 37 then return 0 end -MOD_VERSION = "1.9" +MOD_VERSION = "1.9.1" ommActive = false for i in pairs(gActiveMods) do @@ -121,4 +121,4 @@ for i in pairs(gActiveMods) do if (gActiveMods[i].incompatible ~= nil and gActiveMods[i].incompatible:find("gamemode")) and not (gActiveMods[i].name:find("Personal Star Counter EX+")) then stopPalettes = true end -end \ No newline at end of file +end diff --git a/mods/character-select-coop/main.lua b/mods/character-select-coop/main.lua index 0c33568f..e6c14e2e 100644 --- a/mods/character-select-coop/main.lua +++ b/mods/character-select-coop/main.lua @@ -1,5 +1,6 @@ -- name: Character Select --- description:\\#ffff33\\---- Character Select Coop v1.9 ----\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\\#dcdcdc\\Concepts by:\\#4496f5\\ AngelicMiracles\n\n\\#AAAAFF\\Updates can be found on\nCharacter Select's Github:\n\\#6666FF\\Squishy6094/character-select-coop +-- description:\\#ffff33\\--- Character Select Coop v1.9.1 ---\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\\#dcdcdc\\Concepts by:\\#4496f5\\ AngelicMiracles\n\n\\#AAAAFF\\Updates can be found on\nCharacter Select's Github:\n\\#6666FF\\Squishy6094/character-select-coop +-- pausable: false if incompatibleClient then return 0 end @@ -1311,13 +1312,3 @@ local function chat_command(msg) end hook_chat_command("char-select", "- Opens the Character Select Menu", chat_command) - --------------- --- Mod Menu -- --------------- - -local function open_cs_menu() - menu = true -end - -hook_mod_menu_button("Open Menu", open_cs_menu) \ 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 b03b3ece..ba67b1c0 100644 --- a/mods/character-select-coop/n-hud.lua +++ b/mods/character-select-coop/n-hud.lua @@ -12,6 +12,35 @@ local defaultIcons = { [CT_WARIO] = gTextures.wario_head } +local sHudElements = { + [HUD_DISPLAY_FLAG_LIVES] = true, + [HUD_DISPLAY_FLAG_STAR_COUNT] = true, + [HUD_DISPLAY_FLAG_CAMERA] = true +} + +---Hides the specified custom hud element +---@param hudElement HUDDisplayFlag +function hud_hide_element(hudElement) + if sHudElements[hudElement] == nil then return false end + sHudElements[hudElement] = false + return true +end + +---Shows the specified custom hud element +---@param hudElement HUDDisplayFlag +function hud_show_element(hudElement) + if sHudElements[hudElement] == nil then return false end + sHudElements[hudElement] = true + return true +end + +---Gets the specified custom hud element's state +---@param hudElement HUDDisplayFlag +function hud_get_element(hudElement) + if sHudElements[hudElement] == nil then return false end + return sHudElements[hudElement] +end + local MATH_DIVIDE_16 = 1/16 -- Localize Functions to improve performence @@ -82,6 +111,8 @@ end local function render_hud_mario_lives() hud_set_value(HUD_DISPLAY_FLAGS, hud_get_value(HUD_DISPLAY_FLAGS) & ~HUD_DISPLAY_FLAG_LIVES) + if not hud_get_element(HUD_DISPLAY_FLAG_LIVES) then return end + local x = 22 local y = 15 -- SCREEN_HEIGHT - 209 - 16 local lifeIcon = characterTable[currChar].lifeIcon @@ -98,7 +129,8 @@ end local function render_hud_stars() hud_set_value(HUD_DISPLAY_FLAGS, hud_get_value(HUD_DISPLAY_FLAGS) & ~HUD_DISPLAY_FLAG_STAR_COUNT) - if IS_COOPDX and hud_get_flash ~= nil then + if not hud_get_element(HUD_DISPLAY_FLAG_STAR_COUNT) then return end + if hud_get_flash ~= nil then -- prevent star count from flashing outside of castle if gNetworkPlayers[0].currCourseNum ~= COURSE_NONE then hud_set_flash(0) end @@ -126,10 +158,12 @@ local function render_hud_stars() end local function render_hud_camera_status() - if not IS_COOPDX or not HUD_DISPLAY_CAMERA_STATUS then return end + if not HUD_DISPLAY_CAMERA_STATUS then return end hud_set_value(HUD_DISPLAY_FLAGS, hud_get_value(HUD_DISPLAY_FLAGS) & ~HUD_DISPLAY_FLAG_CAMERA) + if not hud_get_element(HUD_DISPLAY_FLAG_CAMERA) then return end + local x = djui_hud_get_screen_width() - 54 local y = 205 local cameraHudStatus = hud_get_value(HUD_DISPLAY_CAMERA_STATUS) @@ -165,23 +199,19 @@ local function render_hud_camera_status() }) end +-- Act Select Hud -- local function render_act_select_hud() - local course = gNetworkPlayers[0].currCourseNum + + local course, starBhvCount, sVisibleStars -- Localizing variables + + course = gNetworkPlayers[0].currCourseNum if gServerSettings.enablePlayersInLevelDisplay == 0 or course == 0 or obj_get_first_with_behavior_id(id_bhvActSelector) == nil then return end - local stars = save_file_get_star_flags(get_current_save_file_num() - 1, course - 1) - local maxStar = 0 - local wasLastActBeat = true -- True by default to account for 0 stars collected not needing an offset - for i = 5, 0, -1 do - if stars & 2 ^ i ~= 0 then - maxStar = i - wasLastActBeat = stars & 2^(i-1) ~= 0 - break - end - end + starBhvCount = count_objects_with_behavior(get_behavior_from_id(id_bhvActSelectorStarType)) + sVisibleStars = starBhvCount < 7 and starBhvCount or 6 - for a = 1, maxStar + 1 do - local x = (139 - (maxStar - (wasLastActBeat and 1 or 0) - (maxStar < 5 and 0 or 1) - (maxStar < 1 and 1 or 0)) * 17 + (a - (wasLastActBeat and 1 or 0)) * 34) + (djui_hud_get_screen_width()/2) - 176 + for a = 1, sVisibleStars do + local x = (139 - sVisibleStars * 17 + a * 34) + (djui_hud_get_screen_width() / 2) - 160 + 0.5 for j = 1, MAX_PLAYERS - 1 do -- 0 is not needed due to the due to the fact that you are never supposed to see yourself in the act local np = gNetworkPlayers[j] if np and np.connected and np.currCourseNum == course and np.currActNum == a then @@ -223,6 +253,5 @@ local function on_hud_render() end end - hook_event(HOOK_ON_HUD_RENDER_BEHIND, on_hud_render_behind) hook_event(HOOK_ON_HUD_RENDER, on_hud_render) \ No newline at end of file diff --git a/mods/character-select-coop/o-api.lua b/mods/character-select-coop/o-api.lua index f1af4b63..088250c4 100644 --- a/mods/character-select-coop/o-api.lua +++ b/mods/character-select-coop/o-api.lua @@ -343,6 +343,11 @@ _G.charSelect = { character_get_life_icon = life_icon_from_local_index, -- Function located in n-hud.lua character_get_star_icon = star_icon_from_local_index, -- Function located in n-hud.lua + -- Hud Element Functions -- + hud_hide_element = hud_hide_element, + hud_show_element = hud_show_element, + hud_get_element = hud_get_element, + -- Menu Functions -- header_set_texture = header_set_texture, -- Function located in main.lua version_get = version_get, diff --git a/mods/character-select-coop/z-voice.lua b/mods/character-select-coop/z-voice.lua index 497babbe..498c0bac 100644 --- a/mods/character-select-coop/z-voice.lua +++ b/mods/character-select-coop/z-voice.lua @@ -125,7 +125,7 @@ local function custom_character_snore(m) local animFrame = m.marioObj.header.gfx.animInfo.animFrame if snoreTable ~= nil and #snoreTable >= 2 then if animFrame == 2 and m.actionTimer < SLEEP_TALK_START then - play_custom_character_sound(m, snoreTable[2]) + custom_character_sound(m, snoreTable[2]) elseif animFrame == 25 then if #snoreTable >= 3 then m.actionTimer = m.actionTimer + 1