Skip to content

Commit

Permalink
feat: 添加一些设置
Browse files Browse the repository at this point in the history
  • Loading branch information
DengSir committed Sep 5, 2024
1 parent d0b89fd commit 6e91516
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 28 deletions.
1 change: 1 addition & 0 deletions .emmy/UI/Template.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ local tdInspectGearTalentTemplate = {}
---@field Portrait __tdInspectGearFrameTemplate_Portrait
---@field Talent1 __tdInspectGearFrameTemplate_Talent1
---@field Talent2 __tdInspectGearFrameTemplate_Talent2
---@field Option Button
local tdInspectGearFrameTemplate = {}

---@class tdInspectSocketItemTemplate : Button
Expand Down
16 changes: 16 additions & 0 deletions Addon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ function Addon:OnInitialize()
inspectGear = true,
inspectCompare = true,
showTalentBackground = true,
showOptionButtonInCharacter = true,
showOptionButtonInInspect = true,
},
}

Expand Down Expand Up @@ -143,6 +145,20 @@ function Addon:TDINSPECT_OPTION_CHANGED(_, key, value)
elseif self.InspectGearFrame then
self.InspectGearFrame:Hide()
end
elseif self.InspectGearFrame then
self.InspectGearFrame:Hide()
end
elseif key == 'inspectCompare' then
if value then
if InspectPaperDollFrame:IsShown() then
self:OpenInspectGearFrame()
end
elseif self.CharacterGearFrame then
self.CharacterGearFrame:Hide()

if self.CharacterGearParent:IsShown() then
self:OpenCharacterGearFrame()
end
end
end
end
Expand Down
16 changes: 10 additions & 6 deletions Api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,12 @@ function ns.GetItemEnchantInfo(link)
end

local GLYPH_SLOTS = {
[1] = { id = 21, level = 15 },
[2] = { id = 22, level = 15 },
[3] = { id = 23, level = 50 },
[4] = { id = 24, level = 30 },
[5] = { id = 25, level = 70 },
[6] = { id = 26, level = 80 },
[1] = {id = 21, level = 15},
[2] = {id = 22, level = 15},
[3] = {id = 23, level = 50},
[4] = {id = 24, level = 30},
[5] = {id = 25, level = 70},
[6] = {id = 26, level = 80},
}

function ns.GetGlyphSlotRequireLevel(slot)
Expand All @@ -183,3 +183,7 @@ function ns.GetGlyphSlotId(slot)
local d = GLYPH_SLOTS[slot]
return d and d.id
end

function ns.IsCanEnchant(item)
local itemEquipLoc = select(4, GetItemInfoInstant(item))
end
7 changes: 5 additions & 2 deletions Localization/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ L["Show talent background"] = true
-- @end-locale@
-- @debug@
-- @import:language=enUS@
--[====[ never used ]====]
--[====[ L['Show Model'] = true ]====]
L['Last update:'] = true
L['Data source:'] = true
L['Inspect target'] = true
Expand All @@ -31,6 +29,11 @@ L['Show inspect gear list'] = true
L['Show talent background'] = true
L.HELP_SUMMARY = true
L.Help = true
L['Show option button in character gear list'] = true
L['Show option button in inspect gear list'] = true
L['View mouseover hotkey'] = true
L['View target hotkey'] = true
L['The key is bound to |cffffd100%s|r, are you sure you want to overwrite it?'] = true
-- @locale-fill@
-- @end-import@
-- @end-debug@
10 changes: 6 additions & 4 deletions Localization/zhCN.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@ if not L then
end

-- @import:language=zhCN@

--[====[ never used ]====]
--[====[ L['Show Model'] = '显示模型' ]====]
L['Last update:'] = '最后更新:'
L['Inspect target'] = '观察目标'
L['Inspect mouseover'] = '观察鼠标悬停目标'
L['Data source:'] = '数据来源:'
L['iLvl:'] = true
L['Show character gear list'] = '显示角色的装备列表'
L['Show inspect compare'] = '观察是比较装备'
L['Show inspect compare'] = '观察时比较装备'
L['Show inspect gear list'] = '显示被观察者装备列表'
L['Show talent background'] = '装备列表显示天赋背景'
L['Show option button in character gear list'] = '在角色装备列表中显示选项按钮'
L['Show option button in inspect gear list'] = '在被观察者装备列表中显示选项按钮'
L.Help = '帮助'
L.HELP_SUMMARY = [[1. 大部分玩家右键菜单(好友,公会,聊天等),可远程观察玩家。
2. 若玩家菜单右键没有观察选项,尝试禁用玩家菜单增强插件。
3. 角色装备列表非当前天赋按钮,点击可切换天赋。]]
L['View mouseover hotkey'] = '观察鼠标悬停目标快捷键'
L['View target hotkey'] = '观察目标快捷键'
L['The key is bound to |cffffd100%s|r, are you sure you want to overwrite it?'] = '按键已绑定到|cffffd100%s|r,确定要覆盖吗?'
-- @locale-fill@

-- @end-import@
24 changes: 14 additions & 10 deletions UI/CharacterGearFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ function CharacterGearFrame:Constructor()
self:SetScript('OnShow', self.OnShow)
self:SetScript('OnHide', self.OnHide)

self:UpdateOptionButton(ns.Addon.db.profile.showOptionButtonInCharacter)

self.Talent2:SetScript('OnClick', function(button)
if not InCombatLockdown() then
SetActiveTalentGroup(button.id)
Expand All @@ -37,16 +39,6 @@ function CharacterGearFrame:OnHide()
self:Hide()
end

function CharacterGearFrame:UpdateOption(_, key, value)
if key == 'showTalentBackground' then
if value then
self:UpdateTalents()
else
self:SetBackground()
end
end
end

function CharacterGearFrame:UNIT_INVENTORY_CHANGED(_, unit)
if unit == 'player' then
self:Update()
Expand Down Expand Up @@ -104,3 +96,15 @@ function CharacterGearFrame:TapTo(frame, ...)
self:SetPoint(...)
self:UpdateOption()
end

function CharacterGearFrame:UpdateOption(_, key, value)
if key == 'showTalentBackground' then
if value then
self:UpdateTalents()
else
self:SetBackground()
end
elseif key == 'showOptionButtonInCharacter' then
self:UpdateOptionButton(value)
end
end
4 changes: 4 additions & 0 deletions UI/GearFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,7 @@ end
function GearFrame:OptionOnClick()
ns.Addon:OpenOptionFrame()
end

function GearFrame:UpdateOptionButton(value)
self.Option:SetShown(value)
end
1 change: 1 addition & 0 deletions UI/GearItem.lua
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ function GearItem:Update()
tex:SetPoint('LEFT', self.Name, 'RIGHT', socketWidth, 0)

socketWidth = socketWidth + tex:GetWidth()
else
end

for i = 1, 3 do
Expand Down
21 changes: 16 additions & 5 deletions UI/InspectGearFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,20 @@ function InspectGearFrame:Constructor()
self:SetScript('OnShow', self.OnShow)
self:SetScript('OnHide', self.OnHide)

self:UpdateOptionButton(ns.Addon.db.profile.showOptionButtonInInspect)

local DataSource = self:CreateFontString(nil, 'ARTWORK', 'GameFontNormalSmall')
DataSource:SetPoint('BOTTOMLEFT', self, 'TOPLEFT', 10, 0)
DataSource:SetFont(DataSource:GetFont(), 12, 'OUTLINE')
self.DataSource = DataSource
end

function InspectGearFrame:OnShow()
self:RegisterMessage('INSPECT_READY', 'Update')
self:RegisterEvent('UNIT_LEVEL', 'Update')
self:RegisterEvent('UNIT_INVENTORY_CHANGED')
self:RegisterEvent('GET_ITEM_INFO_RECEIVED', 'UpdateItemLevel')
self:RegisterMessage('INSPECT_READY', 'Update')
self:RegisterMessage('TDINSPECT_OPTION_CHANGED', 'UpdateOption')
self:Update()
end

Expand All @@ -44,10 +47,6 @@ function InspectGearFrame:UNIT_INVENTORY_CHANGED(_, unit)
end
end

function InspectGearFrame:UpdateOption()
self:SetShown(ns.Addon.db.profile.inspectGear)
end

function InspectGearFrame:UpdateItemLevel()
self:SetItemLevel(Inspect:GetItemLevel())
end
Expand Down Expand Up @@ -106,3 +105,15 @@ function InspectGearFrame:GetTalentInfo(group)
end
return maxName, maxIcon, maxBg, table.concat(counts, '/')
end

function InspectGearFrame:UpdateOption(_, key, value)
if key == 'showTalentBackground' then
if value then
self:UpdateTalents()
else
self:SetBackground()
end
elseif key == 'showOptionButtonInInspect' then
self:UpdateOptionButton(value)
end
end
30 changes: 30 additions & 0 deletions UI/Option.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,32 @@ function Addon:SetupOptionFrame()
return {type = 'toggle', name = name, width = 'full', order = orderGen()}
end

local function keybinding(name)
return {
type = 'keybinding',
name = name,
order = orderGen(),
width = 'double',
get = function(item)
return GetBindingKey(item[#item])
end,
set = function(item, value)
local action = item[#item]
for _, key in ipairs({GetBindingKey(action)}) do
SetBinding(key, nil)
end
SetBinding(value, action)
end,
confirm = function(item, value)
local action = GetBindingAction(value)
if action ~= '' and action ~= item[#item] then
return L['The key is bound to |cffffd100%s|r, are you sure you want to overwrite it?']:format(
_G['BINDING_NAME_' .. action] or action)
end
end,
}
end

local options = {
type = 'group',
name = format('tdInspect - |cff00ff00%s|r', C_AddOns.GetAddOnMetadata('tdInspect', 'Version')),
Expand All @@ -36,9 +62,13 @@ function Addon:SetupOptionFrame()
end,
args = {
characterGear = fullToggle(L['Show character gear list']),
showOptionButtonInCharacter = fullToggle(L['Show option button in character gear list']),
inspectGear = fullToggle(L['Show inspect gear list']),
inspectCompare = fullToggle(L['Show inspect compare']),
showOptionButtonInInspect = fullToggle(L['Show option button in inspect gear list']),
showTalentBackground = fullToggle(L['Show talent background']),
TDINSPECT_VIEW_TARGET = keybinding(L['View target hotkey']),
TDINSPECT_VIEW_MOUSEOVER = keybinding(L['View mouseover hotkey']),
help = {
type = 'group',
name = L['Help'],
Expand Down
2 changes: 1 addition & 1 deletion UI/Template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
<Anchor point="BOTTOMRIGHT" relativeKey="$parent.Talent1" relativePoint="BOTTOMLEFT" x="-10" y="0" />
</Anchors>
</Button>
<Button>
<Button parentKey="Option">
<Size x="16" y="16"/>
<Anchors>
<Anchor point="TOPRIGHT" x="-4" y="4"/>
Expand Down

0 comments on commit 6e91516

Please sign in to comment.