Skip to content

Commit

Permalink
1.5.2 (Pre)
Browse files Browse the repository at this point in the history
-New Module: Group Inviter Info
- Added Quick Slot API for third-party devs
  • Loading branch information
Peterodox committed Dec 24, 2024
1 parent efd139b commit d9780e5
Show file tree
Hide file tree
Showing 22 changed files with 887 additions and 95 deletions.
24 changes: 24 additions & 0 deletions API.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,21 @@ do -- Table
return tbl
end
API.ReverseList = ReverseList;

local function CopyTable(tbl)
--Blizzard TableUtil.lua
if not tbl then return; end;
local copy = {};
for k, v in pairs(tbl) do
if type(v) == "table" then
copy[k] = CopyTable(v);
else
copy[k] = v;
end
end
return copy;
end
API.CopyTable = CopyTable;
end

do -- String
Expand Down Expand Up @@ -131,6 +146,15 @@ do -- String
return obj
end
API.GetGlobalObject = GetGlobalObject;

local function JoinText(delimiter, l, r)
if l and r then
return l..delimiter..r
else
return l or r
end
end
API.JoinText = JoinText;
end

do -- DEBUG
Expand Down
Binary file added Art/ControlCenter/Preview_PartyInviterInfo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Art/GossipIcons/MagnifyingGlass.tga
Binary file not shown.
4 changes: 4 additions & 0 deletions ControlCenter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,10 @@ local function CreateUI()
if a.uiOrder ~= b.uiOrder then
return a.uiOrder < b.uiOrder
--should be finished here
else
if (a.categoryID == b.categoryID) and (a ~= b) then
print("Plumber: Duplicated Module uiOrder", a.uiOrder, a.name, b.name);
end
end

return a.name < b.name
Expand Down
3 changes: 3 additions & 0 deletions Initialization.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ local DefaultValues = {
SpellcastingInfo = false, --Show the spell info when hovering over target/focus cast bars. Logging target spells and displayed it on UnitPopupMenu
ChatOptions = true, --Add Leave button to Channel Context Menu
NameplateWidget = true, --Show required items on nameplate widget set
PartyInviterInfo = false, --Show the inviter's level and class
PartyInviter_Race = false,
PartyInviter_Faction = false,


--Custom Loot Window
Expand Down
19 changes: 19 additions & 0 deletions Locales/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,17 @@ L["ModuleName NameplateWidget"] = "Nameplate: Keyflame";
L["ModuleDescription NameplateWidget"] = "Show the number of owned Radiant Remnant on the nameplate.";


--PartyInviterInfo
L["ModuleName PartyInviterInfo"] = "Group Inviter Info";
L["ModuleDescription PartyInviterInfo"] = "Show the inviter's level and class when you are invited to a group or a guild.";
L["Additional Info"] = "Additional Info";
L["Race"] = RACE or "Race";
L["Faction"] = FACTION or "Faction";
L["Click To Search Player"] = "Search This Player";
L["Searching Player In Progress"] = FRIENDS_FRIENDS_WAITING or "Searching...";
L["Player Not Found"] = ERR_FRIEND_NOT_FOUND or "Player not found.";


--Loot UI
L["ModuleName LootUI"] = HUD_EDIT_MODE_LOOT_FRAME_LABEL or "Loot Window";
L["ModuleDescription LootUI"] = "Replace the default Loot Window and provide some optional features:\n\n- Loot items fast.\n\n- Fix Auto Loot failure bug.\n\n- Show a Take All button when looting manually.";
Expand Down Expand Up @@ -277,6 +288,14 @@ L["LootUI Option Use Default UI"] = "Use Default Loot Window";
L["LootUI Option Use Default UI Tooltip"] = "Use WoW\'s default loot window.\n\n|cffff4800Enabling this option nullifies all settings above.|r";



--Quick Slot For Third-party Dev
L["Quickslot Module Info"] = "Module Info";
L["QuickSlot Error 1"] = "Quick Slot: You have already added this controller.";
L["QuickSlot Error 2"] = "Quick Slot: The controller is missing \"%s\"";
L["QuickSlot Error 3"] = "Quick Slot: A controller with the same key \"%s\" already exists.";


--Generic
L["Reposition Button Horizontal"] = "Move Horizontally"; --Move the window horizontally
L["Reposition Button Vertical"] = "Move Vertically";
Expand Down
11 changes: 11 additions & 0 deletions Locales/zhCN.lua
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,17 @@ L["ModuleName NameplateWidget"] = "姓名版: 钥焰";
L["ModuleDescription NameplateWidget"] = "在钥焰的姓名版进度条上显示你拥有的光耀残渣的数量。";


--PartyInviterInfo
L["ModuleName PartyInviterInfo"] = "队伍邀请人信息";
L["ModuleDescription PartyInviterInfo"] = "显示队伍以及公会邀请人的等级、职业等信息。";
L["Additional Info"] = "额外信息";
L["Race"] = "种族";
L["Faction"] = "阵营";
L["Click To Search Player"] = "搜索此玩家";
L["Searching Player In Progress"] = "搜索中...";
L["Player Not Found"] = "未找到玩家。";


--Loot UI
L["ModuleName LootUI"] = "拾取窗口";
L["ModuleDescription LootUI"] = "替换默认的拾取窗口并提供以下功能:\n\n- 快速拾取所有物品\n\n- 修复自动拾取有时失效的问题\n\n- 手动拾取时显示“全部拾取”按钮";
Expand Down
6 changes: 6 additions & 0 deletions Modules/ChatOptions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ function ChatOptions:Hook()
ChatOptions:SetAutoLeaveChannel(channelID, true);
end;
};

ChatOptions:SetupStaticPopup();
StaticPopup_Show(STATIC_POPUP_WHICH, nil, nil, data);
end
end
Expand Down Expand Up @@ -135,7 +137,11 @@ function ChatOptions:Hook()
end
end);
end
end

function ChatOptions:SetupStaticPopup()
if self.popupInserted then return end;
self.popupInserted = true;
if StaticPopupDialogs then
StaticPopupDialogs[STATIC_POPUP_WHICH] = {
text = "", -- supplied dynamically.
Expand Down
33 changes: 26 additions & 7 deletions Modules/Lockpicking.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ if classID ~= 4 and raceID ~= 37 then return end;
local API = addon.API;
local IsWarningColor = API.IsWarningColor;

local _G = _G;
local InCombatLockdown = InCombatLockdown;
local IsSpellKnown = IsSpellKnown;
local SpellIsTargeting = SpellIsTargeting;
Expand All @@ -26,6 +27,7 @@ local SPELL_ID_PICK_LOCK = ((classID == 4) and 1804) or (312890); --Rogue: Lo
local SPELL_NAME_PICK_LOCK = nil; --Localized with GetSpellInfo
local INSTRUCTION_PICK_LOCK = addon.L["Instruction Pick Lock"];
local NOT_TRADED_ITEM_SLOT_INDEX = 7; --TRADE_ENCHANT_SLOT
local TOOLTIP_DATA_TYPE = Enum.TooltipDataType and Enum.TooltipDataType.Item or 0;


local MODULE_ENABLED = false;
Expand Down Expand Up @@ -298,10 +300,16 @@ local function SetupActionButton(bag, slot, tradeItem)
return ActionButton
end

local function IsMouseoverItemLocked()
local function IsMouseoverItemLocked(lineIndex)
local toIndex;
if lineIndex then
toIndex = 2;
else
toIndex = TooltipFrame:NumLines();
end
local line;
for i = 2, 3 do
line = TooltipFrame["TextLeft"..i];
for i = 2, toIndex do
line = _G["GameTooltipTextLeft"..i];
if line and line:GetText() == TEXT_LOCKED then
local r, g, b = line:GetTextColor();
if IsWarningColor(r, g, b) then
Expand Down Expand Up @@ -371,15 +379,26 @@ function Processor:ProcessItem()
if info.getterName == "GetBagItem" then
local bag, slot = info.getterArgs[1], info.getterArgs[2];
if bag and slot then
if IsMouseoverItemLocked() then
SetupButtonAndTooltip(bag, slot);
return
local tooltipData = TooltipFrame.infoList and TooltipFrame.infoList[1] and TooltipFrame.infoList[1].tooltipData;
if tooltipData and tooltipData.type == TOOLTIP_DATA_TYPE then
local itemID = tooltipData.id;
local lineIndex;
if itemID == 220376 then
--Bismuth Lockbox can have upgrade track on its item tooltip
else
lineIndex = 2;
end
if IsMouseoverItemLocked(lineIndex) then
SetupButtonAndTooltip(bag, slot);
return
end
end
end
elseif info.getterName == "GetTradeTargetItem" then
local tradeSlotIndex = info.getterArgs[1];
if tradeSlotIndex and tradeSlotIndex == NOT_TRADED_ITEM_SLOT_INDEX then
if IsMouseoverItemLocked() then
local lineIndex = 2;
if IsMouseoverItemLocked(lineIndex) then
SetupButtonAndTooltip(nil, nil, true);
return
end
Expand Down
2 changes: 1 addition & 1 deletion Modules/LootUI_Display.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1675,7 +1675,7 @@ do


local function OptionToggle_OnClick(self, button)
if MainFrame.OptionFrame and MainFrame.OptionFrame:IsShown() then
if MainFrame.OptionFrame and MainFrame.OptionFrame:IsShown() and (MainFrame.OptionFrame:IsOwner(self) or MainFrame.OptionFrame:IsOwner(MainFrame)) then
MainFrame:ShowOptions(false);
MainFrame:ExitEditMode();
else
Expand Down
1 change: 0 additions & 1 deletion Modules/NameplateResources.lua
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ local function EnableModule(state)
end

do

local moduleData = {
name = addon.L["ModuleName NameplateWidget"],
dbKey = "NameplateWidget",
Expand Down
24 changes: 21 additions & 3 deletions Modules/QuickSlot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,23 @@ local function RealActionButton_PostClick(self, button)
menu:SetOwner(owner);
menu:ClearAllPoints();
menu:SetPoint("LEFT", owner, "RIGHT", 12, 0);
menu:SetContent(ContextMenuData);

local menuData;
if QuickSlot.buttonData.developerInfo then
menuData = API.CopyTable(ContextMenuData);
tinsert(menuData, {
type = "divider",
});
tinsert(menuData, {
--type == "info",
color = {0.5, 0.5, 0.5},
text = L["Quickslot Module Info"];
tooltip = QuickSlot.buttonData.developerInfo,
});
else
menuData = ContextMenuData;
end
menu:SetContent(menuData);
menu:Show();
end
end
Expand Down Expand Up @@ -341,15 +357,17 @@ local function ItemButton_OnEnter(self)

local macroText;
if self.onClickFunc then

elseif self.macroText then
macroText = self.macroText;
else
if self.actionType == "item" then
macroText = string.format("/use item:%s", self.id);
elseif self.actionType == "spell" then
local spellName = C_Spell.GetSpellName(self.id);
macroText = string.format("/cast %s", spellName);
if spellName then
macroText = string.format("/cast %s", spellName);
end
end
end
RealActionButton:SetAttribute("type1", "macro");
Expand Down
4 changes: 4 additions & 0 deletions Modules/QuickSlot.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/..\FrameXML\UI.xsd">
<Script file="QuickSlot.lua"/>
<Script file="QuickSlot_External.lua"/>
</Ui>
122 changes: 122 additions & 0 deletions Modules/QuickSlot_External.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
--Global API for 3rd-party devs

local _, addon = ...
local L = addon.L;
local API = addon.API;
local QuickSlot = addon.QuickSlot;
local GetSpellName = C_Spell.GetSpellName;


local CustomControllers = {};

local ControllerMixin = {};

do --ControllerMixin
--[[
ControllerMixin = {
key = "key",
title = "Module Name",
showError = false,
spellcastType = 0, --1:Cast 2:Channel
developerInfo = "What does this module do. Developed by Whom";
buttons = {
{actionType = "spell", spellID = 0, icon = 134400, name = "Custom Name", onClickFunc = Nop, enabled = true},
{actionType = "item", itemID = 208067, spellID = 417645},
},
};
--]]

function ControllerMixin:ShowQuickSlot(forceUpdate)
if forceUpdate then
QuickSlot.buttonData = nil;
else
if QuickSlot.buttonData == self and QuickSlot:IsShown() then
return
end
end
QuickSlot:SetButtonData(self);
QuickSlot:ShowUI();
QuickSlot:SetHeaderText(self.title, true);
QuickSlot:SetDefaultHeaderText(self.title);
end

function ControllerMixin:HideQuickSlot()
QuickSlot:RequestCloseUI(self.key);
end
end

local function AddQuickSlotController(controller)
local showError = controller.showError or false;

if CustomControllers[controller] ~= nil then
if showError then
API.PrintMessage(L["QuickSlot Error 1"]);
end
return false
end

local valid = true;
local requiredKeys = {
"key", "buttons", "developerInfo",
};

for _, k in ipairs(requiredKeys) do
if not controller[k] then
valid = false;
API.PrintMessage(L["QuickSlot Error 2"]:format(k));
end
end

if not valid then return end;

for c in pairs(CustomControllers) do
if c.key == controller.key then
API.PrintMessage(L["QuickSlot Error 3"]:format(controller.key));
return false
end
end

CustomControllers[controller] = true;
API.Mixin(controller, ControllerMixin);
controller.systemName = controller.key;

for _, v in ipairs(controller.buttons) do
if v.spellID then --Cache
GetSpellName(v.spellID);
end
end

return true
end

PlumberAPI_AddQuickSlotController = AddQuickSlotController;


do
--[[
local TestModule = {
key = "key",
title = nil,
showError = true,
spellcastType = 1,
developerInfo = "What does this module do. Developed by Whom",
buttons = {
{actionType = "spell", spellID = 2061, icon = nil, name = "Custom Name", onClickFunc = nil, enabled = true},
{actionType = "item", itemID = 208067, spellID = 417645},
},
};
PlumberAPI_AddQuickSlotController(TestModule);
local EL = CreateFrame("Frame");
EL:RegisterEvent("PLAYER_TARGET_CHANGED");
EL:SetScript("OnEvent", function()
if UnitExists("target") and UnitIsFriend("player", "target") then
TestModule:ShowQuickSlot();
else
TestModule:HideQuickSlot();
end
end);
--]]
end
Loading

0 comments on commit d9780e5

Please sign in to comment.