diff --git a/control.lua b/control.lua index 991ea95..3a796c2 100644 --- a/control.lua +++ b/control.lua @@ -6,11 +6,11 @@ private.threads = {} public.thread_id = nil function m.LOAD() - m.event_frame:SetScript('OnUpdate', m.on_update) - m.event_frame:SetScript('OnEvent', m.on_event) + m.event_frame:SetScript('OnUpdate', m.UPDATE) + m.event_frame:SetScript('OnEvent', m.EVENT) end -function private.on_event() +function private.EVENT() for _, listener in m.listeners do if event == listener.event and not listener.killed then listener.cb(listener.kill) @@ -18,7 +18,7 @@ function private.on_event() end end -function private.on_update() +function private.UPDATE() for _, listener in m.listeners do if not aux.util.any(m.listeners, function(l) return not l.killed and l.event == listener.event end) then m.event_frame:UnregisterEvent(listener.event) @@ -42,6 +42,14 @@ function private.on_update() end end +do + local id = 0 + function private.id() + id = id + 1 + return id + end +end + function public.kill_listener(listener_id) for _, listener in {m.listeners[listener_id]} do listener.killed = true @@ -55,7 +63,7 @@ function public.kill_thread(thread_id) end function public.event_listener(event, cb) - local listener_id = aux.id() + local listener_id = m.id() m.listeners[listener_id] = { event=event, cb=cb, kill=function(...) if arg.n == 0 or arg[1] then m.kill_listener(listener_id) end end } m.event_frame:RegisterEvent(event) return listener_id @@ -69,7 +77,7 @@ function public.on_next_event(event, callback) end function public.thread(k, ...) - local thread_id = aux.id() + local thread_id = m.id() m.threads[thread_id] = { k = aux._(k, unpack(arg)) } return thread_id end diff --git a/core.lua b/core.lua index 1535d76..98ca4c8 100644 --- a/core.lua +++ b/core.lua @@ -65,8 +65,8 @@ end function public.VARIABLES_LOADED() do - local frame = CreateFrame('Frame', 'AuxFrame', UIParent) - tinsert(UISpecialFrames, 'AuxFrame') + local frame = CreateFrame('Frame', aux.gui.name(), UIParent) + tinsert(UISpecialFrames, 'aux_frame1') m.gui.set_window_style(frame) frame:SetWidth(768) frame:SetHeight(447) @@ -397,14 +397,6 @@ end public.huge = 2^100000 -do - local x = 0 - function public.id() - x = x + 1 - return x - end -end - function public.log(...) local msg = '[aux]' for i=1,arg.n do diff --git a/gui.lua b/gui.lua index 9746d47..a9a0727 100644 --- a/gui.lua +++ b/gui.lua @@ -45,13 +45,18 @@ public.inline_color = aux.index_function(function(self, key) return format('|c%02X%02X%02X%02X', unpack(color)) end) ---/run aux.gui.menu('kek', 'kuk', 'kok', function() end) do - local dropdown + local id = 0 + function public.name() + id = id + 1 + return 'aux_frame'..id + end +end + +do + local menu function public.menu(...) - local mythis = this - this = dropdown UIMenu_Initialize() for i=1,arg.n-1 do UIMenu_AddButton( @@ -62,36 +67,16 @@ do end ) end - dropdown:SetPoint('BOTTOMLEFT', GetCursorPosition()) - dropdown:Show() - this = mythis + menu:SetPoint('BOTTOMLEFT', GetCursorPosition()) + menu:Show() end --- function public.menu(...) --- UIDropDownMenu_Initialize(dropdown, function() --- for i=1,arg.n-1 do --- UIDropDownMenu_AddButton{ --- text = arg[i], --- value = i, --- func = function() --- return arg[arg.n](this.value) --- end, --- } --- end --- end, 'MENU') --- dropdown:SetPoint('BOTTOMLEFT', GetCursorPosition()) --- ToggleDropDownMenu(nil, nil, dropdown, nil, 0, 0) --- end - --- function private.initialize_menu() --- dropdown = CreateFrame('Frame', 'aux_frame'..aux.id(), UIParent, 'UIDropDownMenuTemplate') --- dropdown:SetWidth(1) --- dropdown:SetHeight(1) --- dropdown:SetAlpha(0) --- end - function private.initialize_menu() - dropdown = CreateFrame('Frame', 'aux_frame'..aux.id(), UIParent, 'UIMenuTemplate') + menu = CreateFrame('Frame', m.name(), UIParent, 'UIMenuTemplate') + local orig = menu:GetScript('OnShow') + menu:SetScript('OnShow', function() + + end) end end @@ -259,7 +244,7 @@ function public.tab_group(parent, orientation) function self:create_tab(text) local id = getn(self.tabs) + 1 - local tab = CreateFrame('Button', 'aux_tab_group'..self.id..'_tab'..id, self.frame) + local tab = CreateFrame('Button', m.name(), self.frame) tab.id = id tab.group = self tab:SetHeight(24) @@ -320,11 +305,11 @@ function public.tab_group(parent, orientation) function self:set_tab(id) self.selected = id - self.update_tabs() + self:update_tabs() aux.call(self.on_select, id) end - function self.update_tabs() + function self:update_tabs() for _, tab in self.tabs do if tab.group.selected == tab.id then tab.text:SetTextColor(unpack(m.color.label.enabled)) @@ -450,7 +435,7 @@ function public.item(parent) local item = CreateFrame('Frame', nil, parent) item:SetWidth(260) item:SetHeight(40) - local btn = CreateFrame('CheckButton', 'aux_frame'..aux.id(), item, 'ActionButtonTemplate') + local btn = CreateFrame('CheckButton', m.name(), item, 'ActionButtonTemplate') item.button = btn btn:SetPoint('LEFT', 2, .5) btn:SetHighlightTexture(nil) @@ -501,7 +486,7 @@ end function public.dropdown(parent) - local dropdown = CreateFrame('Frame', 'aux_frame'..aux.id(), parent, 'UIDropDownMenuTemplate') + local dropdown = CreateFrame('Frame', m.name(), parent, 'UIDropDownMenuTemplate') m.set_content_style(dropdown, 0, 0, 2, 2) getglobal(dropdown:GetName()..'Left'):Hide() diff --git a/tables/auction_listing.lua b/tables/auction_listing.lua index 1bc4c4f..1e56ab8 100644 --- a/tables/auction_listing.lua +++ b/tables/auction_listing.lua @@ -1005,9 +1005,8 @@ local methods = { function public.CreateAuctionResultsTable(parent, config) - local rtName = 'aux_frame'..aux.id() RT_COUNT = RT_COUNT + 1 - local rt = CreateFrame('Frame', rtName, parent) + local rt = CreateFrame('Frame', nil, parent) rt.config = config local numRows = 16 rt.ROW_HEIGHT = (parent:GetHeight() - HEAD_HEIGHT - HEAD_SPACE) / numRows @@ -1030,14 +1029,14 @@ function public.CreateAuctionResultsTable(parent, config) end end) - local contentFrame = CreateFrame('Frame', rtName..'Content', rt) + local contentFrame = CreateFrame('Frame', nil, rt) contentFrame:SetPoint('TOPLEFT', 0, 0) contentFrame:SetPoint('BOTTOMRIGHT', -15, 0) -- contentFrame:SetScript('OnSizeChanged', rt.OnContentSizeChanged) rt.contentFrame = contentFrame -- frame to hold the header columns and the rows - local scrollFrame = CreateFrame('ScrollFrame', rtName..'ScrollFrame', rt, 'FauxScrollFrameTemplate') + local scrollFrame = CreateFrame('ScrollFrame', aux.gui.name(), rt, 'FauxScrollFrameTemplate') scrollFrame:SetScript('OnVerticalScroll', function() if not rt.scrollDisabled then FauxScrollFrame_OnVerticalScroll(rt.ROW_HEIGHT, function() rt:UpdateRows() end) @@ -1063,7 +1062,7 @@ function public.CreateAuctionResultsTable(parent, config) -- create the header cells rt.headCells = {} for i, column_config in rt.config do - local cell = CreateFrame('Button', rtName..'HeadCol'..i, rt.contentFrame) + local cell = CreateFrame('Button', nil, rt.contentFrame) cell:SetHeight(HEAD_HEIGHT) if i == 1 then cell:SetPoint('TOPLEFT', 0, 0) @@ -1106,7 +1105,7 @@ function public.CreateAuctionResultsTable(parent, config) -- create the rows rt.rows = {} for i=1, numRows do - local row = CreateFrame('Frame', rtName..'Row'..i, rt.contentFrame) + local row = CreateFrame('Frame', nil, rt.contentFrame) row:SetHeight(rt.ROW_HEIGHT) if i == 1 then row:SetPoint('TOPLEFT', 0, -(HEAD_HEIGHT + HEAD_SPACE))