Skip to content

Commit

Permalink
Support the Keyring
Browse files Browse the repository at this point in the history
  • Loading branch information
Nevcairiel committed Aug 31, 2020
1 parent 1bd4846 commit caf11b5
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 8 deletions.
17 changes: 17 additions & 0 deletions Frame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,23 @@ function Inventorian.Frame:Create(name, titleText, settings, config)

if frame:IsBank() then
frame:SetMinResize(275, 325)
frame.KeyRingButton:Hide()
else
frame:SetMinResize(250, 260)
end

if frame:IsKeyring() then
frame:SetMinResize(200, 200)
frame.KeyRingButton:Hide()

frame.Money:Hide()
frame.BagToggle:Hide()
frame.ArtBottomDivider:Hide()
frame.ArtBottomLeft:Hide()
frame.ArtBottomRight:Hide()
frame.ArtBottomRight2:Hide()
end

-- components
frame.itemContainer = Inventorian.ItemContainer:Create(frame)
frame.itemContainer:SetPoint("TOPLEFT", 10, -64)
Expand Down Expand Up @@ -377,6 +390,10 @@ function Frame:IsBank()
return self.currentConfig.isBank
end

function Frame:IsKeyring()
return self.currentConfig.isKeyring
end

function Frame:AtBank()
return Events.atBank
end
41 changes: 36 additions & 5 deletions Frame.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
</MaskTexture>
</Layer>
<Layer level="OVERLAY">
<Texture inherits="UI-Frame-BtnDivMiddle"> <!-- Separator -->
<Texture parentKey="ArtBottomDivider" inherits="UI-Frame-BtnDivMiddle"> <!-- Separator -->
<Anchors>
<Anchor point="BOTTOMLEFT">
<Offset x="145" y="2"/>
Expand All @@ -56,7 +56,7 @@
</Texture>
</Layer>
<Layer level="ARTWORK">
<Texture file="Interface\MerchantFrame\UI-Merchant-BotLeft"> <!-- Left -->
<Texture parentKey="ArtBottomLeft" file="Interface\MerchantFrame\UI-Merchant-BotLeft"> <!-- Left -->
<Size x="64" y="24"/>
<Anchors>
<Anchor point="BOTTOMLEFT">
Expand All @@ -65,7 +65,7 @@
</Anchors>
<TexCoords left="0.72" right="1" top="0.675" bottom=".754"/>
</Texture>
<Texture file="Interface\MerchantFrame\UI-Merchant-BotRight">
<Texture parentKey="ArtBottomRight" file="Interface\MerchantFrame\UI-Merchant-BotRight">
<Size x="64" y="24"/>
<Anchors>
<Anchor point="BOTTOMRIGHT">
Expand All @@ -77,7 +77,7 @@
</Anchors>
<TexCoords left="0" right="0.5" top="0.675" bottom=".754"/>
</Texture>
<Texture file="Interface\MerchantFrame\UI-Merchant-BotRight"> <!-- Right -->
<Texture parentKey="ArtBottomRight2" file="Interface\MerchantFrame\UI-Merchant-BotRight"> <!-- Right -->
<Size x="64" y="24"/>
<Anchors>
<Anchor point="BOTTOMRIGHT">
Expand Down Expand Up @@ -203,7 +203,7 @@
</Scripts>
</EditBox>

<Button name="$pargenBagToggle">
<Button parentKey="BagToggle" name="$pargenBagToggle">
<Size x="32" y="32"/>
<Anchors>
<Anchor point="TOPRIGHT">
Expand Down Expand Up @@ -269,6 +269,37 @@
</OnLoad>
</Scripts>
</Frame>

<Button parentKey="KeyRingButton" name="$parentKeyRingButton">
<Size x="15" y="32"/>
<Anchors>
<Anchor point="TOPRIGHT">
<Offset x="-46" y="-26"/>
</Anchor>
</Anchors>
<Scripts>
<OnClick>
ToggleBag(KEYRING_CONTAINER)
</OnClick>
<OnEnter>
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:SetText(KEYRING, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b)
GameTooltip:AddLine()
</OnEnter>
<OnLeave>
GameTooltip:Hide()
</OnLeave>
</Scripts>
<NormalTexture file="Interface\Buttons\UI-Button-KeyRing">
<TexCoords left="0" right="0.5625" top="0" bottom="0.609375"/>
</NormalTexture>
<HighlightTexture file="Interface\Buttons\UI-Button-KeyRing-Highlight" alphaMode="ADD">
<TexCoords left="0" right="0.5625" top="0" bottom="0.609375"/>
</HighlightTexture>
<PushedTexture file="Interface\Buttons\UI-Button-KeyRing-Down">
<TexCoords left="0" right="0.5625" top="0" bottom="0.609375"/>
</PushedTexture>
</Button>
</Frames>

<Scripts>
Expand Down
36 changes: 33 additions & 3 deletions Inventorian.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ local defaults = {
height = 512,
showBags = false,
},
keyring = {
x = -422,
y = 75,
point = "RIGHT",
width = 265,
height = 200,
showBags = false,
},
}
}

Expand All @@ -46,9 +54,19 @@ local BANK_CONFIG =
}
}

local KEYRING_CONFIG =
{
{
title = KEYRING,
bags = { KEYRING_CONTAINER },
isKeyring = true,
}
}

function Inventorian:OnEnable()
self.bag = Inventorian.Frame:Create("InventorianBagFrame", L["%s's Inventory"], db.bag, BAG_CONFIG)
self.bank = Inventorian.Frame:Create("InventorianBankFrame", L["%s's Bank"], db.bank, BANK_CONFIG)
self.keyring = Inventorian.Frame:Create("InventorianKeyringFrame", L["%s's Keyring"], db.keyring, KEYRING_CONFIG)
self:SetupBagHooks()

self:RegisterChatCommand("inventorian", "HandleSlash")
Expand All @@ -71,8 +89,20 @@ function Inventorian:AutoHideInventory()
self.bag:HideFrame(true)
end

function Inventorian:ToggleBackpack()
self.bag:ToggleFrame()
function Inventorian:ToggleBackpack(id)
if id == KEYRING_CONTAINER then
self.keyring:ToggleFrame()
else
self.bag:ToggleFrame()
end
end

function Inventorian:OpenBag(id)
if id == KEYRING_CONTAINER then
self.keyring:ShowFrame()
else
self.bag:ShowFrame()
end
end

function Inventorian:OpenAllBags()
Expand Down Expand Up @@ -108,7 +138,7 @@ function Inventorian:SetupBagHooks()
self:RawHook("ToggleBackpack", true)
self:RawHook("ToggleAllBags", "ToggleBackpack", true)
self:RawHook("OpenAllBags", true)
self:RawHook("OpenBag", "OpenAllBags", true)
self:RawHook("OpenBag", true)

self:RawHook("GetBackpackFrame", function() return self.bag end, true)

Expand Down

0 comments on commit caf11b5

Please sign in to comment.