Skip to content

Commit

Permalink
8.3.04.3
Browse files Browse the repository at this point in the history
Added confirmation setting buttons
Added reset option for profiles
Prioritize xp reward over xp item
  • Loading branch information
LanceDH committed Jun 15, 2020
1 parent c8813cd commit 4dc42a2
Show file tree
Hide file tree
Showing 8 changed files with 304 additions and 55 deletions.
27 changes: 14 additions & 13 deletions Data.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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"]
Expand Down Expand Up @@ -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."
}
Expand Down
15 changes: 11 additions & 4 deletions Dataprovider.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Locals.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
62 changes: 41 additions & 21 deletions Profiles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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];
Expand Down Expand Up @@ -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



73 changes: 66 additions & 7 deletions Settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
--------------------------------
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down
Loading

0 comments on commit 4dc42a2

Please sign in to comment.