📄 equipcompare.lua
字号:
end
end;
check = true;
default = { checked = false; };
disabled = { checked = false; };
},{
id = "EquipCompareOptionCVIntegration";
type = K_TEXT;
difficulty = 2;
text = EQUIPCOMPARE_COSMOS_CVMODE;
helptext = EQUIPCOMPARE_COSMOS_CVMODE_INFO;
callback = function(state) EquipCompare_ToggleCV(state.checked); end;
feedback = function(state)
if (state.checked) then
return EQUIPCOMPARE_TOGGLECV_ON;
else
return EQUIPCOMPARE_TOGGLECV_OFF;
end
end;
check = true;
default = { checked = true; };
disabled = { checked = false; };
},{
id = "EquipCompareOptionAltMode";
type = K_TEXT;
difficulty = 3;
text = EQUIPCOMPARE_COSMOS_ALTMODE;
helptext = EQUIPCOMPARE_COSMOS_ALTMODE_INFO;
callback = function(state) EquipCompare_ToggleAlt(state.checked); end;
feedback = function(state)
if (state.checked) then
return EQUIPCOMPARE_TOGGLEALT_ON;
else
return EQUIPCOMPARE_TOGGLEALT_OFF;
end
end;
check = true;
default = { checked = false; };
disabled = { checked = false; };
},{
id = "EquipCompareOptionShiftupMode";
type = K_TEXT;
difficulty = 2;
text = EQUIPCOMPARE_COSMOS_SHIFTUP;
helptext = EQUIPCOMPARE_COSMOS_SHIFTUP_INFO;
callback = function(state) EquipCompare_ToggleShiftup(state.checked); end;
feedback = function(state)
if (state.checked) then
return EQUIPCOMPARE_SHIFTUP_ON;
else
return EQUIPCOMPARE_SHIFTUP_OFF;
end
end;
check = true;
default = { checked = false; };
disabled = { checked = false; };
}
}
}
)
end
function EquipCompare_Register_Cosmos()
-- Note: Default to disabled if Cosmos is present
Cosmos_RegisterConfiguration(
"COS_EQC",
"SECTION",
EQUIPCOMPARE_COSMOS_SECTION,
EQUIPCOMPARE_COSMOS_SECTION_INFO
);
Cosmos_RegisterConfiguration(
"COS_EQC_SEPARATOR",
"SEPARATOR",
EQUIPCOMPARE_COSMOS_HEADER,
EQUIPCOMPARE_COSMOS_HEADER_INFO
);
Cosmos_RegisterConfiguration(
"COS_EQC_ENABLED",
"CHECKBOX",
EQUIPCOMPARE_COSMOS_ENABLE,
EQUIPCOMPARE_COSMOS_ENABLE_INFO,
EquipCompare_Toggle,
0
);
Cosmos_RegisterConfiguration(
"COS_EQC_CONTROLMODE",
"CHECKBOX",
EQUIPCOMPARE_COSMOS_CONTROLMODE,
EQUIPCOMPARE_COSMOS_CONTROLMODE_INFO,
EquipCompare_ToggleControl,
0
);
Cosmos_RegisterConfiguration(
"COS_EQC_CVMODE",
"CHECKBOX",
EQUIPCOMPARE_COSMOS_CVMODE,
EQUIPCOMPARE_COSMOS_CVMODE_INFO,
EquipCompare_ToggleCV,
1
);
Cosmos_RegisterConfiguration(
"COS_EQC_ALTMODE",
"CHECKBOX",
EQUIPCOMPARE_COSMOS_ALTMODE,
EQUIPCOMPARE_COSMOS_ALTMODE_INFO,
EquipCompare_ToggleAlt,
0
);
Cosmos_RegisterConfiguration(
"COS_EQC_SHIFTUP",
"CHECKBOX",
EQUIPCOMPARE_COSMOS_SHIFTUP,
EQUIPCOMPARE_COSMOS_SHIFTUP_INFO,
EquipCompare_ToggleShiftup,
0
);
end
--
-- XML Event handlers
--
function EquipCompare_OnLoad()
-- Hook into various methods of ShoppingTooltips
EquipCompare_SetupHooks();
-- Initialize lists
EquipCompare_InitializeTooltipList();
EquipCompare_InitializeBarList();
-- GUI configuration registration
-- Check for Khaos. If available, register with it.
if ( Khaos ) then
EquipCompare_Register_Khaos();
elseif ( Cosmos_RegisterConfiguration ) then
-- Check for Cosmos. If available, register with it.
EquipCompare_Register_Cosmos()
end
-- Slash command registration - for now, don't use Khaos
-- If Sky is present, use it to register slash commands
if ( Sky ) then
Sky.registerSlashCommand {
id = "EquipCompare";
commands = { "/equipcompare", "/eqc" };
onExecute = EquipCompare_SlashCommand;
helpText = EQUIPCOMPARE_COSMOS_SLASH_DESC;
}
-- If Cosmos allows chat command registration, do so
elseif ( Cosmos_RegisterChatCommand ) then
local comlist = { "/equipcompare", "/eqc" };
local desc = EQUIPCOMPARE_COSMOS_SLASH_DESC;
local id = "EQUIPCOMPARE";
local func = EquipCompare_SlashCommand
Cosmos_RegisterChatCommand ( id, comlist, func, desc, CSM_CHAINNONE );
else
-- otherwise, just register slash commands manually
SlashCmdList["EQUIPCOMPARE"] = EquipCompare_SlashCommand;
SLASH_EQUIPCOMPARE1 = "/equipcompare";
SLASH_EQUIPCOMPARE2 = "/eqc";
end
-- Check to see if CharactersViewer is installed, has the right version
-- and has the required interface. If so, enable support for it.
if ( IsCharactersViewer() ) then
EquipCompare_CharactersViewer = true;
end
EquipCompare_Register();
end
function EquipCompare_OnEvent()
end
function EquipCompare_PostClearTooltip()
if ( not EquipCompare_Protected ) then
EquipCompare_Recheck = true;
end
end
local lastAltState = "undefined";
-- This function is called on every OnUpdate. This is the only way to detect if a
-- game tooltip has been displayed, without overriding FrameXML files or hooking
-- millions of functions.
-- So that this function doesn't hog resources, the EquipCompare_Recheck flag is
-- set to false, until the game tooltip changes.
function EquipCompare_OnUpdate()
if ( not EquipCompare_Enabled ) then
return;
end
if ( EquipCompare_ControlMode and not IsControlKeyDown() ) then
if (EquipCompare_TargetTooltip) then
EquipCompare_Recheck = true;
EquipCompare_TargetTooltip = nil;
EquipCompare_HideTips();
end
return;
end
if ( EquipCompare_AltMode and lastAltState ~= IsAltKeyDown() ) then
local changed;
lastAltState = IsAltKeyDown();
if ( lastAltState ) then
if ( IsCharactersViewer() ) then
EquipCompare_CharactersViewer = true;
changed = true;
end
else
if ( EquipCompare_CharactersViewer ) then
EquipCompare_CharactersViewer = false;
changed = true;
end
end
if ( changed ) then
EquipCompare_Recheck = true;
EquipCompare_TargetTooltip = nil;
EquipCompare_HideTips();
end
end
-- If we currently have a target that has since become
-- hidden, hide the comparison tooltips too.
if ( EquipCompare_TargetTooltip and
not EquipCompare_TargetTooltip:IsVisible() ) then
EquipCompare_Recheck = true;
EquipCompare_TargetTooltip = nil;
EquipCompare_HideTips();
end
if ( not EquipCompare_Recheck ) then
return;
end
EquipCompare_CheckCompare();
end
--
-- Other functions
--
function EquipCompare_SetupHooks()
EquipCompare_old_SetAuctionCompareItem1 = ShoppingTooltip1.SetAuctionCompareItem;
EquipCompare_old_SetAuctionCompareItem2 = ShoppingTooltip2.SetAuctionCompareItem;
ShoppingTooltip1.SetAuctionCompareItem = function(a1,a2,a3,a4,a5)
if ( EquipCompare_Enabled ) then
return false;
else
return EquipCompare_old_SetAuctionCompareItem1(a1,a2,a3,a4,a5);
end
end
ShoppingTooltip2.SetAuctionCompareItem = function(a1,a2,a3,a4,a5)
if ( EquipCompare_Enabled ) then
return false;
else
return EquipCompare_old_SetAuctionCompareItem2(a1,a2,a3,a4,a5);
end
end
EquipCompare_old_SetMerchantCompareItem1 = ShoppingTooltip1.SetMerchantCompareItem;
EquipCompare_old_SetMerchantCompareItem2 = ShoppingTooltip2.SetMerchantCompareItem;
ShoppingTooltip1.SetMerchantCompareItem = function(a1,a2,a3,a4,a5)
if ( EquipCompare_Enabled ) then
return false;
else
return EquipCompare_old_SetMerchantCompareItem1(a1,a2,a3,a4,a5);
end
end
ShoppingTooltip2.SetMerchantCompareItem = function(a1,a2,a3,a4,a5)
if ( EquipCompare_Enabled ) then
return false;
else
return EquipCompare_old_SetMerchantCompareItem2(a1,a2,a3,a4,a5);
end
end
end
local function EquipCompare_EmptyFunction() end;
function EquipCompare_InitializeTooltipList()
if ( not EquipCompare_TooltipList ) then
EquipCompare_TooltipList = {};
end
EquipCompare_RegisterTooltip(ItemRefTooltip, "high");
EquipCompare_RegisterTooltip(LootLinkTooltip);
EquipCompare_RegisterTooltip(GameTooltip, "low");
end
function EquipCompare_InitializeBarList()
if ( not EquipCompare_BarList ) then
EquipCompare_BarList = {};
end
EquipCompare_RegisterExclusion("^Character.*Slot");
EquipCompare_RegisterExclusion("^CharactersViewer_Frame");
EquipCompare_RegisterExclusion("^TempEnchant");
EquipCompare_RegisterExclusion("^MultiBar");
EquipCompare_RegisterExclusion("^ActionButton");
EquipCompare_RegisterExclusion("^WeaponButton.*Slot");
end
local showedTip = false;
function EquipCompare_SlashCommand(msg)
local setlevel = false;
if (not msg or msg == "") then
-- toggle
EquipCompare_Toggle(not EquipCompare_Enabled);
if (EquipCompare_Enabled) then
ChatFrame1:AddMessage(EQUIPCOMPARE_TOGGLE_ON);
else
ChatFrame1:AddMessage(EQUIPCOMPARE_TOGGLE_OFF);
end
if (not showedTip) then
showedTip = true;
ChatFrame1:AddMessage(EQUIPCOMPARE_HELPTIP);
end
setlevel = true;
elseif (msg == "on") then
-- turn on
EquipCompare_Toggle(true);
ChatFrame1:AddMessage(EQUIPCOMPARE_TOGGLE_ON);
setlevel = true;
elseif (msg == "off") then
-- turn off
EquipCompare_Toggle(false);
ChatFrame1:AddMessage(EQUIPCOMPARE_TOGGLE_OFF);
setlevel = true;
elseif (msg == "control") then
-- toggle Control Key Mode
EquipCompare_ToggleControl(not EquipCompare_ControlMode);
if (EquipCompare_ControlMode) then
ChatFrame1:AddMessage(EQUIPCOMPARE_TOGGLECONTROL_ON);
else
ChatFrame1:AddMessage(EQUIPCOMPARE_TOGGLECONTROL_OFF);
end
elseif (msg == "cv") then
-- toggle CharactersViewer integration
EquipCompare_ToggleCV(not EquipCompare_UseCV);
if (EquipCompare_UseCV) then
ChatFrame1:AddMessage(EQUIPCOMPARE_TOGGLECV_ON);
else
ChatFrame1:AddMessage(EQUIPCOMPARE_TOGGLECV_OFF);
end
elseif (msg == "alt") then
-- toggle Alt Key Mode
EquipCompare_ToggleAlt(not EquipCompare_AltMode);
if (EquipCompare_AltMode) then
ChatFrame1:AddMessage(EQUIPCOMPARE_TOGGLEALT_ON);
else
ChatFrame1:AddMessage(EQUIPCOMPARE_TOGGLEALT_OFF);
end
elseif (msg == "shift") then
-- toggle Alt Key Mode
EquipCompare_ToggleShiftup(not EquipCompare_Shiftup);
if (EquipCompare_Shiftup) then
ChatFrame1:AddMessage(EQUIPCOMPARE_SHIFTUP_ON);
else
ChatFrame1:AddMessage(EQUIPCOMPARE_SHIFTUP_OFF);
end
else
-- usage
for i, s in EQUIPCOMPARE_USAGE_TEXT do
ChatFrame1:AddMessage(s);
end
end
end
function EquipCompare_Toggle(toggle)
-- workaround, as Cosmos sends a 0 when it wants to turn us off
if ( toggle == 0 ) then toggle = false; end
-- turn on
if ( toggle and not EquipCompare_Enabled ) then
EquipCompare_Enabled = true;
EquipCompare_Recheck = true;
-- In case Blizzard's ShoppingTooltips are visible, hide them
ShoppingTooltip1:Hide();
ShoppingTooltip2:Hide();
end
-- turn off
if ( not toggle and EquipCompare_Enabled ) then
EquipCompare_Enabled = false;
EquipCompare_HideTips();
end
end
function EquipCompare_ToggleControl(toggle)
-- workaround, as Cosmos sends a 0 when it wants to turn us off
if ( toggle == 0 ) then toggle = false; end
-- turn on
if ( toggle ) then
EquipCompare_ControlMode = true;
end
-- turn off
if ( not toggle ) then
EquipCompare_ControlMode = false;
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -