479 lines
14 KiB
Lua
479 lines
14 KiB
Lua
require( "LUI.CodeDependence" )
|
|
|
|
if not Engine.InFrontend() then
|
|
require( "LUI.GameX" )
|
|
end
|
|
require( "LUI.FlowManager" )
|
|
require( "LUI.HudManager" )
|
|
require( "LUI.EventCatcher" )
|
|
if Engine.HasSpeechFeature() then
|
|
require( "LUI.MenuAutoNav" )
|
|
require( "LUI.Speech" )
|
|
require( "LUI.common_menus.KinectUtils" )
|
|
end
|
|
LUI.UIRoot = {}
|
|
LUI.UIRoot.childPriorities = {
|
|
menuRoot = 10,
|
|
default = 0,
|
|
MLGHud = -4,
|
|
hudElems = -5,
|
|
roundEndScreen = -7,
|
|
finalScoresScreen = -7,
|
|
hudContainer = -10
|
|
}
|
|
function LUI_UIRoot_HandleSpeechWhatCanISay( f1_arg0, f1_arg1, f1_arg2 )
|
|
if Engine.HasSpeechFeature() and Kinect.CanOpenWhatCanISayMenu() == true then
|
|
Kinect.OpenWhatCanISayMenu( f1_arg1.controler )
|
|
LUI.Speech.PerformingSpeechAction()
|
|
end
|
|
end
|
|
|
|
function LUI_UIRoot_HandleSpeechPause( f2_arg0, f2_arg1, f2_arg2 )
|
|
if Engine.HasSpeechFeature() then
|
|
local f2_local0 = false
|
|
if not Engine.InFrontend() and not Engine.IsMultiplayer() and Engine.GetDvarInt( "cl_paused" ) == 0 then
|
|
local f2_local1 = Engine.GetLuiRoot()
|
|
if f2_local1 then
|
|
Engine.TogglePause()
|
|
f2_local1.is_paused = true
|
|
f2_local1:processEvent( {
|
|
name = "hud_refresh"
|
|
} )
|
|
f2_local1:dispatchEventToRoot( {
|
|
name = "toggle_pause"
|
|
} )
|
|
f2_local0 = true
|
|
end
|
|
end
|
|
if f2_local0 == false then
|
|
LUI.Speech.SquelchSpeechAction()
|
|
else
|
|
LUI.Speech.PerformingSpeechAction()
|
|
end
|
|
end
|
|
end
|
|
|
|
function LUI_UIRoot_HandleSpeechChangeView( f3_arg0, f3_arg1, f3_arg2 )
|
|
if Engine.HasSpeechFeature() and Engine.SpeechEmitKeyPressAndRelease then
|
|
DebugPrint( "Kinect: Issuing a GPAD_BACK button press in response to VIEW voice command." )
|
|
Engine.SpeechEmitKeyPressAndRelease( "GPAD_BACK", f3_arg1.controller )
|
|
end
|
|
end
|
|
|
|
function LUI_UIRoot_HandleSpeechShowMenu( f4_arg0, f4_arg1, f4_arg2 )
|
|
if Engine.HasSpeechFeature() and Engine.SpeechEmitKeyPressAndRelease then
|
|
DebugPrint( "Kinect: Issuing a GPAD_START button press in response to MENU voice command." )
|
|
Engine.SpeechEmitKeyPressAndRelease( "GPAD_START", f4_arg1.controller )
|
|
end
|
|
end
|
|
|
|
function LUI_UIRoot_HandleSpeechBack( f5_arg0, f5_arg1, f5_arg2 )
|
|
if Engine.HasSpeechFeature() and Engine.GetLuiInUse() and Engine.SpeechEmitKeyPressAndRelease then
|
|
DebugPrint( "Kinect: Issuing a GPAD_B button press in response to XBOX GO BACK voice command." )
|
|
Engine.SpeechEmitKeyPressAndRelease( "GPAD_B", f5_arg1.controller )
|
|
end
|
|
end
|
|
|
|
function LUI_UIRoot_HandleSpeechShortcuts( f6_arg0, f6_arg1, f6_arg2 )
|
|
if Engine.HasSpeechFeature() and Kinect.CanOpenKinectGuide() == true then
|
|
Kinect.OpenKinectGuide( f6_arg1.controler )
|
|
LUI.Speech.PerformingSpeechAction()
|
|
end
|
|
end
|
|
|
|
if Engine.HasSpeechFeature() then
|
|
luiRootSpeechGrammarFrontEndHandlersArray = {
|
|
{
|
|
action = "what can i say",
|
|
confidence = LUI.Speech.whatCanISayConfidence,
|
|
handler = LUI_UIRoot_HandleSpeechWhatCanISay,
|
|
extradata = nil
|
|
},
|
|
{
|
|
action = "pause",
|
|
confidence = LUI.Speech.pauseConfidence,
|
|
handler = LUI_UIRoot_HandleSpeechPause,
|
|
extradata = nil
|
|
},
|
|
{
|
|
action = "show view",
|
|
confidence = LUI.Speech.changeViewConfidence,
|
|
handler = LUI_UIRoot_HandleSpeechChangeView,
|
|
extradata = nil
|
|
},
|
|
{
|
|
action = "view",
|
|
confidence = LUI.Speech.changeViewConfidence,
|
|
handler = LUI_UIRoot_HandleSpeechChangeView,
|
|
extradata = nil
|
|
},
|
|
{
|
|
action = "show menu",
|
|
confidence = LUI.Speech.showMenuConfidence,
|
|
handler = LUI_UIRoot_HandleSpeechShowMenu,
|
|
extradata = nil
|
|
},
|
|
{
|
|
action = "menu",
|
|
confidence = LUI.Speech.showMenuConfidence,
|
|
handler = LUI_UIRoot_HandleSpeechShowMenu,
|
|
extradata = nil
|
|
},
|
|
{
|
|
action = "shortcuts",
|
|
confidence = LUI.Speech.defaultConfidence,
|
|
handler = LUI_UIRoot_HandleSpeechShortcuts,
|
|
extradata = nil
|
|
},
|
|
{
|
|
action = "xbox pause",
|
|
confidence = LUI.Speech.pauseConfidence,
|
|
handler = LUI_UIRoot_HandleSpeechPause,
|
|
extradata = nil
|
|
},
|
|
{
|
|
action = "xbox view",
|
|
confidence = LUI.Speech.changeViewConfidence,
|
|
handler = LUI_UIRoot_HandleSpeechChangeView,
|
|
extradata = nil
|
|
},
|
|
{
|
|
action = "xbox menu",
|
|
confidence = LUI.Speech.showMenuConfidence,
|
|
handler = LUI_UIRoot_HandleSpeechShowMenu,
|
|
extradata = nil
|
|
},
|
|
{
|
|
action = "xbox back",
|
|
confidence = LUI.Speech.goBackConfidence,
|
|
handler = LUI_UIRoot_HandleSpeechBack,
|
|
extradata = nil
|
|
}
|
|
}
|
|
luiRootSpeechGrammarInGameHandlersArray = {
|
|
{
|
|
action = "what can i say",
|
|
confidence = LUI.Speech.whatCanISayConfidence,
|
|
handler = LUI_UIRoot_HandleSpeechWhatCanISay,
|
|
extradata = nil
|
|
},
|
|
{
|
|
action = "pause",
|
|
confidence = LUI.Speech.pauseConfidence,
|
|
handler = LUI_UIRoot_HandleSpeechPause,
|
|
extradata = nil
|
|
},
|
|
{
|
|
action = "show view",
|
|
confidence = LUI.Speech.changeViewConfidence,
|
|
handler = LUI_UIRoot_HandleSpeechChangeView,
|
|
extradata = nil
|
|
},
|
|
{
|
|
action = "view",
|
|
confidence = LUI.Speech.changeViewConfidence,
|
|
handler = LUI_UIRoot_HandleSpeechChangeView,
|
|
extradata = nil
|
|
},
|
|
{
|
|
action = "show menu",
|
|
confidence = LUI.Speech.showMenuConfidence,
|
|
handler = LUI_UIRoot_HandleSpeechShowMenu,
|
|
extradata = nil
|
|
},
|
|
{
|
|
action = "menu",
|
|
confidence = LUI.Speech.showMenuConfidence,
|
|
handler = LUI_UIRoot_HandleSpeechShowMenu,
|
|
extradata = nil
|
|
},
|
|
{
|
|
action = "xbox pause",
|
|
confidence = LUI.Speech.pauseConfidence,
|
|
handler = LUI_UIRoot_HandleSpeechPause,
|
|
extradata = nil
|
|
},
|
|
{
|
|
action = "xbox view",
|
|
confidence = LUI.Speech.changeViewConfidence,
|
|
handler = LUI_UIRoot_HandleSpeechChangeView,
|
|
extradata = nil
|
|
},
|
|
{
|
|
action = "xbox menu",
|
|
confidence = LUI.Speech.showMenuConfidence,
|
|
handler = LUI_UIRoot_HandleSpeechShowMenu,
|
|
extradata = nil
|
|
},
|
|
{
|
|
action = "xbox back",
|
|
confidence = LUI.Speech.goBackConfidence,
|
|
handler = LUI_UIRoot_HandleSpeechBack,
|
|
extradata = nil
|
|
}
|
|
}
|
|
else
|
|
luiRootSpeechGrammarFrontEndHandlersArray = {}
|
|
luiRootSpeechGrammarInGameHandlersArray = {}
|
|
end
|
|
function LUI_UIRoot_SpeechRestart( f7_arg0, f7_arg1 )
|
|
if Engine.HasSpeechFeature() then
|
|
LUI.Speech.CancelSpeechFailTimer()
|
|
Kinect.RestartGlobalGrammars()
|
|
end
|
|
end
|
|
|
|
function LUI_UIRoot_SpeechHandler( f8_arg0, f8_arg1 )
|
|
if Engine.HasSpeechFeature() then
|
|
LUI.Speech.LaunchSpeechFailTimer()
|
|
if Engine.InFrontend() then
|
|
LUI.Speech.ProcessActionEvent( f8_arg0, f8_arg1, luiRootSpeechGrammarFrontEndHandlersArray )
|
|
else
|
|
LUI.Speech.ProcessActionEvent( f8_arg0, f8_arg1, luiRootSpeechGrammarInGameHandlersArray )
|
|
end
|
|
end
|
|
end
|
|
|
|
function LUI_UIRoot_SpeechFailTimerHandler( f9_arg0, f9_arg1 )
|
|
if Engine.HasSpeechFeature() then
|
|
if LUI.Speech.waitingForOutstandingCommandConfirmation == true then
|
|
LUI.Speech.waitingForOutstandingCommandConfirmation = false
|
|
LUI.Speech.PlayBadSound()
|
|
end
|
|
LUI.Speech.CancelSpeechFailTimer()
|
|
end
|
|
end
|
|
|
|
local f0_local0 = function ( f10_arg0, f10_arg1 )
|
|
f10_arg0:registerAnimationState( "default", {
|
|
left = -f10_arg1.width / 2,
|
|
top = -f10_arg1.height / 2,
|
|
right = f10_arg1.width / 2,
|
|
bottom = f10_arg1.height / 2,
|
|
leftAnchor = false,
|
|
topAnchor = false,
|
|
rightAnchor = false,
|
|
bottomAnchor = false
|
|
} )
|
|
f10_arg0:animateToState( "default" )
|
|
end
|
|
|
|
local f0_local1 = function ( f11_arg0, f11_arg1 )
|
|
f11_arg1.root = f11_arg0
|
|
f11_arg0:dispatchEventToChildren( f11_arg1 )
|
|
end
|
|
|
|
local f0_local2 = function ( f12_arg0, f12_arg1 )
|
|
local f12_local0 = f12_arg0.m_currentAnimationState
|
|
local f12_local1 = f12_local0.unitsToPixels
|
|
return f12_local0.left + f12_arg1.left * f12_local1, f12_local0.top + f12_arg1.top * f12_local1, f12_local0.left + f12_arg1.right * f12_local1, f12_local0.top + f12_arg1.bottom * f12_local1
|
|
end
|
|
|
|
local f0_local3 = function ( f13_arg0, f13_arg1, f13_arg2 )
|
|
local f13_local0 = f13_arg0.m_currentAnimationState
|
|
local f13_local1 = f13_local0.unitsToPixels
|
|
local f13_local2 = f13_local0.left
|
|
local f13_local3 = f13_local0.top
|
|
f13_arg2:setRectInC( f13_local2 + f13_arg1.left * f13_local1, f13_local3 + f13_arg1.top * f13_local1, f13_local2 + f13_arg1.right * f13_local1, f13_local3 + f13_arg1.bottom * f13_local1 )
|
|
end
|
|
|
|
local f0_local4 = function ( f14_arg0, f14_arg1 )
|
|
return f14_arg1 * f14_arg0.m_currentAnimationState.unitsToPixels
|
|
end
|
|
|
|
local f0_local5 = function ( f15_arg0, f15_arg1, f15_arg2 )
|
|
return f15_arg0:RootPixelsToUnits( f15_arg1, f15_arg2 )
|
|
end
|
|
|
|
LUI.UIRoot.DebugPrint_IgnoreEventsSetup = function ( f16_arg0 )
|
|
f16_arg0.debugPrintIgnoreEvents = {
|
|
process_events = true,
|
|
gamepad_sticks = true,
|
|
mousemove = true
|
|
}
|
|
end
|
|
|
|
local f0_local6 = function ( f17_arg0, f17_arg1 )
|
|
InitPlayerData( f17_arg0, f17_arg1 )
|
|
end
|
|
|
|
local f0_local7 = function ( f18_arg0, f18_arg1 )
|
|
InitPlayerDataExtended( f18_arg0, f18_arg1 )
|
|
end
|
|
|
|
local f0_local8 = function ( f19_arg0, f19_arg1 )
|
|
|
|
end
|
|
|
|
function LUI_UIRoot_TryOpenMOTD( f20_arg0, f20_arg1 )
|
|
TryForceOpenMOTD()
|
|
end
|
|
|
|
function LUI_UIRoot_OnValidatePlayerData( f21_arg0, f21_arg1 )
|
|
local f21_local0 = f21_arg1.controller
|
|
if f21_local0 then
|
|
ValidateOperations( f21_local0 )
|
|
end
|
|
end
|
|
|
|
LUI.UIRoot.new = function ( f22_arg0 )
|
|
local self = LUI.UIElement.new( {
|
|
left = 0,
|
|
top = 0,
|
|
right = 0,
|
|
bottom = 0,
|
|
leftAnchor = false,
|
|
topAnchor = false,
|
|
rightAnchor = false,
|
|
bottomAnchor = false
|
|
} )
|
|
self.id = "LUIRoot"
|
|
self.isaroot = true
|
|
self.unitsToPixelsRect = f0_local2
|
|
self.pixelsToUnits = f0_local5
|
|
self.unitsToPixels = f0_local4
|
|
self.setDimensionsForElement = f0_local3
|
|
self:registerEventHandler( "resize", f0_local0 )
|
|
self:registerEventHandler( "mousemove", f0_local1 )
|
|
self:registerEventHandler( "mousedown", f0_local1 )
|
|
self:registerEventHandler( "mouseup", f0_local1 )
|
|
self:registerEventHandler( "process_events", LUI.UIRoot.ProcessEvents )
|
|
if Engine.HasSpeechFeature() then
|
|
self:registerEventHandler( "menu_auto_nav_timer", LUI.MenuAutoNav.HandleTimerEvent )
|
|
self:registerEventHandler( "speech_grammar_changed", LUI_UIRoot_SpeechRestart )
|
|
self:registerEventHandler( "speech_action", LUI_UIRoot_SpeechHandler )
|
|
self:registerEventHandler( "speech_fail_timer", LUI_UIRoot_SpeechFailTimerHandler )
|
|
end
|
|
if Engine.IsMultiplayer() then
|
|
self:registerEventHandler( "init_player_data", f0_local6 )
|
|
self:registerEventHandler( "init_player_data_extended", f0_local7 )
|
|
self:registerEventHandler( "get_next_round_of_operations", f0_local8 )
|
|
self:registerEventHandler( "open_motd", LUI_UIRoot_TryOpenMOTD )
|
|
self:registerEventHandler( "validate_player_data", LUI_UIRoot_OnValidatePlayerData )
|
|
end
|
|
LUI.roots[f22_arg0] = self
|
|
if LUI.primaryRoot == nil then
|
|
LUI.primaryRoot = self
|
|
end
|
|
self.flowManager = LUI.FlowManager.new()
|
|
self.flowManager:setupRoot( self )
|
|
if not Engine.InFrontend() then
|
|
self.hudManager = LUI.HudManager.new()
|
|
self.hudManager:setupRoot( self )
|
|
end
|
|
self.eventCatcher = LUI.EventCatcher.new()
|
|
self.eventCatcher:setupRoot( self )
|
|
self.timerGroupQueues = {}
|
|
self.name = f22_arg0
|
|
self.eventQueue = {}
|
|
self.debugEvents = true
|
|
LUI.UIRoot.DebugPrint_IgnoreEventsSetup( self )
|
|
self.processEvent = LUI.UIRoot.ProcessEvent
|
|
self.SaveMenuStack = self.flowManager.SaveMenuStack
|
|
self.RestoreMenuStack = self.flowManager.RestoreMenuStack
|
|
self.AnyActiveMenusInStack = self.flowManager.AnyActiveMenusInStack
|
|
self.IsMenuOpenAndVisible = self.flowManager.IsMenuOpenAndVisible
|
|
self.IsMenuInStack = self.flowManager.IsMenuInStack
|
|
self.IsMenuTopmost = self.flowManager.IsMenuTopmost
|
|
self.IsTopSignInMenu = self.flowManager.IsTopSignInMenu
|
|
self.GetFirstButtonActionInFocusId = LUI.UIRoot.GetFirstButtonActionInFocusId
|
|
if Engine.HasSpeechFeature() then
|
|
Kinect.EnableGlobalGrammars()
|
|
end
|
|
return self
|
|
end
|
|
|
|
LUI.UIRoot.GetFirstButtonActionInFocus = function ( f23_arg0 )
|
|
if f23_arg0:isInFocus() and f23_arg0.m_eventHandlers.button_action then
|
|
return f23_arg0
|
|
end
|
|
local f23_local0 = f23_arg0:getFirstChild()
|
|
while f23_local0 do
|
|
local f23_local1 = LUI.UIRoot.GetFirstButtonActionInFocus( f23_local0 )
|
|
if f23_local1 then
|
|
return f23_local1
|
|
end
|
|
f23_local0 = f23_local0:getNextSibling()
|
|
end
|
|
end
|
|
|
|
LUI.UIRoot.GetFirstButtonActionInFocusId = function ( f24_arg0 )
|
|
local f24_local0 = LUI.UIRoot.GetFirstButtonActionInFocus( f24_arg0 )
|
|
return f24_local0.id
|
|
end
|
|
|
|
LUI.UIRoot.BlockButtonInput = function ( f25_arg0, f25_arg1, f25_arg2 )
|
|
if f25_arg1 then
|
|
f25_arg0.m_blockButtonInput = true
|
|
else
|
|
f25_arg0.m_blockButtonInput = false
|
|
end
|
|
end
|
|
|
|
LUI.UIRoot.IsButtonInputBlocked = function ( f26_arg0 )
|
|
return f26_arg0.m_blockButtonInput
|
|
end
|
|
|
|
LUI.UIRoot.ProcessEvent = function ( f27_arg0, f27_arg1 )
|
|
if f27_arg1.immediate == true then
|
|
local f27_local0 = profile.beginuserevent( "IE_" .. f27_arg1.name )
|
|
LUI.UIRoot.ProcessEventNow( f27_arg0, f27_arg1 )
|
|
profile.enduserevent( f27_local0 )
|
|
else
|
|
local f27_local0 = f27_arg0.eventQueue
|
|
table.insert( f27_local0, f27_arg1 )
|
|
if #f27_local0 > 20 then
|
|
DebugPrint( "LUI WARNING: Event queue exceeded 20 events! " .. f27_arg1.name )
|
|
if f27_arg1.name == "omnvar_update" then
|
|
DebugPrint( "LUI WARNING: omnvar = " .. f27_arg1.omnvar )
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
LUI.UIRoot.ProcessEvents = function ( f28_arg0, f28_arg1 )
|
|
LUI.UITimer.DispatchEventsFromQueue( f28_arg0 )
|
|
local f28_local0 = f28_arg0.eventQueue
|
|
local f28_local1 = f28_local0[1]
|
|
if f28_local1 ~= nil then
|
|
table.remove( f28_local0, 1 )
|
|
local f28_local2 = profile.beginuserevent( "RE_" .. f28_local1.name )
|
|
LUI.UIRoot.ProcessEventNow( f28_arg0, f28_local1 )
|
|
profile.enduserevent( f28_local2 )
|
|
end
|
|
end
|
|
|
|
LUI.UIRoot.IsNavigationEvent = function ( f29_arg0 )
|
|
if not handled and f29_arg0.name == "gamepad_button" and f29_arg0.down and (f29_arg0.button == "up" or f29_arg0.button == "down" or f29_arg0.button == "left" or f29_arg0.button == "right") then
|
|
return true
|
|
else
|
|
return false
|
|
end
|
|
end
|
|
|
|
LUI.UIRoot.ProcessEventNow = function ( f30_arg0, f30_arg1 )
|
|
if not f30_arg0.debugPrintIgnoreEvents[f30_arg1.name] and Engine.GetDvarBool( "lui_print_events" ) then
|
|
DebugPrint( "Processed Event " .. f30_arg1.name )
|
|
if f30_arg1.name == "gamepad_button" then
|
|
DebugPrint( "button " .. f30_arg1.button )
|
|
end
|
|
if f30_arg1.name == "keybind" then
|
|
DebugPrint( "keybind " .. f30_arg1.command )
|
|
end
|
|
end
|
|
if f30_arg0.m_blockButtonInput and (f30_arg1.name == "gamepad_button" or f30_arg1.name == "mouseup") then
|
|
DebugPrint( "Blocking Button input for " .. f30_arg1.button .. " because m_ignoreButtonInput is true" )
|
|
return false
|
|
end
|
|
local f30_local0 = f30_arg0
|
|
if f30_arg1.target then
|
|
f30_local0 = f30_arg1.target
|
|
end
|
|
local f30_local1 = LUI.UIElement.processEvent( f30_local0, f30_arg1 )
|
|
if not f30_local1 and LUI.UIRoot.IsNavigationEvent( f30_arg1 ) then
|
|
f30_arg0.flowManager:CheckRestoreFocus()
|
|
end
|
|
return f30_local1
|
|
end
|
|
|