731 lines
21 KiB
Lua
731 lines
21 KiB
Lua
LUI.UIElement = {
|
|
id = "LUIElement",
|
|
m_defaultAnimationState = {
|
|
left = 0,
|
|
top = 0,
|
|
right = 0,
|
|
bottom = 0,
|
|
leftAnchor = false,
|
|
topAnchor = false,
|
|
bottomAnchor = false,
|
|
rightAnchor = false,
|
|
red = 1,
|
|
green = 1,
|
|
blue = 1,
|
|
alpha = 1,
|
|
alphaMultiplier = 1
|
|
}
|
|
}
|
|
LUI.UIElement.addChildRecord = function ( f1_arg0, f1_arg1 )
|
|
local f1_local0 = rawget
|
|
local f1_local1 = getmetatable( f1_arg1 )
|
|
f1_local0 = f1_local0( f1_local1.__newindex, "id" )
|
|
if f1_local0 ~= nil then
|
|
if not f1_arg0.childRecord then
|
|
f1_arg0.childRecord = {}
|
|
end
|
|
if f1_arg0.childRecord[f1_local0] ~= nil then
|
|
DebugPrint( "LUI Warning: Element has duplicate raw id \"" .. f1_local0 .. "\" id .. \"" .. f1_arg1.id .. "\", closing it" )
|
|
f1_arg0.childRecord[f1_local0]:close()
|
|
end
|
|
f1_arg0.childRecord[f1_local0] = f1_arg1
|
|
end
|
|
end
|
|
|
|
LUI.UIElement.removeChildRecord = function ( f2_arg0, f2_arg1 )
|
|
local f2_local0 = rawget
|
|
local f2_local1 = getmetatable( f2_arg1 )
|
|
f2_local0 = f2_local0( f2_local1.__newindex, "id" )
|
|
if f2_local0 ~= nil then
|
|
if f2_arg0.childRecord and f2_arg0.childRecord[f2_local0] then
|
|
f2_arg0.childRecord[f2_local0] = nil
|
|
else
|
|
DebugPrint( "LUI Warning: Removing element from an element which does not contain it: \"" .. f2_local0 .. "\"" )
|
|
end
|
|
end
|
|
end
|
|
|
|
LUI.UIElement.addElement = function ( f3_arg0, f3_arg1 )
|
|
if f3_arg0:canAddElement( f3_arg1 ) then
|
|
f3_arg0:addElementToC( f3_arg1 )
|
|
f3_arg0:addChildRecord( f3_arg1 )
|
|
end
|
|
end
|
|
|
|
LUI.UIElement.addElementBefore = function ( f4_arg0, f4_arg1 )
|
|
local f4_local0 = f4_arg1:getParent()
|
|
if not f4_local0 then
|
|
error( "LUI Error: Element has no parent!" )
|
|
return
|
|
elseif f4_local0:canAddElement( f4_arg0 ) then
|
|
f4_arg0:addElementBeforeInC( f4_arg1 )
|
|
f4_local0:addChildRecord( f4_arg0 )
|
|
end
|
|
end
|
|
|
|
LUI.UIElement.addElementAfter = function ( f5_arg0, f5_arg1 )
|
|
local f5_local0 = f5_arg1:getParent()
|
|
if not f5_local0 then
|
|
error( "LUI Error: Element has no parent!" )
|
|
return
|
|
elseif f5_local0:canAddElement( f5_arg0 ) then
|
|
f5_arg0:addElementAfterInC( f5_arg1 )
|
|
f5_local0:addChildRecord( f5_arg0 )
|
|
end
|
|
end
|
|
|
|
LUI.UIElement.removeElement = function ( f6_arg0, f6_arg1 )
|
|
if f6_arg0.removeElementInC then
|
|
f6_arg0:removeElementInC( f6_arg1 )
|
|
f6_arg0:removeChildRecord( f6_arg1 )
|
|
end
|
|
end
|
|
|
|
LUI.UIElement.canAddElement = function ( f7_arg0, f7_arg1 )
|
|
if f7_arg1 == nil then
|
|
error( "LUI Error: Tried to add nil element!" )
|
|
return false
|
|
elseif f7_arg1:getParent() == f7_arg0 then
|
|
return false
|
|
else
|
|
return true
|
|
end
|
|
end
|
|
|
|
LUI.UIElement.isClosed = function ( f8_arg0 )
|
|
return f8_arg0:getParent() == nil
|
|
end
|
|
|
|
LUI.UIElement.close = function ( f9_arg0 )
|
|
local f9_local0 = f9_arg0:getParent()
|
|
if f9_local0 ~= nil then
|
|
f9_local0:removeElement( f9_arg0 )
|
|
end
|
|
end
|
|
|
|
LUI.UIElement.closeChildren = function ( f10_arg0 )
|
|
local f10_local0 = f10_arg0:getFirstChild()
|
|
if not f10_local0 then
|
|
return
|
|
end
|
|
while f10_local0 do
|
|
local f10_local1 = f10_local0:getNextSibling()
|
|
f10_local0:close()
|
|
f10_local0 = f10_local1
|
|
end
|
|
end
|
|
|
|
LUI.UIElement.closeTree = function ( f11_arg0 )
|
|
local f11_local0 = f11_arg0:getFirstChild()
|
|
while f11_local0 do
|
|
local f11_local1 = f11_local0:getNextSibling()
|
|
f11_local0:closeTree()
|
|
f11_local0 = f11_local1
|
|
end
|
|
local f11_local1 = f11_arg0:getParent()
|
|
if f11_local1 ~= nil then
|
|
f11_local1:removeElementInC( f11_arg0 )
|
|
f11_local1:removeChildRecord( f11_arg0 )
|
|
end
|
|
end
|
|
|
|
LUI.UIElement.getFullID = function ( f12_arg0 )
|
|
local f12_local0 = f12_arg0.id
|
|
local f12_local1 = f12_arg0:getParent()
|
|
while f12_local1 do
|
|
f12_local0 = f12_local1.id .. "/" .. f12_local0
|
|
f12_local1 = f12_local1:getParent()
|
|
end
|
|
return f12_local0
|
|
end
|
|
|
|
LUI.UIElement.getChildById = function ( f13_arg0, f13_arg1 )
|
|
return f13_arg0.childRecord and f13_arg0.childRecord[f13_arg1]
|
|
end
|
|
|
|
LUI.UIElement.getFirstDescendentById = function ( f14_arg0, f14_arg1 )
|
|
local f14_local0 = f14_arg0.childRecord
|
|
if f14_local0 then
|
|
f14_local0 = f14_arg0.childRecord[f14_arg1]
|
|
end
|
|
if f14_local0 ~= nil then
|
|
return f14_local0
|
|
end
|
|
f14_local0 = f14_arg0:getFirstChild()
|
|
while f14_local0 ~= nil do
|
|
local f14_local1 = f14_local0:getFirstDescendentById( f14_arg1 )
|
|
if f14_local1 ~= nil then
|
|
return f14_local1
|
|
end
|
|
f14_local0 = f14_local0:getNextSibling()
|
|
end
|
|
return nil
|
|
end
|
|
|
|
LUI.UIElement.setHandleMouse = function ( f15_arg0, f15_arg1 )
|
|
f15_arg0.handleMouseMove = f15_arg1
|
|
f15_arg0.handleMouseButton = f15_arg1
|
|
end
|
|
|
|
LUI.UIElement.setHandleMouseMove = function ( f16_arg0, f16_arg1 )
|
|
f16_arg0.handleMouseMove = f16_arg1
|
|
end
|
|
|
|
LUI.UIElement.setHandleMouseButton = function ( f17_arg0, f17_arg1 )
|
|
f17_arg0.handleMouseButton = f17_arg1
|
|
end
|
|
|
|
LUI.UIElement.MouseMoveEvent = function ( f18_arg0, f18_arg1 )
|
|
if f18_arg0.m_ignoreMouseFocus or f18_arg0.m_outsideParentList or f18_arg0.m_focusLockedByScrolling then
|
|
return
|
|
elseif not Engine.UsesMouseCursor() then
|
|
return
|
|
elseif not Engine.InFrontend() and not LUI.UIRoot.mouseInitialized then
|
|
LUI.UIRoot.mouseInitialized = true
|
|
return true
|
|
end
|
|
local f18_local0 = false
|
|
f18_arg0:applyElementTransform()
|
|
if f18_arg0.handleMouseMove and not f18_arg1.waitingForKeyBind then
|
|
local f18_local1, f18_local2 = ProjectRootCoordinate( f18_arg1.rootName, f18_arg1.x, f18_arg1.y )
|
|
if f18_local1 == nil or f18_local2 == nil then
|
|
f18_arg0:undoElementTransform()
|
|
return
|
|
end
|
|
local f18_local3 = false
|
|
local f18_local4, f18_local5, f18_local6, f18_local7 = f18_arg0:getRect()
|
|
if f18_arg1.mouse_outside == nil and f18_local4 ~= nil and f18_local5 <= f18_local2 and f18_local2 <= f18_local7 and f18_local4 <= f18_local1 and f18_local1 <= f18_local6 then
|
|
f18_local3 = true
|
|
end
|
|
if f18_local3 then
|
|
if f18_arg0:canFocus( FocusType.MouseOver ) and not f18_arg0:isInFocus() then
|
|
f18_arg0:processEvent( {
|
|
name = "gain_focus",
|
|
focusType = FocusType.MouseOver
|
|
} )
|
|
local f18_local8 = f18_arg0:getParent()
|
|
if f18_local8:isIDNamed() then
|
|
f18_local8.shouldSaveState = true
|
|
end
|
|
end
|
|
if f18_arg0.m_mouseOver == nil then
|
|
f18_arg0.m_mouseOver = true
|
|
if f18_arg0.m_eventHandlers.mouseenter ~= nil then
|
|
f18_arg0.m_eventHandlers:mouseenter( {
|
|
name = "mouseenter",
|
|
controller = f18_arg1.controller,
|
|
root = f18_arg1.root,
|
|
x = f18_local1,
|
|
y = f18_local2
|
|
} )
|
|
end
|
|
end
|
|
if f18_arg0.m_eventHandlers.mouseover ~= nil then
|
|
f18_arg0.m_eventHandlers:mouseover( {
|
|
name = "mouseover",
|
|
controller = f18_arg1.controller,
|
|
root = f18_arg1.root,
|
|
x = f18_local1,
|
|
y = f18_local2
|
|
} )
|
|
end
|
|
else
|
|
if f18_arg0:isInFocus() then
|
|
f18_arg0:processEvent( {
|
|
name = "lose_focus"
|
|
} )
|
|
end
|
|
if f18_arg0.m_mouseOver ~= nil then
|
|
f18_arg0.m_mouseOver = nil
|
|
if f18_arg0.m_eventHandlers.mouseleave ~= nil then
|
|
f18_arg0.m_eventHandlers:mouseleave( {
|
|
name = "mouseleave",
|
|
controller = f18_arg1.controller,
|
|
root = f18_arg1.root
|
|
} )
|
|
end
|
|
end
|
|
end
|
|
if not f18_local3 and f18_arg1.mouse_outside == nil then
|
|
f18_arg1.mouse_outside = true
|
|
f18_local0 = true
|
|
end
|
|
end
|
|
f18_arg0:dispatchEventToChildren( f18_arg1 )
|
|
if f18_arg0.shouldSaveState then
|
|
f18_arg0:saveState()
|
|
f18_arg0.shouldSaveState = nil
|
|
end
|
|
if f18_local0 then
|
|
f18_arg1.mouse_outside = nil
|
|
end
|
|
f18_arg0:undoElementTransform()
|
|
end
|
|
|
|
LUI.UIElement.MouseButtonEvent = function ( f19_arg0, f19_arg1 )
|
|
if f19_arg0.m_ignoreMouseFocus or f19_arg0.m_outsideParentList or f19_arg0.m_focusLockedByScrolling then
|
|
return
|
|
end
|
|
f19_arg0:applyElementTransform()
|
|
if f19_arg0.handleMouseButton then
|
|
local f19_local0, f19_local1 = ProjectRootCoordinate( f19_arg1.rootName, f19_arg1.x, f19_arg1.y )
|
|
if f19_local0 == nil or f19_local1 == nil then
|
|
f19_arg0:undoElementTransform()
|
|
return
|
|
end
|
|
local f19_local2 = false
|
|
local f19_local3, f19_local4, f19_local5, f19_local6 = f19_arg0:getRect()
|
|
if f19_arg1.mouse_outside == nil and f19_local3 ~= nil and f19_local4 <= f19_local1 and f19_local1 <= f19_local6 and f19_local3 <= f19_local0 and f19_local0 <= f19_local5 then
|
|
f19_local2 = true
|
|
end
|
|
if f19_arg1.name == "mouseup" then
|
|
if f19_arg1.button == "left" and f19_arg0.m_leftMouseDown ~= nil then
|
|
f19_arg0.m_leftMouseDown = nil
|
|
if f19_arg0.m_eventHandlers.leftmouseup ~= nil then
|
|
local f19_local7 = f19_arg0.m_eventHandlers:leftmouseup( {
|
|
name = "leftmouseup",
|
|
controller = f19_arg1.controller,
|
|
root = f19_arg1.root,
|
|
x = f19_local0,
|
|
y = f19_local1,
|
|
inside = f19_local2
|
|
} )
|
|
if f19_local7 then
|
|
f19_arg0:undoElementTransform()
|
|
return f19_local7
|
|
end
|
|
end
|
|
end
|
|
if f19_arg1.button == "right" and f19_arg0.m_rightMouseDown ~= nil then
|
|
f19_arg0.m_rightMouseDown = nil
|
|
if f19_arg0.m_eventHandlers.rightmouseup ~= nil then
|
|
local f19_local7 = f19_arg0.m_eventHandlers:rightmouseup( {
|
|
name = "rightmouseup",
|
|
controller = f19_arg1.controller,
|
|
root = f19_arg1.root,
|
|
x = f19_local0,
|
|
y = f19_local1,
|
|
inside = f19_local2
|
|
} )
|
|
if f19_local7 then
|
|
f19_arg0:undoElementTransform()
|
|
return f19_local7
|
|
end
|
|
end
|
|
end
|
|
end
|
|
if f19_local2 and f19_arg1.name == "mousedown" then
|
|
if f19_arg1.button == "left" and f19_arg0.m_eventHandlers.leftmousedown ~= nil and f19_arg0.m_leftMouseDown == nil then
|
|
f19_arg0.m_leftMouseDown = true
|
|
f19_arg0.m_eventHandlers:leftmousedown( {
|
|
name = "leftmousedown",
|
|
controller = f19_arg1.controller,
|
|
root = f19_arg1.root,
|
|
x = f19_local0,
|
|
y = f19_local1,
|
|
inside = f19_local2
|
|
} )
|
|
end
|
|
if f19_arg1.button == "right" and f19_arg0.m_eventHandlers.rightmousedown ~= nil and f19_arg0.m_rightMouseDown == nil then
|
|
f19_arg0.m_rightMouseDown = true
|
|
f19_arg0.m_eventHandlers:rightmousedown( {
|
|
name = "rightmousedown",
|
|
controller = f19_arg1.controller,
|
|
root = f19_arg1.root,
|
|
x = f19_local0,
|
|
y = f19_local1,
|
|
inside = f19_local2
|
|
} )
|
|
end
|
|
end
|
|
if f19_arg0.m_eventHandlers.mousedrag ~= nil and f19_arg0.m_leftMouseDown ~= nil then
|
|
f19_arg0.m_eventHandlers:mousedrag( {
|
|
name = "mousedrag",
|
|
controller = f19_arg1.controller,
|
|
root = f19_arg1.root,
|
|
x = f19_local0,
|
|
y = f19_local1
|
|
} )
|
|
end
|
|
end
|
|
f19_arg0:dispatchEventToChildren( f19_arg1 )
|
|
f19_arg0:undoElementTransform()
|
|
end
|
|
|
|
LUI.UIElement.GamepadButton = function ( f20_arg0, f20_arg1 )
|
|
if not f20_arg0:handleGamepadButton( f20_arg1 ) then
|
|
if f20_arg0.m_ownerController == nil or f20_arg0.m_ownerController == f20_arg1.controller then
|
|
return f20_arg0:dispatchEventToChildren( f20_arg1 )
|
|
else
|
|
DebugPrint( "Item Exclusive to controller " .. f20_arg1.controller )
|
|
|
|
end
|
|
else
|
|
return true
|
|
end
|
|
end
|
|
|
|
LUI.UIElement.handleGamepadButton = function ( f21_arg0, f21_arg1 )
|
|
if f21_arg0:isInFocus() and f21_arg1.down == true and f21_arg0.m_disableNavigation ~= true and f21_arg0.navigation[f21_arg1.button] and f21_arg0.navigation[f21_arg1.button]:canFocus( FocusType.Gamepad ) then
|
|
local f21_local0 = f21_arg0:getParent()
|
|
if f21_local0:isIDNamed() then
|
|
f21_local0:saveState()
|
|
end
|
|
f21_arg0:processEvent( {
|
|
name = "lose_focus",
|
|
controller = f21_arg1.controller
|
|
} )
|
|
f21_arg0.navigation[f21_arg1.button]:processEvent( {
|
|
name = "gain_focus",
|
|
controller = f21_arg1.controller
|
|
} )
|
|
if f21_local0:isIDNamed() and f21_local0 == f21_arg0.navigation[f21_arg1.button]:getParent() then
|
|
f21_local0:saveState()
|
|
end
|
|
return true
|
|
else
|
|
|
|
end
|
|
end
|
|
|
|
LUI.UIElement.disableTreeFocus = function ( f22_arg0, f22_arg1 )
|
|
f22_arg0.m_disableTreeFocus = true
|
|
end
|
|
|
|
LUI.UIElement.enableTreeFocus = function ( f23_arg0, f23_arg1 )
|
|
f23_arg0.m_disableTreeFocus = nil
|
|
end
|
|
|
|
LUI.UIElement.canFocus = function ( f24_arg0, f24_arg1 )
|
|
local f24_local0 = f24_arg0.m_focusable
|
|
if f24_local0 and f24_arg0.m_requireFocusType then
|
|
f24_local0 = f24_arg1 == f24_arg0.m_requireFocusType
|
|
end
|
|
return f24_local0
|
|
end
|
|
|
|
LUI.UIElement.gainFocus = function ( f25_arg0, f25_arg1 )
|
|
if f25_arg0:canFocus( f25_arg1.focusType ) then
|
|
f25_arg0:setFocus( true )
|
|
end
|
|
if not f25_arg0.m_disableTreeFocus then
|
|
f25_arg0:dispatchEventToChildren( f25_arg1 )
|
|
end
|
|
end
|
|
|
|
LUI.UIElement.loseFocus = function ( f26_arg0, f26_arg1 )
|
|
if f26_arg0.m_focusable and f26_arg0:isInFocus() then
|
|
f26_arg0:setFocus( false )
|
|
end
|
|
f26_arg0:dispatchEventToChildren( f26_arg1 )
|
|
end
|
|
|
|
LUI.UIElement.processEvent = function ( f27_arg0, f27_arg1 )
|
|
local f27_local0 = f27_arg0.m_eventHandlers[f27_arg1.name]
|
|
if f27_local0 ~= nil then
|
|
if f27_arg1.dispatchChildren then
|
|
f27_arg0:dispatchEventToChildren( f27_arg1 )
|
|
end
|
|
return f27_local0( f27_arg0, f27_arg1 )
|
|
else
|
|
return f27_arg0:dispatchEventToChildren( f27_arg1 )
|
|
end
|
|
end
|
|
|
|
LUI.UIElement.dispatchEventToParent = function ( f28_arg0, f28_arg1 )
|
|
local f28_local0 = f28_arg0:getParent()
|
|
while f28_local0 do
|
|
local f28_local1 = f28_local0.m_eventHandlers[f28_arg1.name]
|
|
if f28_local1 then
|
|
if f28_arg1.dispatchChildren then
|
|
f28_local0:dispatchEventToChildren( f28_arg1 )
|
|
end
|
|
return f28_local1( f28_local0, f28_arg1 )
|
|
end
|
|
f28_local0 = f28_local0:getParent()
|
|
end
|
|
end
|
|
|
|
LUI.UIElement.dispatchEventToMenuRoot = function ( f29_arg0, f29_arg1 )
|
|
local f29_local0 = f29_arg0
|
|
local f29_local1 = f29_arg0:getParent()
|
|
local f29_local2 = f29_arg0:getRootParent()
|
|
if f29_local2.flowManager and f29_local2.flowManager.menuRoot then
|
|
local f29_local3 = f29_local2.flowManager.menuRoot
|
|
while f29_local1 do
|
|
if f29_local1 == f29_local3 then
|
|
return f29_local0:processEvent( f29_arg1 )
|
|
end
|
|
f29_local0 = f29_local1
|
|
f29_local1 = f29_local1:getParent()
|
|
end
|
|
end
|
|
DebugPrint( "LUI Warning: Could not find the Menu Root for " .. f29_arg1.name .. " called on elemment id " .. (f29_arg0.id or "anonymous element") )
|
|
end
|
|
|
|
LUI.UIElement.dispatchEventToChildren = function ( f30_arg0, f30_arg1 )
|
|
local f30_local0 = f30_arg0:getFirstChild()
|
|
while f30_local0 do
|
|
local f30_local1 = f30_local0:getNextSibling()
|
|
local f30_local2 = f30_local0:processEvent( f30_arg1 )
|
|
if f30_local2 then
|
|
return f30_local2
|
|
end
|
|
f30_local0 = f30_local1
|
|
end
|
|
end
|
|
|
|
LUI.UIElement.getRootParent = function ( f31_arg0 )
|
|
return Engine.GetLuiRoot()
|
|
end
|
|
|
|
LUI.UIElement.dispatchEventToRoot = function ( f32_arg0, f32_arg1 )
|
|
LUI.UIRoot.ProcessEvent( f32_arg0:getRootParent(), f32_arg1 )
|
|
end
|
|
|
|
LUI.UIElement.dispatchEventToAllOtherRoots = function ( f33_arg0, f33_arg1 )
|
|
local f33_local0 = f33_arg0:getRootParent()
|
|
for f33_local4, f33_local5 in pairs( LUI.roots ) do
|
|
if f33_local0 ~= f33_local5 and f33_local5 ~= LUI.primaryRoot then
|
|
f33_local5:processEvent( f33_arg1 )
|
|
end
|
|
end
|
|
end
|
|
|
|
LUI.UIElement.getRootController = function ( f34_arg0 )
|
|
local f34_local0 = f34_arg0:getRootParent()
|
|
return f34_local0.m_controllerIndex
|
|
end
|
|
|
|
LUI.UIElement.registerEventHandler = function ( f35_arg0, f35_arg1, f35_arg2 )
|
|
f35_arg0.m_eventHandlers[f35_arg1] = f35_arg2
|
|
if not f35_arg0.isaroot and LUI.EventCatcher.isDirectDispatchEventType( f35_arg1 ) then
|
|
local f35_local0 = f35_arg0:getRootParent()
|
|
f35_local0.eventCatcher:registerDirectDispatchHandler( f35_arg0, f35_arg1, f35_arg2 )
|
|
end
|
|
end
|
|
|
|
LUI.UIElement.registerOmnvarHandler = function ( f36_arg0, f36_arg1, f36_arg2 )
|
|
assert( not f36_arg0.isaroot )
|
|
local f36_local0 = f36_arg0:getRootParent()
|
|
f36_local0.eventCatcher:registerOmnvarHandler( f36_arg0, f36_arg1, f36_arg2 )
|
|
end
|
|
|
|
LUI.UIElement.registerDvarHandler = function ( f37_arg0, f37_arg1, f37_arg2 )
|
|
assert( not f37_arg0.isaroot )
|
|
local f37_local0 = f37_arg0:getRootParent()
|
|
f37_local0.eventCatcher:registerDvarHandler( f37_arg0, f37_arg1, f37_arg2 )
|
|
end
|
|
|
|
LUI.UIElement.registerEventHandlerIfFree = function ( f38_arg0, f38_arg1, f38_arg2 )
|
|
if f38_arg0.m_eventHandlers[f38_arg1] == nil then
|
|
f38_arg0:registerEventHandler( f38_arg1, f38_arg2 )
|
|
end
|
|
end
|
|
|
|
local f0_local0 = function ( f39_arg0, f39_arg1 )
|
|
local f39_local0 = f39_arg0
|
|
local f39_local1 = f39_arg1
|
|
return function ( f40_arg0, f40_arg1 )
|
|
local f40_local0, f40_local1 = nil
|
|
return f39_local0( f40_arg0, f40_arg1 ) or f39_local1( f40_arg0, f40_arg1 )
|
|
end
|
|
|
|
end
|
|
|
|
LUI.UIElement.addEventHandler = function ( f41_arg0, f41_arg1, f41_arg2 )
|
|
if f41_arg0.m_eventHandlers[f41_arg1] then
|
|
f41_arg0:registerEventHandler( f41_arg1, f0_local0( f41_arg2, f41_arg0.m_eventHandlers[f41_arg1] ) )
|
|
else
|
|
f41_arg0:registerEventHandler( f41_arg1, f41_arg2 )
|
|
end
|
|
end
|
|
|
|
LUI.UIElement.makeFocusable = function ( f42_arg0 )
|
|
f42_arg0.m_focusable = true
|
|
f42_arg0.navigation = {}
|
|
end
|
|
|
|
LUI.UIElement.makeNotFocusable = function ( f43_arg0 )
|
|
f43_arg0.m_focusable = false
|
|
end
|
|
|
|
LUI.UIElement.isIDNamed = function ( f44_arg0 )
|
|
local f44_local0
|
|
if type( f44_arg0.id ) ~= "string" or f44_arg0.id == "" then
|
|
f44_local0 = false
|
|
else
|
|
f44_local0 = true
|
|
end
|
|
return f44_local0
|
|
end
|
|
|
|
LUI.UIElement.getFirstInFocus = function ( f45_arg0 )
|
|
if f45_arg0:isInFocus() then
|
|
return f45_arg0
|
|
end
|
|
local f45_local0 = f45_arg0:getFirstChild()
|
|
while f45_local0 do
|
|
local f45_local1 = f45_local0:getFirstInFocus()
|
|
if f45_local1 then
|
|
return f45_local1
|
|
end
|
|
f45_local0 = f45_local0:getNextSibling()
|
|
end
|
|
end
|
|
|
|
LUI.UIElement.getAllFocusedChildren = function ( f46_arg0, f46_arg1 )
|
|
if not f46_arg1 then
|
|
f46_arg1 = {}
|
|
end
|
|
local f46_local0 = f46_arg0:getFirstChild()
|
|
while f46_local0 do
|
|
local f46_local1 = f46_local0:getNextSibling()
|
|
if f46_local0:isInFocus() then
|
|
f46_arg1[#f46_arg1 + 1] = f46_local0
|
|
else
|
|
f46_arg1 = f46_local0:getAllFocusedChildren( f46_arg1 )
|
|
end
|
|
f46_local0 = f46_local1
|
|
end
|
|
return f46_arg1
|
|
end
|
|
|
|
LUI.UIElement.isParentInFocus = function ( f47_arg0 )
|
|
local f47_local0 = f47_arg0:getParent()
|
|
if f47_local0 and f47_local0:isInFocus() then
|
|
return true
|
|
else
|
|
return false
|
|
end
|
|
end
|
|
|
|
LUI.UIElement.saveState = function ( f48_arg0 )
|
|
if not f48_arg0:isIDNamed() then
|
|
error( "LUI Error: Tried to save menu state, but element has no name: " .. f48_arg0:getFullID() )
|
|
return
|
|
end
|
|
LUI.savedMenuStates[f48_arg0.id] = {}
|
|
for f48_local3, f48_local4 in ipairs( f48_arg0:getAllFocusedChildren() ) do
|
|
if not f48_local4:isIDNamed() then
|
|
error( "LUI Error: Tried to save menu state, but focused element has no name: " .. f48_local4:getFullID() )
|
|
return
|
|
end
|
|
LUI.savedMenuStates[f48_arg0.id][#LUI.savedMenuStates[f48_arg0.id] + 1] = {
|
|
id = f48_local4.id,
|
|
data = f48_local4.saveData
|
|
}
|
|
end
|
|
end
|
|
|
|
LUI.UIElement.clearSavedState = function ( f49_arg0 )
|
|
if not f49_arg0:isIDNamed() then
|
|
error( "LUI Error: Tried to save menu state, but element has no name: " .. f49_arg0:getFullID() )
|
|
return
|
|
end
|
|
local f49_local0 = f49_arg0:getFirstChild()
|
|
while f49_local0 do
|
|
local f49_local1 = f49_local0:getNextSibling()
|
|
f49_local0:clearSavedState()
|
|
f49_local0 = f49_local1
|
|
end
|
|
LUI.savedMenuStates[f49_arg0.id] = nil
|
|
end
|
|
|
|
LUI.UIElement.restoreState = function ( f50_arg0, f50_arg1 )
|
|
if not f50_arg0:isIDNamed() then
|
|
error( "LUI Error: Tried to restore menu state, but element has no name: " .. f50_arg0:getFullID() )
|
|
return
|
|
end
|
|
local f50_local0 = false
|
|
local f50_local1 = 0
|
|
if LUI.savedMenuStates[f50_arg0.id] ~= nil then
|
|
f50_local0 = true
|
|
for f50_local5, f50_local6 in ipairs( LUI.savedMenuStates[f50_arg0.id] ) do
|
|
if f50_local6.id and f50_arg0:processEvent( {
|
|
name = "restore_focus",
|
|
id = f50_local6.id,
|
|
data = f50_local6.data,
|
|
isRefresh = f50_arg1
|
|
} ) then
|
|
f50_local1 = f50_local1 + 1
|
|
end
|
|
end
|
|
end
|
|
return f50_local0, f50_local1
|
|
end
|
|
|
|
LUI.UIElement.restoreFocus = function ( f51_arg0, f51_arg1 )
|
|
if f51_arg0.id == f51_arg1.id and f51_arg0:canFocus( FocusType.MenuFlow ) then
|
|
if not f51_arg1.isRefresh or f51_arg1.isRefresh and not f51_arg0._isRefresh then
|
|
f51_arg0:processEvent( {
|
|
name = "gain_focus",
|
|
focusType = FocusType.MenuFlow
|
|
} )
|
|
end
|
|
return true
|
|
else
|
|
return f51_arg0:dispatchEventToChildren( f51_arg1 )
|
|
end
|
|
end
|
|
|
|
if not LUI.UIElement.hasAnimationState then
|
|
LUI.UIElement.hasAnimationState = function ( f52_arg0, f52_arg1 )
|
|
if not f52_arg0.hasAnimationStateInC then
|
|
return f52_arg0.m_animationStates[f52_arg1]
|
|
else
|
|
return f52_arg0:hasAnimationStateInC( f52_arg1 )
|
|
end
|
|
end
|
|
|
|
end
|
|
LUI.UIElement.setClass = function ( f53_arg0, f53_arg1 )
|
|
local f53_local0 = getmetatable( f53_arg0 )
|
|
local f53_local1 = f53_local0.__newindex
|
|
local f53_local2 = getmetatable( f53_local1 )
|
|
if not f53_local2 then
|
|
setmetatable( f53_local1, {
|
|
__index = f53_arg1
|
|
} )
|
|
else
|
|
f53_local2.__index = f53_arg1
|
|
end
|
|
local f53_local3 = getmetatable( f53_local1.m_eventHandlers )
|
|
if not f53_local3 then
|
|
setmetatable( f53_local1.m_eventHandlers, {
|
|
__index = f53_arg1.m_eventHandlers
|
|
} )
|
|
else
|
|
f53_local3.__index = f53_arg1.m_eventHandlers
|
|
end
|
|
end
|
|
|
|
LUI.UIElement.m_eventHandlers = {
|
|
mousemove = LUI.UIElement.MouseMoveEvent,
|
|
mousedown = LUI.UIElement.MouseButtonEvent,
|
|
mouseup = LUI.UIElement.MouseButtonEvent,
|
|
gamepad_button = LUI.UIElement.GamepadButton,
|
|
gain_focus = LUI.UIElement.gainFocus,
|
|
lose_focus = LUI.UIElement.loseFocus,
|
|
restore_focus = LUI.UIElement.restoreFocus,
|
|
close = LUI.UIElement.close
|
|
}
|
|
LUI.UIElement.build = function ( f54_arg0, f54_arg1 )
|
|
return LUI.UIElement.new()
|
|
end
|
|
|
|
LUI.UIElement.new = function ( f55_arg0 )
|
|
local f55_local0 = ConstructLUIElement()
|
|
LUI.UIElement.setClass( f55_local0, LUI.UIElement )
|
|
f55_local0._scoped = LUI.ActiveScoped
|
|
f55_local0:setLayoutCached( false )
|
|
if not f55_arg0 then
|
|
f55_local0:registerAnimationState( "default", LUI.UIElement.m_defaultAnimationState )
|
|
else
|
|
f55_local0:registerAnimationState( "default", f55_arg0 )
|
|
end
|
|
f55_local0:animateToState( "default" )
|
|
return f55_local0
|
|
end
|
|
|