diff --git a/Data.lua b/Data.lua index 48e69ae..34a8e25 100644 --- a/Data.lua +++ b/Data.lua @@ -393,16 +393,7 @@ _V["SETTING_LIST"] = { end WQT_Profiles:Load(arg1); - WQT_WorldQuestFrame:UpdateBountyCounters(); - WQT_WorldQuestFrame:RepositionBountyTabs(); - WQT_WorldQuestFrame.pinDataProvider:RefreshAllData() - if (value) then - WQT_Utils:RefreshOfficialDataProviders(); - end - WQT_QuestScrollFrame:UpdateQuestList(); - WQT:Sort_OnClick(nil, WQT.settings.general.sortBy); - WQT_WorldMapContainerButton:LinkSettings(WQT.settings.general.fullScreenButtonPos); - WQT_WorldMapContainer:LinkSettings(WQT.settings.general.fullScreenContainerPos); + WQT_WorldQuestFrame:ApplyAllSettings(); end ,["getValueFunc"] = function() return WQT_Profiles:GetIndexById(WQT.db.char.activeProfile) end } @@ -420,11 +411,18 @@ _V["SETTING_LIST"] = { WQT_Profiles:CreateNew(); end } - ,{["template"] = "WQT_SettingButtonTemplate", ["categoryID"] = "PROFILES", ["label"] =_L["REMOVE_PROFILE"], ["tooltip"] = _L["REMOVE_PROFILE_TT"] + ,{["template"] = "WQT_SettingConfirmButtonTemplate", ["categoryID"] = "PROFILES", ["label"] =_L["RESET_PROFILE"], ["tooltip"] = _L["RESET_PROFILE_TT"] , ["valueChangedFunc"] = function(value) - WQT_Profiles:Delete( WQT_Profiles:GetActiveProfileId()); + WQT_Profiles:ResetActive(); + WQT_WorldQuestFrame:ApplyAllSettings(); end - ,["isDisabled"] = function() return WQT_Profiles:DefaultIsActive() end + } + ,{["template"] = "WQT_SettingConfirmButtonTemplate", ["categoryID"] = "PROFILES", ["label"] =_L["REMOVE_PROFILE"], ["tooltip"] = _L["REMOVE_PROFILE_TT"] + , ["valueChangedFunc"] = function(value) + WQT_Profiles:Delete(WQT_Profiles:GetActiveProfileId()); + WQT_WorldQuestFrame:ApplyAllSettings(); + end + ,["isDisabled"] = function() return WQT_Profiles:DefaultIsActive() end } -- General settings ,{["template"] = "WQT_SettingCheckboxTemplate", ["categoryID"] = "GENERAL", ["label"] = _L["DEFAULT_TAB"], ["tooltip"] = _L["DEFAULT_TAB_TT"] @@ -1040,6 +1038,9 @@ _V["PATCH_NOTES"] = { ,["new"] = { "Added support for setting profiles, allowing people to have different settings for different characters." } + ,["changes"] = { + "Dropdown menus can now be opened by clicking anywhere on the dropdown button, rather than just the arrow on the right." + } ,["fixes"] = { "Fixed content on the full screen map not being constrained to the map area." } diff --git a/Dataprovider.lua b/Dataprovider.lua index 388968d..3f196f0 100644 --- a/Dataprovider.lua +++ b/Dataprovider.lua @@ -145,6 +145,7 @@ end local function SetQuestRewards(questInfo) local haveData = HaveQuestRewardData(questInfo.questId); + local hasAddedExperience = false; if haveData then -- Setup default for no reward @@ -159,7 +160,8 @@ local function SetQuestRewards(questInfo) -- Items if (GetNumQuestLogRewards(questInfo.questId) > 0) then local _, texture, numItems, quality, _, rewardId, ilvl = GetQuestLogRewardInfo(1, questInfo.questId); - if rewardId then + + if (rewardId) then local price, typeID, subTypeID = select(11, GetItemInfo(rewardId)); if (typeID == 4 or typeID == 2) then -- Gear (4 = armor, 2 = weapon) local canUpgrade = ScanTooltipRewardForPattern(questInfo.questId, "(%d+%+)$") and true or false; @@ -172,10 +174,15 @@ local function SetQuestRewards(questInfo) AddQuestReward(questInfo, WQT_REWARDTYPE.relic, numItems, texture, quality, _V["WQT_COLOR_RELIC"], rewardId); else -- Normal items - if (typeID == 0 and subTypeID == 8 and price == 0 and ilvl > 100) then + if (texture == 894556 and GetQuestLogRewardXP(questInfo.questId)) then + -- Player experience + local numItems = GetQuestLogRewardXP(questInfo.questId); + AddQuestReward(questInfo, WQT_REWARDTYPE.xp, numItems, texture, 1, _V["WQT_COLOR_ITEM"]); + hasAddedExperience = true; + elseif (typeID == 0 and subTypeID == 8 and price == 0 and ilvl > 100) then -- Item converting into equipment AddQuestReward(questInfo, WQT_REWARDTYPE.equipment, ilvl, texture, quality, _V["WQT_COLOR_ARMOR"], rewardId); - else + else AddQuestReward(questInfo, WQT_REWARDTYPE.item, numItems, texture, quality, _V["WQT_COLOR_ITEM"], rewardId); end end @@ -217,7 +224,7 @@ local function SetQuestRewards(questInfo) end end -- Player experience - if haveData and GetQuestLogRewardXP(questInfo.questId) > 0 then + if (not hasAddedExperience and GetQuestLogRewardXP(questInfo.questId) > 0) then local numItems = GetQuestLogRewardXP(questInfo.questId); AddQuestReward(questInfo, WQT_REWARDTYPE.xp, numItems, 894556, 1, _V["WQT_COLOR_ITEM"]); end diff --git a/Locals.lua b/Locals.lua index 000626c..da65bf6 100644 --- a/Locals.lua +++ b/Locals.lua @@ -123,6 +123,8 @@ L["NEW_PROFILE"] = "New Profile" L["NEW_PROFILE_TT"] = "Create a new profile based on the current settings." L["REMOVE_PROFILE"] = "Remove Profile" L["REMOVE_PROFILE_TT"] = "Remove the currently active profile." +L["RESET_PROFILE"] = "Reset Profile" +L["RESET_PROFILE_TT"] = "Reset the currently active profile to standard settings." if locale == "deDE" then L["COMBATLOCK"] = "Nicht verfügbar während eines Kampfes." diff --git a/Profiles.lua b/Profiles.lua index a143fb1..ce4c730 100644 --- a/Profiles.lua +++ b/Profiles.lua @@ -8,11 +8,6 @@ local WQT_Profiles = addon.WQT_Profiles; local _profileReferenceList = {}; - --- TODO - --- Make active profile per character - local function ReferenceListSort(a, b) -- Default always on top, and in case of duplicate labels if (a.arg1 == 0 or b.arg1 == 0) then @@ -31,6 +26,19 @@ local function ReferenceListSort(a, b) return a.label:lower() < b.label:lower(); end +local function ClearDefaults(a, b) + for k, v in pairs(b) do + if (type(a[k]) == "table" and type(v) == "table") then + ClearDefaults(a[k], v); + if (next(a[k]) == nil) then + a[k] = nil; + end + elseif (a[k] ~= nil and a[k] == v) then + a[k] = nil; + end + end +end + local function ProfileNameIsAvailable(name) for k, v in pairs(WQT.db.global.profiles) do if (v.name == name) then @@ -40,6 +48,16 @@ local function ProfileNameIsAvailable(name) return true; end +local function ForceCopy(a, b) + for k, v in pairs(b) do + if (type(v) == "table") then + ForceCopy(a[k], v); + else + a[k] = v; + end + end +end + local function CopyIfNil(a, b) for k, v in pairs(b) do local curVal = a[k]; @@ -286,28 +304,30 @@ function WQT_Profiles:GetActiveProfileName() return profile and profile.name or "Invalid Profile"; end -local function test(a, b) - for k, v in pairs(b) do - if (type(a[k]) == "table" and type(v) == "table") then - test(a[k], v); - if (next(a[k]) == nil) then - a[k] = nil; - end - elseif (a[k] ~= nil and a[k] == v) then - a[k] = nil; - end - end -end + function WQT_Profiles:ClearDefaultsFromActive() local category = "general"; - test(WQT.settings[category], _V["WQT_DEFAULTS"].global[category]); + ClearDefaults(WQT.settings[category], _V["WQT_DEFAULTS"].global[category]); category = "list"; - test(WQT.settings[category], _V["WQT_DEFAULTS"].global[category]); + ClearDefaults(WQT.settings[category], _V["WQT_DEFAULTS"].global[category]); category = "pin"; - test(WQT.settings[category], _V["WQT_DEFAULTS"].global[category]); + ClearDefaults(WQT.settings[category], _V["WQT_DEFAULTS"].global[category]); category = "filters"; - test(WQT.settings[category], _V["WQT_DEFAULTS"].global[category]); + ClearDefaults(WQT.settings[category], _V["WQT_DEFAULTS"].global[category]); end +function WQT_Profiles:ResetActive() + local category = "general"; + ForceCopy(WQT.settings[category], _V["WQT_DEFAULTS"].global[category]); + category = "list"; + ForceCopy(WQT.settings[category], _V["WQT_DEFAULTS"].global[category]); + category = "pin"; + ForceCopy(WQT.settings[category], _V["WQT_DEFAULTS"].global[category]); + category = "filters"; + ForceCopy(WQT.settings[category], _V["WQT_DEFAULTS"].global[category]); +end + + + diff --git a/Settings.lua b/Settings.lua index b481086..9078be8 100644 --- a/Settings.lua +++ b/Settings.lua @@ -53,7 +53,7 @@ function WQT_SettingsBaseMixin:Init(data) self.DisabledOverlay:SetFrameLevel(self:GetFrameLevel() + 2) end - self:UpdateState(); + --self:UpdateState(); end function WQT_SettingsBaseMixin:Reset() @@ -299,8 +299,9 @@ function WQT_SettingsDropDownMixin:OnLoad() self.DropDown = ADD:CreateMenuTemplate(nil, self, nil, "BUTTON"); self.DropDown:SetSize(150, 22); self.DropDown:SetPoint("BOTTOMLEFT", self, 27, 0); + self.DropDown:SetPoint("RIGHT", self, -35, 0); + self.DropDown.Text:SetJustifyH("LEFT"); self.DropDown:EnableMouse(true); - self.DropDown:SetScript("OnClick", function() PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON); end); self.DropDown:SetScript("OnEnter", function() self:OnEnter(self.DropDown) end); self.DropDown:SetScript("OnLeave", function() self:OnLeave() end); end @@ -397,6 +398,61 @@ function WQT_SettingsButtonMixin:Init(data) self:UpdateState(); end +-------------------------------- +-- WQT_SettingsConfirmButtonMixin +-------------------------------- + +WQT_SettingsConfirmButtonMixin = CreateFromMixins(WQT_SettingsBaseMixin); + +function WQT_SettingsConfirmButtonMixin:OnLoad() + self.Label = self.Button.Label; +end + +function WQT_SettingsConfirmButtonMixin:SetDisabled(value) + WQT_SettingsBaseMixin.SetDisabled(self, value); + if (value) then + self.Button:Disable(); + else + self.Button:Enable(); + end +end + +function WQT_SettingsConfirmButtonMixin:Init(data) + WQT_SettingsBaseMixin.Init(self, data); +end + +function WQT_SettingsConfirmButtonMixin:UpdateState() + WQT_SettingsBaseMixin.UpdateState(self); + local width = (self:GetWidth() - 67) / 2; + self.ButtonConfirm:SetWidth(width); + + if (self.isPicking == true) then + self.Button:Show(); + self.ButtonConfirm:Hide(); + self.ButtonDecline:Hide(); + self.isPicking = false; + end +end + +function WQT_SettingsConfirmButtonMixin:OnValueChanged(value, userInput) + self:SetPickingState(false); + WQT_SettingsBaseMixin.OnValueChanged(self, value, userInput); +end + +function WQT_SettingsConfirmButtonMixin:SetPickingState(isPicking) + self.isPicking = isPicking; + if (self.isPicking) then + self.Button:Hide(); + self.ButtonConfirm:Show(); + self.ButtonDecline:Show(); + return; + end + + self.Button:Show(); + self.ButtonConfirm:Hide(); + self.ButtonDecline:Hide(); +end + -------------------------------- -- WQT_SettingsTextInputMixin -------------------------------- @@ -489,11 +545,11 @@ function WQT_SettingsFrameMixin:SetCategoryExpanded(id, value) category.ExpandIcon:SetAtlas("friendslist-categorybutton-arrow-down", true); -- Update states - for k2, setting in ipairs(category.settings) do - if (setting.UpdateState) then - setting:UpdateState(); - end - end + --for k2, setting in ipairs(category.settings) do + -- if (setting.UpdateState) then + -- setting:UpdateState(); + -- end + --end else category.ExpandIcon:SetAtlas("friendslist-categorybutton-arrow-right", true); end @@ -634,6 +690,9 @@ function WQT_SettingsFrameMixin:PlaceSetting(setting) end setting:SetPoint("RIGHT", self.ScrollFrame.ScrollChild); setting:Show(); + if (setting.UpdateState) then + setting:UpdateState(); + end self.previous = setting; self.totalHeight = self.totalHeight + setting:GetHeight(); diff --git a/Settings.xml b/Settings.xml index 4f8271d..022b4d1 100644 --- a/Settings.xml +++ b/Settings.xml @@ -247,9 +247,10 @@ + + + + + + + + + + + @@ -348,6 +489,7 @@ + \ No newline at end of file diff --git a/WorldQuestTab.lua b/WorldQuestTab.lua index 9c2ed45..da2c691 100644 --- a/WorldQuestTab.lua +++ b/WorldQuestTab.lua @@ -4,24 +4,24 @@ -- questId [number] questId -- isAllyQuest [boolean] is a quest for combat allies (Nazjatar) -- isDaily [boolean] is a daily type quest (Nazjatar & threat quests) --- isCriteria [boolean] is part of currently selected amissary +-- isCriteria [boolean] is part of currently selected emissary -- alwaysHide [boolean] If the quest should be hidden no matter what -- passedFilter [boolean] passed current filters -- isValid [boolean] true if the quest is valid. Quest are invalid when they are missing quest data -- time [table] time related values -- seconds [number] seconds remaining when the data was gathered (To check the difference between no time and expired time) --- mapInfo [table] zone related values +-- mapInfo [table] zone related values, for more accurate position use WQT_Utils:GetQuestMapLocation -- mapX [number] x pin position -- mapY [number] y pin position -- reward [table] reward related values --- type [number] type of the more valueable reward (and the one displayed). See WQT_REWARDTYPE in Data.lua +-- type [number] type of the most valueable reward (and the one displayed). See WQT_REWARDTYPE in Data.lua -- texture [number/string] texture of the reward. can be string for things like gold or unknown reward -- amount [amount] amount of items, gold, rep, or item level -- id [number, nullable] itemId for reward. null if not an item -- quality [number] item quality; common, rare, epic, etc -- canUpgrade [boolean, nullable] true if item has a chance to upgrade (e.g. ilvl 285+) -- color [Color] color based on the type of reward --- typeBits [bitfield] a combination of flags for all the types of rewards the quest provides. I.e. AP + gold + rep = 2^3 + 2^6 + 2^9 = 584 (10 0100 1000‬) +-- typeBits [bitfield] a combination of flags for all the types of rewards the quest provides. I.e. AP + gold + rep = 2^3 + 2^6 + 2^9 = 584 (1001001000‬) -- -- For other data use following functions @@ -33,6 +33,7 @@ -- local tagID, tagName, worldQuestType, rarity, isElite, tradeskillLineIndex, displayTimeLeft = GetQuestTagInfo(questId); -- local texture, sizeX, sizeY = WQT_Utils:GetCachedTypeIconData(worldQuestType, tradeskillLineIndex); -- local timeLeftSeconds, timeString, color, timeStringShort, category = WQT_Utils:GetQuestTimeString(questInfo, fullString, unabreviated); +-- local x, y = WQT_Utils:GetQuestMapLocation(questId, mapId); | More up to date position than mapInfo -- -- Callbacks (WQT_WorldQuestFrame:RegisterCallback(event, func)) @@ -69,8 +70,6 @@ local _utilitiesInstalled = not utilitiesStatus or utilitiesStatus ~= "MISSING"; local _WFMLoaded = IsAddOnLoaded("WorldFlightMap"); - - -- Custom number abbreviation to fit inside reward icons in the list. local function GetLocalizedAbbreviatedNumber(number) if type(number) ~= "number" then return "NaN" end; @@ -1783,8 +1782,6 @@ function WQT_CoreMixin:OnLoad() self.sortButton = ADD:CreateMenuTemplate("WQT_WorldQuestFrameSortButton", self, nil, "BUTTON"); self.sortButton:SetSize(110, 22); self.sortButton:SetPoint("RIGHT", "WQT_WorldQuestFrameFilterButton", "LEFT", -2, -1); - self.sortButton:EnableMouse(false); - self.sortButton:SetScript("OnClick", function() PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON); end); ADD:Initialize(self.sortButton, function(self, level) WQT:InitSort(self, level) end); @@ -2088,6 +2085,19 @@ function WQT_CoreMixin:OnLoad() end +function WQT_CoreMixin:ApplyAllSettings() + self:UpdateBountyCounters(); + self:RepositionBountyTabs(); + self.pinDataProvider:RefreshAllData() + if (value) then + WQT_Utils:RefreshOfficialDataProviders(); + end + WQT_QuestScrollFrame:UpdateQuestList(); + WQT:Sort_OnClick(nil, WQT.settings.general.sortBy); + WQT_WorldMapContainerButton:LinkSettings(WQT.settings.general.fullScreenButtonPos); + WQT_WorldMapContainer:LinkSettings(WQT.settings.general.fullScreenContainerPos); +end + function WQT_CoreMixin:UpdateBountyCounters() self.bountyCounterPool:ReleaseAll(); if (not WQT.settings.general.bountyCounter) then return end diff --git a/libs/AddonDropDown-1.0/AddonDropDownTemplates-1.0.lua b/libs/AddonDropDown-1.0/AddonDropDownTemplates-1.0.lua index 0b87922..fa980f5 100644 --- a/libs/AddonDropDown-1.0/AddonDropDownTemplates-1.0.lua +++ b/libs/AddonDropDown-1.0/AddonDropDownTemplates-1.0.lua @@ -1,4 +1,4 @@ -local MAJOR, MINOR = "AddonDropDownTemplates-1.0", 8 +local MAJOR, MINOR = "AddonDropDownTemplates-1.0", 9 local ADDT, oldminor = LibStub:NewLibrary(MAJOR, MINOR) if not ADDT then return end -- No Upgrade needed. @@ -310,6 +310,7 @@ function ADDT:CreateMenuTemplate(lib, name, parent, id, frameType) fontString:SetJustifyH("RIGHT"); fontString:SetSize(0, 10); fontString:SetPoint("RIGHT", button.Right, "RIGHT", -43, 2); + fontString:SetPoint("LEFT", button.Left, "LEFT", 28, 2); --parentIcon tex = button:CreateTexture(nil, "OVERLAY"); button.Icon = tex; @@ -376,6 +377,13 @@ function ADDT:CreateMenuTemplate(lib, name, parent, id, frameType) button.Text:SetVertexColor(DISABLED_FONT_COLOR:GetRGB()); button.Button:Disable(); end); + + if (frameType == "BUTTON") then + button:SetScript("OnClick", function(self) + lib:ToggleDropDownMenu(nil, nil, button); + PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON); + end); + end return button; end