diff --git a/src/resource/ui/menus/controls.menu b/src/resource/ui/menus/controls.menu index d5805ce..356d280 100644 --- a/src/resource/ui/menus/controls.menu +++ b/src/resource/ui/menus/controls.menu @@ -127,7 +127,7 @@ resource/ui/menus/controls.menu pin_corner_to_sibling TOP_LEFT pin_to_sibling_corner BOTTOM_LEFT navUp SwchHoldToRodeo - navDown BtnGamepadLayout + navDown DemosMenu ConVar "sv_cheats" list { @@ -135,6 +135,16 @@ resource/ui/menus/controls.menu "Enable" 1 } } + DemosMenu + { + ControlName RuiButton + InheritProperties WideButton + pin_to_sibling SwchEnableCheats + pin_corner_to_sibling TOP_LEFT + pin_to_sibling_corner BOTTOM_LEFT + navUp SwchEnableCheats + navDown BtnGamepadLayout + } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -317,7 +327,7 @@ resource/ui/menus/controls.menu ControlName ImagePanel InheritProperties SubheaderBackground xpos 96 - ypos 330 + ypos 380 } LblGamepadSubheaderText { @@ -338,7 +348,7 @@ resource/ui/menus/controls.menu pin_corner_to_sibling TOP_LEFT pin_to_sibling_corner BOTTOM_LEFT xpos -22 - navUp SwchHoldToRodeo + navUp DemosMenu navDown SwchHoldToCrouch tabPosition 2 } diff --git a/src/resource/ui/menus/demos.menu b/src/resource/ui/menus/demos.menu new file mode 100644 index 0000000..a5dd5da --- /dev/null +++ b/src/resource/ui/menus/demos.menu @@ -0,0 +1,174 @@ +resource/ui/menus/demos.menu +{ + menu + { + ControlName Frame + xpos 0 + ypos 0 + zpos 3 + wide f0 + tall f0 + autoResize 0 + visible 1 + enabled 1 + pinCorner 0 + PaintBackgroundType 0 + infocus_bgcolor_override "0 0 0 0" + outoffocus_bgcolor_override "0 0 0 0" + + Vignette + { + ControlName ImagePanel + InheritProperties MenuVignette + } + + Title + { + ControlName Label + InheritProperties MenuTitle + labelText "Demos" + } + + ImgTopBar + { + ControlName ImagePanel + InheritProperties MenuTopBar + } + + MatchmakingStatus + { + ControlName CNestedPanel + xpos 0 + ypos 0 + wide f0 + tall f0 + visible 1 + controlSettingsFile "resource/ui/menus/panels/matchmaking_status.res" + } + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + LblMenuItemDescription + { + ControlName Label + InheritProperties OptionMenuTooltip + classname MenuItemDescriptionClass + xpos 975 + ypos 168 + } + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + SwchEnableDemos + { + ControlName RuiButton + InheritProperties SwitchButton + xpos 120 + ypos 160 + tabPosition 1 + style DialogListButton + navUp SwchSoundWithoutFocus + navDown SwchDemosWrite + ConVar "demo_enabledemos" + list + { + "#SETTING_OFF" 0 + "#SETTING_ON" 1 + } + } + SwchDemosWrite + { + ControlName RuiButton + InheritProperties SwitchButton + style DialogListButton + navUp SwchEnableDemos + navDown SwchDemosInterpolate + ConVar "demo_writeLocalFile" + list + { + "#SETTING_OFF" 0 + "#SETTING_ON" 1 + } + + pin_to_sibling SwchEnableDemos + pin_corner_to_sibling TOP_LEFT + pin_to_sibling_corner BOTTOM_LEFT + } + SwchDemosInterpolate + { + ControlName RuiButton + InheritProperties SwitchButton + style DialogListButton + navUp SwchDemosWrite + navDown SwchDemosUpdateRate + ConVar "demo_interpolateview" + list + { + "#SETTING_OFF" 0 + "#SETTING_ON" 1 + } + + pin_to_sibling SwchDemosWrite + pin_corner_to_sibling TOP_LEFT + pin_to_sibling_corner BOTTOM_LEFT + } + SwchDemosUpdateRate + { + ControlName RuiButton + InheritProperties SwitchButton + style DialogListButton + navUp SwchDemosInterpolate + navDown SwchDemosAutorecord + ConVar "base_tickinterval_sp" + list + { + "20 FPS" 0.05 + "60 FPS" 0.016666667 + "100 FPS" 0.010000 + } + + pin_to_sibling SwchDemosInterpolate + pin_corner_to_sibling TOP_LEFT + pin_to_sibling_corner BOTTOM_LEFT + } + SwchDemosAutorecord + { + ControlName RuiButton + InheritProperties SwitchButton + style DialogListButton + navUp SwchDemosUpdateRate + navDown BtnMouseKeyboardBindings + ConVar "demo_autoRecord" + list + { + "#SETTING_OFF" 0 + "#SETTING_ON" 1 + } + + pin_to_sibling SwchDemosUpdateRate + pin_corner_to_sibling TOP_LEFT + pin_to_sibling_corner BOTTOM_LEFT + } + + // Mouse/Keyboard options + BtnMouseKeyboardBindings [!$GAMECONSOLE] + { + ControlName RuiButton + InheritProperties WideButton + pin_to_sibling SwchDemosAutorecord + pin_corner_to_sibling TOP_LEFT + pin_to_sibling_corner BOTTOM_LEFT + ypos 30 + navUp SwchDemosAutorecord + navDown SwchEnableDemos + } + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + FooterButtons + { + ControlName CNestedPanel + InheritProperties FooterButtons + } + } +} diff --git a/src/scripts/kb_act.lst b/src/scripts/kb_act.lst index 60e51a6..9fb7144 100644 --- a/src/scripts/kb_act.lst +++ b/src/scripts/kb_act.lst @@ -13,6 +13,12 @@ "give mp_weapon_shotgun" "Spawn EVA Shotgun" "give mp_weapon_epg" "Spawn EPG" "blank" "==========================" +"blank" "DEMOS" +"blank" "==========================" +"_record demo" "Record Demo Increment" +"record demo" "Record Demo" +"stop" "Stop Recording" +"blank" "==========================" "blank" "EXTRAS" "blank" "==========================" "toggle sv_gravity 200 750" "Low Gravity" diff --git a/src/scripts/vscripts/scripts.rson b/src/scripts/vscripts/scripts.rson new file mode 100644 index 0000000..f868a95 --- /dev/null +++ b/src/scripts/vscripts/scripts.rson @@ -0,0 +1,1052 @@ + +/* +Expression values: +SERVER Server per-level script VM +CLIENT Client per-level script VM +UI UI script VM +SP Singleplayer (returns true for sp maps) +MP Multiplayer (returns true for mp maps) +DEV Value of developer convar +CONSOLE_PROG True if a Durango or PS4 program +DURANGO_PROG True if a Durango program +PS4_PROG True if a PS4 program +PC_PROG True if a PC program +LOBBY True in mp_lobby. (Server and client VMs only) +MAP_mp_box True if the given map name is being loaded +GAMEMODE_at True of the given game mode is being loaded +*/ + +When: "SERVER || CLIENT" +Scripts: +[ + sh_damage_history.gnut // needs to come before _entitystructs +] + +When: "SERVER" +Scripts: +[ + ai/_ai_pilots.gnut // needs to come before _entitystructs +] + +When: "(SERVER || CLIENT) && SP" +Scripts: +[ + sh_consts_sp.gnut + sp/sh_sp_objective_strings.gnut +] + +When: "(SERVER || CLIENT) && MP" +Scripts: +[ + //gamemodes/sh_dev_gamemodes_mp.gnut // DEVSCRIPTS REMOVE + gamemodes/sh_gamemodes_mp.gnut +] + +When: "UI" +Scripts: +[ + ui/ui_vars.gnut + sp/sh_start_points.nut + sp/_sp_sh_weapons.gnut + sh_savegame.gnut +] + +When: "SERVER || CLIENT || UI" +Scripts: +[ + _scripttest.gnut + sh_consts.gnut + sh_common_models.gnut + _threads.nut + _settings.nut + sh_utility_all.gnut + sh_networkvars.gnut + sh_loadouts_common.gnut + sh_passives.gnut + sh_entitystructs.gnut + sh_death_hints.gnut + _entitlements.gnut +] + +When: "(SERVER && MP) || UI" +Scripts: +[ + sh_store.gnut +] + +When: "MP || UI" +Scripts: +[ + mp/sh_challenges.gnut + sh_consts_mp.gnut + _items.nut + _random_unlocks.gnut + sh_camo.gnut + sh_calling_cards.gnut + _persistentdata.gnut + gamemodes/sh_gamemodes.gnut + //gamemodes/sh_dev_gamemodes.gnut // DEVSCRIPTS REMOVE + mp/sh_challenges_content.nut + sh_loadouts.nut + sh_mp_utility_all.gnut + sh_stats.gnut + sh_faction_xp.gnut + sh_titan_xp.gnut + sh_weapon_xp.gnut + sh_xp.gnut + burnmeter/sh_boost_store.gnut +] + +When: "SERVER && SP" +Scripts: +[ + sp/_sp_mapspawn.gnut +] + +When: "SERVER && MP" +Scripts: +[ + mp/_mp_mapspawn.gnut + mp/_stats.nut // needs to come before _entitystructs + class/CHardPointEntity.nut +] + +When: "SERVER && DEV" +Scripts: +[ + mp/_model_viewer.nut + _auto_precache.gnut // needs to come before flightpath scripts +] + +When: "SERVER" +Scripts: +[ + _mapspawn.gnut + _networkvars.gnut + _vscript.gnut + _init.gnut + class/CPlayer.nut + sh_anim_events.gnut + _entitystructs.gnut + class/CBaseEntity.nut + class/CTitanSoul.nut + class/CBaseCombatCharacter.nut + class/CAI_BaseNPC.nut + // Put new server-specific scripts in the later SERVER section, not here. +] + + +When: "CLIENT && SP" +Scripts: +[ + cl_sp_mapspawn.gnut +] + +When: "CLIENT && MP" +Scripts: +[ + cl_mapspawn.gnut + client/cl_scoreboard_mp.nut + burnmeter/cl_burnmeter.gnut + class/C_HardPointEntity.nut +] + + +When: "CLIENT" +Scripts: +[ + cl_vscript.gnut + sh_anim_events.gnut + cl_entitystructs.gnut + class/C_BaseEntity.nut + class/C_Player.nut + class/C_AI_BaseNPC.nut + class/C_TitanSoul.nut + class/C_VGuiScreen.nut + // Put new client-specific scripts in the later CLIENT section, not here. +] + + +When: "(SERVER || CLIENT) && SP" +Scripts: +[ + _remote_functions_sp.gnut + sh_sp_utility.gnut + sp/_sp_sh_weapons.gnut +] + +When: "(SERVER || CLIENT) && MP" +Scripts: +[ + //_dev_remote_functions_mp.gnut // DEVSCRIPTS REMOVE + _remote_functions_mp.gnut +] + +When: "SERVER || CLIENT" +Scripts: +[ + sh_debug_draw.gnut + sh_flag.gnut + _utility_shared.nut + sh_damage_types.nut + sh_passive_utility.gnut + gamemodes/_frontline.gnut + gamemodes/sh_riff_settings.gnut + melee/sh_melee.gnut + melee/sh_melee_human.gnut + melee/sh_melee_synced_human.gnut + melee/sh_melee_synced_titan.gnut + melee/sh_melee_titan.gnut + mp/sh_revive.gnut + mp/sh_bleedout.gnut + mp/sh_smoke_sight.gnut + mp/sh_teams.gnut + sp/sh_mobility_ghost.gnut + pilot/sh_pilot_leeching.gnut + rodeo/sh_rodeo.gnut + rodeo/sh_rodeo_titan.gnut + rodeo/sh_rodeo_titan_anim.nut + sentry_turrets/sh_sentry_turrets.gnut + sh_anim_aliases.gnut + sh_codecallbacks.gnut + sh_damage_utility.gnut + sh_death_package.gnut + sh_dialogue.gnut + sh_dialogue_schedule.gnut + sh_flightpath.gnut + sh_flightpath_utility.gnut + sh_flyers.gnut + sh_highlight.gnut + sh_minimap.gnut + sh_network_marker.gnut + sh_timer.gnut + sh_toy_arc_connectors.nut + earn_meter/sh_earn_meter.gnut + titan/sh_titan.gnut + titan/sh_titan_embark.gnut + titan/sh_titan_soul.gnut + titan/sh_titan_triple_health.gnut + titan/sh_ion_energy.gnut + weapons/_arc_cannon.nut + weapons/_grenade.nut + weapons/_vortex.nut + weapons/_weapon_dialogue.nut + weapons/_weapon_utility.nut + weapons/mp_ability_cloak.nut + weapons/mp_ability_timeshift.nut + weapons/mp_ability_grapple.nut + weapons/mp_ability_holopilot.nut + weapons/mp_ability_holopilot_nova.nut + weapons/mp_ability_heal.nut + weapons/mp_ability_shifter.nut + weapons/mp_ability_shifter_super.nut + weapons/mp_ability_sonar.nut + weapons/mp_projectile_cluster_rocket.nut + weapons/mp_projectile_titanweapon_rocket_launcher.nut + weapons/mp_projectile_titanweapon_sniper.nut + weapons/mp_projectile_titanweapon_triple_threat.nut + weapons/mp_projectile_weapon_gunship_launcher.nut + weapons/mp_titanability_amped_wall.nut + weapons/mp_titanability_basic_block.nut + weapons/mp_titanability_hover.nut + weapons/mp_titanability_laser_trip.nut + weapons/mp_titanability_particle_wall.nut + weapons/mp_titanability_gun_shield.nut + weapons/mp_titanability_phase_dash.nut + weapons/mp_titanability_slow_trap.nut + weapons/mp_titanability_smoke.nut + weapons/mp_titanability_timeshift.nut + weapons/mp_titanability_tether_trap.nut + weapons/mp_titanability_power_shot.nut + weapons/mp_titanability_ammo_swap.nut + weapons/mp_titanability_rocketeer_ammo_swap.nut + weapons/mp_titanability_sonar_pulse.nut + weapons/mp_titanability_rearm.nut + weapons/mp_titancore_amp_core.nut + weapons/mp_titancore_flame_wave.nut + weapons/mp_titancore_flight_core.nut + weapons/mp_titancore_lasercannon.nut + weapons/mp_titancore_salvo_core.nut + weapons/mp_titancore_shift_core.nut + weapons/mp_titancore_dash_core.nut + weapons/mp_titancore_upgrade.nut + weapons/mp_titancore_siege_mode.nut + weapons/mp_titanweapon_40mm.nut + weapons/mp_titanweapon_arc_wave.nut + weapons/mp_titanweapon_arc_ball.nut + weapons/mp_titanweapon_dumbfire_rockets.nut + weapons/mp_titanweapon_flame_wall.nut + weapons/mp_titanweapon_flightcore_rockets.nut + weapons/mp_titanweapon_homing_rockets.nut + weapons/mp_titanweapon_laser_lite.nut + weapons/mp_titanweapon_leadwall.nut + weapons/mp_titanweapon_particle_accelerator.nut + weapons/mp_titanweapon_predator_cannon.nut + weapons/mp_titanweapon_meteor.nut + weapons/mp_titanweapon_rocketeer_rocketstream.nut + weapons/mp_titanweapon_salvo_rockets.nut + weapons/mp_titanweapon_tracker_rockets.nut + weapons/mp_titanweapon_shoulder_rockets.nut + weapons/mp_titanweapon_sniper.nut + weapons/mp_titanweapon_vortex_shield.nut + weapons/mp_titanweapon_xo16.nut + weapons/mp_titanweapon_heat_shield.nut + weapons/mp_titanweapon_sword.nut + weapons/mp_titanweapon_stun_laser.nut + weapons/mp_weapon_arc_launcher.nut + weapons/mp_weapon_defender.nut + weapons/mp_weapon_deployable_cover.nut + weapons/mp_weapon_deployable_cloakfield.nut + weapons/mp_weapon_dmr.nut + weapons/mp_weapon_dronebeam.nut + weapons/mp_weapon_dronerocket.nut + weapons/mp_weapon_droneplasma.nut + weapons/mp_weapon_turretplasma.nut + weapons/mp_weapon_turretlaser.nut + weapons/mp_weapon_gunship_missile.nut + weapons/mp_weapon_engineer_combat_drone.nut + weapons/mp_weapon_flak_rifle.nut + weapons/mp_weapon_doubletake.nut + weapons/mp_weapon_shotgun_pistol.nut + weapons/mp_weapon_frag_drone.nut + weapons/mp_weapon_grenade_electric_smoke.nut + weapons/mp_weapon_grenade_emp.nut + weapons/mp_weapon_grenade_gravity.nut + weapons/mp_weapon_gunship_launcher.nut + weapons/mp_weapon_lmg.nut + weapons/mp_weapon_lstar.nut + weapons/mp_weapon_mastiff.nut + weapons/mp_weapon_mega_turret.nut + weapons/mp_weapon_mgl.nut + weapons/mp_weapon_softball.nut + weapons/mp_weapon_proximity_mine.nut + weapons/mp_weapon_rocket_launcher.nut + weapons/mp_weapon_satchel.nut + weapons/mp_weapon_shotgun.nut + weapons/mp_weapon_shotgun_doublebarrel.nut + weapons/mp_weapon_smart_pistol.nut + weapons/mp_weapon_smr.nut + weapons/mp_weapon_sniper.nut + weapons/mp_weapon_super_spectre.nut + weapons/mp_weapon_tether.nut + weapons/mp_weapon_thermite_grenade.nut + weapons/mp_weapon_grenade_sonar.nut + weapons/mp_weapon_tripwire.nut + weapons/mp_weapon_yh803.nut + weapons/mp_weapon_zipline.nut + weapons/mp_weapon_alternator_smg.nut + weapons/mp_weapon_gibber_pistol.nut + weapons/mp_weapon_arc_rifle.nut + weapons/mp_weapon_npc_rocket_launcher.nut + weapons/remote_turrets.gnut + weapons/sh_deployable.gnut + weapons/sh_phase_shift.gnut + weapons/sh_smart_ammo.gnut + weapons/sh_sonar.gnut + weapons/sh_stim.gnut + weapons/sh_titancore_utility.gnut + weapons/sh_triple_threat.gnut + weapons/sp_weapon_proto_hold_beam.nut +] + +When: "(SERVER || CLIENT) && SP" +Scripts: +[ + sp/_sp_sh_init.gnut + ai/sh_ai_boss_titan.gnut + sp/sh_crane.gnut + sp/sh_sp_dialogue.gnut + sp/sh_settings_sp.gnut + titan/sh_titan_fastball.nut + weapons/sp_weapon_arc_tool.nut + ai/sh_grunt_chatter.gnut + sp/_sh_gauntlet.gnut + sp/sh_sp_objective.gnut + sp/_onscreen_hints.gnut +] + +When: "((SERVER || CLIENT) && MP) || UI" +Scripts: +[ + gamemodes/sh_all_gamemode_fd.nut +] + +When: "(SERVER || CLIENT) && MP" +Scripts: +[ + conversation/sh_battle_chatter.gnut + conversation/sh_faction_dialogue.gnut + conversation/sh_grunt_chatter_mp.gnut + conversation/sh_spectre_chatter_mp.gnut + + evac/sh_evac.nut + evac/sh_evac_dialogue.nut + mp/sh_game_state_dialog.nut + mp/mp_autoprecache.nut + + mp/_mp_sh_init.gnut + sh_team_titan_selection.gnut + sh_mp_utility.gnut + sh_powerup.gnut + sh_score.gnut + + gamemodes/sh_capture_point.gnut + gamemodes/sh_riff_floor_is_lava.nut + gamemodes/sh_gamemode_at.nut + gamemodes/sh_gamemode_cp.nut + gamemodes/sh_gamemode_cp_dialogue.nut + gamemodes/sh_gamemode_ctf.nut + gamemodes/sh_gamemode_ctf_dialogue.nut + gamemodes/sh_gamemode_mfd.nut + gamemodes/sh_gamemode_mfd_dialogue.nut + gamemodes/sh_gamemode_lts.nut + gamemodes/sh_gamemode_ps.nut + gamemodes/sh_gamemode_tdm.nut + gamemodes/sh_gamemode_ttdm.nut + gamemodes/sh_gamemode_aitdm.nut + gamemodes/sh_gamemode_wlts_dialogue.nut + gamemodes/sh_gamemode_wlts.nut + gamemodes/sh_gamemode_bomb.nut + gamemodes/sh_gamemode_bomb_dialogue.nut + gamemodes/sh_gamemode_ffa.nut + gamemodes/sh_gamemode_ffa_dialogue.nut + + weapons/mp_ability_burncardweapon.nut + weapons/mp_ability_turretweapon.nut + + sh_ping.gnut + + burnmeter/sh_burnmeter.gnut + item_inventory/sh_item_inventory.gnut + + weapons/mp_weapon_arc_trap.nut + gamemodes/sh_gamemode_fd.nut + mp/sh_team_titan_selection_menu.nut +] + +When: "SERVER && SP" +Scripts: +[ + ui/ui_vars.gnut + sp/sh_start_points.nut + mp/_pickups.gnut + ai/_ai_turret_sentry.gnut +] + +When: "SERVER && MP" +Scripts: +[ + ui/ui_vars.gnut + sp/sh_start_points.nut + mp/_utility_mp.gnut + _menu_callbacks.gnut + ai/_ai_turret.gnut + _script_movers_light.gnut +] + +When: "SERVER" +Scripts: +[ + _utility.gnut + _anim.gnut + _bubble_shield.gnut + _codecallbacks_common.gnut + _codecallbacks_player_input.gnut + _control_panel.gnut + _dogfighter.gnut + _global_entities.gnut + _health_regen.gnut + _objective.gnut + _on_spawned.gnut + _passives.gnut + _script_triggers.gnut + _trigger_functions.gnut + _viewcone.gnut + _pain_death_sounds.gnut + sh_savegame.gnut + ai/_ai_chatter.gnut + ai/_ai_stationary_firing_positions.gnut + ai/_ai_cloak_drone.gnut + ai/_ai_drone.gnut + ai/_ai_personal_shield.gnut + ai/_ai_emp_titans.gnut + ai/_ai_gunship.gnut + ai/_ai_lethality.gnut + ai/_ai_marvin_faces.gnut + ai/_ai_marvin_jobs.gnut + ai/_ai_marvins.gnut + ai/_ai_mortar_titans.gnut + ai/_ai_nuke_titans.gnut + ai/_ai_soldiers.gnut + ai/_ai_spawn.gnut + ai/_ai_spawn_content.gnut + ai/_ai_spectre.gnut + ai/_ai_stalker.gnut + ai/_ai_suicide_spectres.gnut + ai/_ai_utility.gnut + ai/_droppod_fireteam.gnut + ai/_squad_spawn.gnut + ai/_titan_npc_behavior.gnut + conversation/_conversation_schedule.gnut + melee/_melee.gnut + melee/_melee_rewards.gnut + melee/_melee_synced_human.gnut + melee/_melee_synced_titan.gnut + mp/_ai_superspectre.nut + mp/_base_gametype.gnut + mp/_changemap.nut + mp/_codecallbacks.gnut + mp/_gamestate.nut + mp/_goblin_dropship.nut + mp/_loadout_crate.nut + mp/_music.gnut + mp/_pickups_glow.gnut + mp/_revive.gnut + mp/_bleedout.gnut + mp/_serverflags.nut + mp/_sniper_spectres.nut + mp/_spawn_functions.nut + mp/_spectre_rack.nut + mp/_titan_npc.nut + mp/_titan_transfer.nut + mp/_tonecontroller.nut + mp/_vr.nut + mp/player_cloak.nut + mp/_titan_tether.gnut + pilot/_leeching.gnut + pilot/_pilot_leeching.gnut + pilot/_slamzoom.nut + pilot/_zipline.gnut + pilot/class_wallrun.gnut + rodeo/_rodeo.gnut + rodeo/_rodeo_titan.gnut + superbar/smokescreen.nut + superbar/orbitalstrike.nut + titan/_replacement_titans.gnut + titan/_replacement_titans_drop.gnut + titan/_titan_commands.gnut + titan/_titan_health.gnut + titan/_titan_hotdrop.gnut + titan/_titan_triple_health.gnut + titan/class_titan.gnut + vehicle/_vehicle_behavior.gnut + vehicle/_vehicle_dropship_new.nut + weapons/_at_turrets.gnut + weapons/_ball_lightning.gnut + weapons/_cloaker.gnut + weapons/_particle_wall.gnut + weapons/_team_emp.gnut + earn_meter/sv_earn_meter.gnut +] + +When: "SERVER && SP" +Scripts: +[ + sp/_savegame.gnut + _trigger_functions_sp.gnut + _script_movers.gnut + sp/_ai_sp.gnut + sp/_sp_introscreen.gnut + ai/_ai_boss_titan.gnut + sp/_gamestate_sp.gnut + ai/_ai_soldiers_sp.gnut + ai/_grunt_chatter.gnut + sp/_gauntlet.gnut + sp/_base_gametype_sp.gnut + sp/_combat_path.gnut + sp/_friendly_follower.gnut + sp/_sp_dropship.nut + sp/_sp_dropship_zipline.nut + sp/_sp_dropship_widow.nut + sp/_infinite_spawners.gnut + sp/_pickups_ammo.gnut + sp/_sp_difficulty.gnut + sp/_sp_loadouts.nut + sp/_start_points.gnut + sp/_utility_sp.gnut + sp/_sp_titanweapon_pickups.gnut + mp/_score_sp.nut + earn_meter/sv_earn_meter_sp.gnut + titan/_titan_hints.gnut + titan/_battery_generator.gnut +] + +When: "SERVER && MP" +Scripts: +[ + lobby/_lobby.gnut + lobby/_private_lobby.gnut + lobby/sh_lobby.gnut + + _harvester.gnut + sh_loadouts_mp.nut + mp/_ai_mp.gnut + _ping.gnut + faction_xp.gnut + titan_xp.gnut + weapon_xp.gnut + _xp.gnut + _powerup.gnut + _side_notifications.gnut + + ai/_ai_soldiers_mp.gnut + + mp/_challenges.gnut + mp/_dropship_spawn_common.gnut + mp/_classic_mp.nut + mp/spawn.nut + mp/spawn_debug.gnut + mp/spawn_wave.gnut + mp/spawn_wave_dropship.gnut + mp/_score.nut + mp/_gamestate_mp.nut + mp/spawn_on_friendly.gnut + mp/pintelemetry.gnut + + conversation/_battle_chatter.gnut + conversation/_faction_dialogue.gnut + conversation/_grunt_chatter_mp.gnut + conversation/_spectre_chatter_mp.gnut + + earn_meter/sv_earn_meter_mp.gnut + evac/_evac.gnut + + ai/_droppod.gnut + + gamemodes/_capture_point.gnut + gamemodes/_ai_gamemodes.gnut + gamemodes/_ai_frontline.gnut + gamemodes/_gamemode_at.nut + gamemodes/_gamemode_speedball.nut + burnmeter/_burnmeter.gnut + gamemodes/_gamemode_coliseum.nut + gamemodes/_gamemode_cp.nut + + gamemodes/_hardpoints.gnut + gamemodes/_gamemode_ctf.nut + + gamemodes/_gamemode_lts.nut + gamemodes/_gamemode_mfd.nut + gamemodes/_gamemode_ps.nut + gamemodes/_gamemode_tdm.nut + gamemodes/_gamemode_ttdm.nut + gamemodes/_gamemode_aitdm.nut + gamemodes/_gamemode_ffa.nut + + mp/_base_gametype_mp.gnut + mp/_playlist.gnut + + gamemodes/_riff_floor_is_lava.nut + + item_inventory/sv_item_inventory.gnut + + ai/_ai_mortar_spectres.gnut + ai/_ai_sniper_titans.gnut + mp/_battery_port.gnut + gamemodes/_gamemode_fd.nut + mp/_lasermesh.gnut +] + +When: "CLIENT || UI" +Scripts: +[ + class/CClientScriptHudElement.nut + sh_scoreboard.gnut + sh_menu_models.gnut + sh_gamepad_utility.gnut +] + +When: "(CLIENT && MP) || UI" +Scripts: +[ + sh_postgame_data.gnut +] + +When: "CLIENT && SP" +Scripts: +[ + ai/cl_ai_boss_titan.gnut + client/cl_utility_sp.gnut + client/cl_sp_obituary.gnut + client/cl_announcement.gnut + client/cl_codecallbacks.gnut + client/cl_codecallbacks_sp.gnut + client/rui/cl_sp_hud.gnut + client/cl_sp_player.gnut + client/cl_respawnselect_sp.gnut + client/cl_sp_objective.gnut + sp/cl_gamestate_sp.gnut + sp/cl_sp_hud.gnut + sp/cl_sp_introscreen.gnut + titan/cl_titan_hints.gnut + sp/_cl_gauntlet.gnut + client/objects/cl_titan_buddy.nut + sp/_sp_cl_titanweapon_pickups.gnut +] + +When: "CLIENT && MP" +Scripts: +[ + client/cl_codecallbacks.gnut + client/cl_codecallbacks_mp.gnut + client/rui/cl_hud.gnut + client/cl_obituary.gnut + client/cl_announcement.gnut + client/cl_gamestate.gnut + client/cl_kill_replay_hud.gnut + client/cl_music.gnut + client/cl_ping.gnut + client/cl_player.gnut + client/cl_powerup.gnut + client/cl_precache.nut + client/cl_respawnselect.gnut + client/cl_scoresplash.gnut + client/cl_utility_mp.gnut + client/cl_side_notifications.gnut + client/cl_spectator_hud.gnut + client/cl_weapon_xp.gnut + client/cl_xp.gnut + client/cl_minimap.gnut + client/cl_titan_xp.gnut + client/cl_pilot_speedometer.gnut + lobby/cl_lobby.gnut + lobby/sh_lobby.gnut + mp/cl_challenges.gnut + + conversation/cl_battle_chatter.gnut + conversation/cl_faction_dialogue.gnut + conversation/cl_grunt_chatter_mp.gnut + conversation/cl_spectre_chatter_mp.gnut + + client/cl_objective.gnut + evac/cl_evac.gnut + //cinematic_mp/_ai_skits_clientdebugging.nut + //cinematic_mp/_cinematic_mp_client.nut + gamemodes/cl_gamemode_at.nut + gamemodes/cl_gamemode_cp.nut + gamemodes/cl_gamemode_speedball.nut + gamemodes/cl_gamemode_aitdm.nut + gamemodes/cl_gamemode_coliseum.nut + gamemodes/cl_gamemode_ctf.nut + gamemodes/cl_gamemode_mfd.nut + gamemodes/cl_gamemode_lts.nut + gamemodes/cl_gamemode_lts_bomb.nut + gamemodes/cl_gamemode_bomb.nut + gamemodes/cl_gamemode_ffa.nut + gamemodes/cl_capture_point.gnut + gamemodes/cl_gamemode_ttdm.nut + + gamemodes/cl_riff_floor_is_lava.nut + gamemodes/cl_riff_floor_is_lava_dialogue.nut + + + mp/cl_classic_mp.gnut + + item_inventory/cl_item_inventory.gnut + + gamemodes/cl_gamemode_fd.nut + mp/cl_lasermesh.gnut +] + + +When: "CLIENT" +Scripts: +[ + client/cl_player_common.gnut + client/cl_utility.gnut + ai/cl_ai_emp_titans.gnut + ai/cl_ai_suicide_spectres.gnut + cl_networkvars.gnut + client/cl_anim.gnut + client/cl_auto_precache.gnut + client/cl_carrier_torpedo_points.nut + client/cl_cockpit_model_names.gnut + client/cl_damage_indicator.gnut + client/cl_data_knife.gnut + client/cl_dof.gnut + client/cl_dpad_hud.gnut + client/cl_entity_creation_functions.gnut + client/cl_event_notification.gnut + client/cl_flyout.gnut + client/cl_goblin_dropship.gnut + client/cl_indicators_hud.gnut + client/cl_introscreen.gnut + client/cl_loadout_crate.gnut + client/cl_main_hud.nut + client/cl_material_proxies.gnut + client/cl_revive.gnut + client/cl_bleedout.gnut + client/cl_rumble.gnut + client/cl_screenfade.gnut + client/cl_titan_cockpit.nut + client/cl_titan_cockpit_sounds.gnut + client/cl_spectator_mode_audio.gnut + client/cl_utility_menu.gnut + client/cl_utility_splash.gnut + client/cl_vdu.gnut + client/cl_voice_hud.gnut + client/cl_zipline.gnut + client/objects/cl_ai_turret.nut + client/objects/cl_annapolis.nut + client/objects/cl_birmingham.nut + client/objects/cl_bomber.nut + client/objects/cl_control_panel.nut + client/objects/cl_crow_dropship.nut + client/objects/cl_crow_dropship_xsmall.nut + client/objects/cl_crow_dropship_hero.nut + client/objects/cl_draconis.nut + client/objects/cl_drone.nut + client/objects/cl_goblin_dropship.nut + client/objects/cl_goblin_dropship_hero.nut + client/objects/cl_gunship.nut + client/objects/cl_hologram_projector.nut + client/objects/cl_hornet_fighter.nut + client/objects/cl_imc_carrier.nut + client/objects/cl_imc_carrier_207.nut + client/objects/cl_phantom_fighter.nut + client/objects/cl_redeye.nut + client/objects/cl_spectre.nut + client/objects/cl_stalker.nut + client/objects/cl_super_spectre.nut + client/objects/cl_titan_atlas.nut + client/objects/cl_titan_ogre.nut + client/objects/cl_titan_stryder.nut + client/objects/cl_widow.nut + conversation/cl_conversation.gnut + conversation/cl_conversation_schedule.gnut + melee/cl_melee.gnut + pilot/cl_pilot_health_hud.gnut + pilot/cl_pilot_jumpjet.gnut + rodeo/cl_rodeo.gnut + rodeo/cl_rodeo_titan.gnut + scoreboard/cl_scoreboard.gnut + scoreboard/cl_scoreboard_precache.gnut + scoreboard/cl_scoreboard_sp.gnut + sentry_turrets/cl_sentry_turrets.gnut + spawnslot/cl_spawnslot_system.gnut + titan/cl_replacement_titan_hud.gnut + titan/cl_titan_commands.gnut + titan/cl_titan_dialogue.gnut + titan/cl_titan_enemy_tracker.gnut + titan/cl_titan_hud.gnut + titan/cl_titan_soul.gnut + titan/cl_titan_triple_health.gnut + titan/cl_tone_hud.gnut + weapons/cl_smart_ammo.gnut + weapons/cl_team_emp.gnut + client/rui/cl_weapon_status.gnut + + // leave this last so it can contain any struct + cl_globals.gnut + earn_meter/cl_earn_meter.gnut +] + +When: "UI" +Scripts: +[ + ui/ui_vscript.gnut + ui/ui_utility.gnut + ui/combo_buttons.nut + ui/_buy.nut + ui/_tabs.nut + ui/_footer.nut + ui/_grid_menu.gnut + ui/_loadout_shared.nut + ui/_menu_utility.nut + ui/_menus.nut + ui/_friends.nut + ui/notifications.nut + ui/openinvites.nut + ui/chatroom.nut + ui/menu_action_blocks.nut + ui/menu_advocate_letter.nut + ui/menu_burn_cards.nut + ui/menu_challenges.nut + ui/menu_community.nut + ui/menu_credits.nut + ui/menu_dev.nut + ui/menu_test.nut + ui/menu_dialog.nut + ui/menu_eula_dialog.nut + ui/menu_review_terms_dialog.nut + ui/menu_registration_dialog.nut + ui/menu_advocate_gift_dialog.nut + ui/menu_edit_loadout_pilot.nut + ui/menu_edit_loadout_titan.nut + ui/menu_edit_camo.nut + ui/menu_edit_nose_art.nut + ui/menu_edit_callsign_card.nut + ui/menu_edit_callsign_icon.nut + ui/menu_postgame.nut + ui/menu_knowledgebase.nut + ui/menu_knowledgebase_submenu.nut + ui/panel_summary.nut + ui/panel_pve.nut + ui/panel_scoreboard.nut + ui/menu_armory.nut + ui/menu_eog.nut + ui/menu_eog_challenges.nut + ui/menu_eog_coins.nut + ui/menu_eog_scoreboard.nut + ui/menu_eog_unlocks.nut + ui/menu_eog_xp.nut + ui/menu_faction_choice.nut + ui/menu_controls.nut + ui/menu_controls_advanced_look.nut + ui/menu_gamepad_layout.nut + ui/menu_generation_respawn.nut + ui/menu_ingame.nut + ui/menu_invite_friends_to_network.nut + //ui/menu_invite_friends_to_party.nut + ui/menu_play_video.nut + ui/menu_lobby.nut + ui/menu_private_match.nut + ui/menu_search.nut + ui/menu_main.nut + ui/panel_mainmenu.nut + ui/panel_establishuser.nut + ui/menu_gamma.nut + ui/menu_map_select.nut + ui/menu_match_settings.nut + ui/menu_matchmaking_utility.nut + ui/menu_mode_select.nut + ui/menu_playlist.nut + ui/menu_playlist_mixtape.nut + ui/menu_single_player.nut + ui/menu_single_player_dev.nut + ui/menu_sp_loadout_titan.nut + ui/menu_sp_loadout_titan_tutorial.nut + ui/menu_sp_training.gnut + ui/menu_stats.nut + ui/menu_store.nut + ui/menu_store_new_releases.nut + ui/menu_store_limited.nut + ui/menu_store_bundles.nut + ui/menu_store_prime_titans.nut + ui/menu_store_customization.nut + ui/menu_store_customization_preview.nut + ui/menu_store_camo.nut + ui/menu_store_camo_preview.nut + ui/menu_store_callsign.nut + ui/menu_store_callsign_preview.nut + ui/menu_store_weapons.nut + ui/menu_store_titans.nut + ui/menu_store_weapon_skin_bundles.nut + ui/menu_advanced_hud.nut + ui/menu_inbox.nut + ui/menu_stats_misc.nut + ui/menu_stats_overview.nut + ui/menu_stats_time.nut + ui/menu_stats_utility.nut + ui/menu_stats_weapons.nut + ui/menu_stats_titans.nut + ui/menu_stats_maps.nut + ui/menu_stats_pve.nut + ui/menu_pilot_loadouts_shared.nut + ui/menu_pilot_loadouts.nut + ui/menu_edit_pilot_loadouts.nut + ui/menu_titan_loadouts_shared.nut + ui/menu_titan_loadouts.nut + ui/menu_edit_titan_loadouts.nut + ui/menu_team_titan_select.nut + ui/menu_fdplaylist.nut + ui/menu_fd_titan_upgrade.nut + ui/menu_boost_store.nut + + //ui/menu_store_weapon_select.nut + //ui/menu_store_weapon_skin_preview.nut + + ui/panel_fd_awards.nut + + burnmeter/sh_burnmeter.gnut + sp/sh_sp_objective_strings.gnut + lobby/sh_lobby.gnut +] + +When: "UI && PC_PROG" +Scripts: +[ + ui/menu_mouse_keyboard_bindings.nut + ui/menu_audio_settings.nut + ui/menu_demo_settings.nut + ui/menu_video_settings.nut +] + +When: "UI && CONSOLE_PROG" +Scripts: +[ + ui/menu_audio_video.nut +] + +When: "SERVER && DEV || UI && DEV" +Scripts: +[ + ai/sh_dev_npc_settings.gnut +] + +When: "CLIENT && DEV" +Scripts: +[ + client/_cl_model_viewer.nut +] + +/* +When: "SERVER && MAP_mp_ab_test" +Scripts: +[ + test\mp_ab_test.nut +] +*/ + +// DEVSCRIPTS CONTENT + +/* +When: "(SERVER || CLIENT) && MP" +Scripts: +[ + + gamemodes/sh_gamemode_atcoop.nut + gamemodes/sh_gamemode_cq.nut + + gamemodes/sh_gamemode_cq_dialogue.nut +] + +When: "MP || UI" +Scripts: +[ + conversation/sh_dpad_comms.gnut +] + +When: "SERVER && MP" +Scripts: +[ + + gamemodes/_gamemode_atcoop.nut + gamemodes/_gamemode_cq.nut + gamemodes/_gamemode_mfd_pro.nut + gamemodes/_gamemode_lts_bomb.nut + gamemodes/_gamemode_wlts.nut + gamemodes/_gamemode_bomb.nut + gamemodes/_gamemode_wps.nut + +] + +When: "CLIENT && MP" +Scripts: +[ + gamemodes/cl_gamemode_atcoop.nut + gamemodes/cl_gamemode_cq.nut + + conversation/cl_dpad_comms.gnut +] + +When: "UI" +Scripts: +[ + + ui/menu_edit_dpad_comms.nut + ui/menu_select_dpad_comms.nut +] + +// END DEVSCRIPTS CONTENT +*/ diff --git a/src/scripts/vscripts/ui/_menus.nut b/src/scripts/vscripts/ui/_menus.nut new file mode 100644 index 0000000..7449cad --- /dev/null +++ b/src/scripts/vscripts/ui/_menus.nut @@ -0,0 +1,2003 @@ +untyped + +global const bool EDIT_LOADOUT_SELECTS = true +global const string PURCHASE_SUCCESS_SOUND = "UI_Menu_Store_Purchase_Success" + +global function UICodeCallback_CloseAllMenus +global function UICodeCallback_ActivateMenus +global function UICodeCallback_LevelInit +global function UICodeCallback_LevelLoadingStarted +global function UICodeCallback_LevelLoadingFinished +global function UICodeCallback_LevelShutdown +global function UICodeCallback_OnConnected +global function UICodeCallback_OnFocusChanged +global function UICodeCallback_NavigateBack +global function UICodeCallback_ToggleInGameMenu +global function UICodeCallback_TryCloseDialog +global function UICodeCallback_UpdateLoadingLevelName +global function UICodeCallback_ConsoleKeyboardClosed +global function UICodeCallback_ErrorDialog +global function UICodeCallback_AcceptInvite +global function UICodeCallback_OnDetenteDisplayed +global function UICodeCallback_OnSpLogDisplayed +global function UICodeCallback_EntitlementsChanged +global function UICodeCallback_StoreTransactionCompleted +global function UICodeCallback_GamePurchased +global function UICodeCallback_PartyUpdated +global function UICodeCallback_KeyBindOverwritten + +global function AdvanceMenu +global function OpenSubmenu // REMOVE +global function CloseSubmenu // REMOVE +global function CloseActiveMenu +global function CloseActiveMenuNoParms +global function CloseAllMenus +global function CloseAllInGameMenus +global function CloseAllDialogs +global function CloseAllToTargetMenu +global function PrintMenuStack +global function CleanupInGameMenus +global function GetActiveMenu +global function GetMenu +global function GetPanel +global function GetAllMenuPanels +global function InitGamepadConfigs +global function InitMenus +global function AdvanceMenuEventHandler +global function PCSwitchTeamsButton_Activate +global function PCToggleSpectateButton_Activate +global function AddMenuElementsByClassname +global function FocusDefault +global function SetPanelDefaultFocus +global function PanelFocusDefault +global function OpenMenuWrapper +global function CloseMenuWrapper +global function IsLevelMultiplayer +global function AddMenuEventHandler +global function AddPanelEventHandler +global function AddButtonEventHandler +global function AddEventHandlerToButton +global function AddEventHandlerToButtonClass +global function DisableMusic +global function EnableMusic +global function PlayMusic +global function StopMusic +global function IsMenuInMenuStack +global function GetTopNonDialogMenu +global function IsDialog +global function IsDialogActive +global function IsDialogOnlyActiveMenu +global function SetNavUpDown +global function SetNavLeftRight +global function IsTrialPeriodActive +global function LaunchGamePurchaseOrDLCStore +global function SetMenuThinkFunc + +global function PCBackButton_Activate + +global function RegisterMenuVarInt +global function GetMenuVarInt +global function SetMenuVarInt +global function RegisterMenuVarBool +global function GetMenuVarBool +global function SetMenuVarBool +global function RegisterMenuVarVar +global function GetMenuVarVar +global function SetMenuVarVar +global function AddMenuVarChangeHandler + +global function InviteFriends + +global function HACK_DelayedSetFocus_BecauseWhy + +#if DURANGO_PROG + global function OpenXboxPartyApp + global function OpenXboxHelp +#endif // DURANGO_PROG + +global function OpenReviewTermsDialog +global function ClassicMusic_OnChange +global function IsClassicMusicAvailable + + +void function UICodeCallback_CloseAllMenus() +{ + printt( "UICodeCallback_CloseAllMenus" ) + CloseAllMenus() + // This is usually followed by a call to UICodeCallback_ActivateMenus(). +} + +// Bringing up the console will cause this, and it probably shouldn't +void function UICodeCallback_ActivateMenus() +{ + if ( IsConnected() ) + return + + printt( "UICodeCallback_ActivateMenus:", uiGlobal.activeMenu && Hud_GetHudName( uiGlobal.activeMenu ) ) + + if ( uiGlobal.menuStack.len() == 0 ) + { + AdvanceMenu( GetMenu( "MainMenu" ) ) + } + + if ( uiGlobal.activeMenu == GetMenu( "MainMenu" ) ) + Signal( uiGlobal.signalDummy, "OpenErrorDialog" ) + + PlayMusic() + + #if DURANGO_PROG + Durango_LeaveParty() + #endif // DURANGO_PROG +} + +void function UICodeCallback_ToggleInGameMenu() +{ + if ( !IsFullyConnected() ) + return + + var activeMenu = uiGlobal.activeMenu + bool isMP = IsLevelMultiplayer( GetActiveLevel() ) + bool isLobby = IsLobby() + + var ingameMenu + if ( isMP ) + { + ingameMenu = GetMenu( "InGameMPMenu" ) + } + else + { + // Disable this callback for this special case menu so players can't skip it. + var spTitanTutorialMenu = GetMenu( "SPTitanLoadoutTutorialMenu" ) + if ( activeMenu == spTitanTutorialMenu ) + return + + ingameMenu = GetMenu( "InGameSPMenu" ) + } + + if ( IsDialog( uiGlobal.activeMenu ) ) + { + // Do nothing if a dialog is showing + } + else if ( TeamTitanSelectMenuIsOpen() ) + { + if ( uiGlobal.activeMenu == GetMenu( "TeamTitanSelectMenu" ) ) + { + // Do nothing here either + } + else + { + CloseActiveMenu() + } + } + else if ( ( isMP && !isLobby ) || !isMP ) + { + if ( !activeMenu ) + AdvanceMenu( ingameMenu ) + else + CloseAllInGameMenus() + } +} + +// Return true to show load screen, false to not show load screen. +// levelname can be "" because the level to load isn't always known when the load screen starts +bool function UICodeCallback_LevelLoadingStarted( string levelname ) +{ + printt( "UICodeCallback_LevelLoadingStarted: " + levelname ) + + CloseAllDialogs() + + uiGlobal.loadingLevel = levelname + + StopMusic() + + if ( uiGlobal.playingVideo ) + Signal( uiGlobal.signalDummy, "PlayVideoEnded" ) + + if ( uiGlobal.playingCredits ) + Signal( uiGlobal.signalDummy, "PlayingCreditsDone" ) + + // kill lingering postgame summary since persistent data may not be available at this point + Signal( uiGlobal.signalDummy, "PGDisplay" ) + +#if CONSOLE_PROG + if ( !Console_IsSignedIn() ) + return false +#endif + + return true +} + +// Return true to show load screen, false to not show load screen. +bool function UICodeCallback_UpdateLoadingLevelName( string levelname ) +{ + printt( "UICodeCallback_UpdateLoadingLevelName: " + levelname ) + +#if CONSOLE_PROG + if ( !Console_IsSignedIn() ) + return false +#endif + + return true +} + +void function UICodeCallback_LevelLoadingFinished( bool error ) +{ + printt( "UICodeCallback_LevelLoadingFinished: " + uiGlobal.loadingLevel + " (" + error + ")" ) + + if ( !IsLobby() ) + { + HudChat_ClearTextFromAllChatPanels() + ResetActiveChatroomLastModified() + } + else + { + uiGlobal.lobbyFromLoadingScreen = true + } + + uiGlobal.loadingLevel = "" + Signal( uiGlobal.signalDummy, "LevelFinishedLoading" ) +} + +void function UICodeCallback_LevelInit( string levelname ) +{ + Assert( IsConnected() ) + + StopVideo() + + uiGlobal.loadedLevel = levelname + + printt( "UICodeCallback_LevelInit: " + uiGlobal.loadedLevel ) + + if ( !uiGlobal.loadoutsInitialized ) + { + string gameModeString = GetConVarString( "mp_gamemode" ) + if ( gameModeString != "solo" ) + { + InitStatsTables() + } + } + + InitItems() + + if ( IsMultiplayer() ) + { + ShWeaponXP_Init() + ShTitanXP_Init() + ShFactionXP_Init() + } + else + { + SPObjectiveStringsInit() + } + + #if DEV + UpdatePrecachedSPWeapons() + #endif + + + if ( !uiGlobal.loadoutsInitialized ) + { + string gameModeString = GetConVarString( "mp_gamemode" ) + if ( gameModeString != "solo" ) + { + DeathHints_Init() + InitDefaultLoadouts() + CreateChallenges() + uiGlobal.loadoutsInitialized = true + } + } + + if ( IsLevelMultiplayer( levelname ) || IsLobbyMapName( levelname ) ) + { + thread UpdateCachedLoadouts() + thread UpdateCachedNewItems() + thread InitUISpawnLoadoutIndexes() + + if ( !uiGlobal.eventHandlersAdded ) + { + uiGlobal.eventHandlersAdded = true + } + + UI_GetAllChallengesProgress() + + bool isLobby = IsLobbyMapName( levelname ) + + string gameModeString = GetConVarString( "mp_gamemode" ) + if ( gameModeString == "" ) + gameModeString = "" + + Assert( gameModeString == GetConVarString( "mp_gamemode" ) ) + Assert( gameModeString != "" ) + + int gameModeId = GameMode_GetGameModeId( gameModeString ) + + int mapId = eMaps.invalid + if ( levelname in getconsttable().eMaps ) + { + mapId = expect int( getconsttable().eMaps[ levelname ] ) + } + else + { + // Don't worry about this until we have to consider R2 Durango TCRs (10/2015) + //if ( !IsTestMap() ) + // CodeWarning( "No map named '" + levelname + "' exists in eMaps, all shipping maps should be in this enum" ) + } + + int difficultyLevelId = 0 + int roundId = 0 + + if ( isLobby ) + Durango_OnLobbySessionStart( gameModeId, difficultyLevelId ) + else + Durango_OnMultiplayerRoundStart( gameModeId, mapId, difficultyLevelId, roundId, 0 ) + } + else + { + // SP loadout stuff + UI_GetAllChallengesProgress() // TODO: Can this be moved so we don't call it twice? It's called above. + + SP_ResetObjectiveStringIndex() // Since this persists thru level load, we need to explicitely clear it. + } + + if ( IsMultiplayer() ) + { + foreach ( callbackFunc in uiGlobal.onLevelInitCallbacks ) + { + thread callbackFunc() + } + + } + thread UpdateMenusOnConnect( levelname ) + + uiGlobal.previousLevel = uiGlobal.loadedLevel + uiGlobal.previousPlaylist = GetCurrentPlaylistName() +} + +void function UICodeCallback_LevelShutdown() +{ + Signal( uiGlobal.signalDummy, "LevelShutdown" ) + + printt( "UICodeCallback_LevelShutdown: " + uiGlobal.loadedLevel ) + + StopVideo() + + if ( uiGlobal.loadedLevel != "" ) + CleanupInGameMenus() + + uiGlobal.loadedLevel = "" + uiGlobal.mapSupportsMenuModelsUpdated = false + uiGlobal.sp_showAlternateMissionLog = false +} + +void function UICodeCallback_NavigateBack() +{ + if ( uiGlobal.activeMenu == null ) + return + + if ( IsDialog( uiGlobal.activeMenu ) ) + { + if ( uiGlobal.menuData[ uiGlobal.activeMenu ].dialogData.noChoice || + uiGlobal.menuData[ uiGlobal.activeMenu ].dialogData.forceChoice || + Time() < uiGlobal.dialogInputEnableTime ) + return + } + + Assert( uiGlobal.activeMenu in uiGlobal.menuData ) + if ( uiGlobal.menuData[ uiGlobal.activeMenu ].navBackFunc != null ) + { + thread uiGlobal.menuData[ uiGlobal.activeMenu ].navBackFunc() + return + } + + if ( uiGlobal.activeMenu.GetType() == "submenu" ) // REMOVE + { + CloseSubmenu() + return + } + + CloseActiveMenu( true ) +} + +// Called when IsConnected() will start returning true. +void function UICodeCallback_OnConnected() +{ + +} + +void function UICodeCallback_OnFocusChanged( var oldFocusedPanel, var newFocusedPanel ) +{ + +} + +// Accepting an origin invite closes dialogs, or aborts if they can't be closed +bool function UICodeCallback_TryCloseDialog() +{ + if ( !IsDialog( uiGlobal.activeMenu ) ) + return true + + if ( uiGlobal.menuData[ uiGlobal.activeMenu ].dialogData.forceChoice ) + return false + + CloseAllDialogs() + Assert( !IsDialog( uiGlobal.activeMenu ) ) + return true +} + +void function UICodeCallback_ConsoleKeyboardClosed() +{ + switch ( uiGlobal.activeMenu ) + { + case GetMenu( "EditPilotLoadoutMenu" ): + string oldName = GetPilotLoadoutName( GetCachedPilotLoadout( uiGlobal.editingLoadoutIndex ) ) + string newName = GetPilotLoadoutRenameText() + + // strip doesn't work on UTF-8 strings + // newName = strip( newName ) // Remove leading/trailing whitespace + if ( newName == "" ) // If all whitespace entered reset to previous name + newName = oldName + + SetPilotLoadoutName( newName ) + SelectPilotLoadoutRenameText() + if ( newName != oldName ) + EmitUISound( "Menu.Accept" ) // No callback when cancelled so for now assume name was changed + break + + default: + break + } +} + +void function UICodeCallback_OnDetenteDisplayed() +{ +// thread PlayDetentSound() +//} +// +//void function PlayDetentSound() +//{ +// WaitFrame() // otherwise gets killed off by code pause +// WaitFrame() // otherwise gets killed off by code pause +// EmitUISound( "Pilot_Killed_Indicator" ) +} + +void function UICodeCallback_OnSpLogDisplayed() +{ +} + +void function UICodeCallback_ErrorDialog( string errorDetails ) +{ + printt( "UICodeCallback_ErrorDialog: " + errorDetails ) + thread OpenErrorDialog( errorDetails ) +} + +void function UICodeCallback_AcceptInviteThread( string accesstoken ) +{ + printt( "UICodeCallback_AcceptInviteThread '" + accesstoken + "'") + + #if PS4_PROG + if ( !Ps4_PSN_Is_Loggedin() ) + { + Ps4_LoginDialog_Schedule(); + while( Ps4_LoginDialog_Running() ) + WaitFrame() + if ( !Ps4_PSN_Is_Loggedin() ) + return; + } + + if( Ps4_CheckPlus_Schedule() ) + { + while( Ps4_CheckPlus_Running() ) + WaitFrame() + if( !Ps4_CheckPlus_Allowed() ) + { + if( Ps4_CheckPlus_GetLastRequestResults() != 0 ) + { + return + } + + if( Ps4_ScreenPlusDialog_Schedule() ) + { + while( Ps4_ScreenPlusDialog_Running() ) + WaitFrame() + if( !Ps4_ScreenPlusDialog_Allowed() ) + return; + } + else + { + return; + } + } + } + + #endif // #if PS4_PROG + + SubscribeToChatroomPartyChannel( accesstoken ); + +} + + +void function UICodeCallback_AcceptInvite( string accesstoken ) +{ + printt( "UICodeCallback_AcceptInvite '" + accesstoken + "'") + thread UICodeCallback_AcceptInviteThread( accesstoken ) +} + +// TODO: replaceCurrent should not be an option. It should be a different function. +void function AdvanceMenu( var menu, bool replaceCurrent = false ) +{ + //foreach ( index, menu in uiGlobal.menuStack ) + //{ + // if ( menu != null ) + // printt( "menu index " + index + " is named " + menu.GetDisplayName() ) + //} + + if ( uiGlobal.activeMenu ) + { + // Don't open the same menu again if it's already open + if ( uiGlobal.activeMenu == menu ) + return + + // Opening a normal menu while a dialog is open + Assert( !IsDialog( uiGlobal.activeMenu ), "Tried opening menu: " + Hud_GetHudName( menu ) + " when uiGlobal.activeMenu was: " + Hud_GetHudName( uiGlobal.activeMenu ) ) + } + + if ( uiGlobal.activeMenu && !IsDialog( menu ) ) // Dialogs show on top so don't close existing menu when opening them + { + SetBlurEnabled( false ) + + if ( replaceCurrent ) + { + CloseMenuWrapper( uiGlobal.activeMenu ) + uiGlobal.menuStack.pop() + } + else + { + CloseMenu( uiGlobal.activeMenu ) + printt( Hud_GetHudName( uiGlobal.activeMenu ), "menu closed" ) + } + } + + if ( IsDialog( menu ) && uiGlobal.activeMenu ) + SetFooterPanelVisibility( uiGlobal.activeMenu, false ) + + uiGlobal.menuStack.push( menu ) + uiGlobal.activeMenu = menu + + uiGlobal.lastMenuNavDirection = MENU_NAV_FORWARD + + if ( uiGlobal.activeMenu ) + { + if ( !IsLobby() && !uiGlobal.mapSupportsMenuModels ) + SetBlurEnabled( true ) + + OpenMenuWrapper( uiGlobal.activeMenu, true ) + } + + Signal( uiGlobal.signalDummy, "ActiveMenuChanged" ) +} + +void function SetFooterPanelVisibility( var menu, bool visible ) +{ + if ( !Hud_HasChild( menu, "FooterButtons" ) ) + return + + var panel = Hud_GetChild( menu, "FooterButtons" ) + Hud_SetVisible( panel, visible ) +} + +void function OpenSubmenu( var menu, bool updateMenuPos = true ) +{ + Assert( menu ) + Assert( menu.GetType() == "submenu" ) + + if ( uiGlobal.activeMenu ) + { + // Don't open the same menu again if it's already open + if ( uiGlobal.activeMenu == menu ) + return + } + + local submenuPos = Hud_GetAbsPos( GetFocus() ) + + uiGlobal.menuStack.push( menu ) + uiGlobal.activeMenu = menu + + OpenMenuWrapper( uiGlobal.activeMenu, true ) + + if ( updateMenuPos ) + { + var vguiButtonFrame = Hud_GetChild( uiGlobal.activeMenu, "ButtonFrame" ) + Hud_SetPos( vguiButtonFrame, submenuPos[0], submenuPos[1] ) + } + + uiGlobal.lastMenuNavDirection = MENU_NAV_FORWARD + + Signal( uiGlobal.signalDummy, "ActiveMenuChanged" ) +} + +void function CloseSubmenu( bool openStackMenu = true ) +{ + if ( !uiGlobal.activeMenu ) + return + + if ( uiGlobal.activeMenu.GetType() != "submenu" ) + return + + CloseMenuWrapper( uiGlobal.activeMenu ) + uiGlobal.menuStack.pop() + + uiGlobal.lastMenuNavDirection = MENU_NAV_FORWARD + + if ( uiGlobal.menuStack.len() ) + { + uiGlobal.activeMenu = uiGlobal.menuStack.top() + + // This runs any OnOpen function for the menu and sets focus, but doesn't actually open the menu because it is already open + if ( openStackMenu ) + OpenMenuWrapper( uiGlobal.activeMenu, false ) + } + else + { + uiGlobal.activeMenu = null + } + + Signal( uiGlobal.signalDummy, "ActiveMenuChanged" ) +} + +void function CloseActiveMenuNoParms() +{ + CloseActiveMenu() +} + +void function CloseActiveMenu( bool cancelled = false, bool openStackMenu = true ) +{ + bool updateBlur = true + bool wasDialog = false + + if ( uiGlobal.activeMenu ) + { + if ( IsDialog( uiGlobal.activeMenu ) ) + { + updateBlur = false + wasDialog = true + uiGlobal.dialogInputEnableTime = 0.0 + + if ( uiGlobal.dialogCloseCallback ) + { + uiGlobal.dialogCloseCallback( cancelled ) + uiGlobal.dialogCloseCallback = null + } + } + + if ( updateBlur ) + SetBlurEnabled( false ) + + CloseMenuWrapper( uiGlobal.activeMenu ) + } + + uiGlobal.menuStack.pop() + if ( uiGlobal.menuStack.len() ) + uiGlobal.activeMenu = uiGlobal.menuStack.top() + else + uiGlobal.activeMenu = null + + uiGlobal.lastMenuNavDirection = MENU_NAV_BACK + + if ( wasDialog ) + { + if ( uiGlobal.activeMenu ) + SetFooterPanelVisibility( uiGlobal.activeMenu, true ) + + if ( IsDialog( uiGlobal.activeMenu ) ) + openStackMenu = true + else + openStackMenu = false + } + + if ( uiGlobal.activeMenu ) + { + if ( uiGlobal.activeMenu.GetType() == "submenu" ) + { + Hud_SetFocused( uiGlobal.menuData[ uiGlobal.activeMenu ].lastFocus ) + } + else if ( openStackMenu ) + { + OpenMenuWrapper( uiGlobal.activeMenu, false ) + + if ( updateBlur && !IsLobby() && !uiGlobal.mapSupportsMenuModels ) + SetBlurEnabled( true ) + } + } + + Signal( uiGlobal.signalDummy, "ActiveMenuChanged" ) +} + +void function CloseAllMenus() +{ + if ( IsDialog( uiGlobal.activeMenu ) ) + CloseActiveMenu( true ) + + if ( uiGlobal.activeMenu && uiGlobal.activeMenu.GetType() == "submenu" ) + CloseSubmenu( false ) + + if ( uiGlobal.activeMenu ) + { + SetBlurEnabled( false ) + CloseMenuWrapper( uiGlobal.activeMenu ) + } + + uiGlobal.menuStack = [] + uiGlobal.activeMenu = null + + uiGlobal.lastMenuNavDirection = MENU_NAV_BACK + + Signal( uiGlobal.signalDummy, "ActiveMenuChanged" ) +} + +void function CloseAllInGameMenus() +{ + while ( uiGlobal.activeMenu ) + { + if ( uiGlobal.activeMenu.GetType() == "submenu" ) + CloseSubmenu( false ) + + CloseActiveMenu( true, false ) + } +} + +void function CloseAllDialogs() +{ + while ( IsDialog( uiGlobal.activeMenu ) ) + CloseActiveMenu( true ) +} + +void function CloseAllToTargetMenu( var targetMenu ) +{ + while ( uiGlobal.activeMenu != targetMenu ) + CloseActiveMenu( true, false ) +} + +void function PrintMenuStack() +{ + array stack = clone uiGlobal.menuStack + stack.reverse() + + printt( "MENU STACK:" ) + + foreach ( menu in stack ) + { + if ( menu ) + printt( " ", Hud_GetHudName( menu ) ) + else + printt( " null" ) + } +} + +// Happens on any level load +void function UpdateMenusOnConnect( string levelname ) +{ + EndSignal( uiGlobal.signalDummy, "LevelShutdown" ) // HACK fix because UICodeCallback_LevelInit() incorrectly runs when disconnected by client error. Test with "script_error_client" while a level is loaded. + + CloseAllDialogs() + + var mainMenu = GetMenu( "MainMenu" ) + if ( IsMenuInMenuStack( mainMenu ) && !IsMenuInMenuStack( null ) ) + CloseAllToTargetMenu( mainMenu ) + + Assert( uiGlobal.activeMenu != null || uiGlobal.menuStack.len() == 0 ) + + AdvanceMenu( null ) + + // TODO: The order things are called in should be predictable so this isn't needed + while ( !uiGlobal.mapSupportsMenuModelsUpdated ) + { + //printt( Time(), "beginning waitframe, uiGlobal.mapSupportsMenuModelsUpdated is:", uiGlobal.mapSupportsMenuModelsUpdated ) + WaitFrame() + //printt( Time(), "ended waitframe, uiGlobal.mapSupportsMenuModelsUpdated is:", uiGlobal.mapSupportsMenuModelsUpdated ) + } + + if ( IsLevelMultiplayer( levelname ) ) + { + bool isLobby = IsLobbyMapName( levelname ) + + if ( isLobby ) + { + if ( IsPrivateMatch() ) + { + AdvanceMenu( GetMenu( "PrivateLobbyMenu" ) ) + } + else + { + AdvanceMenu( GetMenu( "LobbyMenu" ) ) + } + + thread UpdateAnnouncementDialog() + } + else + { + UI_SetPresentationType( ePresentationType.INACTIVE ) + } + } +} + +bool function IsMenuInMenuStack( var searchMenu ) +{ + foreach ( menu in uiGlobal.menuStack ) + { + // loading a map pushes a null sentinel onto the menu stack + if ( !menu ) + continue + + if ( menu == searchMenu ) + return true + } + + return false +} + +var function GetTopNonDialogMenu() +{ + array menuArray = clone uiGlobal.menuStack + menuArray.reverse() + + foreach ( menu in menuArray ) + { + if ( menu == null || IsDialog( menu ) ) + continue + + return menu + } + + return null +} + +void function CleanupInGameMenus() +{ + Signal( uiGlobal.signalDummy, "CleanupInGameMenus" ) + + CloseAllInGameMenus() + Assert( uiGlobal.activeMenu == null ) + if ( uiGlobal.menuStack.len() ) + { + if ( uiGlobal.loadingLevel == "" ) + CloseActiveMenu() // Disconnected. Remove stack null and open main menu. + else + CloseActiveMenu( true, false ) // Level to level transition. Remove stack null and DON'T open main menu. + } +} + +var function GetActiveMenu() +{ + return uiGlobal.activeMenu +} + +var function GetMenu( string menuName ) +{ + return uiGlobal.menus[ menuName ] +} + +var function GetPanel( string panelName ) +{ + return uiGlobal.panels[ panelName ] +} + +array function GetAllMenuPanels( var menu ) +{ + array menuPanels + + foreach ( panel in uiGlobal.allPanels ) + { + if ( Hud_GetParent( panel ) == menu ) + menuPanels.append( panel ) + } + + return menuPanels +} + +void function InitGamepadConfigs() +{ + uiGlobal.buttonConfigs = [ { orthodox = "gamepad_button_layout_default.cfg", southpaw = "gamepad_button_layout_default_southpaw.cfg" } ] + uiGlobal.buttonConfigs.append( { orthodox = "gamepad_button_layout_bumper_jumper.cfg", southpaw = "gamepad_button_layout_bumper_jumper_southpaw.cfg" } ) + uiGlobal.buttonConfigs.append( { orthodox = "gamepad_button_layout_bumper_jumper_alt.cfg", southpaw = "gamepad_button_layout_bumper_jumper_alt_southpaw.cfg" } ) + uiGlobal.buttonConfigs.append( { orthodox = "gamepad_button_layout_pogo_stick.cfg", southpaw = "gamepad_button_layout_pogo_stick_southpaw.cfg" } ) + uiGlobal.buttonConfigs.append( { orthodox = "gamepad_button_layout_button_kicker.cfg", southpaw = "gamepad_button_layout_button_kicker_southpaw.cfg" } ) + uiGlobal.buttonConfigs.append( { orthodox = "gamepad_button_layout_circle.cfg", southpaw = "gamepad_button_layout_circle_southpaw.cfg" } ) + uiGlobal.buttonConfigs.append( { orthodox = "gamepad_button_layout_ninja.cfg", southpaw = "gamepad_button_layout_ninja_southpaw.cfg" } ) + uiGlobal.buttonConfigs.append( { orthodox = "gamepad_button_layout_custom.cfg", southpaw = "gamepad_button_layout_custom.cfg" } ) + + uiGlobal.stickConfigs = [] + uiGlobal.stickConfigs.append( "gamepad_stick_layout_default.cfg" ) + uiGlobal.stickConfigs.append( "gamepad_stick_layout_southpaw.cfg" ) + uiGlobal.stickConfigs.append( "gamepad_stick_layout_legacy.cfg" ) + uiGlobal.stickConfigs.append( "gamepad_stick_layout_legacy_southpaw.cfg" ) + + foreach ( key, val in uiGlobal.buttonConfigs ) + { + VPKNotifyFile( "cfg/" + val.orthodox ) + VPKNotifyFile( "cfg/" + val.southpaw ) + } + + foreach ( key, val in uiGlobal.stickConfigs ) + VPKNotifyFile( "cfg/" + val ) + + ExecCurrentGamepadButtonConfig() + ExecCurrentGamepadStickConfig() + + SetStandardAbilityBindingsForPilot( GetLocalClientPlayer() ) +} + +void function InitMenus() +{ + InitGlobalMenuVars() + SpShWeaponsInit() + + AddMenu( "MainMenu", $"resource/ui/menus/main.menu", InitMainMenu, "#MAIN" ) + AddPanel( GetMenu( "MainMenu" ), "EstablishUserPanel", InitEstablishUserPanel ) + AddPanel( GetMenu( "MainMenu" ), "MainMenuPanel", InitMainMenuPanel ) + + AddMenu( "PlayVideoMenu", $"resource/ui/menus/play_video.menu", InitPlayVideoMenu ) + AddMenu( "LobbyMenu", $"resource/ui/menus/lobby.menu", InitLobbyMenu, "#LOBBY" ) + + AddMenu( "FDMenu", $"resource/ui/menus/playlist_fd.menu", InitFDPlaylistMenu ) + AddMenu( "TeamTitanSelectMenu", $"resource/ui/menus/team_titan_select.menu", InitTeamTitanSelectMenu ) + AddMenu( "PlaylistMenu", $"resource/ui/menus/playlist.menu", InitPlaylistMenu ) + AddMenu( "PlaylistMixtapeMenu", $"resource/ui/menus/playlist_mixtape.menu", InitPlaylistMixtapeMenu ) + AddMenu( "PlaylistMixtapeChecklistMenu", $"resource/ui/menus/playlist_mixtape_checklist.menu", InitPlaylistMixtapeChecklistMenu ) + + AddMenu( "SinglePlayerDevMenu", $"resource/ui/menus/singleplayer_dev.menu", InitSinglePlayerDevMenu, "SINGLE PLAYER DEV" ) + AddMenu( "SinglePlayerMenu", $"resource/ui/menus/singleplayer.menu", InitSinglePlayerMenu, "SINGLE PLAYER" ) + + AddMenu( "SearchMenu", $"resource/ui/menus/search.menu", InitSearchMenu ) + + AddMenu( "GammaMenu", $"resource/ui/menus/gamma.menu", InitGammaMenu, "#BRIGHTNESS" ) + + AddMenu( "CommunitiesMenu", $"resource/ui/menus/community.menu", InitCommunitiesMenu ) + AddMenu( "Notifications", $"resource/ui/menus/notifications.menu", InitNotificationsMenu ) + AddMenu( "MyNetworks", $"resource/ui/menus/communities_mine.menu", InitMyNetworksMenu ) + AddMenu( "InboxFrontMenu", $"resource/ui/menus/inbox_front.menu", InitInboxFrontMenu ) + AddMenu( "Inbox", $"resource/ui/menus/inbox.menu", InitInboxMenu ) + AddMenu( "BrowseCommunities", $"resource/ui/menus/communities_browse.menu" ) + AddMenu( "CommunityEditMenu", $"resource/ui/menus/community_edit.menu" ) + AddMenu( "CommunityAdminSendMessage", $"resource/ui/menus/community_sendMessage.menu" ) + AddMenu( "CommunityAdminInviteRequestMenu", $"resource/ui/menus/community_inviteRequest.menu" ) +#if NETWORK_INVITE + AddMenu( "InviteFriendsToNetworkMenu", $"resource/ui/menus/invite_friends.menu", InitInviteFriendsToNetworkMenu ) +#endif + + AddMenu( "InGameMPMenu", $"resource/ui/menus/ingame_mp.menu", InitInGameMPMenu ) + AddMenu( "InGameSPMenu", $"resource/ui/menus/ingame_sp.menu", InitInGameSPMenu ) + + AddMenu( "Dialog", $"resource/ui/menus/dialog.menu", InitDialogMenu ) + AddMenu( "AnnouncementDialog", $"resource/ui/menus/dialog_announcement.menu", InitAnnouncementDialog ) + AddMenu( "ConnectingDialog", $"resource/ui/menus/dialog_connecting.menu", InitConnectingDialog ) + AddMenu( "DataCenterDialog", $"resource/ui/menus/dialog_datacenter.menu", InitDataCenterDialogMenu ) + AddMenu( "EULADialog", $"resource/ui/menus/dialog_eula.menu", InitEULADialog ) + AddMenu( "ReviewTermsDialog", $"resource/ui/menus/dialog_review_terms.menu", InitReviewTermsDialog ) + AddMenu( "RegistrationDialog", $"resource/ui/menus/dialog_registration.menu", InitRegistrationDialog ) + AddMenu( "AdvocateGiftDialog", $"resource/ui/menus/dialog_advocate_gift.menu", InitAdvocateGiftDialog ) + + AddMenu( "ControlsMenu", $"resource/ui/menus/controls.menu", InitControlsMenu, "#CONTROLS" ) + AddMenu( "DemosMenu", $"resource/ui/menus/demos.menu", InitDemosMenu, "Demos" ) + AddMenu( "ControlsAdvancedLookMenu", $"resource/ui/menus/controls_advanced_look.menu", InitControlsAdvancedLookMenu, "#CONTROLS_ADVANCED_LOOK" ) + AddMenu( "GamepadLayoutMenu", $"resource/ui/menus/gamepadlayout.menu", InitGamepadLayoutMenu ) +#if PC_PROG + AddMenu_WithCreateFunc( "MouseKeyboardBindingsMenu", $"resource/ui/menus/mousekeyboardbindings.menu", InitMouseKeyboardMenu, CreateKeyBindingMenu ) + AddMenu( "AudioMenu", $"resource/ui/menus/audio.menu", InitAudioMenu, "#AUDIO" ) + AddMenu_WithCreateFunc( "VideoMenu", $"resource/ui/menus/video.menu", InitVideoMenu, CreateVideoOptionsMenu ) +#elseif CONSOLE_PROG + AddMenu( "AudioVideoMenu", $"resource/ui/menus/audio_video.menu", InitAudioVideoMenu, "#AUDIO_VIDEO" ) +#endif + + AddMenu( "AdvancedHudMenu", $"resource/ui/menus/advanced_hud.menu", InitAdvancedHudMenu, "#ADVANCED_HUD" ) + + AddMenu( "PilotLoadoutsMenu", $"resource/ui/menus/pilotloadouts.menu", InitPilotLoadoutsMenu ) + AddMenu( "TitanLoadoutsMenu", $"resource/ui/menus/titanloadouts.menu", InitTitanLoadoutsMenu ) + AddMenu( "EditPilotLoadoutsMenu", $"resource/ui/menus/pilotloadouts.menu", InitEditPilotLoadoutsMenu ) + AddMenu( "EditTitanLoadoutsMenu", $"resource/ui/menus/titanloadouts.menu", InitEditTitanLoadoutsMenu ) + AddMenu( "EditPilotLoadoutMenu", $"resource/ui/menus/editpilotloadout.menu", InitEditPilotLoadoutMenu ) + AddMenu( "EditTitanLoadoutMenu", $"resource/ui/menus/edittitanloadout.menu", InitEditTitanLoadoutMenu ) + + AddMenu( "SPTitanLoadoutMenu", $"resource/ui/menus/sptitanloadout.menu", InitSPTitanLoadoutMenu ) + AddMenu( "SPTitanLoadoutTutorialMenu", $"resource/ui/menus/sptitanloadout_tutorial.menu", InitSPTitanLoadoutTutorialMenu ) + + AddMenu( "SuitSelectMenu", $"resource/ui/menus/suitselect.menu", InitSuitSelectMenu ) + AddMenu( "WeaponSelectMenu", $"resource/ui/menus/weaponselect.menu", InitWeaponSelectMenu ) + AddMenu( "CategorySelectMenu", $"resource/ui/menus/categoryselect.menu", InitCategorySelectMenu ) + AddMenu( "AbilitySelectMenu", $"resource/ui/menus/abilityselect.menu", InitAbilitySelectMenu ) + AddMenu( "PassiveSelectMenu", $"resource/ui/menus/passiveselect.menu", InitPassiveSelectMenu ) + AddSubmenu( "ModSelectMenu", $"resource/ui/menus/modselect.menu", InitModSelectMenu ) + AddMenu( "CamoSelectMenu", $"resource/ui/menus/camoselect.menu", InitCamoSelectMenu ) + AddMenu( "NoseArtSelectMenu", $"resource/ui/menus/noseartselect.menu", InitNoseArtSelectMenu ) + AddMenu( "CallsignCardSelectMenu", $"resource/ui/menus/callsigncardselect.menu", InitCallsignCardSelectMenu ) + AddMenu( "CallsignIconSelectMenu", $"resource/ui/menus/callsigniconselect.menu", InitCallsignIconSelectMenu ) + AddMenu( "BoostStoreMenu", $"resource/ui/menus/booststore.menu", InitBoostStoreMenu ) + + AddMenu( "PrivateLobbyMenu", $"resource/ui/menus/private_lobby.menu", InitPrivateMatchMenu, "#PRIVATE_MATCH" ) + AddMenu( "MapsMenu", $"resource/ui/menus/map_select.menu", InitMapsMenu ) + AddMenu( "ModesMenu", $"resource/ui/menus/mode_select.menu", InitModesMenu ) + AddMenu( "MatchSettingsMenu", $"resource/ui/menus/match_settings.menu", InitMatchSettingsMenu ) + + AddMenu( "Advocate_Letter", $"resource/ui/menus/advocate_letter.menu", InitAdvocateLetterMenu ) + AddMenu( "Generation_Respawn", $"resource/ui/menus/generation_respawn.menu", InitGenerationRespawnMenu ) + AddMenu( "ChallengesMenu", $"resource/ui/menus/challenges.menu", InitChallengesMenu ) + + AddMenu( "ViewStatsMenu", $"resource/ui/menus/viewstats.menu", InitViewStatsMenu, "#PERSONAL_STATS" ) + AddMenu( "ViewStats_Overview_Menu", $"resource/ui/menus/viewstats_overview.menu", InitViewStatsOverviewMenu ) + //AddMenu( "ViewStats_Kills_Menu", $"resource/ui/menus/viewstats_kills.menu", InitViewStatsKillsMenu ) + AddMenu( "ViewStats_Time_Menu", $"resource/ui/menus/viewstats_time.menu", InitViewStatsTimeMenu ) + //AddMenu( "ViewStats_Distance_Menu", $"resource/ui/menus/viewstats_distance.menu", InitViewStatsDistanceMenu ) + AddMenu( "ViewStats_Weapons_Menu", $"resource/ui/menus/viewstats_weapons.menu", InitViewStatsWeaponsMenu ) + AddMenu( "ViewStats_Titans_Menu", $"resource/ui/menus/viewstats_titans.menu", InitViewStatsTitansMenu ) + AddMenu( "ViewStats_Misc_Menu", $"resource/ui/menus/viewstats_misc.menu", InitViewStatsMiscMenu ) + AddMenu( "ViewStats_Maps_Menu", $"resource/ui/menus/viewstats_maps.menu", InitViewStatsMapsMenu ) + + AddMenu( "PostGameMenu", $"resource/ui/menus/postgame.menu", InitPostGameMenu ) + AddMenu( "EOG_XP", $"resource/ui/menus/eog_xp.menu", InitEOG_XPMenu ) + AddMenu( "EOG_Coins", $"resource/ui/menus/eog_coins.menu", InitEOG_CoinsMenu ) + AddMenu( "EOG_Challenges", $"resource/ui/menus/eog_challenges.menu", InitEOG_ChallengesMenu ) + AddMenu( "EOG_Unlocks", $"resource/ui/menus/eog_unlocks.menu", InitEOG_UnlocksMenu ) + AddMenu( "EOG_Scoreboard", $"resource/ui/menus/eog_scoreboard.menu", InitEOG_ScoreboardMenu ) + + AddMenu( "CreditsMenu", $"resource/ui/menus/credits.menu", InitCreditsMenu, "#CREDITS" ) + + AddMenu( "BurnCardMenu", $"resource/ui/menus/burn_cards.menu", InitBurnCardMenu, "#MENU_BURNCARD_MENU" ) + AddMenu( "FactionChoiceMenu", $"resource/ui/menus/faction_choice.menu", InitFactionChoiceMenu, "#FACTION_CHOICE_MENU" ) + AddMenu( "ArmoryMenu", $"resource/ui/menus/armory.menu", InitArmoryMenu, "#ARMORY_MENU" ) + + AddMenu( "StoreMenu", $"resource/ui/menus/store.menu", InitStoreMenu, "#STORE_MENU" ) + AddMenu( "StoreMenu_NewReleases", $"resource/ui/menus/store_new_releases.menu", InitStoreMenuNewReleases, "#STORE_NEW_RELEASES" ) + AddMenu( "StoreMenu_Limited", $"resource/ui/menus/store_limited.menu", InitStoreMenuLimited, "#STORE_LIMITED" ) + AddMenu( "StoreMenu_Sales", $"resource/ui/menus/store_bundles.menu", InitStoreMenuSales, "#STORE_BUNDLES" ) + AddMenu( "StoreMenu_Titans", $"resource/ui/menus/store_prime_titans.menu", InitStoreMenuTitans, "#STORE_TITANS" ) // reusing store_prime_titans.menu + AddMenu( "StoreMenu_PrimeTitans", $"resource/ui/menus/store_prime_titans.menu", InitStoreMenuPrimeTitans, "#STORE_PRIME_TITANS" ) + //AddMenu( "StoreMenu_WeaponSelect", $"resource/ui/menus/store_weapon_select.menu", InitStoreMenuWeaponSelect ) + //AddMenu( "StoreMenu_WeaponSkinPreview", $"resource/ui/menus/store_weapon_skin_preview.menu", InitStoreMenuWeaponSkinPreview ) + AddMenu( "StoreMenu_WeaponSkinBundles", $"resource/ui/menus/store_weapon_skin_bundles.menu", InitStoreMenuWeaponSkinBundles ) + AddMenu( "StoreMenu_WeaponSkins", $"resource/ui/menus/store_weapons.menu", InitStoreMenuWeaponSkins ) + AddMenu( "StoreMenu_Customization", $"resource/ui/menus/store_customization.menu", InitStoreMenuCustomization, "#STORE_CUSTOMIZATION_PACKS" ) + AddMenu( "StoreMenu_CustomizationPreview", $"resource/ui/menus/store_customization_preview.menu", InitStoreMenuCustomizationPreview, "#STORE_CUSTOMIZATION_PACKS" ) + AddMenu( "StoreMenu_Camo", $"resource/ui/menus/store_camo.menu", InitStoreMenuCamo, "#STORE_CAMO_PACKS" ) + AddMenu( "StoreMenu_CamoPreview", $"resource/ui/menus/store_camo_preview.menu", InitStoreMenuCamoPreview, "#STORE_CAMO_PACKS" ) + AddMenu( "StoreMenu_Callsign", $"resource/ui/menus/store_callsign.menu", InitStoreMenuCallsign, "#STORE_CALLSIGN_PACKS" ) + AddMenu( "StoreMenu_CallsignPreview", $"resource/ui/menus/store_callsign_preview.menu", InitStoreMenuCallsignPreview, "#STORE_CALLSIGN_PACKS" ) + + AddMenu( "KnowledgeBaseMenu", $"resource/ui/menus/knowledgebase.menu", InitKnowledgeBaseMenu ) + AddMenu( "KnowledgeBaseMenuSubMenu", $"resource/ui/menus/knowledgebase_submenu.menu", InitKnowledgeBaseMenuSubMenu ) + + AddMenu( "DevMenu", $"resource/ui/menus/dev.menu", InitDevMenu, "Dev" ) + InitSharedStartPoints() + + foreach ( menu in uiGlobal.allMenus ) + { + if ( uiGlobal.menuData[ menu ].initFunc != null ) + uiGlobal.menuData[ menu ].initFunc() + + array elems = GetElementsByClassname( menu, "TabsCommonClass" ) + if ( elems.len() ) + uiGlobal.menuData[ menu ].hasTabs = true + + elems = GetElementsByClassname( menu, "EnableKeyBindingIcons" ) + foreach ( elem in elems ) + Hud_EnableKeyBindingIcons( elem ) + } + + InitTabs() + + var tabbedMenu = GetMenu( "PostGameMenu" ) + AddPanel( tabbedMenu, "PVEPanel", InitPVEPanel ) + AddPanel( tabbedMenu, "SummaryPanel", InitSummaryPanel ) + AddPanel( tabbedMenu, "FDAwardsPanel", InitFDAwardsPanel ) + + AddPanel( tabbedMenu, "ScoreboardPanel", InitScoreboardPanel ) + + foreach ( panel in uiGlobal.allPanels ) + { + if ( uiGlobal.panelData[ panel ].initFunc != null ) + uiGlobal.panelData[ panel ].initFunc() + } + + // A little weird, but GetElementsByClassname() uses menu scope rather than parent scope. + foreach ( menu in uiGlobal.allMenus ) + { + array buttons = GetElementsByClassname( menu, "DefaultFocus" ) + foreach ( button in buttons ) + { + var panel = Hud_GetParent( button ) + + //Assert( elems.len() == 1, "More than 1 panel element set as DefaultFocus!" ) + Assert( panel != null, "no parent panel found for button " + Hud_GetHudName( button ) ) + Assert( panel in uiGlobal.panelData, "panel " + Hud_GetHudName( panel ) + " isn't in uiGlobal.panelData, but button " + Hud_GetHudName( button ) + " has defaultFocus set!" ) + uiGlobal.panelData[ panel ].defaultFocus = button + //printt( "Found DefaultFocus, button was:", Hud_GetHudName( button ), "panel was:", Hud_GetHudName( panel ) ) + } + } + + InitFooterOptions() + + #if DEV + if ( Dev_CommandLineHasParm( "-autoprecache_all" ) ) + { + // repreache all levels + ExecuteLoadingClientCommands_SetStartPoint( "sp_training" ) + ClientCommand( "map sp_training" ) + CloseAllMenus() + } + #endif +} + +void functionref( var ) function AdvanceMenuEventHandler( var menu ) +{ + return void function( var item ) : ( menu ) + { + if ( Hud_IsLocked( item ) ) + return + + AdvanceMenu( menu ) + } +} + +void function PCBackButton_Activate( var button ) +{ + UICodeCallback_NavigateBack() +} + +void function PCSwitchTeamsButton_Activate( var button ) +{ + ClientCommand( "PrivateMatchSwitchTeams" ) +} + +void function PCToggleSpectateButton_Activate( var button ) +{ + ClientCommand( "PrivateMatchToggleSpectate" ) +} + +void function ToggleButtonStates( var button ) +{ + for ( ;; ) + { + Hud_SetEnabled( button, true ) + wait 1 + Hud_SetSelected( button, true ) + wait 1 + Hud_SetLocked( button, true ) + wait 1 + Hud_SetNew( button, true ) + wait 1 + Hud_SetNew( button, false ) + wait 1 + Hud_SetLocked( button, false ) + wait 1 + Hud_SetSelected( button, false ) + wait 1 + Hud_SetEnabled( button, false ) + wait 1 + } +} + +void function AddMenuElementsByClassname( var menu, string classname ) +{ + array elements = GetElementsByClassname( menu, classname ) + + if ( !(classname in menu.classElements) ) + menu.classElements[classname] <- [] + + menu.classElements[classname].extend( elements ) +} + +void function FocusDefault( var menu ) +{ + if ( + menu == GetMenu( "MainMenu" ) || + menu == GetMenu( "CategorySelectMenu" ) || + menu == GetMenu( "AbilitySelectMenu" ) || + menu == GetMenu( "PassiveSelectMenu" ) || + menu == GetMenu( "WeaponSelectMenu" ) || + menu == GetMenu( "SuitSelectMenu" ) || + menu == GetMenu( "CamoSelectMenu" ) || + menu == GetMenu( "NoseArtSelectMenu" ) || + menu == GetMenu( "FactionChoiceMenu" ) || + menu == GetMenu( "BurnCardMenu" ) || + menu == GetMenu( "CallsignCardSelectMenu" ) || + menu == GetMenu( "CallsignIconSelectMenu" ) ) + { + } + else + { + //printt( "FocusDefaultMenuItem() called" ) + FocusDefaultMenuItem( menu ) + } +} + +void function SetPanelDefaultFocus( var panel, var button ) +{ + uiGlobal.panelData[ panel ].defaultFocus = button +} + +void function PanelFocusDefault( var panel ) +{ + //printt( "PanelFocusDefault called" ) + if ( uiGlobal.panelData[ panel ].defaultFocus ) + { + Hud_SetFocused( uiGlobal.panelData[ panel ].defaultFocus ) + //printt( "PanelFocusDefault if passed,", Hud_GetHudName( uiGlobal.panelData[ panel ].defaultFocus ), "focused" ) + } +} + +void function SetMenuThinkFunc( var menu, void functionref() func ) +{ + Assert( uiGlobal.menuData[ menu ].thinkFunc == null ) + uiGlobal.menuData[ menu ].thinkFunc = func +} + +void function AddMenuEventHandler( var menu, int event, void functionref() func ) +{ + if ( event == eUIEvent.MENU_OPEN ) + { + Assert( uiGlobal.menuData[ menu ].openFunc == null ) + uiGlobal.menuData[ menu ].openFunc = func + } + else if ( event == eUIEvent.MENU_CLOSE ) + { + Assert( uiGlobal.menuData[ menu ].closeFunc == null ) + uiGlobal.menuData[ menu ].closeFunc = func + } + else if ( event == eUIEvent.MENU_SHOW ) + { + Assert( uiGlobal.menuData[ menu ].showFunc == null ) + uiGlobal.menuData[ menu ].showFunc = func + } + else if ( event == eUIEvent.MENU_HIDE ) + { + Assert( uiGlobal.menuData[ menu ].hideFunc == null ) + uiGlobal.menuData[ menu ].hideFunc = func + } + else if ( event == eUIEvent.MENU_NAVIGATE_BACK ) + { + Assert( uiGlobal.menuData[ menu ].navBackFunc == null ) + uiGlobal.menuData[ menu ].navBackFunc = func + } + else if ( event == eUIEvent.MENU_TAB_CHANGED ) + { + Assert( uiGlobal.menuData[ menu ].tabChangedFunc == null ) + uiGlobal.menuData[ menu ].tabChangedFunc = func + } + else if ( event == eUIEvent.MENU_ENTITLEMENTS_CHANGED ) + { + Assert( uiGlobal.menuData[ menu ].entitlementsChangedFunc == null ) + uiGlobal.menuData[ menu ].entitlementsChangedFunc = func + } + else if ( event == eUIEvent.MENU_INPUT_MODE_CHANGED ) + { + Assert( uiGlobal.menuData[ menu ].inputModeChangedFunc == null ) + uiGlobal.menuData[ menu ].inputModeChangedFunc = func + } +} + +void function AddPanelEventHandler( var panel, int event, void functionref() func ) +{ + if ( event == eUIEvent.PANEL_SHOW ) + uiGlobal.panelData[ panel ].showFunc = func + else if ( event == eUIEvent.PANEL_HIDE ) + uiGlobal.panelData[ panel ].hideFunc = func +} + +// TODO: Get a real on open event from code? +void function OpenMenuWrapper( var menu, bool focusDefault ) +{ + OpenMenu( menu ) + printt( Hud_GetHudName( menu ), "menu opened" ) + + Assert( menu in uiGlobal.menuData ) + if ( uiGlobal.menuData[ menu ].openFunc != null ) + { + thread uiGlobal.menuData[ menu ].openFunc() + //printt( "Called openFunc for:", menu.GetHudName() ) + } + + if ( focusDefault ) + FocusDefault( menu ) + + //UpdateMenuTabs() + UpdateFooterOptions() +} + +void function CloseMenuWrapper( var menu ) +{ + CloseMenu( menu ) + printt( Hud_GetHudName( menu ), "menu closed" ) + + Assert( menu in uiGlobal.menuData ) + if ( uiGlobal.menuData[ menu ].closeFunc != null ) + { + thread uiGlobal.menuData[ menu ].closeFunc() + //printt( "Called closeFunc for:", Hud_GetHudName( menu ) ) + } +} + +bool function IsLevelMultiplayer( string levelname ) +{ + return levelname.find( "mp_" ) == 0 +} + +void function AddButtonEventHandler( var button, int event, void functionref( var ) func ) +{ + Hud_AddEventHandler( button, event, func ) +} + +void function AddEventHandlerToButton( var menu, string buttonName, int event, void functionref( var ) func ) +{ + var button = Hud_GetChild( menu, buttonName ) + Hud_AddEventHandler( button, event, func ) +} + +void function AddEventHandlerToButtonClass( var menu, string classname, int event, void functionref( var ) func ) +{ + array buttons = GetElementsByClassname( menu, classname ) + + foreach ( button in buttons ) + { + //printt( "button name:", Hud_GetHudName( button ) ) + Hud_AddEventHandler( button, event, func ) + } +} + +// Added slight delay to main menu music to work around a hitch caused when the game first starts up +void function PlayMusicAfterDelay() +{ + wait MAINMENU_MUSIC_DELAY + if ( uiGlobal.playingMusic ) + EmitUISound( "MainMenu_Music" ) +} + +void function DisableMusic() +{ + EmitUISound( "Movie_MuteAllGameSound" ) +} + +void function EnableMusic() +{ + StopUISoundByName( "Movie_MuteAllGameSound" ) +} + +void function PlayMusic() +{ + if ( !uiGlobal.playingMusic && !uiGlobal.playingVideo && !uiGlobal.playingCredits ) + { + //printt( "PlayMusic() called. Playing: MainMenu_Music. uiGlobal.playingMusic:", uiGlobal.playingMusic, "uiGlobal.playingVideo:", uiGlobal.playingVideo, "uiGlobal.playingCredits:", uiGlobal.playingCredits ) + uiGlobal.playingMusic = true + thread PlayMusicAfterDelay() + } + else + { + //printt( "PlayMusic() called, but doing nothing. uiGlobal.playingMusic:", uiGlobal.playingMusic, "uiGlobal.playingVideo:", uiGlobal.playingVideo, "uiGlobal.playingCredits:", uiGlobal.playingCredits ) + } +} + +void function StopMusic() +{ + //printt( "StopMusic() called. Stopping: MainMenu_Music" ) + StopUISound( "MainMenu_Music" ) + uiGlobal.playingMusic = false +} + +void function RegisterMenuVarInt( string varName, int value ) +{ + table intVars = uiGlobal.intVars + + Assert( !( varName in intVars ) ) + + intVars[varName] <- value +} + +void function RegisterMenuVarBool( string varName, bool value ) +{ + table boolVars = uiGlobal.boolVars + + Assert( !( varName in boolVars ) ) + + boolVars[varName] <- value +} + +void function RegisterMenuVarVar( string varName, var value ) +{ + table varVars = uiGlobal.varVars + + Assert( !( varName in varVars ) ) + + varVars[varName] <- value +} + +int function GetMenuVarInt( string varName ) +{ + table intVars = uiGlobal.intVars + + Assert( varName in intVars ) + + return intVars[varName] +} + +bool function GetMenuVarBool( string varName ) +{ + table boolVars = uiGlobal.boolVars + + Assert( varName in boolVars ) + + return boolVars[varName] +} + +var function GetMenuVarVar( string varName ) +{ + table varVars = uiGlobal.varVars + + Assert( varName in varVars ) + + return varVars[varName] +} + +void function SetMenuVarInt( string varName, int value ) +{ + table intVars = uiGlobal.intVars + + Assert( varName in intVars ) + + if ( intVars[varName] == value ) + return + + intVars[varName] = value + + table > varChangeFuncs = uiGlobal.varChangeFuncs + + if ( varName in varChangeFuncs ) + { + foreach ( func in varChangeFuncs[varName] ) + { + //printt( varName, "changed, calling changeFunc:", string( func ) ) + func() + } + } +} + +void function SetMenuVarBool( string varName, bool value ) +{ + table boolVars = uiGlobal.boolVars + + Assert( varName in boolVars ) + + if ( boolVars[varName] == value ) + return + + boolVars[varName] = value + + table > varChangeFuncs = uiGlobal.varChangeFuncs + + if ( varName in varChangeFuncs ) + { + foreach ( func in varChangeFuncs[varName] ) + { + //printt( varName, "changed, calling changeFunc:", string( func ) ) + func() + } + } +} + +void function SetMenuVarVar( string varName, var value ) +{ + table varVars = uiGlobal.varVars + + Assert( varName in varVars ) + + if ( varVars[varName] == value ) + return + + varVars[varName] = value + + table > varChangeFuncs = uiGlobal.varChangeFuncs + + if ( varName in varChangeFuncs ) + { + foreach ( func in varChangeFuncs[varName] ) + { + //printt( varName, "changed, calling changeFunc:", string( func ) ) + func() + } + } +} + +void function AddMenuVarChangeHandler( string varName, void functionref() func ) +{ + table > varChangeFuncs = uiGlobal.varChangeFuncs + + if ( !( varName in varChangeFuncs ) ) + varChangeFuncs[varName] <- [] + + // TODO: Verify we're not duplicating an existing func + varChangeFuncs[varName].append( func ) +} + +// These are common menu statuses that trigger menu logic any time they change +// They should become code callbacks, so script doesn't poll +void function InitGlobalMenuVars() +{ + RegisterMenuVarVar( "focus", null ) + RegisterMenuVarBool( "isConnected", false ) + RegisterMenuVarBool( "isFullyConnected", false ) + RegisterMenuVarBool( "isPartyLeader", false ) + RegisterMenuVarBool( "isPrivateMatch", false ) + RegisterMenuVarBool( "isGamepadActive", IsControllerModeActive() ) + + #if CONSOLE_PROG + RegisterMenuVarBool( "CONSOLE_isOnline", false ) + RegisterMenuVarBool( "CONSOLE_isSignedIn", false ) + #endif // CONSOLE_PROG + + #if DURANGO_PROG + RegisterMenuVarBool( "DURANGO_isGameFullyInstalled", false ) + RegisterMenuVarBool( "DURANGO_canInviteFriends", false ) + RegisterMenuVarBool( "DURANGO_isJoinable", false ) + #elseif PS4_PROG + RegisterMenuVarBool( "PS4_canInviteFriends", false) + #elseif PC_PROG + RegisterMenuVarBool( "ORIGIN_isEnabled", false ) + RegisterMenuVarBool( "ORIGIN_isJoinable", false ) + #endif + + thread UpdateFocus() + thread UpdateIsConnected() + thread UpdateIsFullyConnected() + thread UpdateAmIPartyLeader() + thread UpdateIsPrivateMatch() + thread UpdateActiveMenuThink() + + #if CONSOLE_PROG + thread UpdateConsole_IsOnline() + thread UpdateConsole_IsSignedIn() + #endif // CONSOLE_PROG + + #if DURANGO_PROG + thread UpdateDurango_IsGameFullyInstalled() + thread UpdateDurango_CanInviteFriends() + thread UpdateDurango_IsJoinable() + #elseif PS4_PROG + thread UpdatePS4_CanInviteFriends() + #elseif PC_PROG + thread UpdateOrigin_IsEnabled() + thread UpdateOrigin_IsJoinable() + thread UpdateIsGamepadActive() + #endif +} + +void function UpdateFocus() +{ + while ( true ) + { + SetMenuVarVar( "focus", GetFocus() ) + WaitFrame() + } +} + +void function UpdateActiveMenuThink() +{ + while ( true ) + { + var menu = GetActiveMenu() + if ( menu ) + { + Assert( menu in uiGlobal.menuData ) + if ( uiGlobal.menuData[ menu ].thinkFunc != null ) + uiGlobal.menuData[ menu ].thinkFunc() + } + + WaitFrame() + } +} + +void function UpdateIsConnected() +{ + while ( true ) + { + SetMenuVarBool( "isConnected", IsConnected() ) + WaitFrame() + } +} + +void function UpdateIsFullyConnected() +{ + while ( true ) + { + SetMenuVarBool( "isFullyConnected", IsFullyConnected() ) + WaitFrame() + } +} + +void function UpdateAmIPartyLeader() +{ + while ( true ) + { + SetMenuVarBool( "isPartyLeader", AmIPartyLeader() ) + WaitFrame() + } +} + +void function UpdateIsPrivateMatch() +{ + while ( true ) + { + SetMenuVarBool( "isPrivateMatch", IsPrivateMatch() ) + WaitFrame() + } +} + +#if CONSOLE_PROG + void function UpdateConsole_IsOnline() + { + while ( true ) + { + SetMenuVarBool( "CONSOLE_isOnline", Console_IsOnline() ) + WaitFrame() + } + } + + void function UpdateConsole_IsSignedIn() + { + while ( true ) + { + SetMenuVarBool( "CONSOLE_isSignedIn", Console_IsSignedIn() ) + WaitFrame() + } + } +#endif // CONSOLE_PROG + + +#if PS4_PROG + void function UpdatePS4_CanInviteFriends() + { + while ( true ) + { + SetMenuVarBool( "PS4_canInviteFriends", PS4_canInviteFriends() ) + WaitFrame() + } + } +#endif // PS4_PROG + + + +#if DURANGO_PROG + void function UpdateDurango_IsGameFullyInstalled() + { + while ( true ) + { + SetMenuVarBool( "DURANGO_isGameFullyInstalled", IsGameFullyInstalled() ) + wait 1 // Poll less frequent + } + } + + void function UpdateDurango_CanInviteFriends() + { + while ( true ) + { + SetMenuVarBool( "DURANGO_canInviteFriends", Durango_CanInviteFriends() ) + WaitFrame() + } + } + + void function UpdateDurango_IsJoinable() + { + while ( true ) + { + SetMenuVarBool( "DURANGO_isJoinable", Durango_IsJoinable() ) + WaitFrame() + } + } +#endif // DURANGO_PROG + +#if PC_PROG + void function UpdateOrigin_IsEnabled() + { + while ( true ) + { + SetMenuVarBool( "ORIGIN_isEnabled", Origin_IsEnabled() ) + WaitFrame() + } + } + + void function UpdateOrigin_IsJoinable() + { + while ( true ) + { + SetMenuVarBool( "ORIGIN_isJoinable", Origin_IsJoinable() ) + WaitFrame() + } + } + + void function UpdateIsGamepadActive() + { + while ( true ) + { + SetMenuVarBool( "isGamepadActive", IsControllerModeActive() ) + WaitFrame() + } + } +#endif // PC_PROG + +void function InviteFriends( var button ) +{ + //AdvanceMenu( GetMenu( "InviteFriendsToPartyMenu" ) ) + + #if DURANGO_PROG + Durango_InviteFriends() + #elseif PS4_PROG + ClientCommand("session_debug_invite"); + #elseif PC_PROG + Assert( Origin_IsEnabled() ) + Assert( Origin_IsJoinable() ) + + Origin_ShowInviteFriendsDialog() + #endif +} + +#if DURANGO_PROG +void function OpenXboxPartyApp( var button ) +{ + Durango_OpenPartyApp() +} + +void function OpenXboxHelp( var button ) +{ + Durango_ShowHelpWindow() +} +#endif // DURANGO_PROG + +void function OpenReviewTermsDialog( var button ) +{ + AdvanceMenu( GetMenu( "ReviewTermsDialog" ) ) +} + +void function OpenErrorDialog( string errorDetails ) +{ + DialogData dialogData + dialogData.header = "#ERROR" + dialogData.message = errorDetails + dialogData.image = $"ui/menu/common/dialog_error" + +#if PC_PROG + AddDialogButton( dialogData, "#DISMISS" ) + + AddDialogFooter( dialogData, "#A_BUTTON_SELECT" ) +#endif // PC_PROG + AddDialogFooter( dialogData, "#B_BUTTON_DISMISS_RUI" ) + + while ( uiGlobal.activeMenu != GetMenu( "MainMenu" ) ) + { + WaitSignal( uiGlobal.signalDummy, "OpenErrorDialog", "ActiveMenuChanged" ) + } + + OpenDialog( dialogData ) +} + +bool function IsDialog( var menu ) +{ + if ( menu == null ) + return false + + return uiGlobal.menuData[ menu ].isDialog +} + +bool function IsDialogActive( DialogData dialogData ) +{ + if ( !IsDialog( uiGlobal.activeMenu ) ) + return false + + return uiGlobal.menuData[ uiGlobal.activeMenu ].dialogData == dialogData +} + +bool function IsDialogOnlyActiveMenu() +{ + if ( !IsDialog( uiGlobal.activeMenu ) ) + return false + + int stackLen = uiGlobal.menuStack.len() + if ( stackLen < 1 ) + return false + + if ( uiGlobal.menuStack[stackLen - 1] != uiGlobal.activeMenu ) + return false + + if ( stackLen == 1 ) + return true + + if ( uiGlobal.menuStack[stackLen - 2] == null ) + return true + + return false +} + +void function SetNavUpDown( array buttons, var wrap = true ) +{ + Assert( buttons.len() > 0 ) + + var first = buttons[0] + var last = buttons[buttons.len() - 1] + var prev + var next + var button + + for ( int i = 0; i < buttons.len(); i++ ) + { + button = buttons[i] + + if ( button == first ) + prev = last + else + prev = buttons[i - 1] + + if ( button == last ) + next = first + else + next = buttons[i + 1] + + button.SetNavUp( prev ) + button.SetNavDown( next ) + + //printt( "SetNavUP for:", Hud_GetHudName( button ), "to:", Hud_GetHudName( prev ) ) + //printt( "SetNavDown for:", Hud_GetHudName( button ), "to:", Hud_GetHudName( next ) ) + } +} + +void function SetNavLeftRight( array buttons, var wrap = true ) +{ + Assert( buttons.len() > 0 ) + + var first = buttons[0] + var last = buttons[buttons.len() - 1] + var prev + var next + var button + + for ( int i = 0; i < buttons.len(); i++ ) + { + button = buttons[i] + + if ( button == first ) + prev = last + else + prev = buttons[i - 1] + + if ( button == last ) + next = first + else + next = buttons[i + 1] + + button.SetNavLeft( prev ) + button.SetNavRight( next ) + + //printt( "SetNavUP for:", Hud_GetHudName( button ), "to:", Hud_GetHudName( prev ) ) + //printt( "SetNavDown for:", Hud_GetHudName( button ), "to:", Hud_GetHudName( next ) ) + } +} + +void function UICodeCallback_EntitlementsChanged() +{ + if ( uiGlobal.activeMenu == null ) + return + + if ( uiGlobal.menuData[ uiGlobal.activeMenu ].entitlementsChangedFunc != null ) + thread uiGlobal.menuData[ uiGlobal.activeMenu ].entitlementsChangedFunc() +} + +#if PC_PROG +void function QuitGame() +{ + ClientCommand( "quit" ) +} +#endif + +void function UICodeCallback_StoreTransactionCompleted() +{ + // this callback is only supported and needed on PS4 currently +#if PS4_PROG + if ( InStoreMenu() ) + OnOpenDLCStore() +#endif +} + +void function UICodeCallback_GamePurchased() +{ + // this callback is only supported and needed on PC currently +#if PC_PROG + DialogData dialogData + dialogData.header = "#PURCHASE_GAME_COMPLETE" + dialogData.message = "#PURCHASE_GAME_RESTART" + AddDialogButton( dialogData, "#QUIT", QuitGame ) + + OpenDialog( dialogData ) +#endif +} + +bool function IsTrialPeriodActive() +{ + return GetConVarBool( "trialPeriodIsActive" ) +} + +void function LaunchGamePurchaseOrDLCStore( array menuNames = [ "StoreMenu" ] ) +{ + if ( Script_IsRunningTrialVersion() ) + { + LaunchGamePurchase() + } + else + { + void functionref() preOpenFunc = null + + foreach ( menuName in menuNames ) + { + // Special case because this menu needs a few properties set before opening + if ( menuName == "StoreMenu_WeaponSkins" ) + { + preOpenFunc = DefaultToDLC11WeaponWarpaintBundle + break + } + } + + OpenStoreMenu( menuNames, preOpenFunc ) + } +} + +void function UICodeCallback_PartyUpdated() +{ + if ( AmIPartyLeader() ) + { + string activeSearchingPlaylist = GetActiveSearchingPlaylist() + if ( activeSearchingPlaylist != "" && !CanPlaylistFitMyParty( activeSearchingPlaylist ) ) + { + CancelMatchSearch() + + DialogData dialogData + dialogData.header = "#MATCHMAKING_CANCELED" + dialogData.message = "#MATCHMAKING_CANCELED_REASON_PARTY_SIZE" + AddDialogButton( dialogData, "#OK" ) + + OpenDialog( dialogData ) + } + } +} + + +void function HACK_DelayedSetFocus_BecauseWhy( var item ) +{ + wait 0.1 + if ( IsValid( item ) ) + Hud_SetFocused( item ) +} + +void function ClassicMusic_OnChange( var button ) +{ + bool isEnabled = GetConVarBool( "sound_classic_music" ) + + if ( IsFullyConnected() && IsMultiplayer() && GetUIPlayer() ) + { + if ( IsItemLocked( GetUIPlayer(), "classic_music" ) ) + SetConVarBool( "sound_classic_music", false ) + + if ( IsLobby() ) + thread RunClientScript( "OnSoundClassicMusicChanged" ) + } +} + +bool function IsClassicMusicAvailable() +{ + bool classicMusicAvailable = false + if ( IsFullyConnected() && IsMultiplayer() && GetUIPlayer() ) + classicMusicAvailable = !IsItemLocked( GetUIPlayer(), "classic_music" ) + + return classicMusicAvailable +} + +void function UICodeCallback_KeyBindOverwritten( string key, string oldbinding, string newbinding ) +{ + DialogData dialogData + dialogData.header = Localize( "#MENU_KEYBIND_WAS_BEING_USED", key ) + dialogData.message = Localize( "#MENU_KEYBIND_WAS_BEING_USED_SUB", key, Localize( oldbinding ) ) + + AddDialogButton( dialogData, "#OK" ) + + OpenDialog( dialogData ) +} diff --git a/src/scripts/vscripts/ui/menu_controls.nut b/src/scripts/vscripts/ui/menu_controls.nut index c1d8601..bfb83ae 100644 --- a/src/scripts/vscripts/ui/menu_controls.nut +++ b/src/scripts/vscripts/ui/menu_controls.nut @@ -26,6 +26,10 @@ void function InitControlsMenu() file.itemDescriptionBox = Hud_GetChild( menu, "LblMenuItemDescription" ) #if PC_PROG + button = Hud_GetChild( menu, "DemosMenu" ) + SetupButton( button, "Demos", "Edit demo settings" ) + AddButtonEventHandler( button, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "DemosMenu" ) ) ) + button = Hud_GetChild( menu, "BtnMouseKeyboardBindings" ) SetupButton( button, "#KEY_BINDINGS", "#MOUSE_KEYBOARD_MENU_CONTROLS_DESC" ) AddButtonEventHandler( button, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "MouseKeyboardBindingsMenu" ) ) ) @@ -161,6 +165,28 @@ void function OnCloseControlsMenu() SavePlayerSettings() } +void function OnOpenDemosMenu() +{ + UI_SetPresentationType( ePresentationType.NO_MODELS ) + + Hud_SetEnabled( file.autoSprintSetting, !IsAutoSprintForced() ) + + RefreshGamepadLayoutLabel() + + SetStatesForCustomEnable() +} + +void function OnCloseDemosMenu() +{ + if ( IsConnected() ) + { + int holdToRodeoState = GetConVarInt( "cl_hold_to_rodeo_enable" ) + ClientCommand( "HoldToRodeo " + holdToRodeoState ) + } + + SavePlayerSettings() +} + var function SetupButton( var button, string buttonText, string description ) { SetButtonRuiText( button, buttonText ) diff --git a/src/scripts/vscripts/ui/menu_demo_settings.nut b/src/scripts/vscripts/ui/menu_demo_settings.nut new file mode 100644 index 0000000..fe9ff06 --- /dev/null +++ b/src/scripts/vscripts/ui/menu_demo_settings.nut @@ -0,0 +1,64 @@ + +global function InitDemosMenu + +struct +{ + var menu + table buttonDescriptions + var classicMusicSwitch +} file + +void function InitDemosMenu() +{ + var menu = GetMenu( "DemosMenu" ) + file.menu = menu + + AddMenuEventHandler( menu, eUIEvent.MENU_OPEN, OnOpenDemosMenu ) + AddMenuEventHandler( menu, eUIEvent.MENU_CLOSE, OnCloseDemosMenu ) + + var button + + SetupButton( Hud_GetChild( menu, "SwchEnableDemos" ), "Enable Demos", "Enable recording demos (must be set true before loading a map)." ) + SetupButton( Hud_GetChild( menu, "SwchDemosWrite" ), "Save Demos", "Demos write to a local file when recording a demo." ) + SetupButton( Hud_GetChild( menu, "SwchDemosInterpolate" ), "Interpolate Playback", "Do view interpolation during dem playback." ) + SetupButton( Hud_GetChild( menu, "SwchDemosUpdateRate" ), "Demo record rate", "Change the tick recording rate" ) + SetupButton( Hud_GetChild( menu, "SwchDemosAutorecord" ), "Auto Record", "Automatically record multiplayer matches as demos." ) + + button = Hud_GetChild( menu, "BtnMouseKeyboardBindings" ) + SetupButton( button, "#KEY_BINDINGS", "#MOUSE_KEYBOARD_MENU_CONTROLS_DESC" ) + AddButtonEventHandler( button, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "MouseKeyboardBindingsMenu" ) ) ) + + AddEventHandlerToButtonClass( menu, "RuiFooterButtonClass", UIE_GET_FOCUS, FooterButton_Focused ) + + AddMenuFooterOption( menu, BUTTON_A, "#A_BUTTON_SELECT" ) + AddMenuFooterOption( menu, BUTTON_B, "#B_BUTTON_BACK", "#BACK" ) +} + +void function OnOpenDemosMenu() +{ + UI_SetPresentationType( ePresentationType.NO_MODELS ) + +} + +void function OnCloseDemosMenu() +{ + SavePlayerSettings() +} + +void function SetupButton( var button, string buttonText, string description ) +{ + SetButtonRuiText( button, buttonText ) + file.buttonDescriptions[ button ] <- description + AddButtonEventHandler( button, UIE_GET_FOCUS, Button_Focused ) +} + +void function Button_Focused( var button ) +{ + string description = file.buttonDescriptions[ button ] + SetElementsTextByClassname( file.menu, "MenuItemDescriptionClass", description ) +} + +void function FooterButton_Focused( var button ) +{ + SetElementsTextByClassname( file.menu, "MenuItemDescriptionClass", "" ) +}