Skip to content

Commit

Permalink
More storage development
Browse files Browse the repository at this point in the history
  • Loading branch information
Tercioo committed Jul 11, 2024
1 parent 74d8ba5 commit 0531ed0
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 40 deletions.
6 changes: 4 additions & 2 deletions boot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,10 @@
---@type details_storage_feature
---@diagnostic disable-next-line: missing-fields
local storage = {
DiffNames = {"normal", "heroic", "mythic"},
DiffNamesHash = {normal = 14, heroic = 15, mythic = 16},
DiffNames = {"normal", "heroic", "mythic", "raidfinder"},
DiffNamesHash = {normal = 14, heroic = 15, mythic = 16, raidfinder = 17},
DiffIdToName = {[14] = "normal", [15] = "heroic", [16] = "mythic", [17] = "raidfinder"},
IsDebug = false
}
Details222.storage = storage

Expand Down
8 changes: 1 addition & 7 deletions classes/class_combat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -177,17 +177,11 @@ local segmentTypeToString = {
return rawget(self, "is_trash")
end

local diffNumberToName = {
[14] = "normal",
[15] = "heroic",
[16] = "mythic",
}

function classCombat:GetDifficulty()
local bossInfo = self:GetBossInfo()
if (bossInfo) then
local difficultyId = bossInfo.diff
return difficultyId, diffNumberToName[difficultyId]
return difficultyId, Details222.storage.DiffIdToName[difficultyId]
end
end

Expand Down
2 changes: 2 additions & 0 deletions classes/class_damage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
--show more information about spells
local debugmode = false

local GetSpellTexture = GetSpellTexture or C_Spell.GetSpellTexture

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--constants

Expand Down
42 changes: 20 additions & 22 deletions core/gears.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function Details:UpdateGears()
Details:UpdateCombat()
end

---@alias raid_difficulty_eng_name_lowercase "normal" | "heroic" | "mythic"
---@alias raid_difficulty_eng_name_lowercase "normal" | "heroic" | "mythic" | "raidfinder"

------------------------------------------------------------------------------------------------------------
--chat hooks
Expand Down Expand Up @@ -861,7 +861,7 @@ end)
---@field totalkills table<string, table<encounterid, details_bosskillinfo>>

---@class details_storage_feature : table
---@field diffNames string[] {"normal", "heroic", "mythic"}
---@field diffNames string[] {"normal", "heroic", "mythic", "raidfinder"}
---@field OpenRaidStorage fun():details_storage
---@field HaveDataForEncounter fun(difficulty:string, encounterId:number, guildName:string|boolean):boolean
---@field GetBestFromGuild fun(difficulty:string, encounterId:number, role:role, dps:boolean, guildName:string):actorname, details_storage_unitresult, details_encounterkillinfo
Expand All @@ -871,11 +871,7 @@ end)

local CONST_ADDONNAME_DATASTORAGE = "Details_DataStorage"

local diffNumberToName = {
[14] = "normal",
[15] = "heroic",
[16] = "mythic",
}
local diffNumberToName = Details222.storage.DiffIdToName

local createStorageTables = function()
local storageDatabase = DetailsDataStorage
Expand Down Expand Up @@ -1764,9 +1760,9 @@ function Details.Database.StoreWipe(combat)

local name, type, zoneDifficulty, difficultyName, maxPlayers, playerDifficulty, isDynamicInstance, mapID, instanceGroupSize = GetInstanceInfo()

if (not Details:IsZoneIdFromCurrentExpansion(mapID)) then
if (not Details:IsZoneIdFromCurrentExpansion(mapID) and not Details222.storage.IsDebug) then
if (Details.debug) then
print("|cFFFFFF00Details! Storage|r: instance not allowed.")
print("|cFFFFFF00Details! Storage|r: instance not allowed.") --again
end
return
end
Expand Down Expand Up @@ -1813,14 +1809,10 @@ function Details.Database.StoreWipe(combat)
end
end


---PAREI AQUI


---@param combat combat
function Details.Database.StoreEncounter(combat)
combat = combat or Details:GetCurrentCombat()

print(1)
if (not combat) then
if (Details.debug) then
print("|cFFFFFF00Details! Storage|r: combat not found.")
Expand All @@ -1830,13 +1822,15 @@ function Details.Database.StoreEncounter(combat)

local name, type, difficulty, difficultyName, maxPlayers, playerDifficulty, isDynamicInstance, mapID, instanceGroupSize = GetInstanceInfo()

if (not Details:IsZoneIdFromCurrentExpansion(mapID)) then
--Details:IsZoneIdFromCurrentExpansion(select(8, GetInstanceInfo()))

if (not Details:IsZoneIdFromCurrentExpansion(mapID) and not Details222.storage.IsDebug) then
if (Details.debug) then
print("|cFFFFFF00Details! Storage|r: instance not allowed.")
end
return
end

print(2)
local encounterInfo = combat:GetBossInfo()
local encounterId = encounterInfo and encounterInfo.id

Expand All @@ -1856,7 +1850,7 @@ function Details.Database.StoreEncounter(combat)
if (not savedData) then
return
end

print(3)
--[=[
savedData[mythic] = {
[encounterId] = { --indexed table
Expand Down Expand Up @@ -1896,7 +1890,7 @@ function Details.Database.StoreEncounter(combat)

--total kills in a boss on raid or dungeon
local totalkillsTable = Details.Database.GetBossKillsDB(savedData)

--store total kills on this boss
--if the player is facing a raid boss
if (IsInRaid()) then
Expand All @@ -1912,7 +1906,7 @@ function Details.Database.StoreEncounter(combat)
dps_best_raid = 0,
dps_best_raid_when = 0
}

print(4)
---@type details_bosskillinfo
local bossData = totalkillsTable[encounterId][diff]
---@type combattime
Expand Down Expand Up @@ -1949,17 +1943,17 @@ function Details.Database.StoreEncounter(combat)
bossData.dps_best_raid_when = time()
end
end

print(5, diff)
--check for heroic and mythic
if (storageDebug or Details222.storage.DiffNamesHash[diff]) then
if (Details222.storage.IsDebug or Details222.storage.DiffNamesHash[diff]) then
--check the guild name
local match = 0
local guildName = GetGuildInfo("player")
local raidSize = GetNumGroupMembers() or 0

local cachedUnitIds = Details222.UnitIdCache.Raid

if (not storageDebug) then
if (not Details222.storage.IsDebug) then
if (guildName) then
for i = 1, raidSize do
local gName = GetGuildInfo(cachedUnitIds[i]) or ""
Expand Down Expand Up @@ -1998,6 +1992,8 @@ function Details.Database.StoreEncounter(combat)
local damageContainer = combat:GetContainer(DETAILS_ATTRIBUTE_DAMAGE)
local healingContainer = combat:GetContainer(DETAILS_ATTRIBUTE_HEAL)

print(6, diff)

for i = 1, GetNumGroupMembers() do
local role = UnitGroupRolesAssigned(cachedUnitIds[i])

Expand Down Expand Up @@ -2039,6 +2035,8 @@ function Details.Database.StoreEncounter(combat)
end
end

print(7, diff)

--add the encounter data
tinsert(allEncountersStored, combatResultData)
if (Details.debug) then
Expand Down
6 changes: 1 addition & 5 deletions core/parser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -677,11 +677,7 @@
--this block won't execute if the storage isn't loaded
--self is a timer reference from C_Timer

local diffNumberToName = {
[14] = "normal",
[15] = "heroic",
[16] = "mythic",
}
local diffNumberToName = Details222.storage.DiffIdToName

local encounterID = self.Boss
local diff = self.Diff
Expand Down
19 changes: 19 additions & 0 deletions frames/window_debug.lua
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,25 @@ local createDebugOptionsFrame = function()
desc = "When enabled, Details! will save the chart data from the next m+ run and use it when showing the chart panel. This save persist on saved variables and I don't think it is deleted, never.",
--/run Details.mythic_plus.last_mythicrun_chart = {}
},

{type = "blank"},

{--storage debug
type = "toggle",
get = function()
return Details222.storage.IsDebug
end,
set = function(self, fixedparam, value)
Details222.storage.IsDebug = value
if (Details222.storage.IsDebug) then
Details:Msg("Storage Debug is ON.")
else
Details:Msg("Storage Debug is OFF.")
end
end,
name = "Encounter Storage Debug",
desc = "Internal tests of the storage feature.",
},
}

options.always_boxfirst = true
Expand Down
6 changes: 3 additions & 3 deletions frames/window_main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6096,9 +6096,9 @@ local build_mode_list = function(self, deltaTime)
gameCooltip:AddMenu(1, function() instance:SetMode(2) end)
gameCooltip:AddIcon([[Interface\AddOns\Details\images\modo_icones]], 1, 1, 20, 20, 32/256, 32/256*2, 0, 1)

gameCooltip:AddLine(Loc["STRING_MODE_ALL"])
gameCooltip:AddMenu(1, function() instance:SetMode(3) end)
gameCooltip:AddIcon([[Interface\AddOns\Details\images\modo_icones]], 1, 1, 20, 20, 32/256*2, 32/256*3, 0, 1)
--gameCooltip:AddLine(Loc["STRING_MODE_ALL"])
--gameCooltip:AddMenu(1, function() instance:SetMode(3) end)
--gameCooltip:AddIcon([[Interface\AddOns\Details\images\modo_icones]], 1, 1, 20, 20, 32/256*2, 32/256*3, 0, 1)

gameCooltip:AddLine(Loc["STRING_OPTIONS_PLUGINS"])
gameCooltip:AddMenu(1, function() instance:SetMode(4) end)
Expand Down
7 changes: 6 additions & 1 deletion startup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function Details:StartMeUp()
Details.ShowDeathTooltipFunction = Details.ShowDeathTooltip

if (C_CVar) then
if (not InCombatLockdown()) then --disable for releases
if (not InCombatLockdown() and DetailsFramework.IsDragonflightAndBeyond()) then --disable for releases
C_CVar.SetCVar("cameraDistanceMaxZoomFactor", 2.6)
end
end
Expand Down Expand Up @@ -190,6 +190,11 @@ function Details:StartMeUp()
for id = 1, Details:GetNumInstances() do
local instance = Details:GetInstance(id)
if (instance:IsEnabled()) then
if (instance.modo == 3) then --everything
instance.LastModo = 2 --standard
instance.modo = 2 --standard
end

--refresh wallpaper
if (instance.wallpaper.enabled) then
instance:InstanceWallpaper(true)
Expand Down

0 comments on commit 0531ed0

Please sign in to comment.