Character Select v1.7

This commit is contained in:
Agent X 2024-03-09 14:23:25 -05:00
parent 48360c05ad
commit 8cccd6bf69
9 changed files with 399 additions and 196 deletions

View file

@ -1,3 +1,17 @@
MOD_VERSION = "1.7"
IS_COOPDX = get_coop_compatibility_enabled ~= nil
ommActive = false
for i in pairs(gActiveMods) do
if gActiveMods[i].relativePath == "omm-coop" then
ommActive = true
break
end
end
-- localize functions to improve performance
local string_lower,table_insert = string.lower,table.insert
local saveableCharacters = { local saveableCharacters = {
["1"] = true, ["1"] = true,
["2"] = true, ["2"] = true,
@ -43,51 +57,49 @@ local saveableCharacters = {
[" "] = false, [" "] = false,
} }
--- @param string string
--- Replaces underscores in the string with spaces
function string_underscore_to_space(string) function string_underscore_to_space(string)
local s = '' if string == nil then return "" end
for i = 1, #string do return string:gsub("_", " ")
local c = string:sub(i,i)
if c ~= '_' then
s = s .. c
else
s = s .. " "
end
end
return s
end end
--- @param string string
--- Constructs a new string but only with characters from `saveableCharacters`
--- * Spaces are the notable character that gets turned into an underscore
function string_space_to_underscore(string) function string_space_to_underscore(string)
local s = '' local s = ''
for i = 1, #string do for i = 1, #string do
local c = string:sub(i,i) local c = string:sub(i,i)
if saveableCharacters[string.lower(c)] then if saveableCharacters[string_lower(c)] then
s = s .. c s = s .. c
elseif saveableCharacters[string.lower(c)] ~= nil then elseif saveableCharacters[string_lower(c)] ~= nil then
s = s .. "_" s = s .. "_"
end end
end end
return s return s
end end
function string_split(s) --- @param string string
--- Splits a string into a table by spaces
function string_split(string)
local result = {} local result = {}
for match in (s):gmatch(string.format("[^%s]+", " ")) do for match in string:gmatch(string.format("[^%s]+", " ")) do
table.insert(result, match) table_insert(result, match)
end end
return result return result
end end
client_is_coop_dx = get_coop_compatibility_enabled ~= nil -- Checks if Client is DX --- @param param number
-- network_is_coop_dx = SM64COOPDX_VERSION ~= nil -- Checks if Coop Compatibility is Off (As of now unused) --- @param caseTable table
--- Switch statement function
ommActive = false function switch(param, caseTable)
for i in pairs(gActiveMods) do local case = caseTable[param]
local name = gActiveMods[i].name if case then return case() end
if (name:find("OMM Rebirth")) then local def = caseTable['default']
ommActive = true return def and def() or nil
end
end end
modVersion = "1.6.1"
allowMenu = {} allowMenu = {}
renderInMenuTable = {}

View file

@ -1,6 +1,8 @@
-- name: Character Select -- name: Character Select
-- description:\\#ffff33\\--- Character Select Coop v1.6.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 and Packs can be found on\nCharacter Select's Github:\n\\#6666FF\\Squishy6094/character-select-coop -- description:\\#ffff33\\---- Character Select Coop v1.7 ----\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 and Packs can be found on\nCharacter Select's Github:\n\\#6666FF\\Squishy6094/character-select-coop
-- localize functions to improve performance
local mod_storage_load,tonumber,djui_popup_create,mod_storage_save,tostring,djui_chat_message_create,camera_freeze,hud_hide,vec3f_copy,set_mario_action,set_mario_animation,camera_unfreeze,hud_show,obj_has_behavior_id,network_local_index_from_global,obj_has_model_extended,obj_set_model_extended,get_id_from_behavior,nearest_player_to_object,math_random,djui_hud_set_resolution,djui_hud_set_font,djui_hud_get_screen_width,maxf,djui_hud_set_color,djui_hud_render_rect,djui_hud_measure_text,djui_hud_print_text,math_ceil,math_abs,math_sin,min,math_min,minf,djui_hud_set_rotation,djui_hud_is_pause_menu_created,is_game_paused,hud_is_hidden,obj_get_first_with_behavior_id,hud_get_value,hud_set_value,play_sound,string_lower = mod_storage_load,tonumber,djui_popup_create,mod_storage_save,tostring,djui_chat_message_create,camera_freeze,hud_hide,vec3f_copy,set_mario_action,set_mario_animation,camera_unfreeze,hud_show,obj_has_behavior_id,network_local_index_from_global,obj_has_model_extended,obj_set_model_extended,get_id_from_behavior,nearest_player_to_object,math.random,djui_hud_set_resolution,djui_hud_set_font,djui_hud_get_screen_width,maxf,djui_hud_set_color,djui_hud_render_rect,djui_hud_measure_text,djui_hud_print_text,math.ceil,math.abs,math.sin,min,math.min,minf,djui_hud_set_rotation,djui_hud_is_pause_menu_created,is_game_paused,hud_is_hidden,obj_get_first_with_behavior_id,hud_get_value,hud_set_value,play_sound,string.lower
local menu = false local menu = false
menuAndTransition = false menuAndTransition = false
@ -10,9 +12,15 @@ local currOption = 1
local menuCrossFade = 7 local menuCrossFade = 7
local menuCrossFadeCap = menuCrossFade local menuCrossFadeCap = menuCrossFade
local menuCrossFadeMath = 255/menuCrossFade local menuCrossFadeMath = 255 / menuCrossFade
local TEX_HEADER = get_texture_info("char-select-text") local TEX_HEADER = get_texture_info("char-select-text")
local TEX_OVERRIDE_HEADER = nil
---@param texture TextureInfo|nil
function header_set_texture(texture)
TEX_OVERRIDE_HEADER = texture
end
local TEXT_PREF_LOAD = "Default" local TEXT_PREF_LOAD = "Default"
@ -23,7 +31,7 @@ local TEXT_PREF_LOAD = "Default"
to use for anyone and low on file space! to use for anyone and low on file space!
]] ]]
characterTable = { characterTable = {
[1] = { [1] = {
name = "Default", name = "Default",
saveName = "Default", saveName = "Default",
description = {"The vanilla cast for sm64ex-coop!", "", "These Characters are swappable", "via the default Options Menu"}, description = {"The vanilla cast for sm64ex-coop!", "", "These Characters are swappable", "via the default Options Menu"},
@ -32,11 +40,13 @@ characterTable = {
model = nil, model = nil,
forceChar = nil, forceChar = nil,
lifeIcon = gTextures.mario_head, lifeIcon = gTextures.mario_head,
starIcon = gTextures.star,
camScale = 1.0 camScale = 1.0
}, },
} }
characterCaps = {} characterCaps = {}
characterCelebrationStar = {}
optionTableRef = { optionTableRef = {
openInputs = 1, openInputs = 1,
@ -47,7 +57,7 @@ optionTableRef = {
localModels = 6, localModels = 6,
localVoices = 7, localVoices = 7,
debugInfo = 8, debugInfo = 8,
resetSaveData = 9, resetSaveData = 9
} }
optionTable = { optionTable = {
@ -84,6 +94,7 @@ optionTable = {
toggleSaveName = "Anims", toggleSaveName = "Anims",
toggleDefault = 1, toggleDefault = 1,
toggleMax = 1, toggleMax = 1,
toggleNames = {"Off", "On"--[[, "On (30 fps)"]]},
description = {"Toggles Animations In-Menu,", "Turning these off may", "Save Performance"} description = {"Toggles Animations In-Menu,", "Turning these off may", "Save Performance"}
}, },
[optionTableRef.inputLatency] = { [optionTableRef.inputLatency] = {
@ -134,15 +145,15 @@ local optionTableCount = #optionTable
local latencyValueTable = {12, 6, 3} local latencyValueTable = {12, 6, 3}
local menuColorTable = { local menuColorTable = {
{r = 255, g = 50, b = 50 }, { r = 255, g = 50, b = 50 },
{r = 255, g = 100, b = 50 }, { r = 255, g = 100, b = 50 },
{r = 255, g = 255, b = 50 }, { r = 255, g = 255, b = 50 },
{r = 50, g = 255, b = 50 }, { r = 50, g = 255, b = 50 },
{r = 50, g = 50, b = 255}, { r = 50, g = 50, b = 255 },
{r = 251, g = 148, b = 220}, { r = 251, g = 148, b = 220 },
{r = 130, g = 25, b = 130}, { r = 130, g = 25, b = 130 },
{r = 255, g = 255, b = 255}, { r = 255, g = 255, b = 255 },
{r = 50, g = 50, b = 50 }, { r = 50, g = 50, b = 50 }
} }
-- Default Player Adjustments -- Default Player Adjustments
@ -151,45 +162,37 @@ local defaultNames = {
[CT_LUIGI] = "Luigi", [CT_LUIGI] = "Luigi",
[CT_TOAD] = "Toad", [CT_TOAD] = "Toad",
[CT_WALUIGI] = "Waluigi", [CT_WALUIGI] = "Waluigi",
[CT_WARIO] = "Wario", [CT_WARIO] = "Wario"
} }
local defaultPlayerColors = { local defaultPlayerColors = {
[CT_MARIO] = menuColorTable[1], [CT_MARIO] = menuColorTable[1],
[CT_LUIGI] = menuColorTable[4], [CT_LUIGI] = menuColorTable[4],
[CT_TOAD] = menuColorTable[5], [CT_TOAD] = menuColorTable[5],
[CT_WALUIGI] = menuColorTable[7], [CT_WALUIGI] = menuColorTable[7],
[CT_WARIO] = menuColorTable[3], [CT_WARIO] = menuColorTable[3]
} }
local defaultForceChar = { local defaultForceChar = {
[CT_MARIO] = "CT_MARIO", [CT_MARIO] = "CT_MARIO",
[CT_LUIGI] = "CT_LUIGI", [CT_LUIGI] = "CT_LUIGI",
[CT_TOAD] = "CT_TOAD", [CT_TOAD] = "CT_TOAD",
[CT_WALUIGI] = "CT_WALUIGI", [CT_WALUIGI] = "CT_WALUIGI",
[CT_WARIO] = "CT_WARIO", [CT_WARIO] = "CT_WARIO"
} }
local defaultIcons = { local defaultIcons = {
[CT_MARIO] = gTextures.mario_head, [CT_MARIO] = gTextures.mario_head,
[CT_LUIGI] = gTextures.luigi_head, [CT_LUIGI] = gTextures.luigi_head,
[CT_TOAD] = gTextures.toad_head, [CT_TOAD] = gTextures.toad_head,
[CT_WALUIGI] = gTextures.waluigi_head, [CT_WALUIGI] = gTextures.waluigi_head,
[CT_WARIO] = gTextures.wario_head, [CT_WARIO] = gTextures.wario_head
} }
local defaultCamScales = { local defaultCamScales = {
[CT_MARIO] = 1, [CT_MARIO] = 1,
[CT_LUIGI] = 1, [CT_LUIGI] = 1,
[CT_TOAD] = 0.8, [CT_TOAD] = 0.8,
[CT_WALUIGI] = 1.1, [CT_WALUIGI] = 1.1,
[CT_WARIO] = 1, [CT_WARIO] = 1
} }
-- "localize functions to improve performance" 🔥🔥🔥
local camera_freeze, camera_unfreeze, network_local_index_from_global, obj_set_model_extended, hud_hide, hud_show, djui_chat_message_create,
djui_hud_set_resolution, djui_hud_set_font, djui_hud_set_color, djui_hud_get_screen_width, djui_hud_render_rect, djui_hud_print_text,
djui_hud_render_texture, math_max, math_min, math_sin, math_random, math_abs, math_ceil, play_sound, mod_storage_save, mod_storage_load, string_lower =
camera_freeze, camera_unfreeze, network_local_index_from_global, obj_set_model_extended, hud_hide, hud_show, djui_chat_message_create,
djui_hud_set_resolution, djui_hud_set_font, djui_hud_set_color, djui_hud_get_screen_width, djui_hud_render_rect, djui_hud_print_text,
djui_hud_render_texture, math.max, math.min, math.sin, math.random, math.abs, math.ceil, play_sound, mod_storage_save, mod_storage_load, string.lower
---@param m MarioState ---@param m MarioState
local function nullify_inputs(m) local function nullify_inputs(m)
local c = m.controller local c = m.controller
@ -219,21 +222,22 @@ local prefCharColor = defaultPlayerColors[CT_MARIO]
local function load_preferred_char() local function load_preferred_char()
local savedChar = mod_storage_load("PrefChar") local savedChar = mod_storage_load("PrefChar")
if savedChar == nil or savedChar == "" then
mod_storage_save("PrefChar", "Default")
savedChar = "Default"
end
if savedChar ~= nil and savedChar ~= "Default" then if savedChar ~= nil and savedChar ~= "Default" then
for i = 2, #characterTable do for i = 2, #characterTable do
if characterTable[i].saveName == savedChar then if characterTable[i].saveName == savedChar then
currChar = i currChar = i
if optionTable[optionTableRef.localModels].toggle == 1 then if optionTable[optionTableRef.localModels].toggle == 1 then
if optionTable[optionTableRef.notification].toggle > 0 then if optionTable[optionTableRef.notification].toggle > 0 then
djui_popup_create('Character Select:\nYour Preferred Character\n"'..string_underscore_to_space(characterTable[i].name)..'"\nwas applied successfully!', 4) djui_popup_create('Character Select:\nYour Preferred Character\n"' .. string_underscore_to_space(characterTable[i].name) .. '"\nwas applied successfully!', 4)
end end
end end
break break
end end
end end
elseif savedChar == nil then
mod_storage_save("PrefChar", "Default")
savedChar = "Default"
end end
local savedCharColors = mod_storage_load("PrefCharColor") local savedCharColors = mod_storage_load("PrefCharColor")
@ -253,12 +257,12 @@ local function load_preferred_char()
djui_popup_create("Character Select:\nNo Characters were Found", 2) djui_popup_create("Character Select:\nNo Characters were Found", 2)
end end
end end
TEXT_PREF_LOAD = savedChar return savedChar
end end
local function mod_storage_save_pref_char(charTable) local function mod_storage_save_pref_char(charTable)
mod_storage_save("PrefChar", charTable.saveName) mod_storage_save("PrefChar", charTable.saveName)
mod_storage_save("PrefCharColor", tostring(charTable.color.r).."_"..tostring(charTable.color.g).."_"..tostring(charTable.color.b)) mod_storage_save("PrefCharColor", tostring(charTable.color.r) .. "_" .. tostring(charTable.color.g) .. "_" .. tostring(charTable.color.b))
TEXT_PREF_LOAD = charTable.saveName TEXT_PREF_LOAD = charTable.saveName
prefCharColor = charTable.color prefCharColor = charTable.color
end end
@ -284,7 +288,7 @@ local promptedAreYouSure = false
local function reset_options(wasChatTriggered) local function reset_options(wasChatTriggered)
if not promptedAreYouSure then if not promptedAreYouSure then
djui_chat_message_create("\\#ffdcdc\\Are you sure you want to reset your Save Data for Character Select, including your Preferred Character\nand Settings?\n".. (wasChatTriggered and "Type \\#ff3333\\/char-select reset\\#ffdcdc\\ to confirm." or "Press the \\#ff3333\\"..optionTable[optionTableRef.resetSaveData].name.."\\#ffdcdc\\ Option again to confirm." )) djui_chat_message_create("\\#ffdcdc\\Are you sure you want to reset your Save Data for Character Select, including your Preferred Character\nand Settings?\n" .. (wasChatTriggered and "Type \\#ff3333\\/char-select reset\\#ffdcdc\\ to confirm." or "Press the \\#ff3333\\" .. optionTable[optionTableRef.resetSaveData].name .. "\\#ffdcdc\\ Option again to confirm." ))
promptedAreYouSure = true promptedAreYouSure = true
else else
djui_chat_message_create("\\#ff3333\\Character Select Save Data Reset!") djui_chat_message_create("\\#ff3333\\Character Select Save Data Reset!")
@ -295,7 +299,7 @@ local function reset_options(wasChatTriggered)
mod_storage_save(optionTable[i].toggleSaveName, tostring(optionTable[i].toggle)) mod_storage_save(optionTable[i].toggleSaveName, tostring(optionTable[i].toggle))
end end
if optionTable[i].toggleNames == nil then if optionTable[i].toggleNames == nil then
optionTable[i].toggleNames = {"Off", "On"} optionTable[i].toggleNames = { "Off", "On" }
end end
end end
mod_storage_save_pref_char(characterTable[1]) mod_storage_save_pref_char(characterTable[1])
@ -303,17 +307,14 @@ local function reset_options(wasChatTriggered)
end end
end end
local function boot_note() local function boot_note()
if #characterTable > 1 then if #characterTable > 1 then
djui_chat_message_create("Character Select has "..(#characterTable - 1).." character"..(#characterTable > 2 and "s" or "").." available!\nYou can use \\#ffff33\\/char-select \\#ffffff\\to open the menu!") djui_chat_message_create("Character Select has " .. (#characterTable - 1) .. " character" .. (#characterTable > 2 and "s" or "") .. " available!\nYou can use \\#ffff33\\/char-select \\#ffffff\\to open the menu!")
else else
djui_chat_message_create("Character Select is active!\nYou can use \\#ffff33\\/char-select \\#ffffff\\to open the menu!") djui_chat_message_create("Character Select is active!\nYou can use \\#ffff33\\/char-select \\#ffffff\\to open the menu!")
end end
if not client_is_coop_dx then if not IS_COOPDX then
djui_chat_message_create("\\#FFAAAA\\Note: Although not required, we highly reccomend\nusing SM64CoopDX when playing Character Select!\n\\#6666FF\\https://sm64coopdx.com") djui_chat_message_create("\\#FFAAAA\\Note: Although not required, we highly reccomend\nusing SM64CoopDX when playing Character Select!\n\\#6666FF\\https://sm64coopdx.com")
end end
end end
@ -327,12 +328,10 @@ local noLoop = false
local CUTSCENE_CS_MENU = 0xFA local CUTSCENE_CS_MENU = 0xFA
-- Respecfully, GO FUCK YOURSELVES. I hate EVERY SINGLE ONE OF YOU. Your lives are NOTHING. You serve ZERO PURPOSE. You should kill yourselves, NOW! local ignoredSurfaces = {
local ignored_surfaces = {
SURFACE_BURNING, SURFACE_QUICKSAND, SURFACE_INSTANT_QUICKSAND, SURFACE_INSTANT_MOVING_QUICKSAND, SURFACE_DEEP_MOVING_QUICKSAND, SURFACE_INSTANT_QUICKSAND, SURFACE_DEEP_QUICKSAND, SURFACE_SHALLOW_MOVING_QUICKSAND, SURFACE_BURNING, SURFACE_QUICKSAND, SURFACE_INSTANT_QUICKSAND, SURFACE_INSTANT_MOVING_QUICKSAND, SURFACE_DEEP_MOVING_QUICKSAND, SURFACE_INSTANT_QUICKSAND, SURFACE_DEEP_QUICKSAND, SURFACE_SHALLOW_MOVING_QUICKSAND,
SURFACE_SHALLOW_QUICKSAND, SURFACE_WARP, SURFACE_LOOK_UP_WARP, SURFACE_WOBBLING_WARP, SURFACE_INSTANT_WARP_1B, SURFACE_INSTANT_WARP_1C, SURFACE_INSTANT_WARP_1D, SURFACE_INSTANT_WARP_1E SURFACE_SHALLOW_QUICKSAND, SURFACE_WARP, SURFACE_LOOK_UP_WARP, SURFACE_WOBBLING_WARP, SURFACE_INSTANT_WARP_1B, SURFACE_INSTANT_WARP_1C, SURFACE_INSTANT_WARP_1D, SURFACE_INSTANT_WARP_1E
} }
-- Yes, floral gave me permission to use this table full of USELESS PIECES OF SHITS
local menuActBlacklist = { local menuActBlacklist = {
-- Star Acts -- Star Acts
@ -346,6 +345,11 @@ local menuActBlacklist = {
-- Cutscene Acts -- Cutscene Acts
[ACT_INTRO_CUTSCENE] = true, [ACT_INTRO_CUTSCENE] = true,
[ACT_CREDITS_CUTSCENE] = true, [ACT_CREDITS_CUTSCENE] = true,
[ACT_WARP_DOOR_SPAWN] = true,
[ACT_PULLING_DOOR] = true,
[ACT_PUSHING_DOOR] = true,
[ACT_UNLOCKING_KEY_DOOR] = true,
[ACT_UNLOCKING_STAR_DOOR] = true,
-- Dialog Acts -- Dialog Acts
[ACT_READING_NPC_DIALOG] = true, [ACT_READING_NPC_DIALOG] = true,
[ACT_WAITING_FOR_DIALOG] = true, [ACT_WAITING_FOR_DIALOG] = true,
@ -359,7 +363,7 @@ local faceAngle = 0
local function mario_update(m) local function mario_update(m)
if stallFrame == 1 then if stallFrame == 1 then
failsafe_options() failsafe_options()
load_preferred_char() TEXT_PREF_LOAD = load_preferred_char()
if optionTable[optionTableRef.notification].toggle == 1 then if optionTable[optionTableRef.notification].toggle == 1 then
boot_note() boot_note()
end end
@ -368,7 +372,7 @@ local function mario_update(m)
if stallFrame < 2 then if stallFrame < 2 then
stallFrame = stallFrame + 1 stallFrame = stallFrame + 1
end end
if m.playerIndex == 0 and stallFrame > 1 then if m.playerIndex == 0 and stallFrame > 1 then
local modelIndex = gNetworkPlayers[m.playerIndex].modelIndex local modelIndex = gNetworkPlayers[m.playerIndex].modelIndex
characterTable[1].forceChar = modelIndex characterTable[1].forceChar = modelIndex
@ -414,7 +418,7 @@ local function mario_update(m)
gLakituState.pos.y = m.pos.y + 100 * camScale gLakituState.pos.y = m.pos.y + 100 * camScale
gLakituState.pos.z = m.pos.z + coss(faceAngle) * 500 * camScale gLakituState.pos.z = m.pos.z + coss(faceAngle) * 500 * camScale
if m.forwardVel == 0 and m.pos.y == m.floorHeight and not ignored_surfaces[m.floor.type] and m.health > 255 and not menuActBlacklist[m.action] then if m.forwardVel == 0 and m.pos.y == m.floorHeight and not ignoredSurfaces[m.floor.type] and m.health > 255 and not menuActBlacklist[m.action] then
set_mario_action(m, ACT_IDLE, 0) set_mario_action(m, ACT_IDLE, 0)
set_mario_animation(m, MARIO_ANIM_FIRST_PERSON) set_mario_animation(m, MARIO_ANIM_FIRST_PERSON)
end end
@ -439,21 +443,44 @@ local function mario_update(m)
end end
end end
local sCapBhvs = {
[id_bhvWingCap] = true,
[id_bhvVanishCap] = true,
[id_bhvMetalCap] = true
}
--- @param o Object
--- @param model integer
function set_model(o, model) function set_model(o, model)
local i = network_local_index_from_global(o.globalPlayerIndex)
if obj_has_behavior_id(o, id_bhvMario) ~= 0 then if obj_has_behavior_id(o, id_bhvMario) ~= 0 then
local i = network_local_index_from_global(o.globalPlayerIndex)
if gPlayerSyncTable[i].modelId ~= nil and obj_has_model_extended(o, gPlayerSyncTable[i].modelId) == 0 then if gPlayerSyncTable[i].modelId ~= nil and obj_has_model_extended(o, gPlayerSyncTable[i].modelId) == 0 then
obj_set_model_extended(o, gPlayerSyncTable[i].modelId) obj_set_model_extended(o, gPlayerSyncTable[i].modelId)
return end end
return
end end
if obj_has_behavior_id(o, id_bhvCelebrationStar) ~= 0 and o.parentObj ~= nil then
local i = network_local_index_from_global(o.parentObj.globalPlayerIndex)
local starModel = characterCelebrationStar[gPlayerSyncTable[i].modelId]
if gPlayerSyncTable[i].modelId ~= nil and starModel ~= nil and obj_has_model_extended(o, starModel) == 0 then
obj_set_model_extended(o, starModel)
end
return
end
if sCapBhvs[get_id_from_behavior(o.behavior)] then
o.globalPlayerIndex = nearest_player_to_object(o.parentObj).globalPlayerIndex
end
local i = network_local_index_from_global(o.globalPlayerIndex)
local c = gMarioStates[i].character local c = gMarioStates[i].character
if model == c.capModelId or if model == c.capModelId or
model == c.capWingModelId or model == c.capWingModelId or
model == c.capMetalModelId or model == c.capMetalModelId or
model == c.capMetalWingModelId then model == c.capMetalWingModelId then
local capModels = characterCaps[gPlayerSyncTable[i].modelId] local capModels = characterCaps[gPlayerSyncTable[i].modelId]
local capModel = nil
if capModels ~= nil then if capModels ~= nil then
local capModel = E_MODEL_NONE
if model == c.capModelId then if model == c.capModelId then
capModel = capModels.normal capModel = capModels.normal
elseif model == c.capWingModelId then elseif model == c.capWingModelId then
@ -463,9 +490,9 @@ function set_model(o, model)
elseif model == c.capMetalWingModelId then elseif model == c.capMetalWingModelId then
capModel = capModels.metalWing capModel = capModels.metalWing
end end
if capModel ~= nil and obj_has_model_extended(o, capModel) == 0 then if capModel ~= E_MODEL_NONE then
obj_set_model_extended(o, capModel) obj_set_model_extended(o, capModel)
return end end
end end
end end
end end
@ -490,11 +517,11 @@ local inputStallToDirectional = 12
local inputStallToButton = 10 local inputStallToButton = 10
-- Font Consistency between sm64ex-coop and sm64coopdx -- Font Consistency between sm64ex-coop and sm64coopdx
local FONT_CS_NORMAL = client_is_coop_dx and FONT_ALIASED or FONT_NORMAL local FONT_CS_NORMAL = IS_COOPDX and FONT_ALIASED or FONT_NORMAL
--Basic Menu Text --Basic Menu Text
local TEXT_OPTIONS_HEADER = "Menu Options" local TEXT_OPTIONS_HEADER = "Menu Options"
local TEXT_VERSION = "Version: "..modVersion..(client_is_coop_dx and " | sm64coopdx" or " | sm64ex-coop") local TEXT_VERSION = "Version: " .. MOD_VERSION .. (IS_COOPDX and " | sm64coopdx" or " | sm64ex-coop")
local TEXT_RATIO_UNSUPPORTED = "Your Current Aspect-Ratio isn't Supported!" local TEXT_RATIO_UNSUPPORTED = "Your Current Aspect-Ratio isn't Supported!"
local TEXT_DESCRIPTION = "Character Description:" local TEXT_DESCRIPTION = "Character Description:"
local TEXT_PREF_SAVE = "Press A to Set as Preferred Character" local TEXT_PREF_SAVE = "Press A to Set as Preferred Character"
@ -522,6 +549,7 @@ local TEXT_LOCAL_MODEL_OFF_OPTIONS = "You can turn it back on in the Options Men
local menuColor = characterTable[currChar].color local menuColor = characterTable[currChar].color
local MATH_DIVIDE_THREE_HUNDRED_TWENTY = 1/320 local MATH_DIVIDE_THREE_HUNDRED_TWENTY = 1/320
local MATH_DIVIDE_THIRTY_TWO = 1/32
local function on_hud_render() local function on_hud_render()
djui_hud_set_resolution(RESOLUTION_N64) djui_hud_set_resolution(RESOLUTION_N64)
@ -529,15 +557,15 @@ local function on_hud_render()
local width = djui_hud_get_screen_width() + 1.4 local width = djui_hud_get_screen_width() + 1.4
local height = 240 local height = 240
local widthHalf = width*0.5 local widthHalf = width * 0.5
local heightHalf = height*0.5 local heightHalf = height * 0.5
local widthScale = math_max(width, 321.4)*MATH_DIVIDE_THREE_HUNDRED_TWENTY local widthScale = maxf(width, 321.4) * MATH_DIVIDE_THREE_HUNDRED_TWENTY
if menuAndTransition then if menuAndTransition then
if optionTable[optionTableRef.menuColor].toggle > 1 then if optionTable[optionTableRef.menuColor].toggle > 1 then
menuColor = menuColorTable[optionTable[optionTableRef.menuColor].toggle - 1] menuColor = menuColorTable[optionTable[optionTableRef.menuColor].toggle - 1]
elseif optionTable[optionTableRef.menuColor].toggle == 1 then elseif optionTable[optionTableRef.menuColor].toggle == 1 then
optionTable[optionTableRef.menuColor].toggleNames[2] = string_underscore_to_space(TEXT_PREF_LOAD).." (Pref)" optionTable[optionTableRef.menuColor].toggleNames[2] = string_underscore_to_space(TEXT_PREF_LOAD) .. " (Pref)"
menuColor = prefCharColor menuColor = prefCharColor
else else
menuColor = characterTable[currChar].color menuColor = characterTable[currChar].color
@ -547,10 +575,10 @@ local function on_hud_render()
djui_hud_set_color(0, 0, 0, 200) djui_hud_set_color(0, 0, 0, 200)
djui_hud_render_rect(0, 0, width, height) djui_hud_render_rect(0, 0, width, height)
djui_hud_set_color(255, 255, 255, 255) djui_hud_set_color(255, 255, 255, 255)
djui_hud_print_text(TEXT_LOCAL_MODEL_OFF, widthHalf - djui_hud_measure_text(TEXT_LOCAL_MODEL_OFF)*0.15*widthScale, heightHalf, 0.3 * widthScale) djui_hud_print_text(TEXT_LOCAL_MODEL_OFF, widthHalf - djui_hud_measure_text(TEXT_LOCAL_MODEL_OFF) * 0.15 * widthScale, heightHalf, 0.3 * widthScale)
djui_hud_print_text(TEXT_LOCAL_MODEL_OFF_OPTIONS, widthHalf - djui_hud_measure_text(TEXT_LOCAL_MODEL_OFF_OPTIONS)*0.1*widthScale, heightHalf + 10*widthScale, 0.2*widthScale) djui_hud_print_text(TEXT_LOCAL_MODEL_OFF_OPTIONS, widthHalf - djui_hud_measure_text(TEXT_LOCAL_MODEL_OFF_OPTIONS) * 0.1 * widthScale, heightHalf + 10 * widthScale, 0.2 * widthScale)
end end
local x = 135 * widthScale * 0.8 local x = 135 * widthScale * 0.8
--Character Description --Character Description
@ -563,57 +591,58 @@ local function on_hud_render()
local character = characterTable[currChar] local character = characterTable[currChar]
if optionTable[optionTableRef.debugInfo].toggle == 0 then -- Actual Description if optionTable[optionTableRef.debugInfo].toggle == 0 then -- Actual Description
local TEXT_NAME = string_underscore_to_space(character.name) local TEXT_NAME = string_underscore_to_space(character.name)
local TEXT_CREDIT = "Credit: "..character.credit local TEXT_CREDIT = "Credit: " .. character.credit
local TEXT_DESCRIPTION_TABLE = character.description local TEXT_DESCRIPTION_TABLE = character.description
local TEXT_PREF = "Preferred Character:" local TEXT_PREF = "Preferred Character:"
if djui_hud_measure_text(string_underscore_to_space(TEXT_PREF_LOAD)) / widthScale > 110 then local TEXT_PREF_LOAD = string_underscore_to_space(TEXT_PREF_LOAD)
if djui_hud_measure_text(TEXT_PREF_LOAD) / widthScale > 110 then
TEXT_PREF = "Preferred Char:" TEXT_PREF = "Preferred Char:"
end end
if djui_hud_measure_text(string_underscore_to_space(TEXT_PREF_LOAD)) / widthScale > 164 then if djui_hud_measure_text(TEXT_PREF_LOAD) / widthScale > 164 then
TEXT_PREF = "Pref Char:" TEXT_PREF = "Pref Char:"
end end
TEXT_PREF = TEXT_PREF..' "'..string_underscore_to_space(TEXT_PREF_LOAD)..'"' TEXT_PREF = TEXT_PREF .. ' "' .. TEXT_PREF_LOAD .. '"'
local textX = x * 0.5 local textX = x * 0.5
djui_hud_print_text(TEXT_NAME, width - textX - djui_hud_measure_text(TEXT_NAME)*0.3, 55, 0.6) djui_hud_print_text(TEXT_NAME, width - textX - djui_hud_measure_text(TEXT_NAME) * 0.3, 55, 0.6)
djui_hud_set_font(FONT_TINY) djui_hud_set_font(FONT_TINY)
djui_hud_print_text(TEXT_CREDIT, width - textX - djui_hud_measure_text(TEXT_CREDIT)*0.3, 74, 0.6) djui_hud_print_text(TEXT_CREDIT, width - textX - djui_hud_measure_text(TEXT_CREDIT) * 0.3, 74, 0.6)
djui_hud_set_font(FONT_CS_NORMAL) djui_hud_set_font(FONT_CS_NORMAL)
djui_hud_print_text(TEXT_DESCRIPTION, width - textX - djui_hud_measure_text(TEXT_DESCRIPTION)*0.2, 85, 0.4) djui_hud_print_text(TEXT_DESCRIPTION, width - textX - djui_hud_measure_text(TEXT_DESCRIPTION) * 0.2, 85, 0.4)
if widthScale < 1.65 then if widthScale < 1.65 then
for i = 1, #TEXT_DESCRIPTION_TABLE do for i = 1, #TEXT_DESCRIPTION_TABLE do
djui_hud_print_text(TEXT_DESCRIPTION_TABLE[i], width - textX - djui_hud_measure_text(TEXT_DESCRIPTION_TABLE[i])*0.15, 90 + i*9, 0.3) djui_hud_print_text(TEXT_DESCRIPTION_TABLE[i], width - textX - djui_hud_measure_text(TEXT_DESCRIPTION_TABLE[i]) * 0.15, 90 + i * 9, 0.3)
end end
else else
for i = 1, math_ceil(#TEXT_DESCRIPTION_TABLE*0.5) do for i = 1, math_ceil(#TEXT_DESCRIPTION_TABLE*0.5) do
local TablePos = (i * 2) - 1 local tablePos = (i * 2) - 1
if TEXT_DESCRIPTION_TABLE[TablePos] and TEXT_DESCRIPTION_TABLE[TablePos + 1] then if TEXT_DESCRIPTION_TABLE[tablePos] and TEXT_DESCRIPTION_TABLE[tablePos + 1] then
local TEXT_STRING = TEXT_DESCRIPTION_TABLE[TablePos].." "..TEXT_DESCRIPTION_TABLE[TablePos + 1] local TEXT_STRING = TEXT_DESCRIPTION_TABLE[tablePos] .. " " .. TEXT_DESCRIPTION_TABLE[tablePos + 1]
djui_hud_print_text(TEXT_STRING, width - textX - djui_hud_measure_text(TEXT_STRING)*0.15, 90 + i*9, 0.3) djui_hud_print_text(TEXT_STRING, width - textX - djui_hud_measure_text(TEXT_STRING) * 0.15, 90 + i * 9, 0.3)
elseif TEXT_DESCRIPTION_TABLE[TablePos] then elseif TEXT_DESCRIPTION_TABLE[tablePos] then
local TEXT_STRING = TEXT_DESCRIPTION_TABLE[TablePos] local TEXT_STRING = TEXT_DESCRIPTION_TABLE[tablePos]
djui_hud_print_text(TEXT_STRING, width - textX - djui_hud_measure_text(TEXT_STRING)*0.15, 90 + i*9, 0.3) djui_hud_print_text(TEXT_STRING, width - textX - djui_hud_measure_text(TEXT_STRING) * 0.15, 90 + i * 9, 0.3)
end end
end end
end end
djui_hud_print_text(TEXT_PREF, width - textX - djui_hud_measure_text(TEXT_PREF)*0.15, height - 22, 0.3) djui_hud_print_text(TEXT_PREF, width - textX - djui_hud_measure_text(TEXT_PREF) * 0.15, height - 22, 0.3)
djui_hud_set_font(FONT_TINY) djui_hud_set_font(FONT_TINY)
djui_hud_print_text(TEXT_PREF_SAVE, width - textX - djui_hud_measure_text(TEXT_PREF_SAVE)*0.25, height - 13, 0.5) djui_hud_print_text(TEXT_PREF_SAVE, width - textX - djui_hud_measure_text(TEXT_PREF_SAVE) * 0.25, height - 13, 0.5)
else -- Debugging Info else -- Debugging Info
local TEXT_NAME = "Name: "..character.name local TEXT_NAME = "Name: " .. character.name
local TEXT_SAVE_NAME = "Save Name: "..character.saveName local TEXT_SAVE_NAME = "Save Name: " .. character.saveName
local TEXT_CREDIT = "Credit: "..character.credit local TEXT_CREDIT = "Credit: " .. character.credit
local TEXT_DESCRIPTION_TABLE = character.description local TEXT_DESCRIPTION_TABLE = character.description
local TEXT_COLOR = "Color: R-"..character.color.r..", G-"..character.color.g..", B-"..character.color.b local TEXT_COLOR = "Color: R-" .. character.color.r ..", G-" ..character.color.g ..", B-"..character.color.b
local TEX_ICON = character.lifeIcon local TEX_ICON = character.lifeIcon
local TEXT_ICON_DEFAULT = "?" local TEXT_ICON_DEFAULT = "?"
local TEXT_SCALE = "Camera Scale: "..character.camScale local TEXT_SCALE = "Camera Scale: " .. character.camScale
local TEXT_PREF = "Preferred: "..TEXT_PREF_LOAD local TEXT_PREF = "Preferred: " .. TEXT_PREF_LOAD
local TEXT_PREF_COLOR = "Pref Color: R-"..prefCharColor.r..", G-"..prefCharColor.g..", B-"..prefCharColor.b local TEXT_PREF_COLOR = "Pref Color: R-" .. prefCharColor.r .. ", G-" .. prefCharColor.g .. ", B-" .. prefCharColor.b
local textX = x * 0.5 local textX = x * 0.5
djui_hud_print_text(TEXT_DEBUGGING, width - textX - djui_hud_measure_text(TEXT_DEBUGGING)*0.3, 55, 0.6) djui_hud_print_text(TEXT_DEBUGGING, width - textX - djui_hud_measure_text(TEXT_DEBUGGING) * 0.3, 55, 0.6)
djui_hud_set_font(FONT_TINY) djui_hud_set_font(FONT_TINY)
djui_hud_print_text(TEXT_NAME, width - x + 8, 72, 0.6) djui_hud_print_text(TEXT_NAME, width - x + 8, 72, 0.6)
djui_hud_print_text(TEXT_SAVE_NAME, width - x + 8, 81, 0.6) djui_hud_print_text(TEXT_SAVE_NAME, width - x + 8, 81, 0.6)
@ -624,13 +653,13 @@ local function on_hud_render()
if TEXT_DESCRIPTION_TABLE[i] ~= "" then if TEXT_DESCRIPTION_TABLE[i] ~= "" then
djui_hud_set_font(FONT_CS_NORMAL) djui_hud_set_font(FONT_CS_NORMAL)
local TEXT_DESCRIPTION_LINE = TEXT_DESCRIPTION_TABLE[i] local TEXT_DESCRIPTION_LINE = TEXT_DESCRIPTION_TABLE[i]
if (djui_hud_measure_text(TEXT_DESCRIPTION_TABLE[i])*0.3 > 100) then if (djui_hud_measure_text(TEXT_DESCRIPTION_TABLE[i]) * 0.3 > 100) then
TEXT_DESCRIPTION_LINE = "(!) "..TEXT_DESCRIPTION_LINE TEXT_DESCRIPTION_LINE = "(!) " .. TEXT_DESCRIPTION_LINE
else else
TEXT_DESCRIPTION_LINE = " "..TEXT_DESCRIPTION_LINE TEXT_DESCRIPTION_LINE = " " .. TEXT_DESCRIPTION_LINE
end end
djui_hud_set_font(FONT_TINY) djui_hud_set_font(FONT_TINY)
djui_hud_print_text(TEXT_DESCRIPTION_LINE, width - x + 5, 101 + (i-removeLine)*7, 0.5) djui_hud_print_text(TEXT_DESCRIPTION_LINE, width - x + 5, 101 + (i-removeLine) * 7, 0.5)
else else
removeLine = removeLine + 1 removeLine = removeLine + 1
end end
@ -638,19 +667,19 @@ local function on_hud_render()
local descriptionOffset = (#TEXT_DESCRIPTION_TABLE - removeLine) * 7 local descriptionOffset = (#TEXT_DESCRIPTION_TABLE - removeLine) * 7
djui_hud_print_text(TEXT_COLOR, width - x + 8, 109 + descriptionOffset, 0.6) djui_hud_print_text(TEXT_COLOR, width - x + 8, 109 + descriptionOffset, 0.6)
if TEX_ICON ~= nil then if TEX_ICON ~= nil then
djui_hud_print_text(TEXT_LIFE_ICON.." ("..TEX_ICON.width.."x"..TEX_ICON.height..")", width - x + 8, 118 + descriptionOffset, 0.6) djui_hud_print_text(TEXT_LIFE_ICON .. " (" .. TEX_ICON.width .. "x" .. TEX_ICON.height .. ")", width - x + 8, 118 + descriptionOffset, 0.6)
djui_hud_set_color(255, 255, 255, 255) djui_hud_set_color(255, 255, 255, 255)
djui_hud_render_texture(TEX_ICON, width - x + 38, 119 + descriptionOffset, 0.5/(TEX_ICON.width/16), 0.5/(TEX_ICON.height/16)) djui_hud_render_texture(TEX_ICON, width - x + 38, 119 + descriptionOffset, 0.5 / (TEX_ICON.width / 16), 0.5 / (TEX_ICON.height / 16))
else else
djui_hud_print_text(TEXT_LIFE_ICON.." (?x?)", width - x + 8, 118 + descriptionOffset, 0.6) djui_hud_print_text(TEXT_LIFE_ICON .. " (?x?)", width - x + 8, 118 + descriptionOffset, 0.6)
djui_hud_set_font(FONT_HUD) djui_hud_set_font(FONT_HUD)
djui_hud_set_color(255, 255, 255, 255) djui_hud_set_color(255, 255, 255, 255)
djui_hud_print_text(TEXT_ICON_DEFAULT, width - x + 38, 119 + descriptionOffset, 0.5) djui_hud_print_text(TEXT_ICON_DEFAULT, width - x + 38, 119 + descriptionOffset, 0.5)
djui_hud_set_font(FONT_TINY) djui_hud_set_font(FONT_TINY)
end end
djui_hud_set_color(menuColor.r, menuColor.g, menuColor.b, 255) djui_hud_set_color(menuColor.r, menuColor.g, menuColor.b, 255)
djui_hud_print_text(TEXT_FORCED_CHAR..defaultForceChar[character.forceChar], width - x + 8, 127 + descriptionOffset, 0.6) djui_hud_print_text(TEXT_FORCED_CHAR .. defaultForceChar[character.forceChar], width - x + 8, 127 + descriptionOffset, 0.6)
djui_hud_print_text(TEXT_TABLE_POS..currChar, width - x + 8, 136 + descriptionOffset, 0.6) djui_hud_print_text(TEXT_TABLE_POS .. currChar, width - x + 8, 136 + descriptionOffset, 0.6)
djui_hud_print_text(TEXT_SCALE, width - x + 8, 145 + descriptionOffset, 0.6) djui_hud_print_text(TEXT_SCALE, width - x + 8, 145 + descriptionOffset, 0.6)
@ -670,7 +699,7 @@ local function on_hud_render()
if optionTable[optionTableRef.anims].toggle == 0 then if optionTable[optionTableRef.anims].toggle == 0 then
buttonScroll = 0 buttonScroll = 0
elseif math_abs(buttonScroll) > 0.1 then elseif math_abs(buttonScroll) > 0.1 then
buttonScroll = buttonScroll*0.03*inputStallToDirectional buttonScroll = buttonScroll * 0.03 * inputStallToDirectional
end end
local buttonColor = {} local buttonColor = {}
@ -681,7 +710,7 @@ local function on_hud_render()
local buttonX = 20 * widthScale local buttonX = 20 * widthScale
if i == 0 then if i == 0 then
if optionTable[optionTableRef.anims].toggle > 0 then if optionTable[optionTableRef.anims].toggle > 0 then
buttonX = buttonX + math_sin(buttonAnimTimer*0.05)*2.5 + 5 buttonX = buttonX + math_sin(buttonAnimTimer * 0.05) * 2.5 + 5
else else
buttonX = buttonX + 10 buttonX = buttonX + 10
end end
@ -704,10 +733,10 @@ local function on_hud_render()
djui_hud_set_color(0, 0, 0, 255) djui_hud_set_color(0, 0, 0, 255)
djui_hud_render_rect(7 * widthScale + 1, 56, 5, 168) djui_hud_render_rect(7 * widthScale + 1, 56, 5, 168)
djui_hud_set_color(menuColor.r, menuColor.g, menuColor.b, 255) djui_hud_set_color(menuColor.r, menuColor.g, menuColor.b, 255)
djui_hud_render_rect(7 * widthScale + 2, 57 + 166 * ((currChar - 1) / #characterTable) - (buttonScroll*0.03333333333)*(166/#characterTable), 3, 166/#characterTable) djui_hud_render_rect(7 * widthScale + 2, 57 + 166 * ((currChar - 1) / #characterTable) - (buttonScroll * 0.03333333333) * (166 / #characterTable), 3, 166 / #characterTable)
djui_hud_set_font(FONT_TINY) djui_hud_set_font(FONT_TINY)
local TEXT_CHAR_COUNT = currChar.."/"..#characterTable local TEXT_CHAR_COUNT = currChar .. "/" .. #characterTable
djui_hud_print_text(TEXT_CHAR_COUNT, (11 - djui_hud_measure_text(TEXT_CHAR_COUNT)*0.2) * widthScale, height - 12, 0.4) djui_hud_print_text(TEXT_CHAR_COUNT, (11 - djui_hud_measure_text(TEXT_CHAR_COUNT) * 0.2) * widthScale, height - 12, 0.4)
--Character Select Header --Character Select Header
djui_hud_set_color(menuColor.r, menuColor.g, menuColor.b, 255) djui_hud_set_color(menuColor.r, menuColor.g, menuColor.b, 255)
@ -715,28 +744,40 @@ local function on_hud_render()
djui_hud_set_color(0, 0, 0, 255) djui_hud_set_color(0, 0, 0, 255)
djui_hud_render_rect(2, 2, width - 4, 46) djui_hud_render_rect(2, 2, width - 4, 46)
djui_hud_set_color(menuColor.r * 0.5 + 127, menuColor.g * 0.5 + 127, menuColor.b * 0.5 + 127, 255) djui_hud_set_color(menuColor.r * 0.5 + 127, menuColor.g * 0.5 + 127, menuColor.b * 0.5 + 127, 255)
djui_hud_render_texture(TEX_HEADER, widthHalf - 128, 10, 1, 1) if TEX_OVERRIDE_HEADER then -- Render Override Header
djui_hud_render_texture(TEX_OVERRIDE_HEADER, widthHalf - 128, 10, 1/(TEX_OVERRIDE_HEADER.height*MATH_DIVIDE_THIRTY_TWO), 1/(TEX_OVERRIDE_HEADER.height*MATH_DIVIDE_THIRTY_TWO))
else
djui_hud_render_texture(TEX_HEADER, widthHalf - 128, 10, 1, 1)
end
djui_hud_set_color(menuColor.r, menuColor.g, menuColor.b, 255) djui_hud_set_color(menuColor.r, menuColor.g, menuColor.b, 255)
djui_hud_set_font(FONT_TINY) djui_hud_set_font(FONT_TINY)
djui_hud_print_text(TEXT_VERSION, 5, 3, 0.5) djui_hud_print_text(TEXT_VERSION, 5, 3, 0.5)
--Unsupported Res Warning --Unsupported Res Warning
if width < 321.2 or width > 575 then if width < 321.2 or width > 575 then
djui_hud_print_text(TEXT_RATIO_UNSUPPORTED, 5, 39, 0.5) djui_hud_print_text(TEXT_RATIO_UNSUPPORTED, 5, 39, 0.5)
end end
-- API Rendering
if #renderInMenuTable > 0 then
for i = 1, #renderInMenuTable do
renderInMenuTable[i]()
end
end
--Options display --Options display
if options or optionAnimTimer > optionAnimTimerCap then if options or optionAnimTimer > optionAnimTimerCap then
djui_hud_set_color(menuColor.r * 0.25, menuColor.g * 0.25, menuColor.b * 0.25, 205 + math_max(-200, optionAnimTimer)) djui_hud_set_color(menuColor.r * 0.25, menuColor.g * 0.25, menuColor.b * 0.25, 205 + maxf(-200, optionAnimTimer))
djui_hud_render_rect(0, 0, width, height) djui_hud_render_rect(0, 0, width, height)
djui_hud_set_color(menuColor.r, menuColor.g, menuColor.b, 255) djui_hud_set_color(menuColor.r, menuColor.g, menuColor.b, 255)
djui_hud_render_rect(width*0.5 - 50 * widthScale, math.min(55 - optionAnimTimer, height - 25 * widthScale), 100 * widthScale, 200) djui_hud_render_rect(width * 0.5 - 50 * widthScale, minf(55 - optionAnimTimer, height - 25 * widthScale), 100 * widthScale, 200)
djui_hud_set_color(0, 0, 0, 255) djui_hud_set_color(0, 0, 0, 255)
djui_hud_render_rect(width*0.5 - 50 * widthScale + 2, math.min(55 - optionAnimTimer + 2, height - 25 * widthScale + 2), 100 * widthScale - 4, 196) djui_hud_render_rect(width * 0.5 - 50 * widthScale + 2, minf(55 - optionAnimTimer + 2, height - 25 * widthScale + 2), 100 * widthScale - 4, 196)
djui_hud_set_font(FONT_CS_NORMAL) djui_hud_set_font(FONT_CS_NORMAL)
djui_hud_set_color(menuColor.r * 0.5 + 127, menuColor.g * 0.5 + 127, menuColor.b * 0.5 + 127, 255) djui_hud_set_color(menuColor.r * 0.5 + 127, menuColor.g * 0.5 + 127, menuColor.b * 0.5 + 127, 255)
djui_hud_print_text(TEXT_OPTIONS_HEADER, widthHalf - djui_hud_measure_text(TEXT_OPTIONS_HEADER)*0.3*math_min(widthScale, 1.5), 65 + optionAnimTimer * -1, 0.6*math_min(widthScale, 1.5)) djui_hud_print_text(TEXT_OPTIONS_HEADER, widthHalf - djui_hud_measure_text(TEXT_OPTIONS_HEADER) * 0.3 * minf(widthScale, 1.5), 65 + optionAnimTimer * -1, 0.6 * minf(widthScale, 1.5))
local widthScaleLimited = math_min(widthScale, 1.5) local widthScaleLimited = minf(widthScale, 1.5)
-- Up Arrow -- Up Arrow
if currOption > 3 then if currOption > 3 then
djui_hud_set_color(menuColor.r, menuColor.g, menuColor.b, 255) djui_hud_set_color(menuColor.r, menuColor.g, menuColor.b, 255)
@ -760,7 +801,7 @@ local function on_hud_render()
-- Options -- Options
for i = currOption - 2, currOption + 2 do for i = currOption - 2, currOption + 2 do
if not (i < 1 or i > optionTableCount) then if not (i < 1 or i > optionTableCount) then
local toggleName = optionTable[i].name local toggleName = optionTable[i].name
local scale = 0.5 local scale = 0.5
local yOffset = 100 - optionAnimTimer + (i - currOption + 2) * 9 * widthScaleLimited local yOffset = 100 - optionAnimTimer + (i - currOption + 2) * 9 * widthScaleLimited
@ -779,7 +820,7 @@ local function on_hud_render()
djui_hud_set_color(menuColor.r, menuColor.g, menuColor.b, 150) djui_hud_set_color(menuColor.r, menuColor.g, menuColor.b, 150)
end end
scale = scale * widthScaleLimited scale = scale * widthScaleLimited
djui_hud_print_text(toggleName, widthHalf - djui_hud_measure_text(toggleName)*scale*0.5, yOffset, scale) djui_hud_print_text(toggleName, widthHalf - djui_hud_measure_text(toggleName) * scale * 0.5, yOffset, scale)
end end
end end
@ -789,18 +830,18 @@ local function on_hud_render()
for i = 1, #optionTable[currOption].description do for i = 1, #optionTable[currOption].description do
djui_hud_set_font(FONT_CS_NORMAL) djui_hud_set_font(FONT_CS_NORMAL)
local line = optionTable[currOption].description[i] local line = optionTable[currOption].description[i]
djui_hud_print_text(line, widthHalf - djui_hud_measure_text(line)*0.15, 180 - optionAnimTimer + 15 * widthScaleLimited + 8 * i - 8 * #optionTable[currOption].description, 0.3) djui_hud_print_text(line, widthHalf - djui_hud_measure_text(line) * 0.15, 180 - optionAnimTimer + 15 * widthScaleLimited + 8 * i - 8 * #optionTable[currOption].description, 0.3)
end end
end end
-- Footer -- Footer
djui_hud_set_font(FONT_TINY) djui_hud_set_font(FONT_TINY)
djui_hud_set_color(menuColor.r, menuColor.g, menuColor.b, 255) djui_hud_set_color(menuColor.r, menuColor.g, menuColor.b, 255)
djui_hud_print_text(TEXT_OPTIONS_SELECT, widthHalf - djui_hud_measure_text(TEXT_OPTIONS_SELECT)*0.3, height - 20 - optionAnimTimer, 0.6) djui_hud_print_text(TEXT_OPTIONS_SELECT, widthHalf - djui_hud_measure_text(TEXT_OPTIONS_SELECT) * 0.3, height - 20 - optionAnimTimer, 0.6)
djui_hud_set_color(menuColor.r, menuColor.g, menuColor.b, 255) djui_hud_set_color(menuColor.r, menuColor.g, menuColor.b, 255)
djui_hud_render_rect(width*0.5 - 50 * widthScale, height - 2, 100 * widthScale, 2) djui_hud_render_rect(width * 0.5 - 50 * widthScale, height - 2, 100 * widthScale, 2)
else else
-- How to open options display -- How to open options display
local widthScaleLimited = math_min(widthScale, 1.42) local widthScaleLimited = minf(widthScale, 1.42)
djui_hud_set_color(menuColor.r, menuColor.g, menuColor.b, 255) djui_hud_set_color(menuColor.r, menuColor.g, menuColor.b, 255)
djui_hud_render_rect(widthHalf - 50 * widthScale, height - 25 * widthScaleLimited, 100 * widthScale, 26 * widthScaleLimited) djui_hud_render_rect(widthHalf - 50 * widthScale, height - 25 * widthScaleLimited, 100 * widthScale, 26 * widthScaleLimited)
djui_hud_set_color(0, 0, 0, 255) djui_hud_set_color(0, 0, 0, 255)
@ -808,17 +849,17 @@ local function on_hud_render()
djui_hud_set_color(menuColor.r, menuColor.g, menuColor.b, 255) djui_hud_set_color(menuColor.r, menuColor.g, menuColor.b, 255)
djui_hud_render_rect(widthHalf - 50 * widthScale, height - 2, 100 * widthScale, 2) djui_hud_render_rect(widthHalf - 50 * widthScale, height - 2, 100 * widthScale, 2)
djui_hud_set_font(FONT_CS_NORMAL) djui_hud_set_font(FONT_CS_NORMAL)
djui_hud_print_text(TEXT_OPTIONS_OPEN, widthHalf - djui_hud_measure_text(TEXT_OPTIONS_OPEN)*0.175 * widthScaleLimited, height - 23 * widthScaleLimited + optionAnimTimer + 202, 0.35 * widthScaleLimited) djui_hud_print_text(TEXT_OPTIONS_OPEN, widthHalf - djui_hud_measure_text(TEXT_OPTIONS_OPEN) * 0.175 * widthScaleLimited, height - 23 * widthScaleLimited + optionAnimTimer + 202, 0.35 * widthScaleLimited)
djui_hud_set_font(FONT_TINY) djui_hud_set_font(FONT_TINY)
djui_hud_print_text(TEXT_MENU_CLOSE, widthHalf - djui_hud_measure_text(TEXT_MENU_CLOSE)*0.25 * widthScaleLimited, height - 13 * widthScaleLimited + optionAnimTimer + 202, 0.5 * widthScaleLimited) djui_hud_print_text(TEXT_MENU_CLOSE, widthHalf - djui_hud_measure_text(TEXT_MENU_CLOSE) * 0.25 * widthScaleLimited, height - 13 * widthScaleLimited + optionAnimTimer + 202, 0.5 * widthScaleLimited)
end end
-- Anim logic -- Anim logic
if options then if options then
if optionTable[optionTableRef.anims].toggle > 0 then if optionTable[optionTableRef.anims].toggle > 0 then
if optionAnimTimer < -1 then if optionAnimTimer < -1 then
optionAnimTimer = optionAnimTimer/1.1 optionAnimTimer = optionAnimTimer / 1.1
end end
else else
optionAnimTimer = -1 optionAnimTimer = -1
@ -826,13 +867,13 @@ local function on_hud_render()
else else
if optionTable[optionTableRef.anims].toggle > 0 then if optionTable[optionTableRef.anims].toggle > 0 then
if optionAnimTimer > optionAnimTimerCap then if optionAnimTimer > optionAnimTimerCap then
optionAnimTimer = optionAnimTimer*1.3 optionAnimTimer = optionAnimTimer * 1.3
end end
else else
optionAnimTimer = optionAnimTimerCap optionAnimTimer = optionAnimTimerCap
end end
end end
optionAnimTimer = math_max(optionAnimTimer, -200) optionAnimTimer = maxf(optionAnimTimer, -200)
else else
options = false options = false
optionAnimTimer = optionAnimTimerCap optionAnimTimer = optionAnimTimerCap
@ -872,8 +913,8 @@ local function on_hud_render()
djui_hud_set_font(FONT_NORMAL) djui_hud_set_font(FONT_NORMAL)
if optionTable[optionTableRef.openInputs].toggle == 2 then if optionTable[optionTableRef.openInputs].toggle == 2 then
currCharY = 27 currCharY = 27
local width = djui_hud_get_screen_width() - djui_hud_measure_text(TEXT_PAUSE_Z_OPEN) width = djui_hud_get_screen_width() - djui_hud_measure_text(TEXT_PAUSE_Z_OPEN)
if not client_is_coop_dx then -- Done to match DX not having dropshadow on the "R Button - Options" thingy if not IS_COOPDX then -- Done to match DX not having dropshadow on the "R Button - Options" thingy
djui_hud_set_color(0, 0, 0, 255) djui_hud_set_color(0, 0, 0, 255)
djui_hud_print_text(TEXT_PAUSE_Z_OPEN, width - 19, 17, 1) djui_hud_print_text(TEXT_PAUSE_Z_OPEN, width - 19, 17, 1)
end end
@ -883,10 +924,10 @@ local function on_hud_render()
if optionTable[optionTableRef.localModels].toggle == 1 then if optionTable[optionTableRef.localModels].toggle == 1 then
local charName = string_underscore_to_space(characterTable[currChar].name) local charName = string_underscore_to_space(characterTable[currChar].name)
local TEXT_PAUSE_CURR_CHAR_WITH_NAME = TEXT_PAUSE_CURR_CHAR..charName local TEXT_PAUSE_CURR_CHAR_WITH_NAME = TEXT_PAUSE_CURR_CHAR .. charName
local width = djui_hud_get_screen_width() - djui_hud_measure_text(TEXT_PAUSE_CURR_CHAR_WITH_NAME) width = djui_hud_get_screen_width() - djui_hud_measure_text(TEXT_PAUSE_CURR_CHAR_WITH_NAME)
local charColor = characterTable[currChar].color local charColor = characterTable[currChar].color
if not client_is_coop_dx then if not IS_COOPDX then
djui_hud_set_color(0, 0, 0, 255) djui_hud_set_color(0, 0, 0, 255)
djui_hud_print_text(TEXT_PAUSE_CURR_CHAR_WITH_NAME, width - 19, 17 + currCharY, 1) djui_hud_print_text(TEXT_PAUSE_CURR_CHAR_WITH_NAME, width - 19, 17 + currCharY, 1)
end end
@ -895,8 +936,8 @@ local function on_hud_render()
djui_hud_set_color(charColor.r, charColor.g, charColor.b, 255) djui_hud_set_color(charColor.r, charColor.g, charColor.b, 255)
djui_hud_print_text(charName, djui_hud_get_screen_width() - djui_hud_measure_text(charName) - 20, 16 + currCharY, 1) djui_hud_print_text(charName, djui_hud_get_screen_width() - djui_hud_measure_text(charName) - 20, 16 + currCharY, 1)
else else
local width = djui_hud_get_screen_width() - djui_hud_measure_text(TEXT_LOCAL_MODEL_OFF) width = djui_hud_get_screen_width() - djui_hud_measure_text(TEXT_LOCAL_MODEL_OFF)
if not client_is_coop_dx then if not IS_COOPDX then
djui_hud_set_color(0, 0, 0, 255) djui_hud_set_color(0, 0, 0, 255)
djui_hud_print_text(TEXT_LOCAL_MODEL_OFF, width - 19, 17 + currCharY, 1) djui_hud_print_text(TEXT_LOCAL_MODEL_OFF, width - 19, 17 + currCharY, 1)
end end
@ -906,36 +947,11 @@ local function on_hud_render()
end end
end end
-- Custom life icon rendering (Thanks LuigiGamer)
function on_life_counter_render()
if obj_get_first_with_behavior_id(id_bhvActSelector) ~= nil then return end
djui_hud_set_font(FONT_HUD)
djui_hud_set_resolution(RESOLUTION_N64)
djui_hud_set_color(255, 255, 255, 255);
local x = 22
local y = 15
if gNetworkPlayers[0].currActNum == 99 then return end
if gMarioStates[0].action == ACT_INTRO_CUTSCENE then return end
if not hud_is_hidden() then
local icon = characterTable[currChar].lifeIcon
if icon == nil then
djui_hud_print_text("?", x, y, 1)
else
djui_hud_render_texture(icon, x, y, 1/(icon.width/16), 1/(icon.height/16))
end
djui_hud_print_text("@", x + 16, y, 1)
djui_hud_print_text(tostring(gMarioStates[0].numLives), x + 32, y, 1)
hud_set_value(HUD_DISPLAY_FLAGS, hud_get_value(HUD_DISPLAY_FLAGS) &~ HUD_DISPLAY_FLAG_LIVES) -- Hides the lives counter
else
hud_set_value(HUD_DISPLAY_FLAGS, hud_get_value(HUD_DISPLAY_FLAGS) | HUD_DISPLAY_FLAG_LIVES) -- Shows the lives counter, use this when you're no longer using a custom character
end
end
local function before_mario_update(m) local function before_mario_update(m)
if m.playerIndex ~= 0 then return end if m.playerIndex ~= 0 then return end
if inputStallTimerButton > 0 then inputStallTimerButton = inputStallTimerButton - 1 end if inputStallTimerButton > 0 then inputStallTimerButton = inputStallTimerButton - 1 end
if inputStallTimerDirectional > 0 then inputStallTimerDirectional = inputStallTimerDirectional - 1 end if inputStallTimerDirectional > 0 then inputStallTimerDirectional = inputStallTimerDirectional - 1 end
if menu and inputStallToDirectional ~= latencyValueTable[optionTable[optionTableRef.inputLatency].toggle + 1] then if menu and inputStallToDirectional ~= latencyValueTable[optionTable[optionTableRef.inputLatency].toggle + 1] then
inputStallToDirectional = latencyValueTable[optionTable[optionTableRef.inputLatency].toggle + 1] inputStallToDirectional = latencyValueTable[optionTable[optionTableRef.inputLatency].toggle + 1]
end end
@ -1072,13 +1088,12 @@ end
hook_event(HOOK_BEFORE_MARIO_UPDATE, before_mario_update) hook_event(HOOK_BEFORE_MARIO_UPDATE, before_mario_update)
hook_event(HOOK_ON_HUD_RENDER, on_hud_render) hook_event(HOOK_ON_HUD_RENDER, on_hud_render)
hook_event(HOOK_ON_HUD_RENDER_BEHIND, on_life_counter_render)
-------------- --------------
-- Commands -- -- Commands --
-------------- --------------
local promptedAreYouSure = false promptedAreYouSure = false
local function chat_command(msg) local function chat_command(msg)
msg = string_lower(msg) msg = string_lower(msg)
@ -1091,10 +1106,10 @@ local function chat_command(msg)
-- Help Prompt Check -- Help Prompt Check
if msg == "?" or msg == "help" then if msg == "?" or msg == "help" then
djui_chat_message_create("Character Select's Avalible Commands:".. djui_chat_message_create("Character Select's Avalible Commands:" ..
"\n\\#ffff33\\/char-select help\\#ffffff\\ - Returns Avalible Commands".. "\n\\#ffff33\\/char-select help\\#ffffff\\ - Returns Avalible Commands" ..
"\n\\#ffff33\\/char-select menu\\#ffffff\\ - Opens the Menu".. "\n\\#ffff33\\/char-select menu\\#ffffff\\ - Opens the Menu" ..
"\n\\#ffff33\\/char-select [name/num]\\#ffffff\\ - Switches to Character".. "\n\\#ffff33\\/char-select [name/num]\\#ffffff\\ - Switches to Character" ..
"\n\\#ff3333\\/char-select reset\\#ffffff\\ - Resets your Save Data") "\n\\#ff3333\\/char-select reset\\#ffffff\\ - Resets your Save Data")
return true return true
end end
@ -1109,18 +1124,17 @@ local function chat_command(msg)
for i = 1, #characterTable do for i = 1, #characterTable do
if msg == string_lower(characterTable[i].name) or msg == string_underscore_to_space(string_lower(characterTable[i].saveName)) then if msg == string_lower(characterTable[i].name) or msg == string_underscore_to_space(string_lower(characterTable[i].saveName)) then
currChar = i currChar = i
djui_chat_message_create(characterTable[i].saveName) djui_chat_message_create('Character set to "' .. characterTable[i].name .. '" Successfully!')
djui_chat_message_create('Character set to "'..characterTable[i].name..'" Successfully!')
return true return true
end end
end end
-- Number Check -- Number Check
if tonumber(msg) then if tonumber(msg) then
local msg = tonumber(msg) msg = tonumber(msg)
if msg > 0 and msg <= #characterTable then if msg > 0 and msg <= #characterTable then
currChar = msg currChar = msg
djui_chat_message_create('Character set to "'..characterTable[msg].name..'" Successfully!') djui_chat_message_create('Character set to "' .. characterTable[msg].name .. '" Successfully!')
return true return true
end end
end end

View file

@ -0,0 +1,152 @@
------------------------------------------------------
-- Custom HUD Rendering by Agent X and xLuigiGamerx --
------------------------------------------------------
--- @param localIndex integer
--- @return TextureInfo|nil
--- This assumes multiple characters will not have the same model
function life_icon_from_local_index(localIndex)
for i = 1, #characterTable do
if characterTable[i].model == gPlayerSyncTable[localIndex].modelId then
return characterTable[i].lifeIcon
end
end
end
local function render_hud_mario_lives()
hud_set_value(HUD_DISPLAY_FLAGS, hud_get_value(HUD_DISPLAY_FLAGS) & ~HUD_DISPLAY_FLAG_LIVES)
local x = 22
local y = 15 -- SCREEN_HEIGHT - 209 - 16
local lifeIcon = characterTable[currChar].lifeIcon
if lifeIcon == nil then
djui_hud_print_text("?", x, y, 1)
else
djui_hud_render_texture(lifeIcon, x, y, 1 / (lifeIcon.width * 0.0625), 1 / (lifeIcon.height * 0.0625)) -- 0.0625 is 1/16
end
djui_hud_print_text("@", x + 16, y, 1)
djui_hud_print_text(tostring(hud_get_value(HUD_DISPLAY_LIVES)):gsub("-", "M"), x + 32, y, 1)
end
local function render_hud_stars()
hud_set_value(HUD_DISPLAY_FLAGS, hud_get_value(HUD_DISPLAY_FLAGS) & ~HUD_DISPLAY_FLAG_STAR_COUNT)
-- the flashing when you exit a painting, uses sm64coopdx exclusive functionality
-- v0.1.5
--[[
if IS_COOPDX then
-- prevent star count from flashing outside of castle
if gNetworkPlayers[0].currCourseNum ~= COURSE_NONE then hud_set_flash(0) end
if hud_get_flash() == 1 and (get_global_timer() & 0x08) == 0 then
return
end
end
]]
local x = djui_hud_get_screen_width() - 78
local y = 15 -- SCREEN_HEIGHT - 209 - 16
local starIcon = characterTable[currChar].starIcon and characterTable[currChar].starIcon or gTextures.star
local showX = 0
local hudDisplayStars = hud_get_value(HUD_DISPLAY_STARS)
if hudDisplayStars < 100 then showX = 1 end
djui_hud_render_texture(starIcon, x, y, 1 / (starIcon.width * 0.0625), 1 / (starIcon.height * 0.0625)) -- 0.0625 is 1/16
if showX == 1 then
djui_hud_print_text("@", x + 16, y, 1)
end
djui_hud_print_text(tostring(hudDisplayStars):gsub("-", "M"), (showX * 14) + x + 16, y, 1)
end
local function render_hud_camera_status()
if not IS_COOPDX or not HUD_DISPLAY_CAMERA_STATUS then return end
hud_set_value(HUD_DISPLAY_FLAGS, hud_get_value(HUD_DISPLAY_FLAGS) & ~HUD_DISPLAY_FLAG_CAMERA)
local x = djui_hud_get_screen_width() - 54
local y = 205
local cameraHudStatus = hud_get_value(HUD_DISPLAY_CAMERA_STATUS)
if cameraHudStatus == CAM_STATUS_NONE then return end
djui_hud_render_texture(gTextures.camera, x, y, 1, 1)
switch(cameraHudStatus & CAM_STATUS_MODE_GROUP, {
[CAM_STATUS_MARIO] = function()
local lifeIcon = characterTable[currChar].lifeIcon
if lifeIcon == nil then
djui_hud_print_text("?", x + 16, y, 1)
else
djui_hud_render_texture(lifeIcon, x + 16, y, 1 / (lifeIcon.width * 0.0625), 1 / (lifeIcon.height * 0.0625)) -- 0.0625 is 1/16
end
end,
[CAM_STATUS_LAKITU] = function()
djui_hud_render_texture(gTextures.lakitu, x + 16, y, 1, 1)
end,
[CAM_STATUS_FIXED] = function()
djui_hud_render_texture(gTextures.no_camera, x + 16, y, 1, 1)
end
})
switch(cameraHudStatus & CAM_STATUS_C_MODE_GROUP, {
[CAM_STATUS_C_DOWN] = function()
djui_hud_render_texture(gTextures.arrow_down, x + 4, y + 16, 1, 1)
end,
[CAM_STATUS_C_UP] = function()
djui_hud_render_texture(gTextures.arrow_up, x + 4, y - 8, 1, 1)
end
})
end
local function render_act_select_hud()
local 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
for i = 5, 0, -1 do
if stars & 2 ^ i ~= 0 then
maxStar = i
break
end
end
for a = 1, maxStar + 1 do
local x = (38 - maxStar * 17 + a * 34) + djui_hud_get_screen_width() * 0.5 - 75
for j = 0, MAX_PLAYERS - 1 do
local np = gNetworkPlayers[j]
if np and np.connected and np.currCourseNum == course and np.currActNum == a then
djui_hud_render_rect(x - 4, 17, 16, 16)
local displayHead = life_icon_from_local_index(j)
if displayHead == nil then
djui_hud_print_text("?", x - 4, 17, 1)
else
djui_hud_render_texture(displayHead, x - 4, 17, 1 / (displayHead.width * 0.0625), 1 / (displayHead.height * 0.0625)) -- 0.0625 is 1/16
end
end
end
end
end
local function on_hud_render_behind()
djui_hud_set_resolution(RESOLUTION_N64)
djui_hud_set_font(FONT_HUD)
djui_hud_set_color(255, 255, 255, 255)
if obj_get_first_with_behavior_id(id_bhvActSelector) ~= nil then
render_act_select_hud()
return
elseif gNetworkPlayers[0].currActNum == 99 or gMarioStates[0].action == ACT_INTRO_CUTSCENE or hud_is_hidden() then
return
end
render_hud_mario_lives()
render_hud_stars()
render_hud_camera_status()
end
hook_event(HOOK_ON_HUD_RENDER_BEHIND, on_hud_render_behind)

View file

@ -1,4 +1,3 @@
--- @class CharacterTable --- @class CharacterTable
--- @field public name string --- @field public name string
--- @field public saveName string --- @field public saveName string
@ -10,14 +9,14 @@
--- @field public lifeIcon TextureInfo --- @field public lifeIcon TextureInfo
--- @field public camScale integer --- @field public camScale integer
-- localize functions to improve performance
local smlua_model_util_get_id,table_insert,djui_hud_measure_text,type = smlua_model_util_get_id,table.insert,djui_hud_measure_text,type
local characterVoices = {} local characterVoices = {}
local saveNameTable = {} local saveNameTable = {}
local E_MODEL_ARMATURE = smlua_model_util_get_id("armature_geo") local E_MODEL_ARMATURE = smlua_model_util_get_id("armature_geo")
local table_insert = table.insert
local type = type
local function split_text_into_lines(text) local function split_text_into_lines(text)
local words = {} local words = {}
for word in text:gmatch("%S+") do for word in text:gmatch("%S+") do
@ -110,12 +109,26 @@ local function character_add_caps(modelInfo, caps)
characterCaps[modelInfo] = caps characterCaps[modelInfo] = caps
end end
---@param modelInfo ModelExtendedId|integer
---@param starModel ModelExtendedId|integer
---@param starIcon TextureInfo|nil Use get_texture_info()
local function character_add_celebration_star(modelInfo, starModel, starIcon)
characterCelebrationStar[modelInfo] = starModel
for i = 2, #characterTable do
if characterTable[i].model == modelInfo then
characterTable[i].starIcon = starIcon and starIcon or gTextures.star
return
end
end
return false
end
---@return CharacterTable ---@return CharacterTable
local function character_get_current_table() local function character_get_current_table()
return characterTable[currChar] return characterTable[currChar]
end end
local function character_get_current_model_number() local function character_get_current_number()
return currChar return currChar
end end
@ -135,7 +148,7 @@ local function character_get_voice(m)
end end
local function version_get() local function version_get()
return modVersion return MOD_VERSION
end end
local function is_menu_open() local function is_menu_open()
@ -146,6 +159,10 @@ local function hook_allow_menu_open(func)
table_insert(allowMenu, func) table_insert(allowMenu, func)
end end
local function hook_render_in_menu(func)
table_insert(renderInMenuTable, func)
end
local function is_options_open() local function is_options_open()
return options return options
end end
@ -167,21 +184,26 @@ local function get_status(tableNum)
return optionTable[tableNum].toggle return optionTable[tableNum].toggle
end end
_G.charSelectExists = true -- Ace _G.charSelectExists = true
_G.charSelect = { _G.charSelect = {
character_add = character_add, character_add = character_add,
character_edit = character_edit, character_edit = character_edit,
character_add_voice = character_add_voice, character_add_voice = character_add_voice,
character_add_caps = character_add_caps, character_add_caps = character_add_caps,
character_add_celebration_star = character_add_celebration_star,
character_get_current_table = character_get_current_table, character_get_current_table = character_get_current_table,
character_get_current_model_number = character_get_current_model_number, character_get_current_number = character_get_current_number,
character_get_current_model_number --[[Depreiciated Function Name, Not recommended for use]] = character_get_current_number,
character_get_number_from_string = character_get_number_from_string, character_get_number_from_string = character_get_number_from_string,
character_get_voice = character_get_voice, character_get_voice = character_get_voice,
character_get_life_icon = life_icon_from_local_index,
header_set_texture = header_set_texture, -- Function located in main.lua
version_get = version_get, version_get = version_get,
is_menu_open = is_menu_open, is_menu_open = is_menu_open,
hook_allow_menu_open = hook_allow_menu_open,
is_options_open = is_options_open, is_options_open = is_options_open,
get_status = get_status, get_status = get_status,
optionTableRef = optionTableRef, optionTableRef = optionTableRef,
controller = controller, controller = controller,
hook_allow_menu_open = hook_allow_menu_open,
hook_render_in_menu = hook_render_in_menu,
} }

Binary file not shown.

Binary file not shown.

View file

@ -10,6 +10,9 @@ gCustomVoiceSamples = {}
gCustomVoiceSamplesBackup = {} gCustomVoiceSamplesBackup = {}
gCustomVoiceStream = nil gCustomVoiceStream = nil
-- localize functions to improve performance
local audio_sample_stop,audio_sample_destroy,type,math_random,audio_stream_stop,audio_stream_destroy,audio_stream_load,audio_stream_play,audio_sample_load,audio_sample_play,is_game_paused,play_character_sound = audio_sample_stop,audio_sample_destroy,type,math.random,audio_stream_stop,audio_stream_destroy,audio_stream_load,audio_stream_play,audio_sample_load,audio_sample_play,is_game_paused,play_character_sound
--- @param m MarioState --- @param m MarioState
function stop_custom_character_sound(m, sound) function stop_custom_character_sound(m, sound)
local voice_sample = gCustomVoiceSamples[m.playerIndex] local voice_sample = gCustomVoiceSamples[m.playerIndex]