Commit 9ab93365 authored by Caedis's avatar Caedis

Merge branch 'development' into master

parents 1258d205 fc9896e9
......@@ -5,15 +5,15 @@ local format = format
local function OnEvent(self, event, ...)
if event == "PLAYER_REGEN_ENABLED" then
self.text:SetText("Out of Combat")
if event == 'PLAYER_REGEN_ENABLED' then
self.text:SetText('Out of Combat')
return;
elseif event == "PLAYER_REGEN_DISABLED" then
self.text:SetText(format("|cffff0000In Combat|r"))
elseif event == 'PLAYER_REGEN_DISABLED' then
self.text:SetText(format('|cffff0000In Combat|r'))
return;
end
self.text:SetText("Out of Combat")
self.text:SetText('Out of Combat')
end
--[[
......@@ -28,6 +28,12 @@ end
onLeaveFunc - function to fire OnLeave, if not provided one will be set for you that hides the tooltip.
]]
local events = {
'PLAYER_ENTERING_WORLD',
'ELVUI_FORCE_UPDATE',
'PLAYER_REGEN_ENABLED',
'PLAYER_REGEN_DISABLED'
}
DT:RegisterDatatext('Combat Indicator', 'ExtraDataTexts', {'PLAYER_ENTERING_WORLD', 'PLAYER_REGEN_ENABLED', 'PLAYER_REGEN_DISABLED'}, OnEvent)
DT:RegisterDatatext('Combat Indicator', 'ExtraDataTexts', events, OnEvent)
......@@ -43,7 +43,7 @@ local function OnEnter(self)
end
function OnClick(self, button)
if button == "LeftButton" then
if button == 'LeftButton' then
if IsShiftKeyDown() then
ToggleCharacter('PaperDollFrame')
......@@ -109,6 +109,7 @@ local function OnEvent(self, event, ...)
end
local displayString = ''
local function ValueColorUpdate()
displayString = strjoin('', '|cffFFFFFF%s:|r ')
......
......@@ -2,14 +2,20 @@ local E, L, V, P, G = unpack(ElvUI)
local DT = E:GetModule('DataTexts')
local function OnEvent(self, event, unit)
if not IsInRaid() then self.text:SetText("Raid Group: N/A") return end
if not IsInRaid() then self.text:SetText('Raid Group: N/A') return end
for i = 1, GetNumGroupMembers() do
local name, _, subgroup = GetRaidRosterInfo(i)
if name == UnitName("player") then
self.text:SetFormattedText("Raid Group: %d", subgroup)
if name == UnitName('player') then
self.text:SetFormattedText('Raid Group: %d', subgroup)
return
end
end
end
DT:RegisterDatatext('Raid Group', 'ExtraDataTexts', {"GROUP_ROSTER_UPDATE", "PLAYER_ENTERING_WORLD"}, OnEvent)
\ No newline at end of file
local events = {
'PLAYER_ENTERING_WORLD',
'ELVUI_FORCE_UPDATE',
'GROUP_ROSTER_UPDATE'
}
DT:RegisterDatatext('Raid Group', 'ExtraDataTexts', events, OnEvent)
\ No newline at end of file
......@@ -10,10 +10,12 @@ local TotalPlayTime, LevelPlayTime, SessionPlayTime, LevelPlayedOffset, LastLeve
local MyRealm = GetRealmName();
local MyName = UnitName('player')
local MyClass = select(2, UnitClass('player'))
local RequestTimePlayed = RequestTimePlayed
local OnEnter = function(self)
if not InCombatLockdown() and SessionPlayTime then
DT:SetupTooltip(self)
E:UIFrameFadeIn(self, 0.4, self:GetAlpha(), 1)
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))
......@@ -22,7 +24,7 @@ local OnEnter = function(self)
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)
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
......@@ -53,40 +55,72 @@ local OnEnter = function(self)
end
end
local ElapsedTimer = 0
local ONUPDATE_INTERVAL = 1
local TimeSinceLastUpdate = 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))
TimeSinceLastUpdate = TimeSinceLastUpdate + elapsed
if TimeSinceLastUpdate >= ONUPDATE_INTERVAL then
TimeSinceLastUpdate = 0
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 Day > 0 then
self.text:SetFormattedText('%d days %d hours %d minutes', Day, Hour, Minute)
elseif Hour > 0 then
self.text:SetFormattedText('%d hours %d minutes', Hour, Minute)
elseif Minute > 0 then
self.text:SetFormattedText('%d minutes', Minute)
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
local text = ''
if Day > 0 then
if Day == 1 then
text = text..format('%d day ', Day)
else
text = text..format('%d days ', Day)
end
if Hour > 0 then
if Hour == 1 then
text = text..format('%d hour ', Hour)
else
text = text..format('%d hours ', Hour)
end
end
if Minute > 0 then
if Minute == 1 then
text = text..format('%d minute ', Minute)
else
text = text..format('%d minutes ', Minute)
end
end
if Day == 0 then
if Second == 1 then
text = text..format('%d second ', Second)
else
text = text..format('%d seconds ', Second)
end
end
self.text:SetText(text)
end
else
self.text:SetFormattedText('%d seconds', Second)
self.text:SetText('Waiting')
end
else
self.text:SetText('Waiting')
end
end
local OnEvent = function(self, event, ...)
if not ElvDB['ExtraDataTexts'] then ElvDB['ExtraDataTexts'] = {} end
if not ElvDB['ExtraDataTexts']['TimePlayed'] then ElvDB['ExtraDataTexts']['TimePlayed'] = {} end
if not ElvDB['ExtraDataTexts']['TimePlayed'][MyRealm] then ElvDB['ExtraDataTexts']['TimePlayed'][MyRealm] = {} end
......@@ -110,14 +144,17 @@ local OnEvent = function(self, event, ...)
LevelPlayTimeOffset = GetTime()
ElvDB['ExtraDataTexts']['TimePlayed'][MyRealm][MyName]['Level'] = UnitLevel('player')
end
if event == 'PLAYER_ENTERING_WORLD' then
self:UnregisterEvent(event)
if event == 'PLAYER_ENTERING_WORLD' or event == 'ELVUI_FORCE_UPDATE' then
if event == 'PLAYER_ENTERING_WORLD' then
self:UnregisterEvent(event)
end
if not IsAddOnLoaded('DataStore_Characters') then
E:Delay(5, RequestTimePlayed)
C_Timer.After(8, RequestTimePlayed)
end
end
if event == 'PLAYER_LOGOUT' then
RequestTimePlayed()
--RequestTimePlayed()
end
end
......@@ -129,7 +166,7 @@ local function Reset()
ElvDB['ExtraDataTexts']['TimePlayed'][MyRealm][MyName]['LastLevelTime'] = LastLevelTime
ElvDB['ExtraDataTexts']['TimePlayed'][MyRealm][MyName]['Class'] = MyClass
RequestTimePlayed()
print(': Time Played has been reset!')
print('Time Played has been reset!')
end
local OnMouseDown = function(self, button)
......@@ -140,5 +177,12 @@ local OnMouseDown = function(self, button)
end
end
local events = {
'ELVUI_FORCE_UPDATE',
'PLAYER_ENTERING_WORLD',
'TIME_PLAYED_MSG',
'PLAYER_LEVEL_UP',
'PLAYER_LOGOUT',
}
DT:RegisterDatatext('Time Played', 'ExtraDataTexts', {'TIME_PLAYED_MSG', 'PLAYER_LEVEL_UP', 'PLAYER_ENTERING_WORLD' , 'PLAYER_LOGOUT'}, OnEvent, OnUpdate, OnMouseDown, OnEnter, OnLeave)
\ No newline at end of file
DT:RegisterDatatext('Time Played', 'ExtraDataTexts', events, OnEvent, OnUpdate, OnMouseDown, OnEnter, OnLeave)
\ No newline at end of file
......@@ -10,91 +10,71 @@ local tonumber = tonumber
local tostring = tostring
--WoW API / Variables
local L_EasyMenu = L_EasyMenu
local setCV = SetCVar
local getCV = GetCVar
local IsShiftKeyDown = IsShiftKeyDown
local SOUND = SOUND
local ShowOptionsPanel = ShowOptionsPanel
local volumeCVars = {
{
Name = MASTER,
Volume = {
CVar = "Sound_MasterVolume",
Value = 0
},
Enable = {
CVar = "Sound_EnableMaster",
Value = 0
}
},
{
Name = SOUND_VOLUME,
Volume = {
CVar = "Sound_SFXVolume",
Value = 0
},
Enable = {
CVar = "Sound_EnableSXF",
Value = 0
}
},
{
Name = AMBIENCE_VOLUME,
Volume = {
CVar = "Sound_AmbienceVolume",
Value = 0
},
Enable = {
CVar = "Sound_EnableAmbience",
Value = 0
}
},
{
Name = DIALOG_VOLUME,
Volume = {
CVar = "Sound_DialogVolume",
Value = 0
},
Enable = {
CVar = "Sound_EnableDialog",
Value = 0
}
},
local displayString = ''
local volumeCVars =
{
Name = MUSIC_VOLUME,
Volume = {
CVar = "Sound_MusicVolume",
Value = 0
},
Enable = {
CVar = "Sound_EnableMusic",
Value = 0
}
[1] = {Name = MASTER, CVs = { Volume = 'Sound_MasterVolume', Enabled = 'Sound_EnableAllSound' }, Enabled = nil},
[2] = {Name = SOUND_VOLUME, CVs = { Volume = 'Sound_SFXVolume', Enabled = 'Sound_EnableSFX' }, Enabled = nil},
[3] = {Name = AMBIENCE_VOLUME, CVs = { Volume = 'Sound_AmbienceVolume', Enabled = 'Sound_EnableAmbience' }, Enabled = nil},
[4] = {Name = DIALOG_VOLUME, CVs = { Volume = 'Sound_DialogVolume', Enabled = 'Sound_EnableDialog' }, Enabled = nil},
[5] = {Name = MUSIC_VOLUME, CVs = { Volume = 'Sound_MusicVolume', Enabled = 'Sound_EnableMusic' }, Enabled = nil}
}
}
local activeVolumeIndex = 1
local activeVolume = volumeCVars[activeVolumeIndex]
local menu = {
[1] = {text = 'Volume Stream', isTitle = true, notCheckable = true}
}
local function GetStatusColor(vol, text)
if not text then
text = vol.Name
end
local function roundVal(num, numDecimalPlaces)
local mult = 10^(numDecimalPlaces or 0)
return ceil(num * mult + 0.5) / mult
return strform('|cFF%s%s|r',(getCV(vol.CVs.Volume) == '0' or not vol.Enabled) and 'FF0000' or '00FF00', text)
end
local function OnEvent(self, event, ...)
for key,value in pairs(volumeCVars) do
value.Volume.Value = roundVal(getCV(value.Volume.CVar), 3)
setCV(value.Volume.CVar, value.Volume.Value)
value.Enable.Value = getCV(value.Enable.CVar)
local function OnEnter(self)
E:UIFrameFadeIn(self, 0.4, self:GetAlpha(), 1)
DT:SetupTooltip(self)
DT.tooltip:ClearLines()
DT.tooltip:AddLine('Volume Streams')
DT.tooltip:AddLine(' ')
for _,vol in ipairs(volumeCVars) do
DT.tooltip:AddDoubleLine(vol.Name, GetStatusColor(vol, strform('%.f', getCV(vol.CVs.Volume) * 100) .. '%'))
end
if (event == "ELVUI_FORCE_UPDATE" ) then -- I hate you Azil <3
DT.tooltip:AddLine(' ')
DT.tooltip:AddLine('|cffFFFFFFLeft Click:|r Select Volume Stream')
DT.tooltip:AddLine('|cffFFFFFFRight Click:|r Toggle Volume Stream')
DT.tooltip:AddLine('|cffFFFFFFShift + Left Click:|r Open System Audio Panel')
DT.tooltip:Show()
end
local function OnEvent(self, event, ...)
activeVolume = volumeCVars[activeVolumeIndex]
if (event == 'ELVUI_FORCE_UPDATE' ) then -- I hate you Azil <3
self:EnableMouseWheel(true)
self:SetScript("OnMouseWheel", function(tself, delta)
local vol = activeVolume.Volume.Value;
self:SetScript('OnMouseWheel', function(tself, delta)
local vol = getCV(activeVolume.CVs.Volume);
local volScale = 100;
if (IsShiftKeyDown()) then
......@@ -108,46 +88,81 @@ local function OnEvent(self, event, ...)
elseif (vol <= 0) then
vol = 0
end
activeVolume.Volume.Value = vol
setCV(activeVolume.Volume.CVar, vol)
self.text:SetText(activeVolume.Name..": "..strform("%.f", vol * 100) .. "%")
setCV(activeVolume.CVs.Volume, vol)
OnEvent(self, nil)
end)
end
for i = 1, #volumeCVars do
volumeCVars[i].Enabled = getCV(volumeCVars[i].CVs.Enabled) == '1'
menu[i+1]={
text = volumeCVars[i].Name,
checked = i == activeVolumeIndex,
func = function(slf)
activeVolumeIndex = i;
OnEvent(self, nil);
end
}
end
self.text:SetText(activeVolume.Name..": "..strform("%.f", activeVolume.Volume.Value * 100) .. "%")
self.text:SetText(activeVolume.Name..': '..GetStatusColor(activeVolume, strform('%.f', getCV(activeVolume.CVs.Volume) * 100) .. '%'))
end
local function OnClick(self)
activeVolumeIndex = activeVolumeIndex + 1
if (activeVolumeIndex == 6) then
activeVolumeIndex = 1
end
local function OnClick(self, button)
activeVolume = volumeCVars[activeVolumeIndex]
if button == 'LeftButton' then
if IsShiftKeyDown() then
ShowOptionsPanel(_G.VideoOptionsFrame, _G.GameMenuFrame, SOUND)
return
end
menu[1].text = 'Select Volume Stream'
for i = 2, #menu do
menu[i].checked = i - 1 == activeVolumeIndex
menu[i].func = function(slf)
activeVolumeIndex = i - 1;
OnEvent(self, nil);
end
end
DT:SetEasyMenuAnchor(DT.EasyMenu, self)
_G.EasyMenu(menu, DT.EasyMenu, nil, nil, nil, 'MENU')
elseif button == 'RightButton' then
menu[1].text = 'Toggle Volume Stream'
for i = 2, #menu do
menu[i].checked = volumeCVars[i - 1].Enabled
menu[i].func = function(slf)
setCV(volumeCVars[i - 1].CVs.Enabled, (not volumeCVars[i - 1].Enabled) and '1' or '0');
OnEvent(self, nil);
end
end
OnEvent(self, nil, nil)
DT:SetEasyMenuAnchor(DT.EasyMenu, self)
_G.EasyMenu(menu, DT.EasyMenu, nil, nil, nil, 'MENU')
end
end
--[[
DT:RegisterDatatext(name, events, eventFunc, updateFunc, clickFunc, onEnterFunc, onLeaveFunc)
name - name of the datatext (required)
events - must be a table with string values of event names to register
eventFunc - function that gets fired when an event gets triggered
updateFunc - onUpdate script target function
click - function to fire when clicking the datatext
onEnterFunc - function to fire OnEnter
onLeaveFunc - function to fire OnLeave, if not provided one will be set for you that hides the tooltip.
]]
local function ValueColorUpdate()
displayString = strjoin('', '|cffFFFFFF%s:|r ')
DT:RegisterDatatext('Volume', 'ExtraDataTexts', {'PLAYER_ENTERING_WORLD', "CVAR_UPDATE"}, OnEvent, nil, OnClick, nil, nil)
if lastPanel then OnEvent(lastPanel) end
end
E.valueColorUpdateFuncs[ValueColorUpdate] = true
local events = {
'PLAYER_ENTERING_WORLD',
'ELVUI_FORCE_UPDATE',
'CVAR_UPDATE'
}
DT:RegisterDatatext('Volume', 'ExtraDataTexts', events, OnEvent, nil, OnClick, OnEnter)
\ No newline at end of file
local E, L, V, P, G, _ = unpack(ElvUI)
local DT = E:GetModule("DataTexts")
local DT = E:GetModule('DataTexts')
--Cache global variables
--Lua functions
......@@ -40,11 +40,11 @@ local function OnEnter(self)
if(not C_PvP_CanToggleWarModeInArea()) then
if(C_PvP_IsWarModeDesired()) then
if(not canToggleWarmodeOFF and not IsResting()) then
warmodeErrorText = UnitFactionGroup("player") == PLAYER_FACTION_GROUP[0] and PVP_WAR_MODE_NOT_NOW_HORDE_RESTAREA or PVP_WAR_MODE_NOT_NOW_ALLIANCE_RESTAREA;
warmodeErrorText = UnitFactionGroup('player') == PLAYER_FACTION_GROUP[0] and PVP_WAR_MODE_NOT_NOW_HORDE_RESTAREA or PVP_WAR_MODE_NOT_NOW_ALLIANCE_RESTAREA;
end
else
if(not canToggleWarmode) then
warmodeErrorText = UnitFactionGroup("player") == PLAYER_FACTION_GROUP[0] and PVP_WAR_MODE_NOT_NOW_HORDE or PVP_WAR_MODE_NOT_NOW_ALLIANCE;
warmodeErrorText = UnitFactionGroup('player') == PLAYER_FACTION_GROUP[0] and PVP_WAR_MODE_NOT_NOW_HORDE or PVP_WAR_MODE_NOT_NOW_ALLIANCE;
end
end
end
......@@ -56,9 +56,8 @@ local function OnEnter(self)
DT.tooltip:Show()
end
--azeriteItemsList
function OnClick(self, button)
if button == "LeftButton" then
if button == 'LeftButton' then
DT.tooltip:Hide()
if C_PvP_CanToggleWarMode(not C_PvP_IsWarModeActive()) then
......@@ -71,20 +70,21 @@ local function OnEvent(self, event, unit)
local color
local icon
if C_PvP_IsWarModeDesired() then
color = "ff0000"
icon = " |TInterface\\Icons\\ui_warmode:16|t "
color = 'ff0000'
icon = ' |TInterface\\Icons\\ui_warmode:16|t '
else
color = "00ff00"
icon = ""
color = '00ff00'
icon = ''
end
self.text:SetText(format("%s|cff%sWar Mode%s", icon, color, icon))
self.text:SetText(format('%s|cff%sWar Mode%s', icon, color, icon))
end
local events = {
"PLAYER_ENTERING_WORLD",
"WAR_MODE_STATUS_UPDATE",
"PLAYER_FLAGS_CHANGED"
'PLAYER_ENTERING_WORLD',
'ELVUI_FORCE_UPDATE',
'WAR_MODE_STATUS_UPDATE',
'PLAYER_FLAGS_CHANGED'
}
--[[
DT:RegisterDatatext(name, events, eventFunc, updateFunc, clickFunc, onEnterFunc)
......@@ -96,4 +96,4 @@ local events = {
click - function to fire when clicking the datatext
onEnterFunc - function to fire OnEnter
]]
DT:RegisterDatatext("War Mode", 'ExtraDataTexts', events, OnEvent, nil, OnClick, OnEnter)
DT:RegisterDatatext('War Mode', 'ExtraDataTexts', events, OnEvent, nil, OnClick, OnEnter)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment