-- chat_skins - Logic and data for managing chat skins -- (component of Chat System) -- Template attachment: chat_system -- Created by: Patrick Ferland -- Created on: 05/27/2008 -- Revision History -- 05/27/2008 P.Ferland - New script -- 06/02/2008 P.Ferland - cleanup and documentation -- 06/05/2008 P.Ferland - Imported "pro" default skins -- 06/09/2008 P.Ferland - Multiple changes: -- Separated toolbar skin information into chat_toolbar file; toolbars are "injected" into core skins -- Moved winstyle and button data into each individual skin, allowing (for example) separate winstyle for minimized, normal, and maximized -- 06/13/2008 P.Ferland - Updated for UiAlign fix -- 07/01/2008 P.Ferland - Modified to use stylesheet winstyles -- 07/17/2008 P.Ferland - Suppressed skin messages -- 07/28/2008 P.Ferland - Added drag support (resets drag position when skin changed) -- 07/29/2008 P.Ferland - Replaced "-" with system message colors -- 08/04/2008 P.Ferland - Made default normal size smaller -- 10/02/2008 P.Ferland - Modified to new dual-window layout -- 10/08/2008 P.Ferland - OX friendliness pass -- 10/09/2008 P.Ferland - Production art update -- Constants -- no constants -- Script Properties Define Properties() script_description = 'Chat Skins' script_long_description = 'Change the appearance of chat, and pick what skins are available for users' chat_system_skins = {} chat_system_skin = 'mpdefault' ExposeProperty('chat_system_skin', 'Chat System Skin') PersistProperty('chat_system_skin') chat_system_skin_size = 'normal' ExposeProperty('chat_system_skin_size', 'Chat System Skin Size (min, normal, max)', 'list') PersistProperty('chat_system_skin_size') chat_system_skin_size_list = {'minimized', 'normal', 'maximized'} chat_system_skins_minimized_enabled = 1 ExposeProperty('chat_system_skins_minimized_enabled', 'Enable minimized chat skin?', 'checkbox') PersistProperty('chat_system_skins_minimized_enabled') chat_system_skins_maximized_enabled = 1 ExposeProperty('chat_system_skins_maximized_enabled', 'Enable maximized chat skin?', 'checkbox') PersistProperty('chat_system_skins_maximized_enabled') chat_system_skins_normal_enabled = 1 ExposeProperty('chat_system_skins_normal_enabled', 'Enable normal chat skin?', 'checkbox') PersistProperty('chat_system_skins_normal_enabled') chat_system_skins_player_change = 1 ExposeProperty('chat_system_skins_player_change', 'Allow player to change skin?', 'checkbox') PersistProperty('chat_system_skins_player_change') IncludeScript('11302:12') -- chat utility end -- Commands -- no commands -- Triggers -- System trigger, fired on script attachment (in builder or at world start / object instantiation) Trigger attach() SendTo(self, 'chat_init_skins', 0) -- Register commands SendTo(self, 'chat_system_register_command', 0, 'chatskinlist', 'Display a list of available chat skins', 0, 0) SendTo(self, 'chat_system_register_command', 0, 'chatskin', 'Select \038lt;skin_name\038gt; \038lt;size\038gt; (normal/min/max) with /chatskin \038lt;skin_name\038gt; \038lt;size\038gt;', 2, 0) end -- No detach; chat_skins is a mandatory module Trigger chat_init_skins() -- Load default skins local chat_default_skin = { normal = { winstyle = '11302:60', popup_winstyle = '11302:47', popup_title_color = { r = 0, g = 0, b = 0 }, close_button = { bn = '11302:299', bh = '11302:132', bp = '11302:131', x = -20, y = 1, w = 16, h = 16 }, go_button = { bn = '11302:450', bh = '11302:449', bp = '11302:448', w = 43, h = 21 }, window = { x = 10, y = -10, w = 400, h = 108 }, textfield = { winstyle = '11302:61', icon = { sprite = '11302:499', w = 15, h = 11, x = 3, y = 23 }, x = 10, y = 4, w = 388, h = 16, winheight = 25, win_y = 2, fc = { r = 64, g = 64, b = 64 }, bc = { r = 255, g = 255, b = 255, a = 0.0 }, visible = 1 }, textbox = { x = 5, y = 5, w = 390, h = 97, fc = { r = 255, g = 204, b = 255 }, bc = { r = 64, g = 64, b = 64, a = 0.0 }, visible = 1 } }, minimized = { winstyle = '11302:60', popup_winstyle = '11302:47', popup_title_color = { r = 0, g = 0, b = 0 }, close_button = { bn = '11302:299', bh = '11302:132', bp = '11302:131', x = -20, y = 1, w = 16, h = 16 }, go_button = { bn = '11302:450', bh = '11302:449', bp = '11302:448', w = 43, h = 21 }, window = { x = 10, y = -10, w = 0, h = 0 }, textfield = { winstyle = '11302:61', icon = { sprite = '11302:499', w = 15, h = 11, x = 3, y = 23 }, x = 10, y = 4, w = 388, h = 16, winheight = 25, win_y = 2, fc = { r = 64, g = 64, b = 64 }, bc = { r = 255, g = 255, b = 255, a = 0.0 }, visible = 1 }, textbox = { x = 0, y = 0, w = 0, h = 0, fc = { r = 255, g = 204, b = 255 }, bc = { r = 64, g = 64, b = 64, a = 0.0 }, visible = 0 } }, maximized = { winstyle = '11302:60', popup_winstyle = '11302:47', popup_title_color = { r = 0, g = 0, b = 0 }, close_button = { bn = '11302:299', bh = '11302:132', bp = '11302:131', x = -20, y = 1, w = 16, h = 16 }, go_button = { bn = '11302:450', bh = '11302:449', bp = '11302:448', w = 43, h = 21 }, window = { x = 10, y = -10, w = 400, h = 400 }, textfield = { winstyle = '11302:61', icon = { sprite = '11302:499', w = 15, h = 11, x = 3, y = 23 }, x = 10, y = 4, w = 388, h = 15, winheight = 25, win_y = 2, fc = { r = 64, g = 64, b = 64 }, bc = { r = 255, g = 255, b = 255, a = 0.0 }, visible = 1 }, textbox = { x = 5, y = 5, w = 390, h = 390, fc = { r = 255, g = 204, b = 255 }, bc = { r = 64, g = 64, b = 64, a = 0.0 }, visible = 1 } } } -- Register default skins self.chat_system_skins['mpdefault'] = chat_default_skin SendTo(self, 'chat_system_initialize', 0) end -- Chat command /chatskinlist: List available skins Trigger chat_msg_chatskinlist(sender, message) local skin_message = 'Available chat skins:
' local channel = chat_system_channel_name('user', sender.name) local pre = '' if (self.chat_system_skins_player_change ~= 1) then skin_message = 'Chat skin cannot be changed' else local skin_name = '' for skin_name, _ in pairs(self.chat_system_skins) do skin_message = skin_message .. pre .. skin_name pre = ', ' end end chat_system_send_to_subscribers(self, sender, channel, chat_system_format_system_message(skin_message)) chat_system_set_callback(sender, CHAT_STATUS_CODES.OK, 'OK') end -- Chat command /chatskin: Change current skin Trigger chat_msg_chatskin(sender, message, skin, size) local size_full = size if (size_full == 'min') then size_full = 'minimized' elseif (size_full == 'max') then size_full = 'maximized' end if (self.chat_system_skins_player_change ~= 1) then chat_system_set_callback(sender, CHAT_STATUS_CODES.SYNTAX_ERROR, 'Chat skin cannot be changed') return end if ( (skin == nil) or (skin == '') or (size == nil) or (size == '') ) then chat_system_set_callback(sender, CHAT_STATUS_CODES.SYNTAX_ERROR, 'Missing skin name or size') return end if (self.chat_system_skins[skin] == nil) then chat_system_set_callback(sender, CHAT_STATUS_CODES.SYNTAX_ERROR, 'Skin ' .. skin .. ' not found') return end if (self.chat_system_skins[skin][size_full] == nil) then chat_system_set_callback(sender, CHAT_STATUS_CODES.SYNTAX_ERROR, 'Skin size ' .. size .. ' not found') return end if ( ( (size == 'min') and (self.chat_system_skins_minimized_enabled ~= 1) ) or ( (size == 'normal') and (self.chat_system_skins_normal_enabled ~= 1) ) or ( (size == 'max') and (self.chat_system_skins_maximized_enabled ~= 1) ) ) then chat_system_set_callback(sender, CHAT_STATUS_CODES.INVALID_ARGUMENT_VALUE, 'Skin size ' .. size .. ' not allowed') return end local channel = chat_system_channel_name('user', sender.name) if ( (sender.chat_system_skin ~= skin) or (sender.chat_system_skin_size ~= size_full) ) then sender.chat_system_skin = skin sender.chat_system_skin_size = size_full sender.chat_system_ui_offset.x = 0 sender.chat_system_ui_offset.y = 0 SaveToDb(sender) SendTo(sender, 'chat_system_initialize', 0) else --local message = '- No change to skin' --chat_system_send_to_subscribers(self, sender, channel, message) end chat_system_set_callback(sender, CHAT_STATUS_CODES.OK, 'OK') end -- Local functions -- no functions