diff --git a/BagSync.lua b/BagSync.lua index aa2f0e2..edea094 100644 --- a/BagSync.lua +++ b/BagSync.lua @@ -843,19 +843,42 @@ function BSYC:GetClassColor(sName, sClass) return tooltipColor(self.options.colors.first, sName) end -function BSYC:AddCurrencyTooltip(frame, currencyName) +function BSYC:AddCurrencyTooltip(frame, currencyName, addHeader) if not BagSyncOpt.enableTooltips then return end ---[[ if currencyName and self.db.currency[self.currentRealm][currencyName] then - if self.options.enableTooltipSeperator then + + local tmp = {} + local count = 0 + + local xDB = BSYC:FilterDB(2) --dbSelect 2 + + for k, v in pairs(xDB) do + local yName, yRealm = strsplit("^", k) + local playerName = BSYC:GetCharacterRealmInfo(yName, yRealm) + + for q, r in pairs(v) do + if q == currencyName then + --we only really want to list the currency once for display + table.insert(tmp, { name=playerName, count=r.count} ) + count = count + 1 + end + end + end + + if count > 0 then + table.sort(tmp, function(a,b) return (a.name < b.name) end) + if self.options.enableTooltipSeperator and not addHeader then frame:AddLine(" ") end - for charName, count in pairsByKeys(self.db.currency[self.currentRealm][currencyName]) do - if charName ~= "icon" and charName ~= "header" and count > 0 then - frame:AddDoubleLine(charName, count) - end + if addHeader then + local color = { r = 64/255, g = 224/255, b = 208/255 } --same color as header in Currency window + frame:AddLine(rgbhex(color)..currencyName.."|r") end - frame:Show() - end ]] + for i=1, #tmp do + frame:AddDoubleLine(tooltipColor(BagSyncOpt.colors.first, tmp[i].name), tooltipColor(BagSyncOpt.colors.second, tmp[i].count)) + end + end + + frame:Show() end function BSYC:AddItemToTooltip(frame, link) --workaround @@ -875,10 +898,10 @@ function BSYC:AddItemToTooltip(frame, link) --workaround end --ignore the hearthstone and blacklisted items - -- if itemLink and tonumber(itemLink) and (tonumber(itemLink) == 6948 or tonumber(itemLink) == 110560 or tonumber(itemLink) == 140192 or self.db.blacklist[self.currentRealm][tonumber(itemLink)]) then - -- frame:Show() - -- return - -- end + if itemLink and tonumber(itemLink) and (tonumber(itemLink) == 6948 or tonumber(itemLink) == 110560 or tonumber(itemLink) == 140192 or self.db.blacklist[self.currentRealm][tonumber(itemLink)]) then + frame:Show() + return + end --lag check (check for previously displayed data) if so then display it if self.PreviousItemLink and itemLink and itemLink == self.PreviousItemLink then @@ -1176,7 +1199,7 @@ function BSYC:ChatCommand(input) self:ShowMoneyTooltip() return true elseif cmd == L.SlashCurrency then - BSYC:GetModule("Currency").frame:Show() + self:GetModule("Currency").frame:Show() return true elseif cmd == L.SlashProfiles then self:GetModule("Profiles").frame:Show() @@ -1214,13 +1237,36 @@ function BSYC:ChatCommand(input) end ------------------------------ +-- KEYBINDING -- +------------------------------ + +function BagSync_ShowWindow(windowName) + if windowName == "Search" then + BSYC:GetModule("Search"):StartSearch() + elseif windowName == "Gold" then + BSYC:ShowMoneyTooltip() + else + BSYC:GetModule(windowName).frame:Show() + end +end + +------------------------------ -- LOGIN HANDLER -- ------------------------------ function BSYC:OnEnable() --NOTE: Using OnEnable() instead of OnInitialize() because not all the SavedVarables fully loaded --also one of the major issues is that UnitFullName() will return nil for the short named realm - + + --load the keybinding locale information + BINDING_HEADER_BAGSYNC = "BagSync" + BINDING_NAME_BAGSYNCBLACKLIST = L.KeybindBlacklist + BINDING_NAME_BAGSYNCCURRENCY = L.KeybindCurrency + BINDING_NAME_BAGSYNCGOLD = L.KeybindGold + BINDING_NAME_BAGSYNCPROFESSIONS = L.KeybindProfessions + BINDING_NAME_BAGSYNCPROFILES = L.KeybindProfiles + BINDING_NAME_BAGSYNCSEARCH = L.KeybindSearch + local ver = GetAddOnMetadata("BagSync","Version") or 0 --load our player info after login diff --git a/BagSync.toc b/BagSync.toc index 2e45b4e..4eca3a0 100644 --- a/BagSync.toc +++ b/BagSync.toc @@ -40,4 +40,6 @@ modules\professions.lua modules\recipes.lua modules\blacklist.lua modules\profiles.lua -modules\config.lua \ No newline at end of file +modules\config.lua + +Bindings.xml \ No newline at end of file diff --git a/Bindings.xml b/Bindings.xml index bf01d65..6d16795 100644 --- a/Bindings.xml +++ b/Bindings.xml @@ -1,37 +1,20 @@ <Bindings> - <Binding name="BAGSYNCTOGGLESEARCH" header="BAGSYNC"> - if BagSync_SearchFrame:IsVisible() then - BagSync_SearchFrame:Hide() - else - BagSync_SearchFrame:Show() - end + <Binding name="BAGSYNCBLACKLIST" header="BAGSYNC" category="ADDONS"> + BagSync_ShowWindow("Blacklist"); </Binding> - <Binding name="BAGSYNCTOGGLETOKENS"> - if BagSync_TokensFrame:IsVisible() then - BagSync_TokensFrame:Hide() - else - BagSync_TokensFrame:Show() - end + <Binding name="BAGSYNCCURRENCY" header="BAGSYNC" category="ADDONS"> + BagSync_ShowWindow("Currency"); </Binding> - <Binding name="BAGSYNCTOGGLEPROFILES"> - if BagSync_ProfilesFrame:IsVisible() then - BagSync_ProfilesFrame:Hide() - else - BagSync_ProfilesFrame:Show() - end + <Binding name="BAGSYNCGOLD" header="BAGSYNC" category="ADDONS"> + BagSync_ShowWindow("Gold"); </Binding> - <Binding name="BAGSYNCTOGGLECRAFTS"> - if BagSync_CraftsFrame:IsVisible() then - BagSync_CraftsFrame:Hide() - else - BagSync_CraftsFrame:Show() - end + <Binding name="BAGSYNCPROFESSIONS" header="BAGSYNC" category="ADDONS"> + BagSync_ShowWindow("Professions"); </Binding> - <Binding name="BAGSYNCTOGGLEBLACKLIST"> - if BagSync_BlackListFrame:IsVisible() then - BagSync_BlackListFrame:Hide() - else - BagSync_BlackListFrame:Show() - end + <Binding name="BAGSYNCPROFILES" header="BAGSYNC" category="ADDONS"> + BagSync_ShowWindow("Profiles"); + </Binding> + <Binding name="BAGSYNCSEARCH" header="BAGSYNC" category="ADDONS"> + BagSync_ShowWindow("Search"); </Binding> </Bindings> diff --git a/locale/deDE.lua b/locale/deDE.lua index 0990297..a976594 100644 --- a/locale/deDE.lua +++ b/locale/deDE.lua @@ -26,8 +26,6 @@ L.Config = "Einstellungen" L.DeleteWarning = "Wähle ein Profil zum löschen aus.\nINFO: Dies ist nicht umkehrbar!" L.Delete = "Löschen" L.Confirm = "Bestätigen" -L.ToggleSearch = "Öffne/Schließe Suche" -L.ToggleProfiles = "Öffne/Schließe Profile" L.FixDBComplete = "Die Funktion FixDB wurde ausgeführt! Die Datenbank wurde optimiert!" L.ON = "An" L.OFF = "Aus" diff --git a/locale/enUS.lua b/locale/enUS.lua index d118927..33fdd45 100644 --- a/locale/enUS.lua +++ b/locale/enUS.lua @@ -26,11 +26,6 @@ L.Config = "Config" L.DeleteWarning = "Select a profile to delete.\nNOTE: This is irreversible!" L.Delete = "Delete" L.Confirm = "Confirm" -L.ToggleSearch = "Toggle Search" -L.ToggleCurrency = "Toggle Currency" -L.ToggleProfiles = "Toggle Profiles" -L.ToggleProfessions = "Toggle Professions" -L.ToggleBlacklist = "Toggle Blacklist" L.FixDBComplete = "A FixDB has been performed on BagSync! The database is now optimized!" L.ON = "ON" L.OFF = "OFF" @@ -51,6 +46,12 @@ L.ItemIDExist = "[%d] ItemID already in database." L.ProfessionsFailedRequest = "[%d] Server Request Failed." L.ProfessionHasRecipes = "Left click to view recipes." L.ProfessionHasNoRecipes = "Has no recipes to view." +L.KeybindBlacklist = "Show Blacklist window." +L.KeybindCurrency = "Show Currency window." +L.KeybindGold = "Show Gold tooltip." +L.KeybindProfessions = "Show Professions window." +L.KeybindProfiles = "Show Profiles window." +L.KeybindSearch = "Show Search window." -- ----THESE ARE FOR SLASH COMMANDS L.SlashItemName = "[itemname]" L.SlashSearch = "search" diff --git a/locale/esES.lua b/locale/esES.lua index 292039d..f18eeff 100644 --- a/locale/esES.lua +++ b/locale/esES.lua @@ -26,10 +26,6 @@ L.Config = "Configuración" L.DeleteWarning = "Seleccione el perfil a eliminar,\nNOTE: no podrá volver atrás" L.Delete = "Eliminar" L.Confirm = "Confirmar" -L.ToggleSearch = "Conmutar Búsqueda" -L.ToggleProfiles = "Conmutar Perfiles" -L.ToggleProfessions = "Conmutar Profesiones" -L.ToggleBlacklist = "Conmutar Lista negra" L.FixDBComplete = "¡La reparación de la BD se ha realizado! La base de datos está optimizada" L.ON = "Encender" L.OFF = "Apagar" diff --git a/locale/koKR.lua b/locale/koKR.lua index da1a300..18ea9d6 100644 --- a/locale/koKR.lua +++ b/locale/koKR.lua @@ -23,10 +23,6 @@ L.Config = "설정" L.DeleteWarning = "삭제할 프로필을 선택하세요.\nNOTE: 되돌릴수 없습니다!!!" L.Delete = "삭제" L.Confirm = "확인" -L.ToggleSearch = "검색 토글" -L.ToggleProfiles = "프로필 토글" -L.ToggleProfessions = "전문기술 토글" -L.ToggleBlacklist = "차단목록 토글" L.FixDBComplete = "BagSync에 FixDB가 실행되었습니다! 데이터베이스가 최적화됩니다!" L.LeftClickSearch = "클릭 = 검색창" L.RightClickBagSyncMenu = "오른쪽 클릭 = BagSync 메뉴" diff --git a/locale/ptBR.lua b/locale/ptBR.lua index 8f7c1ff..4ea77c2 100644 --- a/locale/ptBR.lua +++ b/locale/ptBR.lua @@ -25,10 +25,6 @@ L.Config = "Configuração" L.DeleteWarning = "Selecione o perfil para deletar.\nOBS: Isto é irreversível" L.Delete = "Deletar" L.Confirm = "Confirmar" -L.ToggleSearch = "Ativar Pesquisa" -L.ToggleProfiles = "Ativar Perfis" -L.ToggleProfessions = "Ativar Profissões" -L.ToggleBlacklist = "Ativar Lista Negra" L.FixDBComplete = "O FixDB foi realizado no BagSync! O banco de dados agora esta otimizado!" L.ON = "Ligar" L.OFF = "Desligar" diff --git a/locale/zhCN.lua b/locale/zhCN.lua index a5a7a20..3c014b2 100644 --- a/locale/zhCN.lua +++ b/locale/zhCN.lua @@ -25,10 +25,6 @@ L.Config = "设定" L.DeleteWarning = "选择要删除的设定档.\n注意: 不可逆!" L.Delete = "删除" L.Confirm = "确认" -L.ToggleSearch = "切换搜索" -L.ToggleProfiles = "切换设定档" -L.ToggleProfessions = "切换专业" -L.ToggleBlacklist = "切换忽略例表" L.FixDBComplete = "已执行FixDB, 数据库已优化!" L.ON = "开[ON]" L.OFF = "关[OFF]" diff --git a/locale/zhTW.lua b/locale/zhTW.lua index cfeac5e..bdc432d 100644 --- a/locale/zhTW.lua +++ b/locale/zhTW.lua @@ -26,10 +26,6 @@ L.Config = "設定" L.DeleteWarning = "選擇要刪除的設定檔.\n注意:此操作不可逆!" L.Delete = "刪除" L.Confirm = "確認" -L.ToggleSearch = "切換搜索" -L.ToggleProfiles = "切換設定檔" -L.ToggleProfessions = "切換專業" -L.ToggleBlacklist = "切換忽略例表" L.FixDBComplete = "已執行FixDB, 數據庫已優化!" L.ON = "開[ON]" L.OFF = "關[OFF]" diff --git a/modules/config.lua b/modules/config.lua index bd16413..11a55b7 100644 --- a/modules/config.lua +++ b/modules/config.lua @@ -14,14 +14,16 @@ local function get(info) local p, c = string.split(".", info.arg) - if p ~= "color" then + if p == "color" then + return BSYC.options.colors[c].r, BSYC.options.colors[c].g, BSYC.options.colors[c].b + elseif p == "keybind" then + return GetBindingKey(c) + else if BSYC.options[c] then --if this is nil then it will default to false return BSYC.options[c] else return false end - elseif p == "color" then - return BSYC.options.colors[c].r, BSYC.options.colors[c].g, BSYC.options.colors[c].b end end @@ -30,17 +32,23 @@ local function set(info, arg1, arg2, arg3, arg4) local p, c = string.split(".", info.arg) - if p ~= "color" then + if p == "color" then + BSYC.options.colors[c].r = arg1 + BSYC.options.colors[c].g = arg2 + BSYC.options.colors[c].b = arg3 + elseif p == "keybind" then + local b1, b2 = GetBindingKey(c) + if b1 then SetBinding(b1) end + if b2 then SetBinding(b2) end + SetBinding(arg1, c) + SaveBindings(GetCurrentBindingSet()) + else BSYC.options[c] = arg1 if p == "minimap" then if arg1 then BagSync_MinimapButton:Show() else BagSync_MinimapButton:Hide() end else BSYC:ResetTooltip() end - elseif p == "color" then - BSYC.options.colors[c].r = arg1 - BSYC.options.colors[c].g = arg2 - BSYC.options.colors[c].b = arg3 end end @@ -89,6 +97,66 @@ options.args.main = { set = set, arg = "minimap.enableMinimap", }, + keybindblacklist = { + order = 4, + type = "keybinding", + name = L.KeybindBlacklist, + width = "full", + descStyle = "hide", + get = get, + set = set, + arg = "keybind.BAGSYNCBLACKLIST", + }, + keybindcurrency = { + order = 5, + type = "keybinding", + name = L.KeybindCurrency, + width = "full", + descStyle = "hide", + get = get, + set = set, + arg = "keybind.BAGSYNCCURRENCY", + }, + keybindgold = { + order = 6, + type = "keybinding", + name = L.KeybindGold, + width = "full", + descStyle = "hide", + get = get, + set = set, + arg = "keybind.BAGSYNCGOLD", + }, + keybindprofessions = { + order = 7, + type = "keybinding", + name = L.KeybindProfessions, + width = "full", + descStyle = "hide", + get = get, + set = set, + arg = "keybind.BAGSYNCPROFESSIONS", + }, + keybindprofiles = { + order = 8, + type = "keybinding", + name = L.KeybindProfiles, + width = "full", + descStyle = "hide", + get = get, + set = set, + arg = "keybind.BAGSYNCPROFILES", + }, + keybindsearch = { + order = 9, + type = "keybinding", + name = L.KeybindSearch, + width = "full", + descStyle = "hide", + get = get, + set = set, + arg = "keybind.BAGSYNCSEARCH", + }, }, } diff --git a/modules/currency.lua b/modules/currency.lua index 1e7d13c..b424930 100644 --- a/modules/currency.lua +++ b/modules/currency.lua @@ -17,13 +17,6 @@ function Currency:OnEnable() CurrencyFrame:SetWidth(380) CurrencyFrame:EnableResize(false) - local information = AceGUI:Create("Label") - information:SetText(L.ProfessionInformation) - information:SetFont("Fonts\\FRIZQT__.TTF", 12, THICKOUTLINE) - information:SetColor(1, 165/255, 0) - information:SetFullWidth(true) - CurrencyFrame:AddChild(information) - local scrollframe = AceGUI:Create("ScrollFrame"); scrollframe:SetFullWidth(true) scrollframe:SetLayout("Flow") @@ -45,53 +38,38 @@ function Currency:AddEntry(entry, isHeader) local label = AceGUI:Create("BagSyncInteractiveLabel") label.userdata.color = {1, 1, 1} + label:SetHeaderHighlight("Interface\\QuestFrame\\UI-QuestTitleHighlight") label:ToggleHeaderHighlight(false) if isHeader then - label:SetText(entry.player) + label:SetText(entry.header) label:SetFont("Fonts\\FRIZQT__.TTF", 14, THICKOUTLINE) label:SetFullWidth(true) label:SetColor(unpack(label.userdata.color)) label:ApplyJustifyH("CENTER") label.userdata.isHeader = true - label.userdata.hasRecipes = false + label.userdata.text = entry.header label:ToggleHeaderHighlight(true) else - local labelText = entry.name..format(" |cFFFFFFFF(%s)|r", entry.level) - label:SetText(labelText) + label:SetText(entry.name) label:SetFont("Fonts\\FRIZQT__.TTF", 14, THICKOUTLINE) label:SetFullWidth(true) - if entry.recipes then - label.userdata.color = {153/255,204/255,51/255} --primary profession color it green - label.userdata.hasRecipes = true - else - label.userdata.color = {102/255,153/255,1} --gathering profession color it blue - label.userdata.hasRecipes = false - end + label.userdata.color = {64/255, 224/255, 208/255} label:SetColor(unpack(label.userdata.color)) label:ApplyJustifyH("LEFT") label.userdata.isHeader = false + label.userdata.text = entry.name end label:SetCallback( - "OnClick", - function (widget, sometable, button) - if "LeftButton" == button and label.userdata.hasRecipes then - BSYC:GetModule("Recipes"):ViewRecipes(entry.name, entry.level, entry.recipes) - end - end) - label:SetCallback( "OnEnter", function (widget, sometable) label:SetColor(unpack(highlightColor)) GameTooltip:SetOwner(label.frame, "ANCHOR_BOTTOMRIGHT") - if label.userdata.hasRecipes then - GameTooltip:AddLine(L.ProfessionHasRecipes) - else - GameTooltip:AddLine(L.ProfessionHasNoRecipes) + if not label.userdata.isHeader then + BSYC:AddCurrencyTooltip(GameTooltip, label.userdata.text, true) end - GameTooltip:Show() end) label:SetCallback( "OnLeave", @@ -105,38 +83,47 @@ end function Currency:DisplayList() - local CurrencyTable = {} + local tmp = {} local tempList = {} local count = 0 self.scrollframe:ReleaseChildren() --clear out the scrollframe - local xDB = BSYC:FilterDB(1) --dbSelect 1 + local xDB = BSYC:FilterDB(2) --dbSelect 2 --loop through our characters --k = player, v = stored data for player for k, v in pairs(xDB) do - local tmp = {} - local yName, yRealm = strsplit("^", k) - local playerName = BSYC:GetCharacterRealmInfo(yName, yRealm) - for q, r in pairs(v) do - table.insert(tmp, { player=playerName, name=r.name, level=r.level, recipes=r.recipes } ) - count = count + 1 + if not tempList[q] then + --we only really want to list the currency once for display + table.insert(tmp, { header=r.header, icon=r.icon, name=q} ) + tempList[q] = true + count = count + 1 + end end - --add to master table - table.insert(CurrencyTable, { player=playerName, info=tmp } ) end --show or hide the scrolling frame depending on count if count > 0 then - table.sort(CurrencyTable, function(a,b) return (a.player < b.player) end) - for i=1, #CurrencyTable do - self:AddEntry(CurrencyTable[i], true) --add header - for z=1, #CurrencyTable[i].info do - self:AddEntry(CurrencyTable[i].info[z], false) + table.sort(tmp, function(a,b) + if a.header < b.header then + return true; + elseif a.header == b.header then + return (a.name < b.name); + end + end) + + local lastHeader = "" + for i=1, #tmp do + if lastHeader ~= tmp[i].header then + self:AddEntry(tmp[i], true) --add header + self:AddEntry(tmp[i], false) --add entry + lastHeader = tmp[i].header + else + self:AddEntry(tmp[i], false) --add entry end end self.scrollframe.frame:Show() diff --git a/modules/professions.lua b/modules/professions.lua index 1aea08a..eb34e8d 100644 --- a/modules/professions.lua +++ b/modules/professions.lua @@ -86,12 +86,14 @@ function Professions:AddEntry(entry, isHeader) function (widget, sometable) label:SetColor(unpack(highlightColor)) GameTooltip:SetOwner(label.frame, "ANCHOR_BOTTOMRIGHT") - if label.userdata.hasRecipes then - GameTooltip:AddLine(L.ProfessionHasRecipes) - else - GameTooltip:AddLine(L.ProfessionHasNoRecipes) + if not label.userdata.isHeader then + if label.userdata.hasRecipes then + GameTooltip:AddLine(L.ProfessionHasRecipes) + else + GameTooltip:AddLine(L.ProfessionHasNoRecipes) + end + GameTooltip:Show() end - GameTooltip:Show() end) label:SetCallback( "OnLeave", @@ -106,7 +108,6 @@ end function Professions:DisplayList() local professionsTable = {} - local tempList = {} local count = 0 self.scrollframe:ReleaseChildren() --clear out the scrollframe diff --git a/modules/recipes.lua b/modules/recipes.lua index 989a56c..99e1ca4 100644 --- a/modules/recipes.lua +++ b/modules/recipes.lua @@ -53,12 +53,13 @@ function Recipes:AddEntry(entry) local name, recipeID, icon = entry.name, entry.recipeID, entry.icon local highlightColor = {1, 0, 0} + local color = {1, 1, 1} local label = AceGUI:Create("InteractiveLabel") label:SetText(name) label:SetFont("Fonts\\FRIZQT__.TTF", 14, THICKOUTLINE) label:SetFullWidth(true) - label:SetColor( 1,1,1) + label:SetColor(unpack(color)) label:SetImage(icon) label:SetCallback( "OnClick", @@ -76,7 +77,7 @@ function Recipes:AddEntry(entry) label:SetCallback( "OnLeave", function (widget, sometable) - label:SetColor(1,1,1) + label:SetColor(unpack(color)) GameTooltip:Hide() end)