big refactoring

This commit is contained in:
Manuel Simon Hirsig
2016-08-22 23:08:18 +02:00
parent 2e89efe0af
commit bf4af0cb0a
9 changed files with 64 additions and 62 deletions
+3 -3
View File
@@ -1031,7 +1031,7 @@ function public.CreateAuctionResultsTable(parent, config)
rt.scrollFrame = scrollFrame rt.scrollFrame = scrollFrame
FauxScrollFrame_Update(rt.scrollFrame, 0, numRows, rt.ROW_HEIGHT) FauxScrollFrame_Update(rt.scrollFrame, 0, numRows, rt.ROW_HEIGHT)
local scrollBar = getglobal(scrollFrame:GetName()..'ScrollBar') local scrollBar = _g[scrollFrame:GetName()..'ScrollBar']
scrollBar:ClearAllPoints() scrollBar:ClearAllPoints()
scrollBar:SetPoint('BOTTOMRIGHT', rt, -4, 4) scrollBar:SetPoint('BOTTOMRIGHT', rt, -4, 4)
scrollBar:SetPoint('TOPRIGHT', rt, -4, -HEAD_HEIGHT) scrollBar:SetPoint('TOPRIGHT', rt, -4, -HEAD_HEIGHT)
@@ -1041,8 +1041,8 @@ function public.CreateAuctionResultsTable(parent, config)
thumbTex:SetTexture(color.content.background()) thumbTex:SetTexture(color.content.background())
thumbTex:SetHeight(150) thumbTex:SetHeight(150)
thumbTex:SetWidth(scrollBar:GetWidth()) thumbTex:SetWidth(scrollBar:GetWidth())
getglobal(scrollBar:GetName()..'ScrollUpButton'):Hide() _g[scrollBar:GetName()..'ScrollUpButton']:Hide()
getglobal(scrollBar:GetName()..'ScrollDownButton'):Hide() _g[scrollBar:GetName()..'ScrollDownButton']:Hide()
-- create the header cells -- create the header cells
rt.headCells = {} rt.headCells = {}
+14 -14
View File
@@ -57,7 +57,7 @@ do
blizzard_backdrop = DropDownList1Backdrop:GetBackdrop() blizzard_backdrop = DropDownList1Backdrop:GetBackdrop()
hook('ToggleDropDownMenu', function(...) hook('ToggleDropDownMenu', function(...)
local ret = {orig.ToggleDropDownMenu(unpack(arg))} local ret = {orig.ToggleDropDownMenu(unpack(arg))}
local dropdown = getglobal(arg[4] or '') or this:GetParent() local dropdown = _g[arg[4] or ''] or this:GetParent()
if strfind(dropdown:GetName() or '', '^aux_frame%d+$') then if strfind(dropdown:GetName() or '', '^aux_frame%d+$') then
set_aux_dropdown_style(dropdown) set_aux_dropdown_style(dropdown)
else else
@@ -75,20 +75,20 @@ do
DropDownList1:ClearAllPoints() DropDownList1:ClearAllPoints()
DropDownList1:SetPoint('TOPLEFT', dropdown, 'BOTTOMLEFT', -2, -2) DropDownList1:SetPoint('TOPLEFT', dropdown, 'BOTTOMLEFT', -2, -2)
for i=1,UIDROPDOWNMENU_MAXBUTTONS do for i=1,UIDROPDOWNMENU_MAXBUTTONS do
local button = getglobal('DropDownList1Button'..i) local button = _g['DropDownList1Button'..i]
button:SetPoint('TOPLEFT', 0, -((button:GetID() - 1) * UIDROPDOWNMENU_BUTTON_HEIGHT) - 7) button:SetPoint('TOPLEFT', 0, -((button:GetID() - 1) * UIDROPDOWNMENU_BUTTON_HEIGHT) - 7)
button:SetPoint('TOPRIGHT', 0, -((button:GetID() - 1) * UIDROPDOWNMENU_BUTTON_HEIGHT) - 7) button:SetPoint('TOPRIGHT', 0, -((button:GetID() - 1) * UIDROPDOWNMENU_BUTTON_HEIGHT) - 7)
local text = button:GetFontString() local text = button:GetFontString()
text:SetFont(font, font_size.small2) text:SetFont(font, font_size.small2)
text:SetPoint('TOPLEFT', 18, 0) text:SetPoint('TOPLEFT', 18, 0)
text:SetPoint('BOTTOMRIGHT', -8, 0) text:SetPoint('BOTTOMRIGHT', -8, 0)
local highlight = getglobal('DropDownList1Button'..i..'Highlight') local highlight = _g['DropDownList1Button'..i..'Highlight']
highlight:ClearAllPoints() highlight:ClearAllPoints()
highlight:SetDrawLayer 'OVERLAY' highlight:SetDrawLayer 'OVERLAY'
highlight:SetHeight(14) highlight:SetHeight(14)
highlight:SetPoint('LEFT', 5, 0) highlight:SetPoint('LEFT', 5, 0)
highlight:SetPoint('RIGHT', -3, 0) highlight:SetPoint('RIGHT', -3, 0)
local check = getglobal('DropDownList1Button'..i..'Check') local check = _g['DropDownList1Button'..i..'Check']
check:SetWidth(16) check:SetWidth(16)
check:SetHeight(16) check:SetHeight(16)
check:SetPoint('LEFT', 3, -1) check:SetPoint('LEFT', 3, -1)
@@ -100,14 +100,14 @@ do
aux_border:Hide() aux_border:Hide()
aux_background:Hide() aux_background:Hide()
for i=1,UIDROPDOWNMENU_MAXBUTTONS do for i=1,UIDROPDOWNMENU_MAXBUTTONS do
local button = getglobal('DropDownList1Button'..i) local button = _g['DropDownList1Button'..i]
local text = button:GetFontString() local text = button:GetFontString()
text:SetFont([[Fonts\FRIZQT__.ttf]], 10) text:SetFont([[Fonts\FRIZQT__.ttf]], 10)
text:SetShadowOffset(1, -1) text:SetShadowOffset(1, -1)
local highlight = getglobal('DropDownList1Button'..i..'Highlight') local highlight = _g['DropDownList1Button'..i..'Highlight']
highlight:SetAllPoints() highlight:SetAllPoints()
highlight:SetDrawLayer 'BACKGROUND' highlight:SetDrawLayer 'BACKGROUND'
local check = getglobal('DropDownList1Button'..i..'Check') local check = _g['DropDownList1Button'..i..'Check']
check:SetWidth(24) check:SetWidth(24)
check:SetHeight(24) check:SetHeight(24)
check:SetPoint('LEFT', 0, 0) check:SetPoint('LEFT', 0, 0)
@@ -464,13 +464,13 @@ function public.item(parent)
btn:SetPoint('LEFT', 2, .5) btn:SetPoint('LEFT', 2, .5)
btn:SetHighlightTexture(nil) btn:SetHighlightTexture(nil)
btn:RegisterForClicks() btn:RegisterForClicks()
item.texture = getglobal(btn:GetName()..'Icon') item.texture = _g[btn:GetName()..'Icon']
item.texture:SetTexCoord(.06, .94, .06, .94) item.texture:SetTexCoord(.06, .94, .06, .94)
item.name = label(btn, 15) item.name = label(btn, 15)
item.name:SetJustifyH 'LEFT' item.name:SetJustifyH 'LEFT'
item.name:SetPoint('LEFT', btn, 'RIGHT', 10, 0) item.name:SetPoint('LEFT', btn, 'RIGHT', 10, 0)
item.name:SetPoint('RIGHT', item, 'RIGHT', -10, .5) item.name:SetPoint('RIGHT', item, 'RIGHT', -10, .5)
item.count = getglobal(btn:GetName()..'Count') item.count = _g[btn:GetName()..'Count']
item.count:SetTextHeight(17) item.count:SetTextHeight(17)
return item return item
end end
@@ -512,17 +512,17 @@ function public.dropdown(parent)
local dropdown = CreateFrame('Frame', name, parent, 'UIDropDownMenuTemplate') local dropdown = CreateFrame('Frame', name, parent, 'UIDropDownMenuTemplate')
set_content_style(dropdown, 0, 0, 4, 4) set_content_style(dropdown, 0, 0, 4, 4)
getglobal(dropdown:GetName()..'Left'):Hide() _g[dropdown:GetName()..'Left']:Hide()
getglobal(dropdown:GetName()..'Middle'):Hide() _g[dropdown:GetName()..'Middle']:Hide()
getglobal(dropdown:GetName()..'Right'):Hide() _g[dropdown:GetName()..'Right']:Hide()
local button = getglobal(dropdown:GetName()..'Button') local button = _g[dropdown:GetName()..'Button']
button:ClearAllPoints() button:ClearAllPoints()
button:SetScale(0.9) button:SetScale(0.9)
button:SetPoint('RIGHT', dropdown, 0, 0) button:SetPoint('RIGHT', dropdown, 0, 0)
dropdown.button = button dropdown.button = button
local text = getglobal(dropdown:GetName()..'Text') local text = _g[dropdown:GetName()..'Text']
text:ClearAllPoints() text:ClearAllPoints()
text:SetPoint('RIGHT', button, 'LEFT', -2, 0) text:SetPoint('RIGHT', button, 'LEFT', -2, 0)
text:SetPoint('LEFT', 8, 0) text:SetPoint('LEFT', 8, 0)
+3 -3
View File
@@ -48,15 +48,15 @@ function public.create(parent, on_click, selected)
scroll_frame:SetPoint('TOPLEFT', content, 'TOPLEFT', 0, 15) scroll_frame:SetPoint('TOPLEFT', content, 'TOPLEFT', 0, 15)
scroll_frame:SetPoint('BOTTOMRIGHT', content, 'BOTTOMRIGHT', -4, -15) scroll_frame:SetPoint('BOTTOMRIGHT', content, 'BOTTOMRIGHT', -4, -15)
local scrollBar = getglobal(scroll_frame:GetName()..'ScrollBar') local scrollBar = _g[scroll_frame:GetName()..'ScrollBar']
scrollBar:SetWidth(12) scrollBar:SetWidth(12)
local thumbTex = scrollBar:GetThumbTexture() local thumbTex = scrollBar:GetThumbTexture()
thumbTex:SetPoint('CENTER', 0, 0) thumbTex:SetPoint('CENTER', 0, 0)
thumbTex:SetTexture(color.content.background()) thumbTex:SetTexture(color.content.background())
thumbTex:SetHeight(50) thumbTex:SetHeight(50)
thumbTex:SetWidth(12) thumbTex:SetWidth(12)
getglobal(scrollBar:GetName()..'ScrollUpButton'):Hide() _g[scrollBar:GetName()..'ScrollUpButton']:Hide()
getglobal(scrollBar:GetName()..'ScrollDownButton'):Hide() _g[scrollBar:GetName()..'ScrollDownButton']:Hide()
local rows = {} local rows = {}
local row_index = 1 local row_index = 1
+3 -3
View File
@@ -424,7 +424,7 @@ function public.CreateScrollingTable(parent)
scrollFrame:SetAllPoints(contentFrame) scrollFrame:SetAllPoints(contentFrame)
st.scrollFrame = scrollFrame st.scrollFrame = scrollFrame
local scrollBar = getglobal(scrollFrame:GetName()..'ScrollBar') local scrollBar = _g[scrollFrame:GetName()..'ScrollBar']
scrollBar:SetWidth(12) scrollBar:SetWidth(12)
st.scrollBar = scrollBar st.scrollBar = scrollBar
local thumbTex = scrollBar:GetThumbTexture() local thumbTex = scrollBar:GetThumbTexture()
@@ -432,8 +432,8 @@ function public.CreateScrollingTable(parent)
thumbTex:SetTexture(color.content.background()) thumbTex:SetTexture(color.content.background())
thumbTex:SetHeight(50) thumbTex:SetHeight(50)
thumbTex:SetWidth(12) thumbTex:SetWidth(12)
getglobal(scrollBar:GetName()..'ScrollUpButton'):Hide() _g[scrollBar:GetName()..'ScrollUpButton']:Hide()
getglobal(scrollBar:GetName()..'ScrollDownButton'):Hide() _g[scrollBar:GetName()..'ScrollDownButton']:Hide()
-- create head line at default position -- create head line at default position
st.headLine = gui.horizontal_line(st, 0) st.headLine = gui.horizontal_line(st, 0)
+2 -2
View File
@@ -20,7 +20,7 @@ StaticPopupDialogs['AUX_SEARCH_AUTO_BUY'] = {
} }
do do
local function action() local function action()
_g.aux_auto_buy_filter = getglobal(this:GetParent():GetName()..'EditBox'):GetText() _g.aux_auto_buy_filter = _g[this:GetParent():GetName()..'EditBox']:GetText()
update_auto_buy_filter() update_auto_buy_filter()
end end
@@ -30,7 +30,7 @@ do
button2 = 'Cancel', button2 = 'Cancel',
hasEditBox = 1, hasEditBox = 1,
OnShow = function() OnShow = function()
local edit_box = getglobal(this:GetName()..'EditBox') local edit_box = _g[this:GetName()..'EditBox']
edit_box:SetMaxLetters(nil) edit_box:SetMaxLetters(nil)
edit_box:SetFocus() edit_box:SetFocus()
edit_box:HighlightText() edit_box:HighlightText()
+4 -4
View File
@@ -125,13 +125,13 @@ function get_filter_builder_query()
for _, subclass in {blizzard_query.subclass} do for _, subclass in {blizzard_query.subclass} do
local subclasses = {GetAuctionItemSubClasses(class)} local subclasses = {GetAuctionItemSubClasses(class)}
add(strlower(subclasses[subclass])) add(strlower(subclasses[subclass]))
add(blizzard_query.slot and strlower(getglobal(blizzard_query.slot))) add(blizzard_query.slot and strlower(_g[blizzard_query.slot]))
end end
end end
local quality = blizzard_query.quality local quality = blizzard_query.quality
if quality and quality >= 0 then if quality and quality >= 0 then
add(strlower(getglobal('ITEM_QUALITY'..quality..'_DESC'))) add(strlower(_g['ITEM_QUALITY'..quality..'_DESC']))
end end
local post_filter_string = filter.query_string{blizzard={}, post=post_filter} local post_filter_string = filter.query_string{blizzard={}, post=post_filter}
@@ -412,7 +412,7 @@ function initialize_slot_dropdown()
for _, slot in {GetAuctionInvTypes(class_index, subclass_index)} do for _, slot in {GetAuctionInvTypes(class_index, subclass_index)} do
UIDropDownMenu_AddButton{ UIDropDownMenu_AddButton{
text = getglobal(slot), text = _g[slot],
value = slot, value = slot,
func = on_click, func = on_click,
} }
@@ -433,7 +433,7 @@ function initialize_quality_dropdown()
} }
for i=0,4 do for i=0,4 do
UIDropDownMenu_AddButton{ UIDropDownMenu_AddButton{
text = getglobal('ITEM_QUALITY'..i..'_DESC'), text = _g['ITEM_QUALITY'..i..'_DESC'],
value = i, value = i,
func = on_click, func = on_click,
} }
+1 -1
View File
@@ -499,7 +499,7 @@ function create_frames()
dropdown:SetScript('OnShow', function() dropdown:SetScript('OnShow', function()
UIDropDownMenu_Initialize(this, initialize_filter_dropdown) UIDropDownMenu_Initialize(this, initialize_filter_dropdown)
end) end)
getglobal(dropdown:GetName()..'Text'):Hide() _g[dropdown:GetName()..'Text']:Hide()
local label = gui.label(dropdown, gui.font_size.medium) local label = gui.label(dropdown, gui.font_size.medium)
label:SetPoint('RIGHT', dropdown, 'LEFT', -15, 0) label:SetPoint('RIGHT', dropdown, 'LEFT', -15, 0)
label:SetText('Post Filter') label:SetText('Post Filter')
+2 -2
View File
@@ -392,7 +392,7 @@ function suggestions(components)
-- slots -- slots
if not components.blizzard.slot then if not components.blizzard.slot then
for _, invtype in {GetAuctionInvTypes(index(components.blizzard.class, 2) or 0, index(components.blizzard.subclass, 2) or 0)} do for _, invtype in {GetAuctionInvTypes(index(components.blizzard.class, 2) or 0, index(components.blizzard.subclass, 2) or 0)} do
tinsert(suggestions, getglobal(invtype)) tinsert(suggestions, _g[invtype])
end end
end end
@@ -401,7 +401,7 @@ function suggestions(components)
-- rarities -- rarities
if not components.blizzard.quality then if not components.blizzard.quality then
for i=0,4 do tinsert(suggestions, getglobal('ITEM_QUALITY'..i..'_DESC')) end for i=0,4 do tinsert(suggestions, _g['ITEM_QUALITY'..i..'_DESC']) end
end end
-- item names -- item names
+32 -30
View File
@@ -238,8 +238,8 @@ function public.load_tooltip(frame, tooltip)
end end
end end
for i =1,getn(tooltip) do -- TODO why is this needed? for i =1,getn(tooltip) do -- TODO why is this needed?
getglobal(frame:GetName()..'TextLeft'..i):SetJustifyH('LEFT') _g[frame:GetName()..'TextLeft'..i]:SetJustifyH('LEFT')
getglobal(frame:GetName()..'TextRight'..i):SetJustifyH('LEFT') _g[frame:GetName()..'TextRight'..i]:SetJustifyH('LEFT')
end end
end end
@@ -250,7 +250,7 @@ function public.display_name(item_id, no_brackets, no_color)
name = '['..name..']' name = '['..name..']'
end end
if not no_color then if not no_color then
name = ({GetItemQualityColor(item_info.quality)})[4]..name..FONT_COLOR_CODE_CLOSE name = select(4, GetItemQualityColor(item_info.quality))..name..FONT_COLOR_CODE_CLOSE
end end
return name return name
end end
@@ -274,12 +274,12 @@ function public.tooltip(mutator)
AuxTooltip:Show() AuxTooltip:Show()
local tooltip = {} local tooltip = {}
for i = 1,AuxTooltip:NumLines() do for i=1,AuxTooltip:NumLines() do
tinsert(tooltip, { tinsert(tooltip, {
left_text = getglobal('AuxTooltipTextLeft'..i):GetText(), left_text = _g['AuxTooltipTextLeft'..i]:GetText(),
left_color = {getglobal('AuxTooltipTextLeft'..i):GetTextColor()}, left_color = {_g['AuxTooltipTextLeft'..i]:GetTextColor()},
right_text = getglobal('AuxTooltipTextRight'..i):IsVisible() and getglobal('AuxTooltipTextRight'..i):GetText(), right_text = _g['AuxTooltipTextRight'..i]:IsVisible() and _g['AuxTooltipTextRight'..i]:GetText(),
right_color = {getglobal('AuxTooltipTextRight'..i):GetTextColor()}, right_color = {_g['AuxTooltipTextRight'..i]:GetTextColor()},
}) })
end end
@@ -301,29 +301,31 @@ function item_charges(tooltip)
return 1 return 1
end end
function public.max_item_charges(item_id) do
return ({ local data = {
-- wizard oil -- wizard oil
[20744] = 5, [20744] = 5,
[20746] = 5, [20746] = 5,
[20750] = 5, [20750] = 5,
[20749] = 5, [20749] = 5,
-- mana oil -- mana oil
[20745] = 5, [20745] = 5,
[20747] = 5, [20747] = 5,
[20748] = 5, [20748] = 5,
-- discombobulator -- discombobulator
[4388] = 5, [4388] = 5,
-- recombobulator -- recombobulator
[4381] = 10, [4381] = 10,
[18637] = 10, [18637] = 10,
-- ... TODO -- ... TODO
}
})[item_id] function public.max_item_charges(item_id)
return data[item_id]
end
end end
function public.durability(tooltip) function public.durability(tooltip)
@@ -389,15 +391,15 @@ end
function public.item_slot_index(class_index, subclass_index, slot_name) function public.item_slot_index(class_index, subclass_index, slot_name)
for i, slot in {GetAuctionInvTypes(class_index, subclass_index)} do for i, slot in {GetAuctionInvTypes(class_index, subclass_index)} do
if strupper(getglobal(slot)) == strupper(slot_name) then if strupper(_g[slot]) == strupper(slot_name) then
return i, getglobal(slot) return i, _g[slot]
end end
end end
end end
function public.item_quality_index(item_quality) function public.item_quality_index(item_quality)
for i=0,4 do for i=0,4 do
local quality = getglobal('ITEM_QUALITY'..i..'_DESC') local quality = _g['ITEM_QUALITY'..i..'_DESC']
if strupper(item_quality) == strupper(quality) then if strupper(item_quality) == strupper(quality) then
return i, quality return i, quality
end end