PHP код:
StaticPopupDialogs["INSTANCE_LOCK"] = {
-- we use a custom timer called lockTimeleft in here to avoid special casing the static popup code
-- if you use timeout or timeleft then you will go through the StaticPopup system's standard OnUpdate
-- code which we don't want for this dialog
text = INSTANCE_LOCK_TIMER,
button1 = ACCEPT,
button2 = INSTANCE_LEAVE,
OnShow = function(self)
local lockTimeleft, isPreviousInstance =GetInstanceLockTimeRemaining();
if ( lockTimeleft <= 0 ) then
self:Hide();
return;
end
self.lockTimeleft = lockTimeleft;
self.isPreviousInstance = isPreviousInstance;
local type, difficulty;
self.name, type, difficulty, self.difficultyName = GetInstanceInfo();
self.extraFrame:SetAllPoints(self.text)
self.extraFrame:Show()
self.extraFrame:SetScript("OnEnter", InstanceLock_OnEnter)
self.extraFrame:SetScript("OnLeave", GameTooltip_Hide)
end,
OnHide = function(self)
self.extraFrame:SetScript("OnEnter", nil)
self.extraFrame:SetScript("OnLeave", nil)
end,
OnUpdate = function(self, elapsed)
local lockTimeleft = self.lockTimeleft - elapsed;
if ( lockTimeleft <= 0 ) then
local OnCancel = StaticPopupDialogs["INSTANCE_LOCK"].OnCancel;
if ( OnCancel ) then
OnCancel(self, nil, "timeout");
end
self:Hide();
return;
end
self.lockTimeleft = lockTimeleft;
local name = GetDungeonNameWithDifficulty(self.name, self.difficultyName);
-- Set dialog message using information that describes which bosses are still around
local text = _G[self:GetName().."Text"];
local lockstring = string.format((self.isPreviousInstance and INSTANCE_LOCK_TIMER_PREVIOUSLY_SAVED or INSTANCE_LOCK_TIMER), name, SecondsToTime(ceil(lockTimeleft), nil, 1));
local time, extending;
time, extending, self.extraFrame.encountersTotal, self.extraFrame.encountersComplete = GetInstanceLockTimeRemaining();
local bosses = string.format(BOSSES_KILLED, self.extraFrame.encountersComplete, self.extraFrame.encountersTotal);
text:SetFormattedText(INSTANCE_LOCK_SEPARATOR, lockstring, bosses);
-- make sure the dialog fits the text
StaticPopup_Resize(self, "INSTANCE_LOCK");
end,
OnAccept = function(self)
RespondInstanceLock(true);
self.name, self.difficultyName = nil, nil;
self.lockTimeleft = nil;
end,
OnCancel = function(self, data, reason)
if ( reason == "timeout" ) then
self:Hide();
return;
end
RespondInstanceLock(false);
self.name, self.difficultyName = nil, nil;
self.lockTimeleft = nil;
end,
timeout = 0,
showAlert = 1,
whileDead = 1,
interruptCinematic = 1,
notClosableByLogout = 1,
noCancelOnReuse = 1,
};