iw6-lui/lui/common_menus/kinectcontrolmenu.dec.lua
2024-09-12 17:25:45 +02:00

783 lines
18 KiB
Lua

local f0_local0 = module
local f0_local1, f0_local2 = ...
f0_local0( f0_local1, package.seeall )
CoD.PrintModuleLoad( _NAME )
function KinectGuideFeeder( f1_arg0 )
local f1_local0 = {}
Kinect.BuildShortcutArray()
if Kinect.ShortcutArray ~= nil then
for f1_local1 = 1, #Kinect.ShortcutArray, 1 do
local f1_local4 = f1_local1
table.insert( f1_local0, {
type = "UIButton",
id = "kinect_guide_grid_" .. f1_local4 .. "_id",
states = {
default = {
topAnchor = false,
bottomAnchor = false,
leftAnchor = false,
rightAnchor = false,
width = Kinect.Layout.CellWidth,
height = Kinect.Layout.CellHeight
}
},
handlers = {
button_action = function ( f2_arg0, f2_arg1 )
Kinect.ExecShortcut( f2_arg0, f2_arg1, f1_local4 )
end
},
children = {
{
type = "UIElement",
states = {
default = {
topAnchor = true,
bottomAnchor = true,
leftAnchor = true,
rightAnchor = true,
top = 0,
bottom = 0,
left = 0,
right = 0,
alpha = 1
},
dim = {
alpha = 0.8
}
},
handlers = {
button_over = MBh.AnimateLoop( {
{
"dim",
750,
true,
true
},
{
"default",
750
}
} ),
button_up = MBh.AnimateToState( "default", 0 )
},
children = {
{
type = "kinect_button_background",
states = {
default = {
topAnchor = true,
bottomAnchor = true,
leftAnchor = true,
rightAnchor = true,
top = 0,
bottom = 0,
left = 0,
right = 0,
alpha = 0.05
},
focused = {
alpha = 0.4
}
},
handlers = {
button_over = MBh.AnimateToState( "focused" ),
button_up = MBh.AnimateToState( "default" )
}
}
}
},
{
type = "UIImage",
states = {
default = {
topAnchor = true,
bottomAnchor = false,
leftAnchor = true,
rightAnchor = false,
top = 0,
bottom = 16,
left = 0,
right = 16,
material = RegisterMaterial( "widg_triangle" ),
alpha = 0
},
focused = {
alpha = 1
}
},
handlers = {
button_over = MBh.AnimateToState( "focused" ),
button_up = MBh.AnimateToState( "default" )
}
},
{
type = "UIImage",
states = {
default = CoD.ColorizeState( Colors.white, {
topAnchor = true,
bottomAnchor = false,
leftAnchor = false,
rightAnchor = false,
top = 0,
width = 128,
height = 128,
material = RegisterMaterial( "icon_kinect_number_0" .. f1_local4 ),
alpha = 0.1
} ),
focused = CoD.ColorizeState( Colors.black, {
scale = 0.1
} ),
unfocused = CoD.ColorizeState( Colors.black, {
scale = 0
} )
},
handlers = {
button_over = MBh.AnimateSequence( {
{
"unfocused",
0
},
{
"focused",
100
},
{
"unfocused",
100
}
} ),
button_up = MBh.AnimateToState( "default", 0 )
}
},
{
type = "UIElement",
states = {
default = {
topAnchor = false,
bottomAnchor = true,
leftAnchor = true,
rightAnchor = true,
bottom = 0,
left = 0,
right = 0,
height = 32
}
},
children = {
{
type = "kinect_btn_footer_bg",
states = {
default = {
topAnchor = true,
bottomAnchor = true,
leftAnchor = true,
rightAnchor = true,
top = 0,
bottom = 0,
left = 0,
right = 0,
alpha = 0.5
}
}
},
{
type = "UIMarqueeText",
id = "kinect_guide_grid_desc_id",
properties = {
text = Engine.Localize( Kinect.ShortcutArray[f1_local4].TextLabel ),
textStyle = CoD.TextStyle.OutlinedMore
},
states = {
default = CoD.ColorizeState( Kinect.Swatch.DescColor, {
topAnchor = false,
bottomAnchor = false,
leftAnchor = true,
rightAnchor = true,
left = 3,
right = -3,
height = CoD.TextSettings.NormalFont.Height,
font = CoD.TextSettings.NormalFont.Font,
alignment = LUI.Alignment.Center
} ),
focused = CoD.ColorizeState( Kinect.Swatch.DescColorInvert, {} ),
unfocused = CoD.ColorizeState( Kinect.Swatch.DescColor, {} )
}
}
}
}
}
} )
end
else
DebugPrint( "Kinect: Warning, Kinect.ShortcutArray is nil!" )
end
return f1_local0
end
function kinect_btn_footer_bg()
return {
type = "UIElement",
states = {
default = {
topAnchor = true,
bottomAnchor = true,
leftAnchor = true,
rightAnchor = true,
top = 0,
bottom = 0,
left = 0,
right = 0
}
},
children = {
{
type = "UIImage",
states = {
default = {
topAnchor = true,
bottomAnchor = true,
leftAnchor = true,
rightAnchor = false,
top = 0,
bottom = 0,
left = 0,
right = 8,
material = RegisterMaterial( "box_kinect_name_lt" )
}
}
},
{
type = "UIImage",
states = {
default = {
topAnchor = true,
bottomAnchor = true,
leftAnchor = true,
rightAnchor = true,
top = 0,
bottom = 0,
left = 8,
right = -8,
material = RegisterMaterial( "box_kinect_name_mid" )
}
}
},
{
type = "UIImage",
states = {
default = {
topAnchor = true,
bottomAnchor = true,
leftAnchor = false,
rightAnchor = true,
top = 0,
bottom = 0,
left = -8,
right = 0,
material = RegisterMaterial( "box_kinect_name_rt" )
}
}
}
}
}
end
function HandleKinectGuideMenuAutoRefresh( f4_arg0, f4_arg1 )
if Kinect.DoWeNeedToRebuildShortcutArray() == true then
LUI.FlowManager.RequestLeaveMenu( f4_arg0 )
end
end
function kinect_guide_grid()
return {
type = "UIGrid",
id = "kinect_guide_grid_id",
handlers = {
autorefresh = HandleKinectGuideMenuAutoRefresh
},
properties = {
elementsPerRow = Kinect.Layout.NumRows,
rowHeight = 150,
hSpacing = 6,
vSpacing = 6,
vAlign = LUI.Alignment.Center,
hAlign = LUI.Alignment.Center
},
states = {
default = {
topAnchor = true,
bottomAnchor = true,
leftAnchor = true,
rightAnchor = true,
top = 0,
bottom = 0,
left = 0,
right = 0
}
},
childrenFeeder = KinectGuideFeeder
}
end
function HandleKinectGuideMenuSpeechBack( f6_arg0, f6_arg1, f6_arg2 )
if not Kinect.IsWhatCanISayMenuUp() and Kinect.IsKinectGuideUp() then
LUI.FlowManager.RequestLeaveMenu( f6_arg0 )
LUI.Speech.PerformingSpeechAction()
end
end
function HandleKinectGuideMenuSpeechCancel( f7_arg0, f7_arg1, f7_arg2 )
LUI.FlowManager.RequestLeaveMenu( f7_arg0 )
LUI.Speech.PerformingSpeechAction()
end
function HandleKinectGuideMenuSpeechYes( f8_arg0, f8_arg1, f8_arg2 )
end
function HandleKinectGuideMenuSpeechNo( f9_arg0, f9_arg1, f9_arg2 )
end
function HandleKinectGuideMenuSpeechShortcut( f10_arg0, f10_arg1, f10_arg2 )
assert( f10_arg2, "HandleKinectGuideMenuSpeechShortcut: Missing extradata param!" )
assert( f10_arg2.shortcutNum, "HandleKinectGuideMenuSpeechShortcut: Missing extradata shortcutNum param!" )
Kinect.ExecShortcut( f10_arg0, f10_arg1, f10_arg2.shortcutNum )
end
function HandleKinectGuideMenuSpeechReplaceShortcut( f11_arg0, f11_arg1, f11_arg2 )
assert( f11_arg2, "HandleKinectGuideMenuSpeechReplaceShortcut: Missing extradata param!" )
assert( f11_arg2.shortcutNum, "HandleKinectGuideMenuSpeechReplaceShortcut: Missing extradata shortcutNum param!" )
end
if Engine.HasSpeechFeature() then
KinectGuideMenuSpeechGrammarHandlersArray = {
{
action = "back",
confidence = LUI.Speech.defaultConfidence,
handler = HandleKinectGuideMenuSpeechBack,
extradata = nil
},
{
action = "cancel",
confidence = LUI.Speech.defaultConfidence,
handler = HandleKinectGuideMenuSpeechCancel,
extradata = nil
},
{
action = "yes",
confidence = LUI.Speech.defaultConfidence,
handler = HandleKinectGuideMenuSpeechYes,
extradata = nil
},
{
action = "no",
confidence = LUI.Speech.defaultConfidence,
handler = HandleKinectGuideMenuSpeechNo,
extradata = nil
},
{
action = "Shortcut 1",
confidence = LUI.Speech.shortcutMenuConfidence,
handler = HandleKinectGuideMenuSpeechShortcut,
extradata = {
shortcutNum = 1
}
},
{
action = "Shortcut 2",
confidence = LUI.Speech.shortcutMenuConfidence,
handler = HandleKinectGuideMenuSpeechShortcut,
extradata = {
shortcutNum = 2
}
},
{
action = "Shortcut 3",
confidence = LUI.Speech.shortcutMenuConfidence,
handler = HandleKinectGuideMenuSpeechShortcut,
extradata = {
shortcutNum = 3
}
},
{
action = "Shortcut 4",
confidence = LUI.Speech.shortcutMenuConfidence,
handler = HandleKinectGuideMenuSpeechShortcut,
extradata = {
shortcutNum = 4
}
},
{
action = "Shortcut 5",
confidence = LUI.Speech.shortcutMenuConfidence,
handler = HandleKinectGuideMenuSpeechShortcut,
extradata = {
shortcutNum = 5
}
},
{
action = "Shortcut 6",
confidence = LUI.Speech.shortcutMenuConfidence,
handler = HandleKinectGuideMenuSpeechShortcut,
extradata = {
shortcutNum = 6
}
},
{
action = "Shortcut 7",
confidence = LUI.Speech.shortcutMenuConfidence,
handler = HandleKinectGuideMenuSpeechShortcut,
extradata = {
shortcutNum = 7
}
},
{
action = "Shortcut 8",
confidence = LUI.Speech.shortcutMenuConfidence,
handler = HandleKinectGuideMenuSpeechShortcut,
extradata = {
shortcutNum = 8
}
},
{
action = "Shortcut 9",
confidence = LUI.Speech.shortcutMenuConfidence,
handler = HandleKinectGuideMenuSpeechShortcut,
extradata = {
shortcutNum = 9
}
},
{
action = "Replace Shortcut 1",
confidence = LUI.Speech.defaultConfidence,
handler = HandleKinectGuideMenuSpeechReplaceShortcut,
extradata = {
shortcutNum = 1
}
},
{
action = "Replace Shortcut 2",
confidence = LUI.Speech.defaultConfidence,
handler = HandleKinectGuideMenuSpeechReplaceShortcut,
extradata = {
shortcutNum = 2
}
},
{
action = "Replace Shortcut 3",
confidence = LUI.Speech.defaultConfidence,
handler = HandleKinectGuideMenuSpeechReplaceShortcut,
extradata = {
shortcutNum = 3
}
},
{
action = "Replace Shortcut 4",
confidence = LUI.Speech.defaultConfidence,
handler = HandleKinectGuideMenuSpeechReplaceShortcut,
extradata = {
shortcutNum = 4
}
},
{
action = "Replace Shortcut 5",
confidence = LUI.Speech.defaultConfidence,
handler = HandleKinectGuideMenuSpeechReplaceShortcut,
extradata = {
shortcutNum = 5
}
},
{
action = "Replace Shortcut 6",
confidence = LUI.Speech.defaultConfidence,
handler = HandleKinectGuideMenuSpeechReplaceShortcut,
extradata = {
shortcutNum = 6
}
},
{
action = "Replace Shortcut 7",
confidence = LUI.Speech.defaultConfidence,
handler = HandleKinectGuideMenuSpeechReplaceShortcut,
extradata = {
shortcutNum = 7
}
},
{
action = "Replace Shortcut 8",
confidence = LUI.Speech.defaultConfidence,
handler = HandleKinectGuideMenuSpeechReplaceShortcut,
extradata = {
shortcutNum = 8
}
},
{
action = "Replace Shortcut 9",
confidence = LUI.Speech.defaultConfidence,
handler = HandleKinectGuideMenuSpeechReplaceShortcut,
extradata = {
shortcutNum = 9
}
}
}
else
KinectGuideMenuSpeechGrammarHandlersArray = {}
end
function HandleKinectGuideMenuSpeechHandler( f12_arg0, f12_arg1 )
if Engine.HasSpeechFeature() then
LUI.Speech.ProcessActionEvent( f12_arg0, f12_arg1, KinectGuideMenuSpeechGrammarHandlersArray )
end
end
function HandleKinectGuideMenuCreate( f13_arg0, f13_arg1 )
f13_arg0:processEvent( {
name = "add_button_helper_text",
button_ref = "button_secondary",
helper_text = Engine.Localize( "@LUA_MENU_BACK" ),
side = "left",
clickable = true
} )
end
function kinect_guide()
return {
type = "UIElement",
id = "kinect_guide_id",
states = {
default = {
topAnchor = true,
bottomAnchor = true,
leftAnchor = true,
rightAnchor = true,
left = 0,
right = 0,
top = 0,
bottom = 0
}
},
handlers = {
menu_create = HandleKinectGuideMenuCreate,
speech_action = HandleKinectGuideMenuSpeechHandler
},
children = {
{
type = "UIImage",
id = "kinect_menu_overlay_id",
states = {
default = CoD.ColorizeState( Swatches.Overlay.Color, {
topAnchor = true,
bottomAnchor = true,
leftAnchor = true,
rightAnchor = true,
left = 0,
right = 0,
top = 0,
bottom = 0,
material = RegisterMaterial( "white" ),
alpha = Swatches.Overlay.AlphaMore
} )
}
},
{
type = "UIElement",
id = "kinect_menu_container_id",
states = {
default = {
topAnchor = false,
bottomAnchor = false,
leftAnchor = false,
rightAnchor = false,
width = Kinect.Layout.Width,
height = Kinect.Layout.Height
}
},
children = {
{
type = "generic_drop_shadow",
properties = {
offset_shadow = 0
}
},
{
type = "generic_menu_titlebar",
id = "kinect_title_id",
properties = {
font = CoD.TextSettings.ExtraBigFont,
title_bar_text = Engine.Localize( "@SPEECH_SHORTCUTS_TITLE" ),
title_bar_alignment = LUI.Alignment.Center,
fill_alpha = 1
}
},
{
type = "generic_menu_background",
id = "kinect_background_id",
properties = {
fill_alpha = 1
}
},
{
type = "kinect_guide_grid",
id = "kinect_guide_grid_id",
states = {
default = {
topAnchor = true,
bottomAnchor = true,
leftAnchor = true,
rightAnchor = true,
top = GenericTitleBarDims.TitleBarHeight + 10,
bottom = -1 * (GenericFooterDims.Height + 5),
left = 5,
right = -5
}
}
},
{
type = "UITimer",
id = "kinect_guid_grid_autorefresh_timer",
properties = {
event = "autorefresh",
interval = 1000,
disposable = false,
broadcastToRoot = false
}
},
{
type = "UIImage",
states = {
default = CoD.ColorizeState( Swatches.GenericMenu.Border, {
topAnchor = false,
bottomAnchor = true,
leftAnchor = true,
rightAnchor = true,
bottom = -40,
left = 1,
right = -1,
height = 1,
material = RegisterMaterial( "white" ),
alpha = Swatches.GenericMenu.BorderAlpha
} )
}
},
{
type = "button_helper_text_main",
id = "kinect_helper_text_id",
properties = {
left_inset = 10,
left_margin = 1,
right_margin = -1,
top_margin = GenericFooterDims.TopMargin_WithoutBackground,
spacing = 65,
background_alpha = 0
}
},
{
type = "UIBindButton",
id = "kinect_bind_buttons_id",
handlers = {
button_secondary = MBh.LeaveMenu()
}
}
}
}
}
}
end
function kinect_button_background( f15_arg0, f15_arg1 )
local f15_local0 = f15_arg1.red or 1
local f15_local1 = f15_arg1.green or 1
local f15_local2 = f15_arg1.blue or 1
local f15_local3 = f15_arg1.alpha or 1
local f15_local4 = f15_arg1.colorLocked or false
local self = LUI.UIElement.new()
self:registerAnimationState( "default", {
topAnchor = true,
bottomAnchor = true,
leftAnchor = true,
rightAnchor = true,
top = top,
bottom = 0,
left = 0,
right = 0
} )
self:animateToState( "default" )
local f15_local6 = LUI.UIImage.new()
f15_local6.id = "corner"
f15_local6:registerAnimationState( "default", {
topAnchor = true,
bottomAnchor = false,
leftAnchor = true,
rightAnchor = false,
top = 0,
bottom = 32,
left = 0,
right = 32,
material = RegisterMaterial( "btn_cas_item_topleft" )
} )
f15_local6:animateToState( "default" )
self:addElement( f15_local6 )
local f15_local7 = LUI.UIImage.new()
f15_local7.id = "top"
f15_local7:registerAnimationState( "default", {
topAnchor = true,
bottomAnchor = false,
leftAnchor = true,
rightAnchor = true,
top = 0,
bottom = 32,
left = 32,
right = 0,
material = RegisterMaterial( "white" )
} )
f15_local7:animateToState( "default" )
self:addElement( f15_local7 )
local f15_local8 = LUI.UIImage.new()
f15_local8.id = "bottom"
f15_local8:registerAnimationState( "default", {
topAnchor = true,
bottomAnchor = true,
leftAnchor = true,
rightAnchor = true,
top = 32,
bottom = 0,
left = 0,
right = 0,
material = RegisterMaterial( "white" )
} )
f15_local8:animateToState( "default" )
self:addElement( f15_local8 )
self.colorize = function ( f16_arg0, f16_arg1, f16_arg2, f16_arg3 )
for f16_local3, f16_local4 in ipairs( {
f15_local6,
f15_local7,
f15_local8
} ) do
f16_local4:registerAnimationState( "current", {
red = f16_arg0,
green = f16_arg1,
blue = f16_arg2,
alpha = f16_arg3
} )
f16_local4:animateToState( "current" )
end
end
self.colorize( f15_local0, f15_local1, f15_local2, f15_local3 )
if not f15_local4 then
self:registerEventHandler( "updateBackgroundColor", function ( element, event )
element.colorize( event.red, event.green, event.blue, event.alpha )
end )
end
return self
end
LUI.MenuBuilder.registerDef( "kinect_guide", kinect_guide )
LUI.FlowManager.RegisterStackPopBehaviour( "kinect_guide", function ()
Engine.ExecNow( "decnosplitscreencontrol kinect_guide_dec" )
end )
LUI.MenuBuilder.registerDef( "kinect_guide_grid", kinect_guide_grid )
LUI.MenuBuilder.registerDef( "kinect_btn_footer_bg", kinect_btn_footer_bg )
LUI.MenuBuilder.registerType( "kinect_button_background", kinect_button_background )
LockTable( _M )