📄 felwoodgather.lua
字号:
--[[
FelwoodGather
Timer manager for felwood fruit gathering.
Author: nor3
]]--
-- constant definition
FELWOODGATHER_VERSION="0.80c";
FELWOODGATHER_TIMER = 1500;
FELWOODGATHER_TIMER_WARN1 = 300;
FELWOODGATHER_TIMER_WARN2 = 60;
FELWOODGATHER_CHECK_INTERVAL=3.0;
FELWOODGATHER_NOTIFY="TellMessage";
FWG_BROADCAST_HEADER="<FWGBRDCST>";
FELWOODGATHER_ACTIVE = false;
FelwoodGather_WorldMapDetailFrameWidth = 0;
FelwoodGather_WorldMapDetailFrameHeight = 0;
FelwoodGather_Config = {
notify=true,
warn1=FELWOODGATHER_TIMER_WARN1,
warn2=FELWOODGATHER_TIMER_WARN2,
acceptTimer= true,
alpha=0.8,
scale=10,
countdown=5
};
FelwoodGather_DebugMode=false;
--[[
FelwoodGather_Details = {
name = FELWOODGATHER_FELWOODGATHER,
version = FELWOODGATHER_VERSION,
author = "nor3",
email = "norf@asuraguild.org",
website = "http://asuraguild.org/nor3/archives/AddOn/FelwoodGather/",
category = MYADDONS_CATEGORY_MAP
};
]]--
FelwoodGather_Help = {};
FelwoodGather_Help[1] = FELWOODGATHER_HELPMSG1;
FelwoodGather_Help[2] = FELWOODGATHER_HELPMSG2;
FelwoodGather_Help[3] = FELWOODGATHER_HELPMSG3;
FelwoodGather_Help[4] = FELWOODGATHER_HELPMSG4;
FelwoodGather_Help[5] = FELWOODGATHER_HELPMSG5;
-- Object Infomation
FelwoodGather_WorldObjs = {
[1] = {x = 49, y = 12, timer = 0, status = 0,
item = FWG_WHIPPER_ROOT_TUBER,
location = FWG_NORTH_FELWOOD,
texture = FWG_WRT_TEXTURE
},
[2] = {x = 42, y = 13, timer = 0, status = 0,
item = FWG_NIGHT_DRAGON_BREATH,
location = FWG_JADEFIRE_RUN,
texture = FWG_NDB_TEXTURE
},
[3] = {x = 40, y = 19, timer = 0, status = 0,
item = FWG_WHIPPER_ROOT_TUBER,
location = FWG_JADEFIRE_RUN,
texture = FWG_WRT_TEXTURE
},
[4] = {x = 50, y = 18, timer = 0, status = 0,
item = FWG_WHIPPER_ROOT_TUBER,
location = FWG_IRONTREE_WOODS,
texture = FWG_WRT_TEXTURE
},
[5] = {x = 50, y = 30, timer = 0, status = 0,
item = FWG_NIGHT_DRAGON_BREATH,
location = FWG_GRAVEYARD,
texture = FWG_NDB_TEXTURE
},
[6] = {x = 43, y = 46, timer = 0, status = 0,
item = FWG_WHIPPER_ROOT_TUBER,
location = FWG_FALLS,
texture = FWG_WRT_TEXTURE
},
[7] = {x = 34, y = 60, timer = 0, status = 0,
item = FWG_WHIPPER_ROOT_TUBER,
location = FWG_JADENAR,
texture = FWG_WRT_TEXTURE
},
[8] = {x = 35, y = 58, timer = 0, status = 0,
item = FWG_NIGHT_DRAGON_BREATH,
location = FWG_JADENAR,
texture = FWG_NDB_TEXTURE
},
[9] = {x = 40, y = 78, timer = 0, status = 0,
item = FWG_NIGHT_DRAGON_BREATH,
location = FWG_JADEFIRE_GLEN,
texture = FWG_NDB_TEXTURE
},
[10] = { x = 40, y = 85, timer = 0, status = 0,
item = FWG_WHIPPER_ROOT_TUBER,
location = FWG_JADEFIRE_GLEN,
texture = FWG_WRT_TEXTURE
},
[11] = { x = 55, y = 6, timer = 0, status = 0,
item = FWG_WINDBLOSSOM_BERRIES,
location = FWG_NORTH_FELWOOD,
texture = FWG_WBB_TEXTURE
},
[12] = { x = 45, y = 18, timer = 0, status = 0,
item = FWG_WINDBLOSSOM_BERRIES,
location = FWG_JADEFIRE_RUN,
texture = FWG_WBB_TEXTURE
},
[13] = { x = 38, y = 21, timer = 0, status = 0,
item = FWG_WINDBLOSSOM_BERRIES,
location = FWG_JADEFIRE_RUN,
texture = FWG_WBB_TEXTURE
},
[14] = { x = 44, y = 41, timer = 0, status = 0,
item = FWG_WINDBLOSSOM_BERRIES,
location = FWG_SHATTER_SCAR_VALE,
texture = FWG_WBB_TEXTURE
},
[15] = { x = 34, y = 48, timer = 0, status = 0,
item = FWG_WINDBLOSSOM_BERRIES,
location = FWG_RIVER,
texture = FWG_WBB_TEXTURE
},
[16] = { x = 38, y = 59, timer = 0, status = 0,
item = FWG_WINDBLOSSOM_BERRIES,
location = FWG_JADENAR,
texture = FWG_WBB_TEXTURE
},
[17] = { x = 36, y = 61, timer = 0, status = 0,
item = FWG_WINDBLOSSOM_BERRIES,
location = FWG_JADENAR,
texture = FWG_WBB_TEXTURE
},
[18] = { x = 49, y = 79, timer = 0, status = 0,
item = FWG_WINDBLOSSOM_BERRIES,
location = FWG_EMERALD_SANCTUARY,
texture = FWG_WBB_TEXTURE
},
[19] = { x = 55, y = 23, timer = 0, status = 0,
item = FWG_WINDBLOSSOM_BERRIES,
location = FWG_IRONTREE_WOODS,
texture = FWG_WBB_TEXTURE
}
};
FelwoodGather_Latest={};
FelwoodGather_Latest.index = 0;
FelwoodGather_Latest.timer = 0;
FelwoodGather_PickupCount = {};
FelwoodGather_PickupCount.inProgress=false;
FelwoodGather_PickupCount.count = 0;
FelwoodGather_LabelColorPast ={ r=0.7, g=0.7, b=0.7 };
FelwoodGather_LabelColorWarn2 ={ r=1.0, g=0.0, b=0.0 };
FelwoodGather_LabelColorWarn1 ={ r=1.0, g=1.0, b=0.0 };
FelwoodGather_LabelColorNormal ={ r=0.0, g=1.0, b=0.0 };
FelwoodGather_LabelColorHighlight ={ r=1.0, g=1.0, b=1.0 };
FelwoodGather_Continents = {};
FelwoodGather_MapZones = {};
function FelwoodGather_LoadContinents(...)
for i=1, arg.n do
FelwoodGather_Continents[i] = arg[i];
end
end
function FelwoodGather_LoadMapZones(...)
for i=1, arg.n do
FelwoodGather_MapZones[i] = arg[i];
end
end
-- ***************** Handlers **********************
function FelwoodGather_OnLoad()
-- Event Registration
this:RegisterEvent("WORLD_MAP_UPDATE");
this:RegisterEvent("CLOSE_WORLD_MAP");
this:RegisterEvent("ADDON_LOADED");
this:RegisterEvent("VARIABLES_LOADED");
this:RegisterEvent("CHAT_MSG_LOOT");
this:RegisterEvent("ZONE_CHANGED_NEW_AREA");
this:RegisterEvent("CHAT_MSG_RAID");
this:RegisterEvent("CHAT_MSG_PARTY");
-- command registration
SLASH_FELWOODGATHER1="/felwoodgather";
SLASH_FELWOODGATHER2="/fwg";
SlashCmdList["FELWOODGATHER"] = function (msg)
FelwoodGahter_SlashCmd(msg);
end
end
-- Slash Command Handler
function FelwoodGahter_SlashCmd(msg)
msg = string.lower (msg);
if (msg == FWG_SUBCOMMAND_SHARE) then
FelwoodGather_ShareTimer();
elseif (msg == FWG_SUBCOMMAND_CONFIG) then
FelwoodGather_ToggleConfigWindow();
elseif (msg == FWG_SUBCOMMAND_COUNT ) then
FelwoodGather_PickupCountDown(true);
elseif (msg == FWG_SUBCOMMAND_MAP) then
FelwoodGatherMap_ToggleMapWindow();
elseif (msg == FWG_SUBCOMMAND_RESET) then
FelwoodGatherMap_ResetMapPosition();
else
DEFAULT_CHAT_FRAME:AddMessage(FWG_SLASHHELPMSG1);
DEFAULT_CHAT_FRAME:AddMessage(FWG_SLASHHELPMSG2);
DEFAULT_CHAT_FRAME:AddMessage(FWG_SLASHHELPMSG3);
DEFAULT_CHAT_FRAME:AddMessage(FWG_SLASHHELPMSG4);
DEFAULT_CHAT_FRAME:AddMessage(FWG_SLASHHELPMSG5);
DEFAULT_CHAT_FRAME:AddMessage(FWG_SLASHHELPMSG6);
end
end
function FelwoodGather_IsActivate()
if(table.getn(FelwoodGather_Continents) == 0) then
FelwoodGather_Continents = {};
FelwoodGather_MapZones = {};
FelwoodGather_LoadContinents(GetMapContinents());
for n, cont in FelwoodGather_Continents do
if ( cont == FWG_KALIMDOR_MAPNAME ) then
FelwoodGather_LoadMapZones(GetMapZones(n));
end
end
end
if((FelwoodGather_Continents[GetCurrentMapContinent()] == FWG_KALIMDOR_MAPNAME) and (FelwoodGather_MapZones[GetCurrentMapZone()]==FWG_FELWOOD_MAPNAME)) then
return true;
end
return false;
end
-- OnEvent handler for main window
function FelwoodGather_OnEvent(event)
if (strfind(event, "CHAT_MSG_LOOT")) then
FelwoodGather_CheckAndStart(arg1);
elseif (event == "WORLD_MAP_UPDATE") then
FELWOODGATHER_ACTIVE = FelwoodGather_IsActivate();
if ( FELWOODGATHER_ACTIVE ) then
FelwoodGather_WorldMapDetailFrameWidth = WorldMapDetailFrame:GetWidth();
FelwoodGather_WorldMapDetailFrameHeight = WorldMapDetailFrame:GetHeight();
FelwoodMapOverlayFrame:Show();
FelwoodGather_MainDraw();
else
FelwoodGather_HideAll();
end
elseif ( event == "CLOSE_WORLD_MAP") then
FelwoodMapOverlayFrame:Hide();
FelwoodGather_MainDraw();
elseif( event == "ADDON_LOADED") then
if( arg1 == FELWOODGATHER_FELWOODGATHER ) then
-- myAddOns support
-- if ( myAddOnsFrame_Register ) then
-- myAddOnsFrame_Register(FelwoodGather_Details, FelwoodGather_Help);
-- end
-- store MapWindow size
FelwoodGather_WorldMapDetailFrameWidth = WorldMapDetailFrame:GetWidth();
FelwoodGather_WorldMapDetailFrameHeight = WorldMapDetailFrame:GetHeight();
--FelwoodGather_Print("FelwoodGather by nor3 ver."..FELWOODGATHER_VERSION.." loaded.");
end
elseif (event == "VARIABLES_LOADED") then
local playerName = UnitName("player");
UIDropDownMenu_Initialize(FelwoodMainMenu, FelwoodMainMenu_Initialize, "MENU");
-- TODO make charscter depends settings.
if ((playerName) and (playerName ~= UNKNOWNOBJECT)) then
-- TODO
if( FelwoodGather_Config.notify == nil ) then
FelwoodGather_Config.notify = true;
end
if( FelwoodGather_Config.warn1 == nil ) then
FelwoodGather_Config.warn1 = FELWOODGATHER_TIMER_WARN1;
end
if( FelwoodGather_Config.warn2 == nil ) then
FelwoodGather_Config.warn2 = FELWOODGATHER_TIMER_WARN2;
end
if( FelwoodGather_Config.acceptTimer == nil ) then
FelwoodGather_Config.acceptTimer = true;
end
if( FelwoodGather_Config.alpha == nil ) then
FelwoodGather_Config.alpha = 0.7;
end
if( FelwoodGather_Config.scale == nil ) then
FelwoodGather_Config.scale = 12;
end
if( FelwoodGather_Config.countdown == nil ) then
FelwoodGather_Config.countdown = 5;
end
FelGlimReg();
end
FelwoodGather_Options_Init();
elseif ( event == "ZONE_CHANGED_NEW_AREA" ) then
--[[
local curZone = GetRealZoneText();
if( (curZone ~= nil) and curZone == FWG_FELWOOD_MAPNAME) then
FELWOODGATHER_ACTIVE=true;
FelwoodMapOverlayFrame:Show();
FelwoodGather_MainDraw();
else
FELWOODGATHER_ACTIVE=false;
FelwoodMapOverlayFrame:Hide();
FelwoodGather_HideAll();
end
]]--
elseif( event == "CHAT_MSG_RAID") then
if (not FELWOODGATHER_ACTIVE) then
return;
end
if (strsub(arg1, 1, string.len(FWG_BROADCAST_HEADER)) == FWG_BROADCAST_HEADER) then
FelwoodGather_ParseMessage(arg1);
end
elseif( event == "CHAT_MSG_PARTY") then
if (not FELWOODGATHER_ACTIVE) then
return;
end
if (strsub(arg1, 1, string.len(FWG_BROADCAST_HEADER)) == FWG_BROADCAST_HEADER) then
FelwoodGather_ParseMessage(arg1);
end
else
FelwoodGather_Print("Unknown event: "..event);
end
end
function FelGlimReg()
gLim_RegisterButton (
"FelwoodGather",
FELWOODGATHER_OPTIONS,
"Interface\\AddOns\\FelwoodGather\\Icon",
function()
gLimModSecBookShowConfig("gLimFelwoodGather");
end,
4,
10
);
gLim_RegisterConfigClass(
"gLimFelwoodGather",
"FelwoodGather",
"黑眼圈"
);
gLim_RegisterConfigSection(
"gLim_FelwoodGather_Section",
FELWOODGATHER_OPTIONS,
FELWOODGATHER_HELPMSG2,
nil,
"gLimFelwoodGather"
);
gLim_RegisterConfigButton(
"gLim_QuickEquip_ToggleConfigWindow",
"详细设置",
"设置费伍德水果助手",
"设置",
function ()
FelwoodGather_ToggleConfigWindow();
gLimConfigSubFrame:Hide();
end,
"gLimFelwoodGather"
);
gLim_RegisterConfigButton(
"gLim_QuickEquip_ToggleMapWindow",
"打开小地图",
"打开费伍德水果分布小地图",
"打开小地图",
FelwoodGatherMap_ToggleMapWindow,
"gLimFelwoodGather"
);
end
-- map update handler (seems main window not updated while map window open.)
function FelwoodGather_MapUpdate(elapsed)
if (not FelwoodGather_UpdateMapTimer ) then
FelwoodGather_UpdateMapTimer = 0;
else
FelwoodGather_UpdateMapTimer = FelwoodGather_UpdateMapTimer + elapsed;
if (FelwoodGather_UpdateMapTimer > FELWOODGATHER_CHECK_INTERVAL) then
FelwoodGather_UpdateMapTimer = 0;
FelwoodGather_MainDraw();
end
end
end
-- timer update handler
function FelwoodGather_TimeCheck(elapsed)
-- if ((not FELWOODGATHER_ACTIVE) or (not FelwoodGather_Config.notify)) then
-- return;
-- end
if (not FelwoodGather_UpdateTimer) then
FelwoodGather_UpdateTimer = 0;
else
FelwoodGather_UpdateTimer = FelwoodGather_UpdateTimer + elapsed;
if (FelwoodGather_UpdateTimer > FELWOODGATHER_CHECK_INTERVAL) then
FelwoodGather_UpdateTimer = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -