v9.7.2: Ebonhold Database integration and core logic refinements
This commit is contained in:
@@ -0,0 +1,156 @@
|
||||
---@type QuestieJourney
|
||||
local QuestieJourney = QuestieLoader:CreateModule("QuestieJourney")
|
||||
local _QuestieJourney = QuestieJourney.private
|
||||
_QuestieJourney.myJourney = {}
|
||||
_QuestieJourney.notePopup = nil
|
||||
|
||||
---@type QuestieJourneyUtils
|
||||
local QuestieJourneyUtils = QuestieLoader:ImportModule("QuestieJourneyUtils")
|
||||
---@type QuestieDB
|
||||
local QuestieDB = QuestieLoader:ImportModule("QuestieDB")
|
||||
---@type l10n
|
||||
local l10n = QuestieLoader:ImportModule("l10n")
|
||||
|
||||
--- COMPATIBILITY ---
|
||||
local CALENDAR_WEEKDAY_NAMES = QuestieCompat.CALENDAR_WEEKDAY_NAMES
|
||||
local CALENDAR_FULLDATE_MONTH_NAMES = QuestieCompat.CALENDAR_FULLDATE_MONTH_NAMES
|
||||
|
||||
local AceGUI = LibStub("AceGUI-3.0");
|
||||
local journeyTreeFrame
|
||||
|
||||
-- manage the journey tree
|
||||
function _QuestieJourney.myJourney:ManageTree(container)
|
||||
if not journeyTreeFrame then
|
||||
journeyTreeFrame = AceGUI:Create("TreeGroup");
|
||||
journeyTreeFrame:SetFullWidth(true);
|
||||
journeyTreeFrame:SetFullHeight(true);
|
||||
|
||||
journeyTreeFrame.treeframe:SetWidth(220);
|
||||
|
||||
local journeyTree = _QuestieJourney:GetHistory();
|
||||
journeyTreeFrame:SetTree(journeyTree);
|
||||
local latestMonth, latestYear = _QuestieJourney:GetMonthAndYearOfLatestEntry()
|
||||
if latestMonth and latestYear then
|
||||
journeyTreeFrame:SelectByPath(latestYear, latestMonth)
|
||||
end
|
||||
journeyTreeFrame:SetCallback("OnGroupSelected", function(group)
|
||||
Questie:Debug(Questie.DEBUG_DEVELOP, "[Journey] OnGroupSelected - Path:", group.localstatus.selected)
|
||||
|
||||
local _, _, e = strsplit("\001", group.localstatus.selected);
|
||||
|
||||
if e then
|
||||
local master = group.frame.obj;
|
||||
master:ReleaseChildren();
|
||||
master:SetLayout("fill");
|
||||
master:SetFullWidth(true);
|
||||
master:SetFullHeight(true);
|
||||
|
||||
local f = AceGUI:Create("ScrollFrame");
|
||||
f:SetLayout("flow");
|
||||
master:AddChild(f);
|
||||
|
||||
local header = AceGUI:Create("Heading");
|
||||
header:SetFullWidth(true);
|
||||
f:AddChild(header);
|
||||
|
||||
QuestieJourneyUtils:Spacer(f);
|
||||
|
||||
local created = AceGUI:Create("Label");
|
||||
created:SetFullWidth(true);
|
||||
|
||||
local entry = Questie.db.char.journey[tonumber(e)];
|
||||
local day = CALENDAR_WEEKDAY_NAMES[ tonumber(date('%w', entry.Timestamp)) + 1 ];
|
||||
local month = CALENDAR_FULLDATE_MONTH_NAMES[ tonumber(date('%m', entry.Timestamp)) ];
|
||||
local timestamp = Questie:Colorize(date( day ..', '.. month ..' %d @ %H:%M' , entry.Timestamp), 'blue');
|
||||
|
||||
if entry.Event == "Note" then
|
||||
header:SetText(l10n('Note: %s', entry.Title));
|
||||
|
||||
local note = AceGUI:Create("Label");
|
||||
note:SetFullWidth(true);
|
||||
note:SetText(Questie:Colorize( entry.Note , 'yellow'));
|
||||
f:AddChild(note);
|
||||
QuestieJourneyUtils:Spacer(f);
|
||||
|
||||
created:SetText(l10n('Note Created: %s', timestamp));
|
||||
f:AddChild(created);
|
||||
|
||||
elseif entry.Event == "Level" then
|
||||
header:SetText(l10n('You Reached Level %s', entry.NewLevel));
|
||||
|
||||
local congrats = AceGUI:Create("Label");
|
||||
congrats:SetText(l10n('Congratulations! You reached %s !', entry.NewLevel));
|
||||
congrats:SetFullWidth(true);
|
||||
f:AddChild(congrats);
|
||||
|
||||
created:SetText(timestamp);
|
||||
f:AddChild(created);
|
||||
|
||||
elseif entry.Event == "Quest" then
|
||||
local state
|
||||
if entry.SubType == "Accept" then
|
||||
state = l10n("Accepted");
|
||||
elseif entry.SubType == "Complete" then
|
||||
state = l10n("Completed");
|
||||
elseif entry.SubType == "Abandon" then
|
||||
state = l10n("Abandoned");
|
||||
else
|
||||
state = "ERROR!!";
|
||||
end
|
||||
|
||||
local quest = QuestieDB.GetQuest(entry.Quest)
|
||||
if quest then
|
||||
local qName = quest.name;
|
||||
header:SetText(l10n('Quest %s: %s', state, qName));
|
||||
|
||||
|
||||
local obj = AceGUI:Create("Label");
|
||||
obj:SetFullWidth(true);
|
||||
obj:SetText(_QuestieJourney:CreateObjectiveText(quest.Description));
|
||||
f:AddChild(obj);
|
||||
end
|
||||
|
||||
QuestieJourneyUtils:Spacer(f);
|
||||
|
||||
created:SetText(l10n('Quest %s: %s', state, timestamp));
|
||||
f:AddChild(created);
|
||||
|
||||
else
|
||||
header:SetText("ERROR!!");
|
||||
end
|
||||
|
||||
end
|
||||
end);
|
||||
|
||||
container:AddChild(journeyTreeFrame);
|
||||
else
|
||||
container:ReleaseChildren();
|
||||
journeyTreeFrame = nil;
|
||||
_QuestieJourney.myJourney:ManageTree(container);
|
||||
end
|
||||
end
|
||||
|
||||
--- Get the month and year of the latest entry in the Journey.
|
||||
--- This is used to select it in the tree view.
|
||||
---@return number @The month of the latest entry
|
||||
---@return number @The year of the latest entry
|
||||
function _QuestieJourney:GetMonthAndYearOfLatestEntry()
|
||||
local journeyEntries = _QuestieJourney:GetJourneyEntries()
|
||||
local years = {}
|
||||
local months = {}
|
||||
|
||||
for year, _ in pairs(journeyEntries) do
|
||||
table.insert(years, year)
|
||||
end
|
||||
if not next(years) then
|
||||
return nil, nil
|
||||
end
|
||||
local maxYear = math.max(unpack(years))
|
||||
|
||||
for month, _ in pairs(journeyEntries[maxYear]) do
|
||||
table.insert(months, month)
|
||||
end
|
||||
local maxMonth = math.max(unpack(months))
|
||||
|
||||
return maxMonth, maxYear
|
||||
end
|
||||
@@ -0,0 +1,102 @@
|
||||
---@type QuestieJourney
|
||||
local QuestieJourney = QuestieLoader:CreateModule("QuestieJourney")
|
||||
local _QuestieJourney = QuestieJourney.private
|
||||
-------------------------
|
||||
--Import modules.
|
||||
-------------------------
|
||||
---@type QuestieJourneyUtils
|
||||
local QuestieJourneyUtils = QuestieLoader:ImportModule("QuestieJourneyUtils");
|
||||
---@type QuestieDB
|
||||
local QuestieDB = QuestieLoader:ImportModule("QuestieDB");
|
||||
---@type l10n
|
||||
local l10n = QuestieLoader:ImportModule("l10n")
|
||||
|
||||
--- COMPATIBILITY ---
|
||||
local CALENDAR_WEEKDAY_NAMES = QuestieCompat.CALENDAR_WEEKDAY_NAMES
|
||||
local CALENDAR_FULLDATE_MONTH_NAMES = QuestieCompat.CALENDAR_FULLDATE_MONTH_NAMES
|
||||
|
||||
local AceGUI = LibStub("AceGUI-3.0");
|
||||
|
||||
--- Draw the "My Journey" tab
|
||||
---@param container Frame
|
||||
---@return SimpleGroup
|
||||
function _QuestieJourney.myJourney:DrawTab(container)
|
||||
local header = AceGUI:Create("Heading");
|
||||
header:SetText(l10n('Your Recent History'));
|
||||
header:SetFullWidth(true);
|
||||
container:AddChild(header);
|
||||
QuestieJourneyUtils:Spacer(container);
|
||||
|
||||
-- get last 5 elements from table for history
|
||||
local counter = #Questie.db.char.journey;
|
||||
local recentEvents = {};
|
||||
for i = counter, counter-4, -1 do
|
||||
if i <= 0 then
|
||||
break;
|
||||
end
|
||||
|
||||
recentEvents[i] = {};
|
||||
recentEvents[i] = AceGUI:Create("Label");
|
||||
recentEvents[i]:SetFullWidth(true);
|
||||
|
||||
local day = CALENDAR_WEEKDAY_NAMES[tonumber(date('%w', Questie.db.char.journey[i].Timestamp)) + 1];
|
||||
local month = CALENDAR_FULLDATE_MONTH_NAMES[tonumber(date('%m', Questie.db.char.journey[i].Timestamp))];
|
||||
|
||||
local timestamp = Questie:Colorize(date( '[ '..day ..', '.. month ..' %d @ %H:%M ] ' , Questie.db.char.journey[i].Timestamp), 'blue');
|
||||
|
||||
-- if it's a quest event
|
||||
if Questie.db.char.journey[i].Event == "Quest" then
|
||||
local qName = QuestieDB.QueryQuestSingle(Questie.db.char.journey[i].Quest, "name");
|
||||
if qName then
|
||||
qName = Questie:Colorize(qName, 'gray');
|
||||
|
||||
if Questie.db.char.journey[i].SubType == "Accept" then
|
||||
recentEvents[i]:SetText(timestamp .. Questie:Colorize(l10n('You Accepted the quest %s', qName), 'yellow'));
|
||||
elseif Questie.db.char.journey[i].SubType == "Abandon" then
|
||||
recentEvents[i]:SetText(timestamp .. Questie:Colorize(l10n('You Abandoned the quest %s', qName), 'yellow'));
|
||||
elseif Questie.db.char.journey[i].SubType == "Complete" then
|
||||
recentEvents[i]:SetText(timestamp .. Questie:Colorize(l10n('You Completed the quest %s', qName), 'yellow'));
|
||||
end
|
||||
end
|
||||
elseif Questie.db.char.journey[i].Event == "Level" then
|
||||
local level = Questie:Colorize(l10n('Level %s', Questie.db.char.journey[i].NewLevel), 'gray');
|
||||
recentEvents[i]:SetText(timestamp .. Questie:Colorize(l10n('Congratulations! You reached %s !', level), 'yellow'));
|
||||
elseif Questie.db.char.journey[i].Event == "Note" then
|
||||
local title = Questie:Colorize(Questie.db.char.journey[i].Title, 'gray');
|
||||
recentEvents[i]:SetText(timestamp .. Questie:Colorize(l10n('Note Created: %s', title), 'yellow'));
|
||||
end
|
||||
|
||||
container:AddChild(recentEvents[i]);
|
||||
end
|
||||
|
||||
if counter == 0 then
|
||||
local justdoit = AceGUI:Create("Label");
|
||||
justdoit:SetFullWidth(true);
|
||||
justdoit:SetText(Questie:Colorize(l10n("It's about time you embark on your first Journey!"), 'yellow'));
|
||||
container:AddChild(justdoit);
|
||||
end
|
||||
|
||||
QuestieJourneyUtils:Spacer(container);
|
||||
|
||||
local treeHeader = AceGUI:Create("Heading");
|
||||
treeHeader:SetText(l10n("%s's Journey", UnitName("player")));
|
||||
treeHeader:SetFullWidth(true);
|
||||
container:AddChild(treeHeader);
|
||||
|
||||
local noteButton = AceGUI:Create("Button");
|
||||
noteButton:SetText(l10n('Add New Adventure Note'));
|
||||
noteButton:SetPoint("RIGHT");
|
||||
noteButton:SetCallback("OnClick", _QuestieJourney.ShowNotePopup);
|
||||
container:AddChild(noteButton);
|
||||
|
||||
QuestieJourneyUtils:Spacer(container);
|
||||
|
||||
---@class SimpleGroup
|
||||
local treeGroup = AceGUI:Create("SimpleGroup");
|
||||
treeGroup:SetLayout("fill");
|
||||
treeGroup:SetFullHeight(true);
|
||||
treeGroup:SetFullWidth(true);
|
||||
container:AddChild(treeGroup);
|
||||
|
||||
return treeGroup
|
||||
end
|
||||
@@ -0,0 +1,132 @@
|
||||
---@type QuestieJourney
|
||||
local QuestieJourney = QuestieLoader:CreateModule("QuestieJourney")
|
||||
local _QuestieJourney = QuestieJourney.private
|
||||
_QuestieJourney.notePopup = nil
|
||||
-------------------------
|
||||
--Import modules
|
||||
-------------------------
|
||||
---@type QuestieJourneyUtils
|
||||
local QuestieJourneyUtils = QuestieLoader:ImportModule("QuestieJourneyUtils")
|
||||
---@type l10n
|
||||
local l10n = QuestieLoader:ImportModule("l10n")
|
||||
|
||||
--- COMPATIBILITY ---
|
||||
local CALENDAR_WEEKDAY_NAMES = QuestieCompat.CALENDAR_WEEKDAY_NAMES
|
||||
local CALENDAR_FULLDATE_MONTH_NAMES = QuestieCompat.CALENDAR_FULLDATE_MONTH_NAMES
|
||||
|
||||
local AceGUI = LibStub("AceGUI-3.0")
|
||||
local titleBox, messageBox
|
||||
|
||||
local _CreateNoteWindow, _CreateContainer, _CreateDescription, _CreateTitleBox, _CreateMessageBox
|
||||
local _CreateNoteAddButton, _HandleNoteEntry
|
||||
|
||||
|
||||
function _QuestieJourney:ShowNotePopup()
|
||||
if (not _QuestieJourney.notePopup) then
|
||||
_QuestieJourney.notePopup = _CreateNoteWindow()
|
||||
elseif (not _QuestieJourney.notePopup:IsShown()) then
|
||||
_QuestieJourney.notePopup:Show()
|
||||
else
|
||||
_QuestieJourney.notePopup:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
_CreateNoteWindow = function ()
|
||||
local notePopup = AceGUI:Create("Window")
|
||||
notePopup:Show()
|
||||
notePopup:SetTitle(l10n('Add New Adventure Note'))
|
||||
notePopup:SetWidth(400)
|
||||
notePopup:SetHeight(400)
|
||||
notePopup:EnableResize(false)
|
||||
notePopup.frame:SetFrameStrata(_QuestieJourney.containerCache.frame:GetFrameStrata())
|
||||
notePopup.frame:SetFrameLevel(_QuestieJourney.containerCache.frame:GetFrameLevel())
|
||||
notePopup.frame:Raise()
|
||||
notePopup:SetCallback("OnClose", function()
|
||||
notePopup:Hide()
|
||||
end)
|
||||
|
||||
local container = _CreateContainer()
|
||||
notePopup:AddChild(container)
|
||||
|
||||
local desc = _CreateDescription()
|
||||
container:AddChild(desc)
|
||||
|
||||
QuestieJourneyUtils:Spacer(container)
|
||||
|
||||
titleBox = _CreateTitleBox()
|
||||
container:AddChild(titleBox)
|
||||
|
||||
messageBox = _CreateMessageBox()
|
||||
container:AddChild(messageBox)
|
||||
|
||||
local addEntryBtn = _CreateNoteAddButton()
|
||||
container:AddChild(addEntryBtn)
|
||||
|
||||
return notePopup
|
||||
end
|
||||
|
||||
_CreateContainer = function ()
|
||||
-- Setup Note Taking
|
||||
local day = CALENDAR_WEEKDAY_NAMES[tonumber(date('%w', time())) + 1]
|
||||
local month = CALENDAR_FULLDATE_MONTH_NAMES[tonumber(date('%m', time()))]
|
||||
local today = date(day ..', '.. month ..' %d', time())
|
||||
local container = AceGUI:Create("InlineGroup")
|
||||
container:SetFullHeight(true)
|
||||
container:SetFullWidth(true)
|
||||
container:SetLayout('flow')
|
||||
container:SetTitle(l10n('New Note For: %s', today))
|
||||
return container
|
||||
end
|
||||
|
||||
_CreateDescription =function ()
|
||||
local desc = AceGUI:Create("Label")
|
||||
desc:SetText(Questie:Colorize(l10n('Create an entry in your journal to remember a specific moment. Simply supply a title and description and Questie will remember it for you!'), 'yellow'))
|
||||
desc:SetFullWidth(true)
|
||||
return desc
|
||||
end
|
||||
|
||||
_CreateTitleBox = function ()
|
||||
local box = AceGUI:Create("EditBox")
|
||||
box:SetFullWidth(true)
|
||||
box:SetLabel(l10n('Entry Title'))
|
||||
box:DisableButton(true)
|
||||
box:SetFocus()
|
||||
return box
|
||||
end
|
||||
|
||||
_CreateMessageBox = function ()
|
||||
local box = AceGUI:Create("MultiLineEditBox")
|
||||
box:SetFullWidth(true)
|
||||
box:SetNumLines(12)
|
||||
box:SetLabel(l10n('Journal Entry'))
|
||||
box:DisableButton(true)
|
||||
return box
|
||||
end
|
||||
|
||||
_CreateNoteAddButton = function ()
|
||||
local addEntryBtn = AceGUI:Create("Button")
|
||||
addEntryBtn:SetText(l10n('Add Entry'))
|
||||
addEntryBtn:SetCallback("OnClick", _HandleNoteEntry)
|
||||
return addEntryBtn
|
||||
end
|
||||
|
||||
_HandleNoteEntry = function ()
|
||||
local error = Questie:Colorize('[Questie] ', 'blue')
|
||||
if titleBox:GetText() == '' then
|
||||
print (error .. l10n('No Title was entered. You must enter a title before submitting your note.'))
|
||||
return
|
||||
elseif messageBox:GetText() == '' then
|
||||
print (error .. l10n('No Note was entered. You must enter a note before submitting.'))
|
||||
return
|
||||
end
|
||||
local data = {}
|
||||
data.Event = "Note"
|
||||
data.Note = messageBox:GetText()
|
||||
data.Title = titleBox:GetText()
|
||||
data.Timestamp = time()
|
||||
|
||||
tinsert(Questie.db.char.journey, data)
|
||||
|
||||
_QuestieJourney.myJourney:ManageTree(_QuestieJourney.treeCache)
|
||||
_QuestieJourney.notePopup:Hide()
|
||||
end
|
||||
@@ -0,0 +1,236 @@
|
||||
---@type QuestieJourney
|
||||
local QuestieJourney = QuestieLoader:CreateModule("QuestieJourney")
|
||||
local _QuestieJourney = QuestieJourney.private
|
||||
_QuestieJourney.questsByZone = {}
|
||||
|
||||
---@type QuestieDB
|
||||
local QuestieDB = QuestieLoader:ImportModule("QuestieDB")
|
||||
---@type QuestieLib
|
||||
local QuestieLib = QuestieLoader:ImportModule("QuestieLib")
|
||||
---@type QuestieReputation
|
||||
local QuestieReputation = QuestieLoader:ImportModule("QuestieReputation")
|
||||
---@type QuestieCorrections
|
||||
local QuestieCorrections = QuestieLoader:ImportModule("QuestieCorrections")
|
||||
---@type QuestieEvent
|
||||
local QuestieEvent = QuestieLoader:ImportModule("QuestieEvent")
|
||||
---@type QuestieLink
|
||||
local QuestieLink = QuestieLoader:ImportModule("QuestieLink")
|
||||
---@type l10n
|
||||
local l10n = QuestieLoader:ImportModule("l10n")
|
||||
|
||||
local AceGUI = LibStub("AceGUI-3.0")
|
||||
local zoneTreeFrame
|
||||
|
||||
---Manage the zone tree itself and the contents of the per-quest window
|
||||
---@param container AceSimpleGroup @The container for the zone tree
|
||||
---@param zoneTree table @The zone tree table
|
||||
function _QuestieJourney.questsByZone:ManageTree(container, zoneTree)
|
||||
if zoneTreeFrame then
|
||||
container:ReleaseChildren()
|
||||
zoneTreeFrame = nil
|
||||
_QuestieJourney.questsByZone:ManageTree(container, zoneTree)
|
||||
return
|
||||
end
|
||||
|
||||
zoneTreeFrame = AceGUI:Create("TreeGroup")
|
||||
zoneTreeFrame:SetFullWidth(true)
|
||||
zoneTreeFrame:SetFullHeight(true)
|
||||
zoneTreeFrame:SetTree(zoneTree)
|
||||
|
||||
zoneTreeFrame.treeframe:SetWidth(220)
|
||||
zoneTreeFrame:SetCallback("OnClick", function(group, ...)
|
||||
local treePath = {...}
|
||||
|
||||
if not treePath[2] then
|
||||
Questie:Debug(Questie.DEBUG_CRITICAL, "[zoneTreeFrame:OnClick] No tree path given in Journey.")
|
||||
return
|
||||
end
|
||||
-- if they clicked on a header, don't do anything
|
||||
local sel, questId = strsplit("\001", treePath[2]) -- treePath[2] looks like "a?1234" for an available quest with ID 1234
|
||||
if (sel == nil or sel == "a" or sel == "p" or sel == "c" or sel == "r" or sel == "u") and (not questId) then
|
||||
return
|
||||
end
|
||||
|
||||
-- get master frame and create scroll frame inside
|
||||
local master = group.frame.obj
|
||||
master:ReleaseChildren()
|
||||
master:SetLayout("fill")
|
||||
master:SetFullWidth(true)
|
||||
master:SetFullHeight(true)
|
||||
|
||||
---@class ScrollFrame
|
||||
local scrollFrame = AceGUI:Create("ScrollFrame")
|
||||
scrollFrame:SetLayout("flow")
|
||||
scrollFrame:SetFullHeight(true)
|
||||
master:AddChild(scrollFrame)
|
||||
|
||||
---@type number
|
||||
questId = tonumber(questId)
|
||||
local quest = QuestieDB.GetQuest(questId)
|
||||
|
||||
-- Add the quest to the open chat window if it was a shift click
|
||||
if (IsModifiedClick("CHATLINK") and ChatEdit_GetActiveWindow()) then
|
||||
ChatEdit_InsertLink(QuestieLink:GetQuestLinkString(quest.level, quest.name, quest.Id))
|
||||
end
|
||||
|
||||
_QuestieJourney:DrawQuestDetailsFrame(scrollFrame, quest)
|
||||
end)
|
||||
|
||||
container:AddChild(zoneTreeFrame)
|
||||
end
|
||||
|
||||
---Get all the available/completed/repeatable/unavailable quests
|
||||
---@param zoneId number @The zone ID (Check `l10n.zoneLookup`)
|
||||
---@return table<number,any> @The zoneTree table which represents the list of all the different quests
|
||||
function _QuestieJourney.questsByZone:CollectZoneQuests(zoneId)
|
||||
local quests = QuestieJourney.zoneMap[zoneId]--QuestieDB:GetQuestsByZoneId(zoneId)
|
||||
|
||||
if (not quests) then
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
local zoneTree = {
|
||||
[1] = {
|
||||
value = "a",
|
||||
text = l10n('Available Quests'),
|
||||
children = {}
|
||||
},
|
||||
[2] = {
|
||||
value = "p",
|
||||
text = l10n('Missing Pre Quest'),
|
||||
children = {}
|
||||
},
|
||||
[3] = {
|
||||
value = "c",
|
||||
text = l10n('Completed Quests'),
|
||||
children = {}
|
||||
},
|
||||
[4] = {
|
||||
value = "r",
|
||||
text = l10n('Repeatable Quests'),
|
||||
children = {},
|
||||
},
|
||||
[5] = {
|
||||
value = "u",
|
||||
text = l10n('Unobtainable Quests'),
|
||||
children = {},
|
||||
}
|
||||
}
|
||||
local sortedQuestByLevel = QuestieLib:SortQuestIDsByLevel(quests)
|
||||
|
||||
local availableCounter = 0
|
||||
local prequestMissingCounter = 0
|
||||
local completedCounter = 0
|
||||
local unobtainableCounter = 0
|
||||
local repeatableCounter = 0
|
||||
|
||||
local unobtainableQuestIds = {}
|
||||
local temp = {}
|
||||
|
||||
for _, levelAndQuest in pairs(sortedQuestByLevel) do
|
||||
---@type number
|
||||
local questId = levelAndQuest[2]
|
||||
-- Only show quests which are not hidden
|
||||
local isStreamQuest = QuestieDB.QuestPointers and QuestieDB.QuestPointers[questId]
|
||||
local isAscensionQuest = QuestieDB.ascensionQuestIds and QuestieDB.ascensionQuestIds[questId]
|
||||
|
||||
if QuestieCorrections.hiddenQuests
|
||||
and ((not QuestieCorrections.hiddenQuests[questId]) or QuestieEvent:IsEventQuest(questId))
|
||||
and (isStreamQuest or isAscensionQuest) then
|
||||
|
||||
temp.value = questId
|
||||
temp.text = QuestieLib:GetColoredQuestName(questId, Questie.db.profile.enableTooltipsQuestLevel, false, true)
|
||||
|
||||
-- Completed quests
|
||||
if Questie.db.char.complete[questId] then
|
||||
tinsert(zoneTree[3].children, temp)
|
||||
completedCounter = completedCounter + 1
|
||||
else
|
||||
local queryResult = QuestieDB.QueryQuest(
|
||||
questId,
|
||||
{
|
||||
"exclusiveTo",
|
||||
"nextQuestInChain",
|
||||
"parentQuest",
|
||||
"preQuestSingle",
|
||||
"preQuestGroup",
|
||||
"requiredMinRep",
|
||||
"requiredMaxRep"
|
||||
}
|
||||
) or {}
|
||||
local exclusiveTo = queryResult[1]
|
||||
local nextQuestInChain = queryResult[2]
|
||||
local parentQuest = queryResult[3]
|
||||
local preQuestSingle = queryResult[4]
|
||||
local preQuestGroup = queryResult[5]
|
||||
local requiredMinRep = queryResult[6]
|
||||
local requiredMaxRep = queryResult[7]
|
||||
|
||||
-- Exclusive quests will never be available since another quests permanently blocks them.
|
||||
-- Marking them as complete should be the most satisfying solution for user
|
||||
if (nextQuestInChain and Questie.db.char.complete[nextQuestInChain]) or (exclusiveTo and QuestieDB:IsExclusiveQuestInQuestLogOrComplete(exclusiveTo)) then
|
||||
tinsert(zoneTree[3].children, temp)
|
||||
completedCounter = completedCounter + 1
|
||||
-- The parent quest has been completed
|
||||
elseif parentQuest and Questie.db.char.complete[parentQuest] then
|
||||
tinsert(zoneTree[3].children, temp)
|
||||
completedCounter = completedCounter + 1
|
||||
-- Unoptainable reputation quests
|
||||
elseif not QuestieReputation:HasReputation(requiredMinRep, requiredMaxRep) then
|
||||
tinsert(zoneTree[5].children, temp)
|
||||
unobtainableQuestIds[questId] = true
|
||||
unobtainableCounter = unobtainableCounter + 1
|
||||
-- A single pre Quest is missing
|
||||
elseif not QuestieDB:IsPreQuestSingleFulfilled(preQuestSingle) then
|
||||
-- The pre Quest is unobtainable therefore this quest is it as well
|
||||
if unobtainableQuestIds[preQuestSingle] ~= nil then
|
||||
tinsert(zoneTree[5].children, temp)
|
||||
unobtainableQuestIds[questId] = true
|
||||
unobtainableCounter = unobtainableCounter + 1
|
||||
else
|
||||
tinsert(zoneTree[2].children, temp)
|
||||
prequestMissingCounter = prequestMissingCounter + 1
|
||||
end
|
||||
-- Multiple pre Quests are missing
|
||||
elseif not QuestieDB:IsPreQuestGroupFulfilled(preQuestGroup) then
|
||||
local hasUnobtainablePreQuest = false
|
||||
for _, preQuestId in pairs(preQuestGroup) do
|
||||
if unobtainableQuestIds[preQuestId] ~= nil then
|
||||
tinsert(zoneTree[5].children, temp)
|
||||
unobtainableQuestIds[questId] = true
|
||||
unobtainableCounter = unobtainableCounter + 1
|
||||
hasUnobtainablePreQuest = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if not hasUnobtainablePreQuest then
|
||||
tinsert(zoneTree[2].children, temp)
|
||||
prequestMissingCounter = prequestMissingCounter + 1
|
||||
end
|
||||
-- Repeatable quests
|
||||
elseif QuestieDB.IsRepeatable(questId) then
|
||||
tinsert(zoneTree[4].children, temp)
|
||||
repeatableCounter = repeatableCounter + 1
|
||||
-- Available quests
|
||||
else
|
||||
tinsert(zoneTree[1].children, temp)
|
||||
availableCounter = availableCounter + 1
|
||||
end
|
||||
end
|
||||
temp = {}
|
||||
end
|
||||
end
|
||||
|
||||
local totalCounter = availableCounter + completedCounter + prequestMissingCounter
|
||||
zoneTree[1].text = zoneTree[1].text .. ' [ '.. availableCounter ..'/'.. totalCounter ..' ]'
|
||||
zoneTree[2].text = zoneTree[2].text .. ' [ '.. prequestMissingCounter ..'/'.. totalCounter ..' ]'
|
||||
zoneTree[3].text = zoneTree[3].text .. ' [ '.. completedCounter ..'/'.. totalCounter ..' ]'
|
||||
zoneTree[4].text = zoneTree[4].text .. ' [ '.. repeatableCounter ..' ]'
|
||||
zoneTree[5].text = zoneTree[5].text .. ' [ '.. unobtainableCounter ..' ]'
|
||||
|
||||
zoneTree.numquests = totalCounter + repeatableCounter + unobtainableCounter
|
||||
|
||||
return zoneTree
|
||||
end
|
||||
@@ -0,0 +1,165 @@
|
||||
---@type QuestieJourney
|
||||
local QuestieJourney = QuestieLoader:CreateModule("QuestieJourney")
|
||||
local _QuestieJourney = QuestieJourney.private
|
||||
-------------------------
|
||||
--Import modules.
|
||||
-------------------------
|
||||
---@type QuestieJourneyUtils
|
||||
local QuestieJourneyUtils = QuestieLoader:ImportModule("QuestieJourneyUtils")
|
||||
---@type QuestiePlayer
|
||||
local QuestiePlayer = QuestieLoader:ImportModule("QuestiePlayer")
|
||||
---@type QuestieProfessions
|
||||
local QuestieProfessions = QuestieLoader:ImportModule("QuestieProfessions")
|
||||
---@type QuestieDB
|
||||
local QuestieDB = QuestieLoader:ImportModule("QuestieDB")
|
||||
---@type l10n
|
||||
local l10n = QuestieLoader:ImportModule("l10n")
|
||||
|
||||
local AceGUI = LibStub("AceGUI-3.0")
|
||||
|
||||
local RESET = -1000
|
||||
|
||||
local _CreateContinentDropdown, _CreateZoneDropdown
|
||||
local _HandleContinentSelection, _HandleZoneSelection
|
||||
|
||||
local selectedContinentId
|
||||
local contDropdown, zoneDropdown, treegroup
|
||||
|
||||
-- function that draws the Tab for Zone Quests
|
||||
function _QuestieJourney.questsByZone:DrawTab(container)
|
||||
---@class AceSimpleGroup
|
||||
treegroup = AceGUI:Create("SimpleGroup")
|
||||
|
||||
-- Header
|
||||
local header = AceGUI:Create("Heading")
|
||||
header:SetText(l10n('Select Your Continent and Zone'))
|
||||
header:SetFullWidth(true)
|
||||
container:AddChild(header)
|
||||
|
||||
QuestieJourneyUtils:Spacer(container)
|
||||
|
||||
contDropdown = _CreateContinentDropdown()
|
||||
container:AddChild(contDropdown)
|
||||
|
||||
zoneDropdown = _CreateZoneDropdown()
|
||||
container:AddChild(zoneDropdown)
|
||||
|
||||
QuestieJourneyUtils:Spacer(container)
|
||||
|
||||
header = AceGUI:Create("Heading")
|
||||
header:SetText(l10n('Zone Quests'))
|
||||
header:SetFullWidth(true)
|
||||
container:AddChild(header)
|
||||
|
||||
QuestieJourneyUtils:Spacer(container)
|
||||
|
||||
treegroup:SetFullHeight(true)
|
||||
treegroup:SetFullWidth(true)
|
||||
treegroup:SetLayout("fill")
|
||||
container:AddChild(treegroup)
|
||||
end
|
||||
|
||||
_CreateContinentDropdown = function()
|
||||
local dropdown = AceGUI:Create("Dropdown")
|
||||
dropdown:SetList(QuestieJourney.continents)
|
||||
dropdown:SetText(l10n('Select Your Continent'))
|
||||
dropdown:SetCallback("OnValueChanged", _HandleContinentSelection)
|
||||
|
||||
local currentContinentId = QuestiePlayer:GetCurrentContinentId()
|
||||
|
||||
-- This mapping translates the actual continent ID to the keys of l10n.continentLookup
|
||||
if currentContinentId == 0 then -- Eastern Kingdom
|
||||
selectedContinentId = 1
|
||||
elseif currentContinentId == 1 then -- Kalimdor
|
||||
selectedContinentId = 2
|
||||
elseif currentContinentId == 530 then -- Outland
|
||||
selectedContinentId = 3
|
||||
elseif currentContinentId == 571 then -- Northrend
|
||||
selectedContinentId = 4
|
||||
elseif l10n.zoneLookup[currentContinentId] then -- Dungeon
|
||||
selectedContinentId = 5
|
||||
end
|
||||
|
||||
if _QuestieJourney.lastZoneSelection[1] then
|
||||
selectedContinentId = _QuestieJourney.lastZoneSelection[1]
|
||||
end
|
||||
|
||||
dropdown:SetValue(selectedContinentId)
|
||||
return dropdown
|
||||
end
|
||||
|
||||
_CreateZoneDropdown = function()
|
||||
local dropdown = AceGUI:Create("Dropdown")
|
||||
|
||||
local currentZoneId = QuestiePlayer:GetCurrentZoneId()
|
||||
if _QuestieJourney.lastZoneSelection[2] then
|
||||
currentZoneId = _QuestieJourney.lastZoneSelection[2]
|
||||
end
|
||||
|
||||
local zones = QuestieJourney.zones[selectedContinentId]
|
||||
if currentZoneId and currentZoneId > 0 and zones then
|
||||
local sortedZones = QuestieJourneyUtils:GetSortedZoneKeys(zones)
|
||||
dropdown:SetList(zones, sortedZones)
|
||||
dropdown:SetValue(currentZoneId)
|
||||
|
||||
local zoneTree = _QuestieJourney.questsByZone:CollectZoneQuests(currentZoneId)
|
||||
_QuestieJourney.questsByZone:ManageTree(treegroup, zoneTree)
|
||||
elseif currentZoneId == RESET and zones then
|
||||
dropdown:SetText(l10n('Select Your Zone'))
|
||||
local sortedZones = QuestieJourneyUtils:GetSortedZoneKeys(zones)
|
||||
dropdown:SetList(zones, sortedZones)
|
||||
else
|
||||
dropdown:SetDisabled(true)
|
||||
end
|
||||
|
||||
dropdown:SetCallback("OnValueChanged", _HandleZoneSelection)
|
||||
return dropdown
|
||||
end
|
||||
|
||||
_HandleContinentSelection = function(key, _)
|
||||
if (key.value == QuestieJourney.questCategoryKeys.CLASS) then
|
||||
local _, class, _ = UnitClass("player")
|
||||
local classKey = QuestieDB:GetZoneOrSortForClass(class)
|
||||
local zoneTree = _QuestieJourney.questsByZone:CollectZoneQuests(classKey)
|
||||
_QuestieJourney.questsByZone:ManageTree(treegroup, zoneTree)
|
||||
zoneDropdown.frame:Hide()
|
||||
elseif (key.value == QuestieJourney.questCategoryKeys.PROFESSIONS) then
|
||||
local professionList = QuestieJourney.zones[key.value]
|
||||
local playerProfessions = QuestieProfessions:GetPlayerProfessionNames()
|
||||
|
||||
local relevantProfessions = {}
|
||||
for id, possibleName in pairs(professionList) do
|
||||
for _, name in pairs(playerProfessions) do
|
||||
if possibleName == name then
|
||||
relevantProfessions[id] = professionList[id]
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
local text = l10n('Select Your Profession')
|
||||
if (not next(relevantProfessions)) then
|
||||
text = l10n('No Quests found')
|
||||
zoneDropdown:SetDisabled(true)
|
||||
else
|
||||
zoneDropdown:SetDisabled(false)
|
||||
end
|
||||
zoneDropdown:SetList(relevantProfessions)
|
||||
zoneDropdown:SetText(text)
|
||||
zoneDropdown.frame:Show()
|
||||
else
|
||||
local sortedZones = QuestieJourneyUtils:GetSortedZoneKeys(QuestieJourney.zones[key.value])
|
||||
zoneDropdown:SetList(QuestieJourney.zones[key.value], sortedZones)
|
||||
zoneDropdown:SetText(l10n("Select Your Zone"))
|
||||
zoneDropdown:SetDisabled(false)
|
||||
zoneDropdown.frame:Show()
|
||||
end
|
||||
|
||||
_QuestieJourney.lastZoneSelection[2] = RESET
|
||||
_QuestieJourney.lastZoneSelection[1] = key.value
|
||||
end
|
||||
|
||||
_HandleZoneSelection = function(key, _)
|
||||
local zoneTree = _QuestieJourney.questsByZone:CollectZoneQuests(key.value)
|
||||
_QuestieJourney.questsByZone:ManageTree(treegroup, zoneTree)
|
||||
_QuestieJourney.lastZoneSelection[2] = key.value
|
||||
end
|
||||
Reference in New Issue
Block a user