post refactoring

This commit is contained in:
Manuel Simon Hirsig
2016-07-26 04:49:26 +02:00
parent 552ca3f596
commit 77f7f36ec6
6 changed files with 89 additions and 85 deletions
+1 -1
View File
@@ -39,7 +39,7 @@ do
end
function public.on_load()
public.version = '3.3.0'
public.version = '3.4.0'
public.blizzard_ui_shown = false
public.bids_loaded = false
public.current_owner_page = nil
-30
View File
@@ -18,36 +18,6 @@
</Scripts>
</Frame>
<Frame name="AuxItemTemplate" virtual="true">
<Size><AbsDimension x="193" y="37"/></Size>
<Layers>
<Layer level="BORDER">
<Texture name="$parentIconTexture">
<Size><AbsDimension x="32" y="32"/></Size>
<Anchors><Anchor point="LEFT"><Offset><AbsDimension x="2" y="0"/></Offset></Anchor></Anchors>
</Texture>
<Texture file="Interface\Buttons\UI-Quickslot2">
<Size><AbsDimension x="60" y="60"/></Size>
<Anchors><Anchor point="CENTER" relativeTo="$parentIconTexture"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor></Anchors>
</Texture>
<FontString name="$parentCount" inherits="NumberFontNormal" justifyH="RIGHT">
<Anchors><Anchor point="BOTTOMRIGHT" relativeTo="$parentIconTexture"><Offset><AbsDimension x="-5" y="2"/></Offset></Anchor></Anchors>
</FontString>
<FontString name="$parentName" font="Fonts\ARIALN.TTF" justifyH="LEFT">
<FontHeight>
<AbsValue val="14"/>
</FontHeight>
<Anchors>
<Anchor point="LEFT" relativePoint="RIGHT" relativeTo="$parentIconTexture"><Offset><AbsDimension x="10" y="0"/></Offset></Anchor>
<Anchor point="RIGHT"><Offset><AbsDimension x="-10" y="0"/></Offset></Anchor>
<Anchor point="TOP"><Offset><AbsDimension x="0" y="-5"/></Offset></Anchor>
<Anchor point="BOTTOM"><Offset><AbsDimension x="0" y="5"/></Offset></Anchor>
</Anchors>
</FontString>
</Layer>
</Layers>
</Frame>
<Frame name="AuxFrame" toplevel="true" movable="true" enableMouse="true" hidden="true" parent="UIParent" clampedToScreen="true">
<Size><AbsDimension x="768" y="447"/></Size>
<Anchors>
+30
View File
@@ -16,6 +16,15 @@ public.config = {
off_color = {0.7, 0.3, 0.3},
}
do
local x = 0
function private.id()
x = x + 1
return 'Aux_frame'..x
end
end
function public.inline_color(color)
local r, g, b, a = unpack(color)
return format('|c%02X%02X%02X%02X', a, r, g, b)
@@ -324,6 +333,27 @@ function public.status_bar(parent)
return self
end
function public.item(parent)
local item = CreateFrame('Button', nil, parent)
item:SetWidth(193)
item:SetHeight(40)
local icon = CreateFrame('CheckButton', m.id(), item, 'ActionButtonTemplate')
icon:SetPoint('LEFT', 2, 0.5)
icon:SetHighlightTexture(nil)
icon:RegisterForClicks()
icon:EnableMouse(nil)
item.texture = getglobal(icon:GetName()..'Icon')
item.texture:SetTexCoord(0.06,0.94,0.06,0.94)
item.name = Aux.gui.label(icon)
item.name:SetJustifyH('LEFT')
item.name:SetPoint('LEFT', icon, 'RIGHT', 10, 0)
item.name:SetPoint('RIGHT', item, 'RIGHT', -10, 0.5)
item.name:SetPoint('TOP', item, 'TOP', -5, 0)
item.name:SetPoint('BOTTOM', item, 'BOTTOM', 5, 0)
item.count = getglobal(icon:GetName()..'Count')
return item
end
function public.label(parent, size)
local label = parent:CreateFontString()
label:SetFont(m.config.content_font, size or m.config.normal_font_size)
+14 -12
View File
@@ -1,6 +1,6 @@
local m, public, private = Aux.module'item_listing'
local ROW_HEIGHT = 38
local ROW_HEIGHT = 39
function public.render(item_listing)
@@ -20,14 +20,14 @@ function public.render(item_listing)
elseif not row.mouse_over then
row.highlight:Hide()
end
getglobal(row.item:GetName()..'IconTexture'):SetTexture(item_record.texture)
getglobal(row.item:GetName()..'Name'):SetText('['..item_record.name..']')
row.item.texture:SetTexture(item_record.texture)
row.item.name:SetText('['..item_record.name..']')
local color = ITEM_QUALITY_COLORS[item_record.quality]
getglobal(row.item:GetName()..'Name'):SetTextColor(color.r, color.g, color.b)
row.item.name:SetTextColor(color.r, color.g, color.b)
if item_record.aux_quantity > 1 then
getglobal(row.item:GetName()..'Count'):SetText(item_record.aux_quantity)
row.item.count:SetText(item_record.aux_quantity)
else
getglobal(row.item:GetName()..'Count'):SetText()
row.item.count:SetText()
end
row:Show()
else
@@ -73,8 +73,8 @@ function public.create(parent, on_click, on_enter, on_leave, selected)
while total_height + ROW_HEIGHT < max_height do
local row = CreateFrame('Button', nil, content)
row:SetHeight(ROW_HEIGHT)
row:SetWidth(193)
row:SetPoint('TOPLEFT', content, 0, -((row_index-1) * ROW_HEIGHT))
row:SetWidth(195)
row:SetPoint('TOPLEFT', content, 2, -((row_index-1) * ROW_HEIGHT))
row:SetScript('OnClick', on_click)
row:SetScript('OnEnter', function()
row.highlight:Show()
@@ -87,13 +87,15 @@ function public.create(parent, on_click, on_enter, on_leave, selected)
on_leave()
end)
local item = CreateFrame('Frame', name..'_item'..row_index, row, 'AuxItemTemplate')
row.item = item
item:SetPoint('CENTER', 4, 0)
row.item = Aux.gui.item(row)
row.item:EnableMouse(nil)
row.item:SetScale(0.9)
row.item:SetPoint('LEFT', 2, 0)
row.item:SetPoint('RIGHT', 2, 0)
row:RegisterForClicks('LeftButtonUp', 'RightButtonUp')
local highlight = row:CreateTexture()
highlight:SetAllPoints(item)
highlight:SetAllPoints(row)
highlight:Hide()
highlight:SetTexture(1, .9, .9, .1)
row.highlight = highlight
+9 -9
View File
@@ -276,10 +276,10 @@ function private.update_item_configuration()
if not m.selected_item then
m.refresh_button:Disable()
AuxPostItemIconTexture:SetTexture(nil)
AuxPostItemCount:SetText()
AuxPostItemName:SetTextColor(unpack(Aux.gui.config.label_color.enabled))
AuxPostItemName:SetText('No item selected')
m.item.texture:SetTexture(nil)
m.item.count:SetText()
m.item.name:SetTextColor(unpack(Aux.gui.config.label_color.enabled))
m.item.name:SetText('No item selected')
m.unit_start_price:Hide()
m.unit_buyout_price:Hide()
@@ -299,14 +299,14 @@ function private.update_item_configuration()
m.historical_value_button:Show()
m.hide_checkbox:Show()
AuxPostItemIconTexture:SetTexture(m.selected_item.texture)
AuxPostItemName:SetText('['..m.selected_item.name..']')
m.item.texture:SetTexture(m.selected_item.texture)
m.item.name:SetText('['..m.selected_item.name..']')
local color = ITEM_QUALITY_COLORS[m.selected_item.quality]
AuxPostItemName:SetTextColor(color.r, color.g, color.b)
m.item.name:SetTextColor(color.r, color.g, color.b)
if m.selected_item.aux_quantity > 1 then
AuxPostItemCount:SetText(m.selected_item.aux_quantity)
m.item.count:SetText(m.selected_item.aux_quantity)
else
AuxPostItemCount:SetText()
m.item.count:SetText()
end
m.stack_size_slider.editbox:SetNumber(m.stack_size_slider:GetValue())
+35 -33
View File
@@ -19,44 +19,11 @@ Aux.post_tab.FRAMES(function(m, public, private)
m.frame.parameters:SetPoint('TOPLEFT', m.frame.inventory, 'TOPRIGHT', 2.5, 0)
m.frame.parameters:SetPoint('TOPRIGHT', 0, 0)
m.frame.parameters.item = CreateFrame('Button', 'AuxPostItem', m.frame.parameters, 'AuxItemTemplate')
m.frame.parameters.item:SetPoint('TOPLEFT', 10, -10)
m.frame.auctions = Aux.gui.panel(m.frame.content)
m.frame.auctions:SetHeight(228)
m.frame.auctions:SetPoint('BOTTOMLEFT', m.frame.inventory, 'BOTTOMRIGHT', 2.5, 0)
m.frame.auctions:SetPoint('BOTTOMRIGHT', 0, 0)
m.frame.parameters.item:EnableMouse()
m.frame.parameters.item:SetScript('OnReceiveDrag', function()
local item_info = Aux.cursor_item()
if item_info then
m.select_item(item_info.item_key)
end
ClearCursor()
end)
m.frame.parameters.item:SetScript('OnClick', function()
local item_info = Aux.cursor_item()
if item_info then
m.select_item(item_info.item_key)
end
ClearCursor()
end)
local highlight = m.frame.parameters.item:CreateTexture()
highlight:SetAllPoints(m.frame.parameters.item)
highlight:Hide()
highlight:SetTexture(1, .9, .9, .1)
m.frame.parameters.item:SetScript('OnEnter', function()
highlight:Show()
if m.selected_item then
Aux.info.set_tooltip(m.selected_item.itemstring, this, 'ANCHOR_RIGHT')
end
end)
m.frame.parameters.item:SetScript('OnLeave', function()
highlight:Hide()
GameTooltip:Hide()
end)
do
local checkbox = CreateFrame('CheckButton', nil, m.frame.inventory, 'UICheckButtonTemplate')
checkbox:SetWidth(22)
@@ -150,6 +117,41 @@ Aux.post_tab.FRAMES(function(m, public, private)
end)
private.refresh_button = btn
end
do
local item = Aux.gui.item(m.frame.parameters)
item:SetPoint('TOPLEFT', 10, -10)
item:EnableMouse()
item:SetScript('OnReceiveDrag', function()
local item_info = Aux.cursor_item()
if item_info then
m.select_item(item_info.item_key)
end
ClearCursor()
end)
item:SetScript('OnClick', function()
local item_info = Aux.cursor_item()
if item_info then
m.select_item(item_info.item_key)
end
ClearCursor()
end)
local highlight = item:CreateTexture()
highlight:SetPoint('TOPLEFT', -2, 2)
highlight:SetPoint('BOTTOMRIGHT', 2, -2)
highlight:Hide()
highlight:SetTexture(1, .9, .9, .1)
item:SetScript('OnEnter', function()
highlight:Show()
if m.selected_item then
Aux.info.set_tooltip(m.selected_item.itemstring, this, 'ANCHOR_RIGHT')
end
end)
item:SetScript('OnLeave', function()
highlight:Hide()
GameTooltip:Hide()
end)
private.item = item
end
do
local slider = Aux.gui.slider(m.frame.parameters)
slider:SetValueStep(1)