Refactoring select API functions based on game version (retail/classic)

This commit is contained in:
SabinDeus 2022-09-11 16:29:21 -04:00
parent a78b31dba9
commit 4ce1a4be30
3 changed files with 125 additions and 29 deletions

141
TurnIn.lua Normal file → Executable file
View File

@ -8,6 +8,16 @@
Thanks to Arcanemagus of Hyjal for extra bug fixes and coding input Thanks to Arcanemagus of Hyjal for extra bug fixes and coding input
]] ]]
-- WOW Version detection
local function TI_IsRetail()
if WOW_PROJECT_ID == WOW_PROJECT_MAINLINE then
return true;
else
return false;
end
end
TI_VersionString = "2.0"; TI_VersionString = "2.0";
local TI_slashtable; local TI_slashtable;
TI_gossipclosed = false; TI_gossipclosed = false;
@ -35,18 +45,7 @@ local TI_GossipDefaults = {
banker = "Bank" banker = "Bank"
}; };
local TI_FunctionList = { TI_FunctionList = {};
g = {
availquest = C_GossipInfo.SelectActiveQuest,
activequest = C_GossipInfo.SelectAvailableQuest,
default = C_GossipInfo.SelectOption
},
q = {
availquest = SelectAvailableQuest,
activequest = SelectActiveQuest
}
};
local TI_DefaultStatus = { local TI_DefaultStatus = {
state = false, state = false,
@ -394,20 +393,19 @@ function TI_HandleGossipWindow(gorq)
local ActiveQuests; local ActiveQuests;
local GossipOptions; local GossipOptions;
if(gorq == "g") then if(gorq == "g") then
AvailableQuests = TI_TabulateGossipQuestUIInfo(C_GossipInfo.GetAvailableQuests()); AvailableQuests = TI_FunctionList.g.tabulateAvailable(TI_FunctionList.g.getavailquests());
ActiveQuests = TI_TabulateGossipQuestUIInfo(C_GossipInfo.GetActiveQuests()); ActiveQuests = TI_FunctionList.g.tabulateActive(TI_FunctionList.g.getactivequests());
GossipOptions = TI_TabulateGossipUIInfo(C_GossipInfo.GetOptions()); GossipOptions = TI_FunctionList.g.tabulateOptions(TI_FunctionList.g.getoptions());
SAcQ = C_GossipInfo.SelectActiveQuest; SAcQ = TI_FunctionList.g.activequest;
SAvQ = C_GossipInfo.SelectAvailableQuest; SAvQ = TI_FunctionList.g.availquest;
elseif(gorq == "q") then elseif(gorq == "q") then
AvailableQuests = TI_GetQuests("Available"); AvailableQuests = TI_GetQuests("Available");
ActiveQuests = TI_GetQuests("Active"); ActiveQuests = TI_GetQuests("Active");
GossipOptions = {}; GossipOptions = {};
SAcQ=SelectActiveQuest; SAcQ=TI_FunctionList.q.activequest;
SAvQ=SelectAvailableQuest; SAvQ=TI_FunctionList.q.availquest;
end end
local ListEntry = {}; local ListEntry = {};
for i,v in ipairs(AvailableQuests) do for i,v in ipairs(AvailableQuests) do
local x={}; local x={};
@ -507,7 +505,7 @@ function TI_HandleGossipWindow(gorq)
for i2,v2 in ipairs(GossipOptions) do for i2,v2 in ipairs(GossipOptions) do
if (v2.name == current.name) then if (v2.name == current.name) then
TI_debug(i1.."-Gossip Match Found: "..current.name..", "..current.type); TI_debug(i1.."-Gossip Match Found: "..current.name..", "..current.type);
C_GossipInfo.SelectOption(i2); TI_FunctionList.g.default(i2);
return; return;
end end
end end
@ -551,7 +549,7 @@ function TI_HandleGossipWindow(gorq)
for j,val in ipairs(GossipOptions) do for j,val in ipairs(GossipOptions) do
if(val.type == current.type) then if(val.type == current.type) then
TI_ResetPointers(); TI_ResetPointers();
C_GossipInfo.SelectOption(j); TI_FunctionList.g.default(j);
return; return;
end end
end end
@ -624,7 +622,7 @@ function TI_StripDescriptors(...)
return x; return x;
end end
function TI_TabulateGossipOptions(...) function TI_TabulateGossipOptions_Classic(...)
local x = {}; local x = {};
local arg = {...}; local arg = {...};
for i=1, #arg, 2 do for i=1, #arg, 2 do
@ -636,7 +634,7 @@ function TI_TabulateGossipOptions(...)
return x; return x;
end end
function TI_TabulateGossipQuestUIInfo(gquis) function TI_TabulateGossipQuestUIInfo_Retail(gquis)
local x = {}; local x = {};
for i,gqui in ipairs(gquis) do for i,gqui in ipairs(gquis) do
@ -653,7 +651,7 @@ function TI_TabulateGossipQuestUIInfo(gquis)
return x; return x;
end end
function TI_TabulateGossipUIInfo(guis) function TI_TabulateGossipUIInfo_Retail(guis)
local x = {}; local x = {};
for i,gui in ipairs(guis) do for i,gui in ipairs(guis) do
@ -668,6 +666,97 @@ function TI_TabulateGossipUIInfo(guis)
return x; return x;
end end
function TI_TabulateGossipAvailableQuests_Classic(...)
local x = {};
for i=1, select("#", ...), 7 do
local temp = {};
temp.name = select(i, ...);
local isTrivial = select(i+2, ...);
local isDaily = select(i+3, ...);
local isRepeatable = select(i+4, ...);
local isLegendary = select(i+5, ...);
local isIgnored = select(i+6, ...);
if ( isDaily ) then
temp.icon = "Interface\\GossipFrame\\DailyQuestIcon";
elseif ( isRepeatable ) then
temp.icon = "Interface\\GossipFrame\\DailyActiveQuestIcon";
elseif ( isLegendary ) then
temp.icon = "Interface\\GossipFrame\\AvailableLegendaryQuestIcon";
else
temp.icon = "Interface\\GossipFrame\\AvailableQuestIcon";
end
table.insert(x, temp);
end
return x;
end
function TI_TabulateGossipActiveQuests_Classic(...)
local x = {};
for i=1, select("#", ...), 6 do
local temp = {};
temp.name = select(i, ...);
local isComplete = select(i+3, ...);
temp.isComplete = isComplete;
local isLegendary = select(i+4, ...);
if(isComplete) then
if(isLegendary) then
temp.icon = "Interface\\GossipFrame\\ActiveLegendaryQuestIcon";
else
temp.icon = "Interface\\GossipFrame\\ActiveQuestIcon";
end
else
temp.icon = "Interface\\GossipFrame\\IncompleteQuestIcon";
end
table.insert(x, temp);
end
return x;
end
-- set up functions by release type
if (TI_IsRetail()) then
TI_FunctionList = {
g = {
availquest = C_GossipInfo.SelectAvailableQuest,
activequest = C_GossipInfo.SelectActiveQuest,
default = C_GossipInfo.SelectOption,
getavailquests = C_GossipInfo.GetAvailableQuests,
getactivequests = C_GossipInfo.GetActiveQuests,
getoptions = C_GossipInfo.GetOptions,
tabulateAvailable = TI_TabulateGossipQuestUIInfo_Retail,
tabulateActive = TI_TabulateGossipQuestUIInfo_Retail,
tabulateOptions = TI_TabulateGossipUIInfo_Retail,
},
q = {
activequest = C_GossipInfo.SelectActiveQuest,
availquest = C_GossipInfo.SelectAvailableQuest,
}
};
else
TI_FunctionList = {
g = {
availquest = SelectGossipAvailableQuest,
activequest = SelectGossipActiveQuest,
default = SelectGossipOption,
getavailquests = GetGossipAvailableQuests,
getactivequests = GetGossipActiveQuests,
getoptions = GetGossipOptions,
tabulateAvailable = TI_TabulateGossipAvailableQuests_Classic,
tabulateActive = TI_TabulateGossipActiveQuests_Classic,
tabulateOptions = TI_TabulateGossipOptions_Classic,
},
q = {
activequest = SelectActiveQuest,
availquest = SelectAvailableQuest,
}
};
end
--[[this function stolen from WhisperCast by Sarris, whom I love dearly for his contribution to Paladins everywhere. --[[this function stolen from WhisperCast by Sarris, whom I love dearly for his contribution to Paladins everywhere.
]] ]]

6
TurnIn.toc Normal file → Executable file
View File

@ -1,7 +1,7 @@
## Interface: 90105 ## Interface: 90207
## X-Compatible-With: 90105 ## X-Compatible-With: 90207
## Title: Turn In ## Title: Turn In
## Notes: Automates the selection of quest and gossip options. ## Notes: Automates the selection of quest and gossip options.
## SavedVariables: TI_status, TI_NPCDB, TI_NPCIndex ## SavedVariables: TI_status, TI_NPCDB, TI_NPCIndex
## Version: 2.1 ## Version: 2.2
TurnIn.xml TurnIn.xml

7
TurnIn_Wrath.toc Executable file
View File

@ -0,0 +1,7 @@
## Interface: 30400
## X-Compatible-With: 30400
## Title: Turn In
## Notes: Automates the selection of quest and gossip options.
## SavedVariables: TI_status, TI_NPCDB, TI_NPCIndex
## Version: 2.2
TurnIn.xml