📄 monkeyquest.lua
字号:
--[[
MonkeyQuest:
Displays your quests for quick viewing.
Website: http://wow.visualization.ca/
Author: Trentin (monkeymods@gmail.com)
Contributors:
Celdor
- Help with the Quest Log Freeze bug
Diungo
- Toggle grow direction
Pkp
- Color Quest Titles the same as the quest level
wowpendium.de
- German translation
MarsMod
- Valid player name before the VARIABLES_LOADED event bug
- Settings resetting bug
Dunewarrior
- Tooltip update for WoW 1.7.0
Global
- PvP Quests
--]]
-- script variables not saved
MonkeyQuest = {};
MonkeyQuest.m_bLoaded = false; -- true when the config variables are loaded
MonkeyQuest.m_bVariablesLoaded = false;
MonkeyQuest.m_iNumQuestButtons = 40; -- 40 is the max possible entries in the quest log (20 quests and 20 different locations)
MonkeyQuest.m_iMaxTextWidth = 229; -- wraps the text if it gets too long, mostly needed for objectives
MonkeyQuest.m_strPlayer = "";
MonkeyQuest.m_aQuestList = {};
MonkeyQuest.m_aQuestItemList = {};
MonkeyQuest.m_bGotQuestLogUpdate = false;
MonkeyQuest.m_bNeedRefresh = false;
MonkeyQuest.m_fTimeSinceRefresh = 0.0;
MonkeyQuest.m_bCleanQuestList = true; -- used to clean up the hidden list on the first questlog update event
MonkeyQuest.m_colourBorder = { r = TOOLTIP_DEFAULT_COLOR.r, g = TOOLTIP_DEFAULT_COLOR.g, b = TOOLTIP_DEFAULT_COLOR.b };
function MonkeyQuest_OnLoad()
-- register events
this:RegisterEvent('VARIABLES_LOADED');
this:RegisterEvent('QUEST_LOG_UPDATE'); -- used to know when to refresh the MonkeyQuest text
this:RegisterEvent('UNIT_NAME_UPDATE'); -- this is the event I use to get per character config settings
this:RegisterEvent('PLAYER_ENTERING_WORLD'); -- this event gives me a good character name in situations where 'UNIT_NAME_UPDATE' doesn't even trigger
this:RegisterEvent('PLAYER_LEVEL_UP'); -- when you level up the difficulty of some quests may change
-- events when zone changes to update the zone highlighting quests
this:RegisterEvent('ZONE_CHANGED');
this:RegisterEvent('ZONE_CHANGED_INDOORS');
this:RegisterEvent('ZONE_CHANGED_NEW_AREA');
-- initialize the border and backdrop of the main frame
--this:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b);
--this:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b, 0);
-- setup the title of the main frame
MonkeyQuestTitleText:SetText(MONKEYQUEST_TITLE);
MonkeyQuestTitleText:SetTextColor(MONKEYLIB_TITLE_COLOUR.r, MONKEYLIB_TITLE_COLOUR.g, MONKEYLIB_TITLE_COLOUR.b);
MonkeyQuestTitleText:Show();
MonkeyQuestSlash_Init();
-- overide af tooltip functions
MonkeyQuest_OLD_aftt_setName = aftt_setName;
aftt_setName = MonkeyQuest_NEW_aftt_setName;
-- this will catch mobs needed for quests
this:RegisterEvent('UPDATE_MOUSEOVER_UNIT');
-- this should catch items when you're going to sell them
MonkeyQuest_OLD_ContainerFrameItemButton_OnEnter = ContainerFrameItemButton_OnEnter;
ContainerFrameItemButton_OnEnter = MonkeyQuest_NEW_ContainerFrameItemButton_OnEnter;
end
function MonkeyQuest_OnUpdate(arg1)
-- if not loaded yet then get out
if (MonkeyQuest.m_bLoaded == false) then
return;
end
-- need to make sure we don't read from the quest list before a QUEST_LOG_UPDATE or we'll get the previous character's data
if (MonkeyQuest.m_bGotQuestLogUpdate == false) then
return;
end
-- update the timer
MonkeyQuest.m_fTimeSinceRefresh = MonkeyQuest.m_fTimeSinceRefresh + arg1;
-- if it's been more than MONKEYQUEST_DELAY seconds and we need to process a dropped QUEST_LOG_UPDATE
if (MonkeyQuest.m_fTimeSinceRefresh > MONKEYQUEST_DELAY and MonkeyQuest.m_bNeedRefresh == true) then
MonkeyQuest_Refresh();
end
if (MonkeyQuest.m_bCleanQuestList == true) then
if (MonkeyQuest.m_fTimeSinceRefresh > 15.0) then
MonkeyQuestInit_CleanQuestList();
MonkeyQuest.m_bCleanQuestList = false;
end
end
end
function MonkeyQuest_OnQuestLogUpdate()
-- if everything's been loaded, refresh the Quest Monkey Display
if (MonkeyQuest.m_bLoaded == true) then
if (MonkeyQuest.m_bNeedRefresh == true) then
-- don't process, let the OnUpdate catch it, but reset the timer
MonkeyQuest.m_fTimeSinceRefresh = 0.0;
else
MonkeyQuest.m_bNeedRefresh = true;
MonkeyQuest.m_fTimeSinceRefresh = 0.0;
end
end
end
-- OnEvent Function
function MonkeyQuest_OnEvent(event)
if (event == 'VARIABLES_LOADED') then
-- this event gets called when the variables are loaded
-- there's a possible situation where the other events might get a valid
-- player name BEFORE this event, which resets your config settings :(
MonkeyQuest.m_bVariablesLoaded = true;
-- double check that the mod isn't already loaded
if (not MonkeyQuest.m_bLoaded) then
MonkeyQuest.m_strPlayer = UnitName('player');
-- if MonkeyQuest.m_strPlayer is UNKNOWNOBJECT get out, need a real name
if (MonkeyQuest.m_strPlayer ~= nil and MonkeyQuest.m_strPlayer ~= UNKNOWNOBJECT) then
-- should have a valid player name here
MonkeyQuestInit_LoadConfig();
end
end
-- exit this event
return;
end -- VARIABLES_LOADED
if (event == 'UNIT_NAME_UPDATE') then
-- this event gets called whenever a unit's name changes (supposedly)
-- Note: Sometimes it gets called when unit's name gets set to
-- UNKNOWNOBJECT
-- double check that the mod isn't already loaded
if (not MonkeyQuest.m_bLoaded) then
-- this is the first place I know that reliably gets the player name
MonkeyQuest.m_strPlayer = UnitName('player');
-- if MonkeyQuest.m_strPlayer is UNKNOWNOBJECT get out, need a real name
if (MonkeyQuest.m_strPlayer ~= nil and MonkeyQuest.m_strPlayer ~= UNKNOWNOBJECT) then
-- should have a valid player name here
MonkeyQuestInit_LoadConfig();
end
end
-- exit this event
return;
end -- UNIT_NAME_UPDATE
if (event == 'PLAYER_ENTERING_WORLD') then
-- this event gets called when the player enters the world
-- Note: on initial login this event will not give a good player name
-- double check that the mod isn't already loaded
if (not MonkeyQuest.m_bLoaded) then
MonkeyQuest.m_strPlayer = UnitName('player');
-- if MonkeyQuest.m_strPlayer is UNKNOWNOBJECT get out, need a real name
if (MonkeyQuest.m_strPlayer ~= nil and MonkeyQuest.m_strPlayer ~= UNKNOWNOBJECT) then
-- should have a valid player name here
MonkeyQuestInit_LoadConfig();
end
end
-- exit this event
return;
end -- PLAYER_ENTERING_WORLD
if (event == 'QUEST_LOG_UPDATE') then
MonkeyQuest.m_bGotQuestLogUpdate = true;
MonkeyQuest_OnQuestLogUpdate();
return;
end -- QUEST_LOG_UPDATE
if (event == 'ZONE_CHANGED' or event == 'ZONE_CHANGED_INDOORS' or event == 'ZONE_CHANGED_NEW_AREA') then
MonkeyQuest_Refresh();
end -- ZONE_CHANGED
if (event == 'PLAYER_LEVEL_UP') then
MonkeyQuest_Refresh();
end -- PLAYER_LEVEL_UP
if (event == 'TOOLTIP_ANCHOR_DEFAULT') then
if (MonkeyQuest_SearchTooltip() == true) then
GameTooltip:AddLine(MONKEYQUEST_TOOLTIP_QUESTITEM, MONKEYLIB_TITLE_COLOUR.r, MONKEYLIB_TITLE_COLOUR.g, MONKEYLIB_TITLE_COLOUR.b, 1);
GameTooltip:SetHeight(GameTooltip:GetHeight() + 14);
end
end -- TOOLTIP_ANCHOR_DEFAULT
if (event == 'UPDATE_MOUSEOVER_UNIT') then
-- check if this is a quest item
MonkeyQuest_Refresh();--CraZy aPpLe
MonkeyQuest_SearchTooltip();
end -- UPDATE_MOUSEOVER_UNIT
end
-- this function is called when the frame should be dragged around
function MonkeyQuest_OnMouseDown(arg1)
-- if not loaded yet then get out
if (MonkeyQuest.m_bLoaded == false) then
return;
end
-- left button moves the frame around
if (arg1 == "LeftButton" and MonkeyQuestConfig[MonkeyQuest.m_strPlayer].m_bLocked == false) then
MonkeyQuestFrame:StartMoving();
end
-- right button on the title or frame opens up the MonkeyBuddy, if it's there
if (arg1 == "RightButton" and MonkeyQuestConfig[MonkeyQuest.m_strPlayer].m_bAllowRightClick == true) then
if (MonkeyBuddyFrame ~= nil) then
ShowUIPanel(MonkeyBuddyFrame);
-- make MonkeyBuddy show the MonkeyQuest config
MonkeyBuddyQuestTab_OnClick();
end
end
end
-- this function is called when the frame is stopped being dragged around
function MonkeyQuest_OnMouseUp(arg1)
-- if not loaded yet then get out
if (MonkeyQuest.m_bLoaded == false) then
return;
end
if (arg1 == "LeftButton") then
MonkeyQuestFrame:StopMovingOrSizing();
-- save the position
MonkeyQuestConfig[MonkeyQuest.m_strPlayer].m_iFrameLeft = MonkeyQuestFrame:GetLeft();
MonkeyQuestConfig[MonkeyQuest.m_strPlayer].m_iFrameTop = MonkeyQuestFrame:GetTop();
MonkeyQuestConfig[MonkeyQuest.m_strPlayer].m_iFrameBottom = MonkeyQuestFrame:GetBottom();
end
end
function MonkeyQuestCloseButton_OnClick()
-- if not loaded yet then get out
if (MonkeyQuest.m_bLoaded == false) then
return;
end
MonkeyQuest_Hide();
end
function MonkeyQuestCloseButton_OnEnter()
-- no noob tip?
if (MonkeyQuestConfig[MonkeyQuest.m_strPlayer].m_bShowNoobTips == false) then
return;
end
-- put the tool tip in the default position
GameTooltip:SetOwner(this, "ANCHOR_TOPRIGHT");
-- set the tool tip text
GameTooltip:SetText(MONKEYQUEST_NOOBTIP_HEADER, TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b, 1);
GameTooltip:AddLine(MONKEYQUEST_NOOBTIP_CLOSE, NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, 1);
GameTooltip:AddLine(MONKEYQUEST_HELP_OPEN_MSG, NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, 1);
GameTooltip:Show();
end
function MonkeyQuestMinimizeButton_OnClick()
-- if not loaded yet then get out
if (MonkeyQuest.m_bLoaded == false) then
return;
end
MonkeyQuestConfig[MonkeyQuest.m_strPlayer].m_bMinimized = not MonkeyQuestConfig[MonkeyQuest.m_strPlayer].m_bMinimized;
if (MonkeyQuestConfig[MonkeyQuest.m_strPlayer].m_bMinimized == true) then
MonkeyQuestMinimizeButton:SetNormalTexture("Interface\\AddOns\\MonkeyLibrary\\Textures\\MinimizeButton-Down");
else
MonkeyQuestMinimizeButton:SetNormalTexture("Interface\\AddOns\\MonkeyLibrary\\Textures\\MinimizeButton-Up");
end
MonkeyQuest_Refresh();
end
function MonkeyQuestMinimizeButton_OnEnter()
-- no noob tip?
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -