From eb34f2f6daf66bbc759db9edf985a3b852ac989c Mon Sep 17 00:00:00 2001 From: Repooc Date: Thu, 18 Jul 2013 12:28:22 -0400 Subject: [PATCH] more updates --- ElvUI_SLE/media/textures/SLE_Chat_Logo.blp | Bin 2196 -> 0 bytes ElvUI_SLE/modules/characterframe/itemlevel.lua | 13 +- ElvUI_SLE/modules/chat/chat.lua | 28 ++++ ElvUI_SLE/modules/datatexts/played.lua | 166 ++++++++++++++++++++++++ 4 files changed, 198 insertions(+), 9 deletions(-) delete mode 100755 ElvUI_SLE/media/textures/SLE_Chat_Logo.blp create mode 100644 ElvUI_SLE/modules/datatexts/played.lua diff --git a/ElvUI_SLE/media/textures/SLE_Chat_Logo.blp b/ElvUI_SLE/media/textures/SLE_Chat_Logo.blp deleted file mode 100755 index 79166b968a029b46cc23da08f8f15838f3380b0c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2196 zcmeHIEtBFv5PkW8gd`**@&iug2b@Hnj<}x?g~h~RF>8>AT7gEypfLzEDguj%!J;DO zUQftYu4=26sx>F*s!V6z>wewSsha%CfB&=qSiW!lpjUkUxSv0yo-^j-v*)>N%;$3~ z77HwwORQEatk-L7HXCfWTkLi_?Du;d4hNi0C!Eh`TrL+}uUFh|H{9=cXsw^D^a^`T z;5C8&Z36217Ei)BhzB}xM4R@&$Q(K9xAcJx*rNv!!c&O@!-wM_5qOGjFYhA+N+o6= zVQl$=@!~X277rliNx2b}+sO|2DQ{f6tL|b9-*h(MRV=rsNuyNc!a0B z2Bwoi{)pj;3!8MnWSfB>`4gVTb-0hx1#U?qyJg71O~kMVTs@{kTjkpnoMtwPp| z0?(4JTn>vjyiy@w+>i>PZzjrxlTmS^qNtm`8Ts%-kp9Ygsc-n~t;ou3Aduy>Sr63w zMQEM(Tl!Lf`T-QWLfUqGaV%4TXM^}!mq2RxTp#tjNgMohDlJ$geU*_ zH=PZ5WKG`* zuvKw_3a^i|S;IrNy3WbBl}16CysXTOq&uw}2&kKa5rvd7#>pT{k>}m?&B%uzg7jDR E7rk)SZvX%Q diff --git a/ElvUI_SLE/modules/characterframe/itemlevel.lua b/ElvUI_SLE/modules/characterframe/itemlevel.lua index 4a8cbbb..6bed77c 100755 --- a/ElvUI_SLE/modules/characterframe/itemlevel.lua +++ b/ElvUI_SLE/modules/characterframe/itemlevel.lua @@ -89,15 +89,10 @@ end function CFO:GetActualItemLevel(link) local levelAdjust={ -- 11th item:id field and level adjustment - ["0"]=0,["1"]=8, - ["373"]=4,["374"]=8, - ["375"]=4,["376"]=4,["377"]=4,["379"]=4,["380"]=4, - ["445"]=0,["446"]=4,["447"]=8, - ["451"]=0,["452"]=8, - ["453"]=0,["454"]=4,["455"]=8, - ["456"]=0,["457"]=8, - ["458"]=0,["459"]=4,["460"]=8,["461"]=12,["462"]=16, - ["465"]=0,["466"]=4,["467"]=8 + ["0"]=0,["1"]=8,["373"]=4,["374"]=8,["375"]=4,["376"]=4,["377"]=4,["379"]=4,["380"]=4, + ["445"]=0,["446"]=4,["447"]=8,["451"]=0,["452"]=8,["453"]=0,["454"]=4,["455"]=8, + ["456"]=0,["457"]=8,["458"]=0,["459"]=4,["460"]=8,["461"]=12,["462"]=16, + ["465"]=0,["466"]=4,["467"]=8,["468"] = 0,["469"] = 4,["470"] = 8,["471"] = 12,["472"] = 16 } local baseLevel = select(4,GetItemInfo(link)) local upgrade = link:match(":(%d+)\124h%[") diff --git a/ElvUI_SLE/modules/chat/chat.lua b/ElvUI_SLE/modules/chat/chat.lua index d7cea1c..fa08d7f 100755 --- a/ElvUI_SLE/modules/chat/chat.lua +++ b/ElvUI_SLE/modules/chat/chat.lua @@ -81,6 +81,22 @@ local IconTable = { }, } +--[[ +function CheckFlag(sender) + local senderName, senderRealm = string.split('-', sender + senderName = senderName or E.myname + senderRealm = senderRealm or E.myrealm + + senderRealm = senderRealm:gsub(' ', '') + + if IconTable[senderRealm] and IconTable[senderRealm][senderName] then + return IconTable[senderRealm][senderName] + end + + return false +end +]] + function SLE:Auth() local myRealm = E.myrealm local myName = E.myname @@ -267,6 +283,18 @@ function CH:PositionChat(override) self.initialMove = true; end +--[[ +local function SLEfilter(self, event, message, author, arg3, arg4, arg5, arg6, ...) + local returnTex = arg6 + + if(strlen(arg6) > 0) then + elseif CheckFlag(author) then + returnTex = CheckFlag(author)..arg6 + end + + return false, message, author, arg3, arg4, arg5, returnTex, ... +end]] + --Adding icons to specific toons' names --Filter local function SLEfilter(self, event, message, author, arg3, arg4, arg5, arg6, ...) diff --git a/ElvUI_SLE/modules/datatexts/played.lua b/ElvUI_SLE/modules/datatexts/played.lua new file mode 100644 index 0000000..76842bd --- /dev/null +++ b/ElvUI_SLE/modules/datatexts/played.lua @@ -0,0 +1,166 @@ +local E, L, V, P, G, _ = unpack(ElvUI); +local DT = E:GetModule('DataTexts') + +local format, GetTime, ChatFrame_TimeBreakDown, InCombatLockdown = format, GetTime, ChatFrame_TimeBreakDown, InCombatLockdown +local PlayedTimeFormatFull = '%d D %02d:%02d:%02d' +local PlayedTimeFormatNoDay = '%02d:%02d:%02d' +local TotalPlayTime, LevelPlayTime, SessionPlayTime, LevelPlayedOffset, LastLevelTime +local MyRealm = GetCVar('realmName') +local MyName = UnitName('player') +local MyClass = select(2, UnitClass('player')) + +local OnEnter = function(self) + if not InCombatLockdown() and SessionPlayTime then + DT:SetupTooltip(self) + local SessionDay, SessionHour, SessionMinute, SessionSecond = ChatFrame_TimeBreakDown(GetTime() - SessionPlayTime) + local TotalDay, TotalHour, TotalMinute, TotalSecond = ChatFrame_TimeBreakDown(TotalPlayTime + (GetTime() - SessionPlayTime)) + local LevelDay, LevelHour, LevelMinute, LevelSecond = ChatFrame_TimeBreakDown(LevelPlayTime + (GetTime() - LevelPlayTimeOffset)) + local LastLevelDay, LastLevelHour, LastLevelMinute, LastLevelSecond = ChatFrame_TimeBreakDown(LastLevelTime) + --local Panel, Anchor, xOff, yOff = self:GetTooltipAnchor() + --DT.tooltip:SetOwner(Panel, Anchor, xOff, yOff) + DT.tooltip:ClearLines() + DT.tooltip:AddLine('Time Played', 1, 1, 1) + DT.tooltip:AddLine(' ') + DT.tooltip:AddDoubleLine("Session:", SessionDay > 0 and format(PlayedTimeFormatFull, SessionDay, SessionHour, SessionMinute, SessionSecond) or format(PlayedTimeFormatNoDay, SessionHour, SessionMinute, SessionSecond), 1, 1, 1, 1, 1, 1) + if LastLevelSecond > 0 then + DT.tooltip:AddDoubleLine(format('%s %s:', PREVIOUS, LEVEL), LastLevelDay > 0 and format(PlayedTimeFormatFull, LastLevelDay. LastLevelHour, LastLevelMinute, LastLevelSecond) or format(PlayedTimeFormatNoDay, LastLevelHour, LastLevelMinute, LastLevelSecond), 1, 1, 1, 1, 1, 1) + end + DT.tooltip:AddDoubleLine(LEVEL..':', LevelDay > 0 and format(PlayedTimeFormatFull, LevelDay, LevelHour, LevelMinute, LevelSecond) or format(PlayedTimeFormatNoDay, LevelHour, LevelMinute, LevelSecond), 1, 1, 1, 1, 1, 1) + --DT.tooltip:AddDoubleLine(LEVEL..':', LevelDay > 0 and format(PlayedTimeFormatFull, LevelDay. LevelHour, LevelMinute, LevelSecond) or format(PlayedTimeFormatNoDay, LevelHour, LevelMinute, LevelSecond), 1, 1, 1, 1, 1, 1) + DT.tooltip:AddDoubleLine(TOTAL..':', TotalDay > 0 and format(PlayedTimeFormatFull, TotalDay, TotalHour, TotalMinute, TotalSecond) or format(PlayedTimeFormatNoDay, TotalHour, TotalMinute, TotalSecond), 1, 1, 1, 1, 1, 1) + DT.tooltip:AddLine(' ') + DT.tooltip:AddLine('Account Time Played', 1, 1, 1) + DT.tooltip:AddLine(' ') + local Class, Level, AccountDay, AccountHour, AccountMinute, AccountSecond, TotalAccountTime + for player, subtable in pairs(ElvDB['sle']['TimePlayed'][MyRealm]) do + for k, v in pairs(subtable) do + if k == 'TotalTime' then + AccountDay, AccountHour, AccountMinute, AccountSecond = ChatFrame_TimeBreakDown(v) + TotalAccountTime = (TotalAccountTime or 0) + v + end + if k == 'Class' then Class = v end + if k == 'Level' then Level = v end + end + local color = RAID_CLASS_COLORS[Class] + DT.tooltip:AddDoubleLine(format('%s |cFFFFFFFF- %s %d', player, LEVEL, Level), format(PlayedTimeFormatFull, AccountDay, AccountHour, AccountMinute, AccountSecond), color.r, color.g, color.b, 1, 1, 1) + end + DT.tooltip:AddLine(' ') + local TotalAccountDay, TotalAccountHour, TotalAccountMinute, TotalAccountSecond = ChatFrame_TimeBreakDown(TotalAccountTime) + DT.tooltip:AddDoubleLine('Total', format(PlayedTimeFormatFull, TotalAccountDay, TotalAccountHour, TotalAccountMinute, TotalAccountSecond), 1, 0, 1, 1, 1, 1) + DT.tooltip:AddLine(' ') + DT.tooltip:AddLine('|cFFAAAAAAReset Data: Hold Shift + Right Click|r') + DT.tooltip:Show() + end +end + +local ElapsedTimer = 0 +local OnUpdate = function(self, elapsed) + ElapsedTimer = ElapsedTimer + elapsed + if (not self.text) then + local text = self:CreateFontString(nil, 'OVERLAY') + text:SetFont(DataText.Font, DataText.Size, DataText.Flags) + text:SetText('Time Played') + self.text = text + end + + if TotalPlayTime and LevelPlayTime and SessionPlayTime then + local Day, Hour, Minute, Second + if UnitLevel('player') ~= MAX_PLAYER_LEVEL then + Day, Hour, Minute, Second = ChatFrame_TimeBreakDown(LevelPlayTime + (GetTime() - LevelPlayTimeOffset)) + else + Day, Hour, Minute, Second = ChatFrame_TimeBreakDown(TotalPlayTime + (GetTime() - SessionPlayTime)) + end + if Day > 0 then + self.text:SetFormattedText('%d D %02d:%02d', Day, Hour, Minute) + else + self.text:SetFormattedText('%02d:%02d', Hour, Minute) + end + else + if ElapsedTimer > 1 and not self.Requested then + self.Requested = true + RequestTimePlayed() + end + end +end + +local OnEvent = function(self, event, ...) + if not ElvDB['sle'] then ElvDB['sle'] = {} end + if not ElvDB['sle']['TimePlayed'] then ElvDB['sle']['TimePlayed'] = {} end + if not ElvDB['sle']['TimePlayed'][MyRealm] then ElvDB['sle']['TimePlayed'][MyRealm] = {} end + if not ElvDB['sle']['TimePlayed'][MyRealm][MyName] then ElvDB['sle']['TimePlayed'][MyRealm][MyName] = {} end + ElvDB['sle']['TimePlayed'][MyRealm][MyName]['Class'] = MyClass + ElvDB['sle']['TimePlayed'][MyRealm][MyName]['Level'] = UnitLevel('player') + LastLevelTime = ElvDB['sle']['TimePlayed'][MyRealm][MyName]['LastLevelTime'] or 0 + if event == 'TIME_PLAYED_MSG' then + local TotalTime, LevelTime = ... + TotalPlayTime = TotalTime + LevelPlayTime = LevelTime + if SessionPlayTime == nil then SessionPlayTime = GetTime() end + LevelPlayTimeOffset = GetTime() + ElvDB['sle']['TimePlayed'][MyRealm][MyName]['TotalTime'] = TotalTime + ElvDB['sle']['TimePlayed'][MyRealm][MyName]['LevelTime'] = LevelTime + end + if event == 'PLAYER_LEVEL_UP' then + LastLevelTime = floor(LevelPlayTime + (GetTime() - LevelPlayTimeOffset)) + ElvDB['sle']['TimePlayed'][MyRealm][MyName]['LastLevelTime'] = LastLevelTime + LevelPlayTime = 1 + LevelPlayTimeOffset = GetTime() + ElvDB['sle']['TimePlayed'][MyRealm][MyName]['Level'] = UnitLevel('player') + end + if event == 'PLAYER_ENTERING_WORLD' then + self:UnregisterEvent(event) + if not IsAddOnLoaded('DataStore_Characters') then + RequestTimePlayed() + end + end + if event == 'PLAYER_LOGOUT' then + RequestTimePlayed() + end +end + +local function Reset() + ElvDB['sle']['TimePlayed'][MyRealm] = {} + ElvDB['sle']['TimePlayed'][MyRealm][MyName] = {} + ElvDB['sle']['TimePlayed'][MyRealm][MyName]['Level'] = UnitLevel('player') + ElvDB['sle']['TimePlayed'][MyRealm][MyName]['LastLevelTime'] = LastLevelTime + ElvDB['sle']['TimePlayed'][MyRealm][MyName]['Class'] = MyClass + RequestTimePlayed() + print(': Time Played has been reset!') +end + +local OnMouseDown = function(self, button) + if button == 'RightButton' then + if IsShiftKeyDown()then + Reset() + end + end +end + +--[[ +local Enable = function(self) + if (not self.Text) then + local Text = self:CreateFontString(nil, 'OVERLAY') + Text:SetFont(DataText.Font, DataText.Size, DataText.Flags) + Text:SetText('Time Played') + self.Text = Text + end + + self:RegisterEvent('TIME_PLAYED_MSG') + self:RegisterEvent('PLAYER_LEVEL_UP') + self:RegisterEvent('PLAYER_ENTERING_WORLD') + self:RegisterEvent('PLAYER_LOGOUT') + self:SetScript('OnMouseDown', OnMouseDown) + self:SetScript('OnUpdate', OnUpdate) + self:SetScript('OnEnter', OnEnter) + self:SetScript('OnEvent', OnEvent) + self:SetScript('OnLeave', GameTooltip_Hide) +end + +local Disable = function(self) + self.Text:SetText('') + self:UnregisterAllEvents() + self:SetScript('OnEvent', nil) + self:SetScript('OnEnter', nil) + self:SetScript('OnLeave', nil) +end]] +DT:RegisterDatatext('Time Played', {'TIME_PLAYED_MSG', 'PLAYER_LEVEL_UP', 'PLAYER_ENTERING_WORLD' , 'PLAYER_LOGOUT'}, OnEvent, OnUpdate, OnMouseDown, OnEnter, OnLeave) \ No newline at end of file -- 1.7.9.5