Advertisement
Xaleron

LotJShipSpamWindow

Mar 20th, 2019
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 61.82 KB | None | 0 0
  1. <?xml version="1.0" encoding="iso-8859-1"?>
  2. <!DOCTYPE muclient>
  3.  
  4. <!-- Bits of this plugin and ideas were borrowed and remixed from the MUSHclient community. http://www.gammon.com.au/forum/?id=9385 and others. -->
  5. <!-- Original script by Fiendish with help from Orogan, modified for LotJ by Johnson -->
  6. <!-- Further modified chat windows scripts for use with LotJ space combat by Xaleron -->
  7.  
  8. <muclient>
  9. <plugin
  10. name="LotJ_ShipSpam_Miniwindow"
  11. author="Fiendish"
  12. id="96ce07ef668c1258781d6b59"
  13. language="Lua"
  14. purpose="Move certain space messages to a miniwindow"
  15. date_written="2010-10-25"
  16. requires="4.73"
  17. version="2.0"
  18. save_state="y"
  19. >
  20.  
  21. <description trim="y">
  22. USAGE:
  23.  
  24. shipspam show : show shipspam window
  25. shipspam hide : hide shipspam window
  26. resetshipspam : return shipspam window to default settings
  27.  
  28. Left-click a line to copy it to the clipboard
  29. Left-click-and-drag title bar to move window
  30. Right-click window to see menu of options
  31. </description>
  32.  
  33. </plugin>
  34.  
  35. <triggers>
  36.  
  37. --- Begin space combat grabs
  38.  
  39. <trigger enabled="n" name="turbos" match="Turbolaser fire*" regexp="n" omit_from_output="n" script="untagged_info" sequence="100" />
  40. <trigger enabled="n" name="lasers" match="Laserfire*" regexp="n" omit_from_output="n" script="untagged_info" sequence="100" />
  41. <trigger enabled="n" name="ions" match="An Ion blast*" regexp="n" omit_from_output="n" script="untagged_info" sequence="100" />
  42. <trigger enabled="n" name="missiles" match="*fires a missile*" regexp="n" omit_from_output="n" script="untagged_info" sequence="100" />
  43. <trigger enabled="n" name="torpedos" match="*fires a torpedo*" regexp="n" omit_from_output="n" script="untagged_info" sequence="100" />
  44. <trigger enabled="n" name="rockets" match="*fires a heavy rocket*" regexp="n" omit_from_output="n" script="untagged_info" sequence="100" />
  45. <trigger enabled="n" name="pulses" match="*fires a pulse*" regexp="n" omit_from_output="n" script="untagged_info" sequence="100" />
  46. <trigger enabled="n" name="tractors" match="*white tractorbeam*" regexp="n" omit_from_output="n" script="untagged_info" sequence="100" />
  47.  
  48.  
  49. <!-- begin OOC chat grabs - commented out, not needed - Xaleron
  50.  
  51. <trigger enabled="n" name="immchat" match="( IMM | CHAT )*" regexp="n" omit_from_output="n" script="untagged_info" sequence="100" />
  52. <trigger enabled="n" name="rpcchat" match="(R|P|C)*" regexp="n" omit_from_output="n" script="untagged_info" sequence="100" />
  53. <trigger enabled="n" name="ooc" match="(OOC) *" regexp="n" omit_from_output="n" script="untagged_info" sequence="100" />
  54. <trigger enabled="n" name="newbie" match="(NEWBIE) *" regexp="n" omit_from_output="n" script="untagged_info" sequence="100" />
  55. <trigger enabled="n" name="immooc" match="(IMM) *" regexp="n" omit_from_output="n" script="untagged_info" sequence="100" />
  56. <trigger enabled="n" name="rpcooc" match="(RPC) *" regexp="n" omit_from_output="n" script="untagged_info" sequence="100" />
  57. <trigger enabled="n" name="immnet" match="ImmNet[*]*" regexp="n" omit_from_output="n" script="untagged_info" sequence="100" />
  58. <trigger enabled="n" name="councilnet" match="CouncilNet[*]*" regexp="n" omit_from_output="n" script="untagged_info" sequence="100" />
  59. -->
  60.  
  61. -- blank line gag
  62. <trigger enabled="n" match="^$" regexp="y" name="end_gag" group="end_gag" omit_from_output="y" sequence="100" send_to="12" >
  63. <send>EnableTriggerGroup("end_gag", false)</send></trigger>
  64. </triggers>
  65.  
  66. <aliases>
  67.  
  68. <alias match="resetshipspam" enabled="y" sequence="100" ignore_case="y" script="reset_shipspam" />
  69. <alias script="shipspam_show" match="shipspam show" enabled="y" sequence="100" ignore_case="y" />
  70. <alias script="shipspam_hide" match="shipspam hide" enabled="y" sequence="100" ignore_case="y" />
  71. </aliases>
  72.  
  73. <script>
  74. <![CDATA[
  75.  
  76. require "movewindow" -- load the movewindow.lua module
  77. require "copytable"
  78.  
  79. SCROLL_BAR_WIDTH = 15
  80. MAX_LINES = 10000 -- how many lines to store in scrollback
  81.  
  82. -- date_format = "[%d %b %H:%M:%S] " -- [30 Aug 13:29:49] date and time 24 hour
  83. -- date_format = "[%d %b %I:%M:%S%p] " -- [30 Aug 01:20:12PM] date and time 12 hour
  84. -- date_format = "[%H:%M:%S] " -- [13:29:08] time 24 hour
  85. -- date_format = "[%X] " -- [1:22:06 PM] time 12 hour
  86.  
  87. default_width = 657
  88. default_height = 131
  89. default_x = 0
  90. default_y = 0
  91.  
  92. date_format = GetVariable("date_format") or "[%d %b %H:%M:%S] "
  93. width = tonumber(GetVariable("WINDOW_WIDTH")) or default_width
  94. height = tonumber(GetVariable("WINDOW_HEIGHT")) or default_height
  95. log_to_file = tonumber(GetVariable("log_to_file")) or 0
  96. log_colour_codes = tonumber(GetVariable("log_colour_codes")) or 1
  97. log_timestamps = tonumber(GetVariable("log_timestamps")) or 1
  98.  
  99. function sanitize_filename(str)
  100. str = string.gsub(str, "[^%w%s()_-]", "")
  101. return Trim(str)
  102. end
  103.  
  104. log_filename = GetVariable("log_filename") or (GetInfo(58):gsub("^.\\",GetInfo(56))..sanitize_filename(GetInfo(2)).."ChatLog.txt")
  105.  
  106. -- colours
  107. WINDOW_BACKGROUND_COLOUR = GetNormalColour(1)
  108. WINDOW_TEXT_COLOUR = 0xffffff
  109. SCROLL_BACKGROUND_COLOUR = 0xE8E8E8
  110. SCROLL_BAR_COLOUR = 0x111111
  111. SCROLL_DETAIL_COLOUR = 0x000000
  112. WINDOW_BORDER_COLOUR = 0xE8E8E8
  113.  
  114. -- offset of text from edge
  115. TEXT_INSET = 5
  116.  
  117. -- where to store the chat line
  118. lines = {} -- table of recent chat lines
  119. rawlines = {}
  120.  
  121. lineStart = ""
  122. lineEnd = ""
  123. WINDOW_LINES = ""
  124. WINDOW_NAME = GetVariable("WINDOW_NAME") or "ShipSpam Log"
  125.  
  126. -- functions for handling Aardwolf color codes
  127. dofile(GetPluginInfo(GetPluginID(), 20) .. "lotj_colors.lua")
  128.  
  129. font_height = ""
  130. line_height = ""
  131. windowinfo = ""
  132. startx = ""
  133. starty = ""
  134.  
  135. show_turbos = tonumber(GetVariable("show_turbos")) or 1
  136. show_lasers = tonumber(GetVariable("show_lasers")) or 1
  137. show_ions = tonumber(GetVariable("show_ions")) or 1
  138. show_missiles = tonumber(GetVariable("show_missiles")) or 1
  139. show_torpedos = tonumber(GetVariable("show_torpedos")) or 1
  140. show_rockets = tonumber(GetVariable("show_rockets")) or 1
  141. show_pulses = tonumber(GetVariable("show_pulses")) or 1
  142. show_tractors = tonumber(GetVariable("show_tractors")) or 1
  143.  
  144. turbos_echo = tonumber(GetVariable("turbos_echo")) or 1
  145. lasers_echo = tonumber(GetVariable("lasers_echo")) or 1
  146. ions_echo = tonumber(GetVariable("ions_echo")) or 1
  147. missiles_echo = tonumber(GetVariable("missiles_echo")) or 1
  148. torpedos_echo = tonumber(GetVariable("torpedos_echo")) or 1
  149. rockets_echo = tonumber(GetVariable("rockets_echo")) or 1
  150. pulses_echo = tonumber(GetVariable("pulses_echo")) or 1
  151. tractors_echo = tonumber(GetVariable("tractors_echo")) or 0
  152.  
  153.  
  154.  
  155. SetTriggerOption("turbos", "enabled", show_turbos)
  156. SetTriggerOption("lasers", "enabled", show_lasers)
  157. SetTriggerOption("ions", "enabled", show_ions)
  158. SetTriggerOption("missiles", "enabled", show_missiles)
  159. SetTriggerOption("torpedos", "enabled", show_torpedos)
  160. SetTriggerOption("rockets", "enabled", show_rockets)
  161. SetTriggerOption("pulses", "enabled", show_pulses)
  162. SetTriggerOption("tractors", "enabled", show_tractors)
  163.  
  164. SetTriggerOption("turbos", "omit_from_output", turbos_echo)
  165. SetTriggerOption("lasers", "omit_from_output", lasers_echo)
  166. SetTriggerOption("ions", "omit_from_output", ions_echo)
  167. SetTriggerOption("missiles", "omit_from_output", missiles_echo)
  168. SetTriggerOption("torpedos", "omit_from_output", torpedos_echo)
  169. SetTriggerOption("rockets", "omit_from_output", rockets_echo)
  170. SetTriggerOption("pulses", "omit_from_output", pulses_echo)
  171. SetTriggerOption("tractors", "omit_from_output", tractors_echo)
  172.  
  173.  
  174.  
  175. function reset_shipspam()
  176. width = default_width
  177. height = default_height
  178. font_name = default_font_name
  179. font_size = default_font_size
  180. windowinfo.window_left = default_x
  181. windowinfo.window_top = default_y
  182. WindowPosition(win, default_x, default_y, 0, 18)
  183. Repaint() -- hack because WindowPosition doesn't immediately update coordinates
  184. OnPluginSaveState()
  185. OnPluginInstall()
  186. end
  187.  
  188. function ResizeMoveCallback ()
  189. posx, posy = WindowInfo(win, 17), WindowInfo(win, 18)
  190. width = width+posx-startx
  191. startx = posx
  192. -- if (WindowTextWidth(win, win_font, "WWWCOMMUNICATION")+2*SCROLL_BAR_WIDTH > width) then
  193. if (WindowTextWidth(win, win_font, WINDOW_NAME)+2*SCROLL_BAR_WIDTH > width) then
  194. -- width = WindowTextWidth(win, win_font, "WWWCOMMUNICATION")+2*SCROLL_BAR_WIDTH
  195. width = WindowTextWidth(win, win_font, WINDOW_NAME)+2*SCROLL_BAR_WIDTH
  196. startx = windowinfo.window_left+width
  197. elseif (windowinfo.window_left+width > GetInfo(281)) then
  198. width = GetInfo(281)-windowinfo.window_left
  199. startx = GetInfo(281)
  200. end
  201. height = height+posy-starty
  202. starty=posy
  203. if (3*SCROLL_BAR_WIDTH+10+line_height+TITLE_HEIGHT > height) then
  204. height = 3*SCROLL_BAR_WIDTH+10+line_height+TITLE_HEIGHT
  205. starty = windowinfo.window_top+height
  206. elseif (windowinfo.window_top+height > GetInfo(280)) then
  207. height = GetInfo(280)-windowinfo.window_top
  208. starty = GetInfo(280)
  209. end
  210. if (utils.timer() - lastRefresh > 0.0333) then
  211. init(false)
  212. lastRefresh = utils.timer()
  213. end
  214. end
  215.  
  216. lastRefresh = 0
  217.  
  218. function ResizeReleaseCallback ()
  219. height = TITLE_HEIGHT+(line_height*(WINDOW_LINES-1))+3 -- snap height down to not have dead space after last line
  220. init(true) -- true here causes old lines to re-wrap at the new size
  221. end
  222.  
  223. win = GetPluginID()
  224. require "checkplugin"
  225. function OnPluginListChanged ()
  226. do_plugin_check_now ("e2a1af0b5e462318bb423764", "lotj_repaint_buffer") -- check we have the repaint buffer
  227. end -- OnPluginListChanged
  228.  
  229. function OnPluginInstall ()
  230. -- Dummy window to get font characteristics
  231. check(WindowCreate(win, 0, 0, 1, 1, 0, 0, WINDOW_BACKGROUND_COLOUR))
  232.  
  233. local fonts = utils.getfontfamilies ()
  234.  
  235. -- if not there already, add it
  236. if not fonts.Dina then
  237. AddFont(GetInfo (66) .. "\\Dina.fon")
  238. fonts = utils.getfontfamilies()
  239. end -- if Dina not installed
  240.  
  241. if fonts["Dina"] then
  242. default_font_size = 8
  243. default_font_name = "Dina"
  244. elseif fonts ["Courier New"] then
  245. default_font_size = 9
  246. default_font_name = "Courier New" -- the actual font
  247. else
  248. default_font_size = 9
  249. default_font_name = "Lucida Console"
  250. end -- if
  251.  
  252. font_name = GetVariable("font_name") or default_font_name
  253. font_size = tonumber(GetVariable("font_size")) or default_font_size
  254.  
  255. header_font_name = font_name
  256. header_font_size = font_size
  257.  
  258. win_font = "font"..win
  259. win_head_font = "fonthead"..win
  260. check(WindowFont(win, win_font, font_name, font_size))
  261. check(WindowFont(win, win_head_font, header_font_name, header_font_size))
  262.  
  263. font_height = WindowFontInfo(win, win_font, 1) - WindowFontInfo(win, win_font, 4) + 1
  264. header_font_height = WindowFontInfo(win, win_head_font, 1) - WindowFontInfo(win, win_head_font, 4) + 1
  265. TITLE_HEIGHT = header_font_height*1.8
  266. line_height = font_height+1
  267.  
  268. -- install the window movement handler, get back the window position
  269. 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})
  270.  
  271. init(true)
  272. -- if disabled last time, stay disabled
  273. if GetVariable ("enabled") == "false" then
  274. ColourNote ("yellow", "", "Warning: Plugin " .. GetPluginName ().. " is currently disabled.")
  275. check (EnablePlugin(GetPluginID (), false))
  276. return
  277. else
  278. OnPluginEnable() -- do initialization stuff
  279. end-- they didn't enable us last time
  280. end
  281.  
  282. function init (firstTime)
  283. -- how many lines and columns will fit?
  284. WINDOW_LINES = math.ceil((height-TITLE_HEIGHT)/line_height)
  285.  
  286. if (firstTime == true) then
  287. WindowCreate(win, windowinfo.window_left, windowinfo.window_top, width, height, windowinfo.window_mode, windowinfo.window_flags, WINDOW_BACKGROUND_COLOUR)
  288.  
  289. -- catch for right-click menu and line selection
  290. WindowAddHotspot(win, "textarea", 1, TITLE_HEIGHT, width-SCROLL_BAR_WIDTH-1,height-3, "", "", "MouseDown", "CancelMouseDown", "MouseUp", "", 2, 0)
  291. WindowDragHandler(win, "textarea", "TextareaMoveCallback", "TextareaReleaseCallback", 0x10)
  292.  
  293. -- mouse wheel handler for scrolling up/down
  294. WindowScrollwheelHandler(win, "textarea", "wheel_move")
  295.  
  296. -- add the drag handler so they can move the window around
  297. movewindow.add_drag_handler(win, 0, 0, 0, TITLE_HEIGHT)
  298.  
  299. -- scroll bar up/down buttons
  300. WindowAddHotspot(win, "up", width-SCROLL_BAR_WIDTH, TITLE_HEIGHT, 0, TITLE_HEIGHT+SCROLL_BAR_WIDTH, "MouseOver", "CancelMouseOver", "MouseDown", "CancelMouseDown", "MouseUp", "", 1, 0)
  301. WindowAddHotspot(win, "down", width-SCROLL_BAR_WIDTH, height-(2*SCROLL_BAR_WIDTH), 0, height-SCROLL_BAR_WIDTH, "MouseOver", "CancelMouseOver", "MouseDown", "CancelMouseDown", "MouseUp", "", 1, 0)
  302.  
  303. -- add the resize widget hotspot
  304. WindowAddHotspot(win, "resize", width-SCROLL_BAR_WIDTH, height-SCROLL_BAR_WIDTH, width, height, "MouseOver", "CancelMouseOver", "MouseDown", "CancelMouseDown", "MouseUp", "", 6, 0)
  305. WindowDragHandler(win, "resize", "ResizeMoveCallback", "ResizeReleaseCallback", 0)
  306.  
  307. -- re-wrap buffered lines at the new size
  308. lines = {}
  309. for _,styles in ipairs(rawlines) do
  310. fillBuffer(styles[1],styles[2])
  311. end
  312. --CallPlugin("462b665ecb569efbf261422f", "registerMiniwindow", win) -- fail silently
  313. else
  314. WindowResize(win, width, height, WINDOW_BACKGROUND_COLOUR)
  315. WindowMoveHotspot(win, "textarea", 0, TITLE_HEIGHT, width-SCROLL_BAR_WIDTH-1, height-3)
  316. WindowMoveHotspot(win, "up", width-SCROLL_BAR_WIDTH, TITLE_HEIGHT, 0, TITLE_HEIGHT+SCROLL_BAR_WIDTH)
  317. WindowMoveHotspot(win, "down", width-SCROLL_BAR_WIDTH, height-(2*SCROLL_BAR_WIDTH), 0, height-SCROLL_BAR_WIDTH)
  318. WindowMoveHotspot(win, "resize", width-SCROLL_BAR_WIDTH, height-SCROLL_BAR_WIDTH, width, 0)
  319. end
  320. WindowShow(win, true)
  321.  
  322. lineStart = math.max(1, #lines-WINDOW_LINES+2)
  323. lineEnd = math.max(1, #lines)
  324.  
  325. -- title rectangle
  326. -- header_width = WindowTextWidth(win, win_head_font, "Communication Log")
  327. header_width = WindowTextWidth(win, win_head_font, WINDOW_NAME)
  328. WindowGradient(win, 1, 0, width, TITLE_HEIGHT, WINDOW_BACKGROUND_COLOUR, 0x444444, 2)
  329. -- WindowText(win, win_head_font, "Communication Log", (width-header_width)/2, ((TITLE_HEIGHT-header_font_height)/2)-1, width, TITLE_HEIGHT, 0xEEEEEE, false)
  330. WindowText(win, win_head_font, WINDOW_NAME, (width-header_width)/2, ((TITLE_HEIGHT-header_font_height)/2)-1, width, TITLE_HEIGHT, 0xEEEEEE, false)
  331. WindowLine(win, 0, TITLE_HEIGHT-1, width, TITLE_HEIGHT-1, WINDOW_BORDER_COLOUR, 0 + 0x0200, 1)
  332.  
  333. -- resize tag
  334. WindowRectOp(win, 2, width-SCROLL_BAR_WIDTH, height-SCROLL_BAR_WIDTH, 0, 0, SCROLL_BACKGROUND_COLOUR) -- resizer background
  335. WindowLine(win, width-SCROLL_BAR_WIDTH+1, height-2, width-2, height-SCROLL_BAR_WIDTH+1, 0xffffff, 0, 2)
  336. WindowLine(win, width-SCROLL_BAR_WIDTH+2, height-2, width-2, height-SCROLL_BAR_WIDTH+2, 0x696969, 0, 1)
  337. WindowLine(win, width-SCROLL_BAR_WIDTH+4, height-2, width-2, height-SCROLL_BAR_WIDTH+4, 0xffffff, 0, 2)
  338. WindowLine(win, width-SCROLL_BAR_WIDTH+5, height-2, width-2, height-SCROLL_BAR_WIDTH+5, 0x696969, 0, 1)
  339. WindowLine(win, width-SCROLL_BAR_WIDTH+7, height-2, width-2, height-SCROLL_BAR_WIDTH+7, 0xffffff, 0, 2)
  340. WindowLine(win, width-SCROLL_BAR_WIDTH+8, height-2, width-2, height-SCROLL_BAR_WIDTH+8, 0x696969, 0, 1)
  341. WindowLine(win, width-SCROLL_BAR_WIDTH+10, height-2, width-2, height-SCROLL_BAR_WIDTH+10, 0xffffff, 0, 2)
  342. WindowLine(win, width-SCROLL_BAR_WIDTH+11, height-2, width-2, height-SCROLL_BAR_WIDTH+11, 0x696969, 0, 1)
  343.  
  344. -- draw border
  345. WindowRectOp(win, 1, 0, 0, 0, 0, WINDOW_BORDER_COLOUR)
  346.  
  347. drawStuff()
  348. end
  349.  
  350. function OnPluginConnect ()
  351.  
  352. end -- OnPluginConnect
  353.  
  354. function OnPluginClose ()
  355. -- if enabled
  356. if GetPluginInfo(GetPluginID(), 17) then
  357. OnPluginDisable()
  358. end -- if enabled
  359. WindowDelete(win)
  360. end -- OnPluginClose
  361.  
  362. function OnPluginEnable ()
  363. WindowShow(win, true)
  364. -- if we are connected when the plugin loads, it must have been reloaded while playing
  365. if IsConnected() then
  366. OnPluginConnect()
  367. end -- if already connected
  368. OnPluginSaveState()
  369. end -- OnPluginEnable
  370.  
  371. require "serialize"
  372. function OnPluginSaveState()
  373. -- save window current location for next time
  374. SetVariable("enabled", tostring (GetPluginInfo (GetPluginID(), 17)))
  375. movewindow.save_state(win)
  376.  
  377. SetVariable("font_name", font_name)
  378. SetVariable("font_size", font_size)
  379. SetVariable("date_format", date_format)
  380. SetVariable("WINDOW_WIDTH", width)
  381. SetVariable("WINDOW_HEIGHT", height)
  382. SetVariable("WINDOW_NAME", WINDOW_NAME)
  383. SetVariable("show_turbos", show_turbos)
  384. SetVariable("show_lasers", show_lasers)
  385. SetVariable("show_ions", show_ions)
  386. SetVariable("show_missiles", show_missiles)
  387. SetVariable("show_torpedos", show_torpedos)
  388. SetVariable("show_rockets", show_rockets)
  389. SetVariable("show_pulses", show_pulses)
  390. SetVariable("show_tractors", show_tractors)
  391. SetVariable("turbos_echo", turbos_echo)
  392. SetVariable("lasers_echo", lasers_echo)
  393. SetVariable("ions_echo", ions_echo)
  394. SetVariable("missiles_echo", missiles_echo)
  395. SetVariable("torpedos_echo", torpedos_echo)
  396. SetVariable("rockets_echo", rockets_echo)
  397. SetVariable("pulses_echo", pulses_echo)
  398. SetVariable("tractors_echo", tractors_echo)
  399. SetVariable("log_to_file", log_to_file)
  400. SetVariable("log_filename", log_filename)
  401. SetVariable("log_colour_codes", log_colour_codes)
  402. SetVariable("log_timestamps", log_timestamps)
  403. --SetVariable("show_donations", show_donations)
  404. SetVariable("channels_table", serialize.save("channels_table"))
  405. end -- OnPluginSaveState
  406.  
  407. function OnPluginDisable()
  408. WindowShow( win, false )
  409. --UnloadPlugin("55616ea13339bc68e963e1f8")
  410. OnPluginSaveState()
  411. end -- OnPluginDisable
  412.  
  413. -- display one line
  414. function Display_Line (line, styles, backfill_start, backfill_end)
  415. local left = TEXT_INSET
  416. local top = TITLE_HEIGHT+(line*line_height)
  417. if (backfill_start ~= nil and backfill_end ~= nil) then
  418. WindowRectOp(win, 2, backfill_start, top+1, backfill_end, top+line_height+1, 0x444444)
  419. end -- backfill
  420. if styles then
  421. for _, v in ipairs(styles) do
  422. local t = v.text
  423. -- now clean up dangling newlines that cause block characters to show
  424. if string.sub(v.text,-1) == "\n" then
  425. t = string.sub(v.text,1,-2)
  426. end
  427. left = left + WindowText(win, win_font, t, left, top, width-SCROLL_BAR_WIDTH, 0, v.textcolour)
  428. end -- for each style run
  429. end
  430. end -- Display_Line
  431.  
  432. -- Returns an array {start, end, text}
  433. function findURLs(text)
  434. local URLs = {}
  435. local start, position = 0, 0
  436. -- "rex" is a table supplied by MUSHclient for PCRE functionality.
  437. local re = rex.new("(?:https?://|mailto:)\\S*[\\w/=@#\\-\\?]")
  438. re:gmatch(text,
  439. function (link, _)
  440. start, position = string.find(text, link, position, true)
  441. table.insert(URLs, {start=start, stop=position, text=link})
  442. end
  443. )
  444. return URLs
  445. end -- function findURL
  446.  
  447. -- display all visible lines
  448. hyperlinks = {}
  449. function writeLines ()
  450. WindowRectOp(win, 2, 1, TITLE_HEIGHT, width-SCROLL_BAR_WIDTH, -1, WINDOW_BACKGROUND_COLOUR) -- clear
  451. local ax = nil
  452. local zx = nil
  453. local line_no_colors = ""
  454. if #lines >= 1 then
  455. for count = lineStart, lineEnd do
  456. ax = nil
  457. zx = nil
  458. line_no_colors = strip_colours(StylesToColoursOneLine(lines[count][1]))
  459.  
  460. -- create clickable links for urls
  461. for i,v in ipairs(lines[count][3]) do
  462. local left = TEXT_INSET+WindowTextWidth(win, win_font, string.sub(line_no_colors, 1, v.start-1))
  463. local right = left+WindowTextWidth(win, win_font, string.sub(line_no_colors, v.start-1, v.stop-1))
  464. local top = TITLE_HEIGHT+((count-lineStart)*line_height)-1
  465. local bottom = top+line_height+1
  466. local link_name = table.concat({v.text," ",count,v.start,v.stop})
  467. if not WindowHotspotInfo(win, link_name, 1) then
  468. hyperlinks[link_name] = v.text
  469. 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)
  470. WindowDragHandler(win, link_name, "TextareaMoveCallback", "TextareaReleaseCallback", 0x10)
  471. WindowScrollwheelHandler(win, link_name, "wheel_move")
  472. end
  473. end
  474.  
  475. -- create highlighting parameters when text is selected
  476. if copy_start_line ~= nil and copy_end_line ~= nil and count >= copy_start_line and count <= copy_end_line then
  477. ax = (((count == copy_start_line) and math.min(start_copying_x, WindowTextWidth(win, win_font, line_no_colors)+TEXT_INSET)) or TEXT_INSET)
  478. -- end of highlight for this line
  479. 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))
  480. end
  481.  
  482. Display_Line( count-lineStart, lines[count][1], ax, zx )
  483. end
  484. end
  485. BroadcastPlugin(999, "repaint")
  486. end
  487.  
  488. barPos = ""
  489. barSize = ""
  490. totalSteps = ""
  491. function drawStuff ()
  492.  
  493. -- Scrollbar base
  494. WindowRectOp(win, 2, width-SCROLL_BAR_WIDTH, TITLE_HEIGHT, width, -SCROLL_BAR_WIDTH, SCROLL_BACKGROUND_COLOUR) -- scroll bar background
  495. 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
  496.  
  497. if (keepscrolling == "up") then
  498. -- draw top scroll button pressed
  499. WindowRectOp(win, 5, (width-SCROLL_BAR_WIDTH), TITLE_HEIGHT, 0, TITLE_HEIGHT+SCROLL_BAR_WIDTH, 10, 15 + 0x800) -- up arrow pushed
  500. 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)
  501. WindowPolygon(win, points,
  502. 0x000000, 0, 1, -- pen (solid, width 1)
  503. 0x000000, 0, -- brush (solid)
  504. true, -- close
  505. false) -- alt fill
  506. else
  507. -- draw top scroll button unpressed
  508. WindowRectOp(win, 5, (width-SCROLL_BAR_WIDTH), TITLE_HEIGHT, width, TITLE_HEIGHT+SCROLL_BAR_WIDTH, 5, 15 + 0x800)
  509. 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)
  510. WindowPolygon(win, points,
  511. 0x000000, 0, 1, -- pen (solid, width 1)
  512. 0x000000, 0, --brush (solid)
  513. true, --close
  514. false) --alt fill
  515. end
  516.  
  517. if (keepscrolling == "down") then
  518. -- draw bottom scroll button pressed
  519. WindowRectOp(win, 5, (width-SCROLL_BAR_WIDTH), height-(SCROLL_BAR_WIDTH*2), 0, height-SCROLL_BAR_WIDTH-1, 10, 15 + 0x800)
  520. 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)
  521. WindowPolygon(win, points,
  522. 0x000000, 0, 1, -- pen (solid, width 1)
  523. 0x000000, 0, -- brush (solid)
  524. true, -- close
  525. false) -- alt fill
  526. else
  527. -- draw bottom scroll button unpressed
  528. WindowRectOp(win, 5, (width-SCROLL_BAR_WIDTH), height-(SCROLL_BAR_WIDTH*2), width, height-SCROLL_BAR_WIDTH, 5, 15 + 0x800)
  529. 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)
  530. WindowPolygon(win, points,
  531. 0x000000, 0, 1, -- pen (solid, width 1)
  532. 0x000000, 0, --brush (solid)
  533. true, --close
  534. false) --alt fill
  535. end
  536.  
  537. -- The scrollbar position indicator
  538. totalSteps = #lines
  539. if (totalSteps <= WINDOW_LINES-1) then
  540. totalSteps = 1
  541. end
  542. SCROLL_BAR_HEIGHT = (height-(3*SCROLL_BAR_WIDTH)-TITLE_HEIGHT)
  543. if (not dragscrolling) then
  544. stepNum = lineStart-1
  545. barPos = SCROLL_BAR_WIDTH +TITLE_HEIGHT+ ((SCROLL_BAR_HEIGHT/totalSteps) * stepNum)
  546. barSize = (SCROLL_BAR_HEIGHT/math.max(WINDOW_LINES-1,totalSteps)) * (WINDOW_LINES-1)
  547. if barSize < 10 then
  548. barSize = 10
  549. end
  550. if barPos+barSize > SCROLL_BAR_WIDTH+TITLE_HEIGHT+SCROLL_BAR_HEIGHT then
  551. barPos = SCROLL_BAR_WIDTH+TITLE_HEIGHT+SCROLL_BAR_HEIGHT - barSize
  552. end
  553. WindowAddHotspot(win, "scroller", (width-SCROLL_BAR_WIDTH), barPos, width, barPos+barSize, "MouseOver", "CancelMouseOver", "MouseDown", "CancelMouseDown", "MouseUp", "", 1, 0)
  554. WindowDragHandler(win, "scroller", "ScrollerMoveCallback", "ScrollerReleaseCallback", 0)
  555. end
  556. WindowRectOp(win, 5, (width-SCROLL_BAR_WIDTH), barPos, width, barPos+barSize, 5, 15 + 0x800) -- scrollbar position indicator
  557.  
  558. -- reset hyperlinks if the text moves
  559. for k,v in pairs(hyperlinks) do
  560. WindowDeleteHotspot(win, k)
  561. end
  562. hyperlinks = {}
  563.  
  564. writeLines()
  565. end
  566.  
  567. function wheel_move (flags, hotspot_id)
  568. if bit.band(flags, 0x100) ~= 0 then
  569. if lineStart < #lines-WINDOW_LINES+2 then
  570. -- down
  571. lineStart = math.max(1, math.min(#lines-WINDOW_LINES+2, lineStart+3))
  572. lineEnd = math.min(#lines, lineStart+WINDOW_LINES-2)
  573. drawStuff()
  574. end
  575. elseif lineStart > 1 then
  576. -- up
  577. lineStart = math.max(1, lineStart-3)
  578. lineEnd = math.min(#lines, lineStart+WINDOW_LINES-2)
  579. drawStuff()
  580. end -- if
  581. end -- wheel_move
  582.  
  583. function ScrollerMoveCallback(flags, hotspot_id)
  584. mouseposy = WindowInfo(win, 18)
  585. windowtop = WindowInfo(win, 2)
  586. barPos = math.max(mouseposy-windowtop+clickdelta, SCROLL_BAR_WIDTH+TITLE_HEIGHT)
  587. if barPos > height-(SCROLL_BAR_WIDTH*2)-barSize then
  588. barPos = height-(SCROLL_BAR_WIDTH*2)-barSize
  589. lineStart = math.max(1,#lines-WINDOW_LINES+2)
  590. lineEnd = #lines
  591. else
  592. lineStart = math.max(1,math.floor((barPos-SCROLL_BAR_WIDTH-TITLE_HEIGHT)/(SCROLL_BAR_HEIGHT/totalSteps)+1))
  593. lineEnd = math.min(lineStart + WINDOW_LINES-2, #lines)
  594. end
  595. drawStuff()
  596. end
  597.  
  598. function ScrollerReleaseCallback(flags, hotspot_id)
  599. dragscrolling = false
  600. drawStuff()
  601. end
  602.  
  603. function add_line ( line, is_beginning_of_message, urls )
  604. -- add new line
  605. table.insert(lines, {[1]=line, [2]=is_beginning_of_message, [3]=urls} )
  606. -- advance the count
  607. if #lines >= WINDOW_LINES then
  608. lineStart = lineStart + 1
  609. end -- if
  610.  
  611. if #lines > 1 then
  612. lineEnd = lineEnd + 1
  613. end -- if
  614. end -- add_line
  615.  
  616. function fillBuffer(rawstyles, rawurls)
  617. local avail = width - (TEXT_INSET * 2) - 9
  618. local line_styles = {}
  619. local beginning = true
  620. local length = 0
  621. local styles = copytable.deep(rawstyles)
  622. local urls = copytable.deep(rawurls)
  623.  
  624. -- It turns out you can reduce the function
  625. -- call time by instantiating functions as local.
  626. -- This is really just me being silly.
  627. local remove = table.remove
  628. local insert = table.insert
  629.  
  630. -- Keep pulling out styles and trying to fit them on the current line
  631. while #styles > 0 do
  632. -- break off the next style
  633. local style = remove(styles, 1)
  634.  
  635. -- make this handle forced newlines like in the flickoff social
  636. -- by splitting off and sticking the next part back into the
  637. -- styles list for the next pass
  638. foundbreak = false
  639. newline = string.find(style.text, "\n")
  640. if newline then
  641. insert(styles, 1, {text = string.sub(style.text,newline+1),
  642. length = style.length-newline+1,
  643. textcolour = style.textcolour,
  644. backcolour = style.backcolour}
  645. )
  646. -- we're leaving in the newline characters here because we need to be
  647. -- able to copy them later. I'll clean up the buggy visual later when
  648. -- actually displaying the lines.
  649. style.length = newline
  650. style.text = string.sub(style.text,1,newline)
  651. foundbreak = true
  652. end
  653.  
  654. local text_width = WindowTextWidth(win, win_font, style.text)
  655.  
  656. -- if it fits, copy whole style in
  657. if text_width <= avail then
  658. insert(line_styles, style)
  659. length = length + style.length
  660. avail = avail - text_width
  661. if foundbreak then
  662. avail = 0
  663. end
  664. else -- otherwise, have to split style
  665. -- look for trailing space (work backwards). remember where space is
  666. local col = style.length - 1
  667. local split_col
  668. -- keep going until out of columns
  669. while col > 1 do
  670. text_width = WindowTextWidth(win, win_font, style.text:sub(1, col))
  671. if text_width <= avail then
  672. if not split_col then
  673. split_col = col -- in case no space found, this is where we can split
  674. end -- if
  675. -- see if space here
  676. if style.text:sub(col, col) == " " then
  677. split_col = col
  678. break
  679. end -- if space
  680. end -- if will now fit
  681. col = col - 1
  682. end -- while
  683.  
  684. if split_col then
  685. -- if we found a place to split, use old style and truncate it.
  686. -- Also stick the rest back with the same styling back into the styles list
  687. insert(line_styles, style)
  688. local style_copy = copytable.shallow(style)
  689. style.text = style.text:sub(1, split_col)
  690. style.length = split_col
  691. style_copy.text = style_copy.text:sub(split_col + 1)
  692. style_copy.length = #style_copy.text
  693. insert(styles, 1, style_copy)
  694. length = length + style.length
  695. elseif next(line_styles) == nil then
  696. -- Actually, I don't think this can ever happen. -Fiendish
  697. insert(line_styles, style)
  698. length = length + style.length
  699. else
  700. -- if we're about to start a new style and the
  701. -- line is completely full, put it back in the list for later
  702. insert(styles, 1, style)
  703. end -- if
  704. avail = 0 -- now we need to wrap
  705. end -- if could/not fit whole thing in
  706.  
  707. -- out of styles or out of room? add a line for what we have so far
  708. if #styles == 0 or avail <= 0 then
  709. if #lines >= MAX_LINES then
  710. -- if the history buffer is full then remove the oldest line
  711. remove(lines, 1)
  712. lineStart = lineStart - 1
  713. lineEnd = lineEnd - 1
  714. end -- buffer full
  715.  
  716. local line_urls = {}
  717. while urls[1] and urls[1].stop <= length do
  718. insert(line_urls, remove(urls, 1))
  719. end
  720. if urls[1] and urls[1].start < length then
  721. local url = copytable.deep(urls[1])
  722. url.stop = length + 1
  723. urls[1].stop = urls[1].stop-1
  724. urls[1].old = true
  725. insert(line_urls, url)
  726. end
  727. for i,v in ipairs(urls) do
  728. urls[i].start = urls[i].start - length
  729. urls[i].stop = urls[i].stop - length
  730. if urls[i].start <= 1 then
  731. urls[i].start = 1
  732. urls[i].stop = urls[i].stop+1
  733. end
  734. end
  735.  
  736. add_line( line_styles, beginning, line_urls )
  737.  
  738. avail = width - (TEXT_INSET * 2) - 9
  739. line_styles = {}
  740. length = 0
  741. beginning = false
  742. end -- line full
  743. end -- while we still have styles over
  744. end
  745.  
  746. function stampAndStore(styles)
  747.  
  748. local text = ""
  749. local log_text = ""
  750.  
  751. -- inject timestamp if wanted
  752. tstamp = os.date(date_format)
  753. timestyle = {text=tstamp, length=string.len(tstamp), textcolour=0xc0c0c0}
  754. table.insert(styles,1,timestyle)
  755.  
  756. text = StylesToColoursOneLine(styles)
  757.  
  758. if (log_to_file == 1) then
  759. if (log_timestamps == 0) then
  760. local local_styles = copytable.deep(styles)
  761. table.remove(local_styles, 1)
  762. log_text = StylesToColoursOneLine(local_styles)
  763. else
  764. log_text = text
  765. end
  766. if (log_colour_codes == 0) then
  767. log_text = strip_colours(log_text)
  768. end
  769. --local f = assert(io.open (GetInfo(58):gsub("^.\\",GetInfo(56))..sanitize_filename(GetInfo(2)).."ChatLog.txt", "a+")) -- handle to chat log file
  770. local f = assert(io.open (log_filename, "a+")) -- handle to chat log file
  771. f:write(log_text.."\n") -- write to it
  772. f:close() -- close that file now
  773. end
  774.  
  775. local urls = findURLs(strip_colours(text))
  776.  
  777. -- store the raw lines for use during resizing
  778. if #rawlines >= MAX_LINES then
  779. table.remove(rawlines, 1)
  780. end
  781. table.insert(rawlines, {[1]=styles, [2]=urls})
  782.  
  783. fillBuffer(styles, urls)
  784. drawStuff()
  785. end
  786.  
  787. -- Takes input as a string with embedded LotJ color codes. Use via CallPlugin().
  788. -- See: http://mushclient.com/scripts/doc.php?function=CallPlugin
  789. -- You can use the function StylesToColoursOneLine(styles_table) from aardwolf_colors.lua
  790. -- or manually embed your own colors to push any colorized line you want to the log window.
  791. -- Example: CallPlugin("b555825a4a5700c35fa80780","storeFromOutside","HELLO&RHello&Mhello&x215hello&x66HELLO")
  792. function storeFromOutside(string)
  793. stampAndStore(ColoursToStyles(string))
  794. end
  795.  
  796. function untagged_info (name, line, wildcards, styles)
  797. stampAndStore(styles)
  798. if turbos_echo == 1 and name=="turbos" then
  799. EnableTrigger("end_gag", true)
  800. end
  801. if lasers_echo == 1 and name=="lasers" then
  802. EnableTrigger("end_gag", true)
  803. end
  804. if ions_echo == 1 and name=="ions" then
  805. EnableTrigger("end_gag", true)
  806. end
  807. if missiles_echo == 1 and name=="missiles" then
  808. EnableTrigger("end_gag", true)
  809. end
  810. if torpedos_echo == 1 and name=="torpedos" then
  811. EnableTrigger("end_gag", true)
  812. end
  813. if rockets_echo == 1 and name=="rockets" then
  814. EnableTrigger("end_gag", true)
  815. end
  816. if pulses_echo == 1 and name=="pulses" then
  817. EnableTrigger("end_gag", true)
  818. end
  819. if tractors_echo == 1 and name=="tractors" then
  820. EnableTrigger("end_gag", true)
  821. end
  822. end -- untagged info
  823.  
  824. function OnPluginBroadcast (msg, id, name, text)
  825. -- Look for GMCP handler.
  826. --if (id == '3e7dedbe37e44942dd46d264') then
  827. -- if (text == "comm.channel") then
  828. -- res, gmcparg = CallPlugin("3e7dedbe37e44942dd46d264","gmcpval","comm.channel")
  829. -- luastmt = "gmcpdata = " .. gmcparg
  830. -- assert (loadstring (luastmt or ""))()
  831.  
  832. -- msg = gmcpval("msg") or ""
  833. -- chan = gmcpval("chan") or ""
  834. -- if (show_donations == 1 or string.match(strip_colours(msg), "^CLAN ANNOUNCEMENT: %a+ has donated") == nil) then
  835. -- if not channels_table[chan] then
  836. -- addNewChannel(chan)
  837. -- end
  838. -- if channels_table[chan]["capture"] then
  839. -- stampAndStore(ColoursToStyles(msg))
  840. -- end
  841. -- end
  842. -- end
  843. --elseif (id == "462b665ecb569efbf261422f" and msg==996 and text == "re-register z") then
  844. -- CallPlugin("462b665ecb569efbf261422f", "registerMiniwindow", win)
  845. --end
  846. end
  847.  
  848. keepscrolling = ""
  849. require "wait"
  850.  
  851. function scrollbar()
  852. wait.make(
  853. function()
  854. while keepscrolling == "up" or keepscrolling == "down" do
  855. if keepscrolling == "up" then
  856. if (lineStart > 1) then
  857. lineStart = lineStart - 1
  858. lineEnd = lineEnd - 1
  859. else
  860. keepscrolling = ""
  861. end
  862. elseif keepscrolling == "down" then
  863. if (lineEnd < #lines) then
  864. lineStart = lineStart + 1
  865. lineEnd = lineEnd + 1
  866. else
  867. keepscrolling = ""
  868. end
  869. end
  870. wait.time(0.1)
  871. drawStuff()
  872. end
  873. end
  874. )
  875. end
  876.  
  877. function GetAllBufferedMessages()
  878. local t = {}
  879. for _,styles in ipairs(rawlines) do
  880. table.insert(t, StylesToColoursOneLine(styles[1]))
  881. end
  882. SetClipboard(table.concat(t,"\n"))
  883. end
  884.  
  885. function MouseOver(flags, hotspot_id)
  886. keepscrolling = ""
  887. end
  888.  
  889. function CancelMouseOver(flags, hotspot_id)
  890. keepscrolling = ""
  891. end
  892.  
  893. function MouseOverLink(flags, hotspot_id)
  894. local url = string.gsub(hotspot_id, "(.* ).*", "%1")
  895. local hotspots = WindowHotspotList(win)
  896. for _, v in ipairs (hotspots) do
  897. if string.find(v, url, 1, true) then
  898. local left = WindowHotspotInfo(win, v, 1)
  899. local right = WindowHotspotInfo(win, v, 3)
  900. local bottom = WindowHotspotInfo(win, v, 4)
  901. WindowLine(win, left, bottom, right, bottom, 0xffffff, 256, 1);
  902. end
  903. end
  904. BroadcastPlugin(999, "repaint")
  905. end
  906.  
  907. function CancelMouseOverLink(flags, hotspot_id)
  908. local url = string.gsub(hotspot_id, "(.* ).*", "%1")
  909. if not string.find(WindowInfo(win, 19), url, 1, true) then
  910. writeLines()
  911. end
  912. end
  913.  
  914. temp_start_copying_x = 0
  915. start_copying_y = 0
  916. copied_text = ""
  917. function MouseDown(flags, hotspot_id)
  918. if (hotspot_id == "resize") then
  919. startx, starty = WindowInfo (win, 17), WindowInfo (win, 18)
  920. elseif (hotspot_id == "scroller") then
  921. clickdelta = WindowHotspotInfo(win, "scroller", 2)-WindowInfo (win, 15)
  922. dragscrolling = true
  923. elseif (hotspot_id == "up" or hotspot_id == "down") then
  924. keepscrolling = hotspot_id
  925. scrollbar()
  926. elseif (flags == 0x10) then
  927. temp_start_copying_x = WindowInfo(win, 14)
  928. start_copying_y = WindowInfo(win, 15)
  929. copy_start_windowline = math.floor((start_copying_y-TITLE_HEIGHT)/line_height)
  930. temp_start_line = copy_start_windowline+lineStart
  931. copied_text = ""
  932. copy_start_line = nil
  933. copy_end_line = nil
  934. writeLines()
  935. end
  936. end
  937.  
  938. function CancelMouseDown(flags, hotspot_id)
  939. keepscrolling = ""
  940. drawStuff()
  941. end
  942.  
  943. end_copying_x = 0
  944. end_copying_y = 0
  945. function MouseUp(flags, hotspot_id)
  946. if bit.band (flags, miniwin.hotspot_got_rh_mouse) ~= 0 then
  947. right_click_menu(hotspot_id)
  948. else
  949. drawStuff()
  950. end
  951. keepscrolling = ""
  952. return true
  953. end
  954.  
  955. function TextareaMoveCallback(flags, hotspot_id)
  956. if bit.band (flags, miniwin.hotspot_got_lh_mouse) ~= 0 then -- only on left mouse button
  957. copied_text = ""
  958. end_copying_x = WindowInfo(win, 17)-WindowInfo(win, 1)
  959. end_copying_y = WindowInfo(win, 18)-WindowInfo(win, 2)
  960. local ypos = end_copying_y
  961. end_copying_x = math.max(TEXT_INSET,math.min(end_copying_x, width-SCROLL_BAR_WIDTH))
  962. end_copying_y = math.max(TITLE_HEIGHT+1,math.min(end_copying_y, TITLE_HEIGHT-1+(line_height*(WINDOW_LINES-1))))
  963. copy_end_windowline = math.floor((end_copying_y-TITLE_HEIGHT)/line_height)
  964. copy_end_line = copy_end_windowline+lineStart
  965. copy_start_line = temp_start_line
  966. start_copying_x = temp_start_copying_x
  967.  
  968. if not copy_start_line then
  969. -- OS bug causing errors for me. hack around stupid mouse click tracking mess
  970. return
  971. end
  972.  
  973. if (copy_start_line > #lines) then
  974. start_copying_x = width-SCROLL_BAR_WIDTH
  975. end
  976.  
  977. -- the user is selecting backwards, so reverse the start/end orders
  978. if copy_end_line < temp_start_line then
  979. local temp = copy_end_line
  980. copy_end_line = copy_start_line
  981. copy_start_line = temp
  982. temp = end_copying_x
  983. end_copying_x = start_copying_x
  984. start_copying_x = temp
  985. end -- if
  986. if copy_end_line == copy_start_line and end_copying_x < start_copying_x then
  987. local temp = end_copying_x
  988. end_copying_x = start_copying_x
  989. start_copying_x = temp
  990. end -- if
  991.  
  992. for copy_line=copy_start_line,copy_end_line do
  993. if (lines[copy_line] ~= nil) then
  994. local startpos = 1
  995. local endpos = 99999
  996. if (copy_line-lineStart+1 > 0 and copy_line-lineStart < WINDOW_LINES and copy_line-lineStart < #lines) then
  997. -- snap to character boundaries instead of selecting arbitrary pixel widths
  998. local line_no_colors = strip_colours(StylesToColoursOneLine(lines[copy_line][1]))
  999. startpos = 1
  1000. endpos = #line_no_colors
  1001. -- special deal for the first line
  1002. if copy_line == copy_start_line then
  1003. for pos=1,#line_no_colors do
  1004. startpos = pos
  1005. if WindowTextWidth(win, win_font, string.sub(line_no_colors,1,pos)) > start_copying_x then
  1006. start_copying_x = WindowTextWidth(win, win_font, string.sub(line_no_colors,1,pos-1))+TEXT_INSET
  1007. break
  1008. end
  1009. end
  1010. end
  1011. -- special deal for the last line
  1012. if copy_line == copy_end_line then
  1013. local found = false
  1014. endpos = 0
  1015. for pos=1,#line_no_colors do
  1016. if WindowTextWidth(win, win_font, string.sub(line_no_colors,1,pos)) > end_copying_x then
  1017. end_copying_x = WindowTextWidth(win, win_font, string.sub(line_no_colors,1,endpos))+TEXT_INSET
  1018. found = true
  1019. break
  1020. end
  1021. endpos = pos
  1022. end
  1023. end
  1024. end -- if should show highlight
  1025.  
  1026. -- store selected area for later
  1027. copied_part = StylesToColoursOneLine(lines[copy_line][1], startpos, endpos)
  1028. if copy_line ~= copy_end_line and copy_line ~= #lines and lines[copy_line+1][2] == true then
  1029. -- only put a line break if the next line is from a different message
  1030. copied_part = copied_part.."&w\n"
  1031. elseif copy_line == copy_end_line or copy_line == #lines then
  1032. -- tack a white code on to the very end
  1033. copied_part = copied_part.."&w"
  1034. end
  1035. copied_text = copied_text..(((copied_part ~= nil) and copied_part) or "")
  1036. end -- if valid line
  1037. end -- for
  1038.  
  1039. if ypos < TITLE_HEIGHT then
  1040. keepscrolling = "up"
  1041. scrollbar()
  1042. elseif ypos > height then
  1043. keepscrolling = "down"
  1044. scrollbar()
  1045. else
  1046. keepscrolling = ""
  1047. writeLines()
  1048. end
  1049. end -- if left mouse button
  1050. end -- function TextareaMoveCallback
  1051.  
  1052. function TextareaReleaseCallback(flags, hotspot_id)
  1053. copy_start_line = math.min(#lines, copy_start_line or 0)
  1054. copy_end_line = math.min(#lines, copy_end_line or 0)
  1055. end
  1056.  
  1057. function LeftClickOnly(flags, hotspot_id, win)
  1058. if bit.band (flags, miniwin.hotspot_got_rh_mouse) ~= 0 then
  1059. return true
  1060. end
  1061. return false
  1062. end
  1063.  
  1064. function shipspam_show (name, line, wildcards)
  1065. WindowShow( win, true )
  1066. ColourNote ("yellow", "", "ShipSpam window now shown. Type 'shipspam hide' to hide it.")
  1067. end -- function shipspam_show
  1068.  
  1069. function shipspam_hide (name, line, wildcards)
  1070. WindowShow( win, false )
  1071. ColourNote ("yellow", "", "ShipSpam window now hidden. Type 'shipspam show' to see it again.")
  1072. end -- function shipspam_hide
  1073.  
  1074. require "pairsbykeys"
  1075.  
  1076. --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"}
  1077. local init_channel_names = {"Turbos","Lasers","Ions","Missiles","Rockets","Pulses","Tractors"}
  1078. channels_table = {}
  1079. loadstring(GetVariable("channels_table") or "")()
  1080.  
  1081. function addNewChannel(name)
  1082. if not channels_table[name] then
  1083. channels_table[name] = {capture=true}
  1084. end
  1085. end
  1086.  
  1087. function constructDefaultChannels()
  1088. for i,v in ipairs(init_channel_names) do
  1089. addNewChannel(v)
  1090. end
  1091. end
  1092.  
  1093. constructDefaultChannels()
  1094.  
  1095. -- right click menu
  1096. function right_click_menu (hotspot_id)
  1097. hotspots = {scroller=true, resize=true, down=true, up=true, textarea=true}
  1098. menustring ="!"
  1099. local hyperlink_skip = 0
  1100. local echo_skip = 0
  1101. local url = ""
  1102. if (WindowInfo(win, 15) > TITLE_HEIGHT) and not hotspots[hotspot_id] then
  1103. hyperlink_skip = 2
  1104. menustring = menustring.."Go to URL: "..hyperlinks[hotspot_id].."|Copy URL to Clipboard|-|"
  1105. url = hyperlinks[hotspot_id]
  1106. end
  1107. menustring = menustring.."Copy Selected Without Colors|Copy Selected|Copy All|-|Rename Window|Change Font"
  1108. 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|<|-"
  1109.  
  1110.  
  1111. menustring = menustring .. "|>Capture Spam Types|"..
  1112. ((show_turbos==1 and "+") or "")..
  1113. "Turbolasers|"..
  1114. ((show_lasers==1 and "+") or "")..
  1115. "Lasers|"..
  1116. ((show_ions==1 and "+") or "")..
  1117. "Ions|"..
  1118. ((show_missiles==1 and "+") or "")..
  1119. "Missiles|"..
  1120. ((show_torpedos==1 and "+") or "")..
  1121. "Torpedos|"..
  1122. ((show_rockets==1 and "+") or "")..
  1123. "Rockets|"..
  1124. ((show_pulses==1 and "+") or "")..
  1125. "Pulses|"..
  1126. ((show_tractors==1 and "+") or "")..
  1127. "Tractorbeams|"..
  1128. "<"
  1129.  
  1130.  
  1131.  
  1132. menustring = menustring .. "|>Echo Spam Types in Main Window|"..
  1133. ((turbos_echo==0 and "+") or "").. "Turbolasers|"..
  1134. ((lasers_echo==0 and "+") or "").. "Lasers|"..
  1135. ((ions_echo==0 and "+") or "").. "Ions|"..
  1136. ((missiles_echo==0 and "+") or "").. "Missiles|"..
  1137. ((torpedos_echo==0 and "+") or "").. "Torpedos|"..
  1138. ((rockets_echo==0 and "+") or "").. "Rockets|"..
  1139. ((pulses_echo==0 and "+") or "").. "Pulses|"..
  1140. ((tractors_echo==0 and "+") or "").. "Tractorbeams|"..
  1141. "<|-"
  1142.  
  1143.  
  1144. -- if (IsPluginInstalled("55616ea13339bc68e963e1f8")) then
  1145. -- info_echo = not GetPluginTriggerInfo ("55616ea13339bc68e963e1f8", "info", 8)
  1146. -- remort_auction_echo = not GetPluginTriggerInfo ("55616ea13339bc68e963e1f8", "remort_auction", 8)
  1147. -- pray_echo = not GetPluginTriggerInfo("55616ea13339bc68e963e1f8", "pray", 8)
  1148. -- warfare_echo = not GetPluginTriggerInfo("55616ea13339bc68e963e1f8", "warfare", 8)
  1149. -- global_quest_echo = not GetPluginTriggerInfo ("55616ea13339bc68e963e1f8", "global_quest", 8)
  1150. -- donations_echo = not GetPluginTriggerInfo ("55616ea13339bc68e963e1f8", "donations", 8)
  1151. -- 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:|".."<|<"
  1152. -- echo_skip = 9
  1153. -- end
  1154.  
  1155. --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"
  1156. menustring = menustring .. "|>Logging To File|"..
  1157. ((log_to_file==1 and "Disable|") or "Enable|")..
  1158. "Choose log file|"..
  1159. ((log_colour_codes==0 and "+") or "")..
  1160. "Remove Color Codes|"..
  1161. ((log_timestamps==0 and "+") or "")..
  1162. "Remove Timestamps|<|-"
  1163. result = WindowMenu (win,
  1164. WindowInfo (win, 14), -- x position
  1165. WindowInfo (win, 15), -- y position
  1166. menustring) -- content
  1167. if result ~= "" then
  1168. numResult = tonumber(result)
  1169. if numResult == hyperlink_skip-1 then
  1170. local res = OpenBrowser(url)
  1171. if res ~= 0 then
  1172. SetClipboard(url)
  1173. ColourNote("yellow", "red", "MUSHclient may have encountered an error trying to open the selected URL. It has been copied to the clipboard.")
  1174. ColourNote("cyan","","v-------------------Copied to clipboard-------------------v")
  1175. ColourNote("yellow","",url)
  1176. ColourNote("cyan","","^---------------------------------------------------------^")
  1177. end
  1178. elseif numResult == hyperlink_skip then
  1179. SetClipboard(url)
  1180. ColourNote("cyan","","v-------------------Copied to clipboard-------------------v")
  1181. ColourNote("yellow","",url)
  1182. ColourNote("cyan","","^---------------------------------------------------------^")
  1183. elseif numResult == 1+hyperlink_skip then
  1184. if #copied_text > 0 then
  1185. local declored_text = strip_colours(copied_text)
  1186. SetClipboard(declored_text)
  1187. ColourNote("cyan","","v-------------------Copied to clipboard-------------------v")
  1188. ColourNote("yellow","",declored_text)
  1189. ColourNote("cyan","","^---------------------------------------------------------^")
  1190. end
  1191. elseif numResult == 2+hyperlink_skip then
  1192. if #copied_text > 0 then
  1193. SetClipboard(copied_text)
  1194. ColourNote("cyan","","v-------------------Copied to clipboard-------------------v")
  1195. ColourNote("yellow","",copied_text)
  1196. ColourNote("cyan","","^---------------------------------------------------------^")
  1197. end
  1198. elseif numResult == 3+hyperlink_skip then
  1199. GetAllBufferedMessages()
  1200. ColourNote ("yellow", "", "All chat messages copied to clipboard.")
  1201. elseif numResult == 4+hyperlink_skip then
  1202. wanted_name = utils.inputbox("Choose a new name for this window:", "Window name", WINDOW_NAME, GetVariable("font_name"), GetVariable("font_size"))
  1203. if wanted_name then
  1204. WINDOW_NAME = wanted_name
  1205. SetVariable("WINDOW_NAME", WINDOW_NAME)
  1206. OnPluginInstall()
  1207. end
  1208. elseif numResult == 5+hyperlink_skip then
  1209. wanted_font = utils.fontpicker (font_name, font_size) --font dialog
  1210. if wanted_font then
  1211. font_name = wanted_font.name
  1212. font_size = wanted_font.size
  1213. SetVariable ("font_name", font_name)
  1214. SetVariable ("font_size", font_size)
  1215. OnPluginInstall()
  1216. end
  1217. elseif numResult == 6+hyperlink_skip then
  1218. date_format = ""
  1219. ColourNote ("yellow", "", "Timestamps in shipspam window DISABLED.")
  1220. elseif numResult == 7+hyperlink_skip then
  1221. date_format = "[%d %b %H:%M:%S] "
  1222. ColourNote ("yellow", "", "Timestamps in shipspam window ENABLED using format like '30 Aug 13:29:49'.")
  1223. elseif numResult == 8+hyperlink_skip then
  1224. date_format = "[%d %b %I:%M:%S%p] "
  1225. ColourNote ("yellow", "", "Timestamps in shipspam window ENABLED using format like '30 Aug 01:20:12PM'.")
  1226. elseif numResult == 9+hyperlink_skip then
  1227. date_format = "[%H:%M:%S] "
  1228. ColourNote ("yellow", "", "Timestamps in shipspam window ENABLED using format like '13:29:08'.")
  1229. elseif numResult == 10+hyperlink_skip then
  1230. date_format = "[%I:%M:%S%p] "
  1231. ColourNote ("yellow", "", "Timestamps in shipspam window ENABLED using format like '1:22:06 PM'.")
  1232. elseif numResult == 11+hyperlink_skip then
  1233. --local tbl = {}
  1234. --local defaults = {}
  1235. --local i = 1
  1236. --for k,v in pairsByKeys(channels_table) do
  1237. -- tbl[i] = k
  1238. -- defaults[i] = v["capture"]
  1239. -- i = i+1
  1240. --end
  1241. --local capture_result = utils.multilistbox ("Choose which actions to capture to this shipspam log window.", "ShipSpam Log Actions Selection", tbl, defaults)
  1242. --if capture_result and next(capture_result) then -- cancel if the list is empty
  1243. -- for i,v in ipairs(tbl) do
  1244. -- channels_table[v]["capture"] = capture_result[i]
  1245. -- end
  1246. --end
  1247.  
  1248. if show_turbos == 0 then
  1249. ColourNote("yellow","","Turbolaser capturing is now ENABLED.")
  1250. else
  1251. ColourNote("yellow","","Turbolaser capturing is now DISABLED.")
  1252. end
  1253. EnableTrigger("turbos", 0 == show_turbos)
  1254. show_turbos = GetTriggerOption("turbos", "enabled")
  1255. elseif numResult == 12+hyperlink_skip then
  1256. if show_lasers == 0 then
  1257. ColourNote ("yellow", "", "Laser capturing is now ENABLED.")
  1258. else
  1259. ColourNote ("yellow", "", "Laser capturing is now DISABLED.")
  1260. end
  1261. EnableTrigger("lasers", 0 == show_lasers)
  1262. show_lasers = GetTriggerOption("lasers","enabled")
  1263. elseif numResult == 13+hyperlink_skip then
  1264. if show_ions == 0 then
  1265. ColourNote ("yellow", "", "Ion capturing is now ENABLED.")
  1266. else
  1267. ColourNote ("yellow", "", "Ion capturing is now DISABLED.")
  1268. end
  1269. EnableTrigger("ions", 0 == show_ions)
  1270. show_ions = GetTriggerOption("ions","enabled")
  1271. elseif numResult == 14+hyperlink_skip then
  1272. if show_missiles == 0 then
  1273. ColourNote ("yellow", "", "Missile capturing is now ENABLED.")
  1274. else
  1275. ColourNote ("yellow", "", "Missile capturing is now DISABLED.")
  1276. end
  1277. EnableTrigger("missiles", 0 == show_missiles)
  1278. show_missiles = GetTriggerOption("missiles","enabled")
  1279. elseif numResult == 15+hyperlink_skip then
  1280. if show_torpedos == 0 then
  1281. ColourNote ("yellow", "", "Torpedo capturing is now ENABLED.")
  1282. else
  1283. ColourNote ("yellow", "", "Torpedo capturing is now DISABLED.")
  1284. end
  1285. EnableTrigger("torpedos", 0 == show_torpedos)
  1286. show_torpedos = GetTriggerOption("torpedos","enabled")
  1287. elseif numResult == 16+hyperlink_skip then
  1288. if show_rockets == 0 then
  1289. ColourNote ("yellow", "", "Rocket capturing is now ENABLED.")
  1290. else
  1291. ColourNote ("yellow", "", "Rocket capturing is now DISABLED.")
  1292. end
  1293. EnableTrigger("rockets", 0 == show_rockets)
  1294. show_rockets = GetTriggerOption("rockets","enabled")
  1295. elseif numResult == 17+hyperlink_skip then
  1296. if show_pulses == 0 then
  1297. ColourNote ("yellow", "", "Pulse capturing is now ENABLED.")
  1298. else
  1299. ColourNote ("yellow", "", "Pulse capturing is now DISABLED.")
  1300. end
  1301. EnableTrigger("pulses", 0 == show_pulses)
  1302. show_pulses = GetTriggerOption("pulses","enabled")
  1303. elseif numResult == 18+hyperlink_skip then
  1304. if show_tractors == 0 then
  1305. ColourNote ("yellow", "", "Tractor beam capturing is now ENABLED.")
  1306. else
  1307. ColourNote ("yellow", "", "Tractor beam capturing is now DISABLED.")
  1308. end
  1309. EnableTrigger("tractors", 0 == show_tractors)
  1310. show_tractors = GetTriggerOption("tractors","enabled")
  1311. end
  1312.  
  1313. if numResult == 19+hyperlink_skip then
  1314. if turbos_echo == 0 then
  1315. ColourNote("yellow", "", "Turbolasers will NOT be shown in the main window.")
  1316. else
  1317. ColourNote("yellow", "", "Turbolasers will be shown in the main window.")
  1318. end
  1319. SetTriggerOption("turbos", "omit_from_output", 0 == turbos_echo)
  1320. turbos_echo = GetTriggerOption("turbos", "omit_from_output")
  1321. elseif numResult == 20+hyperlink_skip then
  1322. if lasers_echo == 0 then
  1323. ColourNote("yellow", "", "Lasers will NOT be shown in the main window.")
  1324. else
  1325. ColourNote("yellow", "", "Lasers will be shown in the main window.")
  1326. end
  1327. SetTriggerOption("lasers", "omit_from_output", 0 == lasers_echo)
  1328. lasers_echo = GetTriggerOption("lasers", "omit_from_output")
  1329. elseif numResult == 21+hyperlink_skip then
  1330. if ions_echo == 0 then
  1331. ColourNote("yellow", "", "Ions will NOT be shown in the main window.")
  1332. else
  1333. ColourNote("yellow", "", "Ions will be shown in the main window.")
  1334. end
  1335. SetTriggerOption("ions", "omit_from_output", 0 == ions_echo)
  1336. ions_echo = GetTriggerOption("ions", "omit_from_output")
  1337. elseif numResult == 22+hyperlink_skip then
  1338. if missiles_echo == 0 then
  1339. ColourNote("yellow", "", "Missiles will NOT be shown in the main window.")
  1340. else
  1341. ColourNote("yellow", "", "Missiles will be shown in the main window.")
  1342. end
  1343. SetTriggerOption("missiles", "omit_from_output", 0 == missiles_echo)
  1344. missiles_echo = GetTriggerOption("missiles", "omit_from_output")
  1345. elseif numResult == 23+hyperlink_skip then
  1346. if torpedos_echo == 0 then
  1347. ColourNote("yellow", "", "Torpedos will NOT be shown in the main window.")
  1348. else
  1349. ColourNote("yellow", "", "Torpedos will be shown in the main window.")
  1350. end
  1351. SetTriggerOption("torpedos", "omit_from_output", 0 == torpedos_echo)
  1352. torpedos_echo = GetTriggerOption("torpedos", "omit_from_output")
  1353. elseif numResult == 24+hyperlink_skip then
  1354. if rockets_echo == 0 then
  1355. ColourNote("yellow", "", "Rockets will NOT be shown in the main window.")
  1356. else
  1357. ColourNote("yellow", "", "Rockets will be shown in the main window.")
  1358. end
  1359. SetTriggerOption("rockets", "omit_from_output", 0 == rockets_echo)
  1360. rockets_echo = GetTriggerOption("rockets", "omit_from_output")
  1361. elseif numResult == 25+hyperlink_skip then
  1362. if pulses_echo == 0 then
  1363. ColourNote("yellow", "", "Pulses will NOT be shown in the main window.")
  1364. else
  1365. ColourNote("yellow", "", "Pulses will be shown in the main window.")
  1366. end
  1367. SetTriggerOption("pulses", "omit_from_output", 0 == pulses_echo)
  1368. pulses_echo = GetTriggerOption("pulses", "omit_from_output")
  1369. elseif numResult == 26+hyperlink_skip then
  1370. if tractors_echo == 0 then
  1371. ColourNote("yellow", "", "Tractorbeams will NOT be shown in the main window.")
  1372. else
  1373. ColourNote("yellow", "", "Tractorbeams will be shown in the main window.")
  1374. end
  1375. SetTriggerOption("tractors", "omit_from_output", 0 == tractors_echo)
  1376. tractors_echo = GetTriggerOption("tractors", "omit_from_output")
  1377. end
  1378.  
  1379. --if echo_skip ~= 0 then
  1380. -- if numResult == 17+hyperlink_skip then
  1381. -- Execute("chats echo on")
  1382. -- elseif numResult == 17+hyperlink_skip+1 then
  1383. -- Execute("chats echo off")
  1384. -- elseif numResult == 17+hyperlink_skip+2 then
  1385. -- Execute("chats echo custom")
  1386. -- elseif numResult == 17+hyperlink_skip+3 then
  1387. -- --CallPlugin("55616ea13339bc68e963e1f8", "hideEchos", info_echo, nil, nil, nil, nil, nil)
  1388. -- elseif numResult == 17+hyperlink_skip+4 then
  1389. -- --CallPlugin("55616ea13339bc68e963e1f8", "hideEchos", nil, global_quest_echo, nil, nil, nil, nil)
  1390. -- elseif numResult == 17+hyperlink_skip+5 then
  1391. -- --CallPlugin("55616ea13339bc68e963e1f8", "hideEchos", nil, nil, remort_auction_echo, nil, nil, nil)
  1392. -- elseif numResult == 17+hyperlink_skip+6 then
  1393. -- --CallPlugin("55616ea13339bc68e963e1f8", "hideEchos", nil, nil, nil, donations_echo, nil, nil)
  1394. -- elseif numResult == 17+hyperlink_skip+7 then
  1395. -- --CallPlugin("55616ea13339bc68e963e1f8", "hideEchos", nil, nil, nil, nil, pray_echo, nil)
  1396. -- elseif numResult == 17+hyperlink_skip+8 then
  1397. -- --CallPlugin("55616ea13339bc68e963e1f8", "hideEchos", nil, nil, nil, nil, nil, warfare_echo)
  1398. -- end
  1399. --end
  1400.  
  1401. if numResult == 31+hyperlink_skip+echo_skip then
  1402. log_to_file = (((0 == log_to_file) and 1) or 0)
  1403. SetVariable("log_to_file", log_to_file)
  1404. if log_to_file == 0 then
  1405. ColourNote ("yellow", "", "Logging to file is now DISABLED.")
  1406. else
  1407. ColourNote ("yellow", "", "Logging to file is now ENABLED.")
  1408. end
  1409. elseif numResult == 32+hyperlink_skip+echo_skip then
  1410. local newfile = utils.filepicker ("Choose log file...", "ChatLog.txt", "txt", { txt = "Text log file" }, true )
  1411. if newfile then
  1412. log_filename = newfile
  1413. ColourNote ("yellow", "", "Logging chat to "..log_filename..".")
  1414. end
  1415. elseif numResult == 33+hyperlink_skip+echo_skip then
  1416. log_colour_codes = (((0 == log_colour_codes) and 1) or 0)
  1417. SetVariable("log_colour_codes", log_colour_codes)
  1418. if log_colour_codes == 0 then
  1419. ColourNote ("yellow", "", "Color codes will be stripped from the log file.")
  1420. else
  1421. ColourNote ("yellow", "", "Color codes will be included in the log file.")
  1422. end
  1423. elseif numResult == 34+hyperlink_skip+echo_skip then
  1424. log_timestamps = (((0 == log_timestamps) and 1) or 0)
  1425. SetVariable("log_timestamps", log_timestamps)
  1426. if log_timestamps == 0 then
  1427. ColourNote ("yellow", "", "Timestamps will not be included in the log file.")
  1428. else
  1429. ColourNote ("yellow", "", "Timestamps will be included in the log file.")
  1430. end
  1431. --elseif numResult == 20+hyperlink_skip+echo_skip then
  1432. --CallPlugin("462b665ecb569efbf261422f","boostMe", win)
  1433. --elseif numResult == 21+hyperlink_skip+echo_skip then
  1434. --CallPlugin("462b665ecb569efbf261422f","dropMe", win)
  1435. end
  1436. OnPluginSaveState()
  1437. end
  1438. end -- right_click_menu
  1439.  
  1440. ]]>
  1441. </script>
  1442. </muclient>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement