1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
-- Helper object for dynamically creating keyboard panels. This object does not store the panel itself, and can safely be garbage collected after a panel is created.
return object
end
end
do
-- TODO: Bake these offsets into the control templates themselves
local Y_OFFSET_FOR_CONTROL_TEMPLATE =
{
[ "ZO_Options_Dropdown" ] = 10 ,
[ "ZO_Options_Video_Dropdown_IncludeApplyScreenWarning" ] = 10 ,
[ "ZO_Options_Dropdown_DynamicWarning" ] = 10 ,
[ "ZO_Options_Slider" ] = 4 ,
[ "ZO_Options_Video_Slider_IncludeMaxParticleSystemsWarning" ] = 4 ,
[ "ZO_Options_Slider_VerticalLabel" ] = 4 ,
[ "ZO_Options_Checkbox" ] = 6 ,
[ "ZO_Options_Video_Checkbox_IncludeRestartWarning" ] = 6 ,
[ "ZO_Options_Checkbox_DynamicWarning" ] = 6 ,
[ "ZO_Options_InvokeCallback" ] = 4 ,
[ "ZO_Options_InvokeCallback_Wide" ] = 4 ,
[ "ZO_Options_Account_InvokeCallback_WithEmail" ] = 4 ,
[ "ZO_Options_Color" ] = 4 ,
[ "ZO_Options_Social_ChatColor" ] = 8 ,
[ "ZO_Options_Social_GuildLabel" ] = 30 ,
}
local INDENT_X_OFFSET = 20
local HEADER_Y_OFFSET = 15
-- add headers if necessary
local settingData = KEYBOARD_OPTIONS : GetSettingsData ( self . panel , settingTemplate . settingType , settingTemplate . settingId )
local headerControl
headerControl = CreateControlFromVirtual ( controlName , ZO_OptionsWindowSettingsScrollChild , "ZO_Options_SectionTitle_PanelHeader" )
else
headerControl = CreateControlFromVirtual ( controlName , ZO_OptionsWindowSettingsScrollChild , "ZO_Options_SectionTitle_WithDivider" )
headerControl : SetAnchor ( TOPLEFT , self . lastControl , BOTTOMLEFT , ( self . lastIndentLevel * - INDENT_X_OFFSET ) , HEADER_Y_OFFSET )
end
end
local template = settingTemplate . template
if not template then
-- Use default template for control type
if controlType == OPTIONS_DROPDOWN then
template = "ZO_Options_Dropdown"
elseif controlType == OPTIONS_CHECKBOX then
template = "ZO_Options_Checkbox"
elseif controlType == OPTIONS_SLIDER then
template = "ZO_Options_Slider"
elseif controlType == OPTIONS_INVOKE_CALLBACK then
template = "ZO_Options_InvokeCallback"
elseif controlType == OPTIONS_COLOR then
template = "ZO_Options_Color"
elseif controlType == OPTIONS_CHAT_COLOR then
template = "ZO_Options_Social_ChatColor"
else
internalassert ( false , string . format ( "No control template for control type: %s" , tostring ( controlType ) ) )
end
end
local settingControl = CreateControlFromVirtual ( settingTemplate . controlName , ZO_OptionsWindowSettingsScrollChild , template )
local yOffset = internalassert ( Y_OFFSET_FOR_CONTROL_TEMPLATE [ template ] , "Missing Y offset for control" ) or 0
local indentLevel = settingTemplate . indentLevel or 0
settingControl : SetAnchor ( TOPLEFT , self . lastControl , BOTTOMLEFT , indentDifference * INDENT_X_OFFSET , yOffset )
local initializeControlFunction = settingTemplate . initializeControlFunction or ZO_OptionsWindow_InitializeControl
end
end
end |