From c104881f468f169beef628fd77d11977ef703e34 Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Sat, 23 Jan 2016 21:40:27 +0100 Subject: [PATCH] added status bar --- core.lua | 19 +++-- core.xml | 89 +----------------------- gui.lua | 158 ++++++++++++++++++++++++++++++++++-------- item_search_frame.lua | 26 +++++-- sheet.lua | 2 +- 5 files changed, 168 insertions(+), 126 deletions(-) diff --git a/core.lua b/core.lua index d015987..8f4a240 100644 --- a/core.lua +++ b/core.lua @@ -71,7 +71,7 @@ function Aux_OnLoad() end do local btn = Aux.gui.button(AuxFrame, 12) - btn:SetPoint('RIGHT', AuxCloseButton, 'LEFT') + btn:SetPoint('TOPRIGHT', 0, 0) btn:SetWidth(60) btn:SetHeight(17) btn:SetText('Default UI') @@ -86,6 +86,17 @@ function Aux_OnLoad() end) end + do + local btn = Aux.gui.button(AuxFrame, 15) + btn:SetPoint('BOTTOMRIGHT', -6, 6) + btn:SetWidth(65) + btn:SetHeight(24) + btn:SetText('Close') + btn:SetScript('OnClick',function() + HideUIPanel(this:GetParent()) + end) + end + Aux.item_search_frame.on_load() Aux.filter_search_frame.on_load() end @@ -160,11 +171,7 @@ function Aux.log_frame_update(elapsedSec) end function Aux.log(msg) - local info = ChatTypeInfo['SYSTEM'] - AuxLogFrameMessageFrame:AddMessage(msg, 1, 1, 0) - if not AuxLogFrameMessageFrame:IsVisible() and DEFAULT_CHAT_FRAME then - DEFAULT_CHAT_FRAME:AddMessage(msg, 1, 1, 0) - end + DEFAULT_CHAT_FRAME:AddMessage(msg, 1, 1, 0) end function Aux_SetupHookFunctions() diff --git a/core.xml b/core.xml index ddff053..4b22bf0 100644 --- a/core.xml +++ b/core.xml @@ -335,7 +335,7 @@ - + @@ -370,92 +370,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - this:SetWidth(floor(this:GetParent():GetWidth()/2)) - - - - - - - - - - - - - - - - - - - Aux.log_frame_load() - - - Aux.log_frame_update(arg1) - - - if arg1 == 1 then - this:ScrollUp() - elseif arg1 == -1 then - this:ScrollDown() - end - - - - - - - diff --git a/gui.lua b/gui.lua index 5ea3270..b47fd97 100644 --- a/gui.lua +++ b/gui.lua @@ -9,6 +9,9 @@ m.config = { content_border_color = {0, 0, 0, 0}, content_font = [[Fonts\ARIALN.TTF]], normal_font_size = 15, + text_color = { enabled = { 255, 254, 250, 1 }, disabled = { 147, 151, 139, 1 } }, + label_color = { enabled = { 216, 225, 211, 1 }, disabled = { 150, 148, 140, 1 } }, + } function m.button(parent, text_height, name) @@ -88,7 +91,7 @@ do image:SetTexture(unpack(m.config.content_color)) tab.image = image local dock = tab:CreateTexture(nil, 'OVERLAY') - dock:SetHeight(2) + dock:SetHeight(3) if position == 'TOP' then dock:SetPoint('BOTTOMLEFT', 1, -1) dock:SetPoint('BOTTOMRIGHT', -1, -1) @@ -158,7 +161,7 @@ do -- tab.dock:Hide() if tab.group.selected == tab.id then -- TSMAPI.Design:SetWidgetLabelColor(tab.text) - tab.text:SetTextColor(255/255, 254/255, 250/255) -- TODO + tab.text:SetTextColor(216/255, 225/255, 211/255) -- TODO tab:Disable() tab.image:SetTexture(unpack(m.config.frame_color)) tab.dock:Show() @@ -206,34 +209,22 @@ do end end -do - local id = 0 - function m.editbox(parent, name) - id = id + 1 +function m.editbox(parent, name) -- local frame = CreateFrame('Frame', name, parent) -- frame:Hide() - local editbox = CreateFrame('EditBox', name, parent) - editbox.selector = Aux.completion.selector(editbox) - editbox:SetAutoFocus(false) --- editbox:SetScript("OnEnter", Control_OnEnter) --- editbox:SetScript("OnLeave", Control_OnLeave) --- editbox:SetScript("OnEscapePressed", EditBox_OnEscapePressed) --- editbox:SetScript("OnEnterPressed", EditBox_OnEnterPressed) --- editbox:SetScript("OnTextChanged", EditBox_OnTextChanged) --- editbox:SetScript("OnReceiveDrag", EditBox_OnReceiveDrag) --- editbox:SetScript("OnMouseDown", EditBox_OnReceiveDrag) --- editbox:SetScript("OnEditFocusGained", EditBox_OnFocusGained) --- editbox:SetScript("OnEditFocusLost", EditBox_OnFocusLost) - editbox:SetTextInsets(0, 0, 3, 3) - editbox:SetMaxLetters(256) - editbox:SetHeight(19) - editbox:SetFont(m.config.content_font, m.config.normal_font_size) - editbox:SetShadowColor(0, 0, 0, 0) - editbox:SetBackdrop({bgFile='Interface\\Buttons\\WHITE8X8', edgeFile='Interface\\Buttons\\WHITE8X8', edgeSize=m.config.edge_size}) - editbox:SetBackdropColor(unpack(m.config.content_color)) - editbox:SetBackdropBorderColor(unpack(m.config.content_border_color)) + local editbox = CreateFrame('EditBox', name, parent) + editbox.selector = Aux.completion.selector(editbox) + editbox:SetAutoFocus(false) + editbox:SetTextInsets(0, 0, 3, 3) + editbox:SetMaxLetters(256) + editbox:SetHeight(19) + editbox:SetFont(m.config.content_font, m.config.normal_font_size) + editbox:SetShadowColor(0, 0, 0, 0) + editbox:SetBackdrop({bgFile='Interface\\Buttons\\WHITE8X8', edgeFile='Interface\\Buttons\\WHITE8X8', edgeSize=m.config.edge_size}) + editbox:SetBackdropColor(unpack(m.config.content_color)) + editbox:SetBackdropBorderColor(unpack(m.config.content_border_color)) -- local label = frame:CreateFontString(nil, 'OVERLAY') -- label:SetPoint('TOPLEFT', 0, -2) @@ -244,6 +235,119 @@ do -- label:SetFont(m.config.content_font, m.config.normal_font_size) -- label:SetShadowColor(0, 0, 0, 0) - return editbox + return editbox +end + +function m.status_bar(parent, base_name) + local self = CreateFrame('Frame', nil, parent) + + local level = parent:GetFrameLevel() + + self:SetFrameLevel(level + 1) + + do + -- minor status bar (gray one) + local status_bar = CreateFrame('STATUSBAR', base_name..'_minor', self, 'TextStatusBar') + status_bar:SetOrientation('HORIZONTAL') + status_bar:SetMinMaxValues(0, 100) + status_bar:SetAllPoints() + status_bar:SetStatusBarTexture('[[Interface\Buttons\WHITE8X8]]') + status_bar:SetStatusBarColor(.42, .42, .42, .7) + status_bar:SetFrameLevel(level + 2) +-- local ag = status_bar:CreateAnimationGroup() +-- local alpha = ag:CreateAnimation('Alpha') +-- alpha:SetDuration(1) +-- alpha:SetChange(-.5) +-- ag:SetLooping('Bounce') +-- status_bar.ag = ag + self.minor_status_bar = status_bar end + + do + -- major status bar (main blue one) + local status_bar = CreateFrame('STATUSBAR', base_name..'_major', self, 'TextStatusBar') + status_bar:SetOrientation('HORIZONTAL') + status_bar:SetMinMaxValues(0, 100) + status_bar:SetAllPoints() + status_bar:SetStatusBarTexture([[Interface\Buttons\WHITE8X8]]) + status_bar:SetStatusBarColor(.19, .22, .33, .9) + status_bar:SetFrameLevel(level + 3) +-- local ag = status_bar:CreateAnimationGroup() +-- local alpha = ag:CreateAnimation('Alpha') +-- alpha:SetDuration(1) +-- alpha:SetChange(-.5) +-- ag:SetLooping('Bounce') +-- status_bar.ag = ag + self.major_status_bar = status_bar + end + + do + local text_frame = CreateFrame('Frame', nil, self) + text_frame:SetFrameLevel(level + 4) + text_frame:SetAllPoints(self) + local text = m.create_label(text_frame) + text:SetTextColor(unpack(m.config.text_color.enabled)) + text:SetPoint('CENTER', 0, 0) + self.text = text + end + + function self:update_status(major_status, minor_status) + if major_status then + self.major_status_bar:SetValue(major_status) +-- if major_status == 100 then +-- self.major_status_bar.ag:Stop() +-- elseif not self.major_status_bar.ag:IsPlaying() then +-- self.major_status_bar.ag:Play() +-- end + end + if minor_status then + self.minor_status_bar:SetValue(minor_status) +-- if minor_status == 100 then +-- self.minor_status_bar.ag:Stop() +-- elseif not self.minor_status_bar.ag:IsPlaying() then +-- self.minor_status_bar.ag:Play() +-- end + end + end + + function self:set_text(text) + self.text:SetText(text) + end + + return self +end + +function m.create_label(parent, size) + local label = parent:CreateFontString() + label:SetFont(m.config.content_font, size or m.config.normal_font_size) + label:SetTextColor(unpack(m.config.label_color.enabled)) + return label +end + +function m.CreateHorizontalLine(parent, ofsy, relativeFrame, invertedColor) + relativeFrame = relativeFrame or parent + local barTex = parent:CreateTexture() + barTex:SetPoint("TOPLEFT", relativeFrame, "TOPLEFT", 2, ofsy) + barTex:SetPoint("TOPRIGHT", relativeFrame, "TOPRIGHT", -2, ofsy) + barTex:SetHeight(2) + if invertedColor then + TSMAPI.Design:SetFrameColor(barTex) + else + TSMAPI.Design:SetContentColor(barTex) + end + return barTex +end + +function m.CreateVerticalLine(parent, ofsx, relativeFrame, invertedColor) + relativeFrame = relativeFrame or parent + local barTex = parent:CreateTexture() + barTex:SetPoint("TOPLEFT", relativeFrame, "TOPLEFT", ofsx, -2) + barTex:SetPoint("BOTTOMLEFT", relativeFrame, "BOTTOMLEFT", ofsx, 2) + barTex:SetWidth(2) + if invertedColor then + TSMAPI.Design:SetFrameColor(barTex) + else + TSMAPI.Design:SetContentColor(barTex) + end + return barTex end \ No newline at end of file diff --git a/item_search_frame.lua b/item_search_frame.lua index 1db9003..944f876 100644 --- a/item_search_frame.lua +++ b/item_search_frame.lua @@ -533,6 +533,15 @@ function public.on_load() this:ClearFocus() end) end + do + local status_bar = Aux.gui.status_bar(AuxItemSearchFrame, 15, 'kekbar') + status_bar:SetWidth(265) + status_bar:SetHeight(30) + status_bar:SetPoint('BOTTOMLEFT', AuxItemSearchFrame, 'BOTTOMLEFT', 6, 6) + status_bar:update_status(0,0) + status_bar:set_text('') + private.status_bar = status_bar + end end function public.dialog_cancel() @@ -634,6 +643,9 @@ function public.start_search() Aux.scan.abort(function() + private.status_bar:update_status(0,0) + private.status_bar:set_text('Scanning auctions...') + AuxItemSearchFrameItemRefreshButton:Hide() AuxItemSearchFrameItemStopButton:Show() @@ -658,7 +670,7 @@ function public.start_search() usable = item_info.usable, } - Aux.log('Scanning auctions ...') +-- Aux.log('Scanning auctions ...') Aux.scan.start{ query = search_query, page = AuxItemSearchFrameItemAllPagesCheckButton:GetChecked() and 0 or AuxItemSearchFrameItemPageEditBox:GetNumber(), @@ -666,7 +678,9 @@ function public.start_search() current_page = nil end, on_page_loaded = function(page, total_pages) - Aux.log('Scanning page '..(page+1)..' out of '..total_pages..' ...') + private.status_bar:update_status(100 * (page + 1) / total_pages, 0) + private.status_bar:set_text(string.format('Scanning (Page %d / %d)', page + 1, total_pages)) +-- Aux.log('Scanning page '..(page+1)..' out of '..total_pages..' ...') current_page = page end, on_read_auction = function(auction_info) @@ -677,7 +691,9 @@ function public.start_search() end, on_complete = function() auctions = auctions or {} - Aux.log('Scan complete: '..getn(auctions)..' '..Aux_PluralizeIf('auction', getn(auctions))..' found.') + private.status_bar:update_status(100, 100) + private.status_bar:set_text('Done Scanning') +-- Aux.log('Scan complete: '..getn(auctions)..' '..Aux_PluralizeIf('auction', getn(auctions))..' found.') AuxItemSearchFrameItemStopButton:Hide() AuxItemSearchFrameItemRefreshButton:Show() @@ -685,7 +701,9 @@ function public.start_search() end, on_abort = function() auctions = auctions or {} - Aux.log('Scan aborted: '..getn(auctions)..' '..Aux_PluralizeIf('auction', getn(auctions))..' found.') + private.status_bar:update_status(100, 100) + private.status_bar:set_text('Done Scanning') +-- Aux.log('Scan aborted: '..getn(auctions)..' '..Aux_PluralizeIf('auction', getn(auctions))..' found.') AuxItemSearchFrameItemStopButton:Hide() AuxItemSearchFrameItemRefreshButton:Show() refresh = true diff --git a/sheet.lua b/sheet.lua index 70298c8..db5bd7c 100644 --- a/sheet.lua +++ b/sheet.lua @@ -175,7 +175,7 @@ function public.create(params) local rows = {} local row_index = 1 local max_height = content:GetHeight() - local total_height = 16 + local total_height = params.plain and 0 or 16 while total_height + 14 < max_height do if getn(params.columns) > 0 then local row = CreateFrame('Button', nil, content)