Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="iso-8859-1"?>
- <!DOCTYPE muclient>
- <!-- Bits of this plugin and ideas were borrowed and remixed from the MUSHclient community. http://www.gammon.com.au/forum/?id=9385 and others. -->
- <!-- Original script by Fiendish with help from Orogan, modified for LotJ by Johnson -->
- <!-- Further modified chat windows scripts for use with LotJ space combat by Xaleron -->
- <muclient>
- <plugin
- name="LotJ_ShipSpam_Miniwindow"
- author="Fiendish"
- id="96ce07ef668c1258781d6b59"
- language="Lua"
- purpose="Move certain space messages to a miniwindow"
- date_written="2010-10-25"
- requires="4.73"
- version="2.0"
- save_state="y"
- >
- <description trim="y">
- USAGE:
- shipspam show : show shipspam window
- shipspam hide : hide shipspam window
- resetshipspam : return shipspam window to default settings
- Left-click a line to copy it to the clipboard
- Left-click-and-drag title bar to move window
- Right-click window to see menu of options
- </description>
- </plugin>
- <triggers>
- --- Begin space combat grabs
- <trigger enabled="n" name="turbos" match="Turbolaser fire*" regexp="n" omit_from_output="n" script="untagged_info" sequence="100" />
- <trigger enabled="n" name="lasers" match="Laserfire*" regexp="n" omit_from_output="n" script="untagged_info" sequence="100" />
- <trigger enabled="n" name="ions" match="An Ion blast*" regexp="n" omit_from_output="n" script="untagged_info" sequence="100" />
- <trigger enabled="n" name="missiles" match="*fires a missile*" regexp="n" omit_from_output="n" script="untagged_info" sequence="100" />
- <trigger enabled="n" name="torpedos" match="*fires a torpedo*" regexp="n" omit_from_output="n" script="untagged_info" sequence="100" />
- <trigger enabled="n" name="rockets" match="*fires a heavy rocket*" regexp="n" omit_from_output="n" script="untagged_info" sequence="100" />
- <trigger enabled="n" name="pulses" match="*fires a pulse*" regexp="n" omit_from_output="n" script="untagged_info" sequence="100" />
- <trigger enabled="n" name="tractors" match="*white tractorbeam*" regexp="n" omit_from_output="n" script="untagged_info" sequence="100" />
- <!-- begin OOC chat grabs - commented out, not needed - Xaleron
- <trigger enabled="n" name="immchat" match="( IMM | CHAT )*" regexp="n" omit_from_output="n" script="untagged_info" sequence="100" />
- <trigger enabled="n" name="rpcchat" match="(R|P|C)*" regexp="n" omit_from_output="n" script="untagged_info" sequence="100" />
- <trigger enabled="n" name="ooc" match="(OOC) *" regexp="n" omit_from_output="n" script="untagged_info" sequence="100" />
- <trigger enabled="n" name="newbie" match="(NEWBIE) *" regexp="n" omit_from_output="n" script="untagged_info" sequence="100" />
- <trigger enabled="n" name="immooc" match="(IMM) *" regexp="n" omit_from_output="n" script="untagged_info" sequence="100" />
- <trigger enabled="n" name="rpcooc" match="(RPC) *" regexp="n" omit_from_output="n" script="untagged_info" sequence="100" />
- <trigger enabled="n" name="immnet" match="ImmNet[*]*" regexp="n" omit_from_output="n" script="untagged_info" sequence="100" />
- <trigger enabled="n" name="councilnet" match="CouncilNet[*]*" regexp="n" omit_from_output="n" script="untagged_info" sequence="100" />
- -->
- -- blank line gag
- <trigger enabled="n" match="^$" regexp="y" name="end_gag" group="end_gag" omit_from_output="y" sequence="100" send_to="12" >
- <send>EnableTriggerGroup("end_gag", false)</send></trigger>
- </triggers>
- <aliases>
- <alias match="resetshipspam" enabled="y" sequence="100" ignore_case="y" script="reset_shipspam" />
- <alias script="shipspam_show" match="shipspam show" enabled="y" sequence="100" ignore_case="y" />
- <alias script="shipspam_hide" match="shipspam hide" enabled="y" sequence="100" ignore_case="y" />
- </aliases>
- <script>
- <![CDATA[
- require "movewindow" -- load the movewindow.lua module
- require "copytable"
- SCROLL_BAR_WIDTH = 15
- MAX_LINES = 10000 -- how many lines to store in scrollback
- -- date_format = "[%d %b %H:%M:%S] " -- [30 Aug 13:29:49] date and time 24 hour
- -- date_format = "[%d %b %I:%M:%S%p] " -- [30 Aug 01:20:12PM] date and time 12 hour
- -- date_format = "[%H:%M:%S] " -- [13:29:08] time 24 hour
- -- date_format = "[%X] " -- [1:22:06 PM] time 12 hour
- default_width = 657
- default_height = 131
- default_x = 0
- default_y = 0
- date_format = GetVariable("date_format") or "[%d %b %H:%M:%S] "
- width = tonumber(GetVariable("WINDOW_WIDTH")) or default_width
- height = tonumber(GetVariable("WINDOW_HEIGHT")) or default_height
- log_to_file = tonumber(GetVariable("log_to_file")) or 0
- log_colour_codes = tonumber(GetVariable("log_colour_codes")) or 1
- log_timestamps = tonumber(GetVariable("log_timestamps")) or 1
- function sanitize_filename(str)
- str = string.gsub(str, "[^%w%s()_-]", "")
- return Trim(str)
- end
- log_filename = GetVariable("log_filename") or (GetInfo(58):gsub("^.\\",GetInfo(56))..sanitize_filename(GetInfo(2)).."ChatLog.txt")
- -- colours
- WINDOW_BACKGROUND_COLOUR = GetNormalColour(1)
- WINDOW_TEXT_COLOUR = 0xffffff
- SCROLL_BACKGROUND_COLOUR = 0xE8E8E8
- SCROLL_BAR_COLOUR = 0x111111
- SCROLL_DETAIL_COLOUR = 0x000000
- WINDOW_BORDER_COLOUR = 0xE8E8E8
- -- offset of text from edge
- TEXT_INSET = 5
- -- where to store the chat line
- lines = {} -- table of recent chat lines
- rawlines = {}
- lineStart = ""
- lineEnd = ""
- WINDOW_LINES = ""
- WINDOW_NAME = GetVariable("WINDOW_NAME") or "ShipSpam Log"
- -- functions for handling Aardwolf color codes
- dofile(GetPluginInfo(GetPluginID(), 20) .. "lotj_colors.lua")
- font_height = ""
- line_height = ""
- windowinfo = ""
- startx = ""
- starty = ""
- show_turbos = tonumber(GetVariable("show_turbos")) or 1
- show_lasers = tonumber(GetVariable("show_lasers")) or 1
- show_ions = tonumber(GetVariable("show_ions")) or 1
- show_missiles = tonumber(GetVariable("show_missiles")) or 1
- show_torpedos = tonumber(GetVariable("show_torpedos")) or 1
- show_rockets = tonumber(GetVariable("show_rockets")) or 1
- show_pulses = tonumber(GetVariable("show_pulses")) or 1
- show_tractors = tonumber(GetVariable("show_tractors")) or 1
- turbos_echo = tonumber(GetVariable("turbos_echo")) or 1
- lasers_echo = tonumber(GetVariable("lasers_echo")) or 1
- ions_echo = tonumber(GetVariable("ions_echo")) or 1
- missiles_echo = tonumber(GetVariable("missiles_echo")) or 1
- torpedos_echo = tonumber(GetVariable("torpedos_echo")) or 1
- rockets_echo = tonumber(GetVariable("rockets_echo")) or 1
- pulses_echo = tonumber(GetVariable("pulses_echo")) or 1
- tractors_echo = tonumber(GetVariable("tractors_echo")) or 0
- SetTriggerOption("turbos", "enabled", show_turbos)
- SetTriggerOption("lasers", "enabled", show_lasers)
- SetTriggerOption("ions", "enabled", show_ions)
- SetTriggerOption("missiles", "enabled", show_missiles)
- SetTriggerOption("torpedos", "enabled", show_torpedos)
- SetTriggerOption("rockets", "enabled", show_rockets)
- SetTriggerOption("pulses", "enabled", show_pulses)
- SetTriggerOption("tractors", "enabled", show_tractors)
- SetTriggerOption("turbos", "omit_from_output", turbos_echo)
- SetTriggerOption("lasers", "omit_from_output", lasers_echo)
- SetTriggerOption("ions", "omit_from_output", ions_echo)
- SetTriggerOption("missiles", "omit_from_output", missiles_echo)
- SetTriggerOption("torpedos", "omit_from_output", torpedos_echo)
- SetTriggerOption("rockets", "omit_from_output", rockets_echo)
- SetTriggerOption("pulses", "omit_from_output", pulses_echo)
- SetTriggerOption("tractors", "omit_from_output", tractors_echo)
- function reset_shipspam()
- width = default_width
- height = default_height
- font_name = default_font_name
- font_size = default_font_size
- windowinfo.window_left = default_x
- windowinfo.window_top = default_y
- WindowPosition(win, default_x, default_y, 0, 18)
- Repaint() -- hack because WindowPosition doesn't immediately update coordinates
- OnPluginSaveState()
- OnPluginInstall()
- end
- function ResizeMoveCallback ()
- posx, posy = WindowInfo(win, 17), WindowInfo(win, 18)
- width = width+posx-startx
- startx = posx
- -- if (WindowTextWidth(win, win_font, "WWWCOMMUNICATION")+2*SCROLL_BAR_WIDTH > width) then
- if (WindowTextWidth(win, win_font, WINDOW_NAME)+2*SCROLL_BAR_WIDTH > width) then
- -- width = WindowTextWidth(win, win_font, "WWWCOMMUNICATION")+2*SCROLL_BAR_WIDTH
- width = WindowTextWidth(win, win_font, WINDOW_NAME)+2*SCROLL_BAR_WIDTH
- startx = windowinfo.window_left+width
- elseif (windowinfo.window_left+width > GetInfo(281)) then
- width = GetInfo(281)-windowinfo.window_left
- startx = GetInfo(281)
- end
- height = height+posy-starty
- starty=posy
- if (3*SCROLL_BAR_WIDTH+10+line_height+TITLE_HEIGHT > height) then
- height = 3*SCROLL_BAR_WIDTH+10+line_height+TITLE_HEIGHT
- starty = windowinfo.window_top+height
- elseif (windowinfo.window_top+height > GetInfo(280)) then
- height = GetInfo(280)-windowinfo.window_top
- starty = GetInfo(280)
- end
- if (utils.timer() - lastRefresh > 0.0333) then
- init(false)
- lastRefresh = utils.timer()
- end
- end
- lastRefresh = 0
- function ResizeReleaseCallback ()
- height = TITLE_HEIGHT+(line_height*(WINDOW_LINES-1))+3 -- snap height down to not have dead space after last line
- init(true) -- true here causes old lines to re-wrap at the new size
- end
- win = GetPluginID()
- require "checkplugin"
- function OnPluginListChanged ()
- do_plugin_check_now ("e2a1af0b5e462318bb423764", "lotj_repaint_buffer") -- check we have the repaint buffer
- end -- OnPluginListChanged
- function OnPluginInstall ()
- -- Dummy window to get font characteristics
- check(WindowCreate(win, 0, 0, 1, 1, 0, 0, WINDOW_BACKGROUND_COLOUR))
- local fonts = utils.getfontfamilies ()
- -- if not there already, add it
- if not fonts.Dina then
- AddFont(GetInfo (66) .. "\\Dina.fon")
- fonts = utils.getfontfamilies()
- end -- if Dina not installed
- if fonts["Dina"] then
- default_font_size = 8
- default_font_name = "Dina"
- elseif fonts ["Courier New"] then
- default_font_size = 9
- default_font_name = "Courier New" -- the actual font
- else
- default_font_size = 9
- default_font_name = "Lucida Console"
- end -- if
- font_name = GetVariable("font_name") or default_font_name
- font_size = tonumber(GetVariable("font_size")) or default_font_size
- header_font_name = font_name
- header_font_size = font_size
- win_font = "font"..win
- win_head_font = "fonthead"..win
- check(WindowFont(win, win_font, font_name, font_size))
- check(WindowFont(win, win_head_font, header_font_name, header_font_size))
- font_height = WindowFontInfo(win, win_font, 1) - WindowFontInfo(win, win_font, 4) + 1
- header_font_height = WindowFontInfo(win, win_head_font, 1) - WindowFontInfo(win, win_head_font, 4) + 1
- TITLE_HEIGHT = header_font_height*1.8
- line_height = font_height+1
- -- install the window movement handler, get back the window position
- windowinfo = movewindow.install(win, miniwin.pos_top_right, miniwin.create_absolute_location, false, nil, {mouseup=MouseUp, mousedown=LeftClickOnly, dragmove=LeftClickOnly, dragrelease=LeftClickOnly},{x=default_x, y=default_y})
- init(true)
- -- if disabled last time, stay disabled
- if GetVariable ("enabled") == "false" then
- ColourNote ("yellow", "", "Warning: Plugin " .. GetPluginName ().. " is currently disabled.")
- check (EnablePlugin(GetPluginID (), false))
- return
- else
- OnPluginEnable() -- do initialization stuff
- end-- they didn't enable us last time
- end
- function init (firstTime)
- -- how many lines and columns will fit?
- WINDOW_LINES = math.ceil((height-TITLE_HEIGHT)/line_height)
- if (firstTime == true) then
- WindowCreate(win, windowinfo.window_left, windowinfo.window_top, width, height, windowinfo.window_mode, windowinfo.window_flags, WINDOW_BACKGROUND_COLOUR)
- -- catch for right-click menu and line selection
- WindowAddHotspot(win, "textarea", 1, TITLE_HEIGHT, width-SCROLL_BAR_WIDTH-1,height-3, "", "", "MouseDown", "CancelMouseDown", "MouseUp", "", 2, 0)
- WindowDragHandler(win, "textarea", "TextareaMoveCallback", "TextareaReleaseCallback", 0x10)
- -- mouse wheel handler for scrolling up/down
- WindowScrollwheelHandler(win, "textarea", "wheel_move")
- -- add the drag handler so they can move the window around
- movewindow.add_drag_handler(win, 0, 0, 0, TITLE_HEIGHT)
- -- scroll bar up/down buttons
- WindowAddHotspot(win, "up", width-SCROLL_BAR_WIDTH, TITLE_HEIGHT, 0, TITLE_HEIGHT+SCROLL_BAR_WIDTH, "MouseOver", "CancelMouseOver", "MouseDown", "CancelMouseDown", "MouseUp", "", 1, 0)
- WindowAddHotspot(win, "down", width-SCROLL_BAR_WIDTH, height-(2*SCROLL_BAR_WIDTH), 0, height-SCROLL_BAR_WIDTH, "MouseOver", "CancelMouseOver", "MouseDown", "CancelMouseDown", "MouseUp", "", 1, 0)
- -- add the resize widget hotspot
- WindowAddHotspot(win, "resize", width-SCROLL_BAR_WIDTH, height-SCROLL_BAR_WIDTH, width, height, "MouseOver", "CancelMouseOver", "MouseDown", "CancelMouseDown", "MouseUp", "", 6, 0)
- WindowDragHandler(win, "resize", "ResizeMoveCallback", "ResizeReleaseCallback", 0)
- -- re-wrap buffered lines at the new size
- lines = {}
- for _,styles in ipairs(rawlines) do
- fillBuffer(styles[1],styles[2])
- end
- --CallPlugin("462b665ecb569efbf261422f", "registerMiniwindow", win) -- fail silently
- else
- WindowResize(win, width, height, WINDOW_BACKGROUND_COLOUR)
- WindowMoveHotspot(win, "textarea", 0, TITLE_HEIGHT, width-SCROLL_BAR_WIDTH-1, height-3)
- WindowMoveHotspot(win, "up", width-SCROLL_BAR_WIDTH, TITLE_HEIGHT, 0, TITLE_HEIGHT+SCROLL_BAR_WIDTH)
- WindowMoveHotspot(win, "down", width-SCROLL_BAR_WIDTH, height-(2*SCROLL_BAR_WIDTH), 0, height-SCROLL_BAR_WIDTH)
- WindowMoveHotspot(win, "resize", width-SCROLL_BAR_WIDTH, height-SCROLL_BAR_WIDTH, width, 0)
- end
- WindowShow(win, true)
- lineStart = math.max(1, #lines-WINDOW_LINES+2)
- lineEnd = math.max(1, #lines)
- -- title rectangle
- -- header_width = WindowTextWidth(win, win_head_font, "Communication Log")
- header_width = WindowTextWidth(win, win_head_font, WINDOW_NAME)
- WindowGradient(win, 1, 0, width, TITLE_HEIGHT, WINDOW_BACKGROUND_COLOUR, 0x444444, 2)
- -- WindowText(win, win_head_font, "Communication Log", (width-header_width)/2, ((TITLE_HEIGHT-header_font_height)/2)-1, width, TITLE_HEIGHT, 0xEEEEEE, false)
- WindowText(win, win_head_font, WINDOW_NAME, (width-header_width)/2, ((TITLE_HEIGHT-header_font_height)/2)-1, width, TITLE_HEIGHT, 0xEEEEEE, false)
- WindowLine(win, 0, TITLE_HEIGHT-1, width, TITLE_HEIGHT-1, WINDOW_BORDER_COLOUR, 0 + 0x0200, 1)
- -- resize tag
- WindowRectOp(win, 2, width-SCROLL_BAR_WIDTH, height-SCROLL_BAR_WIDTH, 0, 0, SCROLL_BACKGROUND_COLOUR) -- resizer background
- WindowLine(win, width-SCROLL_BAR_WIDTH+1, height-2, width-2, height-SCROLL_BAR_WIDTH+1, 0xffffff, 0, 2)
- WindowLine(win, width-SCROLL_BAR_WIDTH+2, height-2, width-2, height-SCROLL_BAR_WIDTH+2, 0x696969, 0, 1)
- WindowLine(win, width-SCROLL_BAR_WIDTH+4, height-2, width-2, height-SCROLL_BAR_WIDTH+4, 0xffffff, 0, 2)
- WindowLine(win, width-SCROLL_BAR_WIDTH+5, height-2, width-2, height-SCROLL_BAR_WIDTH+5, 0x696969, 0, 1)
- WindowLine(win, width-SCROLL_BAR_WIDTH+7, height-2, width-2, height-SCROLL_BAR_WIDTH+7, 0xffffff, 0, 2)
- WindowLine(win, width-SCROLL_BAR_WIDTH+8, height-2, width-2, height-SCROLL_BAR_WIDTH+8, 0x696969, 0, 1)
- WindowLine(win, width-SCROLL_BAR_WIDTH+10, height-2, width-2, height-SCROLL_BAR_WIDTH+10, 0xffffff, 0, 2)
- WindowLine(win, width-SCROLL_BAR_WIDTH+11, height-2, width-2, height-SCROLL_BAR_WIDTH+11, 0x696969, 0, 1)
- -- draw border
- WindowRectOp(win, 1, 0, 0, 0, 0, WINDOW_BORDER_COLOUR)
- drawStuff()
- end
- function OnPluginConnect ()
- end -- OnPluginConnect
- function OnPluginClose ()
- -- if enabled
- if GetPluginInfo(GetPluginID(), 17) then
- OnPluginDisable()
- end -- if enabled
- WindowDelete(win)
- end -- OnPluginClose
- function OnPluginEnable ()
- WindowShow(win, true)
- -- if we are connected when the plugin loads, it must have been reloaded while playing
- if IsConnected() then
- OnPluginConnect()
- end -- if already connected
- OnPluginSaveState()
- end -- OnPluginEnable
- require "serialize"
- function OnPluginSaveState()
- -- save window current location for next time
- SetVariable("enabled", tostring (GetPluginInfo (GetPluginID(), 17)))
- movewindow.save_state(win)
- SetVariable("font_name", font_name)
- SetVariable("font_size", font_size)
- SetVariable("date_format", date_format)
- SetVariable("WINDOW_WIDTH", width)
- SetVariable("WINDOW_HEIGHT", height)
- SetVariable("WINDOW_NAME", WINDOW_NAME)
- SetVariable("show_turbos", show_turbos)
- SetVariable("show_lasers", show_lasers)
- SetVariable("show_ions", show_ions)
- SetVariable("show_missiles", show_missiles)
- SetVariable("show_torpedos", show_torpedos)
- SetVariable("show_rockets", show_rockets)
- SetVariable("show_pulses", show_pulses)
- SetVariable("show_tractors", show_tractors)
- SetVariable("turbos_echo", turbos_echo)
- SetVariable("lasers_echo", lasers_echo)
- SetVariable("ions_echo", ions_echo)
- SetVariable("missiles_echo", missiles_echo)
- SetVariable("torpedos_echo", torpedos_echo)
- SetVariable("rockets_echo", rockets_echo)
- SetVariable("pulses_echo", pulses_echo)
- SetVariable("tractors_echo", tractors_echo)
- SetVariable("log_to_file", log_to_file)
- SetVariable("log_filename", log_filename)
- SetVariable("log_colour_codes", log_colour_codes)
- SetVariable("log_timestamps", log_timestamps)
- --SetVariable("show_donations", show_donations)
- SetVariable("channels_table", serialize.save("channels_table"))
- end -- OnPluginSaveState
- function OnPluginDisable()
- WindowShow( win, false )
- --UnloadPlugin("55616ea13339bc68e963e1f8")
- OnPluginSaveState()
- end -- OnPluginDisable
- -- display one line
- function Display_Line (line, styles, backfill_start, backfill_end)
- local left = TEXT_INSET
- local top = TITLE_HEIGHT+(line*line_height)
- if (backfill_start ~= nil and backfill_end ~= nil) then
- WindowRectOp(win, 2, backfill_start, top+1, backfill_end, top+line_height+1, 0x444444)
- end -- backfill
- if styles then
- for _, v in ipairs(styles) do
- local t = v.text
- -- now clean up dangling newlines that cause block characters to show
- if string.sub(v.text,-1) == "\n" then
- t = string.sub(v.text,1,-2)
- end
- left = left + WindowText(win, win_font, t, left, top, width-SCROLL_BAR_WIDTH, 0, v.textcolour)
- end -- for each style run
- end
- end -- Display_Line
- -- Returns an array {start, end, text}
- function findURLs(text)
- local URLs = {}
- local start, position = 0, 0
- -- "rex" is a table supplied by MUSHclient for PCRE functionality.
- local re = rex.new("(?:https?://|mailto:)\\S*[\\w/=@#\\-\\?]")
- re:gmatch(text,
- function (link, _)
- start, position = string.find(text, link, position, true)
- table.insert(URLs, {start=start, stop=position, text=link})
- end
- )
- return URLs
- end -- function findURL
- -- display all visible lines
- hyperlinks = {}
- function writeLines ()
- WindowRectOp(win, 2, 1, TITLE_HEIGHT, width-SCROLL_BAR_WIDTH, -1, WINDOW_BACKGROUND_COLOUR) -- clear
- local ax = nil
- local zx = nil
- local line_no_colors = ""
- if #lines >= 1 then
- for count = lineStart, lineEnd do
- ax = nil
- zx = nil
- line_no_colors = strip_colours(StylesToColoursOneLine(lines[count][1]))
- -- create clickable links for urls
- for i,v in ipairs(lines[count][3]) do
- local left = TEXT_INSET+WindowTextWidth(win, win_font, string.sub(line_no_colors, 1, v.start-1))
- local right = left+WindowTextWidth(win, win_font, string.sub(line_no_colors, v.start-1, v.stop-1))
- local top = TITLE_HEIGHT+((count-lineStart)*line_height)-1
- local bottom = top+line_height+1
- local link_name = table.concat({v.text," ",count,v.start,v.stop})
- if not WindowHotspotInfo(win, link_name, 1) then
- hyperlinks[link_name] = v.text
- WindowAddHotspot(win, link_name, left, top, math.min(right, width-SCROLL_BAR_WIDTH-1), bottom, "MouseOverLink", "CancelMouseOverLink", "MouseDown", "CancelMouseDown", "MouseUp", "Right-click this URL if you want to open it:\n"..v.text, 1)
- WindowDragHandler(win, link_name, "TextareaMoveCallback", "TextareaReleaseCallback", 0x10)
- WindowScrollwheelHandler(win, link_name, "wheel_move")
- end
- end
- -- create highlighting parameters when text is selected
- if copy_start_line ~= nil and copy_end_line ~= nil and count >= copy_start_line and count <= copy_end_line then
- ax = (((count == copy_start_line) and math.min(start_copying_x, WindowTextWidth(win, win_font, line_no_colors)+TEXT_INSET)) or TEXT_INSET)
- -- end of highlight for this line
- zx = math.min(width-SCROLL_BAR_WIDTH,(((count == copy_end_line) and math.min(end_copying_x, WindowTextWidth(win, win_font, line_no_colors)+TEXT_INSET)) or WindowTextWidth(win, win_font, line_no_colors)+TEXT_INSET))
- end
- Display_Line( count-lineStart, lines[count][1], ax, zx )
- end
- end
- BroadcastPlugin(999, "repaint")
- end
- barPos = ""
- barSize = ""
- totalSteps = ""
- function drawStuff ()
- -- Scrollbar base
- WindowRectOp(win, 2, width-SCROLL_BAR_WIDTH, TITLE_HEIGHT, width, -SCROLL_BAR_WIDTH, SCROLL_BACKGROUND_COLOUR) -- scroll bar background
- WindowRectOp(win, 1, width-SCROLL_BAR_WIDTH+1, SCROLL_BAR_WIDTH+TITLE_HEIGHT+1, width-1, height-(2*SCROLL_BAR_WIDTH)-1, SCROLL_DETAIL_COLOUR) -- scroll bar background inset rectangle
- if (keepscrolling == "up") then
- -- draw top scroll button pressed
- WindowRectOp(win, 5, (width-SCROLL_BAR_WIDTH), TITLE_HEIGHT, 0, TITLE_HEIGHT+SCROLL_BAR_WIDTH, 10, 15 + 0x800) -- up arrow pushed
- points = string.format("%i,%i,%i,%i,%i,%i", (width-SCROLL_BAR_WIDTH)+3, TITLE_HEIGHT+9,(width-SCROLL_BAR_WIDTH)+7, TITLE_HEIGHT+5,(width-SCROLL_BAR_WIDTH)+11, TITLE_HEIGHT+9)
- WindowPolygon(win, points,
- 0x000000, 0, 1, -- pen (solid, width 1)
- 0x000000, 0, -- brush (solid)
- true, -- close
- false) -- alt fill
- else
- -- draw top scroll button unpressed
- WindowRectOp(win, 5, (width-SCROLL_BAR_WIDTH), TITLE_HEIGHT, width, TITLE_HEIGHT+SCROLL_BAR_WIDTH, 5, 15 + 0x800)
- points = string.format("%i,%i,%i,%i,%i,%i", (width-SCROLL_BAR_WIDTH)+3, TITLE_HEIGHT+9,(width-SCROLL_BAR_WIDTH)+7, TITLE_HEIGHT+5,(width-SCROLL_BAR_WIDTH)+11, TITLE_HEIGHT+9)
- WindowPolygon(win, points,
- 0x000000, 0, 1, -- pen (solid, width 1)
- 0x000000, 0, --brush (solid)
- true, --close
- false) --alt fill
- end
- if (keepscrolling == "down") then
- -- draw bottom scroll button pressed
- WindowRectOp(win, 5, (width-SCROLL_BAR_WIDTH), height-(SCROLL_BAR_WIDTH*2), 0, height-SCROLL_BAR_WIDTH-1, 10, 15 + 0x800)
- points = string.format("%i,%i,%i,%i,%i,%i", (width-SCROLL_BAR_WIDTH)+3, (height-SCROLL_BAR_WIDTH)-11,(width-SCROLL_BAR_WIDTH)+7, (height-SCROLL_BAR_WIDTH)-7, (width-SCROLL_BAR_WIDTH)+11,(height-SCROLL_BAR_WIDTH)-11)
- WindowPolygon(win, points,
- 0x000000, 0, 1, -- pen (solid, width 1)
- 0x000000, 0, -- brush (solid)
- true, -- close
- false) -- alt fill
- else
- -- draw bottom scroll button unpressed
- WindowRectOp(win, 5, (width-SCROLL_BAR_WIDTH), height-(SCROLL_BAR_WIDTH*2), width, height-SCROLL_BAR_WIDTH, 5, 15 + 0x800)
- points = string.format("%i,%i,%i,%i,%i,%i", (width-SCROLL_BAR_WIDTH)+3, (height-SCROLL_BAR_WIDTH)-11,(width-SCROLL_BAR_WIDTH)+7, (height-SCROLL_BAR_WIDTH)-7, (width-SCROLL_BAR_WIDTH)+11,(height-SCROLL_BAR_WIDTH)-11)
- WindowPolygon(win, points,
- 0x000000, 0, 1, -- pen (solid, width 1)
- 0x000000, 0, --brush (solid)
- true, --close
- false) --alt fill
- end
- -- The scrollbar position indicator
- totalSteps = #lines
- if (totalSteps <= WINDOW_LINES-1) then
- totalSteps = 1
- end
- SCROLL_BAR_HEIGHT = (height-(3*SCROLL_BAR_WIDTH)-TITLE_HEIGHT)
- if (not dragscrolling) then
- stepNum = lineStart-1
- barPos = SCROLL_BAR_WIDTH +TITLE_HEIGHT+ ((SCROLL_BAR_HEIGHT/totalSteps) * stepNum)
- barSize = (SCROLL_BAR_HEIGHT/math.max(WINDOW_LINES-1,totalSteps)) * (WINDOW_LINES-1)
- if barSize < 10 then
- barSize = 10
- end
- if barPos+barSize > SCROLL_BAR_WIDTH+TITLE_HEIGHT+SCROLL_BAR_HEIGHT then
- barPos = SCROLL_BAR_WIDTH+TITLE_HEIGHT+SCROLL_BAR_HEIGHT - barSize
- end
- WindowAddHotspot(win, "scroller", (width-SCROLL_BAR_WIDTH), barPos, width, barPos+barSize, "MouseOver", "CancelMouseOver", "MouseDown", "CancelMouseDown", "MouseUp", "", 1, 0)
- WindowDragHandler(win, "scroller", "ScrollerMoveCallback", "ScrollerReleaseCallback", 0)
- end
- WindowRectOp(win, 5, (width-SCROLL_BAR_WIDTH), barPos, width, barPos+barSize, 5, 15 + 0x800) -- scrollbar position indicator
- -- reset hyperlinks if the text moves
- for k,v in pairs(hyperlinks) do
- WindowDeleteHotspot(win, k)
- end
- hyperlinks = {}
- writeLines()
- end
- function wheel_move (flags, hotspot_id)
- if bit.band(flags, 0x100) ~= 0 then
- if lineStart < #lines-WINDOW_LINES+2 then
- -- down
- lineStart = math.max(1, math.min(#lines-WINDOW_LINES+2, lineStart+3))
- lineEnd = math.min(#lines, lineStart+WINDOW_LINES-2)
- drawStuff()
- end
- elseif lineStart > 1 then
- -- up
- lineStart = math.max(1, lineStart-3)
- lineEnd = math.min(#lines, lineStart+WINDOW_LINES-2)
- drawStuff()
- end -- if
- end -- wheel_move
- function ScrollerMoveCallback(flags, hotspot_id)
- mouseposy = WindowInfo(win, 18)
- windowtop = WindowInfo(win, 2)
- barPos = math.max(mouseposy-windowtop+clickdelta, SCROLL_BAR_WIDTH+TITLE_HEIGHT)
- if barPos > height-(SCROLL_BAR_WIDTH*2)-barSize then
- barPos = height-(SCROLL_BAR_WIDTH*2)-barSize
- lineStart = math.max(1,#lines-WINDOW_LINES+2)
- lineEnd = #lines
- else
- lineStart = math.max(1,math.floor((barPos-SCROLL_BAR_WIDTH-TITLE_HEIGHT)/(SCROLL_BAR_HEIGHT/totalSteps)+1))
- lineEnd = math.min(lineStart + WINDOW_LINES-2, #lines)
- end
- drawStuff()
- end
- function ScrollerReleaseCallback(flags, hotspot_id)
- dragscrolling = false
- drawStuff()
- end
- function add_line ( line, is_beginning_of_message, urls )
- -- add new line
- table.insert(lines, {[1]=line, [2]=is_beginning_of_message, [3]=urls} )
- -- advance the count
- if #lines >= WINDOW_LINES then
- lineStart = lineStart + 1
- end -- if
- if #lines > 1 then
- lineEnd = lineEnd + 1
- end -- if
- end -- add_line
- function fillBuffer(rawstyles, rawurls)
- local avail = width - (TEXT_INSET * 2) - 9
- local line_styles = {}
- local beginning = true
- local length = 0
- local styles = copytable.deep(rawstyles)
- local urls = copytable.deep(rawurls)
- -- It turns out you can reduce the function
- -- call time by instantiating functions as local.
- -- This is really just me being silly.
- local remove = table.remove
- local insert = table.insert
- -- Keep pulling out styles and trying to fit them on the current line
- while #styles > 0 do
- -- break off the next style
- local style = remove(styles, 1)
- -- make this handle forced newlines like in the flickoff social
- -- by splitting off and sticking the next part back into the
- -- styles list for the next pass
- foundbreak = false
- newline = string.find(style.text, "\n")
- if newline then
- insert(styles, 1, {text = string.sub(style.text,newline+1),
- length = style.length-newline+1,
- textcolour = style.textcolour,
- backcolour = style.backcolour}
- )
- -- we're leaving in the newline characters here because we need to be
- -- able to copy them later. I'll clean up the buggy visual later when
- -- actually displaying the lines.
- style.length = newline
- style.text = string.sub(style.text,1,newline)
- foundbreak = true
- end
- local text_width = WindowTextWidth(win, win_font, style.text)
- -- if it fits, copy whole style in
- if text_width <= avail then
- insert(line_styles, style)
- length = length + style.length
- avail = avail - text_width
- if foundbreak then
- avail = 0
- end
- else -- otherwise, have to split style
- -- look for trailing space (work backwards). remember where space is
- local col = style.length - 1
- local split_col
- -- keep going until out of columns
- while col > 1 do
- text_width = WindowTextWidth(win, win_font, style.text:sub(1, col))
- if text_width <= avail then
- if not split_col then
- split_col = col -- in case no space found, this is where we can split
- end -- if
- -- see if space here
- if style.text:sub(col, col) == " " then
- split_col = col
- break
- end -- if space
- end -- if will now fit
- col = col - 1
- end -- while
- if split_col then
- -- if we found a place to split, use old style and truncate it.
- -- Also stick the rest back with the same styling back into the styles list
- insert(line_styles, style)
- local style_copy = copytable.shallow(style)
- style.text = style.text:sub(1, split_col)
- style.length = split_col
- style_copy.text = style_copy.text:sub(split_col + 1)
- style_copy.length = #style_copy.text
- insert(styles, 1, style_copy)
- length = length + style.length
- elseif next(line_styles) == nil then
- -- Actually, I don't think this can ever happen. -Fiendish
- insert(line_styles, style)
- length = length + style.length
- else
- -- if we're about to start a new style and the
- -- line is completely full, put it back in the list for later
- insert(styles, 1, style)
- end -- if
- avail = 0 -- now we need to wrap
- end -- if could/not fit whole thing in
- -- out of styles or out of room? add a line for what we have so far
- if #styles == 0 or avail <= 0 then
- if #lines >= MAX_LINES then
- -- if the history buffer is full then remove the oldest line
- remove(lines, 1)
- lineStart = lineStart - 1
- lineEnd = lineEnd - 1
- end -- buffer full
- local line_urls = {}
- while urls[1] and urls[1].stop <= length do
- insert(line_urls, remove(urls, 1))
- end
- if urls[1] and urls[1].start < length then
- local url = copytable.deep(urls[1])
- url.stop = length + 1
- urls[1].stop = urls[1].stop-1
- urls[1].old = true
- insert(line_urls, url)
- end
- for i,v in ipairs(urls) do
- urls[i].start = urls[i].start - length
- urls[i].stop = urls[i].stop - length
- if urls[i].start <= 1 then
- urls[i].start = 1
- urls[i].stop = urls[i].stop+1
- end
- end
- add_line( line_styles, beginning, line_urls )
- avail = width - (TEXT_INSET * 2) - 9
- line_styles = {}
- length = 0
- beginning = false
- end -- line full
- end -- while we still have styles over
- end
- function stampAndStore(styles)
- local text = ""
- local log_text = ""
- -- inject timestamp if wanted
- tstamp = os.date(date_format)
- timestyle = {text=tstamp, length=string.len(tstamp), textcolour=0xc0c0c0}
- table.insert(styles,1,timestyle)
- text = StylesToColoursOneLine(styles)
- if (log_to_file == 1) then
- if (log_timestamps == 0) then
- local local_styles = copytable.deep(styles)
- table.remove(local_styles, 1)
- log_text = StylesToColoursOneLine(local_styles)
- else
- log_text = text
- end
- if (log_colour_codes == 0) then
- log_text = strip_colours(log_text)
- end
- --local f = assert(io.open (GetInfo(58):gsub("^.\\",GetInfo(56))..sanitize_filename(GetInfo(2)).."ChatLog.txt", "a+")) -- handle to chat log file
- local f = assert(io.open (log_filename, "a+")) -- handle to chat log file
- f:write(log_text.."\n") -- write to it
- f:close() -- close that file now
- end
- local urls = findURLs(strip_colours(text))
- -- store the raw lines for use during resizing
- if #rawlines >= MAX_LINES then
- table.remove(rawlines, 1)
- end
- table.insert(rawlines, {[1]=styles, [2]=urls})
- fillBuffer(styles, urls)
- drawStuff()
- end
- -- Takes input as a string with embedded LotJ color codes. Use via CallPlugin().
- -- See: http://mushclient.com/scripts/doc.php?function=CallPlugin
- -- You can use the function StylesToColoursOneLine(styles_table) from aardwolf_colors.lua
- -- or manually embed your own colors to push any colorized line you want to the log window.
- -- Example: CallPlugin("b555825a4a5700c35fa80780","storeFromOutside","HELLO&RHello&Mhello&x215hello&x66HELLO")
- function storeFromOutside(string)
- stampAndStore(ColoursToStyles(string))
- end
- function untagged_info (name, line, wildcards, styles)
- stampAndStore(styles)
- if turbos_echo == 1 and name=="turbos" then
- EnableTrigger("end_gag", true)
- end
- if lasers_echo == 1 and name=="lasers" then
- EnableTrigger("end_gag", true)
- end
- if ions_echo == 1 and name=="ions" then
- EnableTrigger("end_gag", true)
- end
- if missiles_echo == 1 and name=="missiles" then
- EnableTrigger("end_gag", true)
- end
- if torpedos_echo == 1 and name=="torpedos" then
- EnableTrigger("end_gag", true)
- end
- if rockets_echo == 1 and name=="rockets" then
- EnableTrigger("end_gag", true)
- end
- if pulses_echo == 1 and name=="pulses" then
- EnableTrigger("end_gag", true)
- end
- if tractors_echo == 1 and name=="tractors" then
- EnableTrigger("end_gag", true)
- end
- end -- untagged info
- function OnPluginBroadcast (msg, id, name, text)
- -- Look for GMCP handler.
- --if (id == '3e7dedbe37e44942dd46d264') then
- -- if (text == "comm.channel") then
- -- res, gmcparg = CallPlugin("3e7dedbe37e44942dd46d264","gmcpval","comm.channel")
- -- luastmt = "gmcpdata = " .. gmcparg
- -- assert (loadstring (luastmt or ""))()
- -- msg = gmcpval("msg") or ""
- -- chan = gmcpval("chan") or ""
- -- if (show_donations == 1 or string.match(strip_colours(msg), "^CLAN ANNOUNCEMENT: %a+ has donated") == nil) then
- -- if not channels_table[chan] then
- -- addNewChannel(chan)
- -- end
- -- if channels_table[chan]["capture"] then
- -- stampAndStore(ColoursToStyles(msg))
- -- end
- -- end
- -- end
- --elseif (id == "462b665ecb569efbf261422f" and msg==996 and text == "re-register z") then
- -- CallPlugin("462b665ecb569efbf261422f", "registerMiniwindow", win)
- --end
- end
- keepscrolling = ""
- require "wait"
- function scrollbar()
- wait.make(
- function()
- while keepscrolling == "up" or keepscrolling == "down" do
- if keepscrolling == "up" then
- if (lineStart > 1) then
- lineStart = lineStart - 1
- lineEnd = lineEnd - 1
- else
- keepscrolling = ""
- end
- elseif keepscrolling == "down" then
- if (lineEnd < #lines) then
- lineStart = lineStart + 1
- lineEnd = lineEnd + 1
- else
- keepscrolling = ""
- end
- end
- wait.time(0.1)
- drawStuff()
- end
- end
- )
- end
- function GetAllBufferedMessages()
- local t = {}
- for _,styles in ipairs(rawlines) do
- table.insert(t, StylesToColoursOneLine(styles[1]))
- end
- SetClipboard(table.concat(t,"\n"))
- end
- function MouseOver(flags, hotspot_id)
- keepscrolling = ""
- end
- function CancelMouseOver(flags, hotspot_id)
- keepscrolling = ""
- end
- function MouseOverLink(flags, hotspot_id)
- local url = string.gsub(hotspot_id, "(.* ).*", "%1")
- local hotspots = WindowHotspotList(win)
- for _, v in ipairs (hotspots) do
- if string.find(v, url, 1, true) then
- local left = WindowHotspotInfo(win, v, 1)
- local right = WindowHotspotInfo(win, v, 3)
- local bottom = WindowHotspotInfo(win, v, 4)
- WindowLine(win, left, bottom, right, bottom, 0xffffff, 256, 1);
- end
- end
- BroadcastPlugin(999, "repaint")
- end
- function CancelMouseOverLink(flags, hotspot_id)
- local url = string.gsub(hotspot_id, "(.* ).*", "%1")
- if not string.find(WindowInfo(win, 19), url, 1, true) then
- writeLines()
- end
- end
- temp_start_copying_x = 0
- start_copying_y = 0
- copied_text = ""
- function MouseDown(flags, hotspot_id)
- if (hotspot_id == "resize") then
- startx, starty = WindowInfo (win, 17), WindowInfo (win, 18)
- elseif (hotspot_id == "scroller") then
- clickdelta = WindowHotspotInfo(win, "scroller", 2)-WindowInfo (win, 15)
- dragscrolling = true
- elseif (hotspot_id == "up" or hotspot_id == "down") then
- keepscrolling = hotspot_id
- scrollbar()
- elseif (flags == 0x10) then
- temp_start_copying_x = WindowInfo(win, 14)
- start_copying_y = WindowInfo(win, 15)
- copy_start_windowline = math.floor((start_copying_y-TITLE_HEIGHT)/line_height)
- temp_start_line = copy_start_windowline+lineStart
- copied_text = ""
- copy_start_line = nil
- copy_end_line = nil
- writeLines()
- end
- end
- function CancelMouseDown(flags, hotspot_id)
- keepscrolling = ""
- drawStuff()
- end
- end_copying_x = 0
- end_copying_y = 0
- function MouseUp(flags, hotspot_id)
- if bit.band (flags, miniwin.hotspot_got_rh_mouse) ~= 0 then
- right_click_menu(hotspot_id)
- else
- drawStuff()
- end
- keepscrolling = ""
- return true
- end
- function TextareaMoveCallback(flags, hotspot_id)
- if bit.band (flags, miniwin.hotspot_got_lh_mouse) ~= 0 then -- only on left mouse button
- copied_text = ""
- end_copying_x = WindowInfo(win, 17)-WindowInfo(win, 1)
- end_copying_y = WindowInfo(win, 18)-WindowInfo(win, 2)
- local ypos = end_copying_y
- end_copying_x = math.max(TEXT_INSET,math.min(end_copying_x, width-SCROLL_BAR_WIDTH))
- end_copying_y = math.max(TITLE_HEIGHT+1,math.min(end_copying_y, TITLE_HEIGHT-1+(line_height*(WINDOW_LINES-1))))
- copy_end_windowline = math.floor((end_copying_y-TITLE_HEIGHT)/line_height)
- copy_end_line = copy_end_windowline+lineStart
- copy_start_line = temp_start_line
- start_copying_x = temp_start_copying_x
- if not copy_start_line then
- -- OS bug causing errors for me. hack around stupid mouse click tracking mess
- return
- end
- if (copy_start_line > #lines) then
- start_copying_x = width-SCROLL_BAR_WIDTH
- end
- -- the user is selecting backwards, so reverse the start/end orders
- if copy_end_line < temp_start_line then
- local temp = copy_end_line
- copy_end_line = copy_start_line
- copy_start_line = temp
- temp = end_copying_x
- end_copying_x = start_copying_x
- start_copying_x = temp
- end -- if
- if copy_end_line == copy_start_line and end_copying_x < start_copying_x then
- local temp = end_copying_x
- end_copying_x = start_copying_x
- start_copying_x = temp
- end -- if
- for copy_line=copy_start_line,copy_end_line do
- if (lines[copy_line] ~= nil) then
- local startpos = 1
- local endpos = 99999
- if (copy_line-lineStart+1 > 0 and copy_line-lineStart < WINDOW_LINES and copy_line-lineStart < #lines) then
- -- snap to character boundaries instead of selecting arbitrary pixel widths
- local line_no_colors = strip_colours(StylesToColoursOneLine(lines[copy_line][1]))
- startpos = 1
- endpos = #line_no_colors
- -- special deal for the first line
- if copy_line == copy_start_line then
- for pos=1,#line_no_colors do
- startpos = pos
- if WindowTextWidth(win, win_font, string.sub(line_no_colors,1,pos)) > start_copying_x then
- start_copying_x = WindowTextWidth(win, win_font, string.sub(line_no_colors,1,pos-1))+TEXT_INSET
- break
- end
- end
- end
- -- special deal for the last line
- if copy_line == copy_end_line then
- local found = false
- endpos = 0
- for pos=1,#line_no_colors do
- if WindowTextWidth(win, win_font, string.sub(line_no_colors,1,pos)) > end_copying_x then
- end_copying_x = WindowTextWidth(win, win_font, string.sub(line_no_colors,1,endpos))+TEXT_INSET
- found = true
- break
- end
- endpos = pos
- end
- end
- end -- if should show highlight
- -- store selected area for later
- copied_part = StylesToColoursOneLine(lines[copy_line][1], startpos, endpos)
- if copy_line ~= copy_end_line and copy_line ~= #lines and lines[copy_line+1][2] == true then
- -- only put a line break if the next line is from a different message
- copied_part = copied_part.."&w\n"
- elseif copy_line == copy_end_line or copy_line == #lines then
- -- tack a white code on to the very end
- copied_part = copied_part.."&w"
- end
- copied_text = copied_text..(((copied_part ~= nil) and copied_part) or "")
- end -- if valid line
- end -- for
- if ypos < TITLE_HEIGHT then
- keepscrolling = "up"
- scrollbar()
- elseif ypos > height then
- keepscrolling = "down"
- scrollbar()
- else
- keepscrolling = ""
- writeLines()
- end
- end -- if left mouse button
- end -- function TextareaMoveCallback
- function TextareaReleaseCallback(flags, hotspot_id)
- copy_start_line = math.min(#lines, copy_start_line or 0)
- copy_end_line = math.min(#lines, copy_end_line or 0)
- end
- function LeftClickOnly(flags, hotspot_id, win)
- if bit.band (flags, miniwin.hotspot_got_rh_mouse) ~= 0 then
- return true
- end
- return false
- end
- function shipspam_show (name, line, wildcards)
- WindowShow( win, true )
- ColourNote ("yellow", "", "ShipSpam window now shown. Type 'shipspam hide' to hide it.")
- end -- function shipspam_show
- function shipspam_hide (name, line, wildcards)
- WindowShow( win, false )
- ColourNote ("yellow", "", "ShipSpam window now hidden. Type 'shipspam show' to see it again.")
- end -- function shipspam_hide
- require "pairsbykeys"
- --local init_channel_names = {"advice","answer","auction","barter","claninfo","clantalk","curse","debate","dtell","ftalk","gametalk","gclan","gossip","gratz","gsocial","gtell","helper","immtalk","lasertag","ltalk","market","mobsay","music","mxit","newbie","nobletalk","pchat","pokerinfo","ptell","question","quote","racetalk","rauction","rp","say","sports","spouse","tech","tell","tiertalk","trivia","wangrp","wardrums"}
- local init_channel_names = {"Turbos","Lasers","Ions","Missiles","Rockets","Pulses","Tractors"}
- channels_table = {}
- loadstring(GetVariable("channels_table") or "")()
- function addNewChannel(name)
- if not channels_table[name] then
- channels_table[name] = {capture=true}
- end
- end
- function constructDefaultChannels()
- for i,v in ipairs(init_channel_names) do
- addNewChannel(v)
- end
- end
- constructDefaultChannels()
- -- right click menu
- function right_click_menu (hotspot_id)
- hotspots = {scroller=true, resize=true, down=true, up=true, textarea=true}
- menustring ="!"
- local hyperlink_skip = 0
- local echo_skip = 0
- local url = ""
- if (WindowInfo(win, 15) > TITLE_HEIGHT) and not hotspots[hotspot_id] then
- hyperlink_skip = 2
- menustring = menustring.."Go to URL: "..hyperlinks[hotspot_id].."|Copy URL to Clipboard|-|"
- url = hyperlinks[hotspot_id]
- end
- menustring = menustring.."Copy Selected Without Colors|Copy Selected|Copy All|-|Rename Window|Change Font"
- menustring = menustring .. "|>Timestamp|"..((date_format=="" and "+") or "").."No Timestamps|"..((date_format=="[%d %b %H:%M:%S] " and "+") or "").."30 Aug 13:29:49|"..((date_format=="[%d %b %I:%M:%S%p] " and "+") or "").."30 Aug 01:20:12PM|"..((date_format=="[%H:%M:%S] " and "+") or "").."13:29:08|"..((date_format=="[%I:%M:%S%p] " and "+") or "").."1:22:06 PM|<|-"
- menustring = menustring .. "|>Capture Spam Types|"..
- ((show_turbos==1 and "+") or "")..
- "Turbolasers|"..
- ((show_lasers==1 and "+") or "")..
- "Lasers|"..
- ((show_ions==1 and "+") or "")..
- "Ions|"..
- ((show_missiles==1 and "+") or "")..
- "Missiles|"..
- ((show_torpedos==1 and "+") or "")..
- "Torpedos|"..
- ((show_rockets==1 and "+") or "")..
- "Rockets|"..
- ((show_pulses==1 and "+") or "")..
- "Pulses|"..
- ((show_tractors==1 and "+") or "")..
- "Tractorbeams|"..
- "<"
- menustring = menustring .. "|>Echo Spam Types in Main Window|"..
- ((turbos_echo==0 and "+") or "").. "Turbolasers|"..
- ((lasers_echo==0 and "+") or "").. "Lasers|"..
- ((ions_echo==0 and "+") or "").. "Ions|"..
- ((missiles_echo==0 and "+") or "").. "Missiles|"..
- ((torpedos_echo==0 and "+") or "").. "Torpedos|"..
- ((rockets_echo==0 and "+") or "").. "Rockets|"..
- ((pulses_echo==0 and "+") or "").. "Pulses|"..
- ((tractors_echo==0 and "+") or "").. "Tractorbeams|"..
- "<|-"
- -- if (IsPluginInstalled("55616ea13339bc68e963e1f8")) then
- -- info_echo = not GetPluginTriggerInfo ("55616ea13339bc68e963e1f8", "info", 8)
- -- remort_auction_echo = not GetPluginTriggerInfo ("55616ea13339bc68e963e1f8", "remort_auction", 8)
- -- pray_echo = not GetPluginTriggerInfo("55616ea13339bc68e963e1f8", "pray", 8)
- -- warfare_echo = not GetPluginTriggerInfo("55616ea13339bc68e963e1f8", "warfare", 8)
- -- global_quest_echo = not GetPluginTriggerInfo ("55616ea13339bc68e963e1f8", "global_quest", 8)
- -- donations_echo = not GetPluginTriggerInfo ("55616ea13339bc68e963e1f8", "donations", 8)
- -- menustring = menustring .. "|>Echo Channels In Main Window|Echo All|Echo None|Custom Echo List|-|>Echo Other Info|"..((info_echo and "+") or "").."INFO:|"..((global_quest_echo and "+") or "").."Global Quest:|"..((remort_auction_echo and "+") or "").."Remort Auction:|"..((donations_echo and "+") or "").."Clan Donations|"..((pray_echo and "+") or "").."Pray|"..((warfare_echo and "+") or "").."WARFARE:|".."<|<"
- -- echo_skip = 9
- -- end
- --menustring = menustring .. "|>Logging To File|"..((log_to_file==1 and "Disable|") or "Enable|")..((log_colour_codes==0 and "+") or "").."Remove Color Codes|"..((log_timestamps==0 and "+") or "").."Remove Timestamps|<|-|Bring To Front|Send To Back"
- menustring = menustring .. "|>Logging To File|"..
- ((log_to_file==1 and "Disable|") or "Enable|")..
- "Choose log file|"..
- ((log_colour_codes==0 and "+") or "")..
- "Remove Color Codes|"..
- ((log_timestamps==0 and "+") or "")..
- "Remove Timestamps|<|-"
- result = WindowMenu (win,
- WindowInfo (win, 14), -- x position
- WindowInfo (win, 15), -- y position
- menustring) -- content
- if result ~= "" then
- numResult = tonumber(result)
- if numResult == hyperlink_skip-1 then
- local res = OpenBrowser(url)
- if res ~= 0 then
- SetClipboard(url)
- ColourNote("yellow", "red", "MUSHclient may have encountered an error trying to open the selected URL. It has been copied to the clipboard.")
- ColourNote("cyan","","v-------------------Copied to clipboard-------------------v")
- ColourNote("yellow","",url)
- ColourNote("cyan","","^---------------------------------------------------------^")
- end
- elseif numResult == hyperlink_skip then
- SetClipboard(url)
- ColourNote("cyan","","v-------------------Copied to clipboard-------------------v")
- ColourNote("yellow","",url)
- ColourNote("cyan","","^---------------------------------------------------------^")
- elseif numResult == 1+hyperlink_skip then
- if #copied_text > 0 then
- local declored_text = strip_colours(copied_text)
- SetClipboard(declored_text)
- ColourNote("cyan","","v-------------------Copied to clipboard-------------------v")
- ColourNote("yellow","",declored_text)
- ColourNote("cyan","","^---------------------------------------------------------^")
- end
- elseif numResult == 2+hyperlink_skip then
- if #copied_text > 0 then
- SetClipboard(copied_text)
- ColourNote("cyan","","v-------------------Copied to clipboard-------------------v")
- ColourNote("yellow","",copied_text)
- ColourNote("cyan","","^---------------------------------------------------------^")
- end
- elseif numResult == 3+hyperlink_skip then
- GetAllBufferedMessages()
- ColourNote ("yellow", "", "All chat messages copied to clipboard.")
- elseif numResult == 4+hyperlink_skip then
- wanted_name = utils.inputbox("Choose a new name for this window:", "Window name", WINDOW_NAME, GetVariable("font_name"), GetVariable("font_size"))
- if wanted_name then
- WINDOW_NAME = wanted_name
- SetVariable("WINDOW_NAME", WINDOW_NAME)
- OnPluginInstall()
- end
- elseif numResult == 5+hyperlink_skip then
- wanted_font = utils.fontpicker (font_name, font_size) --font dialog
- if wanted_font then
- font_name = wanted_font.name
- font_size = wanted_font.size
- SetVariable ("font_name", font_name)
- SetVariable ("font_size", font_size)
- OnPluginInstall()
- end
- elseif numResult == 6+hyperlink_skip then
- date_format = ""
- ColourNote ("yellow", "", "Timestamps in shipspam window DISABLED.")
- elseif numResult == 7+hyperlink_skip then
- date_format = "[%d %b %H:%M:%S] "
- ColourNote ("yellow", "", "Timestamps in shipspam window ENABLED using format like '30 Aug 13:29:49'.")
- elseif numResult == 8+hyperlink_skip then
- date_format = "[%d %b %I:%M:%S%p] "
- ColourNote ("yellow", "", "Timestamps in shipspam window ENABLED using format like '30 Aug 01:20:12PM'.")
- elseif numResult == 9+hyperlink_skip then
- date_format = "[%H:%M:%S] "
- ColourNote ("yellow", "", "Timestamps in shipspam window ENABLED using format like '13:29:08'.")
- elseif numResult == 10+hyperlink_skip then
- date_format = "[%I:%M:%S%p] "
- ColourNote ("yellow", "", "Timestamps in shipspam window ENABLED using format like '1:22:06 PM'.")
- elseif numResult == 11+hyperlink_skip then
- --local tbl = {}
- --local defaults = {}
- --local i = 1
- --for k,v in pairsByKeys(channels_table) do
- -- tbl[i] = k
- -- defaults[i] = v["capture"]
- -- i = i+1
- --end
- --local capture_result = utils.multilistbox ("Choose which actions to capture to this shipspam log window.", "ShipSpam Log Actions Selection", tbl, defaults)
- --if capture_result and next(capture_result) then -- cancel if the list is empty
- -- for i,v in ipairs(tbl) do
- -- channels_table[v]["capture"] = capture_result[i]
- -- end
- --end
- if show_turbos == 0 then
- ColourNote("yellow","","Turbolaser capturing is now ENABLED.")
- else
- ColourNote("yellow","","Turbolaser capturing is now DISABLED.")
- end
- EnableTrigger("turbos", 0 == show_turbos)
- show_turbos = GetTriggerOption("turbos", "enabled")
- elseif numResult == 12+hyperlink_skip then
- if show_lasers == 0 then
- ColourNote ("yellow", "", "Laser capturing is now ENABLED.")
- else
- ColourNote ("yellow", "", "Laser capturing is now DISABLED.")
- end
- EnableTrigger("lasers", 0 == show_lasers)
- show_lasers = GetTriggerOption("lasers","enabled")
- elseif numResult == 13+hyperlink_skip then
- if show_ions == 0 then
- ColourNote ("yellow", "", "Ion capturing is now ENABLED.")
- else
- ColourNote ("yellow", "", "Ion capturing is now DISABLED.")
- end
- EnableTrigger("ions", 0 == show_ions)
- show_ions = GetTriggerOption("ions","enabled")
- elseif numResult == 14+hyperlink_skip then
- if show_missiles == 0 then
- ColourNote ("yellow", "", "Missile capturing is now ENABLED.")
- else
- ColourNote ("yellow", "", "Missile capturing is now DISABLED.")
- end
- EnableTrigger("missiles", 0 == show_missiles)
- show_missiles = GetTriggerOption("missiles","enabled")
- elseif numResult == 15+hyperlink_skip then
- if show_torpedos == 0 then
- ColourNote ("yellow", "", "Torpedo capturing is now ENABLED.")
- else
- ColourNote ("yellow", "", "Torpedo capturing is now DISABLED.")
- end
- EnableTrigger("torpedos", 0 == show_torpedos)
- show_torpedos = GetTriggerOption("torpedos","enabled")
- elseif numResult == 16+hyperlink_skip then
- if show_rockets == 0 then
- ColourNote ("yellow", "", "Rocket capturing is now ENABLED.")
- else
- ColourNote ("yellow", "", "Rocket capturing is now DISABLED.")
- end
- EnableTrigger("rockets", 0 == show_rockets)
- show_rockets = GetTriggerOption("rockets","enabled")
- elseif numResult == 17+hyperlink_skip then
- if show_pulses == 0 then
- ColourNote ("yellow", "", "Pulse capturing is now ENABLED.")
- else
- ColourNote ("yellow", "", "Pulse capturing is now DISABLED.")
- end
- EnableTrigger("pulses", 0 == show_pulses)
- show_pulses = GetTriggerOption("pulses","enabled")
- elseif numResult == 18+hyperlink_skip then
- if show_tractors == 0 then
- ColourNote ("yellow", "", "Tractor beam capturing is now ENABLED.")
- else
- ColourNote ("yellow", "", "Tractor beam capturing is now DISABLED.")
- end
- EnableTrigger("tractors", 0 == show_tractors)
- show_tractors = GetTriggerOption("tractors","enabled")
- end
- if numResult == 19+hyperlink_skip then
- if turbos_echo == 0 then
- ColourNote("yellow", "", "Turbolasers will NOT be shown in the main window.")
- else
- ColourNote("yellow", "", "Turbolasers will be shown in the main window.")
- end
- SetTriggerOption("turbos", "omit_from_output", 0 == turbos_echo)
- turbos_echo = GetTriggerOption("turbos", "omit_from_output")
- elseif numResult == 20+hyperlink_skip then
- if lasers_echo == 0 then
- ColourNote("yellow", "", "Lasers will NOT be shown in the main window.")
- else
- ColourNote("yellow", "", "Lasers will be shown in the main window.")
- end
- SetTriggerOption("lasers", "omit_from_output", 0 == lasers_echo)
- lasers_echo = GetTriggerOption("lasers", "omit_from_output")
- elseif numResult == 21+hyperlink_skip then
- if ions_echo == 0 then
- ColourNote("yellow", "", "Ions will NOT be shown in the main window.")
- else
- ColourNote("yellow", "", "Ions will be shown in the main window.")
- end
- SetTriggerOption("ions", "omit_from_output", 0 == ions_echo)
- ions_echo = GetTriggerOption("ions", "omit_from_output")
- elseif numResult == 22+hyperlink_skip then
- if missiles_echo == 0 then
- ColourNote("yellow", "", "Missiles will NOT be shown in the main window.")
- else
- ColourNote("yellow", "", "Missiles will be shown in the main window.")
- end
- SetTriggerOption("missiles", "omit_from_output", 0 == missiles_echo)
- missiles_echo = GetTriggerOption("missiles", "omit_from_output")
- elseif numResult == 23+hyperlink_skip then
- if torpedos_echo == 0 then
- ColourNote("yellow", "", "Torpedos will NOT be shown in the main window.")
- else
- ColourNote("yellow", "", "Torpedos will be shown in the main window.")
- end
- SetTriggerOption("torpedos", "omit_from_output", 0 == torpedos_echo)
- torpedos_echo = GetTriggerOption("torpedos", "omit_from_output")
- elseif numResult == 24+hyperlink_skip then
- if rockets_echo == 0 then
- ColourNote("yellow", "", "Rockets will NOT be shown in the main window.")
- else
- ColourNote("yellow", "", "Rockets will be shown in the main window.")
- end
- SetTriggerOption("rockets", "omit_from_output", 0 == rockets_echo)
- rockets_echo = GetTriggerOption("rockets", "omit_from_output")
- elseif numResult == 25+hyperlink_skip then
- if pulses_echo == 0 then
- ColourNote("yellow", "", "Pulses will NOT be shown in the main window.")
- else
- ColourNote("yellow", "", "Pulses will be shown in the main window.")
- end
- SetTriggerOption("pulses", "omit_from_output", 0 == pulses_echo)
- pulses_echo = GetTriggerOption("pulses", "omit_from_output")
- elseif numResult == 26+hyperlink_skip then
- if tractors_echo == 0 then
- ColourNote("yellow", "", "Tractorbeams will NOT be shown in the main window.")
- else
- ColourNote("yellow", "", "Tractorbeams will be shown in the main window.")
- end
- SetTriggerOption("tractors", "omit_from_output", 0 == tractors_echo)
- tractors_echo = GetTriggerOption("tractors", "omit_from_output")
- end
- --if echo_skip ~= 0 then
- -- if numResult == 17+hyperlink_skip then
- -- Execute("chats echo on")
- -- elseif numResult == 17+hyperlink_skip+1 then
- -- Execute("chats echo off")
- -- elseif numResult == 17+hyperlink_skip+2 then
- -- Execute("chats echo custom")
- -- elseif numResult == 17+hyperlink_skip+3 then
- -- --CallPlugin("55616ea13339bc68e963e1f8", "hideEchos", info_echo, nil, nil, nil, nil, nil)
- -- elseif numResult == 17+hyperlink_skip+4 then
- -- --CallPlugin("55616ea13339bc68e963e1f8", "hideEchos", nil, global_quest_echo, nil, nil, nil, nil)
- -- elseif numResult == 17+hyperlink_skip+5 then
- -- --CallPlugin("55616ea13339bc68e963e1f8", "hideEchos", nil, nil, remort_auction_echo, nil, nil, nil)
- -- elseif numResult == 17+hyperlink_skip+6 then
- -- --CallPlugin("55616ea13339bc68e963e1f8", "hideEchos", nil, nil, nil, donations_echo, nil, nil)
- -- elseif numResult == 17+hyperlink_skip+7 then
- -- --CallPlugin("55616ea13339bc68e963e1f8", "hideEchos", nil, nil, nil, nil, pray_echo, nil)
- -- elseif numResult == 17+hyperlink_skip+8 then
- -- --CallPlugin("55616ea13339bc68e963e1f8", "hideEchos", nil, nil, nil, nil, nil, warfare_echo)
- -- end
- --end
- if numResult == 31+hyperlink_skip+echo_skip then
- log_to_file = (((0 == log_to_file) and 1) or 0)
- SetVariable("log_to_file", log_to_file)
- if log_to_file == 0 then
- ColourNote ("yellow", "", "Logging to file is now DISABLED.")
- else
- ColourNote ("yellow", "", "Logging to file is now ENABLED.")
- end
- elseif numResult == 32+hyperlink_skip+echo_skip then
- local newfile = utils.filepicker ("Choose log file...", "ChatLog.txt", "txt", { txt = "Text log file" }, true )
- if newfile then
- log_filename = newfile
- ColourNote ("yellow", "", "Logging chat to "..log_filename..".")
- end
- elseif numResult == 33+hyperlink_skip+echo_skip then
- log_colour_codes = (((0 == log_colour_codes) and 1) or 0)
- SetVariable("log_colour_codes", log_colour_codes)
- if log_colour_codes == 0 then
- ColourNote ("yellow", "", "Color codes will be stripped from the log file.")
- else
- ColourNote ("yellow", "", "Color codes will be included in the log file.")
- end
- elseif numResult == 34+hyperlink_skip+echo_skip then
- log_timestamps = (((0 == log_timestamps) and 1) or 0)
- SetVariable("log_timestamps", log_timestamps)
- if log_timestamps == 0 then
- ColourNote ("yellow", "", "Timestamps will not be included in the log file.")
- else
- ColourNote ("yellow", "", "Timestamps will be included in the log file.")
- end
- --elseif numResult == 20+hyperlink_skip+echo_skip then
- --CallPlugin("462b665ecb569efbf261422f","boostMe", win)
- --elseif numResult == 21+hyperlink_skip+echo_skip then
- --CallPlugin("462b665ecb569efbf261422f","dropMe", win)
- end
- OnPluginSaveState()
- end
- end -- right_click_menu
- ]]>
- </script>
- </muclient>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement