📄 damagemeters.lua
字号:
DamageMeters_quantitiesFilter[DamageMeters_Quantity_HEALING] = true;
DamageMeters_quantitiesFilter[DamageMeters_Quantity_DAMAGED] = true;
DamageMeters_quantitiesFilter[DamageMeters_Quantity_HEALINGRECEIVED] = true;
DamageMeters_quantitiesFilter[DamageMeters_Quantity_DPS] = true;
DamageMeters_quantitiesFilter[DamageMeters_Quantity_HPS] = false;
DamageMeters_quantitiesFilter[DamageMeters_Quantity_DTPS] = false;
DamageMeters_quantitiesFilter[DamageMeters_Quantity_HTPS] = false;
DamageMeters_quantitiesFilter[DamageMeters_Quantity_TIME] = true;
-- Initialize color table.
DamageMeters_SetDefaultColors();
DamageMeters_InitTables();
end
function DamageMeters_InitTables()
-- Init the tables.
local tableIndex;
for tableIndex = 1, DMT_MAX do
DamageMeters_tables[tableIndex] = {};
DamageMeters_tableInfo[tableIndex] = {};
DamageMeters_tableInfo[tableIndex].sessionLabel = "Default";
DamageMeters_tableInfo[tableIndex].sessionIndex = 1;
end
end
-- DEBUG --
DamageMeters_msgCounts = {};
-- NOTE: Whenever you add/remove a new variable, increase the number in this
-- tables name so that it gets reset.
DamageMeters_debug4 = {};
-- Shows all messages.
DamageMeters_debug4.showAll = false;
DamageMeters_debug4.showParse = false;
-- When true, allows you to parse your own sync messages.
DamageMeters_debug4.syncSelf = false;
DamageMeters_debug4.syncSelfTestMode = false; -- Adds "x" to the end of player names for self-sync testing.
DamageMeters_debug4.showValueChanges = false;
-- When true, each incoming message becomes instead a 1 point of damage message
-- caused by a player by the name of the message.
DamageMeters_debug4.msgWatchMode = false;
DamageMeters_debug4.showSyncChanges = false;
DamageMeters_debug4.showSyncQueueInfo = false;
DamageMeters_debug4.showHealthChanges = false;
DamageMeters_debug4.showGCInfo = false;
-------------------------------------------------------------------------------
function DMPrint(msg, color, bSecondChatWindow)
local r = 0.50;
local g = 0.50;
local b = 1.00;
if (color) then
r = color.r;
g = color.g;
b = color.b;
end
local frame = DEFAULT_CHAT_FRAME;
if (bSecondChatWindow) then
frame = ChatFrame2;
end
if (frame) then
frame:AddMessage(msg,r,g,b);
end
end
function DM_DUMP()
local table = DamageMeters_tables[DMT_ACTIVE];
DM_DUMP_RECURSIVE(table, "[root]", "");
end
-- stolen from sky (assertEquals)
function DMASSERTEQUALS(expected, actual)
if actual ~= expected then
local function wrapValue( v )
if type(v) == 'string' then return "'"..v.."'" end
return tostring(v)
end
errorMsg = "expected: "..wrapValue(expected)..", actual: "..wrapValue(actual)
DMPrintD( errorMsg, 2 )
end
end
function DMASSERTNOTEQUALS(expected, actual)
if actual == expected then
local function wrapValue( v )
if type(v) == 'string' then return "'"..v.."'" end
return tostring(v)
end
errorMsg = "not expected: "..wrapValue(expected)..", actual: "..wrapValue(actual)
DMPrintD( errorMsg, 2 )
end
end
function DMPrintD(msg, color, bSecondChatWindow)
if (DamageMeters_debugEnabled) then
--SendChatMessage(msg, "CHANNEL", nil, GetChannelName("dmdebug"));
DMPrint(msg, color, bSecondChatWindow);
end
end
function DMVerbose(msg)
--DMPrint(msg);
end
-------------------------------------------------------------------------------
function DamageMetersFrame_OnLoad()
-- Initialize debug timers.
for timer = 1, DMPROF_COUNT do
DamageMeters_debugTimers[timer] = {};
DamageMeters_debugTimers[timer].time = 0;
DamageMeters_debugTimers[timer].count = 0;
DamageMeters_debugTimers[timer].peak = 0;
end
-- Define DamageMeters_Quantity_MAX.
-- ALL QUANTITIES MUST BE DEFINED BEFORE THIS POINT.
DamageMeters_Quantity_MAX = table.getn(DM_QUANTDEFS);
DMPrintD("DamageMeters_Quantity_MAX = "..DamageMeters_Quantity_MAX);
-- Inititalize quantity color codes.
for quant = 1, DamageMeters_Quantity_MAX do
local color = DM_QUANTDEFS[quant].defaultColor;
local code = string.format("|cFF%02X%02X%02X",
floor(color[1] * 255.0),
floor(color[2] * 255.0),
floor(color[3] * 255.0));
DamageMeters_quantityColorCodeDefault[quant] = code;
end
-- Set default options. Variable loading from SavedVars happens after OnLoad.
DamageMeters_SetDefaultOptions();
if (not DamageMetersFrame:IsUserPlaced()) then
DMPrintD("Not user placed: resetting pos.");
DamageMeters_ResetPos();
end
-- Build arrays for easy reference of Bars and BarText, and initialize those elements.
local name = this:GetName();
local i;
for i = 1,DamageMeters_BARCOUNT_MAX do
DamageMeters_bars[i] = getglobal(name.."Bar"..i);
DamageMeters_bars[i]:SetID(i);
DamageMeters_bars[i]:Hide();
DamageMeters_text[i] = getglobal(name.."Text"..i);
SetTextStatusBarText(DamageMeters_bars[i], DamageMeters_text[i]);
-- Force text on always.
ShowTextStatusBarText(DamageMeters_bars[i]);
end
-- Initialize the sync bars.
DamageMeters_sendMsgQueueBar = getglobal("DamageMetersFrame_SendMsgQueueBar");
DamageMeters_sendMsgQueueBarText = getglobal("DamageMetersFrame_SendMsgQueueBarText");
SetTextStatusBarText(DamageMeters_sendMsgQueueBar, DamageMeters_sendMsgQueueBarText);
DamageMeters_sendMsgQueueBar:SetMinMaxValues(0, 100);
DamageMeters_sendMsgQueueBar:SetValue(100);
DamageMeters_sendMsgQueueBar:SetStatusBarColor(1.00, 0.0, 0.00);
-- Force text on always.
ShowTextStatusBarText(DamageMeters_sendMsgQueueBar);
DamageMeters_sendMsgQueueBarText:SetPoint("CENTER", DamageMeters_sendMsgQueueBar:GetName(), "CENTER", 0, 0);
DamageMeters_sendMsgQueueBarText:SetText("");
DamageMeters_sendMsgQueueBar:Hide();
DamageMeters_processMsgQueueBar = getglobal("DamageMetersFrame_ProcessMsgQueueBar");
DamageMeters_processMsgQueueBarText = getglobal("DamageMetersFrame_ProcessMsgQueueBarText");
SetTextStatusBarText(DamageMeters_processMsgQueueBar, DamageMeters_processMsgQueueBarText);
DamageMeters_processMsgQueueBar:SetMinMaxValues(0, 250);
DamageMeters_processMsgQueueBar:SetValue(0);
DamageMeters_processMsgQueueBar:SetStatusBarColor(1.00, 0.0, 0.00);
-- Force text on always.
ShowTextStatusBarText(DamageMeters_processMsgQueueBar);
DamageMeters_processMsgQueueBarText:SetPoint("CENTER", DamageMeters_processMsgQueueBar:GetName(), "CENTER", 0, 0);
DamageMeters_processMsgQueueBarText:SetText("");
DamageMeters_processMsgQueueBar:Hide();
this:RegisterEvent("VARIABLES_LOADED");
-- Register these events, which will then cause us to register/unregister the rest.
this:RegisterEvent("PLAYER_ENTERING_WORLD");
this:RegisterEvent("PLAYER_LEAVING_WORLD");
-- Console commands.
SlashCmdList["DAMAGEMETERSHELP"] = DamageMeters_Help;
SLASH_DAMAGEMETERSHELP1 = "/dmhelp";
SlashCmdList["DAMAGEMETERSCMD"] = DamageMeters_ListCommands;
SLASH_DAMAGEMETERSCMD1 = "/dmcmd";
SlashCmdList["DAMAGEMETERSSHOW"] = DamageMeters_ToggleShow;
SLASH_DAMAGEMETERSSHOW1 = "/dmshow";
SlashCmdList["DAMAGEMETERSHIDE"] = DamageMeters_Hide;
SLASH_DAMAGEMETERSHIDE1 = "/dmhide";
SlashCmdList["DAMAGEMETERSCLEAR"] = DamageMeters_Clear;
SLASH_DAMAGEMETERSCLEAR1 = "/dmclear";
SlashCmdList["DAMAGEMETERSREPORT"] = DamageMeters_Report;
SLASH_DAMAGEMETERSREPORT1 = "/dmreport";
SlashCmdList["DAMAGEMETERSSORT"] = DamageMeters_SetSort;
SLASH_DAMAGEMETERSSORT1 = "/dmsort";
SlashCmdList["DAMAGEMETERSCOUNT"] = DamageMeters_SetCount;
SLASH_DAMAGEMETERSCOUNT1 = "/dmcount";
SlashCmdList["DAMAGEMETERSSAVE"] = DamageMeters_Save;
SLASH_DAMAGEMETERSSAVE1 = "/dmsave";
SlashCmdList["DAMAGEMETERSRESTORE"] = DamageMeters_Restore;
SLASH_DAMAGEMETERSRESTORE1 = "/dmrestore";
SlashCmdList["DAMAGEMETERSMERGE"] = DamageMeters_Merge;
SLASH_DAMAGEMETERSMERGE1 = "/dmmerge";
SlashCmdList["DAMAGEMETERSSWAP"] = DamageMeters_Swap;
SLASH_DAMAGEMETERSSWAP1 = "/dmswap";
SlashCmdList["DAMAGEMETERSMEMCLEAR"] = DamageMeters_MemClear;
SLASH_DAMAGEMETERSMEMCLEAR1 = "/dmmemclear";
SlashCmdList["DAMAGEMETERSRESETPOS"] = DamageMeters_ResetPos;
SLASH_DAMAGEMETERSRESETPOS1 = "/dmresetpos";
SlashCmdList["DAMAGEMETERSSHOWTEXT"] = DamageMeters_SetTextOptions;
SLASH_DAMAGEMETERSSHOWTEXT1 = "/dmtext";
SlashCmdList["DAMAGEMETERSCOLORSCHEME"] = DamageMeters_SetColorScheme;
SLASH_DAMAGEMETERSCOLORSCHEME1 = "/dmcolor";
SlashCmdList["DAMAGEMETERSQUANTITY"] = DamageMeters_SetQuantity;
SLASH_DAMAGEMETERSQUANTITY1 = "/dmquant";
SlashCmdList["DAMAGEMETERSVISINPARTY"] = DamageMeters_SetVisibleInParty;
SLASH_DAMAGEMETERSVISINPARTY1 = "/dmvisinparty";
SlashCmdList["DAMAGEMETERSAUTOCOUNT"] = DamageMeters_SetAutoCount;
SLASH_DAMAGEMETERSAUTOCOUNT1 = "/dmautocount";
SlashCmdList["DAMAGEMETERSLISTBANNED"] = DamageMeters_ListBanned;
SLASH_DAMAGEMETERSLISTBANNED1 = "/dmlistbanned";
SlashCmdList["DAMAGEMETERSCLEARBANNED"] = DamageMeters_ClearBanned;
SLASH_DAMAGEMETERSCLEARBANNED1 = "/dmclearbanned";
SlashCmdList["DAMAGEMETERSSYNC"] = DamageMeters_Sync;
SLASH_DAMAGEMETERSSYNC1 = "/dmsync";
SlashCmdList["DAMAGEMETERSSYNCCHAN"] = DamageMeters_SyncChan;
SLASH_DAMAGEMETERSSYNCCHAN1 = "/dmsyncchan";
SlashCmdList["DAMAGEMETERSSYNCLEAVE"] = DamageMeters_SyncLeaveChanCmd;
SLASH_DAMAGEMETERSSYNCLEAVE1 = "/dmsyncleave";
SlashCmdList["DAMAGEMETERSSYNCSEND"] = DamageMeters_SyncReport;
SLASH_DAMAGEMETERSSYNCSEND1 = "/dmsyncsend";
SlashCmdList["DAMAGEMETERSSYNCREQUEST"] = DamageMeters_SyncRequest;
SLASH_DAMAGEMETERSSYNCREQUEST1 = "/dmsyncrequest";
SlashCmdList["DAMAGEMETERSSYNCCLEAR"] = DamageMeters_SyncClear;
SLASH_DAMAGEMETERSSYNCCLEAR1 = "/dmsyncclear";
SlashCmdList["DAMAGEMETERSSYNCMSG"] = DamageMeters_SendSyncMsg;
SLASH_DAMAGEMETERSSYNCMSG1 = "/dmsyncmsg";
SLASH_DAMAGEMETERSSYNCMSG2 = "/dmm";
SlashCmdList["DAMAGEMETERSSYNCBROADCASTCHAN"] = DamageMeters_SyncBroadcastChan;
SLASH_DAMAGEMETERSSYNCBROADCASTCHAN1 = "/dmsyncbroadcastchan";
SLASH_DAMAGEMETERSSYNCBROADCASTCHAN2 = "/dmsyncb";
SlashCmdList["DAMAGEMETERSSYNCPING"] = DamageMeters_SyncPingRequest;
SLASH_DAMAGEMETERSSYNCPING1 = "/dmsyncping";
SlashCmdList["DAMAGEMETERSSYNCPAUSE"] = DamageMeters_SyncPause;
SLASH_DAMAGEMETERSSYNCPAUSE1 = "/dmsyncpause";
SlashCmdList["DAMAGEMETERSSYNCUNPAUSE"] = DamageMeters_SyncUnpause;
SLASH_DAMAGEMETERSSYNCUNPAUSE1 = "/dmsyncunpause";
SlashCmdList["DAMAGEMETERSSYNCREADY"] = DamageMeters_SyncReady;
SLASH_DAMAGEMETERSSYNCREADY1 = "/dmsyncready";
SlashCmdList["DAMAGEMETERSSYNCKICK"] = DamageMeters_SyncKick;
SLASH_DAMAGEMETERSSYNCKICK1 = "/dmsynckick";
SlashCmdList["DAMAGEMETERSSYNCLABEL"] = DamageMeters_SyncLabel;
SLASH_DAMAGEMETERSSYNCLABEL1 = "/dmsynclabel";
SlashCmdList["DAMAGEMETERSSYNCSTART"] = DamageMeters_SyncStart;
SLASH_DAMAGEMETERSSYNCSTART1 = "/dmsyncstart";
SlashCmdList["DAMAGEMETERSSYNCHALT"] = DamageMeters_SyncHalt;
SLASH_DAMAGEMETERSSYNCHALT1 = "/dmsynchalt";
--SlashCmdList["DAMAGEMETERSSYNCBOSSSTART"] = DamageMeters_SyncBossStart;
--SLASH_DAMAGEMETERSSYNCBOSSSTART1 = "/dmsyncbossstart";
--SlashCmdList["DAMAGEMETERSSYNCBOSSEND"] = DamageMeters_SyncBossEnd;
--SLASH_DAMAGEMETERSSYNCBOSSEND1 = "/dmsyncbossend";
-- Undocumented atm.
SlashCmdList["DAMAGEMETERSSYNCEMOTE"] = DamageMeters_SyncEmote;
SLASH_DAMAGEMETERSSYNCEMOTE1 = "/dme";
SlashCmdList["DAMAGEMETERSRPS"] = DamageMeters_RPSChallenge;
SLASH_DAMAGEMETERSRPS1 = "/dmrps";
SlashCmdList["DAMAGEMETERSRPSR"] = DamageMeters_RPSResponse;
SLASH_DAMAGEMETERSRPSR1 = "/dmrpsr";
SlashCmdList["DAMAGEMETERSPOPULATE"] = DamageMeters_Populate;
SLASH_DAMAGEMETERSPOPULATE1 = "/dmpop";
SlashCmdList["DAMAGEMETERSTOGGLELOCK"] = DamageMeters_ToggleLock;
SLASH_DAMAGEMETERSTOGGLELOCK1 = "/dmlock";
SlashCmdList["DAMAGEMETERSTOGGLEPAUSE"] = DamageMeters_TogglePause;
SLASH_DAMAGEMETERSTOGGLEPAUSE1 = "/dmpause";
SlashCmdList["DAMAGEMETERSSETREADY"] = DamageMeters_SetReady;
SLASH_DAMAGEMETERSSETREADY1 = "/dmready";
SlashCmdList["DAMAGEMETERSTOGGLELOCKPOS"] = DamageMeters_ToggleLockPos;
SLASH_DAMAGEMETERSTOGGLELOCKPOS1 = "/dmlockpos";
SlashCmdList["DAMAGEMETERSTOGGLEGROUPONLY"] = DamageMeters_ToggleGroupMembersOnly;
SLASH_DAMAGEMETERSTOGGLEGROUPONLY1 = "/dmgrouponly";
SlashCmdList["DAMAGEMETERSTOGGLEADDPETTOPLAYER"] = DamageMeters_ToggleAddPetToPlayer;
SLASH_DAMAGEMETERSTOGGLEADDPETTOPLAYER1 = "/dmaddpettoplayer";
SlashCmdList["DAMAGEMETERSTOGGLERESETWHENCOMBATSTARTS"] = DamageMeters_ToggleResetWhenCombatStarts;
SLASH_DAMAGEMETERSTOGGLERESETWHENCOMBATSTARTS1 = "/dmresetoncombat";
SlashCmdList["DAMAGEMETERSVERSION"] = DamageMeters_ShowVersion;
SLASH_DAMAGEMETERSVERSION1 = "/dmversion";
SLASH_DAMAGEMETERSVERSION2 = "/dmver";
SlashCmdList["DAMAGEMETERSTOGGLETOTAL"] = DamageMeters_ToggleTotal;
SLASH_DAMAGEMETERSTOGGLETOTAL1 = "/dmtotal";
SlashCmdList["DAMAGEMETERSTOGGLESHOWMAX"] = DamageMeters_ToggleMaxBars;
SLASH_DAMAGEMETERSTOGGLESHOWMAX1 = "/dmshowmax";
-- Commands for testing.
-- ["reset"] = "/dmreset - (For Testing) Forces a re-layout of the visual elements.",
SlashCmdList["DAMAGEMETERSRESET"] = DamageMeters_Reset;
SLASH_DAMAGEMETERSRESET1 = "/dmreset";
-- ["test"] = "/dmtest [#] - (For Testing) Adds # test entries to the list. If no number specified, adds one entry for each visible bar.",
SlashCmdList["DAMAGEMETERSTEST"] = DamageMeters_Test;
SLASH_DAMAGEMETERSTEST1 = "/dmtest";
-- ["add"] = "/dmadd name - (For Testing) Simulates player 'name' doing 1 damage.",
SlashCmdList["DAMAGEMETERSADD"] = DamageMeters_Add;
SLASH_DAMAGEMETERSADD1 = "/dmadd";
-- ["dumptable"] = "/dmdumptable - (For Testing) Dumps the entire internal data table."
SlashCmdList["DAMAGEMETERSDUMPTABLE"] = DamageMeters_DumpTable;
SLASH_DAMAGEMETERSDUMPTABLE1 = "/dmdumptable";
SlashCmdList["DAMAGEMETERSDEBUGPRINT"] = DM_ToggleDMPrintD;
SLASH_DAMAGEMETERSDEBUGPRINT1 = "/dmdebug";
SlashCmdList["DAMAGEMETERSDUMPMSG"] = DM_DumpMsg;
SLASH_DAMAGEMETERSDUMPMSG1 = "/dmdumpmsg";
SlashCmdList["DAMAGEMETERSCONSOLEPRINT"] = DM_ConsolePrint;
SLASH_DAMAGEMETERSCONSOLEPRINT1 = "/dmp";
SlashCmdList["DAMAGEMETERSCONSOLEPRINTTABLE"] = DM_ConsolePrintTable;
SLASH_DAMAGEMETERSCONSOLEPRINTTABLE1 = "/dmpt";
-- Tell the frame to rebuild itself.
DamageMeters_UpdateVisibility();
DamageMeters_frameNeedsToBeGenerated = true;
DamageMeters_lastUpdateTime = GetTime();
DamageMeters_lastProcessQueueTime = DamageMeters_lastUpdateTime;
DamageMeters_lastEventTime = GetTime();
DamageMeters_FixPatterns();
end
function DamageMeters_RegisterEvents()
for index, event in DamageMeters_watchedEventsTable do
this:RegisterEvent(event);
end
-- This is a hack--if the frame is initially hidden the stupid dropdown
-- menu doesn't work right and needs to be opened twice to be seen the first
-- time.
DMReportFrame:Hide();
end
function DamageMeters_UnregisterEvents()
for index, event in DamageMeters_watchedEventsTable do
this:UnregisterEvent(event);
end
end
function DamageMeters_DeleteDMIData(dmi, dmiCount)
for tableIx, table in DamageMeters_tables do
for playerIx, playerStruct in table do
local dmiTemp;
for dmiTemp = dmi, dmiCount do
playerStruct[dmiTemp] = playerStruct[dmiTemp - 1];
end
end
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -