initial release
This commit is contained in:
295
cosmic rage/worlds/plugins/Config_Option_Changer.xml
Normal file
295
cosmic rage/worlds/plugins/Config_Option_Changer.xml
Normal file
@@ -0,0 +1,295 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!DOCTYPE muclient>
|
||||
|
||||
<muclient>
|
||||
<plugin
|
||||
name="Config_Option_Changer"
|
||||
author="Nick Gammon"
|
||||
id="edb75e5e80221bfb1a83a234"
|
||||
language="Lua"
|
||||
purpose="Changes options not available in GUI configuration"
|
||||
date_written="2010-08-09 10:28:14"
|
||||
date_modified="2010-09-15 13:00"
|
||||
requires="4.50"
|
||||
version="3.0"
|
||||
>
|
||||
<description trim="y">
|
||||
<![CDATA[
|
||||
Type 'config_options' to see dialog of options to change.
|
||||
]]>
|
||||
</description>
|
||||
|
||||
</plugin>
|
||||
|
||||
|
||||
<!-- Aliases -->
|
||||
|
||||
<aliases>
|
||||
<alias
|
||||
script="config_options"
|
||||
match="config_options"
|
||||
enabled="y"
|
||||
sequence="100"
|
||||
>
|
||||
</alias>
|
||||
</aliases>
|
||||
|
||||
<!-- Script -->
|
||||
|
||||
|
||||
<script>
|
||||
<![CDATA[
|
||||
|
||||
-- See: http://www.gammon.com.au/forum/?id=10430
|
||||
|
||||
-- alpha options they can change
|
||||
alpha_options = {
|
||||
editor_window_name = { desc = 'Name of external editor window' },
|
||||
script_editor_argument = { desc = 'External editor argument' },
|
||||
timestamp_input = { desc = 'Timestamp (input)' },
|
||||
timestamp_notes = { desc = 'Timestamp (notes)' },
|
||||
timestamp_output = { desc = 'Timestamp (output)' },
|
||||
} -- end alpha_options
|
||||
|
||||
|
||||
-- boolean options they can change
|
||||
boolean_options = {
|
||||
auto_resize_command_window = { desc = 'Auto-resize command window?' },
|
||||
ctrl_backspace_deletes_last_word = { desc = 'Ctrl+Backspace deletes last word in command window' },
|
||||
default_alias_regexp = { desc = 'New aliases: default to regular expression?' },
|
||||
default_alias_expand_variables = { desc = 'New aliases: default to expand variables?' },
|
||||
default_alias_keep_evaluating = { desc = 'New aliases: default to keep evaluating?' },
|
||||
default_alias_ignore_case = { desc = 'New aliases: default to ignore case?' },
|
||||
default_trigger_regexp = { desc = 'New triggers: default to regular expression?' },
|
||||
default_trigger_expand_variables = { desc = 'New triggers: default to expand variables?' },
|
||||
default_trigger_keep_evaluating = { desc = 'New triggers: default to keep evaluating?' },
|
||||
default_trigger_ignore_case = { desc = 'New triggers: default to ignore case?' },
|
||||
do_not_add_macros_to_command_history = { desc = 'Add macros to command history?' , invert = true },
|
||||
do_not_show_outstanding_lines = { desc = 'Show outstanding lines count?' , invert = true },
|
||||
do_not_translate_iac_to_iac_iac = { desc = 'Translate IAC to IAC IAC?' , invert = true },
|
||||
log_script_errors = { desc = 'Log scripting errors?' },
|
||||
omit_date_from_save_files = { desc = 'Omit the date from world file saves?' },
|
||||
play_sounds_in_background = { desc = 'Play sounds in background?' },
|
||||
send_keep_alives = { desc = 'Send keep-alives?' },
|
||||
wrap_input = { desc = 'Wrap command window at output wrap column' },
|
||||
} -- end boolean_options
|
||||
|
||||
-- numeric options they can change
|
||||
numeric_options = {
|
||||
auto_resize_minimum_lines = { desc = 'Auto-resize: minimum lines', min = 1, max = 100 },
|
||||
auto_resize_maximum_lines = { desc = 'Auto-resize: maximum lines', min = 1, max = 100 },
|
||||
default_alias_send_to = { desc = 'New aliases: Default send-to location', min = 0, max = 14 },
|
||||
default_alias_sequence = { desc = 'New aliases: Default sequence', min = 0, max = 10000 },
|
||||
default_timer_send_to = { desc = 'New timers: Default send-to location', min = 0, max = 14 },
|
||||
default_trigger_send_to = { desc = 'New triggers: Default send-to location', min = 0, max = 14 },
|
||||
default_trigger_sequence = { desc = 'New triggers: Default sequence', min = 0, max = 10000 },
|
||||
fade_output_buffer_after_seconds = { desc = 'Output buffer: Time in seconds before fading lines (0=disable)', min = 0, max = 3600 },
|
||||
fade_output_opacity_percent = { desc = 'Output buffer: Percent opacity to fade to', min = 0, max = 100 },
|
||||
fade_output_seconds = { desc = 'Output buffer: Time to take to fade opacity (seconds)', min = 1, max = 60 },
|
||||
tool_tip_start_time = { desc = 'Tool tips: time before show, in milliseconds', min = 0, max = 120000 },
|
||||
tool_tip_visible_time = { desc = 'Tool tips: time visible, in milliseconds', min = 0, max = 120000 },
|
||||
} -- end numeric_options
|
||||
|
||||
-- colour options they can change
|
||||
colour_options = {
|
||||
timestamp_input_text_colour = { desc = 'Timestamp (input) text colour' },
|
||||
timestamp_notes_text_colour = { desc = 'Timestamp (notes) text colour' },
|
||||
timestamp_output_text_colour = { desc = 'Timestamp (output) text colour' },
|
||||
timestamp_input_back_colour = { desc = 'Timestamp (input) background colour' },
|
||||
timestamp_notes_back_colour = { desc = 'Timestamp (notes) background colour' },
|
||||
timestamp_output_back_colour = { desc = 'Timestamp (output) background colour' },
|
||||
} -- end colour_options
|
||||
|
||||
function edit_boolean_option (name)
|
||||
local val = GetOption (name)
|
||||
local info = boolean_options [name]
|
||||
|
||||
local default = 1 -- default to "Yes" button
|
||||
|
||||
-- if option not set, default to "No" button
|
||||
if (val == 0 and not info.invert) or
|
||||
(val == 1 and info.invert) then
|
||||
default = 2 -- default is "No" button
|
||||
end -- if
|
||||
|
||||
-- what do they *really* want?
|
||||
local response = utils.msgbox (info.desc, "Change option", "yesnocancel", "?", default )
|
||||
|
||||
-- if cancelled dialog, just return
|
||||
if response == "cancel" then
|
||||
return
|
||||
end -- if cancelled
|
||||
|
||||
-- if inverted question, we invert the response meaning
|
||||
local newval = 0
|
||||
|
||||
if info.invert then
|
||||
if response == "no" then
|
||||
newval = 1
|
||||
end -- if
|
||||
else
|
||||
if response == "yes" then
|
||||
newval = 1
|
||||
end -- if
|
||||
end -- if
|
||||
|
||||
-- notify if switched
|
||||
if val ~= newval then
|
||||
SetOption (name, newval)
|
||||
ColourNote ("cyan", "", "Option '" .. info.desc .. "' changed to: " .. response)
|
||||
end -- if
|
||||
|
||||
end -- edit_boolean_option
|
||||
|
||||
function edit_alpha_option (name)
|
||||
local val = GetAlphaOption (name)
|
||||
local info = alpha_options [name]
|
||||
|
||||
local response = utils.inputbox (info.desc, "Change option", val, "Courier", 9)
|
||||
|
||||
-- if cancelled dialog, just return
|
||||
if not response then
|
||||
return
|
||||
end -- cancelled
|
||||
|
||||
-- if value changed, notify them
|
||||
if response ~= val then
|
||||
SetAlphaOption (name, response)
|
||||
ColourNote ("cyan", "", string.format ("Option '%s' changed from '%s' to '%s'", info.desc, val, response))
|
||||
end -- if
|
||||
|
||||
end -- edit_alpha_option
|
||||
|
||||
function edit_numeric_option (name)
|
||||
local val = tonumber (GetOption (name))
|
||||
local info = numeric_options [name]
|
||||
|
||||
local response = utils.inputbox (
|
||||
string.format ("%s\r\n\r\nRange: %i to %i", info.desc, info.min, info.max),
|
||||
"Change option", val, "Courier", 9)
|
||||
|
||||
-- if cancelled dialog, just return
|
||||
if not response then
|
||||
return
|
||||
end -- cancelled
|
||||
|
||||
-- check numeric
|
||||
n = tonumber (response)
|
||||
|
||||
if not n then
|
||||
utils.msgbox ("You must enter a number",
|
||||
"Incorrect input", "ok", "!", 1)
|
||||
return
|
||||
end -- if
|
||||
|
||||
-- check in range
|
||||
if n < info.min or n > info.max then
|
||||
utils.msgbox (info.desc .. " must be in range " ..
|
||||
info.min .. " to " .. info.max,
|
||||
"Incorrect input", "ok", "!", 1)
|
||||
return
|
||||
end -- if
|
||||
|
||||
-- notify them if value changed
|
||||
if n ~= val then
|
||||
SetOption (name, n)
|
||||
ColourNote ("cyan", "", string.format ("Option '%s' changed from %i to %i", info.desc, val, n))
|
||||
end -- if
|
||||
|
||||
end -- edit_numeric_option
|
||||
|
||||
function edit_colour_option (name)
|
||||
local val = tonumber (GetOption (name))
|
||||
local info = colour_options [name]
|
||||
|
||||
local response = PickColour (val)
|
||||
|
||||
-- if cancelled dialog, just return
|
||||
if response == -1 then
|
||||
return
|
||||
end -- cancelled
|
||||
|
||||
-- if value changed, notify them
|
||||
if response ~= val then
|
||||
SetOption (name, response)
|
||||
ColourNote ("cyan", "", string.format ("Option '%s' changed from '%s' to '%s'",
|
||||
info.desc,
|
||||
RGBColourToName (val),
|
||||
RGBColourToName (response)))
|
||||
end -- if
|
||||
|
||||
end -- edit_colour_option
|
||||
|
||||
function config_options (name, line, wildcards)
|
||||
|
||||
repeat
|
||||
local choices = {}
|
||||
|
||||
-- build table of choices, with existing values
|
||||
|
||||
-- alpha
|
||||
for k, v in pairs (alpha_options) do
|
||||
local val = GetAlphaOption (k)
|
||||
if val then
|
||||
choices [k] = string.format ("%s (%s)", v.desc, val)
|
||||
end -- if exists
|
||||
end -- for alpha_options
|
||||
|
||||
-- boolean
|
||||
for k, v in pairs (boolean_options) do
|
||||
local val = GetOption (k)
|
||||
local yes_no = "Yes"
|
||||
if (val == 0 and not v.invert) or
|
||||
(val == 1 and v.invert) then
|
||||
yes_no = "No"
|
||||
end -- if
|
||||
if val then
|
||||
choices [k] = string.format ("%s (%s)", v.desc, yes_no)
|
||||
end -- if exists
|
||||
end -- for boolean_options
|
||||
|
||||
-- numeric
|
||||
for k, v in pairs (numeric_options) do
|
||||
local val = GetOption (k)
|
||||
if val then
|
||||
choices [k] = string.format ("%s (%i)", v.desc, val)
|
||||
end -- if exists
|
||||
end -- for numeric_options
|
||||
|
||||
-- colour
|
||||
for k, v in pairs (colour_options) do
|
||||
local val = GetOption (k)
|
||||
if val then
|
||||
choices [k] = string.format ("%s (%s)", v.desc, RGBColourToName (val))
|
||||
end -- if exists
|
||||
end -- for colour_options
|
||||
|
||||
-- choose one ...
|
||||
local result = utils.listbox (
|
||||
"Choose an option to edit.\r\n\r\nClick Cancel when done (any changes will be retained).",
|
||||
"Options", choices)
|
||||
|
||||
-- if not cancelled, go to appropriate handler
|
||||
if result then
|
||||
if alpha_options [result] then
|
||||
edit_alpha_option (result)
|
||||
elseif boolean_options [result] then
|
||||
edit_boolean_option (result)
|
||||
elseif numeric_options [result] then
|
||||
edit_numeric_option (result)
|
||||
elseif colour_options [result] then
|
||||
edit_colour_option (result)
|
||||
end -- if
|
||||
end -- if they chose something
|
||||
|
||||
until not result -- loop until dialog cancelled
|
||||
|
||||
end -- function config_options
|
||||
|
||||
ColourNote ("cyan", "", "Type 'config_options' to view options dialog.")
|
||||
|
||||
]]>
|
||||
</script>
|
||||
|
||||
|
||||
</muclient>
|
||||
Reference in New Issue
Block a user