Skip to content

Commit

Permalink
(new) Ugh, StatBlockCore is unusably inconfigurable. Adding Chocolate…
Browse files Browse the repository at this point in the history
…Bar.
  • Loading branch information
ELLIOTTCABLE committed Jun 19, 2015
1 parent ae3f51d commit c74a667
Show file tree
Hide file tree
Showing 251 changed files with 52,060 additions and 0 deletions.
245 changes: 245 additions & 0 deletions Interface/AddOns/Broker_Equipment/Broker_Equipment.lua
@@ -0,0 +1,245 @@
local Broker_Equipment = CreateFrame('Frame')
Broker_Equipment:RegisterEvent('PLAYER_LOGIN')
Broker_Equipment:SetScript('OnEvent', function(self, event, ...) self[event](self, ...) end)
Broker_Equipment:Hide()

local BACKDROP = {
bgFile = [[Interface\Tooltips\UI-Tooltip-Background]],
edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]], edgeSize = 16,
insets = {top = 3, bottom = 3, left = 3, right = 3}
}

local LDB = LibStub('LibDataBroker-1.1'):NewDataObject('Broker_Equipment', {
type = 'data source',
})

local Menu, pending

local function UpdateDisplay()
if(InCombatLockdown() and pending) then
LDB.text = '|cffffff00' .. pending
LDB.icon = [[Interface\Icons\]] .. GetEquipmentSetInfoByName(pending)
else
for index = 1, GetNumEquipmentSets() do
local name, icon, _, equipped = GetEquipmentSetInfo(index)
if(equipped) then
LDB.text = name
LDB.icon = icon
return
end
end

LDB.text = UNKNOWN
LDB.icon = [[Interface\Icons\INV_Misc_QuestionMark]]
end
end

local function OnItemClick(self)
if(IsShiftKeyDown() and not pending) then
local dialog = StaticPopup_Show('CONFIRM_SAVE_EQUIPMENT_SET', self.name)
dialog.data = self.name
elseif(IsControlKeyDown() and not pending) then
local dialog = StaticPopup_Show('CONFIRM_DELETE_EQUIPMENT_SET', self.name)
dialog.data = self.name
else
if(InCombatLockdown()) then
Broker_Equipment:RegisterEvent('PLAYER_REGEN_ENABLED')
pending = self.name

UpdateDisplay()
else
EquipmentManager_EquipSet(pending or self.name)
end
end

Menu:Hide()
end

local function OnEnter()
Menu.Fader:Stop()
end

local function OnLeave()
Menu.Fader:Play()
end

local function OnItemEnter(self)
GameTooltip:SetOwner(self, 'ANCHOR_RIGHT')
GameTooltip:SetEquipmentSet(self.name)

OnEnter()
end

local function UpdateMenu(parent)
local maxWidth = 0

local numEquipmentSets = GetNumEquipmentSets()
for index = 1, numEquipmentSets do
local Item = Menu.items[index]
if(not Item) then
Item = CreateFrame('Button', nil, Menu)
Item:SetPoint('TOPLEFT', 11, -((index - 1) * 18) - UIDROPDOWNMENU_BORDER_HEIGHT)
Item:SetHighlightTexture([[Interface\QuestFrame\UI-QuestTitleHighlight]])
Item:GetHighlightTexture():SetBlendMode('ADD')
Item:SetScript('OnClick', OnItemClick)
Item:SetScript('OnEnter', OnItemEnter)
Item:SetScript('OnLeave', GameTooltip_Hide)
Item:HookScript('OnLeave', OnLeave)

local Button = CreateFrame('CheckButton', nil, Item)
Button:SetPoint('LEFT')
Button:SetSize(16, 16)
Button:SetNormalTexture([[Interface\Common\UI-DropDownRadioChecks]])
Button:GetNormalTexture():SetTexCoord(0.5, 1, 0.5, 1)
Button:SetCheckedTexture([[Interface\Common\UI-DropDownRadioChecks]])
Button:GetCheckedTexture():SetTexCoord(0, 0.5, 0.5, 1)
Button:EnableMouse(false)
Item.Button = Button

local Label = Item:CreateFontString(nil, nil, 'GameFontHighlightSmall')
Label:SetPoint('LEFT', 20, 0)
Item:SetFontString(Label)
Item.Label = Label

local Icon = Item:CreateTexture(nil, 'ARTWORK')
Icon:SetPoint('RIGHT')
Icon:SetSize(16, 16)
Item.Icon = Icon

Menu.items[index] = Item
else
Item:Show()
end

local name, icon, _, equipped, _, _, _, missing = GetEquipmentSetInfo(index)
Item.Button:SetChecked(equipped)
Item.Icon:SetTexture(icon)
Item.name = name

if(pending == name) then
Item:SetFormattedText('|cffffff00%s|r', name)
elseif(missing > 0) then
Item:SetFormattedText('|cffff0000%s|r', name)
else
Item:SetText(name)
end

local width = Item.Label:GetWidth() + 50
if(width > maxWidth) then
maxWidth = width
end
end

for index = numEquipmentSets + 1, #Menu.items do
Menu.items[index]:Hide()
end

for _, Item in next, Menu.items do
Item:SetSize(maxWidth, 18)
end

Menu:SetSize(maxWidth + 25, (numEquipmentSets * 18) + (UIDROPDOWNMENU_BORDER_HEIGHT * 2))
end

function LDB:OnTooltipShow()
self:SetEquipmentSet(LDB.text)
end

local hooked = {}
function LDB:OnClick(button)
if(GameTooltip:GetOwner() == self) then
GameTooltip:Hide()
end

if(button ~= 'RightButton' and GetNumEquipmentSets() > 0) then
if(not Menu) then
Menu = CreateFrame('Frame', nil, UIParent)
Menu:SetBackdrop(BACKDROP)
Menu:SetBackdropColor(0, 0, 0)
Menu:SetFrameStrata('DIALOG')
Menu:SetScript('OnEnter', OnEnter)
Menu:SetScript('OnLeave', OnLeave)
Menu:Hide()
Menu.items = {}

local Fader = Menu:CreateAnimationGroup()
Fader:CreateAnimation():SetDuration(UIDROPDOWNMENU_SHOW_TIME)
Fader:SetScript('OnFinished', function()
Menu:Hide()
end)
Menu.Fader = Fader
end

if(Menu:IsShown()) then
Menu:Hide()
else
UpdateMenu(self)
Menu:ClearAllPoints()
Menu:SetPoint('TOP', self, 'BOTTOM') -- temporary anchor

local sideAnchor = ''
if(Menu:GetRight() > GetScreenWidth()) then
sideAnchor = 'RIGHT'
elseif(Menu:GetLeft() <= 0) then
sideAnchor = 'LEFT'
end

Menu:ClearAllPoints()
if(Menu:GetBottom() <= 0) then
Menu:SetPoint('BOTTOM' .. sideAnchor, self, 'TOP' .. sideAnchor)
else
Menu:SetPoint('TOP' .. sideAnchor, self, 'BOTTOM' .. sideAnchor)
end

Menu:Show()
end

PlaySound('igMainMenuOptionCheckBoxOn')

if(not hooked[self]) then
self:HookScript('OnEnter', OnEnter)
self:HookScript('OnLeave', OnLeave)

hooked[self] = true
end
else
if(not PaperDollFrame:IsVisible()) then
ToggleCharacter('PaperDollFrame')
end

if(not CharacterFrame.Expanded) then
SetCVar('characterFrameCollapsed', '0')
CharacterFrame_Expand()
end

if(not _G[PAPERDOLL_SIDEBARS[3].frame]:IsShown()) then
Broker_Equipment:Show()
end
end
end

function Broker_Equipment:PLAYER_LOGIN()
self:RegisterEvent('UNIT_INVENTORY_CHANGED')
self:RegisterEvent('EQUIPMENT_SETS_CHANGED')
self.EQUIPMENT_SETS_CHANGED = UpdateDisplay

UpdateDisplay()
end

function Broker_Equipment:UNIT_INVENTORY_CHANGED(unit)
if(unit == 'player') then
UpdateDisplay()
end
end

function Broker_Equipment:PLAYER_REGEN_ENABLED()
self:UnregisterEvent('PLAYER_REGEN_ENABLED')

OnItemClick()
pending = nil
end

Broker_Equipment:SetScript('OnUpdate', function(self)
PaperDollFrame_SetSidebar(nil, 3)
self:Hide()
end)
17 changes: 17 additions & 0 deletions Interface/AddOns/Broker_Equipment/Broker_Equipment.toc
@@ -0,0 +1,17 @@
## Interface: 60000
## Author: p3lim
## Version: 60000.25-Release
## Title: Broker Equipment
## Notes: LDB Equipment Manager plug-in
## X-Curse-Packaged-Version: 60000.25-Release
## X-Curse-Project-Name: Broker_Equipment
## X-Curse-Project-ID: broker_equipment
## X-Curse-Repository-ID: wow/broker_equipment/mainline

## OptionalDeps: LibStub, CallbackHandler-1.0, LibDataBroker-1.1

embeds\LibStub\LibStub.lua
embeds\CallbackHandler\CallbackHandler-1.0.lua
embeds\LibDataBroker\LibDataBroker-1.1.lua

Broker_Equipment.lua
129 changes: 129 additions & 0 deletions Interface/AddOns/Broker_Equipment/CHANGELOG.md
@@ -0,0 +1,129 @@
## Changes in 60000.25-Release:

- Changed: Update Interface version
- Fixed: Dropdown sometimes rendering behind other objects

## Changes in 50400.24-Release:

- Added: Changelog file
- Changed: Create the broker object on load
- Fixed: Dropdown going off the screen
- Fixed: Dropdown not respecting the parent frame

## Changes in 50400.23-Release:

- Added: Proper license
- Added: Custom dropdown to avoid tainting default UI
- Added: Metadata file for the curseforge packager
- Changed: Use externals for libraries

## Changes in 50400.22-Release:

- Added: Hacky method to show tooltips in dropdown
- Changed: Update Interface version
- Removed: License

## Changes in 50200.21-Release:

- Changed: Update Interface version
- Fixed: LDB text when there are no matching sets

## Changes in 40300.20-Release:

- Changed: Use the new equipment API

## Changes in 40300.19-Release:

- Changed: Update license
- Removed: Usage tooltips and translations

## Changes in 40300.18-Release:

- Added: ptBR translations
- Changed: Added support for packagers to set the version automatically

## Changes in 40200.17-Release:

- Changed: Update Interface version

## Changes in 40100.16-Release:

- Changed: Update ruRU translations
- Fixed: Properly show the new equipment tab in the character window

## Changes in 40100.15-Beta:

- Added: Proper defaults for LDB
- Added: Support for changes to the GearManager
- Changed: Update Interface version
- Removed: Buggy hack to get set texture

## Changes in 40000.14-Release:

- Changed: Use the dropdown's built-in support for icons
- Changed: Use the dropdown's built-in support for checkboxes
- Changed: Color the usage tooltip lines
- Fixed: Hide the tooltips properly when clicked

## Changes in 40000.13-Release:

- Changed: Revert back to using hard copies instead of externals/submodules

## Changes in 40000.12-Release:

- Changed: Localization table for easier integration with curseforge

## Changes in 40000.11-Release:

- Added: esES translations
- Added: esMS translations
- Added: ruRU translations
- Changed: Update Interface version
- Changed: Update deDE translations
- Changed: Only show usage tooltips when SHOW_NEWBIE_TIPS is enabled
- Changed: Use externals/submodules for libraries
- Fixed: Detecting set on login
- Fixed: Gear manager click functionality

## Changes in 30300.10-Release:

- Added: Support for AddonLoader

## Changes in 30300.9-Release:

- Fixed: Pending sets not showing during combat

## Changes in 30300.8-Beta:

- Fixed: Pending sets

## Changes in 30300.7-Beta:

- Changed: Table layout for localizations

## Changes in 30300.6-Beta:

- Changed: Update Interface version
- Changed: Use the environment arguments
- Changed: Move localization to it's own file

## Changes in 30200.4-Beta:

- Changed: Use location matching instead of itemIDs
- Changed: Use a proper dropdown
- Fixed: Faulty LDB icon texture
- Fixed: Overwrite popup
- Fixed: Updating LDB on set changes
- Fixed: Updating LDB on login

## Changes in 30200.3-Beta:

- Fixed: Item match on ignored slots

## Changes in 30200.2-Beta:

- Changed: Update Interface version

## Changes in 30200.1-Beta:

- First public release

0 comments on commit c74a667

Please sign in to comment.