Skip to main content
Skip to main content

ColorPickerDialog

ColorPickerDialog

Description

Color Picker Dialog Lets the player pick from a set of colors.

Parent

MessageDialog

Functions

onHorizontalCursorInput

Description

Event function for horizontal cursor input bound to InputAction.AXIS_PICK_COLOR_LEFTRIGHT.

Definition

onHorizontalCursorInput()

Arguments

any_
anyinputValue

Code

function ColorPickerDialog:onHorizontalCursorInput(_, inputValue)
self.accumHorizontalInput = self.accumHorizontalInput + inputValue
end

onVerticalCursorInput

Description

Event function for vertical cursor input bound to InputAction.AXIS_PICK_COLOR_UPDOWN.

Definition

onVerticalCursorInput()

Arguments

any_
anyinputValue

Code

function ColorPickerDialog:onVerticalCursorInput(_, inputValue)
self.accumVerticalInput = self.accumVerticalInput + inputValue
end

show

Description

Opens a color picker dialog, which allows the player to pick from a selection of colors, or create a custom color and save some favorites.

Definition

show(function callback, table target, table? args, table colors, integer? defaultColorIndex, string? defaultMaterial, table? customColor, boolean? customColorsEnabled, boolean? disableOpenSound, boolean? materialSelectionDisabled)

Arguments

functioncallbackCallback function
tabletargetCallback target
table?argsCallback arguments
tablecolorsTable containing all colors, each color contains the linear sRGB value (value range is 0-1) as well as the material name
integer?defaultColorIndexIndex of the default color, which will be selected in the list. If nil, the first color will be chosen. The index refers to the index of the color in the material manager.
string?defaultMaterialName of the default material, currently glossy, metallic and matte materials are supported, see ColorPickerDialog.MATERIAL_TEXTS for the exact names
table?customColorTable containing the linear sRGB values and material for a custom color. This parameter sets the color in the custom picker and opens that category instead of the list.
boolean?customColorsEnabledIf false, the custom picker and favorites are not shown and only predefined color values can be chosen. Defaults to false
boolean?disableOpenSoundIf true, no sound is played upon opening the dialog
boolean?materialSelectionDisabledIf true, no material can be chosen and glossy material is used as the default

Code

function ColorPickerDialog.show(callback, target, args, colors, defaultColorIndex, defaultMaterial, customColor, customColorsEnabled, disableOpenSound, materialSelectionDisabled)
if ColorPickerDialog.INSTANCE ~ = nil then
local dialog = ColorPickerDialog.INSTANCE

dialog.dialogColors = colors
dialog.dialogDefaultColorIndex = defaultColorIndex
dialog.dialogCustomColor = customColor
dialog.dialogDefaultMaterial = defaultMaterial

dialog:setCustomOptionsEnabled(customColorsEnabled, materialSelectionDisabled)
dialog:setCallback(callback, target, args)
dialog:setDisableOpenSound(disableOpenSound)

g_gui:showDialog( "ColorPickerDialog" )
end
end