Files
Questie-Octo/Map/MinimapSettings.lua

475 lines
19 KiB
Lua

QuestieOcto.MinimapSettings = QuestieOcto.MinimapSettings or {}
local S = QuestieOcto.MinimapSettings
-- Stable defaults across supplied Questie 5.2.3, 6.0.0, 3.3.5, 7.0.0, 8.0.0.
S.defaults={
-- Questie global map/minimap presentation defaults.
enableMapIcons=true,
-- Continent/world-overview-only master for available quest starts
-- (including item starts) and completed turn-ins. Selected zone/city maps
-- are unaffected; active objective markers remain independently controlled.
showAllQuestsWorldMap=true,
-- Continent/world-overview-only master for special quest markers:
-- repeatable (blue), PvP (red), and verified seasonal/event (green).
-- Selected zone/city maps are unaffected.
showSpecialQuestsWorldMap=false,
enableObjectives=true,
enableTurnins=true,
enableAvailable=true,
-- Keep completed quests on the map/minimap even when their Blizzard quest-log
-- zone header is collapsed. Opt-in, so default map behavior is unchanged.
showCompletedQuests=false,
globalScale=1,
-- Questie 5.2.3/6.0.0 mature old-Questie icon-type defaults.
-- Questie native objective-node presentation.
objectiveNodeDensity="clustered",
-- Item-start quests are visually quest starters, but their source density
-- and map/minimap visibility are independent from ordinary available NPCs.
showItemStartQuests=true,
showItemStartMap=true,
showItemStartMinimap=true,
itemStartDensity="clustered",
enableMiniMapIcons=true,
globalMiniMapScale=1,
alwaysGlowMap=false,
alwaysGlowMinimap=false,
questObjectiveColors=false,
questMinimapObjectiveColors=false,
-- Questie 3.3.5 townsfolk-style service markers. Questie-Octo keeps map
-- and minimap visibility independent so each presentation can be tuned.
showMapRareMonsters=true,
showMapAuctioneer=true,
showMapBanker=true,
showMapFlightMaster=true,
showMapMailbox=true,
-- Additional pfQuest service/utility tracking categories are opt-in. Keeping
-- them disabled by default preserves Questie-Octo's lightweight baseline.
showMapBattlemaster=false,
showMapInnkeeper=false,
showMapMeetingStone=false,
showMapRepair=false,
showMapSpiritHealer=false,
showMapStableMaster=false,
showMapVendor=false,
-- Class/profession trainers (map only). Opt-in, using the ringed atlas icons.
showMapClassTrainer=false,
showMapProfessionTrainer=false,
showMinimapRareMonsters=true,
showMinimapAuctioneer=true,
showMinimapBanker=true,
showMinimapFlightMaster=true,
showMinimapMailbox=true,
showMinimapBattlemaster=false,
showMinimapInnkeeper=false,
showMinimapMeetingStone=false,
showMinimapRepair=false,
showMinimapSpiritHealer=false,
showMinimapStableMaster=false,
showMinimapVendor=false,
showMinimapClassTrainer=false,
showMinimapProfessionTrainer=false,
showLowLevelQuests=true,
-- Maximum number of displayed quest levels below the player to expose when
-- Show Low-Level Quests is enabled. 35 is the UI's "All" sentinel; the
-- visible slider stops are 5/10/15/20/25/30/All.
lowLevelQuestRange=35,
showEventQuests=false,
showRepeatableQuests=true,
showPvPRelatedQuests=true,
enableTooltips=true,
enableTooltipsQuestLevel=true,
enableTooltipsQuestID=false,
enableTooltipsNPCID=false,
enableTooltipsItemID=false,
enableTooltipDroprates=true,
-- Quest Log presentation. Questie provides the interaction semantics; the
-- 1.12 title-button presentation follows the supplied pfQuest compatibility
-- pattern where old Questie has no equivalent visual layer.
questLogShowLevels=true,
questLogDifficultyColors=true,
-- Quest objective arrow and route are opt-in.
showQuestArrow=false,
showQuestRoute=false,
-- Options-frame dark theme is off by default so the config window opens with
-- native Blizzard colors until the player opts in.
useDarkTheme=false,
-- Questie 3.3.5 tracker driver defaults. Rendering is a separate layer.
trackerEnabled=true,
trackerLocked=true,
trackerAutoTrack=true,
trackerShowCompleted=true,
trackerHideCompletedObjectives=false,
trackerSort="zone",
-- Temporary tracker font-flag comparison options. Keep both off by default
-- so existing profiles retain the historical Questie-Octo presentation.
-- They are mutually exclusive when changed through Set().
trackerOutlineText=false,
trackerThickOutlineText=false,
trackerFontSize=11,
trackerMaxWidth=280,
trackerVisibleRows=30,
trackerBackgroundOpacity=0,
trackerHideInCombat=false
}
local function Clamp(value,minValue,maxValue)
value=tonumber(value)
if not value then return nil end
if value<minValue then value=minValue end
if value>maxValue then value=maxValue end
return value
end
local function IsCharacterOption(key)
return key=="showLowLevelQuests" or key=="lowLevelQuestRange" or key=="showEventQuests" or key=="showRepeatableQuests" or key=="showPvPRelatedQuests"
end
-- Vanilla/Turtle can restore SavedVariables after addon files have executed.
-- Never trust an early cached table reference: rebind to the currently loaded
-- SavedVariables tables before every read/write operation.
local function SavedVariableBindingsChanged(self)
if not QuestieOctoGlobalDB or not QuestieOctoGlobalDB.minimap then return true end
if not QuestieOctoDB or not QuestieOctoDB.options then return true end
return self.db~=QuestieOctoGlobalDB.minimap or self.charDB~=QuestieOctoDB.options
end
function S:Initialize()
QuestieOctoGlobalDB=QuestieOctoGlobalDB or {}
QuestieOctoGlobalDB.minimap=QuestieOctoGlobalDB.minimap or {}
QuestieOctoDB=QuestieOctoDB or {}
QuestieOctoDB.options=QuestieOctoDB.options or {}
local db=QuestieOctoGlobalDB.minimap
local charDB=QuestieOctoDB.options
-- Discard obsolete presentation choices rather than leaving hidden stale
-- settings in SavedVariables.
db.databaseLocale=nil
db.enableTooltipsObjectID=nil
-- 1.0.31 replaces the experimental Thicker Text toggle with explicit WoW
-- OUTLINE / THICKOUTLINE comparison toggles. Ignore the old saved value.
db.trackerThickerText=nil
-- 0.3.3: per-category size sliders were removed. Questie-Octo now has one
-- World Map scale and one Minimap scale; discard hidden stale multipliers.
local obsoleteScales={"availableScale","monsterScale","objectScale","lootScale","itemStartScale",
"rareMonsterScale","auctioneerScale","bankerScale","flightMasterScale","mailboxScale"}
for _,key in pairs(obsoleteScales) do db[key]=nil end
for key,value in pairs(self.defaults) do
if IsCharacterOption(key) then
if charDB[key]==nil then
-- Migrate 0.1.44's global value once if present.
if db[key]~=nil then charDB[key]=db[key] else charDB[key]=value end
end
elseif db[key]==nil then
db[key]=value
end
end
-- 1.0.38: 30 used to be the hidden "All" sentinel. The slider now exposes
-- a literal 30-level choice and uses 35 internally for "All". Migrate the
-- old saved sentinel once so updating players keep the same unrestricted
-- behavior instead of unexpectedly receiving a 30-level cutoff.
if not charDB.lowLevelQuestRangeAll35Migrated then
if tonumber(charDB.lowLevelQuestRange)==30 then charDB.lowLevelQuestRange=35 end
charDB.lowLevelQuestRangeAll35Migrated=true
end
-- Requested 0.1.45 defaults. Migrate only exact previous defaults.
if not db.mapScaleDefault1Migrated then
if tonumber(db.globalScale)==0.7 then db.globalScale=1 end
db.mapScaleDefault1Migrated=true
end
-- 0.2.46: OctoWoW baseline uses 1.0 for minimap and item-start scale.
-- Migrate only the exact former default so deliberate player values survive.
if not db.miniMapScaleDefault1Migrated then
if tonumber(db.globalMiniMapScale)==0.7 then db.globalMiniMapScale=1 end
db.miniMapScaleDefault1Migrated=true
end
-- 1.1: map objective glow is now opt-in. Migrate the former default ON
-- once so existing profiles receive the new baseline; players can re-enable
-- the option afterwards if they prefer the glow.
if not db.mapIconGlowDefaultOffMigrated then
if db.alwaysGlowMap==true then db.alwaysGlowMap=false end
db.mapIconGlowDefaultOffMigrated=true
end
self.db=db
self.charDB=charDB
end
function S:Get(key)
if not self.db or SavedVariableBindingsChanged(self) then self:Initialize() end
local value
if IsCharacterOption(key) then
value=self.charDB[key]
else
value=self.db[key]
end
if value==nil then return self.defaults[key] end
return value
end
function S:Set(key,value)
if not self.db or SavedVariableBindingsChanged(self) then self:Initialize() end
if key=="enableMapIcons" or key=="showAllQuestsWorldMap" or key=="showSpecialQuestsWorldMap" or key=="enableObjectives" or key=="enableTurnins" or
key=="enableAvailable" or key=="enableMiniMapIcons" or key=="showCompletedQuests" or
key=="alwaysGlowMap" or key=="alwaysGlowMinimap" or
key=="questObjectiveColors" or key=="questMinimapObjectiveColors" or
key=="showLowLevelQuests" or key=="showEventQuests" or key=="showRepeatableQuests" or key=="showPvPRelatedQuests" or
key=="showItemStartQuests" or key=="showItemStartMap" or key=="showItemStartMinimap" or
key=="showMapRareMonsters" or key=="showMapAuctioneer" or key=="showMapBanker" or
key=="showMapFlightMaster" or key=="showMapMailbox" or
key=="showMapBattlemaster" or key=="showMapInnkeeper" or key=="showMapMeetingStone" or
key=="showMapRepair" or key=="showMapSpiritHealer" or key=="showMapStableMaster" or key=="showMapVendor" or
key=="showMapClassTrainer" or key=="showMapProfessionTrainer" or
key=="showMinimapRareMonsters" or key=="showMinimapAuctioneer" or key=="showMinimapBanker" or
key=="showMinimapFlightMaster" or key=="showMinimapMailbox" or
key=="showMinimapBattlemaster" or key=="showMinimapInnkeeper" or key=="showMinimapMeetingStone" or
key=="showMinimapRepair" or key=="showMinimapSpiritHealer" or key=="showMinimapStableMaster" or key=="showMinimapVendor" or
key=="showMinimapClassTrainer" or key=="showMinimapProfessionTrainer" or
key=="enableTooltips" or
key=="enableTooltipsQuestLevel" or key=="enableTooltipsQuestID" or
key=="enableTooltipsNPCID" or key=="enableTooltipsItemID" or
key=="enableTooltipDroprates" or
key=="questLogShowLevels" or key=="questLogDifficultyColors" or
key=="showQuestArrow" or key=="showQuestRoute" or
key=="useDarkTheme" or
key=="trackerEnabled" or key=="trackerLocked" or key=="trackerAutoTrack" or
key=="trackerShowCompleted" or key=="trackerHideCompletedObjectives" or key=="trackerHideInCombat" or
key=="trackerOutlineText" or key=="trackerThickOutlineText" then
value=value and true or false
elseif key=="lowLevelQuestRange" then
value=tonumber(value)
if value~=5 and value~=10 and value~=15 and value~=20 and value~=25 and value~=30 and value~=35 then return false end
elseif key=="globalScale" then
value=Clamp(value,0.01,4)
elseif key=="objectiveNodeDensity" or key=="itemStartDensity" then
if value~="clustered" and value~="full" then return false end
elseif key=="globalMiniMapScale" then
value=Clamp(value,0.01,4)
elseif key=="trackerSort" then
if value~="zone" and value~="level" and value~="proximity" then return false end
elseif key=="trackerFontSize" then
value=Clamp(value,8,18)
elseif key=="trackerMaxWidth" then
value=Clamp(value,200,500)
if value then value=math.floor(value+0.5) end
elseif key=="trackerVisibleRows" then
value=Clamp(value,6,60)
if value then value=math.floor(value+0.5) end
elseif key=="trackerBackgroundOpacity" then
value=Clamp(value,0,1)
else
return false
end
if value==nil then return false end
-- OUTLINE and THICKOUTLINE are comparison modes, not cumulative effects.
-- Keep them mutually exclusive even if a caller changes settings outside
-- the AceConfig UI.
if value==true and key=="trackerOutlineText" then
self.db.trackerThickOutlineText=false
elseif value==true and key=="trackerThickOutlineText" then
self.db.trackerOutlineText=false
end
if IsCharacterOption(key) then
self.charDB[key]=value
else
self.db[key]=value
end
if string.find(key,"^questLog") then
-- Run Blizzard's normal QuestLog_Update first so disabling difficulty
-- coloring restores the native text color before Questie reapplies its
-- optional presentation layer.
if QuestLogFrame and QuestLogFrame:IsShown() and QuestLog_Update then
QuestLog_Update()
elseif QuestieOcto.QuestLogEnhancements and QuestieOcto.QuestLogEnhancements.Refresh then
QuestieOcto.QuestLogEnhancements:Refresh()
end
return true
end
if string.find(key,"^tracker") then
if QuestieOcto.TrackerDriver and QuestieOcto.TrackerDriver.OnSettingChanged then
QuestieOcto.TrackerDriver:OnSettingChanged(key,value)
end
return true
end
-- The options-frame dark theme only recolors the config window (Options.lua
-- reacts to it directly). It has no map/minimap consumers, so persist it and
-- stop before the icon-refresh fall-through below.
if key=="useDarkTheme" then
return true
end
-- The quest arrow and route read their setting live each frame; just persist.
if key=="showQuestArrow" or key=="showQuestRoute" then
return true
end
-- Rescan the quest log so completed quests in collapsed zones are added to
-- (or removed from) the active set, which cascades to the map and minimap.
if key=="showCompletedQuests" then
if QuestieOcto.QuestLog and QuestieOcto.QuestLog.Schedule then
QuestieOcto.QuestLog:Schedule(0.01,true)
end
return true
end
if key=="showLowLevelQuests" or key=="lowLevelQuestRange" or key=="showEventQuests" or key=="showRepeatableQuests" or key=="showPvPRelatedQuests" then
if QuestieOcto.AvailableQuests and QuestieOcto.AvailableQuests.FastRefresh then
QuestieOcto.AvailableQuests:FastRefresh()
end
-- PvP visibility applies to every PvP map/minimap marker, including
-- accepted objectives and completed turn-ins. Refresh the renderers
-- immediately while the available-quest service rebuilds in parallel.
if key=="showPvPRelatedQuests" then
if QuestieOcto.Map and QuestieOcto.Map.OnSettingChanged then
QuestieOcto.Map:OnSettingChanged(key,value)
end
if QuestieOcto.Minimap and QuestieOcto.Minimap.OnSettingChanged then
QuestieOcto.Minimap:OnSettingChanged(key,value)
end
end
return true
end
-- Questie 11's advanced clustering option explicitly treats zero
-- separation as "show all icons". Our two-state UI exposes that mature
-- behavior as Clustered / Full Nodes while keeping PreparedMap shared by
-- world map and minimap.
if key=="objectiveNodeDensity" or key=="itemStartDensity" then
if QuestieOcto.PreparedMap and QuestieOcto.PreparedMap.PrepareAll and
QuestieOcto.Nodes and QuestieOcto.Nodes.ready then
QuestieOcto.PreparedMap:PrepareAll("density:"..tostring(key))
end
return true
end
-- Questie 3.3.5 mature scale ordering:
-- save the option first, then route every scale through the single
-- QuestieMap:RescaleIcons-style path so world map + minimap are refreshed
-- from the same current semantic icon data.
if key=="globalScale" then
if QuestieOcto.Map and QuestieOcto.Map.RescaleIcons then QuestieOcto.Map:RescaleIcons(key,value) end
return true
end
if key=="globalMiniMapScale" then
if QuestieOcto.Minimap and QuestieOcto.Minimap.RescaleIcons then QuestieOcto.Minimap:RescaleIcons(key,value) end
return true
end
if key=="showItemStartQuests" or key=="showItemStartMap" or
key=="showItemStartMinimap" then
if QuestieOcto.Map and QuestieOcto.Map.OnSettingChanged then
QuestieOcto.Map:OnSettingChanged(key,value)
end
if QuestieOcto.Minimap and QuestieOcto.Minimap.OnSettingChanged then
QuestieOcto.Minimap:OnSettingChanged(key,value)
end
return true
end
if key=="showMapRareMonsters" or key=="showMapAuctioneer" or key=="showMapBanker" or
key=="showMapFlightMaster" or key=="showMapMailbox" or
key=="showMapBattlemaster" or key=="showMapInnkeeper" or key=="showMapMeetingStone" or
key=="showMapRepair" or key=="showMapSpiritHealer" or key=="showMapStableMaster" or key=="showMapVendor" or
key=="showMapClassTrainer" or key=="showMapProfessionTrainer" then
-- The additional pfQuest service categories are not materialized while
-- disabled on both map surfaces. Rebuild transactionally when one changes
-- so opt-in categories have no default startup/node cost.
if string.find(key,"Battlemaster") or string.find(key,"Innkeeper") or string.find(key,"MeetingStone") or
string.find(key,"Repair") or string.find(key,"SpiritHealer") or string.find(key,"StableMaster") or
string.find(key,"Vendor") or string.find(key,"ClassTrainer") or string.find(key,"ProfessionTrainer") then
if QuestieOcto.Nodes and QuestieOcto.Nodes.Rebuild then QuestieOcto.Nodes:Rebuild() end
end
if QuestieOcto.Map and QuestieOcto.Map.OnSettingChanged then
QuestieOcto.Map:OnSettingChanged(key,value)
end
return true
end
if key=="showMinimapRareMonsters" or key=="showMinimapAuctioneer" or key=="showMinimapBanker" or
key=="showMinimapFlightMaster" or key=="showMinimapMailbox" or
key=="showMinimapBattlemaster" or key=="showMinimapInnkeeper" or key=="showMinimapMeetingStone" or
key=="showMinimapRepair" or key=="showMinimapSpiritHealer" or key=="showMinimapStableMaster" or key=="showMinimapVendor" or
key=="showMinimapClassTrainer" or key=="showMinimapProfessionTrainer" then
if string.find(key,"Battlemaster") or string.find(key,"Innkeeper") or string.find(key,"MeetingStone") or
string.find(key,"Repair") or string.find(key,"SpiritHealer") or string.find(key,"StableMaster") or
string.find(key,"Vendor") or string.find(key,"ClassTrainer") or string.find(key,"ProfessionTrainer") then
if QuestieOcto.Nodes and QuestieOcto.Nodes.Rebuild then QuestieOcto.Nodes:Rebuild() end
end
if QuestieOcto.Minimap and QuestieOcto.Minimap.OnSettingChanged then
QuestieOcto.Minimap:OnSettingChanged(key,value)
end
return true
end
if key=="alwaysGlowMap" or key=="alwaysGlowMinimap" or
key=="questObjectiveColors" or key=="questMinimapObjectiveColors" then
if QuestieOcto.Map and QuestieOcto.Map.RefreshVisualSettings then
QuestieOcto.Map:RefreshVisualSettings()
end
return true
end
if QuestieOcto.Minimap and QuestieOcto.Minimap.OnSettingChanged then
QuestieOcto.Minimap:OnSettingChanged(key,value)
end
if QuestieOcto.Map and QuestieOcto.Map.OnSettingChanged then
QuestieOcto.Map:OnSettingChanged(key,value)
end
return true
end
function S:Reset()
if not self.db or SavedVariableBindingsChanged(self) then self:Initialize() end
for key,value in pairs(self.defaults) do
if IsCharacterOption(key) then
self.charDB[key]=value
else
self.db[key]=value
end
end
if QuestieOcto.Minimap and QuestieOcto.Minimap.ApplySettings then
QuestieOcto.Minimap:ApplySettings()
end
if QuestieOcto.Map and QuestieOcto.Map.ApplySettings then
QuestieOcto.Map:ApplySettings()
end
if QuestieOcto.Map and QuestieOcto.Map.RescaleIcons then
QuestieOcto.Map:RescaleIcons()
end
if QuestieOcto.AvailableQuests and QuestieOcto.AvailableQuests.FastRefresh then
QuestieOcto.AvailableQuests:FastRefresh()
end
end
S:Initialize()