Initial addons
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
de17b0006e
17 changed files with 3257 additions and 0 deletions
336
DungeonPreQuest/Data.lua
Normal file
336
DungeonPreQuest/Data.lua
Normal file
|
|
@ -0,0 +1,336 @@
|
|||
-- Generated from QuestieDB's Forever quest data. Do not edit.
|
||||
-- quests[id] = { dungeon, faction, classes, ... }; faction 1 Alliance, 2 Horde, 3 both; classes 0 = all; dungeon 0 = unnamed.
|
||||
local _, ns = ...
|
||||
|
||||
ns.dungeons = {
|
||||
"Blackfathom Deeps",
|
||||
"Blackrock Depths",
|
||||
"Blackrock Spire",
|
||||
"Dire Maul",
|
||||
"Gnomeregan",
|
||||
"Maraudon",
|
||||
"Ragefire Chasm",
|
||||
"Razorfen Downs",
|
||||
"Razorfen Kraul",
|
||||
"Scarlet Monastery",
|
||||
"Scholomance",
|
||||
"Shadowfang Keep",
|
||||
"Stratholme",
|
||||
"The Deadmines",
|
||||
"The Stockade",
|
||||
"The Temple of Atal'Hakkar",
|
||||
"Uldaman",
|
||||
"Wailing Caverns",
|
||||
"Zul'Farrak",
|
||||
}
|
||||
|
||||
ns.quests = {
|
||||
[65]={14,1,0},
|
||||
[132]={14,1,0},
|
||||
[135]={14,1,0},
|
||||
[141]={14,1,0},
|
||||
[142]={14,1,0},
|
||||
[155]={14,1,0},
|
||||
[261]={10,1,0},
|
||||
[303]={15,1,0},
|
||||
[373]={15,1,0},
|
||||
[389]={15,1,0},
|
||||
[707]={17,1,0},
|
||||
[720]={17,1,0},
|
||||
[723]={17,1,0},
|
||||
[724]={17,1,0},
|
||||
[725]={17,1,0},
|
||||
[726]={17,1,0},
|
||||
[738]={17,1,0},
|
||||
[739]={17,1,0},
|
||||
[762]={17,1,0},
|
||||
[865]={18,3,0},
|
||||
[870]={18,2,0},
|
||||
[877]={18,2,0},
|
||||
[880]={18,2,0},
|
||||
[886]={18,2,0},
|
||||
[1052]={10,1,0},
|
||||
[1100]={9,1,0},
|
||||
[1109]={10,2,0},
|
||||
[1149]={10,2,0},
|
||||
[1150]={10,2,0},
|
||||
[1151]={10,2,0},
|
||||
[1152]={10,2,0},
|
||||
[1154]={10,2,0},
|
||||
[1159]={10,2,0},
|
||||
[1424]={16,2,0},
|
||||
[1429]={16,2,0},
|
||||
[1444]={16,2,0},
|
||||
[1448]={16,1,0},
|
||||
[1449]={16,1,0},
|
||||
[1450]={16,1,0},
|
||||
[1451]={16,1,0},
|
||||
[1452]={16,1,0},
|
||||
[1469]={16,1,0},
|
||||
[1649]={0,1,2},
|
||||
[1650]={0,1,2},
|
||||
[1651]={0,1,2},
|
||||
[1652]={0,1,2},
|
||||
[1793]={0,1,2},
|
||||
[1794]={0,1,2},
|
||||
[1947]={0,3,128},
|
||||
[1949]={0,3,128},
|
||||
[1950]={0,3,128},
|
||||
[1953]={0,3,128},
|
||||
[1954]={0,3,128},
|
||||
[1955]={0,3,128},
|
||||
[2041]={14,1,0},
|
||||
[2258]={17,2,0},
|
||||
[2500]={17,1,0},
|
||||
[2769]={19,1,0},
|
||||
[2933]={19,2,0},
|
||||
[2934]={19,2,0},
|
||||
[2935]={19,2,0},
|
||||
[2988]={19,1,0},
|
||||
[2989]={19,1,0},
|
||||
[2990]={19,1,0},
|
||||
[3441]={2,3,0},
|
||||
[3442]={2,3,0},
|
||||
[3443]={2,3,0},
|
||||
[3444]={16,3,0},
|
||||
[3445]={16,1,0},
|
||||
[3452]={2,3,0},
|
||||
[3453]={2,3,0},
|
||||
[3454]={2,3,0},
|
||||
[3462]={2,3,0},
|
||||
[3463]={2,3,0},
|
||||
[3481]={2,3,0},
|
||||
[3520]={3,3,0,16,3,0,19,3,0},
|
||||
[3527]={3,3,0,16,3,0},
|
||||
[3528]={3,3,0},
|
||||
[3701]={2,1,0},
|
||||
[3702]={2,1,0},
|
||||
[3765]={1,1,0},
|
||||
[3906]={2,2,0},
|
||||
[4022]={2,3,0},
|
||||
[4023]={2,3,0},
|
||||
[4061]={2,2,0},
|
||||
[4062]={2,2,0},
|
||||
[4141]={0,1,0},
|
||||
[4142]={0,1,0},
|
||||
[4145]={0,2,0},
|
||||
[4146]={0,2,0},
|
||||
[4147]={0,2,0},
|
||||
[4182]={2,1,0,3,1,0},
|
||||
[4183]={2,1,0,3,1,0},
|
||||
[4184]={2,1,0,3,1,0},
|
||||
[4185]={2,1,0,3,1,0},
|
||||
[4186]={2,1,0,3,1,0},
|
||||
[4223]={2,1,0,3,1,0},
|
||||
[4224]={2,1,0,3,1,0},
|
||||
[4241]={3,1,0},
|
||||
[4242]={3,1,0},
|
||||
[4262]={2,1,0},
|
||||
[4264]={3,1,0},
|
||||
[4282]={3,1,0},
|
||||
[4322]={3,1,0},
|
||||
[4726]={0,3,0,3,3,0,11,3,0},
|
||||
[4734]={0,3,0,11,3,0},
|
||||
[4735]={0,3,0,11,3,0},
|
||||
[4787]={3,3,0,16,3,0},
|
||||
[4808]={0,3,0,3,3,0,11,3,0},
|
||||
[4809]={0,3,0,3,3,0,11,3,0},
|
||||
[4810]={0,3,0,3,3,0,11,3,0},
|
||||
[4907]={0,3,0,11,3,0},
|
||||
[4941]={3,2,0},
|
||||
[5065]={3,3,0},
|
||||
[5126]={3,3,67},
|
||||
[5281]={13,3,0},
|
||||
[5382]={13,3,0},
|
||||
[5384]={13,3,0},
|
||||
[5461]={11,3,0,13,3,0},
|
||||
[5462]={11,3,0,13,3,0},
|
||||
[5463]={11,3,0},
|
||||
[5464]={11,3,0},
|
||||
[5465]={11,3,0},
|
||||
[5515]={13,3,0},
|
||||
[5522]={11,3,0},
|
||||
[5527]={0,3,0},
|
||||
[5542]={13,3,0},
|
||||
[5543]={13,3,0},
|
||||
[5544]={13,3,0},
|
||||
[5726]={7,2,0},
|
||||
[5727]={7,2,0},
|
||||
[5742]={13,3,0},
|
||||
[5781]={13,3,0},
|
||||
[5845]={13,3,0},
|
||||
[5846]={13,3,0},
|
||||
[6022]={13,2,0},
|
||||
[6042]={13,2,0},
|
||||
[6133]={13,2,0},
|
||||
[6135]={13,2,0},
|
||||
[6136]={13,2,0},
|
||||
[6141]={10,1,0},
|
||||
[6402]={3,1,0},
|
||||
[6403]={3,1,0},
|
||||
[6501]={3,1,0},
|
||||
[6566]={3,2,0},
|
||||
[6567]={3,2,0},
|
||||
[6568]={3,2,0},
|
||||
[6570]={3,2,0},
|
||||
[6582]={3,2,0},
|
||||
[6583]={3,2,0},
|
||||
[6584]={3,2,0},
|
||||
[6585]={3,2,0},
|
||||
[6601]={3,2,0},
|
||||
[6627]={10,2,0},
|
||||
[7562]={0,3,256},
|
||||
[7563]={0,3,256},
|
||||
[7564]={0,3,256},
|
||||
[7623]={0,3,256},
|
||||
[7624]={0,3,256},
|
||||
[7625]={0,3,256},
|
||||
[7626]={0,3,256},
|
||||
[7627]={0,3,256},
|
||||
[7628]={0,3,256},
|
||||
[7630]={0,3,256},
|
||||
[7637]={0,1,2},
|
||||
[7638]={0,1,2},
|
||||
[7639]={0,1,2},
|
||||
[7640]={0,1,2},
|
||||
[7641]={0,1,2},
|
||||
[7644]={0,1,2},
|
||||
[7646]={0,1,2},
|
||||
[7667]={0,2,64},
|
||||
[7670]={0,1,2},
|
||||
[7722]={0,3,0},
|
||||
[8151]={0,3,4},
|
||||
[8153]={0,3,4},
|
||||
[8231]={0,3,4},
|
||||
[8233]={0,3,8},
|
||||
[8234]={0,3,8},
|
||||
[8235]={0,3,8},
|
||||
[8251]={0,3,128},
|
||||
[8252]={0,3,128},
|
||||
[8254]={0,3,16},
|
||||
[8255]={0,3,16},
|
||||
[8256]={0,3,16},
|
||||
[8286]={16,3,0},
|
||||
[8288]={16,3,0},
|
||||
[8301]={16,3,0},
|
||||
[8303]={16,3,0},
|
||||
[8305]={16,3,0},
|
||||
[8410]={0,2,64},
|
||||
[8411]={0,2,64},
|
||||
[8412]={0,2,64},
|
||||
[8414]={0,1,2},
|
||||
[8415]={0,1,2},
|
||||
[8416]={0,1,2},
|
||||
[8417]={0,3,1},
|
||||
[8419]={0,3,256},
|
||||
[8420]={0,3,256},
|
||||
[8421]={0,3,256},
|
||||
[8423]={0,3,1},
|
||||
[8424]={0,3,1},
|
||||
[8519]={16,3,0},
|
||||
[8555]={16,3,0},
|
||||
[8905]={2,1,1024,3,1,1024,4,1,1024,11,1,1024,13,1,1024},
|
||||
[8906]={2,1,4,3,1,4,4,1,4,11,1,4,13,1,4},
|
||||
[8907]={2,1,128,3,1,128,4,1,128,11,1,128,13,1,128},
|
||||
[8908]={2,1,2,3,1,2,4,1,2,11,1,2,13,1,2},
|
||||
[8909]={2,1,16,3,1,16,4,1,16,11,1,16,13,1,16},
|
||||
[8910]={2,1,8,3,1,8,4,1,8,11,1,8,13,1,8},
|
||||
[8911]={2,1,256,3,1,256,4,1,256,11,1,256,13,1,256},
|
||||
[8912]={2,1,1,3,1,1,4,1,1,11,1,1,13,1,1},
|
||||
[8913]={2,2,1024,3,2,1024,4,2,1024,11,2,1024,13,2,1024},
|
||||
[8914]={2,2,4,3,2,4,4,2,4,11,2,4,13,2,4},
|
||||
[8915]={2,2,128,3,2,128,4,2,128,11,2,128,13,2,128},
|
||||
[8916]={2,2,16,3,2,16,4,2,16,11,2,16,13,2,16},
|
||||
[8917]={2,2,8,3,2,8,4,2,8,11,2,8,13,2,8},
|
||||
[8918]={2,2,64,3,2,64,4,2,64,11,2,64,13,2,64},
|
||||
[8919]={2,2,256,3,2,256,4,2,256,11,2,256,13,2,256},
|
||||
[8920]={2,2,1,3,2,1,4,2,1,11,2,1,13,2,1},
|
||||
[8921]={0,1,1439,0,2,1501,2,1,1439,2,2,1501,3,1,1439,3,2,1501,4,1,1439,4,2,1501,11,1,1439,11,2,1501,13,1,1439,13,2,1501},
|
||||
[8922]={0,1,1439,2,1,1439,3,1,1439,4,1,1439,11,1,1439,13,1,1439},
|
||||
[8923]={0,2,1501,2,2,1501,3,2,1501,4,2,1501,11,2,1501,13,2,1501},
|
||||
[8924]={0,1,1439,0,2,1501,2,1,1439,2,2,1501,3,1,1439,3,2,1501,4,1,1439,4,2,1501,11,1,1439,11,2,1501,13,1,1439,13,2,1501},
|
||||
[8925]={0,1,1439,0,2,1501,2,1,1439,2,2,1501,3,1,1439,3,2,1501,4,1,1439,4,2,1501,11,1,1439,11,2,1501,13,1,1439,13,2,1501},
|
||||
[8926]={2,1,1024,3,1,1024,4,1,1024,11,1,1024,13,1,1024},
|
||||
[8927]={2,2,1024,3,2,1024,4,2,1024,11,2,1024,13,2,1024},
|
||||
[8928]={0,1,1439,0,2,1501,2,1,1439,2,2,1501,3,1,1439,3,2,1501,4,1,1439,4,2,1501,11,1,1439,11,2,1501,13,1,1439,13,2,1501},
|
||||
[8929]={0,1,1439,2,1,0,3,1,1439,4,1,0,11,1,1439,13,1,0},
|
||||
[8930]={0,2,1501,2,2,0,3,2,1501,4,2,0,11,2,1501,13,2,0},
|
||||
[8931]={2,1,4,3,1,4,4,1,4,11,1,4,13,1,4},
|
||||
[8932]={2,1,128,3,1,128,4,1,128,11,1,128,13,1,128},
|
||||
[8933]={2,1,2,3,1,2,4,1,2,11,1,2,13,1,2},
|
||||
[8934]={2,1,16,3,1,16,4,1,16,11,1,16,13,1,16},
|
||||
[8935]={2,1,8,3,1,8,4,1,8,11,1,8,13,1,8},
|
||||
[8936]={2,1,256,3,1,256,4,1,256,11,1,256,13,1,256},
|
||||
[8937]={2,1,1,3,1,1,4,1,1,11,1,1,13,1,1},
|
||||
[8938]={2,2,4,3,2,4,4,2,4,11,2,4,13,2,4},
|
||||
[8939]={2,2,128,3,2,128,4,2,128,11,2,128,13,2,128},
|
||||
[8940]={2,2,16,3,2,16,4,2,16,11,2,16,13,2,16},
|
||||
[8941]={2,2,8,3,2,8,4,2,8,11,2,8,13,2,8},
|
||||
[8942]={2,2,64,3,2,64,4,2,64,11,2,64,13,2,64},
|
||||
[8943]={2,2,256,3,2,256,4,2,256,11,2,256,13,2,256},
|
||||
[8944]={2,2,1,3,2,1,4,2,1,11,2,1,13,2,1},
|
||||
[8945]={0,1,1439,0,2,1501,2,3,0,3,1,1439,3,2,1501,4,3,0,11,1,1439,11,2,1501},
|
||||
[8946]={0,1,1439,0,2,1501,2,3,0,3,1,1439,3,2,1501,4,3,0,11,1,1439,11,2,1501,13,1,1439,13,2,1501},
|
||||
[8947]={0,1,1439,0,2,1501,2,3,0,3,1,1439,3,2,1501,4,3,0,11,1,1439,11,2,1501,13,1,1439,13,2,1501},
|
||||
[8948]={0,1,1439,0,2,1501,2,3,0,3,1,1439,3,2,1501,11,1,1439,11,2,1501,13,1,1439,13,2,1501},
|
||||
[8949]={0,1,1439,0,2,1501,2,3,0,3,1,1439,3,2,1501,11,1,1439,11,2,1501,13,1,1439,13,2,1501},
|
||||
[8950]={0,1,1439,0,2,1501,2,3,0,3,1,1439,3,2,1501,11,1,1439,11,2,1501,13,1,1439,13,2,1501},
|
||||
[8951]={3,1,1024,4,1,1024,11,1,1024,13,1,1024},
|
||||
[8952]={3,1,4,4,1,4,11,1,4,13,1,4},
|
||||
[8953]={3,1,128,4,1,128,11,1,128,13,1,128},
|
||||
[8954]={3,1,2,4,1,2,11,1,2,13,1,2},
|
||||
[8955]={3,1,16,4,1,16,11,1,16,13,1,16},
|
||||
[8956]={3,1,8,4,1,8,11,1,8,13,1,8},
|
||||
[8957]={3,2,64,4,2,64,11,2,64,13,2,64},
|
||||
[8958]={3,1,256,4,1,256,11,1,256,13,1,256},
|
||||
[8959]={3,1,1,4,1,1,11,1,1,13,1,1},
|
||||
[8960]={0,1,1439,3,1,0,4,1,0,11,1,0,13,1,0},
|
||||
[8961]={0,1,1439,0,2,1501,3,3,0,4,3,0,11,3,0,13,3,0},
|
||||
[8962]={0,1,1439,0,2,1501,3,3,0,4,3,0,11,3,0,13,3,0},
|
||||
[8963]={0,1,1439,0,2,1501,3,3,0,4,3,0,11,3,0,13,3,0},
|
||||
[8964]={0,1,1439,0,2,1501,3,3,0,4,3,0,11,3,0,13,3,0},
|
||||
[8965]={0,1,1439,0,2,1501,3,3,0,4,3,0,11,3,0,13,3,0},
|
||||
[8966]={0,1,1439,0,2,1501,4,3,0,11,3,0,13,3,0},
|
||||
[8967]={0,1,1439,0,2,1501,3,3,0,11,3,0,13,3,0},
|
||||
[8968]={0,1,1439,0,2,1501,3,3,0,4,3,0,11,3,0},
|
||||
[8969]={0,1,1439,0,2,1501,3,3,0,4,3,0,13,3,0},
|
||||
[8970]={0,1,1439,0,2,1501,3,3,0,4,3,0,11,3,0,13,3,0},
|
||||
[8977]={0,1,1439,2,1,1439,3,1,1439,4,1,1439,11,1,1439,13,1,1439},
|
||||
[8978]={0,2,1501,2,2,1501,3,2,1501,4,2,1501,11,2,1501,13,2,1501},
|
||||
[8985]={0,1,1439,0,2,1501,3,3,0,4,3,0,11,3,0,13,3,0},
|
||||
[8986]={0,1,1439,0,2,1501,3,3,0,4,3,0,11,3,0,13,3,0},
|
||||
[8987]={0,1,1439,0,2,1501,3,3,0,4,3,0,11,3,0,13,3,0},
|
||||
[8988]={0,1,1439,0,2,1501,3,3,0,4,3,0,11,3,0,13,3,0},
|
||||
[8989]={0,1,1439,0,2,1501},
|
||||
[8990]={0,1,1439,0,2,1501,3,3,0},
|
||||
[8991]={0,1,1439,0,2,1501,3,3,0},
|
||||
[8992]={0,1,1439,0,2,1501,3,3,0},
|
||||
[8994]={0,1,1439,0,2,1501,3,3,0},
|
||||
[8995]={0,1,1439,0,2,1501},
|
||||
[8996]={0,1,1439,0,2,1501},
|
||||
[8997]={0,1,1439},
|
||||
[8998]={0,2,1501},
|
||||
[9015]={0,1,1439,0,2,1501,3,1,1439,3,2,1501,4,1,1439,4,2,1501,11,1,1439,11,2,1501,13,1,1439,13,2,1501},
|
||||
[9016]={3,2,1024,4,2,1024,11,2,1024,13,2,1024},
|
||||
[9017]={3,2,4,4,2,4,11,2,4,13,2,4},
|
||||
[9018]={3,2,128,4,2,128,11,2,128,13,2,128},
|
||||
[9019]={3,2,16,4,2,16,11,2,16,13,2,16},
|
||||
[9020]={3,2,8,4,2,8,11,2,8,13,2,8},
|
||||
[9021]={3,2,256,4,2,256,11,2,256,13,2,256},
|
||||
[9022]={3,2,1,4,2,1,11,2,1,13,2,1},
|
||||
[9032]={0,2,1501,3,2,0,4,2,0,11,2,0,13,2,0},
|
||||
[9051]={0,3,1024},
|
||||
[9052]={0,3,1024},
|
||||
[9063]={0,3,1024},
|
||||
[9250]={0,3,1424},
|
||||
[9251]={0,3,1424},
|
||||
[92742]={14,1,0},
|
||||
[92744]={14,1,0},
|
||||
[92745]={14,1,0},
|
||||
[92747]={14,1,0},
|
||||
[92748]={14,1,0},
|
||||
[92749]={14,1,0},
|
||||
[92750]={14,1,0},
|
||||
[92751]={14,1,0},
|
||||
[92752]={14,1,0},
|
||||
}
|
||||
123
DungeonPreQuest/DungeonPreQuest.lua
Normal file
123
DungeonPreQuest/DungeonPreQuest.lua
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
-- Dungeon Pre-Quest: marks quests whose chain leads to a dungeon quest, in the
|
||||
-- quest log and on the quest offer window. The client has no chain data, so
|
||||
-- Data.lua is generated ahead of time.
|
||||
|
||||
local _, ns = ...
|
||||
|
||||
local COLOR = "|cffffd100"
|
||||
local LABEL = "Dungeon pre-quest"
|
||||
|
||||
local function HasClass(mask, classID)
|
||||
return mask == 0 or math.floor(mask / 2 ^ (classID - 1)) % 2 == 1
|
||||
end
|
||||
|
||||
-- Dungeon names this quest leads to for this character, or nil if none.
|
||||
-- An empty list means a dungeon quest whose dungeon isn't known.
|
||||
local function DungeonsFor(questID)
|
||||
local row = questID and ns.quests[questID]
|
||||
if not row then
|
||||
return nil
|
||||
end
|
||||
|
||||
local faction = UnitFactionGroup("player")
|
||||
local factionBit = faction == "Alliance" and 1 or faction == "Horde" and 2
|
||||
local classID = select(3, UnitClass("player"))
|
||||
if not factionBit or not classID then
|
||||
return nil
|
||||
end
|
||||
|
||||
local names, seen, matched = {}, {}, false
|
||||
for i = 1, #row, 3 do
|
||||
local dungeon, factions, classes = row[i], row[i + 1], row[i + 2]
|
||||
if (factions == 3 or factions == factionBit) and HasClass(classes, classID) then
|
||||
matched = true
|
||||
local name = ns.dungeons[dungeon]
|
||||
if name and not seen[name] then
|
||||
seen[name] = true
|
||||
names[#names + 1] = name
|
||||
end
|
||||
end
|
||||
end
|
||||
return matched and names or nil
|
||||
end
|
||||
|
||||
local function Describe(names)
|
||||
if #names == 0 then
|
||||
return LABEL
|
||||
end
|
||||
return LABEL .. ": " .. table.concat(names, ", ")
|
||||
end
|
||||
|
||||
local function MarkRow(button)
|
||||
local names = DungeonsFor(button.questID)
|
||||
if not names then
|
||||
if button.dpqMark then
|
||||
button.dpqMark:Hide()
|
||||
end
|
||||
return
|
||||
end
|
||||
if not button.dpqMark then
|
||||
button.dpqMark = button:CreateFontString(nil, "ARTWORK", "GameFontNormalSmall")
|
||||
button.dpqMark:SetPoint("TOPLEFT", button, "TOPLEFT", 12, -9)
|
||||
button.dpqMark:SetText(COLOR .. "D|r")
|
||||
end
|
||||
button.dpqMark:Show()
|
||||
end
|
||||
|
||||
local function UpdateRows()
|
||||
for button in QuestScrollFrame.titleFramePool:EnumerateActive() do
|
||||
MarkRow(button)
|
||||
end
|
||||
end
|
||||
|
||||
local banner
|
||||
|
||||
local function UpdateBanner()
|
||||
if not banner then
|
||||
return
|
||||
end
|
||||
local names = DungeonsFor(GetQuestID())
|
||||
if names then
|
||||
banner:SetText(COLOR .. Describe(names) .. "|r")
|
||||
banner:Show()
|
||||
else
|
||||
banner:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
local function Setup()
|
||||
hooksecurefunc("QuestLogQuests_Update", UpdateRows)
|
||||
|
||||
EventRegistry:RegisterCallback("QuestMapLogTitleButton.OnEnter", function(_, button, questID)
|
||||
local names = DungeonsFor(questID or (button and button.questID))
|
||||
if names then
|
||||
GameTooltip:AddLine(Describe(names), 1, 0.82, 0, true)
|
||||
GameTooltip:Show()
|
||||
end
|
||||
end, ns)
|
||||
|
||||
-- Sits above the window, where it can't disturb Blizzard's layout. Parented
|
||||
-- to the detail panel so it goes away with that panel.
|
||||
banner = QuestFrameDetailPanel:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
|
||||
banner:SetPoint("BOTTOM", QuestFrame, "TOP", 0, 6)
|
||||
QuestFrameDetailPanel:HookScript("OnShow", UpdateBanner)
|
||||
end
|
||||
|
||||
local frame = CreateFrame("Frame")
|
||||
frame:RegisterEvent("PLAYER_LOGIN")
|
||||
frame:RegisterEvent("QUEST_DETAIL")
|
||||
frame:SetScript("OnEvent", function(_, event)
|
||||
if event == "PLAYER_LOGIN" then
|
||||
Setup()
|
||||
else
|
||||
UpdateBanner()
|
||||
end
|
||||
end)
|
||||
|
||||
-- /dpq 123 says what is known about a quest ID.
|
||||
SLASH_DUNGEONPREQUEST1 = "/dpq"
|
||||
SlashCmdList.DUNGEONPREQUEST = function(text)
|
||||
local id = tonumber(text)
|
||||
local names = DungeonsFor(id)
|
||||
DEFAULT_CHAT_FRAME:AddMessage(COLOR .. "DungeonPreQuest:|r " .. (id and (names and Describe(names) or "not a pre-quest for you") or "usage: /dpq questID"))
|
||||
end
|
||||
7
DungeonPreQuest/DungeonPreQuest.toc
Normal file
7
DungeonPreQuest/DungeonPreQuest.toc
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
## Interface: 16001
|
||||
## Title: Dungeon Pre-Quest
|
||||
## Notes: Marks quests whose chain leads to a dungeon quest.
|
||||
## Version: 1.0
|
||||
|
||||
Data.lua
|
||||
DungeonPreQuest.lua
|
||||
232
DungeonPreQuest/tools/extract.lua
Normal file
232
DungeonPreQuest/tools/extract.lua
Normal file
|
|
@ -0,0 +1,232 @@
|
|||
-- Merges QuestieDB's Forever quest data into plain rows, without running its
|
||||
-- generator. Each downloaded file runs in an empty environment: no io, os,
|
||||
-- require, dofile or loadstring.
|
||||
-- usage: lua extract.lua <qdb dir> <questie dir> <output file>
|
||||
|
||||
local qdb, questie, outPath = arg[1], arg[2], arg[3]
|
||||
|
||||
local function proxy(name)
|
||||
local mt = {}
|
||||
mt.__index = function(t, k)
|
||||
local child = proxy(name .. "." .. tostring(k))
|
||||
rawset(t, k, child)
|
||||
return child
|
||||
end
|
||||
mt.__call = function() return proxy(name .. "()") end
|
||||
mt.__add = function(a) return a end
|
||||
mt.__sub = mt.__add
|
||||
mt.__mul = mt.__add
|
||||
mt.__unm = mt.__add
|
||||
return setmetatable({}, mt)
|
||||
end
|
||||
|
||||
local function sandbox(extra)
|
||||
local env = {
|
||||
pairs = pairs, ipairs = ipairs, type = type, tostring = tostring, tonumber = tonumber,
|
||||
select = select, unpack = unpack, next = next, assert = assert, error = error,
|
||||
rawget = rawget, rawset = rawset, setmetatable = setmetatable, getmetatable = getmetatable,
|
||||
math = math, string = { format = string.format, find = string.find, match = string.match,
|
||||
gsub = string.gsub, sub = string.sub, lower = string.lower, upper = string.upper,
|
||||
byte = string.byte, char = string.char, rep = string.rep, len = string.len, gmatch = string.gmatch },
|
||||
table = table,
|
||||
}
|
||||
for k, v in pairs(extra or {}) do env[k] = v end
|
||||
return env
|
||||
end
|
||||
|
||||
local function read(path)
|
||||
local f = assert(io.open(path, "rb"), path)
|
||||
local s = f:read("*a")
|
||||
f:close()
|
||||
assert(s:sub(1, 1) ~= "\27", "bytecode refused: " .. path)
|
||||
return s
|
||||
end
|
||||
|
||||
local function run(path, env, ...)
|
||||
local chunk = assert(loadstring(read(path), "@" .. path))
|
||||
setfenv(chunk, env)
|
||||
return chunk(...)
|
||||
end
|
||||
|
||||
-- Enums, read from QuestieDB's own definition files.
|
||||
local Lib = { Enum = {} }
|
||||
local function enumFile(name) run(qdb .. "/src/corrections/enum/" .. name .. ".lua", sandbox(), "QuestieDB", Lib) end
|
||||
for _, name in ipairs({ "constants", "quests", "zones", "professions", "factions", "expansions" }) do
|
||||
local ok, err = pcall(enumFile, name)
|
||||
if not ok then io.stderr:write("enum ", name, ": ", tostring(err), "\n") end
|
||||
end
|
||||
local forever = assert(Lib.Enum.byExpansion and Lib.Enum.byExpansion.Forever, "no Forever enum")
|
||||
forever.classKeys = forever.classKeys or assert(Lib.Enum.byExpansion.Classic.classKeys)
|
||||
|
||||
-- Raw rows and field indexes.
|
||||
local modules = {}
|
||||
local function module(name)
|
||||
if not modules[name] then
|
||||
modules[name] = proxy(name)
|
||||
end
|
||||
return modules[name]
|
||||
end
|
||||
local loader = {
|
||||
CreateModule = function(_, name) rawset(modules, name, {}) return modules[name] end,
|
||||
ImportModule = function(_, name) return module(name) end,
|
||||
}
|
||||
|
||||
local rawQuestDB = {}
|
||||
modules.QuestieDB = rawQuestDB
|
||||
run(qdb .. "/data/Forever/foreverQuestDB.lua", sandbox({ QuestieLoader = loader }))
|
||||
local realKeys = assert(rawQuestDB.questKeys)
|
||||
local dataText = assert(rawQuestDB.questData)
|
||||
assert(dataText:sub(1, 6) == "return")
|
||||
local dataChunk = assert(loadstring(dataText, "=questData"))
|
||||
setfenv(dataChunk, {})
|
||||
local quests = dataChunk()
|
||||
|
||||
local ADD, REMOVE = 1000, 2000
|
||||
local keyProxy = setmetatable({}, { __index = function(_, k)
|
||||
local base, op = k:match("^(.-)_(add)$")
|
||||
if not base then base, op = k:match("^(.-)_(remove)$") end
|
||||
if base then
|
||||
return assert(realKeys[base], k) + (op == "add" and ADD or REMOVE)
|
||||
end
|
||||
return assert(realKeys[k], k)
|
||||
end })
|
||||
|
||||
modules = {
|
||||
QuestieDB = { questKeys = keyProxy, raceKeys = forever.raceKeys, classKeys = forever.classKeys,
|
||||
sortKeys = Lib.Enum.sortKeys, specialFlags = Lib.Enum.specialFlags, factionIDs = Lib.Enum.factionIDs },
|
||||
ZoneDB = { zoneIDs = Lib.Enum.zoneIDs },
|
||||
QuestieProfessions = { professionKeys = Lib.Enum.professionKeys or proxy("prof"),
|
||||
specializationKeys = Lib.Enum.specializationKeys or proxy("spec") },
|
||||
}
|
||||
for k, v in pairs(modules) do
|
||||
setmetatable(v, { __index = function(t, key) local p = proxy(k .. "." .. key); rawset(t, key, p); return p end })
|
||||
end
|
||||
|
||||
local WANT = { "name", "questLevel", "requiredRaces", "requiredClasses", "preQuestGroup", "preQuestSingle",
|
||||
"zoneOrSort", "nextQuestInChain", "breadcrumbForQuestId", "breadcrumbs", "objectives", "specialFlags" }
|
||||
local wanted = {}
|
||||
for _, n in ipairs(WANT) do wanted[realKeys[n]] = true end
|
||||
|
||||
local function contains(list, v) for _, x in ipairs(list) do if x == v then return true end end return false end
|
||||
|
||||
local changed = {}
|
||||
local function apply(id, fixes)
|
||||
local row = quests[id]
|
||||
if not row then row = {}; quests[id] = row end
|
||||
local removes, sets, adds = {}, {}, {}
|
||||
for k, v in pairs(fixes) do
|
||||
if k > REMOVE then removes[k - REMOVE] = v
|
||||
elseif k > ADD then adds[k - ADD] = v
|
||||
else sets[k] = v end
|
||||
end
|
||||
for k, v in pairs(removes) do
|
||||
if wanted[k] and type(row[k]) == "table" and type(v) == "table" then
|
||||
local kept = {}
|
||||
for _, x in ipairs(row[k]) do if not contains(v, x) then kept[#kept + 1] = x end end
|
||||
row[k] = kept
|
||||
end
|
||||
end
|
||||
for k, v in pairs(sets) do row[k] = v end
|
||||
for k, v in pairs(adds) do
|
||||
if wanted[k] and type(v) == "table" then
|
||||
row[k] = type(row[k]) == "table" and row[k] or {}
|
||||
for _, x in ipairs(v) do if not contains(row[k], x) then table.insert(row[k], x) end end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local LAYERS = {
|
||||
{ "Forever/legacy/classicQuestFixes.lua", "QuestieQuestFixes" },
|
||||
{ "Forever/generated/foreverBaseQuest.lua", "ForeverBaseQuest" },
|
||||
{ "Forever/traces/foreverQuestTraces.lua", "ForeverQuestTraces" },
|
||||
{ "Forever/foreverQuestFixes.lua", "ForeverQuestFixes" },
|
||||
}
|
||||
local layerLoader = {
|
||||
CreateModule = function(_, name) local m = {}; rawset(modules, name, m); return m end,
|
||||
ImportModule = function(_, name) return modules[name] or proxy(name) end,
|
||||
}
|
||||
local stubs = { QuestieLoader = layerLoader, UnitFactionGroup = function() return "Alliance" end,
|
||||
Questie = proxy("Questie") }
|
||||
for _, layer in ipairs(LAYERS) do
|
||||
run(qdb .. "/src/corrections/" .. layer[1], sandbox(stubs))
|
||||
local fixes = modules[layer[2]]:Load()
|
||||
local n = 0
|
||||
for id, row in pairs(fixes) do apply(id, row); n = n + 1 end
|
||||
io.stderr:write(layer[2], ": ", n, " rows\n")
|
||||
end
|
||||
|
||||
-- Quest tags. Questie treats Forever as Era content here.
|
||||
local tags = {}
|
||||
do
|
||||
local private = {}
|
||||
local Expansions = { Era = 1, Tbc = 2, Wotlk = 3, Cata = 4, MoP = 5, Current = 1 }
|
||||
local tagLoader = { ImportModule = function(_, name)
|
||||
if name == "QuestieDB" then return { private = private } end
|
||||
if name == "Expansions" then return Expansions end
|
||||
if name == "l10n" then return function(s) return s end end
|
||||
return proxy(name)
|
||||
end }
|
||||
run(questie .. "/Database/Corrections/questTagInfoCorrections.lua", sandbox({ QuestieLoader = tagLoader, Questie = proxy("Questie") }))
|
||||
private.InitializeQuestTagInfoCorrections()
|
||||
for id, tag in pairs(private.questTagCorrections) do
|
||||
if type(tag) == "table" and tag[1] == 81 then tags[id] = true end
|
||||
end
|
||||
end
|
||||
|
||||
-- Dungeon list is parsed as text, not run.
|
||||
local zoneNames, allNames = {}, {}
|
||||
for line in read(qdb .. "/support/Forever/Zones/dungeons.lua"):gmatch("[^\n]+") do
|
||||
local id, name, rest = line:match('^%s*%[(%d+)%]%s*=%s*{"([^"]+)",(.*)')
|
||||
if id then
|
||||
allNames[#allNames + 1] = name
|
||||
zoneNames[tonumber(id)] = name
|
||||
local alts = rest:match("^{([%d,%s]+)}")
|
||||
if alts then for a in alts:gmatch("%d+") do zoneNames[tonumber(a)] = name end end
|
||||
end
|
||||
end
|
||||
table.sort(allNames)
|
||||
|
||||
local q = {}
|
||||
for id, row in pairs(quests) do
|
||||
local r = {}
|
||||
for _, n in ipairs(WANT) do r[n] = row[realKeys[n]] end
|
||||
q[id] = r
|
||||
end
|
||||
|
||||
local function ser(v)
|
||||
if type(v) == "table" then
|
||||
local parts, n = {}, 0
|
||||
for k in pairs(v) do if type(k) == "number" and k > n then n = k end end
|
||||
for i = 1, n do parts[i] = ser(v[i]) end
|
||||
return "{" .. table.concat(parts, ",") .. "}"
|
||||
elseif type(v) == "string" then return string.format("%q", v)
|
||||
elseif v == nil then return "nil"
|
||||
else return tostring(v) end
|
||||
end
|
||||
|
||||
local out = assert(io.open(outPath, "w"))
|
||||
out:write("return {quests={\n")
|
||||
local ids = {}
|
||||
for id in pairs(q) do ids[#ids + 1] = id end
|
||||
table.sort(ids)
|
||||
for _, id in ipairs(ids) do
|
||||
local r = q[id]
|
||||
out:write("[", id, "]={")
|
||||
for _, n in ipairs(WANT) do
|
||||
if r[n] ~= nil and n ~= "objectives" then out:write(n, "=", ser(r[n]), ",") end
|
||||
end
|
||||
out:write("},\n")
|
||||
end
|
||||
out:write("},\ntags={")
|
||||
for id in pairs(tags) do out:write("[", id, "]=true,") end
|
||||
out:write("},\nzoneNames={")
|
||||
for id, name in pairs(zoneNames) do out:write("[", id, "]=", string.format("%q", name), ",") end
|
||||
out:write("},\nallDungeons=", ser(allNames), ",\n")
|
||||
out:write("ALL_ALLIANCE=", string.format("%.0f", forever.raceKeys.ALL_ALLIANCE), ",ALL_HORDE=", string.format("%.0f", forever.raceKeys.ALL_HORDE), ",\n")
|
||||
out:write("classKeys=", "{")
|
||||
for k, v in pairs(forever.classKeys) do out:write(k, "=", string.format("%.0f", v), ",") end
|
||||
out:write("}}\n")
|
||||
out:close()
|
||||
io.stderr:write("quests: ", #ids, ", dungeon tags: ")
|
||||
local c = 0; for _ in pairs(tags) do c = c + 1 end
|
||||
io.stderr:write(c, "\n")
|
||||
157
DungeonPreQuest/tools/generate.lua
Normal file
157
DungeonPreQuest/tools/generate.lua
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
-- Turns merged.lua into the addon's Data.lua.
|
||||
-- usage: lua generate.lua merged.lua Data.lua
|
||||
local data = dofile(arg[1])
|
||||
local q = data.quests
|
||||
|
||||
local FIVE_MAN = {}
|
||||
for _, n in ipairs({ "Ragefire Chasm", "The Deadmines", "Wailing Caverns", "Shadowfang Keep", "Blackfathom Deeps",
|
||||
"The Stockade", "Gnomeregan", "Razorfen Kraul", "Scarlet Monastery", "Razorfen Downs", "Uldaman", "Zul'Farrak",
|
||||
"Maraudon", "The Temple of Atal'Hakkar", "Blackrock Depths", "Blackrock Spire", "Dire Maul", "Scholomance",
|
||||
"Stratholme" }) do FIVE_MAN[n] = true end
|
||||
|
||||
local UNNAMED = ""
|
||||
local dungeon = {}
|
||||
for id, r in pairs(q) do
|
||||
local name = r.zoneOrSort and data.zoneNames[r.zoneOrSort]
|
||||
if name and FIVE_MAN[name] then
|
||||
dungeon[id] = name
|
||||
elseif data.tags[id] and not name then
|
||||
dungeon[id] = UNNAMED
|
||||
end
|
||||
end
|
||||
|
||||
local function intersects(a, b)
|
||||
for i = 0, 52 do
|
||||
local bit = 2 ^ i
|
||||
if math.floor(a / bit) % 2 == 1 and math.floor(b / bit) % 2 == 1 then return true end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local nexts = {}
|
||||
local function edge(a, b)
|
||||
if a and b and a ~= 0 and b ~= 0 and a ~= b and q[a] and q[b] then
|
||||
nexts[a] = nexts[a] or {}
|
||||
nexts[a][b] = true
|
||||
end
|
||||
end
|
||||
for id, r in pairs(q) do
|
||||
for _, a in ipairs(r.preQuestSingle or {}) do edge(a, id) end
|
||||
for _, a in ipairs(r.preQuestGroup or {}) do edge(a, id) end
|
||||
edge(id, r.nextQuestInChain)
|
||||
edge(id, r.breadcrumbForQuestId)
|
||||
for _, a in ipairs(r.breadcrumbs or {}) do edge(a, id) end
|
||||
end
|
||||
|
||||
local FACTIONS = { { bit = 1, mask = data.ALL_ALLIANCE }, { bit = 2, mask = data.ALL_HORDE } }
|
||||
local CLASSES = { "WARRIOR", "PALADIN", "HUNTER", "ROGUE", "PRIEST", "SHAMAN", "MAGE", "WARLOCK", "DRUID" }
|
||||
local ALL_CLASSES = 0
|
||||
for _, c in ipairs(CLASSES) do ALL_CLASSES = ALL_CLASSES + data.classKeys[c] end
|
||||
|
||||
local function available(r, factionMask, classBit)
|
||||
local races, classes = r.requiredRaces or 0, r.requiredClasses or 0
|
||||
if races ~= 0 and not intersects(races, factionMask) then return false end
|
||||
if classes ~= 0 and not intersects(classes, classBit) then return false end
|
||||
return true
|
||||
end
|
||||
|
||||
-- result[quest][dungeon][factionBit] = class mask
|
||||
local result = {}
|
||||
for _, faction in ipairs(FACTIONS) do
|
||||
for _, class in ipairs(CLASSES) do
|
||||
local classBit = data.classKeys[class]
|
||||
local function walk(id, seen, found)
|
||||
for b in pairs(nexts[id] or {}) do
|
||||
if not seen[b] and available(q[b], faction.mask, classBit) then
|
||||
seen[b] = true
|
||||
if dungeon[b] then found[dungeon[b]] = true end
|
||||
walk(b, seen, found)
|
||||
end
|
||||
end
|
||||
end
|
||||
for id, r in pairs(q) do
|
||||
if available(r, faction.mask, classBit) then
|
||||
local found = {}
|
||||
walk(id, { [id] = true }, found)
|
||||
found[dungeon[id] or false] = nil
|
||||
for name in pairs(found) do
|
||||
result[id] = result[id] or {}
|
||||
result[id][name] = result[id][name] or {}
|
||||
result[id][name][faction.bit] = (result[id][name][faction.bit] or 0) + classBit
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local names, nameIndex = {}, {}
|
||||
for _, n in ipairs(data.allDungeons) do
|
||||
if FIVE_MAN[n] and not nameIndex[n] then
|
||||
names[#names + 1] = n
|
||||
nameIndex[n] = #names
|
||||
end
|
||||
end
|
||||
nameIndex[UNNAMED] = 0
|
||||
|
||||
local ids = {}
|
||||
for id in pairs(result) do ids[#ids + 1] = id end
|
||||
table.sort(ids)
|
||||
|
||||
local out = assert(io.open(arg[2], "w"))
|
||||
out:write("-- Generated from QuestieDB's Forever quest data. Do not edit.\n")
|
||||
out:write("-- quests[id] = { dungeon, faction, classes, ... }; faction 1 Alliance, 2 Horde, 3 both; classes 0 = all; dungeon 0 = unnamed.\n")
|
||||
out:write("local _, ns = ...\n\nns.dungeons = {\n")
|
||||
for _, n in ipairs(names) do out:write(string.format(" %q,\n", n)) end
|
||||
out:write("}\n\nns.quests = {\n")
|
||||
for _, id in ipairs(ids) do
|
||||
local parts = {}
|
||||
local dungeonsHere = {}
|
||||
for name in pairs(result[id]) do dungeonsHere[#dungeonsHere + 1] = name end
|
||||
table.sort(dungeonsHere)
|
||||
for _, name in ipairs(dungeonsHere) do
|
||||
local byFaction = result[id][name]
|
||||
local a, h = byFaction[1], byFaction[2]
|
||||
local function emit(faction, mask)
|
||||
parts[#parts + 1] = nameIndex[name] .. "," .. faction .. "," .. (mask == ALL_CLASSES and 0 or mask)
|
||||
end
|
||||
if a and a == h then
|
||||
emit(3, a)
|
||||
else
|
||||
if a then emit(1, a) end
|
||||
if h then emit(2, h) end
|
||||
end
|
||||
end
|
||||
out:write(" [", id, "]={", table.concat(parts, ","), "},\n")
|
||||
end
|
||||
out:write("}\n")
|
||||
out:close()
|
||||
|
||||
local function summary(faction, classBit, label)
|
||||
local n, named = 0, 0
|
||||
for id, row in pairs(result) do
|
||||
local any, anyNamed = false, false
|
||||
for name, f in pairs(row) do
|
||||
if f[faction] and intersects(f[faction], classBit) then
|
||||
any = true
|
||||
if name ~= UNNAMED then anyNamed = true end
|
||||
end
|
||||
end
|
||||
if any then n = n + 1 end
|
||||
if anyNamed then named = named + 1 end
|
||||
end
|
||||
print(label, "pre-quests", n, "with a named dungeon", named)
|
||||
end
|
||||
print("rows", #ids)
|
||||
summary(1, data.classKeys.SHAMAN, "Alliance shaman")
|
||||
summary(1, data.classKeys.WARRIOR, "Alliance warrior")
|
||||
summary(2, data.classKeys.WARRIOR, "Horde warrior")
|
||||
|
||||
local function show(id)
|
||||
local r = result[id]
|
||||
local list = {}
|
||||
for name, f in pairs(r or {}) do
|
||||
list[#list + 1] = (name == UNNAMED and "(unnamed)" or name) .. " A:" .. tostring(f[1]) .. " H:" .. tostring(f[2])
|
||||
end
|
||||
print(id, q[id] and q[id].name, table.concat(list, " | "))
|
||||
end
|
||||
for _, id in ipairs({ 65, 155, 166, 8928, 8916, 94501 }) do show(id) end
|
||||
675
LICENSE.md
Normal file
675
LICENSE.md
Normal file
|
|
@ -0,0 +1,675 @@
|
|||
# GNU GENERAL PUBLIC LICENSE
|
||||
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
<https://fsf.org/>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this
|
||||
license document, but changing it is not allowed.
|
||||
|
||||
## Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom
|
||||
to share and change all versions of a program--to make sure it remains
|
||||
free software for all its users. We, the Free Software Foundation, use
|
||||
the GNU General Public License for most of our software; it applies
|
||||
also to any other work released this way by its authors. You can apply
|
||||
it to your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you
|
||||
have certain responsibilities if you distribute copies of the
|
||||
software, or if you modify it: responsibilities to respect the freedom
|
||||
of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the
|
||||
manufacturer can do so. This is fundamentally incompatible with the
|
||||
aim of protecting users' freedom to change the software. The
|
||||
systematic pattern of such abuse occurs in the area of products for
|
||||
individuals to use, which is precisely where it is most unacceptable.
|
||||
Therefore, we have designed this version of the GPL to prohibit the
|
||||
practice for those products. If such problems arise substantially in
|
||||
other domains, we stand ready to extend this provision to those
|
||||
domains in future versions of the GPL, as needed to protect the
|
||||
freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish
|
||||
to avoid the special danger that patents applied to a free program
|
||||
could make it effectively proprietary. To prevent this, the GPL
|
||||
assures that patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
## TERMS AND CONDITIONS
|
||||
|
||||
### 0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds
|
||||
of works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of
|
||||
an exact copy. The resulting work is called a "modified version" of
|
||||
the earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user
|
||||
through a computer network, with no transfer of a copy, is not
|
||||
conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices" to
|
||||
the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
### 1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work for
|
||||
making modifications to it. "Object code" means any non-source form of
|
||||
a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users can
|
||||
regenerate automatically from other parts of the Corresponding Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that same
|
||||
work.
|
||||
|
||||
### 2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not convey,
|
||||
without conditions so long as your license otherwise remains in force.
|
||||
You may convey covered works to others for the sole purpose of having
|
||||
them make modifications exclusively for you, or provide you with
|
||||
facilities for running those works, provided that you comply with the
|
||||
terms of this License in conveying all material for which you do not
|
||||
control copyright. Those thus making or running the covered works for
|
||||
you must do so exclusively on your behalf, under your direction and
|
||||
control, on terms that prohibit them from making any copies of your
|
||||
copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under the
|
||||
conditions stated below. Sublicensing is not allowed; section 10 makes
|
||||
it unnecessary.
|
||||
|
||||
### 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such
|
||||
circumvention is effected by exercising rights under this License with
|
||||
respect to the covered work, and you disclaim any intention to limit
|
||||
operation or modification of the work as a means of enforcing, against
|
||||
the work's users, your or third parties' legal rights to forbid
|
||||
circumvention of technological measures.
|
||||
|
||||
### 4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
### 5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these
|
||||
conditions:
|
||||
|
||||
- a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
- b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under
|
||||
section 7. This requirement modifies the requirement in section 4
|
||||
to "keep intact all notices".
|
||||
- c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
- d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
### 6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms of
|
||||
sections 4 and 5, provided that you also convey the machine-readable
|
||||
Corresponding Source under the terms of this License, in one of these
|
||||
ways:
|
||||
|
||||
- a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
- b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the Corresponding
|
||||
Source from a network server at no charge.
|
||||
- c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
- d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
- e) Convey the object code using peer-to-peer transmission,
|
||||
provided you inform other peers where the object code and
|
||||
Corresponding Source of the work are being offered to the general
|
||||
public at no charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal,
|
||||
family, or household purposes, or (2) anything designed or sold for
|
||||
incorporation into a dwelling. In determining whether a product is a
|
||||
consumer product, doubtful cases shall be resolved in favor of
|
||||
coverage. For a particular product received by a particular user,
|
||||
"normally used" refers to a typical or common use of that class of
|
||||
product, regardless of the status of the particular user or of the way
|
||||
in which the particular user actually uses, or expects or is expected
|
||||
to use, the product. A product is a consumer product regardless of
|
||||
whether the product has substantial commercial, industrial or
|
||||
non-consumer uses, unless such uses represent the only significant
|
||||
mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to
|
||||
install and execute modified versions of a covered work in that User
|
||||
Product from a modified version of its Corresponding Source. The
|
||||
information must suffice to ensure that the continued functioning of
|
||||
the modified object code is in no case prevented or interfered with
|
||||
solely because modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or
|
||||
updates for a work that has been modified or installed by the
|
||||
recipient, or for the User Product in which it has been modified or
|
||||
installed. Access to a network may be denied when the modification
|
||||
itself materially and adversely affects the operation of the network
|
||||
or violates the rules and protocols for communication across the
|
||||
network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
### 7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders
|
||||
of that material) supplement the terms of this License with terms:
|
||||
|
||||
- a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
- b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
- c) Prohibiting misrepresentation of the origin of that material,
|
||||
or requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
- d) Limiting the use for publicity purposes of names of licensors
|
||||
or authors of the material; or
|
||||
- e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
- f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions
|
||||
of it) with contractual assumptions of liability to the recipient,
|
||||
for any liability that these contractual assumptions directly
|
||||
impose on those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions; the
|
||||
above requirements apply either way.
|
||||
|
||||
### 8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your license
|
||||
from a particular copyright holder is reinstated (a) provisionally,
|
||||
unless and until the copyright holder explicitly and finally
|
||||
terminates your license, and (b) permanently, if the copyright holder
|
||||
fails to notify you of the violation by some reasonable means prior to
|
||||
60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
### 9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or run
|
||||
a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
### 10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
### 11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims owned
|
||||
or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within the
|
||||
scope of its coverage, prohibits the exercise of, or is conditioned on
|
||||
the non-exercise of one or more of the rights that are specifically
|
||||
granted under this License. You may not convey a covered work if you
|
||||
are a party to an arrangement with a third party that is in the
|
||||
business of distributing software, under which you make payment to the
|
||||
third party based on the extent of your activity of conveying the
|
||||
work, and under which the third party grants, to any of the parties
|
||||
who would receive the covered work from you, a discriminatory patent
|
||||
license (a) in connection with copies of the covered work conveyed by
|
||||
you (or copies made from those copies), or (b) primarily for and in
|
||||
connection with specific products or compilations that contain the
|
||||
covered work, unless you entered into that arrangement, or that patent
|
||||
license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
### 12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under
|
||||
this License and any other pertinent obligations, then as a
|
||||
consequence you may not convey it at all. For example, if you agree to
|
||||
terms that obligate you to collect a royalty for further conveying
|
||||
from those to whom you convey the Program, the only way you could
|
||||
satisfy both those terms and this License would be to refrain entirely
|
||||
from conveying the Program.
|
||||
|
||||
### 13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
### 14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in
|
||||
detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies that a certain numbered version of the GNU General Public
|
||||
License "or any later version" applies to it, you have the option of
|
||||
following the terms and conditions either of that numbered version or
|
||||
of any later version published by the Free Software Foundation. If the
|
||||
Program does not specify a version number of the GNU General Public
|
||||
License, you may choose any version ever published by the Free
|
||||
Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future versions
|
||||
of the GNU General Public License can be used, that proxy's public
|
||||
statement of acceptance of a version permanently authorizes you to
|
||||
choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
### 15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
|
||||
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
|
||||
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
|
||||
DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
|
||||
CORRECTION.
|
||||
|
||||
### 16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR
|
||||
CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
|
||||
ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT
|
||||
NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR
|
||||
LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
|
||||
TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
|
||||
PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
### 17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
## How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these
|
||||
terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest to
|
||||
attach them to the start of each source file to most effectively state
|
||||
the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper
|
||||
mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands \`show w' and \`show c' should show the
|
||||
appropriate parts of the General Public License. Of course, your
|
||||
program's commands might be different; for a GUI interface, you would
|
||||
use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. For more information on this, and how to apply and follow
|
||||
the GNU GPL, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your
|
||||
program into proprietary programs. If your program is a subroutine
|
||||
library, you may consider it more useful to permit linking proprietary
|
||||
applications with the library. If this is what you want to do, use the
|
||||
GNU Lesser General Public License instead of this License. But first,
|
||||
please read <https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
299
QuestCraftHighlight/QuestCraftHighlight.lua
Normal file
299
QuestCraftHighlight/QuestCraftHighlight.lua
Normal file
|
|
@ -0,0 +1,299 @@
|
|||
-- Quest Craft Highlight: marks recipes whose output a quest in your log needs.
|
||||
|
||||
-- Lowercased item name -> { need = total across quests, quests = { { title, level, need } } }.
|
||||
local questItems = {}
|
||||
local dirty = true
|
||||
local incomplete = false
|
||||
local lastNumQuests
|
||||
|
||||
-- Recipe rows seen so far -> the recipeInfo each is currently showing.
|
||||
local rows = {}
|
||||
-- Output items whose name was not loaded yet when a row asked for it.
|
||||
local pendingItems = {}
|
||||
local hooked = false
|
||||
|
||||
-- "Linen Cloth: 3/5" or "3/5 Linen Cloth (Optional)" -> "Linen Cloth"
|
||||
local function ObjectiveItemName(text)
|
||||
local name = text:match("^%d+/%d+%s+(.+)$") or text:match("^(.-):?%s*%d+/%d+")
|
||||
if name then
|
||||
name = name:gsub("%s+%(Optional%)$", "")
|
||||
if name ~= "" then
|
||||
return name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function ReadEntries()
|
||||
local entries = {}
|
||||
for i = 1, (C_QuestLog.GetNumQuestLogEntries()) do
|
||||
local info = C_QuestLog.GetInfo(i)
|
||||
if info then
|
||||
entries[#entries + 1] = info
|
||||
end
|
||||
end
|
||||
return entries
|
||||
end
|
||||
|
||||
-- Returns the titles of collapsed headers whose quests are not being listed.
|
||||
-- Those have to be opened to be read, then closed again.
|
||||
local function ExpandHiddenHeaders(entries)
|
||||
local reopened
|
||||
for i = #entries, 1, -1 do
|
||||
local info, nextInfo = entries[i], entries[i + 1]
|
||||
if info.isHeader and info.isCollapsed and (not nextInfo or nextInfo.isHeader) then
|
||||
reopened = reopened or {}
|
||||
reopened[info.title] = true
|
||||
ExpandQuestHeader(i)
|
||||
end
|
||||
end
|
||||
return reopened
|
||||
end
|
||||
|
||||
local function CollapseHeaders(titles)
|
||||
local entries = ReadEntries()
|
||||
for i = #entries, 1, -1 do
|
||||
local info = entries[i]
|
||||
if info.isHeader and titles[info.title] then
|
||||
CollapseQuestHeader(i)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function QuestLevel(info)
|
||||
if info.level and info.level > 0 then
|
||||
return info.level
|
||||
end
|
||||
return C_QuestLog.GetQuestDifficultyLevel and C_QuestLog.GetQuestDifficultyLevel(info.questID) or nil
|
||||
end
|
||||
|
||||
local function Rebuild()
|
||||
local entries = ReadEntries()
|
||||
local reopened = ExpandHiddenHeaders(entries)
|
||||
if reopened then
|
||||
entries = ReadEntries()
|
||||
end
|
||||
|
||||
local new = {}
|
||||
incomplete = false
|
||||
for _, info in ipairs(entries) do
|
||||
if not info.isHeader and not info.isHidden and info.questID and info.questID > 0 then
|
||||
local objectives = C_QuestLog.GetQuestObjectives(info.questID)
|
||||
if not objectives then
|
||||
incomplete = true
|
||||
else
|
||||
for _, objective in ipairs(objectives) do
|
||||
if objective.type == "item" then
|
||||
if not objective.text or objective.text == "" then
|
||||
incomplete = true
|
||||
else
|
||||
local name = ObjectiveItemName(objective.text)
|
||||
if name then
|
||||
local key = name:lower()
|
||||
local item = new[key] or { need = 0, quests = {} }
|
||||
new[key] = item
|
||||
item.need = item.need + (objective.numRequired or 0)
|
||||
table.insert(item.quests, {
|
||||
title = info.title,
|
||||
level = QuestLevel(info),
|
||||
need = objective.numRequired,
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if reopened then
|
||||
CollapseHeaders(reopened)
|
||||
end
|
||||
|
||||
questItems = new
|
||||
dirty = false
|
||||
lastNumQuests = select(2, C_QuestLog.GetNumQuestLogEntries())
|
||||
end
|
||||
|
||||
local function FindMatch(recipeInfo)
|
||||
local schematic = C_TradeSkillUI.GetRecipeSchematic(recipeInfo.recipeID, false)
|
||||
local itemID = schematic and schematic.outputItemID
|
||||
if not itemID then
|
||||
return nil
|
||||
end
|
||||
|
||||
local name = C_Item.GetItemNameByID(itemID)
|
||||
if not name then
|
||||
-- The recipe name usually equals the item name, so match on that for
|
||||
-- now and re-check once the real name has loaded.
|
||||
pendingItems[itemID] = true
|
||||
C_Item.RequestLoadItemDataByID(itemID)
|
||||
name = recipeInfo.name
|
||||
end
|
||||
if not name then
|
||||
return nil
|
||||
end
|
||||
|
||||
if dirty then
|
||||
Rebuild()
|
||||
end
|
||||
return questItems[name:lower()], itemID
|
||||
end
|
||||
|
||||
-- Same arithmetic as the row's own Init, with room kept for our text.
|
||||
local function FitLabel(row, reserved)
|
||||
local countWidth = row.Count:IsShown() and row.Count:GetStringWidth() or 0
|
||||
local lockedWidth = row.LockedIcon:IsShown() and row.LockedIcon:GetWidth() or 0
|
||||
local width = row:GetWidth() - (lockedWidth + countWidth + 10 + row.SkillUps:GetWidth() + reserved)
|
||||
row.Label:SetWidth(row:GetWidth())
|
||||
row.Label:SetWidth(math.min(width, row.Label:GetStringWidth()))
|
||||
end
|
||||
|
||||
local function Decorate(row, recipeInfo)
|
||||
rows[row] = recipeInfo
|
||||
|
||||
local match, itemID = FindMatch(recipeInfo)
|
||||
if not match then
|
||||
if row.qchMatch then
|
||||
row.qchMatch = nil
|
||||
row.qchTint:Hide()
|
||||
row.qchText:Hide()
|
||||
FitLabel(row, 0)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if not row.qchTint then
|
||||
row.qchTint = row:CreateTexture(nil, "BACKGROUND")
|
||||
row.qchTint:SetAllPoints()
|
||||
row.qchTint:SetColorTexture(1, 0.82, 0, 0.18)
|
||||
row.qchText = row:CreateFontString(nil, "OVERLAY", "GameFontNormal_NoShadow")
|
||||
end
|
||||
|
||||
local have = C_Item.GetItemCount(itemID) or 0
|
||||
local done = have >= match.need
|
||||
row.qchMatch = match
|
||||
row.qchHave = have
|
||||
|
||||
row.qchTint:SetShown(not done)
|
||||
row.qchText:SetText("! " .. have .. " / " .. match.need)
|
||||
if done then
|
||||
row.qchText:SetTextColor(0.25, 1, 0.25)
|
||||
else
|
||||
row.qchText:SetTextColor(1, 0.82, 0)
|
||||
end
|
||||
|
||||
local lockedWidth = row.LockedIcon:IsShown() and row.LockedIcon:GetWidth() or 0
|
||||
row.qchText:ClearAllPoints()
|
||||
row.qchText:SetPoint("RIGHT", row, "RIGHT", -(lockedWidth + 4), 0)
|
||||
row.qchText:Show()
|
||||
FitLabel(row, row.qchText:GetStringWidth() + 8)
|
||||
end
|
||||
|
||||
local function ShowQuestLines(row)
|
||||
local match = row.qchMatch
|
||||
if not match then
|
||||
return
|
||||
end
|
||||
|
||||
-- The row already owns the tooltip when its name is truncated.
|
||||
if not GameTooltip:IsOwned(row.Label) then
|
||||
GameTooltip:SetOwner(row, "ANCHOR_RIGHT")
|
||||
end
|
||||
for _, quest in ipairs(match.quests) do
|
||||
local left = "Quest: "
|
||||
if quest.level then
|
||||
left = left .. "[" .. quest.level .. "] "
|
||||
end
|
||||
left = left .. quest.title
|
||||
|
||||
local color = quest.level and GetQuestDifficultyColor and GetQuestDifficultyColor(quest.level)
|
||||
local r, g, b = 1, 0.82, 0
|
||||
if color then
|
||||
r, g, b = color.r, color.g, color.b
|
||||
end
|
||||
GameTooltip:AddDoubleLine(left, row.qchHave .. " / " .. (quest.need or "?"), r, g, b, 1, 1, 1)
|
||||
end
|
||||
GameTooltip:Show()
|
||||
end
|
||||
|
||||
-- Rows copy the mixin when they are created, which happens after this hook.
|
||||
local function HookRecipeList()
|
||||
if hooked or not ProfessionsRecipeListRecipeMixin then
|
||||
return
|
||||
end
|
||||
hooked = true
|
||||
hooksecurefunc(ProfessionsRecipeListRecipeMixin, "Init", function(row, node)
|
||||
local recipeInfo = node:GetData().recipeInfo
|
||||
if recipeInfo then
|
||||
Decorate(row, recipeInfo)
|
||||
end
|
||||
end)
|
||||
hooksecurefunc(ProfessionsRecipeListRecipeMixin, "OnEnter", ShowQuestLines)
|
||||
end
|
||||
|
||||
local refreshQueued = false
|
||||
local function QueueRefresh()
|
||||
if refreshQueued then
|
||||
return
|
||||
end
|
||||
refreshQueued = true
|
||||
C_Timer.After(0, function()
|
||||
refreshQueued = false
|
||||
for row, recipeInfo in pairs(rows) do
|
||||
if row:IsVisible() then
|
||||
Decorate(row, recipeInfo)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
HookRecipeList()
|
||||
|
||||
local frame = CreateFrame("Frame")
|
||||
for _, event in ipairs({
|
||||
"ADDON_LOADED", "PLAYER_ENTERING_WORLD", "QUEST_LOG_UPDATE", "QUEST_ACCEPTED", "QUEST_REMOVED",
|
||||
"QUEST_TURNED_IN", "BAG_UPDATE_DELAYED", "ITEM_DATA_LOAD_RESULT",
|
||||
}) do
|
||||
if not C_EventUtils or C_EventUtils.IsEventValid(event) then
|
||||
frame:RegisterEvent(event)
|
||||
end
|
||||
end
|
||||
frame:SetScript("OnEvent", function(_, event, arg1)
|
||||
if event == "ADDON_LOADED" then
|
||||
if arg1 == "Blizzard_ProfessionsTemplates" then
|
||||
HookRecipeList()
|
||||
end
|
||||
elseif event == "ITEM_DATA_LOAD_RESULT" then
|
||||
if pendingItems[arg1] then
|
||||
pendingItems[arg1] = nil
|
||||
QueueRefresh()
|
||||
end
|
||||
elseif event == "BAG_UPDATE_DELAYED" then
|
||||
QueueRefresh()
|
||||
elseif event == "QUEST_LOG_UPDATE" then
|
||||
-- Also fires when headers are toggled, including by Rebuild itself,
|
||||
-- so only react if the quests themselves changed.
|
||||
if incomplete or select(2, C_QuestLog.GetNumQuestLogEntries()) ~= lastNumQuests then
|
||||
dirty = true
|
||||
QueueRefresh()
|
||||
end
|
||||
else
|
||||
dirty = true
|
||||
QueueRefresh()
|
||||
end
|
||||
end)
|
||||
|
||||
-- /qch prints what the addon currently knows.
|
||||
SLASH_QUESTCRAFTHIGHLIGHT1 = "/qch"
|
||||
SlashCmdList.QUESTCRAFTHIGHLIGHT = function()
|
||||
Rebuild()
|
||||
local print = function(text) DEFAULT_CHAT_FRAME:AddMessage("|cffffd100QuestCraftHighlight:|r " .. text) end
|
||||
local rowCount = 0
|
||||
for _ in pairs(rows) do
|
||||
rowCount = rowCount + 1
|
||||
end
|
||||
print("hooked=" .. tostring(hooked) .. " rows=" .. rowCount)
|
||||
for name, item in pairs(questItems) do
|
||||
print(name .. " -> need " .. item.need .. ", first quest " .. item.quests[1].title)
|
||||
end
|
||||
end
|
||||
6
QuestCraftHighlight/QuestCraftHighlight.toc
Normal file
6
QuestCraftHighlight/QuestCraftHighlight.toc
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
## Interface: 16001
|
||||
## Title: Quest Craft Highlight
|
||||
## Notes: Highlights profession recipes whose crafted item is needed by one of your quests.
|
||||
## Version: 1.0
|
||||
|
||||
QuestCraftHighlight.lua
|
||||
377
QuestItemTip/QuestItemTip.lua
Normal file
377
QuestItemTip/QuestItemTip.lua
Normal file
|
|
@ -0,0 +1,377 @@
|
|||
-- Quest Item Tip: adds "Quest: [level] name have / need" to item tooltips,
|
||||
-- and says so when a quest item you carry is no longer needed.
|
||||
|
||||
local ADDON_NAME = ...
|
||||
local ITEM_CLASS_QUEST = 12
|
||||
local ITEM_BIND_TYPE_QUEST = 4
|
||||
|
||||
-- Lowercased item name -> list of { questID, title, level, need }.
|
||||
-- Holds only what is fixed for the life of a quest; have-counts are read when
|
||||
-- the tooltip is shown, so looting never needs a rebuild.
|
||||
local index = {}
|
||||
-- Item ID -> list of { questID, title, level } for items a quest handed you.
|
||||
local provided = {}
|
||||
-- List of { questID, title, level, text } with each quest's lowercased log text,
|
||||
-- for delivery quests, which name their item only in prose.
|
||||
local questTexts = {}
|
||||
-- Saved per character. Lowercased name or item ID -> the quest last seen using
|
||||
-- it, which is how a quest can still be named after it has left the log.
|
||||
local db
|
||||
|
||||
local dirty = true
|
||||
local incomplete = false
|
||||
local rebuildOnNextUpdate = false
|
||||
local rebuilding = false
|
||||
local lastNumQuests
|
||||
|
||||
-- "Linen Cloth: 3/5" or "3/5 Linen Cloth (Optional)" -> "Linen Cloth"
|
||||
local function ObjectiveItemName(text)
|
||||
local name = text:match("^%d+/%d+%s+(.+)$") or text:match("^(.-):?%s*%d+/%d+")
|
||||
if name then
|
||||
name = name:gsub("%s+%(Optional%)$", "")
|
||||
-- " : 0/1" is what the client gives before the item's name has loaded.
|
||||
name = name:match("^%s*(.-)%s*$")
|
||||
if name ~= "" then
|
||||
return name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function ReadEntries()
|
||||
local entries = {}
|
||||
for i = 1, (C_QuestLog.GetNumQuestLogEntries()) do
|
||||
local info = C_QuestLog.GetInfo(i)
|
||||
if info then
|
||||
info.logIndex = i
|
||||
entries[#entries + 1] = info
|
||||
end
|
||||
end
|
||||
return entries
|
||||
end
|
||||
|
||||
-- Returns the titles of collapsed headers whose quests are not being listed.
|
||||
-- Those have to be opened to be read, then closed again.
|
||||
local function ExpandHiddenHeaders(entries)
|
||||
local reopened
|
||||
for i = #entries, 1, -1 do
|
||||
local info, nextInfo = entries[i], entries[i + 1]
|
||||
if info.isHeader and info.isCollapsed and (not nextInfo or nextInfo.isHeader) then
|
||||
reopened = reopened or {}
|
||||
reopened[info.title] = true
|
||||
ExpandQuestHeader(i)
|
||||
end
|
||||
end
|
||||
return reopened
|
||||
end
|
||||
|
||||
local function CollapseHeaders(titles)
|
||||
local entries = ReadEntries()
|
||||
for i = #entries, 1, -1 do
|
||||
local info = entries[i]
|
||||
if info.isHeader and titles[info.title] then
|
||||
CollapseQuestHeader(i)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function QuestLevel(info)
|
||||
if info.level and info.level > 0 then
|
||||
return info.level
|
||||
end
|
||||
return C_QuestLog.GetQuestDifficultyLevel and C_QuestLog.GetQuestDifficultyLevel(info.questID) or nil
|
||||
end
|
||||
|
||||
local function IsRealQuest(info)
|
||||
return not info.isHeader and not info.isHidden and info.questID and info.questID > 0
|
||||
end
|
||||
|
||||
local function Remember(key, info)
|
||||
if db then
|
||||
db[key] = { questID = info.questID, title = info.title, level = QuestLevel(info) }
|
||||
end
|
||||
end
|
||||
|
||||
-- Same steps as Blizzard's abandon-quest button, which is the only place the
|
||||
-- client exposes these. Skipped while that button's own popup is on screen.
|
||||
local function ReadProvidedItems(entries)
|
||||
if StaticPopup_Visible("ABANDON_QUEST") or StaticPopup_Visible("ABANDON_QUEST_WITH_ITEMS") then
|
||||
return
|
||||
end
|
||||
|
||||
local new = {}
|
||||
local function Add(itemID, info)
|
||||
new[itemID] = new[itemID] or {}
|
||||
table.insert(new[itemID], { questID = info.questID, title = info.title, level = QuestLevel(info) })
|
||||
Remember(itemID, info)
|
||||
end
|
||||
|
||||
local selected = C_QuestLog.GetSelectedQuest()
|
||||
for _, info in ipairs(entries) do
|
||||
if IsRealQuest(info) then
|
||||
C_QuestLog.SetSelectedQuest(info.questID)
|
||||
C_QuestLog.SetAbandonQuest()
|
||||
for _, itemID in ipairs(C_QuestLog.GetAbandonQuestItems() or {}) do
|
||||
Add(itemID, info)
|
||||
end
|
||||
end
|
||||
end
|
||||
C_QuestLog.SetSelectedQuest(selected)
|
||||
provided = new
|
||||
end
|
||||
|
||||
local function Rebuild()
|
||||
if rebuilding then
|
||||
return
|
||||
end
|
||||
rebuilding = true
|
||||
rebuildOnNextUpdate = false
|
||||
lastNumQuests = select(2, C_QuestLog.GetNumQuestLogEntries())
|
||||
|
||||
local entries = ReadEntries()
|
||||
local reopened = ExpandHiddenHeaders(entries)
|
||||
if reopened then
|
||||
entries = ReadEntries()
|
||||
end
|
||||
|
||||
local new = {}
|
||||
local texts = {}
|
||||
incomplete = false
|
||||
for _, info in ipairs(entries) do
|
||||
if IsRealQuest(info) then
|
||||
local description, objectiveText = GetQuestLogQuestText(info.logIndex)
|
||||
if (description or "") == "" and (objectiveText or "") == "" then
|
||||
incomplete = true
|
||||
else
|
||||
texts[#texts + 1] = {
|
||||
questID = info.questID,
|
||||
title = info.title,
|
||||
level = QuestLevel(info),
|
||||
text = ((objectiveText or "") .. "\n" .. (description or "")):lower(),
|
||||
}
|
||||
end
|
||||
|
||||
local objectives = C_QuestLog.GetQuestObjectives(info.questID)
|
||||
if not objectives then
|
||||
incomplete = true
|
||||
else
|
||||
for _, objective in ipairs(objectives) do
|
||||
if objective.type == "item" then
|
||||
if not objective.text or objective.text == "" then
|
||||
incomplete = true
|
||||
else
|
||||
local name = ObjectiveItemName(objective.text)
|
||||
if name then
|
||||
local key = name:lower()
|
||||
new[key] = new[key] or {}
|
||||
table.insert(new[key], {
|
||||
questID = info.questID,
|
||||
title = info.title,
|
||||
level = QuestLevel(info),
|
||||
need = objective.numRequired,
|
||||
})
|
||||
Remember(key, info)
|
||||
else
|
||||
incomplete = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ReadProvidedItems(entries)
|
||||
|
||||
if reopened then
|
||||
CollapseHeaders(reopened)
|
||||
end
|
||||
|
||||
index = new
|
||||
questTexts = texts
|
||||
dirty = false
|
||||
rebuilding = false
|
||||
end
|
||||
|
||||
local function QuestLabel(prefix, quest)
|
||||
local left = prefix
|
||||
if quest.level then
|
||||
left = left .. "[" .. quest.level .. "] "
|
||||
end
|
||||
left = left .. quest.title
|
||||
|
||||
local color = quest.level and GetQuestDifficultyColor and GetQuestDifficultyColor(quest.level)
|
||||
if color then
|
||||
return left, color.r, color.g, color.b
|
||||
end
|
||||
return left, 1, 0.82, 0
|
||||
end
|
||||
|
||||
local function IsQuestItem(id)
|
||||
local _, _, _, _, _, classID = C_Item.GetItemInfoInstant(id)
|
||||
return classID == ITEM_CLASS_QUEST or select(14, C_Item.GetItemInfo(id)) == ITEM_BIND_TYPE_QUEST
|
||||
end
|
||||
|
||||
local function StartsQuest(data)
|
||||
local startsQuest = ITEM_STARTS_QUEST or "This Item Begins a Quest"
|
||||
for _, line in ipairs(data.lines or {}) do
|
||||
if line.leftText == startsQuest then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function QuestMentioning(name)
|
||||
local lowered = name:lower()
|
||||
for _, quest in ipairs(questTexts) do
|
||||
if quest.text:find(lowered, 1, true) then
|
||||
return quest
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- For an item no quest in the log is using right now.
|
||||
local function AddLeftoverLine(tooltip, data, id, name)
|
||||
if (C_Item.GetItemCount(id, true) or 0) == 0 then
|
||||
return false
|
||||
end
|
||||
|
||||
-- Quest items only: ordinary goods turn up in quest prose all the time.
|
||||
local mentioned = IsQuestItem(id) and QuestMentioning(name)
|
||||
if mentioned then
|
||||
Remember(id, mentioned)
|
||||
tooltip:AddLine(QuestLabel("Quest: ", mentioned))
|
||||
return true
|
||||
end
|
||||
|
||||
local record = db and (db[id] or db[name:lower()])
|
||||
if record then
|
||||
if C_QuestLog.IsOnQuest(record.questID) then
|
||||
local left, r, g, b = QuestLabel("Quest: ", record)
|
||||
tooltip:AddLine(left, r, g, b)
|
||||
else
|
||||
local prefix = C_QuestLog.IsQuestFlaggedCompleted(record.questID) and "Quest done: " or "Quest dropped: "
|
||||
tooltip:AddDoubleLine((QuestLabel(prefix, record)), "can delete", 1, 0.3, 0.3, 1, 0.3, 0.3)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
if IsQuestItem(id) and not StartsQuest(data) then
|
||||
tooltip:AddLine("Quest item: no quest in your log uses it", 1, 0.5, 0.1)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function AddQuestLines(tooltip, data)
|
||||
if tooltip ~= GameTooltip and tooltip ~= ItemRefTooltip then
|
||||
return
|
||||
end
|
||||
local id = data and data.id
|
||||
if not id then
|
||||
return
|
||||
end
|
||||
local name = C_Item.GetItemNameByID(id) or tooltip:GetItem()
|
||||
if not name then
|
||||
return
|
||||
end
|
||||
|
||||
if dirty then
|
||||
Rebuild()
|
||||
end
|
||||
local quests = index[name:lower()]
|
||||
local givenBy = provided[id]
|
||||
|
||||
if not quests and not givenBy then
|
||||
if AddLeftoverLine(tooltip, data, id, name) then
|
||||
tooltip:Show()
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
local listed = {}
|
||||
if quests then
|
||||
-- Only bag items count towards an objective, so the bank is shown apart.
|
||||
local bags = C_Item.GetItemCount(id) or 0
|
||||
local bank = (C_Item.GetItemCount(id, true) or bags) - bags
|
||||
|
||||
for _, quest in ipairs(quests) do
|
||||
listed[quest.questID] = true
|
||||
local left, r, g, b = QuestLabel("Quest: ", quest)
|
||||
|
||||
local right = bags .. " / " .. (quest.need or "?")
|
||||
if bank > 0 then
|
||||
right = right .. " (+" .. bank .. " bank)"
|
||||
end
|
||||
|
||||
if quest.need and bags >= quest.need then
|
||||
tooltip:AddDoubleLine(left, right, r, g, b, 0.25, 1, 0.25)
|
||||
else
|
||||
tooltip:AddDoubleLine(left, right, r, g, b, 1, 1, 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for _, quest in ipairs(givenBy or {}) do
|
||||
if not listed[quest.questID] then
|
||||
local left, r, g, b = QuestLabel("Quest: ", quest)
|
||||
tooltip:AddLine(left, r, g, b)
|
||||
end
|
||||
end
|
||||
tooltip:Show()
|
||||
end
|
||||
|
||||
TooltipDataProcessor.AddTooltipPostCall(Enum.TooltipDataType.Item, AddQuestLines)
|
||||
|
||||
local frame = CreateFrame("Frame")
|
||||
for _, event in ipairs({ "ADDON_LOADED", "PLAYER_ENTERING_WORLD", "QUEST_LOG_UPDATE", "QUEST_ACCEPTED", "QUEST_REMOVED", "QUEST_TURNED_IN" }) do
|
||||
if not C_EventUtils or C_EventUtils.IsEventValid(event) then
|
||||
frame:RegisterEvent(event)
|
||||
end
|
||||
end
|
||||
frame:SetScript("OnEvent", function(_, event, arg1)
|
||||
if event == "ADDON_LOADED" then
|
||||
if arg1 == ADDON_NAME then
|
||||
QuestItemTipDB = QuestItemTipDB or {}
|
||||
db = QuestItemTipDB
|
||||
end
|
||||
elseif event == "QUEST_LOG_UPDATE" then
|
||||
-- Also fires when headers are toggled, including by Rebuild itself,
|
||||
-- so only react if the quests themselves changed. Rebuilding now,
|
||||
-- not at the next tooltip, is what records a quest before it ends.
|
||||
local changed = select(2, C_QuestLog.GetNumQuestLogEntries()) ~= lastNumQuests
|
||||
if changed or incomplete then
|
||||
dirty = true
|
||||
end
|
||||
if changed or rebuildOnNextUpdate then
|
||||
rebuildOnNextUpdate = false
|
||||
Rebuild()
|
||||
end
|
||||
else
|
||||
dirty = true
|
||||
rebuildOnNextUpdate = true
|
||||
end
|
||||
end)
|
||||
|
||||
-- /qit prints what was read from the quest log.
|
||||
SLASH_QUESTITEMTIP1 = "/qit"
|
||||
SlashCmdList.QUESTITEMTIP = function()
|
||||
Rebuild()
|
||||
local print = function(text) DEFAULT_CHAT_FRAME:AddMessage("|cffffd100QuestItemTip:|r " .. text) end
|
||||
local found = false
|
||||
for name, quests in pairs(index) do
|
||||
for _, quest in ipairs(quests) do
|
||||
found = true
|
||||
print(name .. " -> [" .. tostring(quest.level) .. "] " .. quest.title .. ", need " .. tostring(quest.need))
|
||||
end
|
||||
end
|
||||
for itemID, quests in pairs(provided) do
|
||||
for _, quest in ipairs(quests) do
|
||||
found = true
|
||||
print("item " .. itemID .. " given by [" .. tostring(quest.level) .. "] " .. quest.title)
|
||||
end
|
||||
end
|
||||
if not found then
|
||||
print("no item objectives in your quest log")
|
||||
end
|
||||
end
|
||||
7
QuestItemTip/QuestItemTip.toc
Normal file
7
QuestItemTip/QuestItemTip.toc
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
## Interface: 16001
|
||||
## Title: Quest Item Tip
|
||||
## Notes: Item tooltips show which of your quests need the item, the quest level, have / need, and when a quest item is no longer needed.
|
||||
## Version: 1.1
|
||||
## SavedVariablesPerCharacter: QuestItemTipDB
|
||||
|
||||
QuestItemTip.lua
|
||||
48
README.md
Normal file
48
README.md
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
# WoW Forever addons
|
||||
|
||||
Four small quality-of-life addons for WoW Forever (client 1.60.1, Interface 16001).
|
||||
|
||||
| Addon | What it does | Check command |
|
||||
| --- | --- | --- |
|
||||
| Quest Item Tip | Item tooltips show the quest, its level and have / need. Warns when a quest item is no longer needed. | `/qit` |
|
||||
| Quest Craft Highlight | Highlights profession recipes whose crafted item an active quest needs. | `/qch` |
|
||||
| Vendor Flag | Marks items for 10 minutes after Auctionator warns they would earn more at a vendor. Requires [Auctionator](https://www.curseforge.com/wow/addons/auctionator). | `/vf` |
|
||||
| Dungeon Pre-Quest | Marks quests whose chain leads to a dungeon quest, in the quest log and on the quest offer window. | `/dpq <questID>` |
|
||||
|
||||
## Install
|
||||
|
||||
Copy the four addon folders into `World of Warcraft/_forever_/Interface/AddOns/`, then restart the game.
|
||||
Each addon works on its own, so copy only the ones you want. Vendor Flag stays disabled unless Auctionator is installed.
|
||||
|
||||
## Known limits
|
||||
|
||||
- Vendor Flag only marks an item when Auctionator shows its vendor warning as you post.
|
||||
- Quest Item Tip's "can delete" only knows quests seen since it was installed.
|
||||
- Quest Craft Highlight doesn't highlight recipes inside collapsed categories until you expand them.
|
||||
- Dungeon Pre-Quest misses chains that QuestieDB has no links for, which includes many quests new to Forever.
|
||||
|
||||
## Tests
|
||||
|
||||
The tests run each addon against a mock of the WoW API, using stock Lua 5.1:
|
||||
|
||||
```
|
||||
lua tests/test_qit.lua QuestItemTip/QuestItemTip.lua
|
||||
lua tests/test_qch.lua QuestCraftHighlight/QuestCraftHighlight.lua
|
||||
lua tests/test_vf.lua VendorFlag/VendorFlag.lua
|
||||
lua tests/test_dpq.lua DungeonPreQuest/DungeonPreQuest.lua
|
||||
```
|
||||
|
||||
## Regenerating Dungeon Pre-Quest's data
|
||||
|
||||
`DungeonPreQuest/Data.lua` is generated from QuestieDB and Questie, cloned locally:
|
||||
|
||||
```
|
||||
lua DungeonPreQuest/tools/extract.lua <QuestieDB dir> <Questie dir> merged.lua
|
||||
lua DungeonPreQuest/tools/generate.lua merged.lua DungeonPreQuest/Data.lua
|
||||
```
|
||||
|
||||
## Credits and licence
|
||||
|
||||
Dungeon Pre-Quest's data is derived from [QuestieDB](https://github.com/Questie/QuestieDB) and
|
||||
[Questie](https://github.com/Questie/Questie), both GPL-3.0. This project is released under the
|
||||
GNU General Public License v3.0, see [LICENSE.md](LICENSE.md).
|
||||
174
VendorFlag/VendorFlag.lua
Normal file
174
VendorFlag/VendorFlag.lua
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
-- Vendor Flag: marks bag items that Auctionator just warned would earn more at
|
||||
-- a vendor, so they can be found again at the merchant.
|
||||
|
||||
local ADDON_NAME = ...
|
||||
local FLAG_SECONDS = 10 * 60
|
||||
|
||||
-- Item key -> time() at which the flag runs out.
|
||||
local flags
|
||||
local hooked = {}
|
||||
-- Every item button Auctionator's selling tab has created so far.
|
||||
local auctionButtons = {}
|
||||
|
||||
-- Item ID plus suffix, so "of the Bear" and "of the Eagle" are told apart.
|
||||
local function ItemKey(link)
|
||||
local id, suffix = link:match("item:(%d+):[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:([^:|]*)")
|
||||
if id then
|
||||
return id .. ":" .. suffix
|
||||
end
|
||||
end
|
||||
|
||||
local function SecondsLeft(link)
|
||||
local key = flags and link and ItemKey(link)
|
||||
local expires = key and flags[key]
|
||||
if not expires then
|
||||
return nil
|
||||
end
|
||||
local left = expires - time()
|
||||
if left <= 0 then
|
||||
flags[key] = nil
|
||||
return nil
|
||||
end
|
||||
return left
|
||||
end
|
||||
|
||||
local function MinutesText(left)
|
||||
return math.ceil(left / 60) .. "m"
|
||||
end
|
||||
|
||||
local function ApplyMark(button, link)
|
||||
local left = SecondsLeft(link)
|
||||
if not left then
|
||||
if button.vfTint then
|
||||
button.vfTint:Hide()
|
||||
button.vfText:Hide()
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if not button.vfTint then
|
||||
button.vfTint = button:CreateTexture(nil, "OVERLAY", nil, 6)
|
||||
button.vfTint:SetAllPoints()
|
||||
button.vfTint:SetColorTexture(1, 0.82, 0, 0.35)
|
||||
button.vfText = button:CreateFontString(nil, "OVERLAY", "NumberFontNormalSmall")
|
||||
button.vfText:SetPoint("TOPRIGHT", button, "TOPRIGHT", -2, -3)
|
||||
button.vfText:SetTextColor(1, 0.82, 0)
|
||||
end
|
||||
button.vfText:SetText(MinutesText(left))
|
||||
button.vfTint:Show()
|
||||
button.vfText:Show()
|
||||
end
|
||||
|
||||
local function UpdateButton(button)
|
||||
ApplyMark(button, C_Container.GetContainerItemLink(button:GetBagID(), button:GetID()))
|
||||
end
|
||||
|
||||
local function UpdateFrame(frame)
|
||||
for _, button in frame:EnumerateValidItems() do
|
||||
UpdateButton(button)
|
||||
end
|
||||
end
|
||||
|
||||
local function EachBagFrame(callback)
|
||||
for i = 1, 20 do
|
||||
local frame = _G["ContainerFrame" .. i]
|
||||
if frame then
|
||||
callback(frame)
|
||||
end
|
||||
end
|
||||
if ContainerFrameCombinedBags then
|
||||
callback(ContainerFrameCombinedBags)
|
||||
end
|
||||
end
|
||||
|
||||
local function UpdateOpenBags()
|
||||
EachBagFrame(function(frame)
|
||||
if frame:IsShown() then
|
||||
UpdateFrame(frame)
|
||||
end
|
||||
end)
|
||||
for button in pairs(auctionButtons) do
|
||||
if button:IsVisible() then
|
||||
ApplyMark(button, button.itemInfo and button.itemInfo.itemLink)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function HookBagFrames()
|
||||
EachBagFrame(function(frame)
|
||||
if frame.UpdateItems and not hooked[frame] then
|
||||
hooked[frame] = true
|
||||
hooksecurefunc(frame, "UpdateItems", UpdateFrame)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
-- Auctionator's frames copy these mixins when the auction house first opens,
|
||||
-- which is always after this file has run.
|
||||
if AuctionatorGroupsViewItemMixin then
|
||||
hooksecurefunc(AuctionatorGroupsViewItemMixin, "SetItemInfo", function(button, info)
|
||||
auctionButtons[button] = true
|
||||
ApplyMark(button, info and info.itemLink)
|
||||
end)
|
||||
end
|
||||
|
||||
if AuctionatorSaleItemMixin and AuctionatorSaleItemMixin.GetConfirmationMessage then
|
||||
local original = AuctionatorSaleItemMixin.GetConfirmationMessage
|
||||
AuctionatorSaleItemMixin.GetConfirmationMessage = function(self, ...)
|
||||
local message = original(self, ...)
|
||||
if message and message == AUCTIONATOR_L_CONFIRM_POST_BELOW_VENDOR and self.itemInfo and self.itemInfo.itemLink and flags then
|
||||
local key = ItemKey(self.itemInfo.itemLink)
|
||||
if key then
|
||||
flags[key] = time() + FLAG_SECONDS
|
||||
UpdateOpenBags()
|
||||
end
|
||||
end
|
||||
return message
|
||||
end
|
||||
end
|
||||
|
||||
TooltipDataProcessor.AddTooltipPostCall(Enum.TooltipDataType.Item, function(tooltip)
|
||||
if tooltip ~= GameTooltip and tooltip ~= ItemRefTooltip then
|
||||
return
|
||||
end
|
||||
local _, link = tooltip:GetItem()
|
||||
local left = SecondsLeft(link)
|
||||
if left then
|
||||
tooltip:AddLine("Vendor beats auction (" .. MinutesText(left) .. " left)", 1, 0.82, 0)
|
||||
tooltip:Show()
|
||||
end
|
||||
end)
|
||||
|
||||
local frame = CreateFrame("Frame")
|
||||
frame:RegisterEvent("ADDON_LOADED")
|
||||
frame:RegisterEvent("PLAYER_LOGIN")
|
||||
frame:RegisterEvent("BAG_UPDATE_DELAYED")
|
||||
frame:SetScript("OnEvent", function(_, event, arg1)
|
||||
if event == "ADDON_LOADED" then
|
||||
if arg1 == ADDON_NAME then
|
||||
VendorFlagDB = VendorFlagDB or {}
|
||||
flags = VendorFlagDB
|
||||
end
|
||||
elseif event == "PLAYER_LOGIN" then
|
||||
HookBagFrames()
|
||||
C_Timer.NewTicker(15, UpdateOpenBags)
|
||||
else
|
||||
UpdateOpenBags()
|
||||
end
|
||||
end)
|
||||
|
||||
-- /vf lists what is currently flagged.
|
||||
SLASH_VENDORFLAG1 = "/vf"
|
||||
SlashCmdList.VENDORFLAG = function()
|
||||
local found = false
|
||||
for key, expires in pairs(flags or {}) do
|
||||
local left = expires - time()
|
||||
if left > 0 then
|
||||
found = true
|
||||
DEFAULT_CHAT_FRAME:AddMessage("|cffffd100VendorFlag:|r " .. key .. " " .. MinutesText(left))
|
||||
end
|
||||
end
|
||||
if not found then
|
||||
DEFAULT_CHAT_FRAME:AddMessage("|cffffd100VendorFlag:|r nothing flagged")
|
||||
end
|
||||
end
|
||||
8
VendorFlag/VendorFlag.toc
Normal file
8
VendorFlag/VendorFlag.toc
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
## Interface: 16001
|
||||
## Title: Vendor Flag
|
||||
## Notes: Marks bag items Auctionator just warned would earn more at a vendor, for 10 minutes.
|
||||
## Version: 1.0
|
||||
## Dependencies: Auctionator
|
||||
## SavedVariablesPerCharacter: VendorFlagDB
|
||||
|
||||
VendorFlag.lua
|
||||
139
tests/test_dpq.lua
Normal file
139
tests/test_dpq.lua
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
-- Runs DungeonPreQuest.lua against a mock of the WoW API.
|
||||
-- arg[1] = addon file
|
||||
|
||||
local faction, classID = "Alliance", 1
|
||||
function UnitFactionGroup() return faction end
|
||||
function UnitClass() return "x", "X", classID end
|
||||
|
||||
local callback
|
||||
EventRegistry = { RegisterCallback = function(_, _, fn) callback = fn end }
|
||||
|
||||
local hooks = {}
|
||||
function hooksecurefunc(name, fn) hooks[name] = fn end
|
||||
|
||||
local function region()
|
||||
local r = { shown = false }
|
||||
function r:Show() self.shown = true end
|
||||
function r:Hide() self.shown = false end
|
||||
function r:SetPoint() end
|
||||
function r:SetText(t) self.text = t end
|
||||
return r
|
||||
end
|
||||
|
||||
local function button(id)
|
||||
local b = { questID = id, creates = 0 }
|
||||
function b:CreateFontString() self.creates = self.creates + 1; return region() end
|
||||
return b
|
||||
end
|
||||
|
||||
local rows = {}
|
||||
QuestScrollFrame = { titleFramePool = { EnumerateActive = function()
|
||||
local i = 0
|
||||
return function() i = i + 1; return rows[i] end
|
||||
end } }
|
||||
|
||||
local onShow
|
||||
QuestFrameDetailPanel = {
|
||||
CreateFontString = function() return region() end,
|
||||
HookScript = function(_, _, fn) onShow = fn end,
|
||||
}
|
||||
local banner
|
||||
do
|
||||
local make = QuestFrameDetailPanel.CreateFontString
|
||||
QuestFrameDetailPanel.CreateFontString = function() banner = make(); return banner end
|
||||
end
|
||||
QuestFrame = {}
|
||||
|
||||
local currentQuest
|
||||
function GetQuestID() return currentQuest end
|
||||
|
||||
local tipLines, tipShown = {}, 0
|
||||
GameTooltip = { AddLine = function(_, l) tipLines[#tipLines + 1] = l end, Show = function() tipShown = tipShown + 1 end }
|
||||
|
||||
local onEvent, registered = nil, {}
|
||||
CreateFrame = function() return { RegisterEvent = function(_, e) registered[e] = true end, SetScript = function(_, _, fn) onEvent = fn end } end
|
||||
SlashCmdList = {}
|
||||
local printed = {}
|
||||
DEFAULT_CHAT_FRAME = { AddMessage = function(_, m) printed[#printed + 1] = m end }
|
||||
|
||||
local failures = 0
|
||||
local function check(cond, what)
|
||||
if not cond then failures = failures + 1 end
|
||||
print((cond and "ok " or "FAIL ") .. what)
|
||||
end
|
||||
|
||||
local ns = {
|
||||
dungeons = { "The Deadmines", "Stratholme" },
|
||||
quests = {
|
||||
[65] = { 1, 3, 0 }, -- everyone
|
||||
[70] = { 1, 1, 0 }, -- Alliance only
|
||||
[71] = { 2, 3, 2 }, -- paladins only (class bit 2)
|
||||
[72] = { 2, 3, 1024 }, -- druids only (class 11)
|
||||
[73] = { 1, 3, 0, 2, 3, 0, 1, 3, 0 }, -- two dungeons, one repeated
|
||||
[74] = { 0, 3, 0 }, -- dungeon not known by name
|
||||
},
|
||||
}
|
||||
assert(loadfile(arg[1]))("DungeonPreQuest", ns)
|
||||
check(hooks.QuestLogQuests_Update == nil, "nothing touches Blizzard frames before login")
|
||||
onEvent(nil, "QUEST_DETAIL")
|
||||
onEvent(nil, "PLAYER_LOGIN")
|
||||
|
||||
local function text(id)
|
||||
tipLines = {}
|
||||
callback(ns, { questID = id }, id)
|
||||
return tipLines[1]
|
||||
end
|
||||
|
||||
check(text(65) == "Dungeon pre-quest: The Deadmines", "tooltip names the dungeon: " .. tostring(text(65)))
|
||||
check(text(99) == nil, "unrelated quest gets no tooltip line")
|
||||
check(text(73) == "Dungeon pre-quest: The Deadmines, Stratholme", "several dungeons, no repeats: " .. tostring(text(73)))
|
||||
check(text(74) == "Dungeon pre-quest", "unknown dungeon still marks: " .. tostring(text(74)))
|
||||
|
||||
check(text(70) ~= nil, "Alliance entry shows for Alliance")
|
||||
faction = "Horde"
|
||||
check(text(70) == nil, "Alliance entry hidden for Horde")
|
||||
faction = "Alliance"
|
||||
|
||||
classID = 1
|
||||
check(text(71) == nil, "paladin chain hidden for a warrior")
|
||||
classID = 2
|
||||
check(text(71) ~= nil, "paladin chain shown for a paladin")
|
||||
classID = 11
|
||||
check(text(72) ~= nil, "class ID 11 maps to the druid bit")
|
||||
classID = 1
|
||||
|
||||
tipLines = {}
|
||||
callback(ns, { questID = 65 })
|
||||
check(tipLines[1] ~= nil, "tooltip falls back to the button's quest ID")
|
||||
|
||||
-- Log rows: buttons are pooled and reused.
|
||||
local a, b = button(65), button(99)
|
||||
rows = { a, b }
|
||||
hooks.QuestLogQuests_Update()
|
||||
check(a.dpqMark and a.dpqMark.shown and a.dpqMark.text:find("D", 1, true), "pre-quest row is marked")
|
||||
check(b.dpqMark == nil, "other row stays unmarked")
|
||||
|
||||
a.questID = 99
|
||||
hooks.QuestLogQuests_Update()
|
||||
check(a.dpqMark.shown == false, "reused row drops the mark")
|
||||
a.questID = 65
|
||||
hooks.QuestLogQuests_Update()
|
||||
check(a.dpqMark.shown == true and a.creates == 1, "row mark is reused, not recreated")
|
||||
|
||||
-- Offer window.
|
||||
currentQuest = 65
|
||||
onShow()
|
||||
check(banner.shown and banner.text:find("The Deadmines", 1, true), "offer window shows the banner")
|
||||
currentQuest = 99
|
||||
check(registered.QUEST_DETAIL, "listens for a new quest being offered")
|
||||
onEvent()
|
||||
check(banner.shown == false, "next offer clears the banner")
|
||||
|
||||
printed = {}
|
||||
SlashCmdList.DUNGEONPREQUEST("65")
|
||||
check(printed[1]:find("The Deadmines", 1, true), "/dpq describes a quest")
|
||||
SlashCmdList.DUNGEONPREQUEST("nope")
|
||||
check(printed[2]:find("usage", 1, true), "/dpq explains itself")
|
||||
|
||||
print(failures == 0 and "ALL PASSED" or (failures .. " FAILED"))
|
||||
os.exit(failures == 0 and 0 or 1)
|
||||
218
tests/test_qch.lua
Normal file
218
tests/test_qch.lua
Normal file
|
|
@ -0,0 +1,218 @@
|
|||
-- Runs QuestCraftHighlight.lua against a mock of the WoW API.
|
||||
-- arg[1] = addon file
|
||||
|
||||
local log = {
|
||||
{ title = "Leather", isHeader = true },
|
||||
{ title = "Moonglow Vest", questID = 1, level = 18, objs = {
|
||||
{ type = "item", text = "Embossed Leather Gloves: 0/1", numRequired = 1, numFulfilled = 0 },
|
||||
} },
|
||||
{ title = "Bars One", questID = 2, level = 10, objs = {
|
||||
{ type = "item", text = "Copper Bar: 0/4", numRequired = 4, numFulfilled = 0 },
|
||||
} },
|
||||
{ title = "Bars Two", questID = 3, level = 12, objs = {
|
||||
{ type = "item", text = "Copper Bar: 0/6", numRequired = 6, numFulfilled = 0 },
|
||||
} },
|
||||
}
|
||||
|
||||
C_QuestLog = {
|
||||
GetNumQuestLogEntries = function()
|
||||
local n = 0
|
||||
for _, e in ipairs(log) do if not e.isHeader then n = n + 1 end end
|
||||
return #log, n
|
||||
end,
|
||||
GetInfo = function(i) return log[i] end,
|
||||
GetQuestObjectives = function(id)
|
||||
for _, e in ipairs(log) do if e.questID == id then return e.objs end end
|
||||
end,
|
||||
}
|
||||
function ExpandQuestHeader() end
|
||||
function CollapseQuestHeader() end
|
||||
function GetQuestDifficultyColor() return { r = 0.1, g = 0.2, b = 0.3 } end
|
||||
|
||||
local outputs = { [100] = 1, [101] = 2, [102] = 3, [103] = 4 }
|
||||
C_TradeSkillUI = {
|
||||
GetRecipeSchematic = function(id) return { outputItemID = outputs[id] } end,
|
||||
}
|
||||
local names = { [1] = "Embossed Leather Gloves", [2] = "Copper Bar", [3] = "Embossed Leather Cloak" }
|
||||
local counts = { [1] = 0, [2] = 3, [3] = 0, [4] = 0 }
|
||||
local requested = {}
|
||||
C_Item = {
|
||||
GetItemNameByID = function(id) return names[id] end,
|
||||
GetItemCount = function(id) return counts[id] end,
|
||||
RequestLoadItemDataByID = function(id) requested[id] = true end,
|
||||
}
|
||||
|
||||
local queued = {}
|
||||
C_Timer = { After = function(_, fn) queued[#queued + 1] = fn end }
|
||||
local function flush() local q = queued; queued = {}; for _, fn in ipairs(q) do fn() end end
|
||||
|
||||
function hooksecurefunc(t, name, fn)
|
||||
local orig = t[name]
|
||||
t[name] = function(...) orig(...); fn(...) end
|
||||
end
|
||||
|
||||
local function region(extra)
|
||||
local r = { shown = true }
|
||||
function r:Show() self.shown = true end
|
||||
function r:Hide() self.shown = false end
|
||||
function r:SetShown(v) self.shown = v and true or false end
|
||||
function r:IsShown() return self.shown end
|
||||
function r:SetAllPoints() end
|
||||
function r:ClearAllPoints() end
|
||||
function r:SetPoint(...) self.point = { ... } end
|
||||
function r:SetColorTexture() end
|
||||
function r:SetText(t) self.text = t end
|
||||
function r:GetStringWidth() return self.textWidth or (#(self.text or "") * 6) end
|
||||
function r:SetTextColor(a, b, c) self.color = { a, b, c } end
|
||||
function r:SetWidth(w) self.width = w end
|
||||
function r:GetWidth() return self.width or 0 end
|
||||
for k, v in pairs(extra or {}) do r[k] = v end
|
||||
return r
|
||||
end
|
||||
|
||||
local tipLines, tipOwner = {}, nil
|
||||
GameTooltip = {
|
||||
IsOwned = function(_, f) return tipOwner == f end,
|
||||
SetOwner = function(_, f) tipOwner = f; tipLines = {} end,
|
||||
AddDoubleLine = function(_, l, r) tipLines[#tipLines + 1] = { l = l, r = r } end,
|
||||
Show = function() end,
|
||||
}
|
||||
|
||||
local handler
|
||||
CreateFrame = function()
|
||||
return { RegisterEvent = function() end, SetScript = function(_, _, fn) handler = fn end }
|
||||
end
|
||||
SlashCmdList = {}
|
||||
local printed = {}
|
||||
DEFAULT_CHAT_FRAME = { AddMessage = function(_, m) printed[#printed + 1] = m end }
|
||||
|
||||
local failures = 0
|
||||
local function check(cond, what)
|
||||
if not cond then failures = failures + 1 end
|
||||
print((cond and "ok " or "FAIL ") .. what)
|
||||
end
|
||||
|
||||
-- The mixin only appears when Blizzard's load-on-demand addon does.
|
||||
assert(loadfile(arg[1]))("QuestCraftHighlight", {})
|
||||
ProfessionsRecipeListRecipeMixin = {
|
||||
Init = function(row, node)
|
||||
row.Label:SetText(node:GetData().recipeInfo.name)
|
||||
row.Label:SetWidth(row:GetStringWidthForTest())
|
||||
end,
|
||||
OnEnter = function() end,
|
||||
}
|
||||
handler(nil, "ADDON_LOADED", "SomethingElse")
|
||||
local initBefore = ProfessionsRecipeListRecipeMixin.Init
|
||||
handler(nil, "ADDON_LOADED", "Blizzard_ProfessionsTemplates")
|
||||
check(ProfessionsRecipeListRecipeMixin.Init ~= initBefore, "hooks installed when Blizzard_ProfessionsTemplates loads")
|
||||
local initOnce = ProfessionsRecipeListRecipeMixin.Init
|
||||
handler(nil, "ADDON_LOADED", "Blizzard_ProfessionsTemplates")
|
||||
check(ProfessionsRecipeListRecipeMixin.Init == initOnce, "hooks are not installed twice")
|
||||
handler(nil, "PLAYER_ENTERING_WORLD")
|
||||
flush()
|
||||
|
||||
local function newRow()
|
||||
local row = region({ width = 270, visible = true })
|
||||
row.Label = region()
|
||||
row.Count = region({ shown = false })
|
||||
row.LockedIcon = region({ shown = false, width = 17 })
|
||||
row.SkillUps = region({ width = 26 })
|
||||
function row:CreateTexture() return region() end
|
||||
function row:CreateFontString() return region() end
|
||||
function row:IsVisible() return self.visible end
|
||||
function row:GetStringWidthForTest() return self.Label:GetStringWidth() end
|
||||
return row
|
||||
end
|
||||
|
||||
local function node(id, name) return { GetData = function() return { recipeInfo = { recipeID = id, name = name } } end } end
|
||||
local function init(row, id, name) ProfessionsRecipeListRecipeMixin.Init(row, node(id, name)) end
|
||||
|
||||
local row = newRow()
|
||||
init(row, 100, "Embossed Leather Gloves")
|
||||
check(row.qchTint and row.qchTint.shown, "needed recipe is tinted")
|
||||
check(row.qchText.text == "! 0 / 1", "shows have / need: " .. tostring(row.qchText.text))
|
||||
check(row.qchText.color[2] == 0.82, "unfinished count is gold")
|
||||
|
||||
ProfessionsRecipeListRecipeMixin.OnEnter(row)
|
||||
check(#tipLines == 1 and tipLines[1].l == "Quest: [18] Moonglow Vest" and tipLines[1].r == "0 / 1", "hover shows quest, level, count")
|
||||
check(tipOwner == row, "hover takes the tooltip when the row did not")
|
||||
|
||||
tipOwner = row.Label; tipLines = { { l = "Full Recipe Name" } }
|
||||
ProfessionsRecipeListRecipeMixin.OnEnter(row)
|
||||
check(#tipLines == 2 and tipLines[1].l == "Full Recipe Name", "keeps the truncated-name tooltip and appends")
|
||||
|
||||
counts[1] = 1
|
||||
handler(nil, "BAG_UPDATE_DELAYED")
|
||||
flush()
|
||||
check(row.qchText.text == "! 1 / 1" and row.qchText.color[2] == 1, "crafting one updates the row live, count turns green")
|
||||
check(row.qchTint.shown == false, "tint goes away once you have enough")
|
||||
|
||||
local bars = newRow()
|
||||
init(bars, 101, "Smelt Copper")
|
||||
check(bars.qchText and bars.qchText.text == "! 3 / 10", "matches output item, not recipe name, and sums quests: " .. tostring(bars.qchText and bars.qchText.text))
|
||||
ProfessionsRecipeListRecipeMixin.OnEnter(bars)
|
||||
check(#tipLines == 2 and tipLines[1].r == "3 / 4" and tipLines[2].r == "3 / 6", "tooltip lists each quest")
|
||||
|
||||
local other = newRow()
|
||||
init(other, 102, "Embossed Leather Cloak")
|
||||
check(other.qchTint == nil, "unrelated recipe is left untouched")
|
||||
|
||||
-- Pool reuse: a highlighted row scrolled onto an unrelated recipe.
|
||||
counts[1] = 0
|
||||
init(row, 102, "Embossed Leather Cloak")
|
||||
check(row.qchTint.shown == false and row.qchText.shown == false, "reused row drops its highlight")
|
||||
ProfessionsRecipeListRecipeMixin.OnEnter(row)
|
||||
tipLines = {}; ProfessionsRecipeListRecipeMixin.OnEnter(row)
|
||||
check(#tipLines == 0, "reused row adds no quest line on hover")
|
||||
|
||||
-- Label must not run under the count text.
|
||||
local long = newRow()
|
||||
names[1] = "Embossed Leather Gloves"
|
||||
long.Label.textWidth = 500
|
||||
init(long, 100, "Embossed Leather Gloves")
|
||||
local avail = 270 - (10 + 26 + long.qchText:GetStringWidth() + 8)
|
||||
check(long.Label.width == avail, "long name is shortened to clear the count: " .. tostring(long.Label.width) .. " vs " .. avail)
|
||||
|
||||
-- Output name not loaded yet.
|
||||
local uncached = newRow()
|
||||
log[#log + 1] = { title = "Mystery", questID = 4, level = 5, objs = {
|
||||
{ type = "item", text = "Late Item: 0/2", numRequired = 2, numFulfilled = 0 },
|
||||
} }
|
||||
handler(nil, "QUEST_ACCEPTED")
|
||||
flush()
|
||||
init(uncached, 103, "Some Recipe Name")
|
||||
check(requested[4] == true, "requests the name of an unloaded item")
|
||||
check(uncached.qchMatch == nil, "no false match while name is loading")
|
||||
names[4] = "Late Item"
|
||||
handler(nil, "ITEM_DATA_LOAD_RESULT", 4, true)
|
||||
flush()
|
||||
check(uncached.qchText and uncached.qchText.text == "! 0 / 2", "row updates when the name arrives")
|
||||
|
||||
local fallback = newRow()
|
||||
outputs[104] = 5; counts[5] = 0
|
||||
init(fallback, 104, "Embossed Leather Gloves")
|
||||
check(fallback.qchText and fallback.qchText.text == "! 0 / 1", "unloaded item falls back to the recipe name")
|
||||
|
||||
-- Quest gone: highlight disappears, name gets its width back.
|
||||
table.remove(log, 2)
|
||||
long.visible = true
|
||||
handler(nil, "QUEST_REMOVED")
|
||||
flush()
|
||||
check(long.qchMatch == nil and long.qchTint.shown == false, "finished quest removes the highlight")
|
||||
check(long.Label.width == 270 - 36, "name gets its width back: " .. tostring(long.Label.width))
|
||||
|
||||
-- Closed window: nothing to do for hidden rows.
|
||||
log[#log + 1] = { title = "Again", questID = 9, level = 18, objs = {
|
||||
{ type = "item", text = "Embossed Leather Gloves: 0/1", numRequired = 1, numFulfilled = 0 },
|
||||
} }
|
||||
long.visible = false
|
||||
handler(nil, "QUEST_ACCEPTED")
|
||||
flush()
|
||||
check(long.qchMatch == nil, "hidden rows are not touched")
|
||||
|
||||
printed = {}
|
||||
SlashCmdList.QUESTCRAFTHIGHLIGHT()
|
||||
check(#printed >= 2 and printed[1]:find("hooked=true", 1, true) ~= nil, "/qch prints state: " .. tostring(printed[1]))
|
||||
|
||||
print(failures == 0 and "ALL PASSED" or (failures .. " FAILED"))
|
||||
os.exit(failures == 0 and 0 or 1)
|
||||
263
tests/test_qit.lua
Normal file
263
tests/test_qit.lua
Normal file
|
|
@ -0,0 +1,263 @@
|
|||
-- Runs QuestItemTip.lua against a mock of the WoW API.
|
||||
-- arg[1] = addon file
|
||||
|
||||
local hideCollapsed -- true: collapsed headers hide their quests (legacy behaviour)
|
||||
local toggles = 0
|
||||
|
||||
local log = {}
|
||||
local function reset()
|
||||
toggles = 0
|
||||
log = {
|
||||
{ title = "Elwynn", isHeader = true, isCollapsed = false },
|
||||
{ title = "Linen Quest", questID = 10, level = 12, desc = "Peacebloom grows nearby.", objs = {
|
||||
{ type = "item", text = "Linen Cloth: 5/5", numRequired = 5, numFulfilled = 5, finished = true },
|
||||
{ type = "monster", text = "Kobold slain: 1/8", numRequired = 8, numFulfilled = 1 },
|
||||
} },
|
||||
{ title = "Second Linen Quest", questID = 11, level = 20, objs = {
|
||||
{ type = "item", text = "3/10 Linen Cloth (Optional)", numRequired = 10, numFulfilled = 3 },
|
||||
} },
|
||||
{ title = "Book Quest", questID = 12, level = 30, objs = {
|
||||
{ type = "item", text = "Advanced Armorsmithing: Volume II: 0/1", numRequired = 1, numFulfilled = 0 },
|
||||
} },
|
||||
{ title = "Westfall", isHeader = true, isCollapsed = true },
|
||||
{ title = "Collapsed Quest", questID = 20, level = 18, objText = "Bring the Hidden Parcel to Bob.", objs = {
|
||||
{ type = "item", text = "Red Bandana: 1/15", numRequired = 15, numFulfilled = 1 },
|
||||
} },
|
||||
{ title = "Hidden Quest", questID = 30, level = 1, isHidden = true, objs = {
|
||||
{ type = "item", text = "Secret Thing: 0/1", numRequired = 1, numFulfilled = 0 },
|
||||
} },
|
||||
}
|
||||
end
|
||||
|
||||
local function visible()
|
||||
local out, inCollapsed = {}, false
|
||||
for _, e in ipairs(log) do
|
||||
if e.isHeader then
|
||||
inCollapsed = e.isCollapsed
|
||||
out[#out + 1] = e
|
||||
elseif not (hideCollapsed and inCollapsed) then
|
||||
out[#out + 1] = e
|
||||
end
|
||||
end
|
||||
return out
|
||||
end
|
||||
|
||||
C_QuestLog = {
|
||||
GetNumQuestLogEntries = function()
|
||||
local n = 0
|
||||
for _, e in ipairs(log) do if not e.isHeader then n = n + 1 end end
|
||||
return #visible(), n
|
||||
end,
|
||||
GetInfo = function(i) return visible()[i] end,
|
||||
GetQuestObjectives = function(id)
|
||||
for _, e in ipairs(log) do if e.questID == id then return e.objs end end
|
||||
end,
|
||||
}
|
||||
local selectedQuest, abandonQuest = 77, nil
|
||||
local abandonItems = { [12] = { 500 } }
|
||||
local completed, popup = {}, false
|
||||
C_QuestLog.GetSelectedQuest = function() return selectedQuest end
|
||||
C_QuestLog.SetSelectedQuest = function(id) selectedQuest = id end
|
||||
C_QuestLog.SetAbandonQuest = function() abandonQuest = selectedQuest end
|
||||
C_QuestLog.GetAbandonQuestItems = function() return abandonItems[abandonQuest] or {} end
|
||||
C_QuestLog.IsOnQuest = function(id)
|
||||
for _, e in ipairs(log) do if e.questID == id then return true end end
|
||||
return false
|
||||
end
|
||||
C_QuestLog.IsQuestFlaggedCompleted = function(id) return completed[id] == true end
|
||||
function StaticPopup_Visible() return popup end
|
||||
function GetQuestLogQuestText(i)
|
||||
local e = visible()[i]
|
||||
if e.noText then return "", "" end
|
||||
return e.desc or "Some story.", e.objText or "Do the thing."
|
||||
end
|
||||
ITEM_STARTS_QUEST = "This Item Begins a Quest"
|
||||
function ExpandQuestHeader(i) toggles = toggles + 1; visible()[i].isCollapsed = false end
|
||||
function CollapseQuestHeader(i) toggles = toggles + 1; visible()[i].isCollapsed = true end
|
||||
function GetQuestDifficultyColor() return { r = 0.1, g = 0.2, b = 0.3 } end
|
||||
|
||||
local names = { [1] = "Linen Cloth", [2] = "Red Bandana", [3] = "Secret Thing", [4] = "Peacebloom", [5] = "Advanced Armorsmithing: Volume II", [500] = "Sealed Letter", [501] = "Old Quest Thing", [502] = "Mystery Thing", [503] = "Odd Starter", [504] = "Abandoned Thing", [506] = "Vial of Purest Water", [507] = "Hidden Parcel" }
|
||||
local bagCount = { [1] = 7, [2] = 2, [3] = 1, [4] = 9, [5] = 0, [500] = 1, [501] = 1, [502] = 1, [503] = 1, [504] = 1, [505] = 0, [506] = 1, [507] = 1 }
|
||||
local bankCount = { [1] = 0, [2] = 3 }
|
||||
C_Item = {
|
||||
GetItemNameByID = function(id) return names[id] end,
|
||||
GetItemInfoInstant = function(id) local c = (id >= 501 and id <= 507) and 12 or 7; return id, "", "", "", 0, c end,
|
||||
GetItemInfo = function() return nil end,
|
||||
GetItemCount = function(id, incBank) return bagCount[id] + (incBank and (bankCount[id] or 0) or 0) end,
|
||||
}
|
||||
|
||||
local lines = {}
|
||||
GameTooltip = {
|
||||
AddDoubleLine = function(_, l, r, _, _, _, rr, rg) lines[#lines + 1] = { l = l, r = r, green = (rr == 0.25 and rg == 1) } end,
|
||||
AddLine = function(_, l) lines[#lines + 1] = { l = l } end,
|
||||
Show = function() end,
|
||||
GetItem = function() return nil end,
|
||||
}
|
||||
ItemRefTooltip = GameTooltip
|
||||
Enum = { TooltipDataType = { Item = 0 } }
|
||||
local postCall
|
||||
TooltipDataProcessor = { AddTooltipPostCall = function(_, fn) postCall = fn end }
|
||||
local handler
|
||||
local registered = {}
|
||||
CreateFrame = function()
|
||||
return {
|
||||
RegisterEvent = function(_, e) registered[e] = true end,
|
||||
SetScript = function(_, _, fn) handler = fn end,
|
||||
}
|
||||
end
|
||||
SlashCmdList = {}
|
||||
local printed = {}
|
||||
DEFAULT_CHAT_FRAME = { AddMessage = function(_, m) printed[#printed + 1] = m end }
|
||||
|
||||
local failures = 0
|
||||
local function check(cond, what)
|
||||
if not cond then failures = failures + 1 end
|
||||
print((cond and "ok " or "FAIL ") .. what)
|
||||
end
|
||||
|
||||
local function tip(id)
|
||||
lines = {}
|
||||
postCall(GameTooltip, { id = id })
|
||||
return lines
|
||||
end
|
||||
|
||||
for _, mode in ipairs({ false, true }) do
|
||||
hideCollapsed = mode
|
||||
print("--- collapsed headers hide quests: " .. tostring(mode))
|
||||
reset()
|
||||
QuestItemTipDB = nil
|
||||
assert(loadfile(arg[1]))("QuestItemTip", {})
|
||||
handler(nil, "ADDON_LOADED", "QuestItemTip")
|
||||
handler(nil, "PLAYER_ENTERING_WORLD")
|
||||
|
||||
local l = tip(1)
|
||||
check(#l == 2, "item needed by two quests gets two lines")
|
||||
check(l[1].l == "Quest: [12] Linen Quest" and l[1].r == "7 / 5", "have 7, need 5: " .. tostring(l[1].l) .. " | " .. tostring(l[1].r))
|
||||
check(l[1].green == true, "met requirement is green")
|
||||
check(l[2].r == "7 / 10" and l[2].green == false, "alternate objective format, unmet: " .. tostring(l[2].r))
|
||||
|
||||
l = tip(2)
|
||||
check(#l == 1 and l[1].l == "Quest: [18] Collapsed Quest", "quest under a collapsed header is found")
|
||||
check(l[1] and l[1].r == "2 / 15 (+3 bank)", "bank shown apart: " .. tostring(l[1] and l[1].r))
|
||||
|
||||
check(log[5].isCollapsed == true, "collapsed header is restored")
|
||||
check(toggles == (mode and 2 or 0), "headers toggled only when needed: " .. toggles)
|
||||
|
||||
check(#tip(3) == 0, "hidden quest ignored")
|
||||
check(#tip(4) == 0, "non-quest item adds nothing")
|
||||
l = tip(5)
|
||||
check(#l == 1 and l[1].r == "0 / 1", "item name containing a colon")
|
||||
|
||||
local before = toggles
|
||||
handler(nil, "QUEST_LOG_UPDATE")
|
||||
tip(1); tip(2)
|
||||
check(toggles == before, "header-toggle QUEST_LOG_UPDATE causes no rescan")
|
||||
|
||||
table.insert(log[2].objs, { type = "item", text = "Peacebloom: 0/4", numRequired = 4, numFulfilled = 0 })
|
||||
handler(nil, "QUEST_ACCEPTED")
|
||||
l = tip(4)
|
||||
check(#l == 1 and l[1].r == "9 / 4", "new objective picked up after QUEST_ACCEPTED")
|
||||
|
||||
log[3] = { title = "Filler", questID = 40, level = 2, objs = {} }
|
||||
log[#log + 1] = { title = "Another", questID = 41, level = 2, objs = {} }
|
||||
handler(nil, "QUEST_LOG_UPDATE")
|
||||
check(#tip(1) == 1, "quest count change rebuilds on QUEST_LOG_UPDATE")
|
||||
|
||||
|
||||
-- === leftover and provided items ===
|
||||
reset()
|
||||
assert(loadfile(arg[1]))("QuestItemTip", {})
|
||||
handler(nil, "ADDON_LOADED", "QuestItemTip")
|
||||
handler(nil, "PLAYER_ENTERING_WORLD")
|
||||
selectedQuest = 77
|
||||
|
||||
l = tip(500)
|
||||
check(#l == 1 and l[1].l == "Quest: [30] Book Quest" and l[1].r == nil, "item a quest handed you names it: " .. tostring(l[1] and l[1].l))
|
||||
check(selectedQuest == 77, "selected quest is restored")
|
||||
|
||||
log[#log + 1] = { title = "Done Soon", questID = 50, level = 9, objs = {
|
||||
{ type = "item", text = "Old Quest Thing: 1/1", numRequired = 1, numFulfilled = 1 },
|
||||
} }
|
||||
log[#log + 1] = { title = "Drop Soon", questID = 51, level = 11, objs = {
|
||||
{ type = "item", text = "Abandoned Thing: 0/2", numRequired = 2, numFulfilled = 0 },
|
||||
} }
|
||||
handler(nil, "QUEST_ACCEPTED")
|
||||
handler(nil, "QUEST_LOG_UPDATE")
|
||||
check(QuestItemTipDB["old quest thing"] and QuestItemTipDB["old quest thing"].title == "Done Soon", "quest is recorded without hovering anything")
|
||||
local n = #log
|
||||
table.remove(log, n); table.remove(log, n - 1)
|
||||
completed[50] = true
|
||||
handler(nil, "QUEST_TURNED_IN")
|
||||
handler(nil, "QUEST_LOG_UPDATE")
|
||||
|
||||
l = tip(501)
|
||||
check(#l == 1 and l[1].l == "Quest done: [9] Done Soon" and l[1].r == "can delete", "finished quest: " .. tostring(l[1] and l[1].l))
|
||||
l = tip(504)
|
||||
check(#l == 1 and l[1].l == "Quest dropped: [11] Drop Soon" and l[1].r == "can delete", "dropped quest: " .. tostring(l[1] and l[1].l))
|
||||
|
||||
check(#tip(505) == 0, "not owned: no leftover warning")
|
||||
l = tip(502)
|
||||
check(#l == 1 and l[1].l == "Quest item: no quest in your log uses it", "unknown quest item gets the soft note, not can-delete")
|
||||
lines = {}
|
||||
postCall(GameTooltip, { id = 503, lines = { { leftText = "Odd Starter" }, { leftText = "This Item Begins a Quest" } } })
|
||||
check(#lines == 0, "quest-starting item is left alone")
|
||||
check(#tip(4) == 0 or tip(4)[1].l:find("Quest item", 1, true) == nil, "ordinary item never gets the quest-item note")
|
||||
|
||||
-- Delivery quest: no objective, the item is only named in the quest text.
|
||||
l = tip(507)
|
||||
check(#l == 1 and l[1].l == "Quest: [18] Collapsed Quest", "quest text under a collapsed header: " .. tostring(l[1] and l[1].l))
|
||||
check(log[5].isCollapsed == true, "header closed again after reading text")
|
||||
|
||||
log[#log + 1] = { title = "Delivery Quest", questID = 52, level = 23, objs = {}, objText = "Bring the Vial of Purest Water to Norric Lochthane in Loch Modan." }
|
||||
QuestItemTipDB[506] = { questID = 99, title = "Earlier Step", level = 22 }
|
||||
handler(nil, "QUEST_ACCEPTED")
|
||||
handler(nil, "QUEST_LOG_UPDATE")
|
||||
l = tip(506)
|
||||
check(#l == 1 and l[1].l == "Quest: [23] Delivery Quest" and l[1].r == nil, "delivery item names its quest: " .. tostring(l[1] and l[1].l))
|
||||
check(QuestItemTipDB[506].questID == 52, "delivery item is remembered, replacing the earlier step")
|
||||
|
||||
table.remove(log)
|
||||
handler(nil, "QUEST_REMOVED")
|
||||
handler(nil, "QUEST_LOG_UPDATE")
|
||||
l = tip(506)
|
||||
check(#l == 1 and l[1].l == "Quest dropped: [23] Delivery Quest" and l[1].r == "can delete", "delivery item after the quest ends: " .. tostring(l[1] and l[1].l))
|
||||
|
||||
-- Objective read before the item's name has loaded.
|
||||
log[#log + 1] = { title = "Waterskin", questID = 53, level = 23, objs = {
|
||||
{ type = "item", text = " : 0/1", numRequired = 1, numFulfilled = 0 },
|
||||
} }
|
||||
handler(nil, "QUEST_ACCEPTED")
|
||||
handler(nil, "QUEST_LOG_UPDATE")
|
||||
check(QuestItemTipDB[" "] == nil, "blank objective name is not recorded")
|
||||
log[#log].objs[1].text = "Peacebloom: 0/1"
|
||||
handler(nil, "QUEST_LOG_UPDATE")
|
||||
l = tip(4)
|
||||
check(#l == 1 and l[1].r == "9 / 1", "objective is read once the name loads: " .. tostring(l[1] and l[1].r))
|
||||
table.remove(log)
|
||||
handler(nil, "QUEST_REMOVED")
|
||||
handler(nil, "QUEST_LOG_UPDATE")
|
||||
|
||||
-- Still on the quest, but the objective no longer lists the item.
|
||||
QuestItemTipDB["peacebloom"] = { questID = 12, title = "Book Quest", level = 30 }
|
||||
l = tip(4)
|
||||
check(#l == 1 and l[1].l == "Quest: [30] Book Quest" and l[1].r == nil, "still-active recorded quest is not a delete warning")
|
||||
QuestItemTipDB["peacebloom"] = nil
|
||||
|
||||
-- Mid-abandon: do not disturb Blizzard's popup.
|
||||
popup = true
|
||||
selectedQuest = 88
|
||||
local abandonBefore = abandonQuest
|
||||
handler(nil, "QUEST_ACCEPTED")
|
||||
handler(nil, "QUEST_LOG_UPDATE")
|
||||
check(abandonQuest == abandonBefore and selectedQuest == 88, "abandon popup is left alone")
|
||||
l = tip(500)
|
||||
check(#l == 1 and l[1].l == "Quest: [30] Book Quest", "provided items are kept meanwhile")
|
||||
popup = false
|
||||
|
||||
printed = {}
|
||||
SlashCmdList.QUESTITEMTIP()
|
||||
check(#printed > 0, "/qit prints the index")
|
||||
end
|
||||
|
||||
print(failures == 0 and "ALL PASSED" or (failures .. " FAILED"))
|
||||
os.exit(failures == 0 and 0 or 1)
|
||||
188
tests/test_vf.lua
Normal file
188
tests/test_vf.lua
Normal file
|
|
@ -0,0 +1,188 @@
|
|||
-- Runs VendorFlag.lua against a mock of the WoW API.
|
||||
-- arg[1] = addon file
|
||||
|
||||
local now = 1000000
|
||||
function time() return now end
|
||||
|
||||
function hooksecurefunc(t, name, fn)
|
||||
local orig = t[name]
|
||||
t[name] = function(...) orig(...); fn(...) end
|
||||
end
|
||||
|
||||
AUCTIONATOR_L_CONFIRM_POST_BELOW_VENDOR = "vendor warning"
|
||||
AuctionatorSaleItemMixin = { GetConfirmationMessage = function(self) return self.msg end }
|
||||
AuctionatorGroupsViewItemMixin = { SetItemInfo = function(self, info) self.itemInfo = info end }
|
||||
|
||||
local bags = {}
|
||||
C_Container = { GetContainerItemLink = function(bag, slot) return bags[bag .. ":" .. slot] end }
|
||||
|
||||
local function region()
|
||||
local r = { shown = false }
|
||||
function r:Show() self.shown = true end
|
||||
function r:Hide() self.shown = false end
|
||||
function r:SetAllPoints() end
|
||||
function r:SetPoint() end
|
||||
function r:SetColorTexture() end
|
||||
function r:SetTextColor() end
|
||||
function r:SetText(t) self.text = t end
|
||||
return r
|
||||
end
|
||||
|
||||
local function button(bag, slot)
|
||||
local b = {}
|
||||
function b:GetBagID() return bag end
|
||||
function b:GetID() return slot end
|
||||
function b:CreateTexture() return region() end
|
||||
function b:CreateFontString() return region() end
|
||||
return b
|
||||
end
|
||||
|
||||
local function bagFrame(buttons, shown)
|
||||
local f = { shown = shown }
|
||||
function f:IsShown() return self.shown end
|
||||
function f:EnumerateValidItems() return ipairs(buttons) end
|
||||
function f:UpdateItems() end
|
||||
return f
|
||||
end
|
||||
|
||||
local b1, b2, b3 = button(0, 1), button(0, 2), button(0, 3)
|
||||
ContainerFrame1 = bagFrame({ b1, b2 }, true)
|
||||
ContainerFrameCombinedBags = bagFrame({ b3 }, false)
|
||||
|
||||
local LINK_A = "|cffffffff|Hitem:2589::::::::70:::::|h[Linen Cloth]|h|r"
|
||||
local LINK_BEAR = "|cff1eff00|Hitem:15000::::::-19:123:70:::::|h[Sword of the Bear]|h|r"
|
||||
local LINK_EAGLE = "|cff1eff00|Hitem:15000::::::-25:456:70:::::|h[Sword of the Eagle]|h|r"
|
||||
local LINK_OTHER = "|cffffffff|Hitem:4306::::::::70:::::|h[Silk Cloth]|h|r"
|
||||
|
||||
GameTooltip = {
|
||||
AddLine = function(self, l) self.line = l end,
|
||||
Show = function() end,
|
||||
GetItem = function(self) return "x", self.link end,
|
||||
}
|
||||
ItemRefTooltip = {}
|
||||
Enum = { TooltipDataType = { Item = 0 } }
|
||||
local postCall
|
||||
TooltipDataProcessor = { AddTooltipPostCall = function(_, fn) postCall = fn end }
|
||||
local tick
|
||||
C_Timer = { NewTicker = function(_, fn) tick = fn end }
|
||||
local handler
|
||||
CreateFrame = function()
|
||||
return { RegisterEvent = function() end, SetScript = function(_, _, fn) handler = fn end }
|
||||
end
|
||||
SlashCmdList = {}
|
||||
local printed = {}
|
||||
DEFAULT_CHAT_FRAME = { AddMessage = function(_, m) printed[#printed + 1] = m end }
|
||||
|
||||
local failures = 0
|
||||
local function check(cond, what)
|
||||
if not cond then failures = failures + 1 end
|
||||
print((cond and "ok " or "FAIL ") .. what)
|
||||
end
|
||||
|
||||
assert(loadfile(arg[1]))("VendorFlag", {})
|
||||
local warn = AuctionatorSaleItemMixin.GetConfirmationMessage
|
||||
handler(nil, "ADDON_LOADED", "Auctionator")
|
||||
check(VendorFlagDB == nil, "ignores other addons loading")
|
||||
handler(nil, "ADDON_LOADED", "VendorFlag")
|
||||
handler(nil, "PLAYER_LOGIN")
|
||||
|
||||
bags["0:1"] = LINK_A
|
||||
bags["0:2"] = LINK_OTHER
|
||||
bags["0:3"] = LINK_A
|
||||
|
||||
check(warn({ msg = "low price", itemInfo = { itemLink = LINK_A } }) == "low price", "other warnings pass through")
|
||||
check(next(VendorFlagDB) == nil, "other warnings do not flag")
|
||||
check(warn({ msg = nil, itemInfo = { itemLink = LINK_A } }) == nil, "no warning passes through nil")
|
||||
check(next(VendorFlagDB) == nil, "no warning does not flag")
|
||||
|
||||
check(warn({ msg = "vendor warning", itemInfo = { itemLink = LINK_A } }) == "vendor warning", "vendor warning passes through unchanged")
|
||||
check(b1.vfTint and b1.vfTint.shown and b1.vfText.text == "10m", "open bag is marked immediately: " .. tostring(b1.vfText and b1.vfText.text))
|
||||
check(b2.vfTint == nil, "other items stay unmarked")
|
||||
check(b3.vfTint == nil, "closed bag is not touched yet")
|
||||
|
||||
ContainerFrameCombinedBags.shown = true
|
||||
ContainerFrameCombinedBags:UpdateItems()
|
||||
check(b3.vfTint and b3.vfTint.shown, "bag gets marked when it opens")
|
||||
|
||||
GameTooltip.link = LINK_A
|
||||
postCall(GameTooltip)
|
||||
check(GameTooltip.line == "Vendor beats auction (10m left)", "tooltip: " .. tostring(GameTooltip.line))
|
||||
GameTooltip.line = nil; GameTooltip.link = LINK_OTHER
|
||||
postCall(GameTooltip)
|
||||
check(GameTooltip.line == nil, "tooltip silent on unflagged item")
|
||||
|
||||
now = now + 245
|
||||
tick()
|
||||
check(b1.vfText.text == "6m", "countdown ticks down: " .. tostring(b1.vfText.text))
|
||||
|
||||
-- Sold to the vendor.
|
||||
bags["0:1"] = nil
|
||||
handler(nil, "BAG_UPDATE_DELAYED")
|
||||
check(b1.vfTint.shown == false and b1.vfText.shown == false, "sold item loses its mark")
|
||||
|
||||
-- Re-flagging restarts the timer.
|
||||
bags["0:1"] = LINK_A
|
||||
warn({ msg = "vendor warning", itemInfo = { itemLink = LINK_A } })
|
||||
check(b1.vfText.text == "10m", "warning again restarts the timer")
|
||||
|
||||
now = now + 601
|
||||
tick()
|
||||
check(b1.vfTint.shown == false, "mark expires after 10 minutes")
|
||||
check(next(VendorFlagDB) == nil, "expired flag is cleared")
|
||||
|
||||
-- Auctionator's selling list.
|
||||
local ah, ahOther = button(9, 1), button(9, 2)
|
||||
function ah:IsVisible() return self.visible end
|
||||
function ahOther:IsVisible() return true end
|
||||
ah.visible = true
|
||||
AuctionatorGroupsViewItemMixin.SetItemInfo(ah, { itemLink = LINK_A })
|
||||
AuctionatorGroupsViewItemMixin.SetItemInfo(ahOther, { itemLink = LINK_EAGLE })
|
||||
check(ah.vfTint == nil, "selling list starts unmarked")
|
||||
|
||||
warn({ msg = "vendor warning", itemInfo = { itemLink = LINK_A } })
|
||||
check(ah.vfTint and ah.vfTint.shown and ah.vfText.text == "10m", "selling list is marked as soon as the warning appears")
|
||||
check(ahOther.vfTint == nil, "other selling list items stay unmarked")
|
||||
|
||||
now = now + 245
|
||||
tick()
|
||||
check(ah.vfText.text == "6m", "selling list counts down: " .. tostring(ah.vfText.text))
|
||||
|
||||
ah.visible = false
|
||||
now = now + 30
|
||||
tick()
|
||||
check(ah.vfText.text == "6m", "hidden selling list is left alone")
|
||||
ah.visible = true
|
||||
|
||||
-- A pooled button is reused for another item, then for an empty slot.
|
||||
AuctionatorGroupsViewItemMixin.SetItemInfo(ah, { itemLink = LINK_EAGLE })
|
||||
check(ah.vfTint.shown == false, "reused button drops the mark")
|
||||
AuctionatorGroupsViewItemMixin.SetItemInfo(ah, { itemLink = LINK_A })
|
||||
check(ah.vfTint.shown == true, "selling list refresh keeps the mark")
|
||||
AuctionatorGroupsViewItemMixin.SetItemInfo(ah, nil)
|
||||
check(ah.vfTint.shown == false, "empty button has no mark")
|
||||
AuctionatorGroupsViewItemMixin.SetItemInfo(ah, { itemLink = LINK_A })
|
||||
now = now + 601
|
||||
tick()
|
||||
check(ah.vfTint.shown == false, "selling list mark expires")
|
||||
|
||||
-- Same item ID, different suffix.
|
||||
bags["0:1"] = LINK_BEAR
|
||||
bags["0:2"] = LINK_EAGLE
|
||||
warn({ msg = "vendor warning", itemInfo = { itemLink = LINK_BEAR } })
|
||||
check(b1.vfTint.shown == true, "flagged suffix is marked")
|
||||
check(b2.vfTint == nil or b2.vfTint.shown == false, "other suffix of the same item is not")
|
||||
|
||||
-- A reload keeps flags: the file runs again with the saved table.
|
||||
AuctionatorSaleItemMixin = { GetConfirmationMessage = function(self) return self.msg end }
|
||||
assert(loadfile(arg[1]))("VendorFlag", {})
|
||||
handler(nil, "ADDON_LOADED", "VendorFlag")
|
||||
handler(nil, "PLAYER_LOGIN")
|
||||
GameTooltip.line = nil; GameTooltip.link = LINK_BEAR
|
||||
postCall(GameTooltip)
|
||||
check(GameTooltip.line ~= nil, "flag survives a reload")
|
||||
|
||||
SlashCmdList.VENDORFLAG()
|
||||
check(#printed == 1 and printed[1]:find("15000:-19", 1, true) ~= nil, "/vf lists the flag: " .. tostring(printed[1]))
|
||||
|
||||
print(failures == 0 and "ALL PASSED" or (failures .. " FAILED"))
|
||||
os.exit(failures == 0 and 0 or 1)
|
||||
Loading…
Add table
Add a link
Reference in a new issue