Skip to content

Commit

Permalink
Initial WoW Classic Support
Browse files Browse the repository at this point in the history
First pass of changes to make Details! compatible with WoW Classic.
  • Loading branch information
Tercioo committed May 23, 2019
1 parent 24dde51 commit 643d25b
Show file tree
Hide file tree
Showing 30 changed files with 517 additions and 364 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ Libs/DF/cooltip_background.blp
Libs/DF/feedback_sites.blp
Libs/DF/icons.blp
Libs/DF/mail.blp
plugins/Details_EncounterDetails/images/boss_icons.png
98 changes: 93 additions & 5 deletions Libs/DF/fw.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

local dversion = 149
local dversion = 151
local major, minor = "DetailsFramework-1.0", dversion
local DF, oldminor = LibStub:NewLibrary (major, minor)

Expand All @@ -25,6 +25,94 @@ DF.AuthorInfo = {
Discord = "https://discord.gg/AGSzAZX",
}

if (not PixelUtil) then
--check if is in classic wow, if it is, build a replacement for PixelUtil
local gameVersion = GetBuildInfo()
if (gameVersion:match("%d") == "1") then
PixelUtil = {
SetWidth = function (self, width) self:SetWidth (width) end,
SetHeight = function (self, height) self:SetHeight (height) end,
SetSize = function (self, width, height) self:SetSize (width, height) end,
SetPoint = function (self, ...) self:SetPoint (...) end,
}
end
end

function DF.IsClassicWow()
local gameVersion = GetBuildInfo()
if (gameVersion:match ("%d") == "1") then
return true
end
return false
end

function DF.UnitGroupRolesAssigned (unitId)
if (UnitGroupRolesAssigned) then
return UnitGroupRolesAssigned (unitId)
else
--attempt to guess the role by the player spec

--at the moment just return none
return "NONE"
end
end

--return the specialization of the player it self
function DF.GetSpecialization()
if (GetSpecialization) then
return GetSpecialization()
end

return nil
end

function DF.GetSpecializationInfoByID (...)
if (GetSpecializationInfoByID) then
return GetSpecializationInfoByID (...)
end

return nil
end

function DF.GetSpecializationInfo (...)
if (GetSpecializationInfo) then
return GetSpecializationInfo (...)
end

return nil
end

function DF.GetSpecializationRole (...)
if (GetSpecializationRole) then
return GetSpecializationRole (...)
end

return nil
end

--build dummy encounter journal functions if they doesn't exists
--this is done for compatibility with classic and if in the future EJ_ functions are moved to C_
DF.EncounterJournal = {
EJ_GetCurrentInstance = EJ_GetCurrentInstance or function() return nil end,
EJ_GetInstanceForMap = EJ_GetInstanceForMap or function() return nil end,
EJ_GetInstanceInfo = EJ_GetInstanceInfo or function() return nil end,
EJ_SelectInstance = EJ_SelectInstance or function() return nil end,

EJ_GetEncounterInfoByIndex = EJ_GetEncounterInfoByIndex or function() return nil end,
EJ_GetEncounterInfo = EJ_GetEncounterInfo or function() return nil end,
EJ_SelectEncounter = EJ_SelectEncounter or function() return nil end,

EJ_GetSectionInfo = EJ_GetSectionInfo or function() return nil end,
EJ_GetCreatureInfo = EJ_GetCreatureInfo or function() return nil end,
EJ_SetDifficulty = EJ_SetDifficulty or function() return nil end,
EJ_GetNumLoot = EJ_GetNumLoot or function() return 0 end,
EJ_GetLootInfoByIndex = EJ_GetLootInfoByIndex or function() return nil end,
}

if (not EJ_GetCurrentInstance) then

end

--> will always give a very random name for our widgets
local init_counter = math.random (1, 1000000)

Expand Down Expand Up @@ -2496,9 +2584,9 @@ function DF:ReskinSlider (slider, heightOffset)
end

function DF:GetCurrentSpec()
local specIndex = GetSpecialization()
local specIndex = DF.GetSpecialization()
if (specIndex) then
local specID = GetSpecializationInfo (specIndex)
local specID = DF.GetSpecializationInfo (specIndex)
if (specID and specID ~= 0) then
return specID
end
Expand Down Expand Up @@ -2786,8 +2874,8 @@ DF.CLEncounterID = {
function DF:GetPlayerRole()
local assignedRole = UnitGroupRolesAssigned ("player")
if (assignedRole == "NONE") then
local spec = GetSpecialization()
return spec and GetSpecializationRole (spec) or "NONE"
local spec = DF.GetSpecialization()
return spec and DF.GetSpecializationRole (spec) or "NONE"
end
return assignedRole
end
Expand Down
26 changes: 14 additions & 12 deletions Libs/DF/panel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ local _type = type --> lua local
local _math_floor = math.floor --> lua local
local loadstring = loadstring --> lua local

local UnitGroupRolesAssigned = DetailsFramework.UnitGroupRolesAssigned

local cleanfunction = function() end
local APIFrameFunctions

Expand Down Expand Up @@ -4459,7 +4461,7 @@ function DF:CreateKeybindBox (parent, name, data, callback, width, height, line_

for index, specId in ipairs (specIds) do
local button = new_keybind_frame ["SpecButton" .. index]
local spec_id, spec_name, spec_description, spec_icon, spec_background, spec_role, spec_class = GetSpecializationInfoByID (specId)
local spec_id, spec_name, spec_description, spec_icon, spec_background, spec_role, spec_class = DetailsFramework.GetSpecializationInfoByID (specId)
button.text = spec_name
button:SetClickFunction (switch_spec, specId)
button:SetIcon (spec_icon)
Expand Down Expand Up @@ -4584,9 +4586,9 @@ function DF:CreateKeybindBox (parent, name, data, callback, width, height, line_
if (type (dispel) == "table") then
local dispelString = "\n"
for specID, spellid in pairs (dispel) do
local specid, specName = GetSpecializationInfoByID (specID)
local specid, specName = DetailsFramework.GetSpecializationInfoByID (specID)
local spellName = GetSpellInfo (spellid)
dispelString = dispelString .. "|cFFE5E5E5" .. specName .. "|r: |cFFFFFFFF" .. spellName .. "\n"
dispelString = dispelString .. "|cFFE5E5E5" .. (specName or "") .. "|r: |cFFFFFFFF" .. spellName .. "\n"
end
dispel = dispelString
else
Expand All @@ -4608,9 +4610,9 @@ function DF:CreateKeybindBox (parent, name, data, callback, width, height, line_
for specID, t in pairs (new_keybind_frame.Data) do
if (specID ~= new_keybind_frame.EditingSpec) then
local key = CopyTable (keybind)
local specid, specName = GetSpecializationInfoByID (specID)
local specid, specName = DetailsFramework.GetSpecializationInfoByID (specID)
tinsert (new_keybind_frame.Data [specID], key)
DF:Msg ("Keybind copied to " .. specName)
DF:Msg ("Keybind copied to " .. (specName or ""))
end
end
DF:QuickDispatch (callback)
Expand Down Expand Up @@ -5653,9 +5655,9 @@ function DF:CreateLoadFilterParser (callback)
elseif (event == "PLAYER_ROLES_ASSIGNED") then
local assignedRole = UnitGroupRolesAssigned ("player")
if (assignedRole == "NONE") then
local spec = GetSpecialization()
local spec = DetailsFramework.GetSpecialization()
if (spec) then
assignedRole = GetSpecializationRole (spec)
assignedRole = DetailsFramework.GetSpecializationRole (spec)
end
end

Expand Down Expand Up @@ -5705,9 +5707,9 @@ function DF:PassLoadFilters (loadTable, encounterID)
end

if (canCheckTalents) then
local specIndex = GetSpecialization()
local specIndex = DetailsFramework.GetSpecialization()
if (specIndex) then
local specID = GetSpecializationInfo (specIndex)
local specID = DetailsFramework.GetSpecializationInfo (specIndex)
if (not loadTable.spec [specID]) then
return false
end
Expand Down Expand Up @@ -5767,9 +5769,9 @@ function DF:PassLoadFilters (loadTable, encounterID)
if (loadTable.role.Enabled) then
local assignedRole = UnitGroupRolesAssigned ("player")
if (assignedRole == "NONE") then
local spec = GetSpecialization()
local spec = DetailsFramework.GetSpecialization()
if (spec) then
assignedRole = GetSpecializationRole (spec)
assignedRole = DetailsFramework.GetSpecializationRole (spec)
end
end
if (not loadTable.role [assignedRole]) then
Expand Down Expand Up @@ -5927,7 +5929,7 @@ function DF:OpenLoadConditionsPanel (optionsTable, callback, frameOptions)
--create the radio group for character spec
local specs = {}
for _, specID in ipairs (DF:GetClassSpecIDs (select (2, UnitClass ("player")))) do
local specID, specName, specDescription, specIcon, specBackground, specRole, specClass = GetSpecializationInfoByID (specID)
local specID, specName, specDescription, specIcon, specBackground, specRole, specClass = DetailsFramework.GetSpecializationInfoByID (specID)
tinsert (specs, {
name = specName,
set = f.OnRadioCheckboxClick,
Expand Down
4 changes: 2 additions & 2 deletions Libs/DF/spells.lua
Original file line number Diff line number Diff line change
Expand Up @@ -834,8 +834,8 @@ DF.RuneIDs = {

function DF:GetSpellsForEncounterFromJournal (instanceEJID, encounterEJID)

EJ_SelectInstance (instanceEJID)
local name, description, encounterID, rootSectionID, link = EJ_GetEncounterInfo (encounterEJID) --taloc (primeiro boss de Uldir)
DetailsFramework.EncounterJournal.EJ_SelectInstance (instanceEJID)
local name, description, encounterID, rootSectionID, link = DetailsFramework.EncounterJournal.EJ_GetEncounterInfo (encounterEJID) --taloc (primeiro boss de Uldir)

if (not name) then
print ("DetailsFramework: Encounter Info Not Found!", instanceEJID, encounterEJID)
Expand Down
2 changes: 1 addition & 1 deletion Libs/libs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
<Include file="LibCompress\lib.xml"/>
<Include file="LibDeflate\lib.xml"/>
<Include file="LibItemUpgradeInfo-1.0\LibItemUpgradeInfo-1.0.xml"/>
<Include file="LibGroupInSpecT-1.1\lib.xml"/>
<!-- <Include file="LibGroupInSpecT-1.1\lib.xml"/> temp disabled due to classic-->
<Include file="DF\load.xml"/>
</Ui>
8 changes: 4 additions & 4 deletions classes/classe_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1920,9 +1920,9 @@
local player
local pet_attribute
local role = UnitGroupRolesAssigned ("player")
local spec = GetSpecialization()
role = spec and GetSpecializationRole (spec) or role
local role = DetailsFramework.UnitGroupRolesAssigned ("player")
local spec = DetailsFramework.GetSpecialization()
role = spec and DetailsFramework.GetSpecializationRole (spec) or role
if (role == "DAMAGER") then
player = combat (DETAILS_ATTRIBUTE_DAMAGE, _detalhes.playername)
Expand Down Expand Up @@ -1980,7 +1980,7 @@
local GC = GameCooltip
GC:SetOption ("YSpacingMod", 0)
local role = UnitGroupRolesAssigned ("player")
local role = DetailsFramework.UnitGroupRolesAssigned ("player")
if (spell.n_dmg) then
Expand Down
29 changes: 2 additions & 27 deletions classes/classe_instancia.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ local _GetChannelName = GetChannelName --> wow api locals
local _UnitExists = UnitExists --> wow api locals
local _UnitName = UnitName --> wow api locals
local _UnitIsPlayer = UnitIsPlayer --> wow api locals
local _UnitGroupRolesAssigned = UnitGroupRolesAssigned --> wow api locals
local _UnitGroupRolesAssigned = DetailsFramework.UnitGroupRolesAssigned --> wow api locals

local _detalhes = _G._detalhes
local gump = _detalhes.gump
Expand Down Expand Up @@ -1284,19 +1284,6 @@ end

--> setup default wallpaper
new_instance.wallpaper.texture = "Interface\\AddOns\\Details\\images\\background"
--[[ 7.1.5 isn't sending the background on the 5� return value ~cleanup
local spec = GetSpecialization()
if (spec) then
local id, name, description, icon, _background, role = GetSpecializationInfo (spec)
if (_background) then
local bg = "Interface\\TALENTFRAME\\" .. _background
if (new_instance.wallpaper) then
new_instance.wallpaper.texture = bg
new_instance.wallpaper.texcoord = {0, 1, 0, 0.703125}
end
end
end
--]]

--> finish
return new_instance
Expand All @@ -1315,19 +1302,7 @@ end
new_instance:ResetInstanceConfig()
--> setup default wallpaper
new_instance.wallpaper.texture = "Interface\\AddOns\\Details\\images\\background"
--[[ 7.1.5 isn't sending the background on the 5� return value ~cleanup
local spec = GetSpecialization()
if (spec) then
local id, name, description, icon, _background, role = GetSpecializationInfo (spec)
if (_background) then
local bg = "Interface\\TALENTFRAME\\" .. _background
if (new_instance.wallpaper) then
new_instance.wallpaper.texture = bg
new_instance.wallpaper.texcoord = {0, 1, 0, 0.703125}
end
end
end
--]]

--> internal stuff
new_instance.barras = {} --container que ir� armazenar todas as barras
new_instance.barraS = {nil, nil} --de x at� x s�o as barras que est�o sendo mostradas na tela
Expand Down
3 changes: 2 additions & 1 deletion classes/container_combatentes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
local _pairs = pairs --lua local

local AddUnique = DetailsFramework.table.addunique --framework
local UnitGroupRolesAssigned = DetailsFramework.UnitGroupRolesAssigned --framework

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--> constants
Expand Down Expand Up @@ -290,7 +291,7 @@
if (name == nome) then
local spec = GetArenaOpponentSpec (i)
if (spec) then
local id, name, description, icon, role, class = GetSpecializationInfoByID (spec) --thanks pas06
local id, name, description, icon, role, class = DetailsFramework.GetSpecializationInfoByID (spec) --thanks pas06
novo_objeto.role = role
novo_objeto.classe = class
novo_objeto.enemy = true
Expand Down
15 changes: 7 additions & 8 deletions core/control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
local atributo_custom = _detalhes.atributo_custom --details local
local info = _detalhes.janela_info --details local

local UnitGroupRolesAssigned = DetailsFramework.UnitGroupRolesAssigned

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--> constants

Expand Down Expand Up @@ -115,15 +117,14 @@
local mapID = C_Map.GetBestMapForUnit ("player")
local ejid
if (mapID) then
ejid = EJ_GetInstanceForMap (mapID)
ejid = DetailsFramework.EncounterJournal.EJ_GetInstanceForMap (mapID)
end

if (not mapID) then
--print ("Details! exeption handled: zone has no map")
return
end

--local ejid = EJ_GetCurrentInstance()
if (ejid == 0) then
ejid = _detalhes:GetInstanceEJID()
end
Expand Down Expand Up @@ -551,9 +552,7 @@
mapID = 0
end

local ejid = EJ_GetInstanceForMap (mapID)

--local ejid = EJ_GetCurrentInstance()
local ejid = DetailsFramework.EncounterJournal.EJ_GetInstanceForMap (mapID)

if (ejid == 0) then
ejid = _detalhes:GetInstanceEJID()
Expand All @@ -575,7 +574,7 @@
end

--> tag as a mythic dungeon segment, can be any type of segment, this tag also avoid the segment to be tagged as trash
local mythicLevel = C_ChallengeMode.GetActiveKeystoneInfo()
local mythicLevel = C_ChallengeMode and C_ChallengeMode.GetActiveKeystoneInfo()
if (mythicLevel and mythicLevel >= 2) then
_detalhes.tabela_vigente.is_mythic_dungeon_segment = true
_detalhes.tabela_vigente.is_mythic_dungeon_run_id = _detalhes.mythic_dungeon_id
Expand Down Expand Up @@ -1070,10 +1069,10 @@
return
end
local _, playerClass = UnitClass ("player")
local specIndex = GetSpecialization()
local specIndex = DetailsFramework.GetSpecialization()
local playerSpecID
if (specIndex) then
playerSpecID = GetSpecializationInfo (specIndex)
playerSpecID = DetailsFramework.GetSpecializationInfo (specIndex)
end

if (playerSpecID and playerClass) then
Expand Down
Loading

0 comments on commit 643d25b

Please sign in to comment.