Merge ilithyia-addons fork (v0.8.8e)
- Russian localization (by Maus) - FishingSchools: track fishing pools, Gatherer integration - FishingOutfitter: Outfitter addon integration - Interface 11200 (patch 1.12 support) - Improved options system with dependencies - Better watcher frame positioning - Various bugfixes Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
+210
-163
@@ -7,121 +7,113 @@ local WATCHDRAGGER_SHOW_DELAY = 0.2;
|
||||
|
||||
local WATCHDRAGGER_FADE_TIME = 0.15;
|
||||
|
||||
local DRAGFRAME_TEXTURES = {
|
||||
"Background",
|
||||
"TopLeft",
|
||||
"TopRight",
|
||||
"BottomLeft",
|
||||
"BottomRight",
|
||||
"Top",
|
||||
"Bottom",
|
||||
"Left",
|
||||
"Right"
|
||||
};
|
||||
local function PlaceDraggerFrame()
|
||||
local where = FishingBuddy.GetSetting("WatcherLocation");
|
||||
if ( not where ) then
|
||||
where = {};
|
||||
where.x = 0;
|
||||
where.y = -384;
|
||||
end
|
||||
FishingWatchDrag:ClearAllPoints();
|
||||
FishingWatchDrag:SetPoint("TOPLEFT", "UIParent", "TOPLEFT",
|
||||
where.x, where.y);
|
||||
end
|
||||
|
||||
local function ShowDraggerFrame()
|
||||
if ( not FishingWatchDragFrame:IsVisible() ) then
|
||||
if ( not FishingWatchDrag:IsVisible() ) then
|
||||
FishingWatchFrame:Show();
|
||||
local width = FishingWatchFrame:GetWidth();
|
||||
local height = FishingWatchFrame:GetHeight();
|
||||
FishingWatchDragFrame:SetHeight(height);
|
||||
FishingWatchDragFrame:SetWidth(width);
|
||||
FishingWatchDragFrame:Show();
|
||||
for index, value in DRAGFRAME_TEXTURES do
|
||||
UIFrameFadeIn(getglobal("FishingWatchDragFrame"..value), WATCHDRAGGER_FADE_TIME, 0, 0.25);
|
||||
end
|
||||
FishingWatchDrag:SetHeight(height);
|
||||
FishingWatchDrag:SetWidth(width);
|
||||
FishingWatchTab:SetText(FishingBuddy.NAME);
|
||||
PanelTemplates_TabResize(10, FishingWatchTab);
|
||||
FishingWatchDrag:Show();
|
||||
FishingWatchTab:Show();
|
||||
UIFrameFadeIn(FishingWatchDrag, WATCHDRAGGER_FADE_TIME, 0, 0.15);
|
||||
UIFrameFadeIn(FishingWatchTab, WATCHDRAGGER_FADE_TIME, 0, 1.0);
|
||||
GameTooltip_AddNewbieTip(FishingBuddy.NAME, 1.0, 1.0, 1.0,
|
||||
FishingBuddy.WATCHERCLICKHELP, 1);
|
||||
end
|
||||
end
|
||||
|
||||
local function HideDraggerFrame()
|
||||
if ( FishingWatchDragFrame:IsVisible() ) then
|
||||
for index, value in DRAGFRAME_TEXTURES do
|
||||
UIFrameFadeOut(getglobal("FishingWatchDragFrame"..value), WATCHDRAGGER_FADE_TIME, 0.25, 0);
|
||||
local function HideDraggerFrame(save)
|
||||
if ( FishingWatchDrag:IsVisible() ) then
|
||||
if ( save ) then
|
||||
FishingWatchFrame:Show();
|
||||
local qx = UIParent:GetLeft()
|
||||
local qy = UIParent:GetTop();
|
||||
local wx = FishingWatchDrag:GetLeft()
|
||||
local wy = FishingWatchDrag:GetTop();
|
||||
local where;
|
||||
if ( wx and wy ) then
|
||||
where = {};
|
||||
where.x = wx - qx;
|
||||
where.y = wy - qy;
|
||||
end
|
||||
FishingBuddy.SetSetting("WatcherLocation", where);
|
||||
end
|
||||
FishingWatchDragFrame:Hide();
|
||||
local qx, qy = UIParent:GetCenter();
|
||||
local wx, wy = FishingWatchDragFrame:GetCenter();
|
||||
local where = {};
|
||||
where.x = qx - wx;
|
||||
where.y = wy - qy;
|
||||
FishingBuddy.SetSetting("WatcherLocation", where);
|
||||
UIFrameFadeOut(FishingWatchDrag, WATCHDRAGGER_FADE_TIME, 0.15, 0);
|
||||
UIFrameFadeOut(FishingWatchTab, WATCHDRAGGER_FADE_TIME, 1.0, 0);
|
||||
FishingWatchDrag:Hide();
|
||||
FishingWatchTab:Hide();
|
||||
GameTooltip:Hide();
|
||||
end
|
||||
end
|
||||
|
||||
local function ResetWatcherFrame(update)
|
||||
FishingWatchTab:Show();
|
||||
FishingWatchDrag:Show();
|
||||
FishingWatchDrag:ClearAllPoints();
|
||||
FishingWatchDrag:SetPoint("CENTER", "UIParent", "CENTER", 0, 0);
|
||||
HideDraggerFrame(true);
|
||||
if ( update ) then
|
||||
FishingBuddy.WatchUpdate();
|
||||
end
|
||||
end
|
||||
|
||||
FishingBuddy.ShowDraggerFrame = ShowDraggerFrame;
|
||||
FishingBuddy.HideDraggerFrame = HideDraggerFrame;
|
||||
FishingBuddy.PlaceDraggerFrame = PlaceDraggerFrame;
|
||||
FishingBuddy.ResetWatcherFrame = ResetWatcherFrame;
|
||||
|
||||
FishingBuddy.Commands[FishingBuddy.WATCHER] = {};
|
||||
FishingBuddy.Commands[FishingBuddy.WATCHER].help = FishingBuddy.WATCHER_HELP;
|
||||
FishingBuddy.Commands[FishingBuddy.WATCHER].func =
|
||||
function(what)
|
||||
if ( what and ( what == FishingBuddy.RESET ) ) then
|
||||
FishingWatchDragFrame:ClearAllPoints();
|
||||
FishingWatchDragFrame:SetPoint("CENTER", "UIParent",
|
||||
"CENTER", 0, 0);
|
||||
FishingWatchDragFrame:Hide();
|
||||
FishingBuddy.SetSetting("WatcherLocation", nil);
|
||||
return true;
|
||||
ResetWatcherFrame(true);
|
||||
return true;
|
||||
end
|
||||
end;
|
||||
|
||||
-- handle really old versions
|
||||
local function UpdateUnknownZones(zone, subzone)
|
||||
if ( FishingBuddy_Info["FishingHoles"][FishingBuddy.UNKNOWN] ) then
|
||||
if ( FishingBuddy_Info["FishingHoles"][FishingBuddy.UNKNOWN][subzone] ) then
|
||||
if ( not FishingBuddy_Info["FishingHoles"][zone] ) then
|
||||
FishingBuddy_Info["FishingHoles"][zone] = { };
|
||||
tinsert(FishingBuddy.SortedZones, zone);
|
||||
table.sort(FishingBuddy.SortedZones);
|
||||
end
|
||||
if ( not FishingBuddy_Info["FishingHoles"][zone][subzone] ) then
|
||||
FishingBuddy_Info["FishingHoles"][zone][subzone] = { };
|
||||
end
|
||||
for k,v in FishingBuddy_Info["FishingHoles"][FishingBuddy.UNKNOWN][subzone] do
|
||||
FishingBuddy_Info["FishingHoles"][zone][subzone][k] = v;
|
||||
end
|
||||
FishingBuddy_Info["FishingHoles"][FishingBuddy.UNKNOWN][subzone] = nil;
|
||||
end
|
||||
FishingBuddy.Locations.DataChanged(zone, subzone);
|
||||
-- Duh, table.getn doesn't work because there aren't any integer
|
||||
-- keys in this table
|
||||
if ( next(FishingBuddy_Info["FishingHoles"][FishingBuddy.UNKNOWN]) == nil ) then
|
||||
FishingBuddy_Info["FishingHoles"][FishingBuddy.UNKNOWN] = nil;
|
||||
local pos;
|
||||
while ( pos < table.getn(FishingBuddy.SortedZones) ) do
|
||||
if ( FishingBuddy.SortedZones[pos] == FishingBuddy.UNKNOWN ) then
|
||||
break;
|
||||
-- fix old data
|
||||
local function UpdateUnknownZone(zone, subzone, zidx, sidx)
|
||||
local uzidx = FishingBuddy.GetZoneIndex(FishingBuddy.UNKNOWN);
|
||||
if ( uzidx ) then
|
||||
local fh = FishingBuddy_Info["FishingHoles"];
|
||||
for usidx in fh[uzidx] do
|
||||
local uszone = FishingBuddy_Info["SubZones"][uzidx][usidx];
|
||||
if ( uszone == subzone ) then
|
||||
for k,v in fh[uzidx][usidx] do
|
||||
if ( fh[zidx][sidx][k] ) then
|
||||
fh[zidx][sidx][k] = fh[zidx][sidx][k] + v;
|
||||
else
|
||||
fh[zidx][sidx][k] = v;
|
||||
end
|
||||
end
|
||||
for k,_ in fh[uzidx][usidx] do
|
||||
fh[uzidx][usidx][k] = nil;
|
||||
end
|
||||
pos = pos + 1;
|
||||
end
|
||||
tremove(FishingBuddy.SortedZones, pos);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- fix a bug where we were recording 'GetZoneText' instead
|
||||
-- of 'GetRealZoneText'
|
||||
local function UpdateRealZones(zone, subzone)
|
||||
local oldzone = GetZoneText();
|
||||
if ( FishingBuddy_Info["FishingHoles"][oldzone] and oldzone ~= zone ) then
|
||||
if ( not FishingBuddy_Info["FishingHoles"][zone] ) then
|
||||
FishingBuddy_Info["FishingHoles"][zone] = { };
|
||||
end
|
||||
for oldsubzone in FishingBuddy_Info["FishingHoles"][oldzone] do
|
||||
local sub = oldsubzone;
|
||||
if ( oldsubzone == oldzone ) then
|
||||
sub = subzone;
|
||||
end
|
||||
if ( not FishingBuddy_Info["FishingHoles"][zone][sub] ) then
|
||||
FishingBuddy_Info["FishingHoles"][zone][sub] = {};
|
||||
end
|
||||
for k,v in FishingBuddy_Info["FishingHoles"][oldzone][oldsubzone] do
|
||||
FishingBuddy_Info["FishingHoles"][zone][sub][k] = v;
|
||||
end
|
||||
end
|
||||
FishingBuddy_Info["FishingHoles"][oldzone] = nil;
|
||||
end
|
||||
end
|
||||
|
||||
-- Fish watcher functions
|
||||
FishingBuddy.WatchUpdate = function()
|
||||
if ( FishingWatchFrame:IsVisible() ) then
|
||||
HideDraggerFrame();
|
||||
FishingWatchFrame:Hide();
|
||||
for i=1, MAX_FISHINGWATCH_LINES, 1 do
|
||||
local line = getglobal("FishingWatchLine"..i);
|
||||
@@ -129,50 +121,60 @@ FishingBuddy.WatchUpdate = function()
|
||||
end
|
||||
end
|
||||
|
||||
local reset = FishingBuddy.GetSetting("ResetWatcher");
|
||||
if ( not reset or reset < 1 ) then
|
||||
ResetWatcherFrame(false);
|
||||
FishingBuddy.SetSetting("ResetWatcher", 1);
|
||||
end
|
||||
|
||||
local zone, subzone = FishingBuddy.GetZoneInfo();
|
||||
local zidx, sidx = FishingBuddy.GetZoneIndex(zone, subzone);
|
||||
|
||||
UpdateUnknownZones(zone, subzone);
|
||||
UpdateRealZones(zone, subzone);
|
||||
UpdateUnknownZone();
|
||||
|
||||
local fz = FishingBuddy_Info["FishingHoles"][zone];
|
||||
if ( FishingBuddy.GetSetting("WatchFishies") == 0 or
|
||||
not fz or not fz[subzone] ) then
|
||||
if ( FishingBuddy.GetSetting("WatchFishies") == 0 ) then
|
||||
return;
|
||||
end
|
||||
|
||||
if ( FishingBuddy.GetSetting("WatchOnlyWhenFishing") == 1 and
|
||||
not FishingBuddy.IsFishingPole() ) then
|
||||
not FishingBuddy.API.IsFishingPole() ) then
|
||||
return;
|
||||
end
|
||||
|
||||
local fz = FishingBuddy_Info["FishingHoles"][zidx];
|
||||
local current = FishingBuddy.currentFishies;
|
||||
local ff = FishingBuddy_Info["Fishies"];
|
||||
local fishsort = {};
|
||||
local totalCount = 0;
|
||||
local totalCurrent = 0;
|
||||
local gotDiffs = false;
|
||||
for fishid in fz[subzone] do
|
||||
local info = {};
|
||||
info.text = ff[fishid].name;
|
||||
info.count = fz[subzone][fishid];
|
||||
totalCount = totalCount + info.count;
|
||||
if ( current[subzone] ) then
|
||||
info.current = current[subzone][fishid] or 0;
|
||||
else
|
||||
info.current = 0;
|
||||
end
|
||||
if ( info.current > 0 and info.current ~= info.count ) then
|
||||
gotDiffs = true;
|
||||
end
|
||||
totalCurrent = totalCurrent + info.current;
|
||||
tinsert(fishsort, info);
|
||||
end
|
||||
|
||||
if ( totalCount == 0 ) then
|
||||
return;
|
||||
end
|
||||
if ( fz and fz[sidx] ) then
|
||||
for fishid in fz[sidx] do
|
||||
local info = {};
|
||||
if ( not FishingBuddy_Info["HiddenFishies"][fishid] ) then
|
||||
info.text = ff[fishid].name;
|
||||
end
|
||||
info.count = fz[sidx][fishid];
|
||||
totalCount = totalCount + info.count;
|
||||
if ( current[sidx] ) then
|
||||
info.current = current[sidx][fishid] or 0;
|
||||
else
|
||||
info.current = 0;
|
||||
end
|
||||
if ( info.current > 0 and info.current ~= info.count ) then
|
||||
gotDiffs = true;
|
||||
end
|
||||
totalCurrent = totalCurrent + info.current;
|
||||
tinsert(fishsort, info);
|
||||
end
|
||||
|
||||
FishingBuddy.FishSort(fishsort);
|
||||
-- if ( totalCount == 0 and totalCurrent == 0 ) then
|
||||
-- return;
|
||||
-- end
|
||||
|
||||
FishingBuddy.FishSort(fishsort);
|
||||
end
|
||||
|
||||
local fishingWatchMaxWidth = 0;
|
||||
local tempWidth;
|
||||
@@ -195,6 +197,7 @@ FishingBuddy.WatchUpdate = function()
|
||||
local entry = getglobal("FishingWatchLine"..index);
|
||||
local skill, mods = FishingBuddy.GetCurrentSkill();
|
||||
local line = "Skill: |cff00ff00"..skill.."+"..mods.."|r";
|
||||
local StartedFishing = FishingBuddy.StartedFishing;
|
||||
if ( StartedFishing ) then
|
||||
local elapsed = GetTime() - StartedFishing;
|
||||
local t = math.floor(elapsed);
|
||||
@@ -231,71 +234,59 @@ FishingBuddy.WatchUpdate = function()
|
||||
if( index <= MAX_FISHINGWATCH_LINES ) then
|
||||
local entry = getglobal("FishingWatchLine"..index);
|
||||
local fishie = info.text;
|
||||
local amount = info.count;
|
||||
local s,e = string.find(fishie, FishingBuddy.RAW.." ");
|
||||
if ( s ) then
|
||||
if ( s > 1 ) then
|
||||
fishie = string.sub(fishie, 1, s-1)..string.sub(fishie, e+1);
|
||||
else
|
||||
fishie = string.sub(fishie, e+1);
|
||||
if ( fishie ) then
|
||||
fishie = FishingBuddy.StripRaw(fishie);
|
||||
local amount = info.count;
|
||||
local fishietext = fishie.." ("..amount;
|
||||
if ( dopercent == 1 ) then
|
||||
local percent = format("%.1f", ( amount / totalCount ) * 100);
|
||||
fishietext = fishietext.." : "..percent.."%";
|
||||
end
|
||||
else
|
||||
s,e = string.find(fishie, " "..FishingBuddy.RAW);
|
||||
if ( s ) then
|
||||
fishie = string.sub(fishie, 1, s-1)..string.sub(fishie, e+1);
|
||||
if ( gotDiffs ) then
|
||||
amount = info.current;
|
||||
local color;
|
||||
fishietext = fishietext..", |c"..FishingBuddy.Colors.GREEN..amount;
|
||||
if ( dopercent == 1 ) then
|
||||
local percent = format("%.1f", ( amount / totalCurrent ) * 100);
|
||||
fishietext = fishietext.." : "..percent.."%";
|
||||
end
|
||||
fishietext = fishietext.."|r";
|
||||
end
|
||||
end
|
||||
local fishietext = fishie.." ("..amount;
|
||||
if ( dopercent == 1 ) then
|
||||
local percent = format("%.1f", ( amount / totalCount ) * 100);
|
||||
fishietext = fishietext.." : "..percent.."%";
|
||||
end
|
||||
if ( gotDiffs ) then
|
||||
amount = info.current;
|
||||
local color;
|
||||
fishietext = fishietext..", |c"..FishingBuddy.Colors.GREEN..amount;
|
||||
if ( dopercent == 1 ) then
|
||||
local percent = format("%.1f", ( amount / totalCurrent ) * 100);
|
||||
fishietext = fishietext.." : "..percent.."%";
|
||||
end
|
||||
fishietext = fishietext.."|r";
|
||||
end
|
||||
fishietext = fishietext..")";
|
||||
entry:SetText(fishietext);
|
||||
tempWidth = entry:GetWidth();
|
||||
entry:Show();
|
||||
if ( tempWidth > fishingWatchMaxWidth ) then
|
||||
fishingWatchMaxWidth = tempWidth;
|
||||
fishietext = fishietext..")";
|
||||
entry:SetText(fishietext);
|
||||
tempWidth = entry:GetWidth();
|
||||
entry:Show();
|
||||
if ( tempWidth > fishingWatchMaxWidth ) then
|
||||
fishingWatchMaxWidth = tempWidth;
|
||||
end
|
||||
index = index + 1;
|
||||
end
|
||||
end
|
||||
index = index + 1;
|
||||
end
|
||||
|
||||
FishingWatchFrame:SetHeight(index * 13);
|
||||
FishingWatchFrame:SetHeight((index - 1) * 13);
|
||||
FishingWatchFrame:SetWidth(fishingWatchMaxWidth + 10);
|
||||
ShowDraggerFrame();
|
||||
PlaceDraggerFrame();
|
||||
FishingWatchFrame:Show();
|
||||
end
|
||||
|
||||
FishingBuddy.WatchFrame.OnLoad = function()
|
||||
local where = FishingBuddy.GetSetting("WatcherLocation");
|
||||
if ( not where ) then
|
||||
where = {};
|
||||
where.x = 0;
|
||||
where.y = 0;
|
||||
end
|
||||
FishingWatchDragFrame:ClearAllPoints();
|
||||
FishingWatchDragFrame:SetPoint("CENTER", "UIParent", "CENTER",
|
||||
where.x, where.y);
|
||||
FishingWatchDragFrame:Hide();
|
||||
|
||||
this:ClearAllPoints();
|
||||
this:SetPoint("TOPRIGHT", "FishingWatchDragFrame", "TOPRIGHT", 0, 0);
|
||||
this:SetPoint("TOPLEFT", "FishingWatchDrag", "TOPLEFT", 0, 0);
|
||||
|
||||
-- Make everything draw at least once
|
||||
FishingWatchDrag:Show();
|
||||
FishingWatchTab:Show();
|
||||
FishingWatchDrag:Hide();
|
||||
FishingWatchTab:Hide();
|
||||
end
|
||||
|
||||
local hover;
|
||||
FishingBuddy.WatchFrame.OnUpdate = function(elapsed)
|
||||
if ( FishingWatchFrame:IsVisible() ) then
|
||||
if ( MouseIsOver(FishingWatchFrame) ) then
|
||||
if ( MouseIsOver(FishingWatchFrame) or
|
||||
( FishingWatchTab:IsVisible() and MouseIsOver(FishingWatchTab) ) ) then
|
||||
local xPos, yPos = GetCursorPosition();
|
||||
if ( hover ) then
|
||||
if ( hover.xPos == xPos and hover.yPos == yPos ) then
|
||||
@@ -315,12 +306,68 @@ FishingBuddy.WatchFrame.OnUpdate = function(elapsed)
|
||||
ShowDraggerFrame();
|
||||
end
|
||||
else
|
||||
HideDraggerFrame();
|
||||
HideDraggerFrame(true);
|
||||
hover = nil;
|
||||
end
|
||||
elseif ( hover ) then
|
||||
HideDraggerFrame();
|
||||
HideDraggerFrame(true);
|
||||
hover = nil;
|
||||
end
|
||||
end
|
||||
|
||||
FishingBuddy.WatchFrame.OnMouseDown = function()
|
||||
if ( arg1 == "LeftButton" ) then
|
||||
FishingWatchDrag:StartMoving();
|
||||
end
|
||||
end
|
||||
|
||||
FishingBuddy.WatchFrame.OnMouseUp = function()
|
||||
if ( arg1 == "LeftButton" ) then
|
||||
FishingWatchDrag:StopMovingOrSizing();
|
||||
end
|
||||
end
|
||||
|
||||
local function HiddenFishToggle(id)
|
||||
if ( FishingBuddy_Info["HiddenFishies"][id] ) then
|
||||
FishingBuddy_Info["HiddenFishies"][id] = nil;
|
||||
else
|
||||
FishingBuddy_Info["HiddenFishies"][id] = true;
|
||||
end;
|
||||
FishingBuddy.WatchUpdate();
|
||||
end
|
||||
|
||||
-- save some memory by keeping one copy of each one
|
||||
local WatcherToggleFunctions = {};
|
||||
-- let's use closures
|
||||
local function WatcherMakeToggle(fishid)
|
||||
if ( not WatcherToggleFunctions[fishid] ) then
|
||||
local id = fishid;
|
||||
WatcherToggleFunctions[fishid] = function() HiddenFishToggle(id); end;
|
||||
end
|
||||
return WatcherToggleFunctions[fishid];
|
||||
end
|
||||
FishingBuddy.WatchFrame.MakeToggle = WatcherMakeToggle;
|
||||
|
||||
local function WatchMenu_Initialize()
|
||||
local zidx, sidx = FishingBuddy.GetZoneIndex();
|
||||
local fz = FishingBuddy_Info["FishingHoles"][zidx];
|
||||
if ( fz and fz[sidx] ) then
|
||||
local ff = FishingBuddy_Info["Fishies"];
|
||||
for fishid in fz[sidx] do
|
||||
info = {};
|
||||
info.text = ff[fishid].name;
|
||||
info.func = WatcherMakeToggle(fishid);
|
||||
info.checked = ( not FishingBuddy_Info["HiddenFishies"][fishid] );
|
||||
info.keepShownOnClick = 1;
|
||||
UIDropDownMenu_AddButton(info);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
FishingBuddy.WatchFrame.OnClick = function()
|
||||
if ( arg1 == "RightButton" ) then
|
||||
local menu = getglobal("FishingBuddyWatcherMenu");
|
||||
UIDropDownMenu_Initialize(menu, WatchMenu_Initialize, "MENU");
|
||||
ToggleDropDownMenu(level, nil, menu, "FishingWatchDrag", 0, 0);
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user