-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathAchaea_Helplist_Miniwindow.xml
More file actions
658 lines (510 loc) · 20.4 KB
/
Achaea_Helplist_Miniwindow.xml
File metadata and controls
658 lines (510 loc) · 20.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
<plugin
name="Achaea_Helplist_Miniwindow"
author="Nick Gammon"
id="588adf89370b6c3e1259ea7e"
language="Lua"
purpose="Makes a helper window with hyperlinks"
date_written="2009-08-12"
requires="4.40"
version="1.0"
save_state="y"
>
<description trim="y">
<![CDATA[
Creates a window with various helpful commands in it, hyperlinked.
Type 'helplist' to toggle the display of the window on and off.
]]>
</description>
</plugin>
<!-- Aliases -->
<aliases>
<alias
name="helplist"
match="helplist"
enabled="y"
sequence="100"
send_to="12"
>
<send>
active = not active
if active then
make_helper_window ()
else
WindowShow (win, false)
end -- if
</send>
</alias>
</aliases>
<script>
<![CDATA[
require "serialize" -- needed to serialize table to string
require "movewindow"
require "commas"
-- CONFIGURATION ---------------------------------------------------
local HEADING_INDENT = 20
local INDENT = 20
local GAP = 5
local TEXT_GAP = 5
local BACKGROUND_COLOUR = 0x000028
local WINDOW_HEADING = "Help"
local HEADING_COLOUR = ColourNameToRGB "yellow"
local TITLE_COLOUR = ColourNameToRGB "lime"
local DESCRIPTION_COLOUR = ColourNameToRGB "white"
local HELP_COLOUR = ColourNameToRGB "goldenrod"
local DOTS_COLOUR = 0x23325C
expanded = {} -- which ones we expanded
active = true
-- ONE TABLE PER GROUP ITEM ---------------------------------------
spells = {
{ name = "Skills", desc = "List of skills." },
-- { name = "Spells", desc = "List of spells." },
-- { name = "Spells spellup", desc = "List of spellups (buffs)." },
-- { name = "Spells combat", desc = "List of combat abilities." },
-- { name = "Affects", desc = "Current affects (buffs) on you." },
} -- end spells
movement = {
-- { name = "Areas", desc= "Shows all areas in a level range." },
-- { name = "Recall", desc= "Returns you to Aylor Grand Temple." },
-- { name = "Speedwalks", desc= "Available speedwalks." },
-- { name = "Mobdeaths", desc= "Shows most frequently killed mobs (monsters) " },
-- { name = "Mobkills", desc= "Shows the mobs that most often kill players. " },
-- { name = "Areadeaths", desc= "Shows areas with at least one mob killed. " },
-- { name = "Areakills", desc= "Shows the mobs that most often kill players overall. " },
-- { name = "Find all", desc= "Shows nearby places of interest in the city. " },
-- { name = "Bigmap", desc= "Outdoors (not in an area), shows a large map." },
{ name = "Look", desc= "Look around current room." },
{ name = "Exits", desc= "See room exits." },
{ name = "Survey", desc= "General information about where you are." },
{ name = "Portals", desc= "Go to room of portals (levels 1-20)." },
} -- end movement
todo = {
--
{ name = "Quests", desc = "See a list of quests you have open." },
{ name = "Greet", desc = "Greet a citizen to find a quest." },
{ name = "Abilities", desc = "Shows your abilities." },
{ name = "House list", desc = "Houses you can join." },
{ name = "Tasks", desc = "Things to do." },
-- { name = "Quest Info", desc = "Show information about current quest" },
-- { name = "Train", desc = "Show training costs for each of your stats." },
-- { name = "Raceinfo", desc = "Show training costs modifiers for your race." },
-- { name = "Exp", desc = "Experience you have, and need to level up." },
} -- end todo
-- Information about you
mystuff = {
{ name = "Score", desc = "Important information about your character." },
{ name = "Inven", desc = "What you are wearing and holding." },
{ name = "Stat", desc = "More info about you." },
{ name = "Probe pack", desc = "Look in your pack." },
{ name = "Info here", desc = "Shows what is here with you." },
{ name = "Info inv", desc = "Your inventory in detail." },
{ name = "Who here", desc = "Shows who is here with you." },
-- { name = "Equip", desc = "What you are wearing." },
-- { name = "Hunger", desc = "Hunger and thirst." },
-- { name = "Config", desc = "Your configuration options." },
{ name = "Wares", desc = "Show what is for sale, if at a shop." },
-- { name = "Worth", desc = "Shows your gold, bank balance, etc." },
-- { name = "Myrank", desc = "Things you have done." },
--
} -- end mystuff
combat = {
--
-- { name = "Consider all", desc = "Compare your own strength to others in the room." },
-- { name = "Scan", desc = "Show characters in the immediate area." },
-- { name = "Study", desc = "Show health of all characters in the room." },
-- { name = "Where", desc = "Shows players nearby (or 'WHERE <mob>' to find a mob)." },
-- { name = "Flee", desc = "Attempt to run away during combat. Costs experience." },
-- { name = "Wimpy", desc = "Set character to auto flee when low on hit points." },
-- { name = "Ownedwhere", desc = "Shows items you own, including your corpses." },
-- { name = "Read page6", desc = "Shows popular low-level areas." },
} -- end combat
comms = {
{ name = "Newbie", desc = "Talk on the newbie channel." },
-- { name = "Friend", desc = "See your friends." },
-- { name = "Info", desc = "View/Toggle Game info channels." },
-- { name = "Quiet", desc = "Temporarily turn channels off/on (toggle)." },
-- { name = "Socials", desc = "List socials in game." },
-- { name = "Random", desc = "Use a random social." },
-- { name = "Forums", desc = "See available message forums." },
-- { name = "Note", desc = "Read next unread note." },
-- { name = "Clist", desc = "Show list of clans." },
{ name = "Who", desc = "Show who is on Achaea." },
{ name = "QW", desc = "Short 'who' list." },
-- { name = "Who helper", desc = "Show players prepared to help you." },
-- { name = "CatchTells", desc = "Stores all tells sent to you (toggle)." },
-- { name = "Replay", desc = "Displays all saved/caught tells." },
} -- end comms
help = {
{ name = "Help help", desc = "Introductory help." },
--
} -- end help
-- GROUPS OF HELP --------------------------------------------------------
-- groups of related things - one item per help category
groups = {
{ name = "Spells and skills", list = spells,
-- extrafunc =
-- function ()
-- ShowText ("To get spells and skills training, do ")
-- ShowHyperlink ("recall")
-- ShowText (" and then ")
-- ShowHyperlink ("run u6ne")
-- end,
-- extrahelp = { "Train", "Practice", "Learned", "Showspell", "Allspells"},
}, -- end Spells and skills
{ name = "Movement", list = movement,
-- extrahelp = { "coordinates", "world", "shortmap", "maptags", "explored", "enter" },
extrahelp = { "landmarks", "walk to", },
}, -- end Movement
{ name = "To do / improvements", list = todo,
extrahelp = { "Newbie quests", "Sleep", "Stand", "Med", "Sip", "Learning", "Basecommands",
},
-- extrahelp = { "Eat", "Drink", "Gulp", "Run", "Find", "aq", "Listen", "www", "rules" },
}, -- end To do
{ name = "Information about you", list = mystuff,
extrahelp = { "Wear", "Remove", "Honours", "Buy", "Rift",
},
-- extrahelp = { "Appraise", "Identify", "Value", "Buy",
-- "Sell", "Bid", "Auction", "Deposit", "Withdraw",
-- "Experience", "Alignment", "Get", "Drop",
-- "Wear", "Wield", "Hold", "Remove", "Object Flags",
-- "Qp", "Tp", "Newhelp", "Where" },
}, -- end Information
{ name = "Combat", list = combat,
-- extrafunc =
-- function ()
-- ShowText ("To get healed, cured or restored, do ")
-- ShowHyperlink ("recall")
-- ShowText (", ")
-- ShowHyperlink ("run 3e")
-- ShowText (" and then ")
-- ShowHyperlink ("heal")
-- end,
-- extrahelp = { "Healing", "Death", "Cr", "Cast",
-- "Sleep", "Wake", "Group", "pk", "hunt"},
extrahelp = { "Seasone", },
}, -- end Combat
{ name = "Communications", list = comms,
extrahelp = { "Tell", "Reply", "Channels",
},
-- extrahelp = { "Tell", "Reply", "Ignore", "Whois", "Warinfo",
-- "Say", "Emote", "Note", "Subscribe", "Forum",
-- "afk", "deaf", "ignore", "rank" },
}, -- end Communications
{ name = "Help", list = help,
-- extrafunc =
-- function ()
-- ShowText ("Type 'HELP <subject>' for help, 'HELP SEARCH <word>' to search for a word.")
-- local line1_x = x
--
-- -- start a new line
-- x = INDENT
-- y = y + font_height
-- ShowText ("Type 'INDEX <x>' for help on words beginning with x.")
--
-- x = math.max (x, line1_x) -- make sure we return the maximum width we took
-- return 2 -- we showed 2 lines
-- end,
}, -- end Help
} -- end groups
-- END CONFIGURABLE STUFF ---------------------------------------------------------
function click_hyperlink (flags, hotspotid)
local item = tonumber (hotspotid)
local text = hyperlinks [item]
if not text then return end
if IsConnected () then
Send (text)
else
ColourNote ("yellow", "", "Cannot send '" .. text .. "' - not connected.")
end -- if
end -- click_hyperlink
function click_group (flags, hotspotid)
expanded [hotspotid] = not expanded [hotspotid]
-- shift+click = expand or contract all of them
if bit.band (flags, 0x01) ~= 0 then
for k, g in ipairs (groups) do
expanded [g.name] = expanded [hotspotid]
end -- for each group
end -- if
make_helper_window ()
end -- click_hyperlink
function ShowText (text, colour)
colour = colour or ColourNameToRGB "silver"
WindowText (win, font_id, text, x, y, 0, 0, colour)
x = x + WindowTextWidth (win, font_id, text)
end -- ShowText
function ShowHyperlink (text, colour, help_hyperlink)
colour = colour or ColourNameToRGB "yellow"
local hyperlink_text
local lower_text = text:lower ()
if help_hyperlink then
hyperlink_text = "help " .. lower_text
text = text:upper ()
else
hyperlink_text = lower_text
end -- if
local width = WindowText (win, font_id_ul, text, x, y, 0, 0, colour)
table.insert (hyperlinks, hyperlink_text)
local item = #hyperlinks
local balloon
if help_hyperlink then
balloon = "Click to get help on:\t" .. lower_text
else
balloon = "Click to send:\t" .. lower_text
end -- if
WindowAddHotspot (win, item, x, y, x + width, y + font_height,
"", -- MouseOver
"", -- CancelMouseOver
"", -- MouseDown
"", -- CancelMouseDown
"click_hyperlink", -- MouseUp
balloon,
1, -- Cursor
0) -- Flag
x = x + WindowTextWidth (win, font_id_ul, text)
end -- ShowHyperlink
function ShowExtraHelp (tbl)
x = TEXT_GAP
ShowText ("Also see ")
local also_see_end = x
table.sort (tbl, function (a, b) return a:upper () < b:upper () end )
local total = #tbl
for i, item in ipairs (tbl) do
if i ~= 1 then
if i == total then
ShowText (" and ")
else
ShowText (", ")
end -- if
end -- not first one
local seperator
local seperator_width = 0
if i < total then
if i == (total - 1) then
seperator = " and "
else
seperator = ", "
end -- if
seperator_width = WindowTextWidth (win, font_id, seperator)
end -- not last one
if (x + WindowTextWidth (win, font_id_ul, item)+ seperator_width) > (window_width - TEXT_GAP) then
x = also_see_end -- line up under "Also see"
y = y + font_height -- new line
end -- if line too long
ShowHyperlink (item, HELP_COLOUR, true) -- is help item
end -- for each item
y = y + font_height
end -- ShowExtraHelp
function GetExtraHelpLines (tbl)
local lines = 1 -- at least one line
local x = TEXT_GAP + WindowTextWidth (win, font_id, "Also see ")
local also_see_end = x
table.sort (tbl, function (a, b) return a:upper () < b:upper () end )
local total = #tbl
for i, item in ipairs (tbl) do
local seperator
if i < total then
if i == (total - 1) then
seperator = " and "
else
seperator = ", "
end -- if
x = x + WindowTextWidth (win, font_id, seperator)
end -- not last one
if (x + WindowTextWidth (win, font_id_ul, item)) > (window_width - TEXT_GAP) then
x = also_see_end -- line up under "Also see"
lines = lines + 1 -- new line
end -- if line too long
x = x + WindowTextWidth (win, font_id_ul, item)
end -- for each item
return lines
end -- GetExtraHelpLines
function show_a_group (g)
local triangle_size = 8
local points
local balloon
if expanded [g.name] then
balloon = "Click to hide"
points = string.format ("%i,%i,%i,%i,%i,%i",
TEXT_GAP, y + 2, -- top left
TEXT_GAP + triangle_size, y + 2, -- top right
TEXT_GAP + triangle_size / 2, y + triangle_size) -- bottom (in middle)
else
balloon = "Click to expand"
points = string.format ("%i,%i,%i,%i,%i,%i",
TEXT_GAP + 2, y + triangle_size + 2, -- top left
TEXT_GAP + 2, y + 2, -- bottom left
TEXT_GAP + 2 + triangle_size / 2, y + triangle_size / 2 + 2) -- right (in middle)
end -- if
-- disclosure triangle
WindowPolygon(win, points, HEADING_COLOUR, 0, 1, HEADING_COLOUR, 0, true, true)
x = HEADING_INDENT
x = x + WindowText (win, font_id, g.name, x, y, 0, 0, HEADING_COLOUR)
WindowAddHotspot (win, g.name, TEXT_GAP, y, x, y + font_height,
"", -- MouseOver
"", -- CancelMouseOver
"", -- MouseDown
"", -- CancelMouseDown
"click_group", -- MouseUp
balloon,
1, -- Cursor
0) -- Flag
y = y + font_height
if not expanded [g.name] then
return
end -- don't show anything else
-- may as well put commands in alphabetic order
table.sort (g.list, function (a, b) return a.name < b.name; end)
-- show each one
for k, v in ipairs (g.list) do
x = INDENT
ShowHyperlink (v.name, TITLE_COLOUR)
WindowLine(win, x + 2, y + ascent, INDENT + max_title_width + GAP - 2, y + ascent, DOTS_COLOUR, 2, 1)
x = INDENT + max_title_width + GAP
ShowText (v.desc, DESCRIPTION_COLOUR)
y = y + font_height
end -- for loop
-- anything extra in this group?
if g.extrafunc then
x = INDENT
g.extrafunc ()
y = y + font_height
end -- call function to do special stuff
-- additional table of things to put "help" in front of
if g.extrahelp then
ShowExtraHelp (g.extrahelp)
end -- table of additional things
-- show additional string
if g.extrastr then
x = INDENT
ShowText(g.extrastr)
y = y + font_height
end -- extra string to show
-- blank line between groups
y = y + font_height
end -- show_a_group
function make_helper_window ()
hyperlinks = {}
local lines = 0
max_title_width = 0
max_description_width = 0
window_width = 0
y = TEXT_GAP
local last_one_expanded = false
for k, g in ipairs (groups) do
if expanded [g.name] then
lines = lines + #g.list + 2 -- one for heading, plus one line each, and one for blank line
if g.extrafunc then
x = INDENT
lines = lines + (g.extrafunc () or 1)
window_width = math.max (window_width, x + TEXT_GAP)
end -- if
if g.extrastr then
lines = lines + 1
window_width = math.max (window_width, WindowTextWidth (win, font_id, g.extrastr) + INDENT)
end -- if
-- measure each one
for k, v in ipairs (g.list) do
max_title_width = math.max (max_title_width, WindowTextWidth (win, font_id, v.name))
max_description_width = math.max (max_description_width, WindowTextWidth (win, font_id, v.desc))
end -- for loop
last_one_expanded = true
else
lines = lines + 1
window_width = math.max (window_width, WindowTextWidth (win, font_id, g.name) + HEADING_INDENT + TEXT_GAP)
last_one_expanded = false
end -- if
end -- for each group
window_width = math.max (window_width, INDENT + max_title_width + GAP + max_description_width + TEXT_GAP)
-- now we know the width, see how many extra lines are needed
for k, g in ipairs (groups) do
if g.extrahelp and expanded [g.name] then
lines = lines + GetExtraHelpLines (g.extrahelp)
end -- if
end -- for each group
-- don't need final blank line if that part was expanded
if last_one_expanded then
lines = lines - 1
end -- if
window_height = (lines + 1) * font_height + TEXT_GAP * 2
-- recreate the window the correct size
WindowCreate (win,
windowinfo.window_left,
windowinfo.window_top,
window_width, -- width
window_height, -- height
windowinfo.window_mode,
windowinfo.window_flags,
BACKGROUND_COLOUR)
WindowDeleteAllHotspots (win)
movewindow.add_drag_handler (win, 0, 0, 0, font_height, 1)
-- draw drag bar rectangle
WindowRectOp (win, 2, 0, 0, 0, font_height + TEXT_GAP, 0x8CE6F0)
-- heading
y = WindowFontInfo (win, font_id, 4)
x = (window_width - WindowTextWidth (win, font_id, WINDOW_HEADING)) / 2
ShowText (WINDOW_HEADING, 0x000000)
y = TEXT_GAP + font_height
for k, g in ipairs (groups) do
show_a_group (g)
end -- for each group
-- DrawEdge rectangle
WindowRectOp (win, 5, 0, 0, 0, 0, 10, 15)
WindowShow (win, true)
end -- make_helper_window
function IntroduceOurselves ()
Tell ("Type ")
Hyperlink ("helplist", "", "", "yellow", "")
Note (" for some helpful information about Aardwolf.")
end --
function OnPluginInstall ()
win = GetPluginID ()
local fonts = utils.getfontfamilies ()
if fonts.Dina then
font_size = 8
font_name = "Dina" -- the actual font
else
font_size = 10
font_name = "Courier"
end -- if
font_id = "help_font" -- our internal name
font_id_ul = "help_font_ul" -- our internal name
windowinfo = movewindow.install (win, 6)
-- make miniwindow so I can grab the font info
check (WindowCreate (win,
windowinfo.window_left,
windowinfo.window_top,
1, 1,
windowinfo.window_mode,
windowinfo.window_flags,
BACKGROUND_COLOUR) )
WindowFont (win, font_id, font_name, font_size, false, false, false, false, 0, 49) -- normal
font_height = WindowFontInfo (win, font_id, 1) -- height
ascent = WindowFontInfo (win, font_id, 2)
descent = WindowFontInfo (win, font_id, 3)
font_width = WindowFontInfo (win, font_id, 6) -- avg width
WindowFont (win, font_id_ul, font_name, font_size, false, false, true, false, 0, 49) -- normal
if GetVariable ("enabled") == "false" then
ColourNote ("yellow", "", "Warning: Plugin " .. GetPluginName ().. " is currently disabled.")
check (EnablePlugin(GetPluginID (), false))
return
end -- they didn't enable us last time
assert (loadstring (GetVariable ("expanded") or "")) ()
OnPluginEnable () -- do initialization stuff
end -- OnPluginInstall
function OnPluginEnable ()
make_helper_window ()
end -- OnPluginEnable
function OnPluginDisable ()
WindowShow (win, false)
end -- OnPluginDisable
function OnPluginSaveState ()
SetVariable ("enabled", tostring (GetPluginInfo (GetPluginID (), 17)))
movewindow.save_state (win)
SetVariable ("expanded",
"expanded = " .. serialize.save_simple (expanded))
end -- OnPluginSaveState
]]>
</script>
</muclient>