1
0
Bifurcation 0

Moved some more variables in vars.lua. Reformated main.lua a little for readability.

Cette révision appartient à :
Nathanial.C.Jones 2013-01-02 18:00:10 +00:00
Parent 0941d6e1e6
révision d0b8ba397e
3 fichiers modifiés avec 78 ajouts et 50 suppressions

Voir le fichier

@ -4,22 +4,6 @@ QuestHelper_Loadtime["main.lua"] = GetTime()
local GetTime = QuestHelper_GetTime
local version_string = QuestHelper_File["main.lua"] -- we pretty much save this only so we can inform the user that they're using a beta version
-- Just to make sure it's always 'seen' (there's nothing that can be seen, but still...), and therefore always updating.
QuestHelper:SetFrameStrata("TOOLTIP")
QuestHelper.tooltip = CreateFrame("GameTooltip", "QuestHelperTooltip", nil, "GameTooltipTemplate")
QuestHelper.objective_objects = {}
QuestHelper.user_objectives = {}
QuestHelper.quest_objects = {}
QuestHelper.player_level = 1
QuestHelper.locale = QuestHelper_Locale
QuestHelper.faction = UnitFactionGroup("player")
--[[ assert(QuestHelper.faction) ]]
QuestHelper.font = {serif=GameFontNormal:GetFont(), sans=ChatFontNormal:GetFont(), fancy=QuestTitleFont:GetFont()}
function QuestHelper:GetFontPath(list_string, font)
if list_string then
for name in string.gmatch(list_string, "[^;]+") do
@ -65,13 +49,6 @@ function QuestHelper:SetLocaleFonts()
-- what why did we ever do this
end
QuestHelper.route = {}
QuestHelper.to_add = {}
QuestHelper.to_remove = {}
QuestHelper.quest_log = {}
QuestHelper.pos = {nil, {}, 0, 0, 1, "You are here.", 0}
QuestHelper.sharing = false -- Will be set to true when sharing with at least one user.
function QuestHelper.tooltip:GetPrevLines() -- Just a helper to make life easier.
local last = self:NumLines()
local name = self:GetName()
@ -122,42 +99,35 @@ local please_submit_initted = false
local spawned = false
QHQuestsCompleted = false
local function QH_QueryQuestsCompletedHandler()
QHQuestsCompleted = GetQuestsCompleted()
end
QH_Event("ADDON_LOADED", function (addonid)
if addonid ~= "QuestHelper" then return end
-- ONLY FAST STUFF ALLOWED IN HERE
local function QH_QueryQuestsCompleted()
--[[
QH_Event("QUEST_QUERY_COMPLETE", function ()
QHQuestsCompleted = GetQuestsCompleted()
end)
QH_Event("QUEST_QUERY_COMPLETE", QH_QueryQuestsCompletedHandler)
QueryQuestsCompleted()
--]]
end
-- Use DefaultPref as fallback for unset preference keys.
setmetatable(QuestHelper_Pref, {__index=QuestHelper_DefaultPref})
QuestHelper: Assert(QuestHelper_Pref.perfload_scale) -- if this fails, something is very botched
--[[
if not QuestHelper_Pref.track or QuestHelper_Pref.hide then
QuestHelper:HideTracker()
local function ShouldTrackingBeEnabled(yn)
DEFAULT_CHAT_FRAME:AddMessage("Tracking not currently available.")
if yn then
-- QuestHelper:ShowTracker() -- to respect the minimized setting
else
QuestHelper:ShowTracker() -- to respect the minimized setting
-- QuestHelper:HideTracker()
end
--]]
end
local self = QuestHelper -- whee hack hack hack
QuestHelper_Loadtime["init2_start"] = GetTime()
local function FileCheck()
local file_problem_version = false
local expected_version = GetAddOnMetadata("QuestHelper", "Version")
-- Why are we checking to make sure these files load?
-- Most if not all are named in the toc file.
-- Duh... There's a lot of files, ergo a method to make sure all expected files have been named in the toc file and check for files that are unexpected too.
local expected_files =
{
["bst_pre.lua"] = true,
@ -167,6 +137,8 @@ QH_Event("ADDON_LOADED", function (addonid)
["manager_completed.lua"] = true,
-- ["upgrade.lua"] = true,
["pref.lua"] = true,
["vars.lua"] = true,
["main.lua"] = true,
["recycle.lua"] = true,
["objective.lua"] = true,
@ -244,7 +216,7 @@ QH_Event("ADDON_LOADED", function (addonid)
["AstrolabeQH/Astrolabe.lua"] = true,
["AstrolabeQH/AstrolabeMapMonitor.lua"] = true,
}
local uninstallederr = ""
for file, version in pairs(QuestHelper_File) do
@ -278,6 +250,10 @@ QH_Event("ADDON_LOADED", function (addonid)
-- Don't need this table anymore.
QuestHelper_File = nil
return uninstallederr, file_problem_version
end
local function FinalProblemChecks(uninstallederr, file_problem_version)
if QuestHelper_StaticData and not QuestHelper_StaticData[GetLocale()] then
local errmsg = "Static data does not seem to exist"
DEFAULT_CHAT_FRAME:AddMessage(errmsg)
@ -307,6 +283,29 @@ QH_Event("ADDON_LOADED", function (addonid)
return
end
return true
end
function QuestHelper_AddonLoadedHandler(addonid)
if addonid ~= "QuestHelper" then return end
-- ONLY FAST STUFF ALLOWED IN HERE
QH_QueryQuestsCompleted
-- Use DefaultPref as fallback for unset preference keys.
setmetatable(QuestHelper_Pref, {__index=QuestHelper_DefaultPref})
QuestHelper: Assert(QuestHelper_Pref.perfload_scale) -- if this fails, something is very botched
ShouldTrackingBeEnabled(QuestHelper_Pref.track and not QuestHelper_Pref.hide)
local self = QuestHelper -- whee hack hack hack
QuestHelper_Loadtime["init2_start"] = GetTime()
-- File Check
local uninstallederr, file_problem_version = FileCheck()
if not FinalProblemChecks(uninstallederr, file_problem_version) then return end -- Something is borked.
QuestHelper_ErrorCatcher_CompletelyStarted()
if not QuestHelper_StaticData then
@ -317,8 +316,11 @@ QH_Event("ADDON_LOADED", function (addonid)
QHFormatSetLocale(QuestHelper_Pref.locale or GetLocale())
if not QuestHelper_UID then
QuestHelper_UID = self:CreateUID()
if not QuestHelper_UID and not QuestHelper_Collector.UID then
QuestHelper_Collector.UID = self:CreateUID()
elseif QuestHelper_UID then
QuestHelper_Collector.UID = QuestHelper_UID
QuestHelper_UID = nil -- We are moving this into Collector.
end
QuestHelper_SaveDate = time()
@ -534,8 +536,9 @@ QH_Event("ADDON_LOADED", function (addonid)
end, "preinit")
QuestHelper_Loadtime["init2_end"] = GetTime()
end)
end
QH_Event("ADDON_LOADED", QuestHelper_AddonLoadedHandler)
--[==[
function QuestHelper:OnEvent(event)

Voir le fichier

@ -3,7 +3,7 @@ QuestHelper_Loadtime["pref.lua"] = GetTime()
QuestHelper_Pref = {}
local QuestHelper_DefaultPref = {
QuestHelper_DefaultPref = {
filter_level = true,
filter_zone = false,
filter_done = false,

Voir le fichier

@ -10,4 +10,29 @@ QuestHelper_FlightInstructors = {}
QuestHelper_FlightLinks = {}
QuestHelper_FlightRoutes = {}
QuestHelper_KnownFlightRoutes = {}
QuestHelper_SeenRealms = {}
QuestHelper_SeenRealms = {}
-- Just to make sure it's always 'seen' (there's nothing that can be seen, but still...), and therefore always updating.
QuestHelper:SetFrameStrata("TOOLTIP")
QuestHelper.tooltip = CreateFrame("GameTooltip", "QuestHelperTooltip", nil, "GameTooltipTemplate")
QuestHelper.objective_objects = {}
QuestHelper.user_objectives = {}
QuestHelper.quest_objects = {}
QuestHelper.player_level = 1
QuestHelper.locale = QuestHelper_Locale
QuestHelper.faction = UnitFactionGroup("player")
--[[ assert(QuestHelper.faction) ]]
QuestHelper.font = {serif=GameFontNormal:GetFont(), sans=ChatFontNormal:GetFont(), fancy=QuestTitleFont:GetFont()}
QuestHelper.route = {}
QuestHelper.to_add = {}
QuestHelper.to_remove = {}
QuestHelper.quest_log = {}
QuestHelper.pos = {nil, {}, 0, 0, 1, "You are here.", 0}
QuestHelper.sharing = false -- Will be set to true when sharing with at least one user.
QHQuestsCompleted = false