· 5 years ago · Aug 14, 2020, 12:08 PM
1<?xml version="1.0" encoding="iso-8859-1"?>
2<!DOCTYPE muclient>
3
4<!-- SpeedTest by Reva, now in milliiSeconds (note it is slightly innacurate)! -->
5<!-- Match start line to time to 'StartTiming' trigger at end of file. -->
6<!-- Match end line to 'EndTiming' trigger at end of file. -->
7
8<muclient>
9<plugin
10 name="SailMate"
11 author="Reva"
12 id="4ebe57445bbefe3429c562c4"
13 language="Lua"
14 purpose="Sail Stats and Timers"
15 date_written="2020-07-21"
16 date_modified="2018-07-21"
17 save_state="y"
18 requires="4.84"
19 version="3"
20 >
21</plugin>
22<script>
23<![CDATA[
24--json seems to not save tables right...
25require "serialize" -- needed to serialize table to string
26
27function SailMateHelp()
28 Note("")
29 ColourNote(SailStatWin["colour"]["text1"], "", "SailMate "..GetPluginInfo (GetPluginID (), 19).." by Reva")
30 ColourNote(SailStatWin["colour"]["text1"], "", " >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< ><")
31 ColourNote(SailStatWin["colour"]["text1"], "", "* Timers, stats, and compass for sailing.")
32 ColourTell(SailStatWin["colour"]["text1"], "", "* Timers for cooldown")
33 if #CDWin["notes"] > 0 then
34 ColourTell(SailStatWin["colour"]["text1"], "", ", ")
35 for i, v in ipairs (CDWin["notes"]) do
36 if i ~= 1 then
37 ColourTell(SailStatWin["colour"]["text1"], "", ", " .. tostring(v))
38 else
39 ColourTell(SailStatWin["colour"]["text1"], "", tostring(v))
40 end
41 end
42 ColourNote(SailStatWin["colour"]["text1"], "", " minute warnings.")
43
44 else
45 ColourNote(SailStatWin["colour"]["text1"], "", ".")
46 end
47 Note("")
48 ColourNote(SailStatWin["colour"]["text1"], "", "Right-click on miniwindows for options.")
49 Note("")
50 ColourNote(SailStatWin["colour"]["text1"], "", "Commands:")
51 ColourNote(SailStatWin["colour"]["text1"], "", " 'sail(mate) help' - This help screen.")
52 ColourNote(SailStatWin["colour"]["text1"], "", " 'sail(mate) show' - Show the cooldown window to be able to get options.")
53 ColourNote(SailStatWin["colour"]["text1"], "", " 'sail(mate) display[ full]' - Display current or previous sail stats, 'full' for individual stages.")
54 ColourNote(SailStatWin["colour"]["text1"], "", " 'sail(mate) gdisplay[ full]' - Group chat current or previous sail stats, 'full' for individual stages.")
55 ColourNote(SailStatWin["colour"]["text1"], "", " 'sail(mate) (cooldown\\cd\\timer)' - Display cooldown timer.")
56 ColourNote(SailStatWin["colour"]["text1"], "", " 'sail(mate) reset' - Reset timers and stats. WARNING: If done mid-sail it will discontinue until next sail.")
57 Note("")
58end
59
60function SailReset(sArg)
61 if sArg == nil then
62 sArg = "all"
63 end
64
65 if sArg == "cd" or sArg == "cooldown" or sArg == "all" then
66 EnableTimer("cdwin_tic", false)
67 CDWin = {
68 ["name"] = "cdwin" .. GetPluginID (),
69 ["notes"] = {
70 10, 5,
71 ["show"] = true,
72 },
73 ["font"] = "Consolas",
74 ["font_size"] = 9,
75 ["padding"] = 2.5,
76 ["cd_text"] = "[SM]",
77 ["colour"] = {
78 ["text1"] = "limegreen",
79 ["text2"] = "white",
80 ["border1"] = "limegreen",
81 ["border2"] = "green",
82 ["back"] = "black",
83 ["time"] = {
84 {10, "yellow"},
85 {5, "red"}
86 }
87 },
88 ["display"] = true,
89 ["dragging"] = false,
90 }
91
92 WindowFont (CDWin["name"], "f", CDWin["font"], CDWin["font_size"], false, false, false, false)
93 CDWin["font_height"] = WindowFontInfo (CDWin["name"], "f", 1)
94 ResizeCDWin()
95 WindowShow(CDWin["name"], CDWin["display"])
96 WindowPosition(CDWin["name"], 0, 0, miniwin.pos_center_all, 2)
97 UpdateCDWinStatic()
98 end
99
100 if sArg == "sailstat" or sArg == "all" then
101 EnableTimer("sailstatwin_tic", false)
102 EnableTriggerGroup("MidSail", false)
103
104 SailStatWin = {
105 ["name"] = "sailstatwin" .. GetPluginID (),
106 ["font"] = "Consolas",
107 ["font_size"] = 9,
108 ["padding"] = 2.5,
109 ["colour"] = {
110 ["text1"] = "limegreen",
111 ["text2"] = "white",
112 ["border1"] = "limegreen",
113 ["border2"] = "green",
114 ["back"] = "black",
115 },
116 ["display"] = {
117 ["notes"] = true,
118 ["window"] = "always", --always, sailing, never
119 ["secs"] = 15,
120 ["time"] = true,
121 ["xp_gained"] = true,
122 ["rate"] = true,
123 },
124 ["display_monster"] = false, --to display monster stats or not
125 ["dragging"] = false,
126 }
127
128 WindowFont (SailStatWin["name"], "f", SailStatWin["font"], SailStatWin["font_size"], false, false, false, false)
129 SailStatWin["font_height"] = WindowFontInfo (SailStatWin["name"], "f", 1)
130 ResizeSailStatWin()
131 if SailStatWin["display"]["window"] == "always" then
132 WindowShow(SailStatWin["name"], true)
133 end
134 if SailStatWin["display"]["window"] == "sailing" and bIsSailing == true then
135 WindowShow(SailStatWin["name"], true)
136 end
137 if CDWin["height"] ~= nil then
138 WindowPosition(SailStatWin["name"], 0, CDWin["height"], miniwin.pos_center_all, 2)
139 else
140 WindowPosition(SailStatWin["name"], 0, SailStatWin["font_height"] + (SailStatWin["padding"] * 2), miniwin.pos_center_all, 2)
141 end
142 UpdateSailStatWin()
143 end
144
145 if sArg == "compass" or sArg == "all" then
146
147 CompassWin = {
148 ["name"] = "compass" .. GetPluginID (),
149 ["font"] = "Consolas",
150 ["font_size"] = 9,
151 ["padding"] = 2.5,
152 ["colour"] = {
153 ["text1"] = "limegreen",
154 --["text2"] = "white",
155 ["border1"] = "limegreen",
156 ["border2"] = "green",
157 ["back"] = "black",
158 },
159 ["north"] = "hubwards",
160 ["size"] = "medium", --full, medium, short
161 ["display"] = "never",--always, sailing, never
162 ["dragging"] = false,
163 }
164
165 CompassWin["font_height"] = WindowFontInfo (CompassWin["name"], "f", 1)
166 ResizeCompassWin()
167 if CompassWin["display"]["window"] == "always" then
168 WindowShow(CompassWin["name"], true)
169 end
170 if CompassWin["display"]["window"] == "sailing" and bIsSailing == true then
171 WindowShow(CompassWin["name"], true)
172 end
173
174 if CDWin["height"] ~= nil and CDWin["display"] == true then
175 if SailStatWin["height"] ~= nil and SailStatWin["display"]["window"] == "always" then
176 WindowPosition(CompassWin["name"], 0, CDWin["height"] + SailStatWin["height"], miniwin.pos_center_all, 2)
177 elseif SailStatWin["height"] ~= nil and SailStatWin["display"]["window"] == "sailing" and bIsSailing == true then
178 WindowPosition(CompassWin["name"], 0, CDWin["height"] + SailStatWin["height"], miniwin.pos_center_all, 2)
179 else
180 if SailStatWin["display_monster"] == true then
181 WindowPosition(CompassWin["name"], 0, CDWin["height"] + (CompassWin["font_height"]*7)+(CompassWin["padding"]*2), miniwin.pos_center_all, 2)
182 else
183 WindowPosition(CompassWin["name"], 0, CDWin["height"] + (CompassWin["font_height"]*6)+(CompassWin["padding"]*2), miniwin.pos_center_all, 2)
184 end
185 end
186 elseif SailStatWin["height"] ~= nil and SailStatWin["display"]["window"] == "always" then
187 WindowPosition(CompassWin["name"], 0, WindowInfo(SailStatWin["name"], 2) + SailStatWin["height"], miniwin.pos_center_all, 2)
188 elseif SailStatWin["height"] ~= nil and SailStatWin["display"]["window"] == "sailing" and bIsSailing == true then
189 WindowPosition(CompassWin["name"], 0, WindowInfo(SailStatWin["name"], 2) + SailStatWin["height"], miniwin.pos_center_all, 2)
190 else
191 if CompassWin["display_monster"] == true then
192 WindowPosition(CompassWin["name"], 0, (CompassWin["font_height"]*8) + (CompassWin["padding"] * 4), miniwin.pos_center_all, 2)
193 else
194 WindowPosition(CompassWin["name"], 0, (CompassWin["font_height"]*7) + (CompassWin["padding"] * 4), miniwin.pos_center_all, 2)
195 end
196 end
197
198 UpdateCompassWin()
199 end
200
201 if sArg == "all" then
202 bIsSailing = false
203 Sail = {
204 ["monster"] = {}
205 }
206
207 --Delete
208 local tTimers = GetTimerList ()
209 if tTimers then
210 for k, v in ipairs (tTimers) do
211 if string.match(v, "tic") == nil then
212 DeleteTimer(v)
213 end
214 end -- for
215 end -- if we have any timers
216 SMNote("Miniwindows, timers, and stats reset.")
217 end
218
219 if sArg == "cd" or sArg == "cooldown" then
220 SMNote("Cooldown miniwindow reset.")
221 elseif sArg == "sailstat" then
222 SMNote("Sail stats miniwindow reset.")
223 elseif sArg == "compass" then
224 SMNote("Compass miniwindow reset.")
225 end
226end
227
228function OnPluginSaveState()
229 SetVariable("iSaveTime", tostring(os.time()))
230 SetVariable("iCDSeconds", tostring(GetTimerInfo("SailCooldownOver", 13)))
231 SetVariable("bIsSailing", tostring(bIsSailing))
232 --using serialize to preserve sail stuff as json messes it up...
233 SetVariable ("Sail", "Sail = " .. serialize.save_simple (Sail))
234 SetVariable("sFirstTime", sFirstTime)
235 CDWin["pos_x"] = WindowInfo (CDWin["name"], 10)
236 CDWin["pos_y"] = WindowInfo (CDWin["name"], 11)
237 SetVariable ("CDWin", "CDWin = " .. serialize.save_simple (CDWin))
238 SailStatWin["pos_x"] = WindowInfo (SailStatWin["name"], 10)
239 SailStatWin["pos_y"] = WindowInfo (SailStatWin["name"], 11)
240 SetVariable ("SailStatWin", "SailStatWin = " .. serialize.save_simple (SailStatWin))
241 CompassWin["pos_x"] = WindowInfo (CompassWin["name"], 10)
242 CompassWin["pos_y"] = WindowInfo (CompassWin["name"], 11)
243 SetVariable ("CompassWin", "CompassWin = " .. serialize.save_simple (CompassWin))
244end
245
246function OnPluginInstall()
247 iCDSeconds = 0
248 if GetVariable("iCDSeconds") ~= nil and GetVariable("iCDSeconds") ~= "nil" then
249 iCDSeconds = tonumber(GetVariable("iCDSeconds") )
250 end
251 iSaveTime = GetVariable("iSaveTime")
252 if iCDSeconds ~= 0 and iSaveTime ~= nil then
253 if iCDSeconds - (os.time() - iSaveTime) > 0 then
254 CreateCooldownTimers(iCDSeconds - (os.time() - iSaveTime))
255 end
256 end
257end
258
259bIsSailing = false
260if GetVariable ("bIsSailing") == "true" then
261 bIsSailing = true
262 EnableTriggerGroup("MidSail", true)
263 EnableTimer("sailstatwin_tic", true)
264end
265
266Sail = {
267["monster"] = {}
268}
269assert (loadstring (GetVariable ("Sail") or "")) ()
270
271sFirstTime = "true"
272if GetVariable("sFirstTime") ~= nil then
273 sFirstTime = GetVariable("sFirstTime")
274end
275if sFirstTime ~= "version_" .. tostring(GetPluginInfo(GetPluginID(), 19)) then
276 DoAfterSpecial (0.5, 'SailMateHelp()', sendto.script)
277 sFirstTime = "version_" .. tostring(GetPluginInfo(GetPluginID(), 19))
278end
279
280StagesToNumber = {
281["first"] = 1,
282["second"] = 2,
283["third"] = 3,
284}
285
286function FormatElapsedTime(iStart, iFinish)
287 local iSeconds = (iFinish - iStart)
288 return TimeFormat(iSeconds)
289end
290
291--if less than 100m return +99m, under that return mins+secs
292function TimeFormat(iSeconds)
293 local iHours = 0
294 local iMins = 0
295 local iSecs = 0
296
297 if iSeconds <= 0 then
298 return "00s"
299 else
300 --if iSeconds >= 3600 then
301 if iSeconds >= 6000 then
302 return "99m+"
303 else
304 iMins = string.format("%02.f", math.floor(iSeconds/60))
305 end
306 iSecs = string.format("%02.f", math.floor(iSeconds - iMins *60))
307 return iMins..":"..iSecs.."s"
308 end
309end
310
311LastSail = {}
312function RealStartSail (sName, sLine, wildcards, styles)
313 --this is to try weeding out if he says it to someone else, we'll start timer but check that it makes sense later
314 bUncertainStart = false
315 --manual testing how long this takes
316 iTestTime = GetInfo(232)
317 --well, now we know...
318 if wildcards.who == "you" then
319 bIsSailing = true
320
321 if SailStatWin["display"]["window"] ~= "never" then
322 EnableTimer("sailstatwin_tic", true)
323 WindowShow(SailStatWin["name"], true)
324 end
325
326 EnableTriggerGroup("MidSail", true)
327
328 --save as last, clear table
329 LastSail = Sail
330 Sail = {
331 ["monster"] = {}
332 }
333 local stage_name = "Search"
334 local start_time = GetInfo(232)
335 local end_time = 0
336 --local start_xp = iCurrentXp or 0
337 --local end_xp = 0
338 local xp_gained = 0
339
340 table.insert(Sail, {["stage"] = stage_name, ["start"] = start_time, ["end"] = end_time, ["xp_gained"] = xp_gained})
341
342 if SailStatWin["display"]["notes"] == true then
343 ColourTell(SailStatWin["colour"]["text2"], "", "[")
344 ColourTell(SailStatWin["colour"]["text1"], "", "Starting Sail Timer")
345 ColourNote(SailStatWin["colour"]["text2"], "", "]")
346 end
347 if SailStatWin["display"]["window"] ~= "never" then
348 UpdateSailStatWin()
349 end
350 else
351 bUncertainStart = true
352 iUncertainTime = GetInfo(232)
353 end
354 --bIsSailing = true
355 --EnableTriggerGroup("MidSail", true)
356end
357
358function StartSail (sName, sLine, wildcards, styles)
359 --in case of missing the real start, not understanding language, etc.
360 if bIsSailing == false then
361 iUncertainTime = GetInfo(232)
362 bUncertainStart = true
363 bIsSailing = true
364 EnableTimer("sailstatwin_tic", true)
365 end
366
367 --for testing for now
368 --[[
369 if iTestTime ~= nil then
370 --Note("Test time is: " .. FormatElapsedTime(iTestTime, GetInfo(232)))
371 end
372 ]]--
373 if bUncertainStart == true then
374
375 if SailStatWin["display"]["window"] ~= "never" then
376 EnableTimer("sailstatwin_tic", true)
377 WindowShow(SailStatWin["name"], true)
378 end
379
380 --save as last, clear table
381 LastSail = Sail
382 Sail = {
383 ["monster"] = {}
384 }
385 local stage_name = "Search"
386 local start_time = GetInfo(232)
387 local end_time = 0
388 local xp_gained = 0
389
390 --if so assume that was our queue... if not we'll just have to wing it, seems it is 11s
391 if start_time - iUncertainTime <= 13 and start_time - iUncertainTime >= 9 then
392 --Note("Reverting to old time...")
393 start_time = iUncertainTime
394 else
395 start_time = start_time - 11
396 end
397
398 table.insert(Sail, {["stage"] = stage_name, ["start"] = start_time, ["end"] = end_time, ["xp_gained"] = xp_gained})
399
400 if SailStatWin["display"]["notes"] == true then
401 ColourTell(SailStatWin["colour"]["text2"], "", "[")
402 ColourTell(SailStatWin["colour"]["text1"], "", "Starting Sail Timer ("..FormatElapsedTime(start_time, GetInfo(232))..")")
403 ColourNote(SailStatWin["colour"]["text2"], "", "]")
404 end
405 EnableTriggerGroup("MidSail", true)
406 if SailStatWin["display"]["sail"] ~= "never" then
407 UpdateSailStatWin()
408 end
409 bUncertainStart = false
410 end
411end
412
413function FinishSearch(sName, sLine, wildcards, styles)
414--Note("search finished...")
415 if bIsSailing == false then
416 EnableTriggerGroup("MidSail", false)
417 return
418 end
419
420 --finish stats from previous stage
421 Sail[#Sail]["end"] = GetInfo(232)
422 --Sail[#Sail]["end_xp"] = iCurrentXp
423 DisplayStageStats(#Sail)
424
425 --now to deal with the new stage...
426 local stage_name = "Leg 1"
427 local start_time = GetInfo(232)
428 local end_time = 0
429 --local start_xp = iCurrentXp or 0
430 --local end_xp = 0
431 local xp_gained = 0
432
433 table.insert(Sail, {["stage"] = stage_name, ["start"] = start_time, ["end"] = end_time, ["xp_gained"] = xp_gained})
434
435 if SailStatWin["display"]["sail"] ~= "never" then
436 UpdateSailStatWin()
437 end
438 --lets not trigger this again
439 EnableTrigger("FirstMovement", false)
440end
441
442function FinishStage(sName, sLine, wildcards, styles)
443 if bIsSailing == false then
444 EnableTriggerGroup("MidSail", false)
445 return
446 end
447
448 --finish stats from previous stage
449 Sail[#Sail]["end"] = GetInfo(232)
450 Sail[#Sail]["xp_gained"] = tonumber(wildcards.xp)
451 DisplayStageStats(#Sail)
452
453 local stage_name = "Leg " .. tostring(StagesToNumber[wildcards.stage] + 1)
454 local start_time = GetInfo(232)
455 local end_time = 0
456 local xp_gained = 0
457
458 --DisplayStageStats(#Sail)
459 table.insert(Sail, {["stage"] = stage_name, ["start"] = start_time, ["end"] = end_time, ["xp_gained"] = xp_gained})
460 if SailStatWin["display"]["sail"] ~= "never" then
461 UpdateSailStatWin()
462 end
463end
464
465function MonsterStart(sName, sLine, wildcards, styles)
466 if bIsSailing == false then
467 EnableTriggerGroup("MidSail", false)
468 return
469 end
470
471 local stage_name = "Monster"
472 local start_time = GetInfo(232)
473 local end_time = 0
474 local xp_gained = 0
475 local monster_type = wildcards.monster or "unknown"
476
477 Sail["monster"] ={["stage"] = stage_name, ["start"] = start_time, ["end"] = end_time, ["xp_gained"] = xp_gained, ["type"] = monster_type, ["mid"] = #Sail}
478
479 if SailStatWin["display"]["sail"] ~= "never" then
480 UpdateSailStatWin()
481 end
482end
483
484--this only triggers on the xp gained message if fought
485function MonsterEnd(sName, sLine, wildcards, styles)
486 if bIsSailing == false then
487 EnableTriggerGroup("MidSail", false)
488 return
489 end
490
491 --finish stats from previous stage
492 Sail["monster"]["end"] = GetInfo(232)
493 Sail["monster"]["xp_gained"] = tonumber(wildcards.xp)
494 Sail["monster"]["type"] = wildcards.monster
495
496 --if we fought it lets have it show in the stage we got the xp
497 Sail["monster"]["mid"] = #Sail
498
499 if SailStatWin["display"]["notes"] == true then
500 ColourTell(SailStatWin["colour"]["text2"], "", "[")
501 ColourTell(SailStatWin["colour"]["text1"], "", Sail["monster"]["stage"] .. " completed (Leg " .. tostring(#Sail - 1) .. "): ")
502 ColourTell(SailStatWin["colour"]["text1"], "", FormatElapsedTime(Sail["monster"]["start"], Sail["monster"]["end"]))
503 if Sail["monster"]["xp_gained"] ~= 0 then
504 ColourTell(SailStatWin["colour"]["text1"], "", ", " .. tostring(AddCommas(Sail["monster"]["xp_gained"])) .. " Xp")
505 ColourTell(SailStatWin["colour"]["text1"], "", " (" .. tostring(Kify(StageRate(Sail["monster"]))) .. " Xp/hr)")
506 end
507
508 ColourNote(SailStatWin["colour"]["text2"], "", "]")
509 end
510
511 if SailStatWin["display"]["sail"] ~= "never" then
512 UpdateSailStatWin()
513 end
514end
515
516function FinishSail(sName, sLine, wildcards, styles)
517 if bIsSailing == false then
518 EnableTriggerGroup("MidSail", false)
519 return
520 end
521
522 --finish stats from previous stage
523 Sail[#Sail]["end"] = GetInfo(232)
524 Sail[#Sail]["xp_gained"] = tonumber(wildcards.xp)
525 DisplayStageStats(#Sail)
526
527 EnableTriggerGroup("MidSail", false)
528 bIsSailing = false
529
530 local iTotalXP = Sail["monster"]["xp_gained"] or 0
531 --local iTotalTime = 0
532 for i, v in ipairs (Sail) do
533 iTotalXP = iTotalXP + v["xp_gained"]
534 end
535
536 local iTotalRate = CalcRate(Sail[#Sail]["end"] - Sail[1]["start"], iTotalXP)
537
538 if SailStatWin["display"]["notes"] == true then
539 ColourTell(SailStatWin["colour"]["text1"], "", "Total: " .. tostring(FormatElapsedTime(Sail[1]["start"], Sail[#Sail]["end"])) .. ", ")
540 ColourNote(SailStatWin["colour"]["text1"], "", "XP Gained: " .. tostring(AddCommas(iTotalXP)) .. " Xp (" .. Kify(iTotalRate) .. "Xp/hr).")
541 end
542
543 --Create cooldown timer, calc is 2 hrs from start.
544 local iSeconds = 7200 - (Sail[#Sail]["end"] - Sail[1]["start"])
545 CreateCooldownTimers(iSeconds)
546
547 --think we need to use os.time to not change over logons\reboots etc.
548 iLastSailTime = os.time()
549
550 if SailStatWin["display"]["window"] ~= "never" then
551 UpdateSailStatWin()
552 end
553
554 --if disabled the timer should stop...
555 EnableTimer("sailstatwin_tic", false)
556 bIsSailing = false
557
558 if SailStatWin["display"]["window"] == "sailing" then
559 --window stays open a bit after sail
560 DoAfterSpecial (SailStatWin["display"]["secs"], 'CloseWindowAfterSail()', sendto.script)
561 end
562end
563
564function CloseWindowAfterSail()
565 bIsSailing = false
566 EnableTimer("sailstatwin_tic", false)
567 if SailStatWin["display"]["window"] == "sailing" then
568 WindowShow(SailStatWin["name"], false)
569 end
570end
571
572function SailFail(sName, sLine, wildcards)
573 local sReason = string.match(sName, "SailFail(.+)")
574
575 --finish stats from previous stage
576 Sail[#Sail]["end"] = GetInfo(232)
577 Sail[#Sail]["xp_gained"] = 0
578 Sail["fail"] = sReason or "unknown"
579 DisplayStageStats(#Sail)
580
581 EnableTriggerGroup("MidSail", false)
582 bIsSailing = false
583
584 local iTotalXP = Sail["monster"]["xp_gained"] or 0
585 --local iTotalTime = 0
586 for i, v in ipairs (Sail) do
587 iTotalXP = iTotalXP + v["xp_gained"]
588 end
589
590 local iTotalRate = CalcRate(Sail[#Sail]["end"] - Sail[1]["start"], iTotalXP)
591
592 if SailStatWin["display"]["notes"] == true then
593 ColourTell(SailStatWin["colour"]["text1"], "", "Total: " .. tostring(FormatElapsedTime(Sail[1]["start"], Sail[#Sail]["end"])) .. ", ")
594 ColourNote(SailStatWin["colour"]["text1"], "", "XP Gained: " .. tostring(AddCommas(iTotalXP)) .. " Xp (" .. Kify(iTotalRate) .. "Xp/hr).")
595 end
596
597 --Create cooldown timer, calc is 2 hrs from start. NOTE: Double check that fail is 2 hr cooldown as well
598 local iSeconds = 7200 - (Sail[#Sail]["end"] - Sail[1]["start"])
599 CreateCooldownTimers(iSeconds)
600
601 --think we need to use os.time to not change over logons\reboots etc.
602 iLastSailTime = os.time()
603
604 if SailStatWin["display"]["sail"] ~= "never" then
605 UpdateSailStatWin()
606 end
607
608 --if disabled the timer should stop...
609 EnableTimer("sailstatwin_tic", false)
610 bIsSailing = false
611
612 if SailStatWin["display"]["sail"] == "sailing" then
613 --window stays open a bit after sail
614 DoAfterSpecial (SailStatWin["display"]["secs"], 'CloseWindowAfterSail()', sendto.script)
615 end
616end
617
618function DisplayStageStats(iStageNum)
619 if SailStatWin["display"]["notes"] == true then
620 ColourTell(SailStatWin["colour"]["text2"], "", "[")
621 --show completed if not failed, or even if failed if this stage was completed
622 if Sail["fail"] == nil or iStageNum < #Sail then
623 ColourTell(SailStatWin["colour"]["text1"], "", Sail[iStageNum]["stage"] .. " completed: ")
624 else
625 ColourTell(SailStatWin["colour"]["text1"], "", Sail[iStageNum]["stage"] .. " failed")
626 if Sail["fail"] ~= "unknown" then
627 ColourTell(SailStatWin["colour"]["text1"], "", " (" .. string.lower(Sail["fail"]) .. ")")
628 end
629 ColourTell(SailStatWin["colour"]["text1"], "", ": ")
630 end
631 ColourTell(SailStatWin["colour"]["text1"], "", FormatElapsedTime(Sail[iStageNum]["start"], Sail[iStageNum]["end"]))
632 if Sail[iStageNum]["xp_gained"] ~= 0 then
633 ColourTell(SailStatWin["colour"]["text1"], "", ", " .. tostring(AddCommas(Sail[iStageNum]["xp_gained"])) .. " Xp")
634 ColourTell(SailStatWin["colour"]["text1"], "", " (" .. tostring(Kify(StageRate(Sail[iStageNum]))) .. " Xp/hr)")
635 end
636 ColourNote(SailStatWin["colour"]["text2"], "", "]")
637 end
638end
639
640function FullSailDisplay()
641 local iTotalXP = 0
642 --local iTotalTime = 0
643 for i, v in ipairs (Sail) do
644 iTotalXP = iTotalXP + v["xp_gained"]
645 end
646 --possibly does not need if....
647 if Sail["monster"]["xp_gained"] ~= nil then
648 iTotalXP = iTotalXP + Sail["monster"]["xp_gained"]
649 end
650
651 local iTotalRate = CalcRate(Sail[#Sail]["end"] - Sail[1]["start"], iTotalXP)
652
653 if Sail["fail"] ~= nil then
654 ColourTell(SailStatWin["colour"]["text1"], "", "FAILED! ("..Sail["fail"]..")")
655 end
656 ColourTell(SailStatWin["colour"]["text1"], "", "Total: " .. tostring(FormatElapsedTime(Sail[1]["start"], Sail[#Sail]["end"])) .. ", ")
657 ColourNote(SailStatWin["colour"]["text1"], "", "XP Gained: " .. tostring(AddCommas(iTotalXP)) .. " Xp (" .. Kify(iTotalRate) .. "Xp/hr).")
658
659 for iStage, vData in ipairs (Sail) do
660 ColourTell(SailStatWin["colour"]["text1"], "", vData["stage"] .. ": ")
661 ColourTell(SailStatWin["colour"]["text1"], "", FormatElapsedTime(vData["start"], vData["end"]))
662 if vData["xp_gained"] ~= 0 then
663 ColourTell(SailStatWin["colour"]["text1"], "", ", " .. tostring(AddCommas(vData["xp_gained"])) .. " Xp")
664 ColourTell(SailStatWin["colour"]["text1"], "", " (" .. tostring(Kify(StageRate(vData))) .. " Xp/hr)")
665 end
666 Note("")
667
668 if Sail["monster"]["mid"] ~= nil and Sail["monster"]["mid"] == iStage then
669 if Sail["monster"]["xp_gained"] ~= 0 then
670 ColourTell(SailStatWin["colour"]["text2"], "", "** ")
671 ColourTell(SailStatWin["colour"]["text1"], "", "Monster")
672 if Sail["monster"]["type"] ~= "unknown" then
673 ColourTell(SailStatWin["colour"]["text1"], "", " (" .. Sail["monster"]["type"] .. ")")
674 end
675 ColourTell(SailStatWin["colour"]["text1"], "", ": ")
676 ColourTell(SailStatWin["colour"]["text1"], "", FormatElapsedTime(vData["start"], vData["end"]))
677 ColourTell(SailStatWin["colour"]["text1"], "", ", " .. tostring(AddCommas(vData["xp_gained"])) .. " Xp")
678 ColourNote(SailStatWin["colour"]["text1"], "", " (" .. tostring(Kify(StageRate(vData))) .. " Xp/hr)")
679 end
680 end
681 end
682end
683
684function DisplaySailStats(sName, sLine, wildcards)
685 if bIsSailing == true then
686 if #Sail == 1 then
687 SMNote("You just started, keep sailing!")
688 else
689 if wildcards.group == "g" then
690 if wildcards.size ~= " full" then
691 local sGroupString = Sail[#Sail-1]["stage"] .. ": "..FormatElapsedTime(Sail[#Sail-1]["start"], Sail[#Sail-1]["end"])
692 if Sail[#Sail-1]["xp_gained"] ~= 0 then
693 sGroupString = sGroupString..", "..tostring(AddCommas(Sail[#Sail-1]["xp_gained"])) .. " Xp (" .. tostring(Kify(StageRate(Sail[#Sail-1]))) .. " Xp/hr)"
694 end
695 Send("group say " .. sGroupString)
696 else
697 for i, v in ipairs(Sail) do
698 if i ~= #Sail then
699 local sGroupString = v["stage"] .. ": "..FormatElapsedTime(v["start"], v["end"])
700 if v["xp_gained"] ~= 0 then
701 sGroupString = sGroupString..", "..tostring(AddCommas(v["xp_gained"])) .. " Xp (" .. tostring(Kify(StageRate(v))) .. " Xp/hr)"
702 end
703 Send("group say " .. sGroupString)
704 end
705 end
706 sGroupString = "[Current] "..Sail[#Sail]["stage"] .. ": "..FormatElapsedTime(Sail[#Sail]["start"], GetInfo(232))
707 Send("group say " .. sGroupString)
708 end
709 else
710 if wildcards.size ~= " full" then
711 ColourTell(SailStatWin["colour"]["text1"], "", Sail[#Sail-1]["stage"] .. ": ")
712 ColourTell(SailStatWin["colour"]["text1"], "", FormatElapsedTime(Sail[#Sail-1]["start"], Sail[#Sail-1]["end"]))
713 if Sail[#Sail-1]["xp_gained"] ~= 0 then
714 ColourTell(SailStatWin["colour"]["text1"], "", ", " .. tostring(AddCommas(Sail[#Sail-1]["xp_gained"])) .. " Xp")
715 ColourTell(SailStatWin["colour"]["text1"], "", " (" .. tostring(Kify(StageRate(Sail[#Sail-1]))) .. " Xp/hr)")
716 end
717 Note("")
718 else
719 for i, v in ipairs(Sail) do
720 if i ~= #Sail then
721 ColourTell(SailStatWin["colour"]["text1"], "", v["stage"] .. ": ")
722 ColourTell(SailStatWin["colour"]["text1"], "", FormatElapsedTime(v["start"], v["end"]))
723 if v["xp_gained"] ~= 0 then
724 ColourTell(SailStatWin["colour"]["text1"], "", ", " .. tostring(AddCommas(v["xp_gained"])) .. " Xp")
725 ColourTell(SailStatWin["colour"]["text1"], "", " (" .. tostring(Kify(StageRate(v))) .. " Xp/hr)")
726 end
727 Note("")
728 end
729 end
730 end
731 ColourTell(SailStatWin["colour"]["text1"], "", "Elapsed Time: ")
732 ColourNote(SailStatWin["colour"]["text1"], "", FormatElapsedTime(Sail[1]["start"], GetInfo(232)))
733 ColourTell(SailStatWin["colour"]["text1"], "", "[Current] "..Sail[#Sail]["stage"] .. ": ")
734 ColourNote(SailStatWin["colour"]["text1"], "", FormatElapsedTime(Sail[#Sail]["start"], GetInfo(232)))
735 end
736 end
737 else
738 if #Sail == 0 then
739 SMNote("No sail stats, do some sailing!")
740 else
741 local iTotalXP = 0
742 --local iTotalTime = 0
743 for i, v in ipairs (Sail) do
744 iTotalXP = iTotalXP + v["xp_gained"]
745 end
746 --possibly does not need if....
747 if Sail["monster"]["xp_gained"] ~= nil then
748 iTotalXP = iTotalXP + Sail["monster"]["xp_gained"]
749 end
750 local iTotalRate = CalcRate(Sail[#Sail]["end"] - Sail[1]["start"], iTotalXP)
751
752 if wildcards.group == "g" then
753
754 if Sail["fail"] == nil then
755 local sGroupString = "Sail: " .. tostring(FormatElapsedTime(Sail[1]["start"], Sail[#Sail]["end"])) .. ", XP: " .. tostring(AddCommas(iTotalXP)) .. " Xp (" .. Kify(iTotalRate) .. "Xp/hr)."
756 Send("group say ".. sGroupString)
757
758 if wildcards.size == " full" then
759 for iStage, vData in ipairs (Sail) do
760 local sGroupString = vData["stage"] .. ": "..FormatElapsedTime(vData["start"], vData["end"])
761 if vData["xp_gained"] ~= 0 then
762 sGroupString = sGroupString .. ", " .. tostring(AddCommas(vData["xp_gained"])) .. " Xp (" .. tostring(Kify(StageRate(vData))) .. " Xp/hr)"
763 end
764 Send("group say " .. sGroupString)
765
766 if Sail["monster"]["mid"] ~= nil and Sail["monster"]["mid"] == iStage then
767 if Sail["monster"]["xp_gained"] ~= 0 then
768 sGroupString = "** Monster: "..FormatElapsedTime(vData["start"], vData["end"])..tostring(AddCommas(vData["xp_gained"])) .. " Xp (" .. tostring(Kify(StageRate(vData))) .. " Xp/hr)"
769 Send("group say " .. sGroupString)
770 end
771 end
772 end
773 end
774 else
775 local sGroupString = "Failed Sail"
776 if Sail["fail"] ~= "unknown" then
777 sGroupString = sGroupString .. " (" ..Sail["fail"]..")"
778 end
779 sGroupString = sGroupString .. ": " .. tostring(FormatElapsedTime(Sail[1]["start"], Sail[#Sail]["end"])) .. ", XP: " .. tostring(AddCommas(iTotalXP)) .. " Xp (" .. Kify(iTotalRate) .. "Xp/hr)."
780 Send("group say ".. sGroupString)
781
782 if wildcards.size == " full" then
783 for iStage, vData in ipairs (Sail) do
784 local sGroupString = vData["stage"] .. ": "..FormatElapsedTime(vData["start"], vData["end"])
785 if vData["xp_gained"] ~= 0 then
786 sGroupString = sGroupString .. ", " .. tostring(AddCommas(vData["xp_gained"])) .. " Xp (" .. tostring(Kify(StageRate(vData))) .. " Xp/hr)"
787 end
788 Send("group say " .. sGroupString)
789
790 if Sail["monster"]["mid"] ~= nil and Sail["monster"]["mid"] == iStage then
791 if Sail["monster"]["xp_gained"] ~= 0 then
792 sGroupString = "** Monster: "..FormatElapsedTime(vData["start"], vData["end"])..tostring(AddCommas(vData["xp_gained"])) .. " Xp (" .. tostring(Kify(StageRate(vData))) .. " Xp/hr)"
793 Send("group say " .. sGroupString)
794 end
795 end
796 end
797 end
798 end
799 else
800 if Sail["fail"] == nil then
801 ColourTell(SailStatWin["colour"]["text1"], "", "Sail: " .. tostring(FormatElapsedTime(Sail[1]["start"], Sail[#Sail]["end"])) .. ", ")
802 else
803 ColourTell(SailStatWin["colour"]["text1"], "", "Failed Sail")
804 if Sail["fail"] ~= "unknown" then
805 ColourTell(SailStatWin["colour"]["text1"], "", " ("..Sail["fail"]..")")
806 end
807 ColourTell(SailStatWin["colour"]["text1"], "", ": " .. tostring(FormatElapsedTime(Sail[1]["start"], Sail[#Sail]["end"])) .. ", ")
808 end
809 ColourNote(SailStatWin["colour"]["text1"], "", "XP Gained: " .. tostring(AddCommas(iTotalXP)) .. " Xp (" .. Kify(iTotalRate) .. "Xp/hr).")
810
811 if wildcards.size == " full" then
812 for iStage, vData in ipairs (Sail) do
813 ColourTell(SailStatWin["colour"]["text1"], "", vData["stage"] .. ": ")
814 ColourTell(SailStatWin["colour"]["text1"], "", FormatElapsedTime(vData["start"], vData["end"]))
815 if vData["xp_gained"] ~= 0 then
816 ColourTell(SailStatWin["colour"]["text1"], "", ", " .. tostring(AddCommas(vData["xp_gained"])) .. " Xp")
817 ColourTell(SailStatWin["colour"]["text1"], "", " (" .. tostring(Kify(StageRate(vData))) .. " Xp/hr)")
818 end
819 Note("")
820
821 if Sail["monster"]["mid"] ~= nil and Sail["monster"]["mid"] == iStage then
822 if Sail["monster"]["xp_gained"] ~= 0 then
823 ColourTell(SailStatWin["colour"]["text2"], "", "** ")
824 ColourTell(SailStatWin["colour"]["text1"], "", "Monster: ")
825 ColourTell(SailStatWin["colour"]["text1"], "", FormatElapsedTime(vData["start"], vData["end"]))
826 ColourTell(SailStatWin["colour"]["text1"], "", ", " .. tostring(AddCommas(vData["xp_gained"])) .. " Xp")
827 ColourNote(SailStatWin["colour"]["text1"], "", " (" .. tostring(Kify(StageRate(vData))) .. " Xp/hr)")
828 else
829 ColourTell(SailStatWin["colour"]["text2"], "", "** ")
830 ColourNote(SailStatWin["colour"]["text1"], "", "Monster skipped.")
831 end
832 end
833 end
834 end
835 end
836 end
837 end
838end
839
840--possible change colours....
841function SMNote(sText)
842 ColourTell(CDWin["colour"]["text2"], "", "[")
843 ColourTell(CDWin["colour"]["text1"], "", "SailMate")
844 ColourTell(CDWin["colour"]["text2"], "", "] ")
845 ColourNote(CDWin["colour"]["text1"], "", sText)
846end
847
848function StageRate(tData)
849 local iTime = math.floor(tData["end"] - tData["start"] + .5)
850 if iTime == 0 then
851 return 0
852 end
853 local iXP = tData["xp_gained"]
854 return CalcRate(iTime, iXP)
855end
856
857function CalcRate(iTime, iXP)
858 return iXP/iTime * 3600
859end
860
861Word2Number={
862 ["zero"]=0, ["one"]=1, ["two"]=2, ["three"]=3, ["four"]=4, ["five"]=5, ["six"]=6, ["seven"]=7, ["eight"]=8, ["nine"]=9, ["ten"]=10,
863 ["eleven"]=11, ["twelve"]=12, ["thirteen"]=13, ["fourteen"]=14, ["fifteen"]=15, ["sixteen"]=16, ["seventeen"]=17, ["eighteen"]=18,
864 ["nineteen"]=19, ["twenty"]=20, ["twenty-one"]=21, ["twenty-two"]=22, ["twenty-three"]=23, ["twenty-four"]=24, ["twenty-five"]=25,
865 ["twenty-six"]=26, ["twenty-seven"]=27, ["twenty-eight"]=28, ["twenty-nine"]=29, ["thirty"]=30, ["thirty-one"]=31, ["thirty-two" ]=32,
866 ["thirty-three" ]=33, ["thirty-four"]=34, ["thirty-five"]=35, ["thirty-six"]=36, ["thirty-seven"]=37, ["thirty-eight"]=38, ["thirty-nine"]=39,
867 ["forty"]=40, ["forty-one"]=41, ["forty-two"]=42, ["forty-three"]=43, ["forty-four"]=44, ["forty-five"]=45, ["forty-six"]=46,
868 ["forty-seven"]=47, ["forty-eight"]=48, ["forty-nine"]=49, ["fifty"]=50, ["fifty-one"]=51, ["fifty-two"]=52, ["fifty-three"]=53,
869 ["fifty-four"]=54, ["fifty-five"]=55, ["fifty-six"]=56, ["fifty-seven"]=57, ["fifty-eight"]=58, ["fifty-nine"]=59, ["sixty"]=60,
870}
871
872function CooldownTime(sName, sLine, wildcards)
873 local iHours = Word2Number[wildcards.hour] or 0
874 local iMinutes = Word2Number[wildcards.mins] or 0
875 local iSeconds = Word2Number[wildcards.secs] or 0
876
877 if CDWin["display"] == false then
878 SMNote("Cooldown timer added for: " ..TimeFormat((iHours*3600)+(iMinutes*60)+iSeconds))
879 end
880 CreateCooldownTimers((iHours * 3600) + (iMinutes * 60) + iSeconds)
881end
882
883function SecondsToTime(iSeconds)
884 local iHours = math.floor(iSeconds/3600)
885 local iMins = math.floor(iSeconds/60 - (iHours*60))
886 local iSecs = math.floor(iSeconds - iHours*3600 - iMins *60)
887 return iHours, iMins, iSecs
888end
889
890function CreateCooldownTimers(iSeconds)
891 local iHours, iMins, iSecs
892 iHours, iMins, iSecs = SecondsToTime(iSeconds)
893
894 --remove all old timers
895 DeleteTimer("SailCooldownOver")
896 for i, v in ipairs(CDWin["notes"]) do
897 DeleteTimer("Warning_"..tostring(v))
898 end -- if we have any timers
899
900 iTimerError = AddTimer ("SailCooldownOver", iHours, iMins, iSecs, "", timer_flag.Enabled + timer_flag.Replace + timer_flag.Temporary + timer_flag.OneShot, "CooldownTimers")
901 CheckError(iTimerError)
902
903 --only do warnigs if more than 5 mins left...
904 if iSeconds >= 300 then
905 for i, v in ipairs(CDWin["notes"]) do
906 --make sure we have this amount of minutes remaining (and 5 mins more, don't need a warning right now)...
907 if v * 60 + 300 < iSeconds then
908 local iThisHours, iThisMinutes, iThisSeconds
909 iThisHours, iThisMinutes, iThisSeconds = SecondsToTime(iSeconds - (v*60))
910 iTimerError = AddTimer ("Warning_"..tostring(v), iThisHours, iThisMinutes, iThisSeconds, "", timer_flag.Enabled + timer_flag.Replace + timer_flag.Temporary + timer_flag.OneShot, "CooldownTimers")
911 CheckError(iTimerError)
912 end
913 end
914 end
915 EnableTimer("cdwin_tic", true)
916end
917
918function CheckError(iError)
919 if (iError == 30008) then
920 SMNote("Error code: " .. iTimerError .. " 'Invalid Name' when trying to create the timer.")
921 elseif (iError == 30018) then
922 SMNote("Error code: " .. iTimerError .. " 'Timer Already Exists' when trying to create the timer.")
923 elseif (iError == 30009) then
924 SMNote("Error code: " .. iTimerError .. " 'Function Not Found' when trying to create the timer.")
925 elseif (iError == 30022) then
926 SMNote("Error code: " .. iTimerError .. " 'Time Invalid' when trying to create the timer.")
927 --else
928 --Note("Successfully created the timer.")
929 end
930end
931
932function CooldownTimers(sName)
933 if CDWin["notes"] == true then
934 if sName == "SailCooldownOver" then
935 SMNote("Cooldown is Over!")
936 else
937 local sMin = string.match(sName, "Warning_(.+)")
938 if sMin ~= "1" then
939 SMNote("Cooldown ends in " .. sMin .. " minutes.")
940 else
941 SMNote("Cooldown ends in " .. sMin .. " minute.")
942 end
943 end
944 end
945end
946
947function DisplayTimers()
948 local iSecs = tonumber(GetTimerInfo("SailCooldownOver", 13))
949 if iSecs == nil then
950 SMNote("No cooldown timer.")
951 else
952 SMNote("Cooldown: " .. TimeFormat(iSecs))
953 end
954end
955
956function GroupDisplayTimers()
957 local iSecs = tonumber(GetTimerInfo("SailCooldownOver", 13))
958 if iSecs == nil then
959 Send("group say No cooldown timer.")
960 else
961 Send("group say Cooldown: " .. TimeFormat(iSecs))
962 end
963end
964
965function AddCommas(n) -- credit http://richard.warburton.it
966 local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$')
967 return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right
968end
969
970--Shorten number to reflect m\k
971function Kify(nNum)
972 if nNum == 0 or nNum == nil or nNum == "" then
973 return "Unknown"
974 end
975 if nNum < 1000 then
976 return math.floor(nNum + .5)
977 end
978
979 nMil = math.floor(nNum / 1000000)
980 nHunThou = math.floor( (nNum - (nMil * 1000000)) / 100000)
981 nTenThou = math.floor( (nNum - (nMil * 1000000) - (nHunThou * 100000)) / 10000)
982 nThou = math.floor( (nNum - (nMil * 1000000) - (nHunThou * 100000) - (nTenThou * 10000)) / 1000)
983 nHun = math.floor( (nNum - (nMil * 1000000) - (nHunThou * 100000) - (nTenThou * 10000) - (nThou * 1000)) / 100)
984 sString = math.floor(nNum)
985
986 if nMil > 0 then
987 if nMil >= 100 then
988 sString = nMil .. "m"
989 elseif nMil >= 10 then
990 if nHunThou > 0 then
991 sString = nMil .. "." .. nHunThou .. "m"
992 else
993 sString = nMil .. "m"
994 end
995 else
996 if nTenThou > 0 then
997 sString = nMil .. "." .. nHunThou .. nTenThou .. "m"
998 elseif nHunThou > 0 then
999 sString = nMil .. "." .. nHunThou .. "m"
1000 else
1001 sString = nMil .. "m"
1002 end
1003 end
1004 elseif nHunThou > 0 then
1005 sString = nHunThou .. nTenThou .. nThou .. "k"
1006 elseif nTenThou > 0 then
1007 if nHun > 0 then
1008 sString = nTenThou .. nThou .. "." .. nHun .. "k"
1009 else
1010 sString = nTenThou .. nThou .. "k"
1011 end
1012 elseif nThou > 0 then
1013 if nHun > 0 then
1014 sString = nThou .. "." .. nHun .. "k"
1015 else
1016 sString = nThou .. "k"
1017 end
1018 end
1019 return sString
1020end
1021
1022function RunTest()
1023
1024 Send([[
1025frimble Chidder says to you in Ephebian with a nautical Ephebian accent: Great! We'll just get the ship ready.
1026frimble The loading of the ship complete, Chidder wishes you a safe and profitable trip as you climb aboard the SS Unsinkable.
1027 frimble As you finish the first leg of your impossible voyage, you feel your experiences settling into the back of your mind. (112000 xp)
1028 frimble As you complete the second leg of your impossible voyage, you feel your experiences settling into the back of your mind. (112000 xp)
1029 frimble A massive sea serpent crests from the water ahead of the ship, seawater sloughing off its dinner-plate-sized scales. In a flash, it wraps the SS Unsinkable in its tail and eyes you as though you were its next meal - which you might well be, if you don't find a way to drive it off.
1030 frimble As you finish the third leg of your impossible voyage, you feel like the experience of sailing across the sea has been enlightening. (155996 xp)
1031 frimble The ship pulls into port. You've arrived.
1032 frimble You have been awarded 394736 experience points for delivering eight out of eight cargo crates to your destination, working with a group of three.
1033 frimble Captain Smith exclaims to youwith a nautical Ephebian accent: Everything looks to be in order. Well done!
1034 ]])
1035end
1036
1037CompassPoints = {
1038{"hubwards", "hub", "H"},
1039{"widdershins-hubwards", "widd-hub", "WH"},
1040{"widdershins", "widd", "W"},
1041{"widdershins-rimwards", "widd-rim", "WR"},
1042{"rimwards", "rim", "R"},
1043{"turnwise-rimwards", "turn-rim", "TR"},
1044{"turnwise", "turn", "T"},
1045{"turnwise-hubwards", "turn-hub", "TH"}
1046}
1047
1048function DetermineCompass(nUp)
1049 if nUp == nil then nUp = "hubwards" end
1050
1051 local thisCompass = {}
1052 local iStart
1053 local iCompassLength = 1
1054 if CompassWin["size"] == "medium" then
1055 iCompassLength = 2
1056 elseif CompassWin["size"] == "short" then
1057 iCompassLength = 3
1058 end
1059
1060 for i, v in ipairs(CompassPoints) do
1061 if v[1] == nUp or v[2] == nUp or v[3] == nUp then
1062 for iReps = 0, 7, 1 do
1063 local iInsert = i + iReps
1064 if iInsert > 8 then
1065 iInsert = iInsert - 8
1066 end
1067 table.insert(thisCompass, CompassPoints[iInsert][iCompassLength])
1068 end
1069 break
1070 end
1071 end
1072 return thisCompass
1073end
1074
1075--compasspoints
1076function RotateCompass(sDir)
1077 local thisCompass = {}
1078 local iStart
1079 local iCompassLength = 1
1080 if CompassWin["size"] == "medium" then
1081 iCompassLength = 2
1082 elseif CompassWin["size"] == "short" then
1083 iCompassLength = 3
1084 end
1085
1086 for i, v in ipairs(CompassPoints) do
1087 if v[1] == CompassWin["north"] then
1088 iNorthNumber = i
1089 break
1090 end
1091 end
1092
1093 if sDir == "clockwise" then
1094 iNorthNumber = iNorthNumber + 1
1095 if iNorthNumber > 8 then
1096 iNorthNumber = 1
1097 end
1098 CompassWin["north"] = CompassPoints[iNorthNumber][1]
1099 UpdateCompassWin()
1100 else
1101 iNorthNumber = iNorthNumber - 1
1102 if iNorthNumber < 1 then
1103 iNorthNumber = 8
1104 end
1105 CompassWin["north"] = CompassPoints[iNorthNumber][1]
1106 UpdateCompassWin()
1107 end
1108end
1109
1110--------------------------------------------------------------------------------
1111-- START MINIWINDOW STUFF
1112--------------------------------------------------------------------------------
1113function OnPluginDisable()
1114 WindowShow (CDWin["name"], false)
1115 WindowShow (SailStatWin["name"], false)
1116 WindowShow (CompassWin["name"], false)
1117end
1118
1119function OnPluginClose ()
1120 WindowShow (CDWin["name"], false)
1121 WindowShow (SailStatWin["name"], false)
1122 WindowShow (CompassWin["name"], false)
1123end
1124
1125function GetCDTimeColour(iSecs)
1126 --be surprised if cooldown is more than 120 mins...
1127 local iLowestNumber = 120
1128 local cReturnColour = CDWin["colour"]["text1"]
1129 for i, v in ipairs (CDWin["colour"]["time"]) do
1130 if iSecs <= v[1] * 60 and v[1] < iLowestNumber then
1131 iLowestNumber = v[1]
1132 cReturnColour = v[2]
1133 end
1134 end
1135 return cReturnColour
1136end
1137
1138function UpdateCDWinStatic()
1139 --Do not update while dragging or it stops the dragging
1140 if CDWin["dragging"] == true then
1141 table.insert(tUpdateAfterDrag, UpdateCDWinStatic)
1142 return
1143 end
1144
1145 WindowRectOp (CDWin["name"], 2, 0, 0, CDWin["width"], CDWin["height"], ColourNameToRGB(CDWin["colour"]["back"]))-- clears the window so old frame doesn't show
1146
1147 WindowRectOp (CDWin["name"], 4, 0, 0, CDWin["width"], CDWin["height"], ColourNameToRGB(CDWin["colour"]["border2"]), ColourNameToRGB(CDWin["colour"]["border1"]))
1148
1149 local sBeforeBracket, sHasBrackets, sBracketText, sAfterBracket = string.match(CDWin["cd_text"], "(.*)(%[(.+)%])(.*)")
1150
1151 local iIndent = CDWin["padding"]
1152 local sText = CDWin["cd_text"]
1153
1154 if sHasBrackets == nil then
1155 WindowText (CDWin["name"], "f", sText, iIndent, CDWin["padding"], 0, 0, ColourNameToRGB(CDWin["colour"]["text1"]), false) -- not Unicode
1156 iIndent = CDWin["padding"] + WindowTextWidth(CDWin["name"], "f", sText)
1157 --silly code to make fancy brackets...
1158 else
1159 if sBeforeBracket ~= "" then
1160 WindowText (CDWin["name"], "f", sBeforeBracket, iIndent, CDWin["padding"], 0, 0, ColourNameToRGB(CDWin["colour"]["text"]), false) -- not Unicode
1161 iIndent = iIndent + WindowTextWidth(CDWin["name"], "f", sBeforeBracket)
1162 end
1163 --brackets
1164 WindowText (CDWin["name"], "f", "[", iIndent, CDWin["padding"], 0, 0, ColourNameToRGB(CDWin["colour"]["text2"]), false) -- not Unicode
1165 iIndent = iIndent + WindowTextWidth(CDWin["name"], "f", "[")
1166 --inside brackets
1167 WindowText (CDWin["name"], "f", sBracketText, iIndent, CDWin["padding"], 0, 0, ColourNameToRGB(CDWin["colour"]["text1"]), false) -- not Unicode
1168 iIndent = iIndent + WindowTextWidth(CDWin["name"], "f", sBracketText)
1169 --end brackets
1170 WindowText (CDWin["name"], "f", "]", iIndent, CDWin["padding"], 0, 0, ColourNameToRGB(CDWin["colour"]["text2"]), false) -- not Unicode
1171 iIndent = iIndent + WindowTextWidth(CDWin["name"], "f", "]")
1172 --after bracket IF there is
1173 if sAfterBracket ~= "" then
1174 WindowText (CDWin["name"], "f", sAfterBracket, iIndent, CDWin["padding"], 0, 0, ColourNameToRGB(CDWin["colour"]["text1"]), false) -- not Unicode
1175 end
1176 end
1177 WindowDeleteHotspot (CDWin["name"], "whole")
1178
1179 WindowAddHotspot(CDWin["name"], "whole", CDWin["padding"], CDWin["padding"], CDWin["width"] - CDWin["padding"],CDWin["height"] - CDWin["padding"], --rectangle
1180 "", -- MouseOver
1181 "", -- CancelMouseOver
1182 "CDWinMouseDown",
1183 "",
1184 "CDWinMouseUp",
1185 "Click to drag, right click for options", -- tooltip text
1186 10, 0) -- hand cursor
1187 WindowDragHandler(CDWin["name"], "whole", "CDWinDragMove", "CDWinDragRelease", 0)
1188
1189 UpdateCDWinTime()
1190 Redraw()
1191end
1192
1193function UpdateCDWinTime()
1194 --Do not update while dragging or it stops the dragging
1195 if CDWin["dragging"] == true then
1196 return
1197 end
1198
1199 local iIndent = CDWin["padding"] + WindowTextWidth(CDWin["name"], "f", CDWin["cd_text"] .. " ")
1200 local iBlankSpot = CDWin["width"] - (CDWin["padding"] + iIndent)
1201 local iSecs = tonumber(GetTimerInfo("SailCooldownOver", 13))
1202 local sTimerString = "none"
1203 local cSecColour = CDWin["colour"]["text2"]
1204 if iSecs ~= nil then
1205 cSecColour = GetCDTimeColour(iSecs)
1206 sTimerString = TimeFormat(iSecs)
1207 end
1208 iIndent = iIndent + ((iBlankSpot - WindowTextWidth(CDWin["name"], "f", sTimerString))/2)
1209
1210 WindowRectOp (CDWin["name"], 2, CDWin["padding"] + WindowTextWidth(CDWin["name"], "f", CDWin["cd_text"] .. " "), CDWin["padding"], CDWin["width"]-CDWin["padding"], CDWin["font_height"]+CDWin["padding"], ColourNameToRGB(CDWin["colour"]["back"]))-- clears the coolown area so old time does not show
1211 WindowText (CDWin["name"], "f", sTimerString, iIndent, CDWin["padding"], 0, 0, ColourNameToRGB(cSecColour), false) -- not Unicode
1212 Redraw()
1213end
1214
1215tUpdateAfterDrag = {}
1216--this is all one as will only be updating on sails
1217function UpdateSailStatWin()
1218 --Do not update while dragging or it stops the dragging
1219 if SailStatWin["dragging"] == true then
1220 table.insert(tUpdateAfterDrag, UpdateSailStatWin)
1221 return
1222 end
1223
1224 WindowRectOp (SailStatWin["name"], 2, 0, 0, SailStatWin["width"], SailStatWin["height"], ColourNameToRGB(SailStatWin["colour"]["back"]))-- clears the window so old frame doesn't show
1225
1226 WindowRectOp (SailStatWin["name"], 4, 0, 0, SailStatWin["width"], SailStatWin["height"], ColourNameToRGB(SailStatWin["colour"]["border2"]), ColourNameToRGB(SailStatWin["colour"]["border1"]))
1227
1228 local iLine = 1
1229 local iIndent = SailStatWin["padding"]
1230 --display sail stats....
1231 if Sail[1] ~= nil then
1232 local iTotalXP = Sail["monster"]["xp_gained"] or 0
1233 --local iTotalTime = 0
1234 for i, v in ipairs (Sail) do
1235 iTotalXP = iTotalXP + v["xp_gained"]
1236 end
1237
1238 local iTotalRate
1239 if bIsSailing == false then
1240 iTotalRate = CalcRate(Sail[#Sail]["end"] - Sail[1]["start"], iTotalXP)
1241 else
1242 iTotalRate = CalcRate(GetInfo(232) - Sail[1]["start"], iTotalXP)
1243 end
1244
1245 local sText = ""
1246 if Sail["fail"] ~= nil then
1247 sText = string.upper(Sail["fail"])..": "
1248 local iIndent = SailStatWin["padding"]
1249 WindowText (SailStatWin["name"], "f", sText, iIndent, SailStatWin["padding"] + (SailStatWin["font_height"] * (iLine - 1)), 0, 0, ColourNameToRGB("red"), false) -- not Unicode
1250 else
1251 sText = "Total: "
1252 local iIndent = SailStatWin["padding"]
1253 WindowText (SailStatWin["name"], "f", sText, iIndent, SailStatWin["padding"] + (SailStatWin["font_height"] * (iLine - 1)), 0, 0, ColourNameToRGB(SailStatWin["colour"]["text1"]), false) -- not Unicode
1254 end
1255
1256 local iIndent = SailStatWin["padding"] + WindowTextWidth(SailStatWin["name"], "f", sText)
1257 local sText = ""
1258
1259 if bIsSailing == false then
1260 if SailStatWin["display"]["time"] == true then
1261 sText = tostring(FormatElapsedTime(Sail[1]["start"], Sail[#Sail]["end"]))
1262 if SailStatWin["display"]["xp_gained"] == true or SailStatWin["display"]["rate"] == true then
1263 sText = sText .. ", "
1264 end
1265 end
1266 if iTotalXP ~= 0 then
1267 if SailStatWin["display"]["xp_gained"] == true then
1268 sText = sText .. tostring(Kify(iTotalXP)) .. " XP"
1269 if SailStatWin["display"]["rate"] == true then
1270 sText = sText .. " "
1271 end
1272 end
1273 end
1274 if SailStatWin["display"]["rate"] == true then
1275 if SailStatWin["display"]["xp_gained"] == true then
1276 sText = sText .. "(" .. Kify(iTotalRate) .. "XP/hr)"
1277 else
1278 sText = sText .. Kify(iTotalRate) .. "XP/hr"
1279 end
1280 end
1281 else
1282 if SailStatWin["display"]["time"] == true then
1283 sText = tostring(FormatElapsedTime(Sail[1]["start"], GetInfo(232)))
1284 if SailStatWin["display"]["xp_gained"] == true or SailStatWin["display"]["rate"] == true then
1285 sText = sText .. ", "
1286 end
1287 end
1288 if iTotalXP ~= 0 then
1289 if SailStatWin["display"]["xp_gained"] == true then
1290 sText = sText .. tostring(Kify(iTotalXP)) .. " XP"
1291 if SailStatWin["display"]["rate"] == true then
1292 sText = sText .. " "
1293 end
1294 end
1295 end
1296 if SailStatWin["display"]["rate"] == true then
1297 if SailStatWin["display"]["xp_gained"] == true then
1298 sText = sText .. "(" .. Kify(iTotalRate) .. "XP/hr)"
1299 else
1300 sText = sText .. Kify(iTotalRate) .. "XP/hr"
1301 end
1302 end
1303 end
1304
1305 WindowText (SailStatWin["name"], "f", sText, iIndent, SailStatWin["padding"] + (SailStatWin["font_height"] * (iLine - 1)), 0, 0, ColourNameToRGB(SailStatWin["colour"]["text1"]), false) -- not Unicode
1306 iLine = iLine + 1
1307
1308 for iStage, vData in ipairs (Sail) do
1309 local iIndent = SailStatWin["padding"]
1310 local sText = ""
1311 if SailStatWin["display"]["time"] == true then
1312 sText = string.sub(vData["stage"], 1, 5) .. ": "..FormatElapsedTime(vData["start"], vData["end"])
1313 if SailStatWin["display"]["xp_gained"] == true or SailStatWin["display"]["rate"] == true then
1314 if vData["xp_gained"] ~= 0 then
1315 sText = sText .. ", "
1316 end
1317 end
1318 end
1319 if vData["xp_gained"] ~= 0 then
1320 --sText = sText ..", " .. tostring(Kify(vData["xp_gained"])) .. " XP (" .. tostring(Kify(StageRate(vData))) .. " Xp/hr)"
1321 if SailStatWin["display"]["xp_gained"] == true then
1322 sText = sText .. tostring(Kify(vData["xp_gained"])) .. " XP"
1323 if SailStatWin["display"]["rate"] == true then
1324 sText = sText .. " "
1325 end
1326 end
1327 if SailStatWin["display"]["rate"] == true then
1328 if SailStatWin["display"]["xp_gained"] == true then
1329 sText = sText .. "(" .. tostring(Kify(StageRate(vData))) .. "XP/hr)"
1330 else
1331 sText = sText .. tostring(Kify(StageRate(vData))) .. "XP/hr"
1332 end
1333 end
1334 end
1335 WindowText (SailStatWin["name"], "f", sText, iIndent, SailStatWin["padding"] + (SailStatWin["font_height"] * (iLine - 1)), 0, 0, ColourNameToRGB(SailStatWin["colour"]["text1"]), false) -- not Unicode
1336 iLine = iLine + 1
1337 --Note("")
1338
1339 if SailStatWin["display"]["monster"] == true and Sail["monster"]["mid"] ~= nil and Sail["monster"]["mid"] == iStage then
1340 if Sail["monster"]["xp_gained"] == 0 then
1341 local iIndent = SailStatWin["padding"]
1342 WindowText (SailStatWin["name"], "f", "**", iIndent, SailStatWin["padding"] + (SailStatWin["font_height"] * (iLine - 1)), 0, 0, ColourNameToRGB(SailStatWin["colour"]["text2"]), false) -- not Unicode
1343 local iIndent = SailStatWin["padding"] + WindowTextWidth(SailStatWin["name"], "f", "** ")
1344 WindowText (SailStatWin["name"], "f", "Monster skipped", iIndent, SailStatWin["padding"] + (SailStatWin["font_height"] * (iLine - 1)), 0, 0, ColourNameToRGB(SailStatWin["colour"]["text1"]), false) -- not Unicode
1345 local iIndent = SailStatWin["padding"] + WindowTextWidth(SailStatWin["name"], "f", "** Monster Skipped ")
1346 WindowText (SailStatWin["name"], "f", "**", iIndent, SailStatWin["padding"] + (SailStatWin["font_height"] * (iLine - 1)), 0, 0, ColourNameToRGB(SailStatWin["colour"]["text2"]), false) -- not Unicode
1347 else
1348 local iIndent = SailStatWin["padding"]
1349 WindowText (SailStatWin["name"], "f", "**", iIndent, SailStatWin["padding"] + (SailStatWin["font_height"] * (iLine - 1)), 0, 0, ColourNameToRGB(SailStatWin["colour"]["text2"]), false) -- not Unicode
1350 local iIndent = SailStatWin["padding"] + WindowTextWidth(SailStatWin["name"], "f", "** ")
1351 local sText = "Monster: "
1352 if Sail["monster"]["type"] ~= "unknown" then
1353 sText = FirstToUpper(Sail["monster"]["type"]) ..": "
1354 end
1355 --sText = sText .. FormatElapsedTime(vData["start"], vData["end"])..", " ..tostring(Kify(vData["xp_gained"])).. " XP (" .. tostring(Kify(StageRate(vData))) .. " Xp/hr)"
1356
1357 if SailStatWin["display"]["time"] == true then
1358 sText = sText .. FormatElapsedTime(vData["start"], vData["end"])
1359 if SailStatWin["display"]["xp_gained"] == true or SailStatWin["display"]["rate"] == true then
1360 sText = sText ..", "
1361 end
1362 end
1363 if SailStatWin["display"]["xp_gained"] == true then
1364 sText = sText .. tostring(Kify(vData["xp_gained"])) .. " XP"
1365 if SailStatWin["display"]["rate"] == true then
1366 sText = sText .. " "
1367 end
1368 end
1369 if SailStatWin["display"]["rate"] == true then
1370 if SailStatWin["display"]["xp_gained"] == true then
1371 sText = sText .. "(" .. tostring(Kify(StageRate(vData))) .. "XP/hr)"
1372 else
1373 sText = sText .. tostring(Kify(StageRate(vData))) .. "XP/hr"
1374 end
1375 end
1376
1377 WindowText (SailStatWin["name"], "f", sText, iIndent, SailStatWin["padding"] + (SailStatWin["font_height"] * (iLine - 1)), 0, 0, ColourNameToRGB(SailStatWin["colour"]["text1"]), false) -- not Unicode
1378 end
1379 iLine = iLine + 1
1380 end
1381 end
1382 else
1383 WindowText (SailStatWin["name"], "f", "No sail data", SailStatWin["padding"], SailStatWin["padding"] + (SailStatWin["font_height"] * (iLine - 1)), 0, 0, ColourNameToRGB(SailStatWin["colour"]["text1"]), false) -- not Unicode
1384 iLine = iLine + 1
1385 end
1386
1387 WindowDeleteHotspot (SailStatWin["name"], "whole")
1388 WindowAddHotspot(SailStatWin["name"], "whole", SailStatWin["padding"], SailStatWin["padding"], SailStatWin["width"] - SailStatWin["padding"],SailStatWin["height"] - SailStatWin["padding"], --rectangle
1389 "", -- MouseOver
1390 "", -- CancelMouseOver
1391 "SailStatWinMouseDown",
1392 "",
1393 "SailStatWinMouseUp",
1394 "Click to drag, right click for options", -- tooltip text
1395 10, 0) -- hand cursor
1396 WindowDragHandler(SailStatWin["name"], "whole", "SailStatWinDragMove", "SailStatWinDragRelease", 0)
1397 Redraw()
1398end
1399
1400function UpdateCompassWin()
1401 --Do not update while dragging or it stops the dragging
1402 if CompassWin["dragging"] == true then
1403 table.insert(tUpdateAfterDrag, UpdateCompassWin)
1404 return
1405 end
1406
1407 WindowRectOp (CompassWin["name"], 2, 0, 0, CompassWin["width"], CompassWin["height"], ColourNameToRGB(CompassWin["colour"]["back"]))-- clears the window so old frame doesn't show
1408
1409 WindowRectOp (CompassWin["name"], 4, 0, 0, CompassWin["width"], CompassWin["height"], ColourNameToRGB(CompassWin["colour"]["border2"]), ColourNameToRGB(CompassWin["colour"]["border1"]))
1410
1411 local thisCompass = DetermineCompass(CompassWin["north"])
1412
1413 local iLine = 1
1414 local sText = thisCompass[1]
1415 local iFWidth = WindowTextWidth (CompassWin["name"], "f", sText)
1416 local iIndent = (CompassWin["width"] -iFWidth)/2
1417 WindowText (CompassWin["name"], "f", sText, iIndent, CompassWin["padding"] + (CompassWin["font_height"] * (iLine - 1)), 0, 0, ColourNameToRGB(CompassWin["colour"]["text1"]), false) -- not Unicode
1418 iLine = iLine + 1
1419
1420 local sTextCentre = " ^ "
1421 local sTextLeft = thisCompass[8]
1422 local sTextRight = thisCompass[2]
1423 local iCWidth = WindowTextWidth (CompassWin["name"], "f", sTextCentre)
1424 local iLWidth = WindowTextWidth (CompassWin["name"], "f", sTextLeft)
1425 local iRWidth = WindowTextWidth (CompassWin["name"], "f", sTextRight)
1426 local iIndent = (CompassWin["width"] -iCWidth)/2
1427 WindowText (CompassWin["name"], "f", sTextCentre, iIndent, CompassWin["padding"] + (CompassWin["font_height"] * (iLine - 1)), 0, 0, ColourNameToRGB(CompassWin["colour"]["text1"]), false) -- not Unicode
1428 WindowText (CompassWin["name"], "f", sTextLeft, iIndent - iLWidth, CompassWin["padding"] + (CompassWin["font_height"] * (iLine - 1)), 0, 0, ColourNameToRGB(CompassWin["colour"]["text1"]), false) -- not Unicode
1429 WindowText (CompassWin["name"], "f", sTextRight, iIndent + iCWidth, CompassWin["padding"] + (CompassWin["font_height"] * (iLine - 1)), 0, 0, ColourNameToRGB(CompassWin["colour"]["text1"]), false) -- not Unicode
1430 iLine = iLine + 1
1431
1432 local sText = "\\ | /"
1433 local iFWidth = WindowTextWidth (CompassWin["name"], "f", sText)
1434 local iIndent = (CompassWin["width"] -iFWidth)/2
1435 WindowText (CompassWin["name"], "f", sText, iIndent, CompassWin["padding"] + (CompassWin["font_height"] * (iLine - 1)), 0, 0, ColourNameToRGB(CompassWin["colour"]["text1"]), false) -- not Unicode
1436 iLine = iLine + 1
1437
1438 local sTextCentre = " <- ship -> "
1439 local sTextLeft = thisCompass[7]
1440 local sTextRight = thisCompass[3]
1441 local iCWidth = WindowTextWidth (CompassWin["name"], "f", sTextCentre)
1442 local iLWidth = WindowTextWidth (CompassWin["name"], "f", sTextLeft)
1443 local iRWidth = WindowTextWidth (CompassWin["name"], "f", sTextRight)
1444 local iIndent = (CompassWin["width"] -iCWidth)/2
1445 WindowText (CompassWin["name"], "f", sTextCentre, iIndent, CompassWin["padding"] + (CompassWin["font_height"] * (iLine - 1)), 0, 0, ColourNameToRGB(CompassWin["colour"]["text1"]), false) -- not Unicode
1446 WindowText (CompassWin["name"], "f", sTextLeft, iIndent - iLWidth, CompassWin["padding"] + (CompassWin["font_height"] * (iLine - 1)), 0, 0, ColourNameToRGB(CompassWin["colour"]["text1"]), false) -- not Unicode
1447 WindowText (CompassWin["name"], "f", sTextRight, iIndent + iCWidth, CompassWin["padding"] + (CompassWin["font_height"] * (iLine - 1)), 0, 0, ColourNameToRGB(CompassWin["colour"]["text1"]), false) -- not Unicode
1448 iLine = iLine + 1
1449
1450 local sText = "/ | \\"
1451 local iFWidth = WindowTextWidth (CompassWin["name"], "f", sText)
1452 local iIndent = (CompassWin["width"] -iFWidth)/2
1453 WindowText (CompassWin["name"], "f", sText, iIndent, CompassWin["padding"] + (CompassWin["font_height"] * (iLine - 1)), 0, 0, ColourNameToRGB(CompassWin["colour"]["text1"]), false) -- not Unicode
1454 iLine = iLine + 1
1455
1456 local sTextCentre = " v "
1457 local sTextLeft = thisCompass[6]
1458 local sTextRight = thisCompass[4]
1459 local iCWidth = WindowTextWidth (CompassWin["name"], "f", sTextCentre)
1460 local iLWidth = WindowTextWidth (CompassWin["name"], "f", sTextLeft)
1461 local iRWidth = WindowTextWidth (CompassWin["name"], "f", sTextRight)
1462 local iIndent = (CompassWin["width"] -iCWidth)/2
1463 WindowText (CompassWin["name"], "f", sTextCentre, iIndent, CompassWin["padding"] + (CompassWin["font_height"] * (iLine - 1)), 0, 0, ColourNameToRGB(CompassWin["colour"]["text1"]), false) -- not Unicode
1464 WindowText (CompassWin["name"], "f", sTextLeft, iIndent - iLWidth, CompassWin["padding"] + (CompassWin["font_height"] * (iLine - 1)), 0, 0, ColourNameToRGB(CompassWin["colour"]["text1"]), false) -- not Unicode
1465 WindowText (CompassWin["name"], "f", sTextRight, iIndent + iCWidth, CompassWin["padding"] + (CompassWin["font_height"] * (iLine - 1)), 0, 0, ColourNameToRGB(CompassWin["colour"]["text1"]), false) -- not Unicode
1466 iLine = iLine + 1
1467
1468 local sText = thisCompass[5]
1469 local iFWidth = WindowTextWidth (CompassWin["name"], "f", sText)
1470 local iIndent = (CompassWin["width"] -iFWidth)/2
1471 WindowText (CompassWin["name"], "f", sText, iIndent, CompassWin["padding"] + (CompassWin["font_height"] * (iLine - 1)), 0, 0, ColourNameToRGB(CompassWin["colour"]["text1"]), false) -- not Unicode
1472
1473 WindowDeleteHotspot (CompassWin["name"], "whole")
1474 WindowAddHotspot(CompassWin["name"], "whole", CompassWin["padding"], CompassWin["padding"], CompassWin["width"] - CompassWin["padding"],CompassWin["height"] - CompassWin["padding"], --rectangle
1475 "", -- MouseOver
1476 "", -- CancelMouseOver
1477 "CompassWinMouseDown",
1478 "",
1479 "CompassWinMouseUp",
1480 "Click to drag, right click for options", -- tooltip text
1481 10, 0) -- hand cursor
1482 WindowDragHandler(CompassWin["name"], "whole", "CompassWinDragMove", "CompassWinDragRelease", 0)
1483 Redraw()
1484end
1485
1486function ResizeCDWin()
1487
1488 CDWin["font_height"] = WindowFontInfo(CDWin["name"], "f", 1)
1489 --Note("fh = " .. tostring(CDWin["font_height"]))
1490
1491 CDWin["height"] = CDWin["font_height"] + (CDWin["padding"] * 2)
1492
1493 local sLongestText = CDWin["cd_text"].." 00:00s"
1494 CDWin["width"] = WindowTextWidth (CDWin["name"], "f", sLongestText) + (CDWin["padding"] * 2)
1495
1496 WindowResize(CDWin["name"], CDWin["width"], CDWin["height"], ColourNameToRGB(CDWin["colour"]["back"]))
1497end
1498
1499function ResizeSailStatWin()
1500 SailStatWin["font_height"] = WindowFontInfo (SailStatWin["name"], "f", 1)
1501 --Note("fh = " .. tostring(SailStatWin["font_height"]))
1502
1503 if SailStatWin["display_monster"] == true then
1504 SailStatWin["height"] = (SailStatWin["font_height"]*7) + (SailStatWin["padding"] * 2)
1505 else
1506 SailStatWin["height"] = (SailStatWin["font_height"]*6) + (SailStatWin["padding"] * 2)
1507 end
1508
1509 --local sLongestText = "Total: 14:12s, 1.62m XP (2.55m XP/hr)"
1510 local sLongestText = "Total: "
1511 if SailStatWin["display"]["time"] == true then
1512 sLongestText = sLongestText .. "14:12s"
1513 if SailStatWin["display"]["xp_gained"] == true or SailStatWin["display"]["rate"] == true then
1514 sLongestText = sLongestText .. ", "
1515 end
1516 end
1517 if SailStatWin["display"]["xp_gained"] == true then
1518 sLongestText = sLongestText .. "1.62m XP"
1519 if SailStatWin["display"]["rate"] == true then
1520 sLongestText = sLongestText .. " "
1521 end
1522 end
1523 if SailStatWin["display"]["rate"] == true then
1524 if SailStatWin["display"]["xp_gained"] == true then
1525 sLongestText = sLongestText .. "(2.55m XP/hr)"
1526 else
1527 sLongestText = sLongestText .. "2.55m XP/hr"
1528 end
1529 end
1530
1531 SailStatWin["width"] = WindowTextWidth (SailStatWin["name"], "f", sLongestText) + (SailStatWin["padding"] * 2)
1532
1533 WindowResize(SailStatWin["name"], SailStatWin["width"], SailStatWin["height"], ColourNameToRGB(SailStatWin["colour"]["back"]))
1534end
1535
1536function ResizeCompassWin()
1537 CompassWin["font_height"] = WindowFontInfo (CompassWin["name"], "f", 1)
1538 --Note("fh = " .. tostring(CompassWin["font_height"]))
1539
1540 CompassWin["height"] = (CompassWin["font_height"] * 7) + (CompassWin["padding"] * 2)
1541
1542
1543 local sLongestText = "h"
1544 local iCompassLength = 1
1545 if CompassWin["size"] == "medium" then
1546 iCompassLength = 2
1547 elseif CompassWin["size"] == "short" then
1548 iCompassLength = 3
1549 end
1550
1551 for i, v in ipairs (CompassPoints) do
1552 if string.len(sLongestText) < string.len(v[iCompassLength]) then
1553 sLongestText = v[iCompassLength]
1554 end
1555 end
1556
1557 CompassWin["width"] = WindowTextWidth (CompassWin["name"], "f", sLongestText .. " <- ship -> " .. sLongestText) + (CompassWin["padding"] * 2)
1558
1559 WindowResize(CompassWin["name"], CompassWin["width"], CompassWin["height"], ColourNameToRGB(CompassWin["colour"]["back"]))
1560end
1561
1562
1563function FirstToUpper(str)
1564 return (string.gsub(str, "^%l", string.upper))
1565end
1566
1567--------------------------------------------------------------------------------
1568-- DRAG AND HOTSPOT HANDLERS
1569--------------------------------------------------------------------------------
1570function CDWinMouseDown(flags, hotspot_id)
1571 if hotspot_id == "whole" then
1572 startx, starty = WindowInfo (CDWin["name"], 14), WindowInfo (CDWin["name"], 15)
1573 end
1574end -- mousedown
1575
1576function CDWinMouseUp(flags, hotspot_id)
1577 if (hotspot_id == "whole") and (flags == miniwin.hotspot_got_rh_mouse ) then
1578 local menu_string = "!Help|"
1579 menu_string = menu_string ..">Display CD|"
1580 menu_string = menu_string .. ">Note|"
1581 menu_string = menu_string .. "Brief|"
1582 menu_string = menu_string .. "Full|"
1583 menu_string = menu_string .. "<|"
1584 menu_string = menu_string .. ">Group|"
1585 menu_string = menu_string .. "Brief|"
1586 menu_string = menu_string .. "Full|"
1587 menu_string = menu_string .. "<|"
1588 menu_string = menu_string .."<|"
1589 menu_string = menu_string ..">Settings|"
1590 menu_string = menu_string .. ">Windows|"
1591 menu_string = menu_string .. ">Cooldown|"
1592 menu_string = menu_string .. "Show|"
1593 menu_string = menu_string .. "Hide|"
1594 menu_string = menu_string .. "<|"
1595 menu_string = menu_string .. ">Sail Stats|"
1596 menu_string = menu_string .. "Always|"
1597 menu_string = menu_string .. "While Sailing|"
1598 menu_string = menu_string .. "Never|"
1599 menu_string = menu_string .. "<|"
1600 menu_string = menu_string .. ">Compass|"
1601 menu_string = menu_string .. "Always|"
1602 menu_string = menu_string .. "While Sailing|"
1603 menu_string = menu_string .. "Never|"
1604 menu_string = menu_string .. "<|"
1605 menu_string = menu_string .. "<|"
1606 menu_string = menu_string .. ">Font\\Size|"
1607 menu_string = menu_string .. CDWin["font"].." ("..CDWin["font_size"]..")|"
1608 menu_string = menu_string .. "<|"
1609 menu_string = menu_string .. ">Window Text|"
1610 menu_string = menu_string .. CDWin["cd_text"].."|"
1611 menu_string = menu_string .. "<|"
1612 menu_string = menu_string .. ">Colour|"
1613 menu_string = menu_string .. "Text1 ("..FirstToUpper(CDWin["colour"]["text1"])..")|"
1614 menu_string = menu_string .. "Text2 ("..FirstToUpper(CDWin["colour"]["text2"])..")|"
1615 menu_string = menu_string .. "Border1 ("..FirstToUpper(CDWin["colour"]["border1"])..")|"
1616 menu_string = menu_string .. "Border2 ("..FirstToUpper(CDWin["colour"]["border2"])..")|"
1617 menu_string = menu_string .. "Background ("..FirstToUpper(CDWin["colour"]["back"])..")|"
1618 menu_string = menu_string .. ">Timer|"
1619 for i, v in ipairs (CDWin["colour"]["time"]) do
1620 if v[1] > 1 then
1621 menu_string = menu_string .. ">"..v[1].." mins|"
1622 else
1623 menu_string = menu_string .. ">"..v[1].." min|"
1624 end
1625 menu_string = menu_string .. FirstToUpper(tostring(v[2])) .."|"
1626 menu_string = menu_string .. "Remove|"
1627 menu_string = menu_string .. "<|"
1628 end
1629 menu_string = menu_string .. "Add|"
1630 menu_string = menu_string .. "<|"
1631 menu_string = menu_string .. "<|"
1632 menu_string = menu_string .. ">Notes|"
1633 menu_string = menu_string .. "Show|"
1634 menu_string = menu_string .. "Hide|"
1635 menu_string = menu_string .. "-|"
1636 for i, v in ipairs (CDWin["notes"]) do
1637 if v > 1 then
1638 menu_string = menu_string .. ">" .. v.." mins|"
1639 else
1640 menu_string = menu_string .. ">" .. v.." min|"
1641 end
1642 menu_string = menu_string .. "Remove|"
1643 menu_string = menu_string .. "<|"
1644 end
1645 menu_string = menu_string .. "Add|"
1646 menu_string = menu_string .. "<|"
1647 menu_string = menu_string .. "<|"
1648 menu_string = menu_string .."<|"
1649 menu_string = menu_string .."-|"
1650 menu_string = menu_string ..">Reset|"
1651 menu_string = menu_string .. "Cooldown|"
1652 menu_string = menu_string .. "Sail Stats|"
1653 menu_string = menu_string .. "Compass|"
1654 menu_string = menu_string .. "All|"
1655 menu_string = menu_string .."<|"
1656
1657 --Note("Menu Text = " .. menu_string)
1658
1659 result = WindowMenu (CDWin["name"],
1660 WindowInfo (CDWin["name"], 14), -- x
1661 WindowInfo (CDWin["name"], 15), -- y
1662 menu_string)
1663
1664 result = tonumber(result) or 0
1665
1666 --Note("Result = " .. result)
1667
1668 if result == 0 then
1669 elseif result == 1 then
1670 SailMateHelp()
1671 elseif result == 2 then
1672 DisplaySailStats()
1673 elseif result == 3 then
1674 DisplaySailStats("","",{["size"] = " full"})
1675 elseif result == 4 then
1676 DisplaySailStats("","",{["group"] = "g"})
1677 elseif result == 5 then
1678 DisplaySailStats("","",{["size"] = " full", ["group"] = "g",})
1679 elseif result == 6 then
1680 if CDWin["display"] == true then
1681 SMNote("Cooldown miniwindow is already showing, it may be hidden under a different miniwindow.")
1682 else
1683 SMNote("Showing cooldown miniwindow.")
1684 CDWin["display"] = true
1685 WindowShow(CDWin["name"], true)
1686 UpdateCDWinStatic()
1687 end
1688 elseif result == 7 then
1689 if CDWin["display"] == true then
1690 SMNote("Closing cooldown miniwindow.")
1691 CDWin["display"] = false
1692 WindowShow(CDWin["name"], false)
1693 else
1694 SMNote("Cooldown miniwindow is already closed.")
1695 end
1696 elseif result == 8 then
1697 if SailStatWin["display"]["window"] == "always" then
1698 SMNote("Sail stats miniwindow is already showing, it may be hidden under a different miniwindow.")
1699 else
1700 SMNote("Showing sails stat miniwindow.")
1701 SailStatWin["display"]["window"] = "always"
1702 WindowShow(SailStatWin["name"], true)
1703 EnableTimer("sailstatwin_tic", true)
1704 UpdateSailStatWin()
1705 end
1706 elseif result == 9 then
1707 if SailStatWin["display"]["window"] == "sailing" then
1708 SMNote("Sail stats miniwindow is already showing while sailing, it may be hidden under a different miniwindow.")
1709 else
1710 if SailStatWin["display"]["window"] == "always" then
1711 SMNote("Showing sail stats miniwindow only while sailing.")
1712 else
1713 SMNote("Showing sail stats miniwindow while sailing.")
1714 end
1715 SailStatWin["display"]["window"] = "sailing"
1716 if bIsSailing == true then
1717 WindowShow(SailStatWin["name"], true)
1718 EnableTimer("sailstatwin_tic", true)
1719 UpdateSailStatWin()
1720 else
1721 WindowShow(SailStatWin["name"], false)
1722 EnableTimer("sailstatwin_tic", false)
1723 end
1724 end
1725 elseif result == 10 then
1726 if SailStatWin["display"]["window"] == "never" then
1727 SMNote("Sail stats miniwindow is already closed.")
1728 else
1729 if SailStatWin["display"]["window"] == "always" then
1730 SMNote("Closing sail stats miniwindow.")
1731 else
1732 SMNote("Sail stats miniwindow will no longer display while sailing.")
1733 end
1734 SailStatWin["display"]["window"] = "never"
1735 WindowShow(SailStatWin["name"], false)
1736 EnableTimer("sailstatwin_tic", false)
1737 end
1738 elseif result == 11 then
1739 if CompassWin["display"] == "always" then
1740 SMNote("Compass miniwindow is already showing, it may be hidden under a different miniwindow.")
1741 else
1742 SMNote("Showing compass miniwindow.")
1743 CompassWin["display"] = "always"
1744 WindowShow(CompassWin["name"], true)
1745 UpdateCompassWin()
1746 end
1747 elseif result == 12 then
1748 if CompassWin["display"] == "sailing" then
1749 SMNote("Compass miniwindow is already showing while sailing, it may be hidden under a different miniwindow.")
1750 else
1751 if CompassWin["display"] == "always" then
1752 SMNote("Showing compass miniwindow only while sailing.")
1753 else
1754 SMNote("Showing compass miniwindow while sailing.")
1755 end
1756 CompassWin["display"] = "sailing"
1757 if bIsSailing == true then
1758 WindowShow(CompassWin["name"], true)
1759 UpdateCompassWin()
1760 else
1761 WindowShow(CompassWin["name"], false)
1762 end
1763 end
1764 elseif result == 13 then
1765 if CompassWin["display"] == "never" then
1766 SMNote("Compass miniwindow is already closed.")
1767 else
1768 if CompassWin["display"] == "always" then
1769 SMNote("Closing compass miniwindow.")
1770 else
1771 SMNote("Sail stats miniwindow will no longer display while sailing.")
1772 end
1773 CompassWin["display"] = "never"
1774 WindowShow(CompassWin["name"], false)
1775 end
1776 elseif result == 14 then
1777 local wanted_font = utils.fontpicker(CDWin["font"], CDWin["font_size"])
1778 if wanted_font then
1779 if CDWin["font"] ~= wanted_font["name"] or CDWin["font_size"] ~= wanted_font["size"] then
1780 SMNote("Setting font to: " .. wanted_font["name"] .. " (" .. wanted_font["size"] .. ")")
1781 CDWin["font"] = wanted_font["name"]
1782 CDWin["font_size"] = wanted_font["size"]
1783 WindowFont (CDWin["name"], "f", CDWin["font"], CDWin["font_size"], false, false, false, false)
1784 ResizeCDWin()
1785 UpdateCDWinStatic()
1786 else
1787 SMNote("Keeping font\\size as it was before.")
1788 end
1789 end
1790 elseif result == 15 then
1791 local text_result = utils.inputbox ( "Enter text for cooldown miniwindow, 'default' for default", "Text", CDWin["cd_text"], "", 0, {
1792 box_width = 300, box_height = 125, prompt_width = 300, prompt_height = 12 } )
1793 if text_result ~= nil then
1794 if text_result ~= CDWin["cd_text"] then
1795 if text_result == "default" then
1796 CDWin["cd_text"] = "[SailMate]"
1797 else
1798 CDWin["cd_text"] = text_result
1799 end
1800 --[[if text_result == "" then
1801 --SMNote("Removing text from cooldown miniwindow.")
1802 else
1803 --SMNote("Changing cooldown miniwindow text to: " .. text_result)
1804 end
1805 ]]--
1806 ResizeCDWin()
1807 UpdateCDWinStatic()
1808 else
1809 SMNote("Cooldown miniwindow text is already: " .. text_result)
1810 end
1811 end
1812 elseif result == 16 then
1813 local chosen_colour = PickColour(ColourNameToRGB(CDWin["colour"]["text1"]))
1814 if chosen_colour ~= -1 then
1815 --Note("colour = " .. RGBColourToName(chosen_colour))
1816 if CDWin["colour"]["text1"] == RGBColourToName(chosen_colour) then
1817 SMNote("Cooldown miniwindow text1 is already: " .. RGBColourToName(chosen_colour))
1818 else
1819 CDWin["colour"]["text1"] = RGBColourToName(chosen_colour)
1820 UpdateCDWinStatic()
1821 end
1822 end
1823 elseif result == 17 then
1824 local chosen_colour = PickColour(ColourNameToRGB(CDWin["colour"]["text2"]))
1825 if chosen_colour ~= -1 then
1826 --Note("colour = " .. RGBColourToName(chosen_colour))
1827 if CDWin["colour"]["text2"] == RGBColourToName(chosen_colour) then
1828 SMNote("Cooldown miniwindow text2 is already: " .. RGBColourToName(chosen_colour))
1829 else
1830 CDWin["colour"]["text2"] = RGBColourToName(chosen_colour)
1831 UpdateCDWinStatic()
1832 end
1833 end
1834 elseif result == 18 then
1835 local chosen_colour = PickColour(ColourNameToRGB(CDWin["colour"]["border1"]))
1836 if chosen_colour ~= -1 then
1837 --Note("colour = " .. RGBColourToName(chosen_colour))
1838 if CDWin["colour"]["border1"] == RGBColourToName(chosen_colour) then
1839 SMNote("Cooldown miniwindow border1 is already: " .. RGBColourToName(chosen_colour))
1840 else
1841 CDWin["colour"]["border1"] = RGBColourToName(chosen_colour)
1842 UpdateCDWinStatic()
1843 end
1844 end
1845 elseif result == 19 then
1846 local chosen_colour = PickColour(ColourNameToRGB(CDWin["colour"]["border2"]))
1847 if chosen_colour ~= -1 then
1848 --Note("colour = " .. RGBColourToName(chosen_colour))
1849 if CDWin["colour"]["border2"] == RGBColourToName(chosen_colour) then
1850 SMNote("Cooldown miniwindow border2 is already: " .. RGBColourToName(chosen_colour))
1851 else
1852 CDWin["colour"]["border2"] = RGBColourToName(chosen_colour)
1853 UpdateCDWinStatic()
1854 end
1855 end
1856 elseif result == 20 then
1857 local chosen_colour = PickColour(ColourNameToRGB(CDWin["colour"]["back"]))
1858 if chosen_colour ~= -1 then
1859 --Note("colour = " .. RGBColourToName(chosen_colour))
1860 if CDWin["colour"]["back"] == RGBColourToName(chosen_colour) then
1861 SMNote("Cooldown miniwindow back is already: " .. RGBColourToName(chosen_colour))
1862 else
1863 CDWin["colour"]["back"] = RGBColourToName(chosen_colour)
1864 UpdateCDWinStatic()
1865 end
1866 end
1867 elseif result <= 20 + (#CDWin["colour"]["time"]*2) then
1868 if ((result - 20) % 2 == 0) then
1869 local table_number = (result - 20) / 2
1870 --Note("table number = " .. table_number)
1871 --.....it is even
1872 --result = 21... remove table 1?
1873 if CDWin["colour"]["time"][table_number][1] == 1 then
1874 SMNote("Removing " .. CDWin["colour"]["time"][table_number][2] .. " colour at " .. CDWin["colour"]["time"][table_number][1] .. " min.")
1875 else
1876 SMNote("Removing " .. CDWin["colour"]["time"][table_number][2] .. " colour at " .. CDWin["colour"]["time"][table_number][1] .. " mins.")
1877 end
1878 table.remove(CDWin["colour"]["time"], table_number)
1879 else
1880 local table_number = (result - 19) / 2
1881 --Note("table number = " .. table_number)
1882 local chosen_colour = PickColour(ColourNameToRGB(CDWin["colour"]["time"][table_number][2]))
1883 if chosen_colour ~= -1 then
1884 --Note("colour = " .. RGBColourToName(chosen_colour))
1885 if CDWin["colour"]["time"][table_number][2] == RGBColourToName(chosen_colour) then
1886 --CHANGE MESSAGE
1887 if CDWin["colour"]["time"][table_number][1] == 1 then
1888 SMNote("Colour for "..CDWin["colour"]["time"][table_number][1].. "mins is already: " .. RGBColourToName(chosen_colour))
1889 else
1890 SMNote("Colour for "..CDWin["colour"]["time"][table_number][1].. "mins is already: " .. RGBColourToName(chosen_colour))
1891 end
1892 else
1893 CDWin["colour"]["time"][table_number][2] = RGBColourToName(chosen_colour)
1894 --UpdateCDWinStatic()
1895 end
1896 end
1897 --.....it is odd
1898 end
1899 elseif result == 21 + (#CDWin["colour"]["time"]*2) then
1900 local time_result = tonumber(utils.inputbox ( "Enter number of minutes to change timer colour.", "Minutes", "", "", 0, {
1901 box_width = 300, box_height = 125, prompt_width = 300, prompt_height = 12 } ))
1902 if time_result ~= nil then
1903 if time_result <= 99 then
1904 local bAlready = false
1905 for i, v in ipairs (CDWin["colour"]["time"]) do
1906 if v[1] == time_result then
1907 bAlready = true
1908 end
1909 end
1910 if bAlready == false then
1911 local chosen_colour = PickColour(ColourNameToRGB(CDWin["colour"]["text1"]))
1912 if chosen_colour ~= -1 then
1913 table.insert(CDWin["colour"]["time"], {time_result, RGBColourToName(chosen_colour)})
1914 local sort_func = function( a,b ) return a[1] > b[1] end
1915 table.sort(CDWin["colour"]["time"], sort_func )
1916 end
1917 else
1918 if time_result == 1 then
1919 SMNote("There already is a colour change for "..time_result.." minute, you can change the colour by selecting it from the menu.")
1920 else
1921 SMNote("There already is a colour change for "..time_result.." minutes, you can change the colour by selecting it from the menu.")
1922 end
1923 end
1924 else
1925 SMNote("You must enter a valid number lower than 99.")
1926 end
1927 else
1928 SMNote("You must enter a valid number lower than 99.")
1929 end
1930 elseif result == 22 + (#CDWin["colour"]["time"]*2) then
1931 if CDWin["notes"]["show"] == true then
1932 SMNote("Already displaying note warnings for cooldown.")
1933 else
1934 SMNote("Now displaying note warnings for cooldown.")
1935 CDWin["notes"]["show"] = true
1936 end
1937 elseif result == 23 + (#CDWin["colour"]["time"]*2) then
1938 if CDWin["notes"]["show"] == true then
1939 SMNote("No longer displaying note warnings for cooldown.")
1940 CDWin["notes"]["show"] = false
1941 else
1942 SMNote("Cooldown warnings are already not displaying.")
1943 end
1944 --elseif result == 23 + (#CDWin["colour"]["time"]*2) then
1945 elseif result <= 23 + (#CDWin["colour"]["time"]*2) + (#CDWin["notes"]) then
1946 local table_number = result - (23 + (#CDWin["colour"]["time"]*2))
1947 if CDWin["notes"][table_number] == 1 then
1948 SMNote("Removing note warning for " .. tostring(CDWin["notes"][table_number]) .. " minute.")
1949 else
1950 SMNote("Removing note warning for " .. tostring(CDWin["notes"][table_number]) .. " minutes.")
1951 end
1952 table.remove(CDWin["notes"], table_number)
1953 elseif result == 24 + (#CDWin["colour"]["time"]*2) + (#CDWin["notes"]) then
1954 local time_result = tonumber(utils.inputbox ( "Enter number of minutes to note cooldown remaining.", "Minutes", "", "", 0, {
1955 box_width = 300, box_height = 125, prompt_width = 300, prompt_height = 12 } ))
1956 if time_result ~= nil then
1957 if time_result <= 99 then
1958 local bAlready = false
1959 for i, v in ipairs (CDWin["notes"]) do
1960 if v == time_result then
1961 bAlready = true
1962 end
1963 end
1964 if bAlready == false then
1965 table.insert(CDWin["notes"], time_result)
1966 local sort_func = function( a,b ) return a > b end
1967 table.sort(CDWin["notes"], sort_func )
1968 else
1969 if time_result == 1 then
1970 SMNote("There already is a cooldown note for "..time_result.." minute.")
1971 else
1972 SMNote("There already is a cooldown note for "..time_result.." minutes.")
1973 end
1974 end
1975 else
1976 SMNote("You must enter a valid number lower than 99.")
1977 end
1978 else
1979 SMNote("You must enter a valid number lower than 99.")
1980 end
1981 elseif result == 25 + (#CDWin["colour"]["time"]*2) + (#CDWin["notes"]) then
1982 SailReset("cd")
1983 elseif result == 26 + (#CDWin["colour"]["time"]*2) + (#CDWin["notes"]) then
1984 SailReset("sailstat")
1985 elseif result == 27 + (#CDWin["colour"]["time"]*2) + (#CDWin["notes"]) then
1986 SailReset("compass")
1987 elseif result == 28 + (#CDWin["colour"]["time"]*2) + (#CDWin["notes"]) then
1988 SailReset("all")
1989 end
1990 end
1991
1992end -- mouseup
1993
1994function CDWinDragMove(flags, hotspot_id)
1995 CDWin["dragging"] = true
1996 if hotspot_id == "whole" then
1997 local posx, posy = WindowInfo (CDWin["name"], 17), WindowInfo (CDWin["name"], 18)
1998 -- move the window to the new location
1999 WindowPosition(CDWin["name"], posx - startx, posy - starty, 0, 2)
2000
2001 -- change the mouse cursor shape appropriately
2002 if posx < 0 or posx > GetInfo (281) or posy < 0 or posy > GetInfo (280) then
2003 check (SetCursor ( 11)) -- X cursor
2004 else
2005 check (SetCursor ( 1)) -- hand cursor
2006 end -- if
2007 end
2008end -- CDWinDragMove
2009
2010function CDWinDragRelease(flags, hotspot_id)
2011 --DebugNote("No longer dragging")
2012 CDWin["dragging"] = false
2013
2014 CDWin["pos_x"] = WindowInfo (CDWin["name"], 10)
2015 CDWin["pos_y"] = WindowInfo (CDWin["name"], 11)
2016
2017 --mainly if we need to update window after drag
2018 for i, vFunc in ipairs(tUpdateAfterDrag) do
2019 vFunc()
2020 table.remove(tUpdateAfterDrag, i)
2021 end
2022end -- CDWinDragRelease
2023
2024function SailStatWinMouseDown(flags, hotspot_id)
2025 if hotspot_id == "whole" then
2026 startx, starty = WindowInfo (SailStatWin["name"], 14), WindowInfo (SailStatWin["name"], 15)
2027 end
2028end -- mousedown
2029
2030function SailStatWinMouseUp(flags, hotspot_id)
2031 if (hotspot_id == "whole") and (flags == miniwin.hotspot_got_rh_mouse ) then
2032 local menu_string = "!Help|"
2033 menu_string = menu_string ..">Settings|"
2034 menu_string = menu_string .. ">Windows|"
2035 menu_string = menu_string .. ">Cooldown|"
2036 menu_string = menu_string .. "Show|"
2037 menu_string = menu_string .. "Hide|"
2038 menu_string = menu_string .. "<|"
2039 menu_string = menu_string .. ">Sail Stats|"
2040 menu_string = menu_string .. "Always|"
2041 menu_string = menu_string .. "While Sailing|"
2042 menu_string = menu_string .. "Never|"
2043 menu_string = menu_string .. "<|"
2044 menu_string = menu_string .. ">Compass|"
2045 menu_string = menu_string .. "Always|"
2046 menu_string = menu_string .. "While Sailing|"
2047 menu_string = menu_string .. "Never|"
2048 menu_string = menu_string .. "<|"
2049 menu_string = menu_string .. "<|"
2050 menu_string = menu_string .. ">Font\\Size|"
2051 menu_string = menu_string .. SailStatWin["font"].." ("..SailStatWin["font_size"]..")|"
2052 menu_string = menu_string .. "<|"
2053 menu_string = menu_string .. ">Colour|"
2054 menu_string = menu_string .. "Text1 ("..FirstToUpper(SailStatWin["colour"]["text1"])..")|"
2055 menu_string = menu_string .. "Text2 ("..FirstToUpper(SailStatWin["colour"]["text2"])..")|"
2056 menu_string = menu_string .. "Border1 ("..FirstToUpper(SailStatWin["colour"]["border1"])..")|"
2057 menu_string = menu_string .. "Border2 ("..FirstToUpper(SailStatWin["colour"]["border2"])..")|"
2058 menu_string = menu_string .. "Background ("..FirstToUpper(SailStatWin["colour"]["back"])..")|"
2059 menu_string = menu_string .. "<|"
2060 menu_string = menu_string .. ">Notes|"
2061 menu_string = menu_string .. "Show|"
2062 menu_string = menu_string .. "Hide|"
2063 menu_string = menu_string .. "<|"
2064 menu_string = menu_string .. "-|"
2065 menu_string = menu_string .. ">Monster|"
2066 menu_string = menu_string .. "Show|"
2067 menu_string = menu_string .. "Hide|"
2068 menu_string = menu_string .. "<|"
2069 menu_string = menu_string .."<|"
2070 menu_string = menu_string .."-|"
2071 menu_string = menu_string ..">Reset|"
2072 menu_string = menu_string .. "Cooldown|"
2073 menu_string = menu_string .. "Sail Stats|"
2074 menu_string = menu_string .. "Compass|"
2075 menu_string = menu_string .. "All|"
2076 menu_string = menu_string .."<|"
2077
2078 --Note("Menu Text = " .. menu_string)
2079
2080 result = WindowMenu (SailStatWin["name"],
2081 WindowInfo (SailStatWin["name"], 14), -- x
2082 WindowInfo (SailStatWin["name"], 15), -- y
2083 menu_string)
2084
2085 result = tonumber(result) or 0
2086
2087 --Note("Result = " .. result)
2088
2089 if result == 0 then
2090 elseif result == 1 then
2091 SailMateHelp()
2092 elseif result == 2 then
2093 if CDWin["display"] == true then
2094 SMNote("Cooldown miniwindow is already showing, it may be hidden under a different miniwindow.")
2095 else
2096 SMNote("Showing cooldown miniwindow.")
2097 CDWin["display"] = true
2098 WindowShow(CDWin["name"], true)
2099 UpdateCDWinStatic()
2100 end
2101 elseif result == 3 then
2102 if CDWin["display"] == true then
2103 SMNote("Closing cooldown miniwindow.")
2104 CDWin["display"] = false
2105 WindowShow(CDWin["name"], false)
2106 else
2107 SMNote("Cooldown miniwindow is already closed.")
2108 end
2109 elseif result == 4 then
2110 if SailStatWin["display"]["window"] == "always" then
2111 SMNote("Sail stats miniwindow is already showing, it may be hidden under a different miniwindow.")
2112 else
2113 SMNote("Showing sails stat miniwindow.")
2114 SailStatWin["display"]["window"] = "always"
2115 WindowShow(SailStatWin["name"], true)
2116 EnableTimer("sailstatwin_tic", true)
2117 UpdateSailStatWin()
2118 end
2119 elseif result == 5 then
2120 if SailStatWin["display"]["window"] == "sailing" then
2121 SMNote("Sail stats miniwindow is already showing while sailing, it may be hidden under a different miniwindow.")
2122 else
2123 if SailStatWin["display"]["window"] == "always" then
2124 SMNote("Showing sail stats miniwindow only while sailing.")
2125 else
2126 SMNote("Showing sail stats miniwindow while sailing.")
2127 end
2128 SailStatWin["display"]["window"] = "sailing"
2129 if bIsSailing == true then
2130 WindowShow(SailStatWin["name"], true)
2131 EnableTimer("sailstatwin_tic", true)
2132 UpdateSailStatWin()
2133 else
2134 WindowShow(SailStatWin["name"], false)
2135 EnableTimer("sailstatwin_tic", false)
2136 end
2137 end
2138 elseif result == 6 then
2139 if SailStatWin["display"]["window"] == "never" then
2140 SMNote("Sail stats miniwindow is already closed.")
2141 else
2142 if SailStatWin["display"]["window"] == "always" then
2143 SMNote("Closing sail stats miniwindow.")
2144 else
2145 SMNote("Sail stats miniwindow will no longer display while sailing.")
2146 end
2147 SailStatWin["display"]["window"] = "never"
2148 WindowShow(SailStatWin["name"], false)
2149 EnableTimer("sailstatwin_tic", false)
2150 end
2151 elseif result == 7 then
2152 if CompassWin["display"] == "always" then
2153 SMNote("Compass miniwindow is already showing, it may be hidden under a different miniwindow.")
2154 else
2155 SMNote("Showing compass miniwindow.")
2156 CompassWin["display"] = "always"
2157 WindowShow(CompassWin["name"], true)
2158 UpdateCompassWin()
2159 end
2160 elseif result == 8 then
2161 if CompassWin["display"] == "sailing" then
2162 SMNote("Compass miniwindow is already showing while sailing, it may be hidden under a different miniwindow.")
2163 else
2164 if CompassWin["display"] == "always" then
2165 SMNote("Showing compass miniwindow only while sailing.")
2166 else
2167 SMNote("Showing compass miniwindow while sailing.")
2168 end
2169 CompassWin["display"] = "sailing"
2170 if bIsSailing == true then
2171 WindowShow(CompassWin["name"], true)
2172 UpdateCompassWin()
2173 else
2174 WindowShow(CompassWin["name"], false)
2175 end
2176 end
2177 elseif result == 9 then
2178 if CompassWin["display"] == "never" then
2179 SMNote("Compass miniwindow is already closed.")
2180 else
2181 if CompassWin["display"] == "always" then
2182 SMNote("Closing compass miniwindow.")
2183 else
2184 SMNote("Sail stats miniwindow will no longer display while sailing.")
2185 end
2186 CompassWin["display"] = "never"
2187 WindowShow(CompassWin["name"], false)
2188 end
2189 elseif result == 10 then
2190 local wanted_font = utils.fontpicker(CDWin["font"], CDWin["font_size"])
2191 if wanted_font then
2192 if CDWin["font"] ~= wanted_font["name"] or CDWin["font_size"] ~= wanted_font["size"] then
2193 SMNote("Setting font to: " .. wanted_font["name"] .. " (" .. wanted_font["size"] .. ")")
2194 CDWin["font"] = wanted_font["name"]
2195 CDWin["font_size"] = wanted_font["size"]
2196 WindowFont (CDWin["name"], "f", CDWin["font"], CDWin["font_size"], false, false, false, false)
2197 ResizeCDWin()
2198 UpdateCDWinStatic()
2199 else
2200 SMNote("Keeping font\\size as it was before.")
2201 end
2202 end
2203 elseif result == 11 then
2204 local chosen_colour = PickColour(ColourNameToRGB(SailStatWin["colour"]["text1"]))
2205 if chosen_colour ~= -1 then
2206 --Note("colour = " .. RGBColourToName(chosen_colour))
2207 if SailStatWin["colour"]["text1"] == RGBColourToName(chosen_colour) then
2208 SMNote("Cooldown miniwindow text1 is already: " .. RGBColourToName(chosen_colour))
2209 else
2210 SailStatWin["colour"]["text1"] = RGBColourToName(chosen_colour)
2211 UpdateSailStatWin()
2212 end
2213 end
2214 elseif result == 12 then
2215 local chosen_colour = PickColour(ColourNameToRGB(SailStatWin["colour"]["text2"]))
2216 if chosen_colour ~= -1 then
2217 --Note("colour = " .. RGBColourToName(chosen_colour))
2218 if SailStatWin["colour"]["text2"] == RGBColourToName(chosen_colour) then
2219 SMNote("Cooldown miniwindow text2 is already: " .. RGBColourToName(chosen_colour))
2220 else
2221 SailStatWin["colour"]["text2"] = RGBColourToName(chosen_colour)
2222 UpdateSailStatWin()
2223 end
2224 end
2225 elseif result == 13 then
2226 local chosen_colour = PickColour(ColourNameToRGB(SailStatWin["colour"]["border1"]))
2227 if chosen_colour ~= -1 then
2228 --Note("colour = " .. RGBColourToName(chosen_colour))
2229 if SailStatWin["colour"]["border1"] == RGBColourToName(chosen_colour) then
2230 SMNote("Cooldown miniwindow border1 is already: " .. RGBColourToName(chosen_colour))
2231 else
2232 SailStatWin["colour"]["border1"] = RGBColourToName(chosen_colour)
2233 UpdateSailStatWin()
2234 end
2235 end
2236 elseif result == 14 then
2237 local chosen_colour = PickColour(ColourNameToRGB(SailStatWin["colour"]["border2"]))
2238 if chosen_colour ~= -1 then
2239 --Note("colour = " .. RGBColourToName(chosen_colour))
2240 if SailStatWin["colour"]["border2"] == RGBColourToName(chosen_colour) then
2241 SMNote("Cooldown miniwindow border2 is already: " .. RGBColourToName(chosen_colour))
2242 else
2243 SailStatWin["colour"]["border2"] = RGBColourToName(chosen_colour)
2244 UpdateSailStatWin()
2245 end
2246 end
2247 elseif result == 15 then
2248 local chosen_colour = PickColour(ColourNameToRGB(SailStatWin["colour"]["back"]))
2249 if chosen_colour ~= -1 then
2250 --Note("colour = " .. RGBColourToName(chosen_colour))
2251 if SailStatWin["colour"]["back"] == RGBColourToName(chosen_colour) then
2252 SMNote("Cooldown miniwindow back is already: " .. RGBColourToName(chosen_colour))
2253 else
2254 SailStatWin["colour"]["back"] = RGBColourToName(chosen_colour)
2255 UpdateSailStatWin()
2256 end
2257 end
2258 elseif result == 16 then
2259 if SailStatWin["notes"] == true then
2260 SMNote("Already showing sail stat notes.")
2261 else
2262 SMNote("Sail stat notes will now be displayed.")
2263 SailStatWin["notes"] = true
2264 end
2265 elseif result == 17 then
2266 if SailStatWin["notes"] == true then
2267 SMNote("Sail stat notes will no longer be displayed.")
2268 SailStatWin["notes"] = false
2269 else
2270 SMNote("Sail stat notes are already not being displayed.")
2271 end
2272 elseif result == 18 then
2273 if SailStatWin["display_monster"] == true then
2274 SMNote("Already showing monster stats.")
2275 else
2276 SMNote("Monster stats will now be displayed.")
2277 SailStatWin["display_monster"] = true
2278 end
2279 elseif result == 19 then
2280 if SailStatWin["display_monster"] == true then
2281 SMNote("Monster stats will no longer be displayed.")
2282 SailStatWin["display_monster"] = false
2283 else
2284 SMNote("Monster stats are already not being displayed.")
2285 end
2286 elseif result == 20 then
2287 SailReset("cd")
2288 elseif result == 21 then
2289 SailReset("sailstat")
2290 elseif result == 22 then
2291 SailReset("compass")
2292 elseif result == 23 then
2293 SailReset("all")
2294 end
2295 end
2296end -- mouseup
2297
2298function SailStatWinDragMove(flags, hotspot_id)
2299 SailStatWin["dragging"] = true
2300 if hotspot_id == "whole" then
2301 local posx, posy = WindowInfo (SailStatWin["name"], 17), WindowInfo (SailStatWin["name"], 18)
2302 -- move the window to the new location
2303 WindowPosition(SailStatWin["name"], posx - startx, posy - starty, 0, 2)
2304
2305 -- change the mouse cursor shape appropriately
2306 if posx < 0 or posx > GetInfo (281) or posy < 0 or posy > GetInfo (280) then
2307 check (SetCursor ( 11)) -- X cursor
2308 else
2309 check (SetCursor ( 1)) -- hand cursor
2310 end -- if
2311 end
2312end -- SailStatWinDragMove
2313
2314function SailStatWinDragRelease(flags, hotspot_id)
2315 --DebugNote("No longer dragging")
2316 SailStatWin["dragging"] = false
2317
2318 SailStatWin["pos_x"] = WindowInfo (SailStatWin["name"], 10)
2319 SailStatWin["pos_y"] = WindowInfo (SailStatWin["name"], 11)
2320
2321 --mainly if we need to update window after drag
2322 for i, vFunc in ipairs(tUpdateAfterDrag) do
2323 vFunc()
2324 table.remove(tUpdateAfterDrag, i)
2325 end
2326end -- SailStatWinDragRelease
2327
2328function CompassWinMouseDown(flags, hotspot_id)
2329 if hotspot_id == "whole" then
2330 startx, starty = WindowInfo (CompassWin["name"], 14), WindowInfo (CompassWin["name"], 15)
2331 end
2332end -- mousedown
2333
2334function CompassWinMouseUp(flags, hotspot_id)
2335 if (hotspot_id == "whole") and (flags == miniwin.hotspot_got_rh_mouse ) then
2336
2337--[[
2338CompassWin = {
2339["name"] = "compass" .. GetPluginID (),
2340["font"] = "Consolas",
2341["font_size"] = 9,
2342["padding"] = 2.5,
2343["colour"] = {
2344 ["text1"] = "limegreen",
2345 --["text2"] = "white",
2346 ["border1"] = "limegreen",
2347 ["border2"] = "green",
2348 ["back"] = "black",
2349 },
2350["north"] = "hubwards",
2351["size"] = "medium", --full, medium, short
2352["display"] = "always",--always, sailing, never
2353["dragging"] = false,
2354}
2355
2356]]--
2357
2358 local menu_string = "!Help|"
2359 menu_string = menu_string ..">Settings|"
2360 menu_string = menu_string .. ">Windows|"
2361 menu_string = menu_string .. ">Cooldown|"
2362 menu_string = menu_string .. "Show|"
2363 menu_string = menu_string .. "Hide|"
2364 menu_string = menu_string .. "<|"
2365 menu_string = menu_string .. ">Sail Stats|"
2366 menu_string = menu_string .. "Always|"
2367 menu_string = menu_string .. "While Sailing|"
2368 menu_string = menu_string .. "Never|"
2369 menu_string = menu_string .. "<|"
2370 menu_string = menu_string .. ">Compass|"
2371 menu_string = menu_string .. "Always|"
2372 menu_string = menu_string .. "While Sailing|"
2373 menu_string = menu_string .. "Never|"
2374 menu_string = menu_string .. "<|"
2375 menu_string = menu_string .. "<|"
2376 menu_string = menu_string .. ">Font\\Size|"
2377 menu_string = menu_string .. SailStatWin["font"].." ("..SailStatWin["font_size"]..")|"
2378 menu_string = menu_string .. "<|"
2379 menu_string = menu_string .. ">Colour|"
2380 menu_string = menu_string .. "Text1 ("..FirstToUpper(SailStatWin["colour"]["text1"])..")|"
2381 menu_string = menu_string .. "Border1 ("..FirstToUpper(SailStatWin["colour"]["border1"])..")|"
2382 menu_string = menu_string .. "Border2 ("..FirstToUpper(SailStatWin["colour"]["border2"])..")|"
2383 menu_string = menu_string .. "Background ("..FirstToUpper(SailStatWin["colour"]["back"])..")|"
2384 menu_string = menu_string .. "<|"
2385 menu_string = menu_string .. "-|"
2386 menu_string = menu_string .. ">Size|"
2387 menu_string = menu_string .. "Full|"
2388 menu_string = menu_string .. "Medium|"
2389 menu_string = menu_string .. "Short|"
2390 menu_string = menu_string .. "<|"
2391 menu_string = menu_string .."<|"
2392 menu_string = menu_string .."-|"
2393 menu_string = menu_string ..">North|"
2394 menu_string = menu_string .. CompassWin["north"].."|"
2395 menu_string = menu_string .."<|"
2396 menu_string = menu_string ..">Rotate|"
2397 menu_string = menu_string .. "Clockwise|"
2398 menu_string = menu_string .. "Anti-Clockwise|"
2399 menu_string = menu_string .."<|"
2400 menu_string = menu_string .."-|"
2401 menu_string = menu_string ..">Reset|"
2402 menu_string = menu_string .. "Cooldown|"
2403 menu_string = menu_string .. "Sail Stats|"
2404 menu_string = menu_string .. "Compass|"
2405 menu_string = menu_string .. "All|"
2406 menu_string = menu_string .."<|"
2407
2408 --Note("Menu Text = " .. menu_string)
2409
2410 result = WindowMenu (CompassWin["name"],
2411 WindowInfo (CompassWin["name"], 14), -- x
2412 WindowInfo (CompassWin["name"], 15), -- y
2413 menu_string)
2414
2415 result = tonumber(result) or 0
2416
2417 --Note("Result = " .. result)
2418
2419 if result == 0 then
2420 elseif result == 1 then
2421 SailMateHelp()
2422 elseif result == 2 then
2423 if CDWin["display"] == true then
2424 SMNote("Cooldown miniwindow is already showing, it may be hidden under a different miniwindow.")
2425 else
2426 SMNote("Showing cooldown miniwindow.")
2427 CDWin["display"] = true
2428 WindowShow(CDWin["name"], true)
2429 UpdateCDWinStatic()
2430 end
2431 elseif result == 3 then
2432 if CDWin["display"] == true then
2433 SMNote("Closing cooldown miniwindow.")
2434 CDWin["display"] = false
2435 WindowShow(CDWin["name"], false)
2436 else
2437 SMNote("Cooldown miniwindow is already closed.")
2438 end
2439 elseif result == 4 then
2440 if SailStatWin["display"]["window"] == "always" then
2441 SMNote("Sail stats miniwindow is already showing, it may be hidden under a different miniwindow.")
2442 else
2443 SMNote("Showing sails stat miniwindow.")
2444 SailStatWin["display"]["window"] = "always"
2445 WindowShow(SailStatWin["name"], true)
2446 EnableTimer("sailstatwin_tic", true)
2447 UpdateSailStatWin()
2448 end
2449 elseif result == 5 then
2450 if SailStatWin["display"]["window"] == "sailing" then
2451 SMNote("Sail stats miniwindow is already showing while sailing, it may be hidden under a different miniwindow.")
2452 else
2453 if SailStatWin["display"]["window"] == "always" then
2454 SMNote("Showing sail stats miniwindow only while sailing.")
2455 else
2456 SMNote("Showing sail stats miniwindow while sailing.")
2457 end
2458 SailStatWin["display"]["window"] = "sailing"
2459 if bIsSailing == true then
2460 WindowShow(SailStatWin["name"], true)
2461 EnableTimer("sailstatwin_tic", true)
2462 UpdateSailStatWin()
2463 else
2464 WindowShow(SailStatWin["name"], false)
2465 EnableTimer("sailstatwin_tic", false)
2466 end
2467 end
2468 elseif result == 6 then
2469 if SailStatWin["display"]["window"] == "never" then
2470 SMNote("Sail stats miniwindow is already closed.")
2471 else
2472 if SailStatWin["display"]["window"] == "always" then
2473 SMNote("Closing sail stats miniwindow.")
2474 else
2475 SMNote("Sail stats miniwindow will no longer display while sailing.")
2476 end
2477 SailStatWin["display"]["window"] = "never"
2478 WindowShow(SailStatWin["name"], false)
2479 EnableTimer("sailstatwin_tic", false)
2480 end
2481 elseif result == 7 then
2482 if CompassWin["display"] == "always" then
2483 SMNote("Compass miniwindow is already showing, it may be hidden under a different miniwindow.")
2484 else
2485 SMNote("Showing compass miniwindow.")
2486 CompassWin["display"] = "always"
2487 WindowShow(CompassWin["name"], true)
2488 UpdateCompassWin()
2489 end
2490 elseif result == 8 then
2491 if CompassWin["display"] == "sailing" then
2492 SMNote("Compass miniwindow is already showing while sailing, it may be hidden under a different miniwindow.")
2493 else
2494 if CompassWin["display"] == "always" then
2495 SMNote("Showing compass miniwindow only while sailing.")
2496 else
2497 SMNote("Showing compass miniwindow while sailing.")
2498 end
2499 CompassWin["display"] = "sailing"
2500 if bIsSailing == true then
2501 WindowShow(CompassWin["name"], true)
2502 UpdateCompassWin()
2503 else
2504 WindowShow(CompassWin["name"], false)
2505 end
2506 end
2507 elseif result == 9 then
2508 if CompassWin["display"] == "never" then
2509 SMNote("Compass miniwindow is already closed.")
2510 else
2511 if CompassWin["display"] == "always" then
2512 SMNote("Closing compass miniwindow.")
2513 else
2514 SMNote("Sail stats miniwindow will no longer display while sailing.")
2515 end
2516 CompassWin["display"] = "never"
2517 WindowShow(CompassWin["name"], false)
2518 end
2519 elseif result == 10 then
2520 local wanted_font = utils.fontpicker(CDWin["font"], CDWin["font_size"])
2521 if wanted_font then
2522 if CDWin["font"] ~= wanted_font["name"] or CDWin["font_size"] ~= wanted_font["size"] then
2523 SMNote("Setting font to: " .. wanted_font["name"] .. " (" .. wanted_font["size"] .. ")")
2524 CDWin["font"] = wanted_font["name"]
2525 CDWin["font_size"] = wanted_font["size"]
2526 WindowFont (CDWin["name"], "f", CDWin["font"], CDWin["font_size"], false, false, false, false)
2527 ResizeCDWin()
2528 UpdateCDWinStatic()
2529 else
2530 SMNote("Keeping font\\size as it was before.")
2531 end
2532 end
2533 elseif result == 11 then
2534 local chosen_colour = PickColour(ColourNameToRGB(CompassWin["colour"]["text1"]))
2535 if chosen_colour ~= -1 then
2536 --Note("colour = " .. RGBColourToName(chosen_colour))
2537 if CompassWin["colour"]["text1"] == RGBColourToName(chosen_colour) then
2538 SMNote("Cooldown miniwindow text1 is already: " .. RGBColourToName(chosen_colour))
2539 else
2540 CompassWin["colour"]["text1"] = RGBColourToName(chosen_colour)
2541 UpdateCompassWin()
2542 end
2543 end
2544 elseif result == 12 then
2545 local chosen_colour = PickColour(ColourNameToRGB(CompassWin["colour"]["border1"]))
2546 if chosen_colour ~= -1 then
2547 --Note("colour = " .. RGBColourToName(chosen_colour))
2548 if CompassWin["colour"]["border1"] == RGBColourToName(chosen_colour) then
2549 SMNote("Cooldown miniwindow border1 is already: " .. RGBColourToName(chosen_colour))
2550 else
2551 CompassWin["colour"]["border1"] = RGBColourToName(chosen_colour)
2552 UpdateCompassWin()
2553 end
2554 end
2555 elseif result == 13 then
2556 local chosen_colour = PickColour(ColourNameToRGB(CompassWin["colour"]["border2"]))
2557 if chosen_colour ~= -1 then
2558 --Note("colour = " .. RGBColourToName(chosen_colour))
2559 if CompassWin["colour"]["border2"] == RGBColourToName(chosen_colour) then
2560 SMNote("Cooldown miniwindow border2 is already: " .. RGBColourToName(chosen_colour))
2561 else
2562 CompassWin["colour"]["border2"] = RGBColourToName(chosen_colour)
2563 UpdateCompassWin()
2564 end
2565 end
2566 elseif result == 14 then
2567 local chosen_colour = PickColour(ColourNameToRGB(CompassWin["colour"]["back"]))
2568 if chosen_colour ~= -1 then
2569 --Note("colour = " .. RGBColourToName(chosen_colour))
2570 if CompassWin["colour"]["back"] == RGBColourToName(chosen_colour) then
2571 SMNote("Cooldown miniwindow back is already: " .. RGBColourToName(chosen_colour))
2572 else
2573 CompassWin["colour"]["back"] = RGBColourToName(chosen_colour)
2574 UpdateCompassWin()
2575 end
2576 end
2577 elseif result == 15 then
2578 if CompassWin["size"] == "full" then
2579 SMNote("Compass directions are already 'full'.")
2580 else
2581 CompassWin["size"] = "full"
2582 ResizeCompassWin()
2583 UpdateCompassWin()
2584 end
2585 elseif result == 16 then
2586 if CompassWin["size"] == "medium" then
2587 SMNote("Compass directions are already 'medium'.")
2588 else
2589 CompassWin["size"] = "medium"
2590 ResizeCompassWin()
2591 UpdateCompassWin()
2592 end
2593 elseif result == 17 then
2594 if CompassWin["size"] == "short" then
2595 SMNote("Compass directions are already 'short'.")
2596 else
2597 CompassWin["size"] = "short"
2598 ResizeCompassWin()
2599 UpdateCompassWin()
2600 end
2601 elseif result == 18 then
2602 local SelectTable = {}
2603 for i, v in ipairs(CompassPoints) do
2604 table.insert(SelectTable, v[1])
2605 end
2606 local dir_result = utils.listbox ("Select a direction for north", "Select North", SelectTable, CompassWin["north"])
2607 --Note("dir_result = "..dir_result)
2608 CompassWin["north"] = CompassPoints[dir_result][1]
2609 UpdateCompassWin()
2610 elseif result == 19 then
2611 RotateCompass("clockwise")
2612 elseif result == 20 then
2613 RotateCompass("counterclockwise")
2614 elseif result == 21 then
2615 SailReset("cd")
2616 elseif result == 22 then
2617 SailReset("sailstat")
2618 elseif result == 23 then
2619 SailReset("compass")
2620 elseif result == 24 then
2621 SailReset("all")
2622 end
2623 end
2624end -- mouseup
2625
2626function CompassWinDragMove(flags, hotspot_id)
2627 CompassWin["dragging"] = true
2628 if hotspot_id == "whole" then
2629 local posx, posy = WindowInfo (CompassWin["name"], 17), WindowInfo (CompassWin["name"], 18)
2630 -- move the window to the new location
2631 WindowPosition(CompassWin["name"], posx - startx, posy - starty, 0, 2)
2632
2633 -- change the mouse cursor shape appropriately
2634 if posx < 0 or posx > GetInfo (281) or posy < 0 or posy > GetInfo (280) then
2635 check (SetCursor ( 11)) -- X cursor
2636 else
2637 check (SetCursor ( 1)) -- hand cursor
2638 end -- if
2639 end
2640end -- CompassWinDragMove
2641
2642function CompassWinDragRelease(flags, hotspot_id)
2643 --DebugNote("No longer dragging")
2644 CompassWin["dragging"] = false
2645
2646 CompassWin["pos_x"] = WindowInfo (CompassWin["name"], 10)
2647 CompassWin["pos_y"] = WindowInfo (CompassWin["name"], 11)
2648
2649 --mainly if we need to update window after drag
2650 for i, vFunc in ipairs(tUpdateAfterDrag) do
2651 vFunc()
2652 table.remove(tUpdateAfterDrag, i)
2653 end
2654end -- CompassWinDragRelease
2655
2656function TestFunction()
2657 Note("THIS WORKED!!")
2658end
2659
2660CDWin = {
2661["name"] = "cdwin" .. GetPluginID (),
2662["notes"] = {
2663 10, 5,
2664 ["show"] = true,
2665 },
2666["font"] = "Consolas",
2667["font_size"] = 9,
2668["padding"] = 2.5,
2669["cd_text"] = "[SM]",
2670["colour"] = {
2671 ["text1"] = "limegreen",
2672 ["text2"] = "white",
2673 ["border1"] = "limegreen",
2674 ["border2"] = "green",
2675 ["back"] = "black",
2676 ["time"] = {
2677 {10, "yellow"},
2678 {5, "red"}
2679 }
2680 },
2681["display"] = true,
2682["dragging"] = false,
2683}
2684assert (loadstring (GetVariable ("CDWin") or "")) ()
2685
2686SailStatWin = {
2687["name"] = "sailstatwin" .. GetPluginID (),
2688["font"] = "Consolas",
2689["font_size"] = 9,
2690["padding"] = 2.5,
2691["colour"] = {
2692 ["text1"] = "limegreen",
2693 ["text2"] = "white",
2694 ["border1"] = "limegreen",
2695 ["border2"] = "green",
2696 ["back"] = "black",
2697 },
2698["display"] = {
2699 ["notes"] = true,
2700 ["window"] = "always", --always, sailing, never
2701 ["secs"] = 15,
2702 ["time"] = true,
2703 ["xp_gained"] = true,
2704 ["rate"] = true,
2705 },
2706["display_monster"] = false, --to display monster stats or not
2707["dragging"] = false,
2708}
2709assert (loadstring (GetVariable ("SailStatWin") or "")) ()
2710
2711CompassWin = {
2712["name"] = "compass" .. GetPluginID (),
2713["font"] = "Consolas",
2714["font_size"] = 9,
2715["padding"] = 2.5,
2716["colour"] = {
2717 ["text1"] = "limegreen",
2718 --["text2"] = "white",
2719 ["border1"] = "limegreen",
2720 ["border2"] = "green",
2721 ["back"] = "black",
2722 },
2723["north"] = "hubwards",
2724["size"] = "medium", --full, medium, short
2725["display"] = "never",--always, sailing, never
2726["dragging"] = false,
2727}
2728assert (loadstring (GetVariable ("CompassWin") or "")) ()
2729
2730function CreateCDWin()
2731 WindowCreate (CDWin["name"], 0, 0, 0, 0, miniwin.pos_center_all, 0, ColourNameToRGB(CDWin["colour"]["back"])) -- we must load the window before we can load fonts
2732 WindowFont (CDWin["name"], "f", CDWin["font"], CDWin["font_size"], false, false, false, false)
2733 CDWin["font_height"] = WindowFontInfo (CDWin["name"], "f", 1)
2734
2735 local sLongestText = CDWin["cd_text"].." 00:00s"
2736 CDWin["height"] = CDWin["font_height"] + (CDWin["padding"] * 2)
2737 CDWin["width"] = WindowTextWidth (CDWin["name"], "f", sLongestText) + (CDWin["padding"] * 2)
2738
2739 WindowResize(CDWin["name"], CDWin["width"], CDWin["height"], ColourNameToRGB(CDWin["colour"]["back"]))
2740
2741 --Note("x = " .. tostring(CDWin["pos_x"]).. "|y = " .. tostring(CDWin["pos_y"]))
2742 if CDWin["pos_x"] ~= nil and CDWin["pos_x"] ~= nil then
2743 WindowPosition(CDWin["name"], CDWin["pos_x"], CDWin["pos_y"], miniwin.pos_center_all, 2)
2744 else
2745 WindowPosition(CDWin["name"], 0, 0, miniwin.pos_center_all, 2)
2746 end
2747
2748 if CDWin["display"] == true then
2749 UpdateCDWinStatic()
2750 WindowShow(CDWin["name"], true)
2751 --EnableTimer("cdwin_tic", true)
2752 end
2753 WindowSetZOrder(CDWin["name"], 2001)
2754end
2755
2756function CreateSailStatWin()
2757 WindowCreate (SailStatWin["name"], 0, 0, 0, 0, miniwin.pos_center_all, 0, ColourNameToRGB(SailStatWin["colour"]["back"])) -- we must load the window before we can load fonts
2758 WindowFont (SailStatWin["name"], "f", SailStatWin["font"], SailStatWin["font_size"], false, false, false, false)
2759 SailStatWin["font_height"] = WindowFontInfo (SailStatWin["name"], "f", 1)
2760
2761 local sLongestText = "Total: 14:12s, 1.62m XP (2.55m XP/hr)"
2762 SailStatWin["width"] = WindowTextWidth (SailStatWin["name"], "f", sLongestText) + (SailStatWin["padding"] * 2)
2763
2764 if SailStatWin["display_monster"] == true then
2765 SailStatWin["height"] = (SailStatWin["font_height"]*7) + (SailStatWin["padding"] * 2)
2766 else
2767 SailStatWin["height"] = (SailStatWin["font_height"]*6) + (SailStatWin["padding"] * 2)
2768 end
2769
2770 ResizeSailStatWin()
2771 --WindowResize(SailStatWin["name"], SailStatWin["width"], SailStatWin["height"], ColourNameToRGB(SailStatWin["colour"]["back"]))
2772
2773 if SailStatWin["pos_x"] ~= nil and SailStatWin["pos_x"] ~= nil then
2774 WindowPosition(SailStatWin["name"], SailStatWin["pos_x"], SailStatWin["pos_y"], miniwin.pos_center_all, 2)
2775 --default _under_ CDWin
2776 else
2777 if CDWin["pos_x"] == nil and CDWin["pos_x"] == nil then
2778 if CDWin["height"] ~= nil and CDWin["display"] == true then
2779 WindowPosition(SailStatWin["name"], 0, CDWin["height"], miniwin.pos_center_all, 2)
2780 else
2781 WindowPosition(SailStatWin["name"], 0, SailStatWin["font_height"] + (SailStatWin["padding"] * 2), miniwin.pos_center_all, 2)
2782 end
2783 else
2784 if CDWin["height"] ~= nil then
2785 WindowPosition(SailStatWin["name"], CDWin["pos_x"], CDWin["pos_y"]+CDWin["height"], miniwin.pos_center_all, 2)
2786 else
2787 WindowPosition(SailStatWin["name"], CDWin["pos_x"], SailStatWin["font_height"] + (SailStatWin["padding"] * 2), miniwin.pos_center_all, 2)
2788 end
2789 end
2790 end
2791
2792 if SailStatWin["display"]["window"] == "always" then
2793 WindowShow(SailStatWin["name"], true)
2794 UpdateSailStatWin()
2795 end
2796 if SailStatWin["display"]["window"] == "sailing" and bIsSailing == true then
2797 WindowShow(SailStatWin["name"], true)
2798 UpdateSailStatWin()
2799 end
2800 WindowSetZOrder(SailStatWin["name"], 2000)
2801end
2802
2803function CreateCompassWin()
2804 WindowCreate (CompassWin["name"], 0, 0, 0, 0, miniwin.pos_center_all, 0, ColourNameToRGB(CompassWin["colour"]["back"])) -- we must load the window before we can load fonts
2805 WindowFont (CompassWin["name"], "f", CompassWin["font"], CompassWin["font_size"], false, false, false, false)
2806 CompassWin["font_height"] = WindowFontInfo (CompassWin["name"], "f", 1)
2807
2808 local sLongestText = "h"
2809 local iCompassLength = 1
2810 if CompassWin["size"] == "medium" then
2811 iCompassLength = 2
2812 elseif CompassWin["size"] == "short" then
2813 iCompassLength = 3
2814 end
2815
2816 for i, v in ipairs (CompassPoints) do
2817 if string.len(sLongestText) < string.len(v[iCompassLength]) then
2818 sLongestText = v[iCompassLength]
2819 end
2820 end
2821
2822 CompassWin["height"] = (CompassWin["font_height"] * 7) + (CompassWin["padding"] * 2)
2823 CompassWin["width"] = WindowTextWidth (CompassWin["name"], "f", sLongestText .. " <- ship -> " .. sLongestText) + (CompassWin["padding"] * 2)
2824
2825 WindowResize(CompassWin["name"], CompassWin["width"], CompassWin["height"], ColourNameToRGB(CompassWin["colour"]["back"]))
2826
2827 --Note("x = " .. tostring(CompassWin["pos_x"]).. "|y = " .. tostring(CompassWin["pos_y"]))
2828--[[
2829 if CompassWin["pos_x"] ~= nil and CompassWin["pos_x"] ~= nil then
2830 WindowPosition(CompassWin["name"], CompassWin["pos_x"], CompassWin["pos_y"], miniwin.pos_center_all, 2)
2831 else
2832 WindowPosition(CompassWin["name"], 0, 0, miniwin.pos_center_all, 2)
2833 end
2834]]--
2835 if CompassWin["pos_x"] ~= nil and CompassWin["pos_x"] ~= nil then
2836 WindowPosition(CompassWin["name"], CompassWin["pos_x"], CompassWin["pos_y"], miniwin.pos_center_all, 2)
2837 --default _under_ SailStatWin
2838 else
2839 if SailStatWin["pos_x"] == nil and SailStatWin["pos_x"] == nil then
2840 if SailStatWin["height"] ~= nil and SailStatWin["display"]["window"] == "always" then
2841 WindowPosition(CompassWin["name"], 0, WindowInfo(SailStatWin["name"], 2) + WindowInfo(SailStatWin["name"], 4), miniwin.pos_center_all, 2)
2842 elseif SailStatWin["height"] ~= nil and SailStatWin["display"]["window"] == "sailing" and bIsSailing == true then
2843 WindowPosition(CompassWin["name"], 0, WindowInfo(SailStatWin["name"], 2) + WindowInfo(SailStatWin["name"], 4), miniwin.pos_center_all, 2)
2844 else
2845 --try placing below Cooldown...
2846 if CDWin["pos_x"] == nil and CDWin["pos_x"] == nil then
2847 if CDWin["height"] ~= nil and CDWin["display"] == true then
2848 if SailStatWin["display_monster"] == true then
2849 WindowPosition(CompassWin["name"], 0, WindowInfo(CDWin["name"], 2) + WindowInfo(CDWin["name"], 4) + (CompassWin["font_height"]*7) + (CompassWin["padding"] * 2), miniwin.pos_center_all, 2)
2850 else
2851 WindowPosition(CompassWin["name"], 0, WindowInfo(CDWin["name"], 2) + WindowInfo(CDWin["name"], 4) + (CompassWin["font_height"]*6) + (CompassWin["padding"] * 2), miniwin.pos_center_all, 2)
2852 end
2853 else
2854 if SailStatWin["display_monster"] == true then
2855 WindowPosition(CompassWin["name"], 0, (CompassWin["font_height"]*8) + (CompassWin["padding"] * 4), miniwin.pos_center_all, 2)
2856 else
2857 WindowPosition(CompassWin["name"], 0, (CompassWin["font_height"]*7) + (CompassWin["padding"] * 4), miniwin.pos_center_all, 2)
2858 end
2859 end
2860 else
2861 if CDWin["height"] ~= nil and CDWin["display"] == true then
2862 if SailStatWin["display_monster"] == true then
2863 WindowPosition(CompassWin["name"], CDWin["pos_x"], WindowInfo(CDWin["name"], 2) + WindowInfo(CDWin["name"], 4) + (CompassWin["font_height"]*7) + (CompassWin["padding"] * 2), miniwin.pos_center_all, 2)
2864 else
2865 WindowPosition(CompassWin["name"], CDWin["pos_x"], WindowInfo(CDWin["name"], 2) + WindowInfo(CDWin["name"], 4) + (CompassWin["font_height"]*6) + (CompassWin["padding"] * 2), miniwin.pos_center_all, 2)
2866 end
2867 else
2868 if SailStatWin["display_monster"] == true then
2869 WindowPosition(CompassWin["name"], CDWin["pos_x"], (CompassWin["font_height"]*8) + (CompassWin["padding"] * 4), miniwin.pos_center_all, 2)
2870 else
2871 WindowPosition(CompassWin["name"], 0, (CompassWin["font_height"]*7) + (CompassWin["padding"] * 4), miniwin.pos_center_all, 2)
2872 end
2873 end
2874 end
2875 end
2876 else
2877 if SailStatWin["height"] ~= nil and SailStatWin["display"]["window"] == "always" then
2878 WindowPosition(CompassWin["name"], SailStatWin["pos_x"], WindowInfo(SailStatWin["name"], 2) + WindowInfo(SailStatWin["name"], 4), miniwin.pos_center_all, 2)
2879 elseif SailStatWin["height"] ~= nil and SailStatWin["display"]["window"] == "sailing" and bIsSailing == true then
2880 WindowPosition(CompassWin["name"], SailStatWin["pos_x"], WindowInfo(SailStatWin["name"], 2) + WindowInfo(SailStatWin["name"], 4), miniwin.pos_center_all, 2)
2881 else
2882 --try placing below Cooldown...
2883 if CDWin["pos_x"] == nil and CDWin["pos_x"] == nil then
2884 if CDWin["height"] ~= nil and CDWin["display"] == true then
2885 if SailStatWin["display_monster"] == true then
2886 WindowPosition(CompassWin["name"], 0, WindowInfo(CDWin["name"], 2) + WindowInfo(CDWin["name"], 4) + (CompassWin["font_height"]*7) + (CompassWin["padding"] * 2), miniwin.pos_center_all, 2)
2887 else
2888 WindowPosition(CompassWin["name"], 0, WindowInfo(CDWin["name"], 2) + WindowInfo(CDWin["name"], 4) + (CompassWin["font_height"]*6) + (CompassWin["padding"] * 2), miniwin.pos_center_all, 2)
2889 end
2890 else
2891 if SailStatWin["display_monster"] == true then
2892 WindowPosition(CompassWin["name"], 0, (CompassWin["font_height"]*8) + (CompassWin["padding"] * 4), miniwin.pos_center_all, 2)
2893 else
2894 WindowPosition(CompassWin["name"], 0, (CompassWin["font_height"]*7) + (CompassWin["padding"] * 4), miniwin.pos_center_all, 2)
2895 end
2896 end
2897 else
2898 if CDWin["height"] ~= nil and CDWin["display"] == true then
2899 if SailStatWin["display_monster"] == true then
2900 WindowPosition(CompassWin["name"], CDWin["pos_x"], WindowInfo(CDWin["name"], 2) + WindowInfo(CDWin["name"], 4) + (CompassWin["font_height"]*7) + (CompassWin["padding"] * 2), miniwin.pos_center_all, 2)
2901 else
2902 WindowPosition(CompassWin["name"], CDWin["pos_x"], WindowInfo(CDWin["name"], 2) + WindowInfo(CDWin["name"], 4) + (CompassWin["font_height"]*6) + (CompassWin["padding"] * 2), miniwin.pos_center_all, 2)
2903 end
2904 else
2905 if SailStatWin["display_monster"] == true then
2906 WindowPosition(CompassWin["name"], CDWin["pos_x"], (CompassWin["font_height"]*8) + (CompassWin["padding"] * 4), miniwin.pos_center_all, 2)
2907 else
2908 WindowPosition(CompassWin["name"], 0, (CompassWin["font_height"]*7) + (CompassWin["padding"] * 4), miniwin.pos_center_all, 2)
2909 end
2910 end
2911 end
2912 end
2913 end
2914 end
2915
2916 if CompassWin["display"] == "always" then
2917 WindowShow(CompassWin["name"], true)
2918 UpdateCompassWin()
2919 end
2920 if CompassWin["display"] == "sailing" and bIsSailing == true then
2921 WindowShow(CompassWin["name"], true)
2922 UpdateCompassWin()
2923 end
2924 WindowSetZOrder(CompassWin["name"], 1999)
2925end
2926
2927CreateCDWin()
2928CreateSailStatWin()
2929CreateCompassWin()
2930
2931function ChangeSailStatWin(sName, sLine, wildcards)
2932 SailStatWin["display"]["window"] = wildcards[1]
2933 Note("Sail display changed to: " .. wildcards[2])
2934
2935end
2936
2937function DisplayCDWindow()
2938 WindowShow(CDWin["name"], true)
2939 CDWin["display"] = true
2940 SMNote("Cooldown window should be showing now.")
2941end
2942]]>
2943</script>
2944<!-- Aliases -->
2945<aliases>
2946 <alias
2947 match="^sail(mate)?win (always|never|sailing)$"
2948 enabled="y"
2949 regexp="y"
2950 ignore_case="y"
2951 sequence="30"
2952 script="ChangeSailStatWin"
2953 ></alias>
2954 <alias
2955 match="^sail(mate)? test$"
2956 enabled="n"
2957 regexp="y"
2958 ignore_case="y"
2959 sequence="30"
2960 script="RunTest"
2961 ></alias>
2962 <alias
2963 match="^sail(mate)? help"
2964 enabled="y"
2965 regexp="y"
2966 ignore_case="y"
2967 sequence="30"
2968 script="SailMateHelp"
2969 ></alias>
2970 <alias
2971 match="^sail(mate)? (?P<group>g)?display(?P<size> full)?$"
2972 enabled="y"
2973 regexp="y"
2974 ignore_case="y"
2975 sequence="30"
2976 script="DisplaySailStats"
2977 ></alias>
2978 <alias
2979 match="^sail(mate)? (?:cooldown|timer|cd)$"
2980 enabled="y"
2981 regexp="y"
2982 ignore_case="y"
2983 sequence="30"
2984 script="DisplayTimers"
2985 ></alias>
2986 <alias
2987 match="^sail(mate)? (?:reset)$"
2988 enabled="y"
2989 regexp="y"
2990 ignore_case="y"
2991 sequence="30"
2992 script="SailReset"
2993 ></alias>
2994 <alias
2995 match="^sail(mate)? show$"
2996 enabled="y"
2997 regexp="y"
2998 ignore_case="y"
2999 sequence="30"
3000 script="DisplayCDWindow"
3001 ></alias>
3002</aliases>
3003
3004<triggers>
3005 <trigger
3006 enabled="y"
3007 keep_evaluating="y"
3008 regexp="y"
3009 match="^(?:Chidder|Captain Smith) says to (?P<who>.+) in Ephebian with a nautical Ephebian accent\: Great\! We'll just get the ship ready\.$"
3010 omit_from_output="n"
3011 script="RealStartSail"
3012 name="RealStartSail"
3013 ></trigger>
3014
3015 <trigger
3016 enabled="y"
3017 keep_evaluating="y"
3018 regexp="y"
3019 match="^The loading of the ship complete, (Captain Smith|Chidder) wishes you a safe and profitable trip as you climb aboard the SS Unsinkable\.$"
3020 omit_from_output="n"
3021 script="StartSail"
3022 name="StartSail"
3023 ></trigger>
3024
3025 <trigger
3026 enabled="n"
3027 keep_evaluating="y"
3028 regexp="y"
3029 match="^(?:Steam whistles from the smokestack as the ship begins to move|You feel the ship begin to move|The ship shudders around you as it turns to.+)\.$"
3030 omit_from_output="n"
3031 script="FinishSearch"
3032 name="FirstMovement"
3033 group="MidSail"
3034 ></trigger>
3035 <trigger
3036 enabled="n"
3037 keep_evaluating="y"
3038 regexp="y"
3039 match="^As you (?:finish|complete) the (?P<stage>first|second|third) leg of your impossible voyage,.+ \((?P<xp>\d+) xp\)$"
3040 omit_from_output="n"
3041 script="FinishStage"
3042 name="FinishStage"
3043 group="MidSail"
3044 ></trigger>
3045 <trigger
3046 enabled="n"
3047 keep_evaluating="y"
3048 regexp="y"
3049 match="^A massive (?:sea )?(?P<monster>kraken|serpent) crests from the water ahead of the ship, seawater sloughing off its (?:dinner-plate-sized scales|many coiling tentacles)\. In a flash, it wraps the SS Unsinkable in its (?:tail|grasp) and eyes you as though you were its next meal - which you might well be, if you don't find a way to drive it off\.$"
3050 omit_from_output="n"
3051 script="MonsterStart"
3052 name="MonsterStart"
3053 group="MidSail"
3054 ></trigger>
3055 <trigger
3056 enabled="n"
3057 keep_evaluating="y"
3058 regexp="y"
3059 match="^As the (?P<monster>kraken|serpent) sinks back beneath the waves, you feel more experienced for having faced it and survived. \((?P<xp>\d+) xp\)$"
3060 omit_from_output="n"
3061 script="MonsterEnd"
3062 name="MonsterEnd"
3063 group="MidSail"
3064 ></trigger>
3065 <trigger
3066 enabled="n"
3067 keep_evaluating="y"
3068 regexp="y"
3069 match="^You have been awarded (?P<xp>\d+) experience points for delivering (?P<crates>\w+) out of eight cargo crates to your destination, working with a group of (?P<group>\w+)\.$"
3070 sequence="12"
3071 omit_from_output="n"
3072 script="FinishSail"
3073 name="FinishSailReward"
3074 group="MidSail"
3075 ></trigger>
3076 <trigger
3077 enabled="n"
3078 keep_evaluating="y"
3079 regexp="y"
3080 match="^As the ship sinks slowly beneath the waves, you dive off the side and manage to grab onto a couple of floating planks that used to be part of the ship\. You drift for what seems like an eternity before finally catching sight of shore\. Battered and bruised, you manage to struggle onto land\.$|You failed your mission because the SS Unsinkable sank\.$"
3081 sequence="12"
3082 omit_from_output="n"
3083 script="SailFail"
3084 name="SailFailSank"
3085 group="MidSail"
3086 ></trigger>
3087 <trigger
3088 enabled="n"
3089 keep_evaluating="y"
3090 regexp="y"
3091 match="^As you swim a little too far from the ship, a current catches you and sweeps you far out\. Soon, you can't see the ship any more, but manage to wash up on a beach before you drown\.$"
3092 sequence="12"
3093 omit_from_output="n"
3094 script="SailFail"
3095 name="SailFailBeeched"
3096 group="MidSail"
3097 ></trigger>
3098 <trigger
3099 enabled="n"
3100 keep_evaluating="y"
3101 regexp="y"
3102 match="^You failed your mission because the SS Unsinkable was abandoned\.$"
3103 sequence="12"
3104 omit_from_output="n"
3105 script="SailFail"
3106 name="SailFailAbandoned"
3107 group="MidSail"
3108 ></trigger>
3109 <trigger
3110 enabled="n"
3111 keep_evaluating="y"
3112 regexp="y"
3113 match="^(Chidder|Captain Smith) exclaims to.+you.+with a nautical Ephebian accent: Everything looks to be in order\. Well done\!$"
3114 sequence="12"
3115 omit_from_output="n"
3116 script="FullSailDisplay"
3117 name="FinishSail"
3118 group="MidSail"
3119 ></trigger>
3120 <trigger
3121 enabled="y"
3122 keep_evaluating="y"
3123 regexp="y"
3124 match="^(?:Chidder|Captain Smith) says to.+you.+with a nautical Ephebian accent: I can't let you start another job for (?:(?P<hour>\w+) hours?)?(?: and )?(?:(?P<mins>(?!and.+).+) minutes?)?(?: and )?(?:(?P<secs>(?!and.+).+) seconds?)?\.$"
3125 sequence="12"
3126 omit_from_output="n"
3127 script="CooldownTime"
3128 name="CooldownTime"
3129 ></trigger>
3130</triggers>
3131<timers>
3132 <timer name="sailstatwin_tic" enabled="n" minute="0" second="1.00" offset_second="0.00" send_to="12"
3133 >
3134 <send>
3135 UpdateSailStatWin()
3136 </send>
3137 </timer>
3138 <timer name="cdwin_tic" enabled="n" minute="0" second="1.00" offset_second="0.00" send_to="12"
3139 >
3140 <send>
3141 UpdateCDWinTime()
3142 </send>
3143 </timer>
3144 </timers>
3145
3146</muclient>