-- User Interface Library -- Author: Jeff the Intern -- NOTE: Attach this script to gain access to various UI functions and assets -- Revisions -- 9/12/08 - J.McNab -- New Library Constant using proper coding standard -- Checkbox, Color Picker, Thumbnail Window and List Window Added -- Update of ui_default_window --Constants -- Expose ui_library for access to the internal aspects -- NOTE: This is an older version and should not be used. It ui_library = {winstyle = '13197:3', close = {normal = '13197:83', hover = '13197:82', press = '13197:84'}, accept = {normal = '13197:74', hover = '13197:136', press = '13197:75'}, decline = {normal = '13197:89', hover = '13197:88', press = '13197:90'}, add = {normal = '13197:77', hover = '13197:76', press = '13197:78'}, delete = {normal = '13197:101', hover = '13197:100', press = '13197:102'}, expand = {normal = '13197:104', hover = '13197:103', press = '13197:105'}, collapse = {normal = '13197:86', hover = '13197:137', press = '13197:87'}, lock = {normal = '13197:116', hover = '13197:115', press = '13197:117'}, up = {normal = '13197:132', hover = '13197:131', press = '13197:133'}, down = {normal = '13197:123', hover = '13197:122', press = '13197:124'}, left = {normal = '13197:126', hover = '13197:125', press = '13197:138'}, right = {normal = '13197:129', hover = '13197:128', press = '13197:130'}, thumbnail = '13197:134', add_small = {normal = '13197:141', hover = '13197:140', press = '13197:142'}, minus_small = {normal = '1319:156', hover = '13197:155', press = '13197:55'}, loading = '13197:164', tooltip_winstyle = '13197:4', config = {normal ='13197:184', hover = '13197:183', press = '13197:182'}, rotate_clockwise = {normal = '13197:193', hover = '13197:192', press = '13197:191'}, rotate_counterclockwise = {normal = '13197:189', hover = '13197:190', press = '13197:185'}, empty_box = {normal = '13197:196', hover = '13197:195', press = '13197:196'}, picker_icon = '13197:194'} UI_LIBRARY = {FG_COLOR = {RED = 0, GREEN = 0, BLUE = 0}, BG_COLOR = {RED = 0, GREEN = 0, BLUE = 0, ALPHA = 0}, TITLE = {COLOR = {RED = 0, GREEN = 0, BLUE = 0}, FONT_SIZE = 12}, FONT = {FACE = 'Arial', SIZE = 10, COLOR = {RED = 0, GREEN = 0, BLUE = 0}}, INPUT = {BG_COLOR = {RED = 255, GREEN = 255, BLUE = 255, ALPHA = 1}, EMPTY_BUTTON = '13197:118'}, ------------- -- BUTTONS -- ------------- CLOSE = {NORMAL = '13197:83', HOVER = '13197:82', PRESS = '13197:84', WIDTH = 12, HEIGHT = 12}, UP = {NORMAL = '13197:132', HOVER = '13197:131', PRESS = '13197:133', WIDTH = 16, HEIGHT = 16}, DOWN = {NORMAL = '13197:123', HOVER = '13197:122', PRESS = '13197:124', WIDTH = 16, HEIGHT = 16}, LEFT = {NORMAL = '13197:126', HOVER = '13197:125', PRESS = '13197:138', WIDTH = 16, HEIGHT = 16}, RIGHT = {NORMAL = '13197:129', HOVER = '13197:128', PRESS = '13197:130', WIDTH = 16, HEIGHT = 16}, CHECKBOX = {UNCHECKED = {NORMAL = '13197:196', HOVER = '13197:195', PRESS = '13197:196'}, CHECKED = {NORMAL = '13197:74', HOVER = '13197:136', PRESS = '13197:75'}, WIDTH = 12, HEIGHT = 12}, DELETE = {NORMAL ='13197:89', HOVER = '13197:88', PRESS = '13197:90', WIDTH = 16, HEIGHT = 16}, ACCEPT = {NORMAL = '13197:74', HOVER = '13197:136', PRESS = '13197:75', WIDTH = 16, HEIGHT = 16}, DECLINE = {NORMAL = '13197:89', HOVER = '13197:88', PRESS = '13197:90', WIDTH = 16, HEIGHT = 16}, DONE = {NORMAL = '13197:202', HOVER = '13197:201', PRESS = '13197:197', WIDTH = 42, HEIGHT = 17}, CANCEL = {NORMAL = '13197:199', HOVER = '13197:198', PRESS = '13197:200', WIDTH = 42, HEIGHT = 17}, OKAY = {NORMAL = '13197:205', HOVER = '13197:204', PRESS = '13197:203', WIDTH = 42, HEIGHT = 17}, --------------- -- WINSTYLES -- --------------- WINSTYLE = '13197:3', WINSTYLE_NO_TITLEBAR = '13197:4', WINSTYLE_CLEAN = '13197:6', --------------- -- MISC -- --------------- THUMBNAIL = {ICON = '13197:134', BG_COLOR = {RED = 255, GREEN = 255, BLUE = 255, ALPHA = 0.3}, TOOLTIP = {WIDTH = 100, HEIGHT = 25}}, ICON = {PALETTE = '13197:118'}} Define Properties() ExportConstant('ui_library', 'Old User Interface Library') ExportConstant('UI_LIBRARY', 'User Interface Library') -- UI Draw Functions ExportFunction('ui_confirm_window', 'Create a confirmation window') ExportFunction('ui_tooltip', 'Create a tooltip') ExportFunction('ui_default_window', 'Create a default window') ExportFunction('ui_checkbox', 'Create a functional checkbox') ExportFunction('ui_checkbox_update', 'Update a ui_checkbox element') ExportFunction('ui_combobox', 'Create a combo box') ExportFunction('ui_draw_icon', 'Draw an icon inside of fixed dimensions') ExportFunction('ui_thumbnail_window', 'Draw a thumbnail window with given window data') ExportFunction('ui_list_window', 'Draw a list window with given window data') ExportFunction('ui_color_picker', 'Draw a color picker window') end -- Create a default window function ui_default_window(parent_window, window_name, window_x, window_y, window_width, window_height, titlebar) local winstyle = 0 if(titlebar ~= 1) then winstyle = UI_LIBRARY.WINSTYLE else winstyle = UI_LIBRARY.WINSTYLE_NO_TITLEBAR end local window = UiWindow(parent_window, window_name, window_x, window_y, window_width, window_height, winstyle) UiCapability(window, 'drag') local close_btn = UiImageButton(window, window_name .. '_close_btn', window_width - (6 + UI_LIBRARY.CLOSE.WIDTH), 6, UI_LIBRARY.CLOSE.WIDTH, UI_LIBRARY.CLOSE.HEIGHT, UI_LIBRARY.CLOSE.NORMAL, UI_LIBRARY.CLOSE.HOVER, UI_LIBRARY.CLOSE.PRESS, string.format('ui_library_close_window %d', window)) return window end function ui_confirm_window(parent_window, window_name, window_x, window_y, window_w, window_h, accept_command) if(window_w < 96) then window_w = 96 end if(window_h < 70) then window_h = 70 end local window = ui_default_window(parent_window, window_name, window_x, window_y, window_w, window_h) local accept_button = UiImageButton(window, window_name .. '_accept', window_w/2 - 40, window_h - 40, 32, 32, ui_library.accept.normal, ui_library.accept.hover, ui_library.accept.press, accept_command) local decline_button = UiImageButton(window, window_name .. '_decline', window_w/2 + 8, window_h - 40, 32, 32, ui_library.decline.normal, ui_library.decline.hover, ui_library.decline.press, string.format('ui_library_close_window %d', window)) return window end function ui_tooltip(target, text, delay, hint, self) width = math.max(string.len(text) * 9, 50) local tooltip = UiWindow(0, 'tooltip_' .. target, 0, 0, width, 22, ui_library.tooltip_winstyle) if (self ~= nil) then UiAttachUser(self, tooltip) end local tooltip_text = UiMultiLabel(tooltip, 'tooltip_' .. target .. '_text', 4, -1, width - 8, 28, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2) UiText(tooltip_text, string.format('%s', text)) if(hint ~= 'below' and hint~='above' and hint~='left' and hint~='right') then hint = 'above' end UiVisible(tooltip, 0) UiHoverWindow(target, tooltip, delay, hint) return tooltip end -- Create a ui checkbox -- NOTE: 'value' is the current value. 1 draws a checked checkbox. Otherwise draws an empty checkbox -- NOTE: 'command' is the command to run when the check box is clicked. You must create a redraw of this checkbox when the value changes. function ui_checkbox(window, window_x, window_y, value, command) local current_images = {} if(value ~= 1) then current_images = UI_LIBRARY.CHECKBOX.UNCHECKED else current_images = UI_LIBRARY.CHECKBOX.CHECKED end -- Draw a checkbox element to hold the checkbox local checkbox_element = UiElement(window, 'checkbox_ui', window_x, window_y) -- Create a command that passes the appropriate arguments to the checkbox command in player_ui_library local checkbox_command = string.format('ui_library_checkbox %d \'%s\' %d', checkbox_element, command, value) local checkbox = UiImageButton(checkbox_element, 'checkbox', 0, 0, UI_LIBRARY.CHECKBOX.WIDTH, UI_LIBRARY.CHECKBOX.HEIGHT, current_images.NORMAL, current_images.HOVER, current_images.PRESS, checkbox_command) return checkbox_element end -- Update a ui checkbox function ui_checkbox_update(checkbox_id, command, value) local current_images = {} if(value ~= 1) then current_images = UI_LIBRARY.CHECKBOX.UNCHECKED else current_images = UI_LIBRARY.CHECKBOX.CHECKED end -- Get the checkbox inside of the element and delete it local checkbox = UiFindWindow(checkbox_id, 'checkbox') UiDelete(checkbox) -- Draw a new checkbox local checkbox_command = string.format('ui_library_checkbox %d \'%s\' %d', checkbox_id, command, value) UiImageButton(checkbox_id, 'checkbox', 0, 0, UI_LIBRARY.CHECKBOX.WIDTH, UI_LIBRARY.CHECKBOX.HEIGHT, current_images.NORMAL, current_images.HOVER, current_images.PRESS, checkbox_command) end -- Draw an icon within a set boundary -- NOTE: Used for thumbnails window function ui_draw_icon(window_id, sprite_id, width, height, padding, url_mode) -- Get sprite from stylesheet local icon_sprite = stylesheet.sprites[sprite_id] if(icon_sprite == nil and url_mode ~= 1) then return end local sprite_scale_x = 1 local sprite_scale_y = 1 if(url_mode ~= 1) then if(icon_sprite.scaleX > icon_sprite.scaleY) then sprite_scale_y = icon_sprite.scaleY / icon_sprite.scaleX end if(icon_sprite.scaleY > icon_sprite.scaleX) then sprite_scale_x = icon_sprite.scaleX / icon_sprite.scaleY end end local icon_w = (width - padding * 2) * sprite_scale_x local icon_h = (height - padding * 2) * sprite_scale_y -- Set Icon local icon = 0 if(url_mode ~= 1) then icon = UiImage(window_id, 'icon', width/2 - icon_w/2, height/2 - icon_h/2, icon_w, icon_h, sprite_id) else icon = UiImageRef(window_id, 'icon', width/2 - icon_w/2, height/2 - icon_h/2, icon_w, icon_h, sprite_id) end return icon end function ui_thumbnail_window(parent_window, parent_width, parent_height, rows, cols, window_data, text_mode, url_mode) -- Calculate thumbnail sizing info -- Size of thumbnail -- NOTE: May be a rectangle local thumb_x = parent_width / cols local thumb_y = parent_height / rows -- Local thumbnail number local thumb_num = 0 local thumb_size = math.min(thumb_x, thumb_y) local padding = math.min((thumb_x - thumb_size)/2, (thumb_y - thumb_size)/2) -- Set Defaults if(text_mode == nil) then text_mode = 0 end if(url_mode == nil) then url_mode = 0 end for index, item in pairs(window_data) do if(thumb_num < rows * cols) then -- Calculate thumbnail position local current_row = math.floor(thumb_num / cols) local current_col = thumb_num - (current_row * cols) local pos_x = current_col * thumb_x local pos_y = current_row * thumb_y -- Draw thumbnail local thumbnail_element = UiElement(parent_window, 'thumbnail_' .. index, pos_x, pos_y) local thumbnail_bg = UiImage(thumbnail_element, 'thumbnail_' .. index .. '_icon', thumb_size * .1, thumb_size * .1, thumb_size * .8, thumb_size * .8, UI_LIBRARY.THUMBNAIL.ICON) if(item.bg_color ~= nil) then UiColor(thumbnail_bg, item.bg_color.RED, item.bg_color.GREEN, item.bg_color.BLUE, item.bg_color.ALPHA) end local icon = ui_draw_icon(thumbnail_bg, item.icon, thumb_size * .8, thumb_size * .8, padding + 5, url_mode) -- Tint icon if needed if(item.tint ~= nil) then UiTint(icon, item.tint.red, item.tint.green, item.tint.blue) end -- Add button functionality if(item.command ~= nil) then local icon_btn = UiImageButton(thumbnail_element, 'thumbnail_' .. index .. '_btn', 0, 0, thumb_x, thumb_y, UI_LIBRARY.INPUT.EMPTY_BUTTON, UI_LIBRARY.INPUT.EMPTY_BUTTON, UI_LIBRARY.INPUT.EMPTY_BUTTON, item.command) UiColor(icon_btn, 0, 0, 0, 0) end thumb_num = thumb_num + 1 else Debug("Amount of data fed: %s", #window_data) Debug("Displayable data: %s", rows * cols) Debug("Too much thumbnail info. Feed ui_thumbnail_window less or increase the number of columns and rows") return end end -- Add thumbnails for index, item in pairs(window_data) do local thumbnail_element = UiFindWindow(parent_window, 'thumbnail_' .. index) local tooltip = UiWindow(parent_window, 'thumbnail_tooltip_' .. index, 0, 0, UI_LIBRARY.THUMBNAIL.TOOLTIP.WIDTH, UI_LIBRARY.THUMBNAIL.TOOLTIP.HEIGHT, UI_LIBRARY.WINSTYLE_NO_TITLEBAR) local tooltip_text = UiMultiLabel(tooltip, 'text', 0, 0, UI_LIBRARY.THUMBNAIL.TOOLTIP.WIDTH, UI_LIBRARY.THUMBNAIL.TOOLTIP.HEIGHT, UI_LIBRARY.FONT.COLOR.RED, UI_LIBRARY.FONT.COLOR.GREEN, UI_LIBRARY.FONT.COLOR.BLUE, 0, 0, 0, 0, 0, 0, 2) UiText(tooltip_text, item.name) UiHoverWindow(thumbnail_element, tooltip, 500, 'below') UiVisible(tooltip, 0, 0) end end function ui_list_window(parent_window, parent_width, parent_height, rows, window_data) -- Size of list item local list_y = parent_height / rows -- Local thumbnail number local list_num = 0 local list_icon_size = list_y for index, item in pairs(window_data) do if(list_num < rows) then -- Calculate list item position local pos_x = 0 local pos_y = list_num * list_icon_size -- Draw List Item local list_element = UiElement(parent_window, 'list_' .. index, pos_x, pos_y) local list_icon_bg = UiImage(list_element, 'list_' .. index .. '_icon', list_y * .1, list_y * .1, list_icon_size * .8, list_icon_size * .8, UI_LIBRARY.THUMBNAIL.ICON) if(item.bg_color ~= nil) then UiColor(list_icon_bg, item.bg_color.RED, item.bg_color.GREEN, item.bg_color.BLUE, item.bg_color.ALPHA) end local icon = ui_draw_icon(list_icon_bg, item.icon, list_icon_size * .8, list_icon_size * .8, 5) if(item.description == nil) then item.description = '' end -- List Info if(item.description == '') then local list_info_title = UiMultiLabel(list_element, 'list_' .. index .. '_info', list_y, list_y/2 - 15, parent_width - list_y, 30, UI_LIBRARY.FONT.COLOR.RED, UI_LIBRARY.FONT.COLOR.GREEN, UI_LIBRARY.FONT.COLOR.BLUE, UI_LIBRARY.BG_COLOR.RED, UI_LIBRARY.BG_COLOR.GREEN, UI_LIBRARY.BG_COLOR.BLUE, UI_LIBRARY.BG_COLOR.ALPHA, 0, 0, 0) UiText(list_info_title, string.format('%s', UI_LIBRARY.FONT.FACE, item.name)) else local list_info = UiMultiLabel(list_element, 'list_' .. index .. '_info', list_y, -2, parent_width - list_y, list_y + 3, UI_LIBRARY.FONT.COLOR.RED, UI_LIBRARY.FONT.COLOR.GREEN, UI_LIBRARY.FONT.COLOR.BLUE, UI_LIBRARY.BG_COLOR.RED, UI_LIBRARY.BG_COLOR.GREEN, UI_LIBRARY.BG_COLOR.BLUE, UI_LIBRARY.BG_COLOR.ALPHA, 0, 0, 0) UiText(list_info, string.format('%s
%s
', UI_LIBRARY.FONT.FACE, item.name, UI_LIBRARY.FONT.SIZE, item.description)) end -- Add List btn if(item.command ~= nil) then local list_btn = UiImageButton(list_element, 'list_' .. index .. '_bg', 0, 0, parent_width, list_y, UI_LIBRARY.INPUT.EMPTY_BUTTON, UI_LIBRARY.INPUT.EMPTY_BUTTON, UI_LIBRARY.INPUT.EMPTY_BUTTON, item.command) UiColor(list_btn, 0, 0, 0, 0) end else Debug("Amount of data fed: %s", #window_data) Debug("Displayable date: %s", rows) Debug("Too much list info. Feed ui_list_window less or increase the number of rows") end list_num = list_num + 1 end end function ui_color_picker(parent_window, x, y, width, height, image, command, current_selection) -- Remove the last color picker if one exists local prev_window = UiFindWindow(parent_window, 'color_picker') if(prev_window ~= 0) then UiDelete(prev_window) end -- Calculate window sizes/position local alpha_slider_height = 30 local window_width = width + 12 + 60 local window_height = height + UI_LIBRARY.OKAY.HEIGHT + 42 + alpha_slider_height window_width = math.max(window_width, 100) window_height = math.max(window_height, 200) local pos_x = x - (window_width - width)/2 local pos_y = y - (window_height - height)/2 -- Show Color Values -- Set Defaults local red = 0 local green = 0 local blue = 0 local alpha = 100 if(current_selection.red ~= nil) then red = current_selection.red end if(current_selection.green ~= nil) then green = current_selection.green end if(current_selection.blue ~= nil) then blue = current_selection.blue end if(current_selection.alpha ~= nil) then alpha = current_selection.alpha end -- Main command used by all actions with variances on arguments local slider_command = string.format('ui_library_color_picker_update %d %d %d %d %d %s \'%s\' %d %d %d %d', parent_window, x, y, width, height, image, command, red, green, blue, alpha) -- Create the base window local color_window = ui_default_window(parent_window, 'color_picker', pos_x, pos_y, window_width, window_height) -- Calculate the current right align buffer for various elements local right_align_buffer = UI_LIBRARY.OKAY.WIDTH + 6 -- Add Okay and Cancel buttons local okay_command = string.format('ui_library_color_picker_complete \'%s\' %d %d %d %d %d', command, color_window, red, green, blue, alpha) local cancel_command = string.format('ui_library_close_window %d', color_window) local okay_btn = UiImageButton(color_window, 'okay_btn', window_width - right_align_buffer, window_height - UI_LIBRARY.OKAY.HEIGHT - 6, UI_LIBRARY.OKAY.WIDTH, UI_LIBRARY.OKAY.HEIGHT, UI_LIBRARY.OKAY.NORMAL, UI_LIBRARY.OKAY.HOVER, UI_LIBRARY.OKAY.PRESS, okay_command) right_align_buffer = right_align_buffer + UI_LIBRARY.OKAY.WIDTH + 4 local cancel_btn = UiImageButton(color_window, 'cancel_btn', window_width - right_align_buffer, window_height - UI_LIBRARY.CANCEL.HEIGHT - 6, UI_LIBRARY.CANCEL.WIDTH, UI_LIBRARY.CANCEL.HEIGHT, UI_LIBRARY.CANCEL.NORMAL, UI_LIBRARY.CANCEL.HOVER, UI_LIBRARY.CANCEL.PRESS, cancel_command) -- Alpha Slider -- Draw the actual slider local alpha_slider_element = UiElement(color_window, 'alpha_element', 6, window_height - UI_LIBRARY.OKAY.HEIGHT - 4 - alpha_slider_height) right_align_buffer = window_width - 41 -- Draw a text field for text input of the value and display of current value local alpha_value = UiTextField(alpha_slider_element, 'alpha_value', right_align_buffer, alpha_slider_height/2 - 15/2, 22, 15, UI_LIBRARY.FONT.COLOR.RED, UI_LIBRARY.FONT.COLOR.GREEN, UI_LIBRARY.FONT.COLOR.BLUE, UI_LIBRARY.INPUT.BG_COLOR.RED, UI_LIBRARY.INPUT.BG_COLOR.GREEN, UI_LIBRARY.INPUT.BG_COLOR.BLUE, UI_LIBRARY.INPUT.BG_COLOR.ALPHA, string.format('%s alpha', slider_command), alpha) right_align_buffer = right_align_buffer - 12 local alpha_slider = UiSlider(alpha_slider_element, 'alpha_slider', 6, 0, right_align_buffer, alpha_slider_height, 0, 100, 1, 10, string.format('%s alpha', slider_command), alpha) -- Draw the minimum label local alpha_min = UiMultiLabel(alpha_slider, 'alpha_slider_min', -3, -5, 20, 20, UI_LIBRARY.FONT.COLOR.RED, UI_LIBRARY.FONT.COLOR.GREEN, UI_LIBRARY.FONT.COLOR.BLUE, UI_LIBRARY.BG_COLOR.RED, UI_LIBRARY.BG_COLOR.GREEN, UI_LIBRARY.BG_COLOR.BLUE, UI_LIBRARY.BG_COLOR.ALPHA, 0, 0, 0) UiText(alpha_min, string.format('%s', UI_LIBRARY.FONT.SIZE, UI_LIBRARY.FONT.FACE, '0')) -- Draw the maximum label local alpha_max = UiMultiLabel(alpha_slider, 'alpha_slider_max', window_width - 79, -5, 30, 20, UI_LIBRARY.FONT.COLOR.RED, UI_LIBRARY.FONT.COLOR.GREEN, UI_LIBRARY.FONT.COLOR.BLUE, UI_LIBRARY.BG_COLOR.RED, UI_LIBRARY.BG_COLOR.GREEN, UI_LIBRARY.BG_COLOR.BLUE, UI_LIBRARY.BG_COLOR.ALPHA, 0, 0, 1) -- Draw the slider title label UiText(alpha_max, string.format('%s', UI_LIBRARY.FONT.SIZE, UI_LIBRARY.FONT.FACE, '100')) local alpha_label = UiMultiLabel(alpha_slider, 'alpha_slider_label', (window_width - 101)/2 - 7, -7, 60, 20, UI_LIBRARY.FONT.COLOR.RED, UI_LIBRARY.FONT.COLOR.GREEN, UI_LIBRARY.FONT.COLOR.BLUE, UI_LIBRARY.BG_COLOR.RED, UI_LIBRARY.BG_COLOR.GREEN, UI_LIBRARY.BG_COLOR.BLUE, UI_LIBRARY.BG_COLOR.ALPHA, 0, 0, 2) UiText(alpha_label, string.format('%s', UI_LIBRARY.FONT.SIZE, UI_LIBRARY.FONT.FACE, 'Alpha')) local red_label = UiMultiLabel(color_window, 'red_label', window_width - 56, 30, 40, 25, UI_LIBRARY.FONT.COLOR.RED, UI_LIBRARY.FONT.COLOR.GREEN, UI_LIBRARY.FONT.COLOR.BLUE, UI_LIBRARY.BG_COLOR.RED, UI_LIBRARY.BG_COLOR.GREEN, UI_LIBRARY.BG_COLOR.BLUE, UI_LIBRARY.BG_COLOR.ALPHA, 0, 0, 0) UiText(red_label, string.format('%s', UI_LIBRARY.FONT.SIZE, UI_LIBRARY.FONT.FACE, 'Red')) local red_value = UiTextField(color_window, 'red_value', window_width - 50, 50, 32, 15, UI_LIBRARY.FONT.COLOR.RED, UI_LIBRARY.FONT.COLOR.GREEN, UI_LIBRARY.FONT.COLOR.BLUE, UI_LIBRARY.INPUT.BG_COLOR.RED, UI_LIBRARY.INPUT.BG_COLOR.GREEN, UI_LIBRARY.INPUT.BG_COLOR.BLUE, UI_LIBRARY.INPUT.BG_COLOR.ALPHA, string.format('%s red', slider_command), red) local green_label = UiMultiLabel(color_window, 'green_label', window_width - 56, 70, 40, 25, UI_LIBRARY.FONT.COLOR.RED, UI_LIBRARY.FONT.COLOR.GREEN, UI_LIBRARY.FONT.COLOR.BLUE, UI_LIBRARY.BG_COLOR.RED, UI_LIBRARY.BG_COLOR.GREEN, UI_LIBRARY.BG_COLOR.BLUE, UI_LIBRARY.BG_COLOR.ALPHA, 0, 0, 0) UiText(green_label, string.format('%s', UI_LIBRARY.FONT.SIZE, UI_LIBRARY.FONT.FACE, 'Green')) local green_value = UiTextField(color_window, 'green_value', window_width - 50, 90, 32, 15, UI_LIBRARY.FONT.COLOR.RED, UI_LIBRARY.FONT.COLOR.GREEN, UI_LIBRARY.FONT.COLOR.BLUE, UI_LIBRARY.INPUT.BG_COLOR.RED, UI_LIBRARY.INPUT.BG_COLOR.GREEN, UI_LIBRARY.INPUT.BG_COLOR.BLUE, UI_LIBRARY.INPUT.BG_COLOR.ALPHA, string.format('%s green', slider_command), green) local blue_label = UiMultiLabel(color_window, 'blue_label', window_width - 56, 110, 40, 25, UI_LIBRARY.FONT.COLOR.RED, UI_LIBRARY.FONT.COLOR.GREEN, UI_LIBRARY.FONT.COLOR.BLUE, UI_LIBRARY.BG_COLOR.RED, UI_LIBRARY.BG_COLOR.GREEN, UI_LIBRARY.BG_COLOR.BLUE, UI_LIBRARY.BG_COLOR.ALPHA, 0, 0, 0) UiText(blue_label, string.format('%s', UI_LIBRARY.FONT.SIZE, UI_LIBRARY.FONT.FACE, 'Blue')) local blue_value = UiTextField(color_window, 'blue_value', window_width - 50, 130, 32, 15, UI_LIBRARY.FONT.COLOR.RED, UI_LIBRARY.FONT.COLOR.GREEN, UI_LIBRARY.FONT.COLOR.BLUE, UI_LIBRARY.INPUT.BG_COLOR.RED, UI_LIBRARY.INPUT.BG_COLOR.GREEN, UI_LIBRARY.INPUT.BG_COLOR.BLUE, UI_LIBRARY.INPUT.BG_COLOR.ALPHA, string.format('%s blue', slider_command), blue) local swatch_size = window_width - width - 12 local color_swatch = UiRect(color_window, 'color_swatch', window_width - swatch_size - 6, 150, swatch_size, swatch_size) UiColor(color_swatch, red, green, blue, 1) -- Add color palette picker local color_palette_command = string.format('ui_library_color_picker_imagemap %d %d %d %d %d %s \'%s\' %d', parent_window, x, y, width, height, image, command, alpha) local color_palette = UiImageMap(color_window, 'color_picker_palette', 6, 30, width, height, image, 0, color_palette_command) end