diff --git a/DJUI-WOW.toc b/DJUI-WOW.toc new file mode 100644 index 0000000..e7ce21a --- /dev/null +++ b/DJUI-WOW.toc @@ -0,0 +1,9 @@ +## Interface: 60200 +## Author: Darkjaguar91 +## Version: 0.01 +## Title: DJUI +## Notes: NOTE!!. + +core/core.xml + +bag/bag.xml \ No newline at end of file diff --git a/bag/bag.lua b/bag/bag.lua index b10eac2..0a830bc 100644 --- a/bag/bag.lua +++ b/bag/bag.lua @@ -1,16 +1,161 @@ -function DJUIBag_OnLoad(self) - SetPortraitToTexture(self.portrait, "Interface\\Icons\\INV_Misc_EngGizmos_30") - - self.items = {} - for idx = 1, 24 do - local item = CreateFrame("Button", "DJUIBagItem" .. idx, self, "DJUIBagItemTemplate") - self.items[idx] = item - if idx == 1 then - item:SetPoint("TOPLEFT", 40, -73) - elseif idx == 7 or idx == 13 or idx == 19 then - item:SetPoint("TopLeft", self.items[idx -6], "BOTTOMLEFT", 0, -7) - else - item:SetPoint("TOPLEFT", self.items[idx - 1], "TOPRIGHT", 12, 0) +local bagItems = {} +local itemSize, columns, padding, titleSize = 37, 5, 4, 15 + +local function GetItems() + bagItems = {} + + for bag = 0, NUM_BAG_SLOTS do + for slot = 1, GetContainerNumSlots(bag) do + local id = GetContainerItemID(bag, slot) + if id then + local texture, count, locked, quality, readable, lootable, link, isFiltered = GetContainerItemInfo(bag, slot) + local name, _, _, ilevel, reqLevel, class, subclass, maxStack, equipSlot, _, vendorPrice = GetItemInfo(id) + + if not bagItems[class] then + bagItems[class] = {} + end + + table.insert(bagItems[class], { + id = id, + name = name, + texture = texture, + link = link, + count = count, + quality = quality, + ilevel = ilevel, + maxStack = maxStack, + }) + end end end +end + +local function CreateBag(parent, name, items) + if #items == 0 then return end + + local function sortIt(a, b) + if a.quality == b.quality then + if a.name == b.name then + return a.count > b.count + end + + return a.name < b.name + end + + return a.quality > b.quality + end + + table.sort(items, sortIt) + + if not parent.frames then + parent.frames = {} + end + local frame = parent.frames[name] + if not frame then + parent.frames[name] = CreateFrame("Frame", "BagFrame" .. name, parent) + frame = parent.frames[name] + frame.name = name + frame.items = {} + frame.buttonPool = {} + frame.createItem = function(self, item) + local button = table.remove(self.buttonPool) + + if not button then + button = CreateFrame("Button", nil, self, "DJUIBagItemTemplate") + button.count:SetFontObject("DJUI_Small") + end + + button.link = item.link + button.icon:SetTexture(item.texture) + + if item.count > 1 then + button.count:SetText(item.count) + button.count:SetVertexColor(1, 1, 1, 1) + button.count:Show() + elseif item.maxStack == 1 and item.ilevel > 1 then + print(item.name) + button.count:SetText(item.ilevel) + button.count:SetVertexColor(GetItemQualityColor(item.quality)) + button.count:Show() + else + button.count:Hide() + end + + if item.quality > 1 then + button.glow:SetVertexColor(GetItemQualityColor(item.quality)) + button.glow:Show() + else + button.glow:Hide() + end + table.insert(self.items, button) + return button + end + frame.title = frame:CreateFontString("BagBuddy_Title", "OVERLAY", "GameFontNormal") + frame.title:SetFontObject("DJUITitle") + frame.title:SetPoint("TOP", 0, -1) + frame.background = frame:CreateTexture(nil, "BACKGROUND") + frame.background:SetAllPoints() + frame.background:SetTexture(0, 0, 0, 0.6) + frame:SetBackdrop({ + edgeFile="Interface\\ChatFrame\\ChatFrameBackground", + edgeSize= 0.6, + }) + end + + local frame = parent.frames[name] + for k, v in pairs(frame.items) do + v:Hide() + v.link = nil + v:ClearAllPoints() + table.insert(frame.buttonPool, v) + end + + frame.items = {} + frame.title:SetText(name) + + local count = 0 + for k, v in pairs(items) do + local btn = frame:createItem(v) + + local x = padding + itemSize * (count % columns) + padding * (count % columns) + local y = -(frame.title:GetStringHeight() + padding + padding * math.floor(count / 5) + itemSize * math.floor(count / 5)) + btn:SetPoint("TOPLEFT", x, y) + + count = count + 1 + end + local numRows = math.ceil(#items / 5) + local x = padding * (columns + 1) + itemSize * columns + local y = numRows * itemSize + frame.title:GetStringHeight() + padding + padding * numRows + frame:SetSize(x, y) + return x, y, frame +end + +local function UpdateItems(parent) + GetItems() + local w, h = 0, 0 + for k, v in pairs(bagItems) do + local w1, h1, frame = CreateBag(parent, k, v) + w = math.max(w, w1) + frame:SetPoint("BOTTOMRIGHT", 0, h) + frame:Show() + h = h + h1 + end + parent:SetSize(w + 5, h + 5) + parent:Show() +end + +function DJUIBag_OnLoad(self) + UpdateItems(self) +end + +function DJUIBag_ItemEnter(self, motion) + if self.link then + GameTooltip:SetOwner(self, "ANCHOR_TOPRIGHT") + GameTooltip:SetHyperlink(self.link) + GameTooltip:Show() + end +end + +function DJUIBag_ItemLeave(self, motion) + GameTooltip:Hide() end \ No newline at end of file diff --git a/bag/bag.xml b/bag/bag.xml index ec936dd..6f10fb0 100644 --- a/bag/bag.xml +++ b/bag/bag.xml @@ -1,96 +1,4 @@ <Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ http://wowprogramming.com/FrameXML/UI.xsd"> - <Button name="DJUIBagItemTemplate" virtual="true"> - <Size> - <AbsDimension x="37" y="37"/> - </Size> - <Layers> - <Layer level="BORDER"> - <Texture name="$parentIconTexture" parentKey="icon"/> - <FontString hidden="true" inherits="NumberFontNormal" justifyH="RIGHT" name="$parentCount" parentKey="count"> - <Anchors> - <Anchor point="BOTTOMRIGHT"> - <Offset> - <AbsDimension x="-5" y="2"/> - </Offset> - </Anchor> - </Anchors> - </FontString> - </Layer> - <Layer level="OVERLAY"> - <Texture alphaMode="ADD" file="Interface\Buttons\UI-ActionButton-Border" name="$parentGlow" parentKey="glow"> - <Size x="70" y="70"/> - <Anchors> - <Anchor point="CENTER"/> - </Anchors> - <Color a="0.6" b="1.0" g="1.0" r="1.0"/> - </Texture> - </Layer> - </Layers> - <NormalTexture file="Interface\Buttons\UI-Quickslot2" name="$parentNormalTexture"> - <Size> - <AbsDimension x="64" y="64"/> - </Size> - <Anchors> - <Anchor point="CENTER"> - <Offset> - <AbsDimension x="0" y="-1"/> - </Offset> - </Anchor> - </Anchors> - </NormalTexture> - <PushedTexture file="Interface\Buttons\UI-Quickslot-Depress"/> - <HighlightTexture alphaMode="ADD" file="Interface\Buttons\ButtonHilight-Square"/> - </Button> - <Frame name="DJUIBag" parent="UIParent"> - <Size x="384" y="512"/> - <Anchors> - <Anchor point="CENTER" relativePoint="CENTER" relativeTo="UIParent"/> - </Anchors> - <Layers> - <Layer level="BACKGROUND"> - <Texture file="Interface\Icons\INV_Misc_EngGizmos_30" name="$parent_Portrait" parentKey="portrait"> - <Size x="60" y="60"/> - <Anchors> - <Anchor point="TOPLEFT"> - <Offset x="7" y="-6"/> - </Anchor> - </Anchors> - </Texture> - </Layer> - <Layer level="OVERLAY"> - <FontString inherits="GameFontNormal" name="$parent_Title" parentKey="title" text="Title thingy"> - <Anchors> - <Anchor point="TOP"> - <Offset x="0" y="-18"/> - </Anchor> - </Anchors> - </FontString> - </Layer> - <Layer level="BORDER"> - <Texture file="Interface\BankFrame\UI-BankFrame-TopLeft"> - <Anchors> - <Anchor point="TOPLEFT"/> - </Anchors> - </Texture> - <Texture file="Interface\BankFrame\UI-BankFrame-TopRight"> - <Anchors> - <Anchor point="TOPRIGHT"/> - </Anchors> - </Texture> - <Texture file="Interface\BankFrame\UI-BankFrame-BotLeft"> - <Anchors> - <Anchor point="BOTTOMLEFT"/> - </Anchors> - </Texture> - <Texture file="Interface\BankFrame\UI-BankFrame-BotRight"> - <Anchors> - <Anchor point="BOTTOMRIGHT"/> - </Anchors> - </Texture> - </Layer> - </Layers> - <Scripts> - <OnLoad function="DJUIBag_OnLoad"/> - </Scripts> - </Frame> + <Script file="bag/bag.lua" /> + <Include file="bag/ui.xml" /> </Ui> \ No newline at end of file diff --git a/bag/ui.xml b/bag/ui.xml new file mode 100644 index 0000000..f44d738 --- /dev/null +++ b/bag/ui.xml @@ -0,0 +1,58 @@ +<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ http://wowprogramming.com/FrameXML/UI.xsd"> + <Button name="DJUIBagItemTemplate" virtual="true"> + <Size> + <AbsDimension x="37" y="37"/> + </Size> + <Layers> + <Layer level="BORDER"> + <Texture name="$parentIconTexture" parentKey="icon"/> + <FontString hidden="true" inherits="NumberFontNormal" justifyH="RIGHT" name="$parentCount" parentKey="count"> + <Anchors> + <Anchor point="BOTTOMRIGHT"> + <Offset> + <AbsDimension x="0" y="1"/> + </Offset> + </Anchor> + </Anchors> + </FontString> + </Layer> + <Layer level="OVERLAY"> + <Texture alphaMode="ADD" file="Interface\Buttons\UI-ActionButton-Border" name="$parentGlow" parentKey="glow"> + <Size x="70" y="70"/> + <Anchors> + <Anchor point="CENTER"/> + </Anchors> + <Color a="0.6" b="1.0" g="1.0" r="1.0"/> + </Texture> + </Layer> + </Layers> + + <Scripts> + <OnEnter function="DJUIBag_ItemEnter" /> + <OnLeave function="DJUIBag_ItemLeave" /> + </Scripts> + + <NormalTexture file="Interface\Buttons\UI-Quickslot2" name="$parentNormalTexture"> + <Size> + <AbsDimension x="64" y="64"/> + </Size> + <Anchors> + <Anchor point="CENTER"> + <Offset> + <AbsDimension x="0" y="-1"/> + </Offset> + </Anchor> + </Anchors> + </NormalTexture> + <PushedTexture file="Interface\Buttons\UI-Quickslot-Depress"/> + <HighlightTexture alphaMode="ADD" file="Interface\Buttons\ButtonHilight-Square"/> + </Button> + <Frame name="DJUIBag" parent="UIParent"> + <Anchors> + <Anchor point="CENTER" relativePoint="CENTER" relativeTo="UIParent"/> + </Anchors> + <Scripts> + <OnLoad function="DJUIBag_OnLoad" /> + </Scripts> + </Frame> +</Ui> \ No newline at end of file diff --git a/core/core.xml b/core/core.xml new file mode 100644 index 0000000..11117b9 --- /dev/null +++ b/core/core.xml @@ -0,0 +1,3 @@ +<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ http://wowprogramming.com/FrameXML/UI.xsd"> + <Include file="core/fonts.xml" /> +</Ui> \ No newline at end of file diff --git a/core/fonts.xml b/core/fonts.xml new file mode 100644 index 0000000..338cf2d --- /dev/null +++ b/core/fonts.xml @@ -0,0 +1,26 @@ +<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ http://wowprogramming.com/FrameXML/UI.xsd"> + <Font name="DJUITitle" font="Fonts\FRIZQT__.TTF" outline="NORMAL" virtual="true"> + <Shadow> + <Offset> + <AbsDimension x="2" y="-2" /> + </Offset> + <Color r="0" g="0" b="0" /> + </Shadow> + <Color r="0.8" g="0.4" b="0" /> + <FontHeight> + <AbsValue val="15" /> + </FontHeight> + </Font> + <Font name="DJUI_Small" font="Fonts\FRIZQT__.TTF" outline="NORMAL" virtual="true"> + <Shadow> + <Offset> + <AbsDimension x="1" y="-1" /> + </Offset> + <Color r="0" g="0" b="0" /> + </Shadow> + <Color r="1" g="1" b="1" /> + <FontHeight> + <AbsValue val="8" /> + </FontHeight> + </Font> +</Ui> \ No newline at end of file