-- Player UI Library -- Author: Jeff The Intern -- Revisions -- New Script - 08/01/08 -- Constants PLAYER_TEMPLATE = '0:1' SCRIPT_ID = '13197:23' Define Commands() MakeCommand('ui_library_close_window', 'Close a given window id', 'window_id:int') MakeCommand('ui_library_color_picker_update', 'Update the color picker screen', 'parent_window:int', 'x:int', 'y:int', 'width:int', 'height:int', 'image:string', 'command:string', 'red:int', 'green:int', 'blue:int', 'alpha:int', 'value_name:string', 'value:int') MakeCommand('ui_library_color_picker_complete', 'Complete color picker use', 'command:string', 'window_id:int', 'red:int', 'green:int', 'blue:int', 'alpha:int') MakeCommand('ui_library_checkbox', 'Check/Uncheck a ui checkbox', 'checkbox_id:int', 'command:string', 'value:int') MakeCommand('ui_library_color_picker_imagemap', 'Update the color picker via imagemap', 'parent_window:int', 'x:int', 'y:int', 'width:int', 'height:int', 'image:string', 'command:string', 'alpha:int', 'mouse_x:int', 'mouse_y:int', 'red:int', 'green:int', 'blue:int') end Define Properties() IncludeScript('13197:21') -- ui_library end Command ui_library_close_window(window_id) UiDelete(window_id) SendTo(self, 'ui_library_window_closed', 0, window_id) end Command ui_library_color_picker_imagemap(parent_window, x, y, width, height, image, command, alpha, mouse_x, mouse_y, red, green, blue) local current_value = {red = red, green = green, blue = blue, alpha = alpha} ui_color_picker(parent_window, x, y, width, height, image, command, current_value) end Command ui_library_color_picker_update(parent_window, x, y, width, height, image, command, red, green, blue, alpha, value_name, value) -- Min/Max the color values red = math.min(255, red) red = math.max(0, red) green = math.min(255, green) green = math.max(0, green) blue = math.min(255, blue) blue = math.max(0, blue) alpha = math.min(100, alpha) alpha = math.max(0, alpha) -- Update the text entry fields with new values local color_window = UiFindWindow(parent_window, 'color_window') if(color_window ~= 0) then local red_value = UiFindWindow(color_window, 'red_value') if(red_value ~= 0) then UiText(red_value, red) end local green_value = UiFindWindow(color_window, 'green_value') if(green_value ~= 0) then UiText(green_value, green) end local blue_value = UiFindWindow(color_window, 'blue_value') if(blue_value ~= 0) then UiText(blue_value, blue) end local alpha_value = UiFindWindow(color_window, 'alpha_value') if(alpha_value ~= 0) then UiText(alpha_value, alpha) end end local current_value = {red = red, green = green, blue = blue, alpha = alpha} current_value[value_name] = value ui_color_picker(parent_window, x, y, width, height, image, command, current_value) end Command ui_library_color_picker_complete(command, window_id, red, green, blue, alpha) local command_arguments = string.split(command, ' ') local command_name = command_arguments[1] table.remove(command_arguments, 1) table.insert(command_arguments, tostring(red)) table.insert(command_arguments, tostring(green)) table.insert(command_arguments, tostring(blue)) table.insert(command_arguments, tostring(alpha/100)) DoCommand(self, 'ui_library_close_window', window_id) DoCommand(self, command_name, unpack(command_arguments)) end Command ui_library_checkbox(checkbox_id, command, value) if(value == 1) then value = 0 else value = 1 end -- Parse out command data local command_table = string.split(command, ' ') local command_name = command_table[1] table.remove(command_table, 1) table.insert(command_table, value) -- Run Command DoCommand(self, command_name, unpack(command_table)) ui_checkbox_update(checkbox_id, command, value) end