|
]]-- |
|
DS_Setting = { |
local CHARACTER_MAXLEVEL = 80; |
|
DeathSnap = { |
|
Setting = { |
Version = GetAddOnMetadata("DeathSnap", "Version"); |
Revision = tonumber(strsub("$Rev: 1056 $", 7, strlen("$Rev: 1056 $") - 2)); |
} |
}, |
|
DS_Options = { |
Active = 1; |
MinLevel = 1; |
MaxLevel = 80; |
CloseWindows = 0; |
} |
On = { |
|
DS_On = { |
|
Load = function() |
|
DS_Register.RegisterEvent("UNIT_DIED") |
DS_Register.RegisterEvent("PLAYER_DEAD") |
|
if (Khaos) then |
DS_Register.Khaos(); |
else |
DS_Register.SlashCommands() |
end |
|
end; |
|
Event = function(event) |
|
if ( ( event == "UNIT_DIED" or event == "PLAYER_DEAD" ) and DS_Options.Active == 1 ) then |
if (UnitLevel("player") >= DS_Options.MinLevel and UnitLevel("player") <= DS_Options.MaxLevel) then |
if (DS_Options.CloseWindows == 1) then |
if ( ( event == "UNIT_DIED" or event == "PLAYER_DEAD" ) and DeathSnap_SavedVars.Enabled ) then |
if (UnitLevel("player") >= DeathSnap_SavedVars.MinLevel and UnitLevel("player") <= DeathSnap_SavedVars.MaxLevel) then |
if (DeathSnap_SavedVars.CloseWindows) then |
CloseAllWindows() |
RequestTimePlayed() |
DS_Function.TakeScreenshot() |
DeathSnap.Function.TakeScreenshot() |
else |
RequestTimePlayed() |
DS_Function.TakeScreenshot() |
DeathSnap.Function.TakeScreenshot() |
end |
end |
end |
|
end; |
|
} |
}, |
|
DS_Register = { |
Function = { |
|
RegisterEvent = function(event) |
this:RegisterEvent(event) |
end; |
|
SlashCommands = function() |
SLASH_DS_HELP1 = "/ds"; |
SLASH_DS_HELP2 = "/deathsnap"; |
SlashCmdList["DS_HELP"] = DS_Command; |
end; |
|
Khaos = function() |
local version = DS_Setting.Version.."."..DS_Setting.Revision |
|
local optionSet = { |
id = "DeathSnap"; |
text = function() return DS_TITLE end; |
helptext = function() return DS_INFO end; |
difficulty = 1; |
default = true; |
callback = function(checked) |
DS_Options.Active = checked and 1 or 0; |
end; |
options = { |
{ |
id = "Header"; |
text = function() return DS_TITLE.." "..DS_Color.Green("v"..version) end; |
helptext = function() return DS_INFO end; |
type = K_HEADER; |
difficulty = 1; |
}; |
|
{ |
id="DS_MinLevel"; |
type = K_SLIDER; |
text = function() return DS_MINIMUM end; |
helptext = function() return DS_HELP_MIN end; |
difficulty = 1; |
feedback = function(state) |
return string.format(DS_MINMAXSET2, DS_MINIMUM, state.slider); |
end; |
callback = function(state) |
if (state.slider >= DS_Options.MaxLevel) then |
Khaos.setSetKeyParameter("DeathSnap","DS_MaxLevel", "slider", state.slider); |
Khaos.refresh(false, false, true); |
end; |
DS_Options.MinLevel = state.slider; |
end; |
default = { checked = true; slider = 1 }; |
disabled = { checked = false; slider = 1 }; |
setup = { |
sliderMin = 1; |
sliderMax = 80; |
sliderStep = 1; |
sliderDisplayFunc = function(val) |
return val; |
end; |
}; |
}; |
|
|
{ |
id="DS_MaxLevel"; |
type = K_SLIDER; |
text = function() return DS_MAXIMUM end; |
helptext = function() return DS_HELP_MAX end; |
difficulty = 1; |
feedback = function(state) |
return string.format(DS_MINMAXSET2, DS_MAXIMUM, state.slider); |
end; |
callback = function(state) |
if (state.slider <= DS_Options.MinLevel) then |
Khaos.setSetKeyParameter("DeathSnap","DS_MinLevel", "slider", state.slider); |
Khaos.refresh(false, false, true); |
end; |
DS_Options.MaxLevel = state.slider; |
end; |
default = { checked = false; slider = 80 }; |
disabled = { checked = false; slider = 80 }; |
setup = { |
sliderMin = 1; |
sliderMax = 80; |
sliderStep = 1; |
sliderDisplayFunc = function(val) |
return val; |
end; |
}; |
}; |
|
{ |
id = "DS_CloseWindows"; |
type = K_TEXT; |
text = function() return DS_CLOSEWIN end; |
helptext = function() return DS_HELP_CLOSEWIN end; |
difficulty = 1; |
feedback = function(state) |
if (state.checked) then |
return string.format(DS_CLOSEALL, DS_ENABLED); |
else |
return string.format(DS_CLOSEALL, DS_DISABLED); |
end |
end; |
callback = function(state) |
if (state.checked) then |
DS_Options.CloseWindows = 1; |
else |
DS_Options.CloseWindows = 0; |
end |
end; |
check = true; |
default = { checked = false }; |
disabled = { checked = true }; |
}; |
|
{ |
id = "DS_Status"; |
type = K_BUTTON; |
text = function() return DS_STATUS end; |
helptext = function() return DS_HELP_STATUS end; |
difficulty = 1; |
callback = function(state) |
DS_Out.Status() |
end; |
feedback = function(state) end; |
setup = { buttonText = function() return DS_STATUS end; }; |
}; |
|
}; |
}; |
Khaos.registerOptionSet( |
"other", |
optionSet |
); |
|
end; |
|
} |
|
DS_Function = { |
|
TakeScreenshot = function() |
Chronos.schedule(1, TakeScreenshot) |
end; |
|
} |
}, |
|
DS_Out = { |
Out = { |
|
Print = function(msg) |
local color = NORMAL_FONT_COLOR; |
DEFAULT_CHAT_FRAME:AddMessage(DS_TITLE..": "..msg, color.r, color.g, color.b) |
DEFAULT_CHAT_FRAME:AddMessage(DS_TITLE..": "..msg, NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b) |
end; |
|
Status = function() |
local active = DS_Color.Green(DS_ENABLED) |
local closeall = DS_Color.Green(DS_ENABLED) |
Status = function() |
local active = DeathSnap.Color.Green(DS_ENABLED) |
local closeall = DeathSnap.Color.Green(DS_ENABLED) |
|
if (DS_Options.Active == 0) then |
active = DS_Color.Red(DS_DISABLED) |
if (not DeathSnap_SavedVars.Enabled) then |
active = DeathSnap.Color.Red(DS_DISABLED) |
end |
if (DS_Options.CloseWindows == 0) then |
closeall = DS_Color.Red(DS_DISABLED) |
if (not DeathSnap_SavedVars.CloseWindows) then |
closeall = DeathSnap.Color.Red(DS_DISABLED) |
end |
|
DS_Out.Print("AddOn "..active..". "..string.format(DS_MINMAXSET2, DS_MINIMUM, DS_Color.Green(DS_Options.MinLevel)).." "..string.format(DS_MINMAXSET2, DS_MAXIMUM, DS_Color.Green(DS_Options.MaxLevel)).." "..string.format(DS_CLOSEALL, closeall)) |
end; |
DeathSnap.Out.Print("AddOn "..active) |
DeathSnap.Out.Print(format(DS_MINMAXSET2, DS_MINIMUM, DeathSnap.Color.Green(DeathSnap_SavedVars.MinLevel))) |
DeathSnap.Out.Print(format(DS_MINMAXSET2, DS_MAXIMUM, DeathSnap.Color.Green(DeathSnap_SavedVars.MaxLevel))) |
DeathSnap.Out.Print(format(DS_CLOSEALL, closeall)) |
end; |
|
Version = function() |
local version = DS_Setting.Version.."."..DS_Setting.Revision |
DS_Out.Print(DS_VERSION..": "..DS_Color.Green(version)) |
end; |
Version = function() |
local version = DeathSnap.Setting.Version.."."..DeathSnap.Setting.Revision |
DeathSnap.Out.Print(DS_VERSION..": "..DeathSnap.Color.Green(version)) |
end; |
|
} |
}, |
|
DS_Color = { |
Color = { |
|
Green = function(msg) |
return "|cff00cc00"..msg.."|r"; |