Skip to content

Commit

Permalink
small adjustments and bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tercioo committed Oct 8, 2022
1 parent f1fa3f5 commit e449983
Show file tree
Hide file tree
Showing 16 changed files with 314 additions and 79 deletions.
2 changes: 1 addition & 1 deletion Libs/DF/fw.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


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

Expand Down
13 changes: 12 additions & 1 deletion Libs/DF/label.lua
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,18 @@ detailsFramework:Mixin(LabelMetaFunctions, detailsFramework.SetPointMixin)
end
end

labelObject.label:SetText(text)
--if the text is a table, it means a language table has been passed
if (type(text) == "table") then
local locTable = text
if (detailsFramework.Language.IsLocTable(locTable)) then
detailsFramework.Language.SetTextWithLocTable(labelObject.widget, locTable)
else
labelObject.label:SetText(text)
end
else
labelObject.label:SetText(text)
end

labelObject.label:SetJustifyH("left")

if (color) then
Expand Down
154 changes: 144 additions & 10 deletions Libs/DF/languages.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
--todo: need to send a callback when setting a new language, this will be used by the volatile menu to refresh the menu

--[=[
DetailsFramework.Language.Register(addonId, languageId[, gameLanguageOnly])
namespace = DetailsFramework.Language = DetailsFramework.Language.Register()
Register(addonId, languageId[, gameLanguageOnly])
create a language table within an addon namespace
@addonId: an identifier, can be any table or string, will be used when getting the table with phrase translations, example: "DetailsLocalization", "Details", "PlaterLoc", _G.Plater
@languageId: game languages: "deDE", "enUS", "esES", "esMX", "frFR", "itIT", "koKR", "ptBR", "ruRU", "zhCN", "zhTW", or any other value if 'gameLanguageOnly' is false (default)
Expand All @@ -17,7 +19,7 @@
local newLanguageTable = DetailsFramework.Language.Register(_G.Details, "valyrianValyria", false)
newLanguageTable["STRING_MY_PHRASE"] = "ñuha udrir"
DetailsFramework.Language.GetLanguageTable(addonId[, languageId])
GetLanguageTable(addonId[, languageId])
get the languageTable for the requested languageId within the addon namespace
if languageId is not passed, uses the current language set for the addonId
the default languageId for the addon is the first language registered with DetailsFramework.Language.Register()
Expand All @@ -34,19 +36,19 @@
local languageTable = DetailsFramework.Language.GetLanguageTable("Details", "valyrianValyria")
fontString:SetText(languageTable["STRING_MY_PHRASE"])
DetailsFramework.Language.GetText(addonId, phraseId[, silent])
GetText(addonId, phraseId[, silent])
get a text from a registered addonId and phraseId
@addonId: an identifier, can be any table or string, will be used when getting the table with phrase translations, example: "DetailsLocalization", "Details", "PlaterLoc", _G.Plater
@phraseId: any string to identify the a translated text, example: phraseId: "OPTIONS_FRAME_WIDTH" text: "Adjust the Width of the frame."
@silent: if true won't error on invalid phrase text and instead use the phraseId as the text, it will still error on invalid addonId
DetailsFramework.Language.SetCurrentLanguage(addonId, languageId)
SetCurrentLanguage(addonId, languageId)
set the language used by default when retriving a languageTable with DF.Language.GetLanguageTable() and not passing the second argument (languageId) within the call
use this in combination with a savedVariable to use a language of the user choice
@addonId: an identifier, can be any table or string, will be used when getting the table with phrase translations, example: "DetailsLocalization", "Details", "PlaterLoc", _G.Plater
@languageId: game languages: "deDE", "enUS", "esES", "esMX", "frFR", "itIT", "koKR", "ptBR", "ruRU", "zhCN", "zhTW", or any other value if 'gameLanguageOnly' is false (default)
DetailsFramework.Language.RegisterObject(addonId, object, phraseId[, silent[, ...]])
RegisterObject(addonId, object, phraseId[, silent[, ...]])
to be registered, the Object need to have a SetText method
when setting a languageId with DetailsFramework.Language.SetCurrentLanguage(), automatically change the text of all registered Objects
@addonId: an identifier, can be any table or string, will be used when getting the table with phrase translations, example: "DetailsLocalization", "Details", "PlaterLoc", _G.Plater
Expand All @@ -55,15 +57,15 @@
@silent: if true won't error on invalid phrase text and instead use the phraseId as the text, it will still error on invalid addonId and Object
@vararg: arguments to pass for format(text, ...)
DetailsFramework.Language.UpdateObjectArguments(addonId, object, ...)
UpdateObjectArguments(addonId, object, ...)
update the arguments (...) of a registered Object, if no argument passed it'll erase the arguments previously set
the Object need to be already registered with DetailsFramework.Language.RegisterObject()
the font string text will be changed to update the text with the new arguments
@addonId: an identifier, can be any table or string, will be used when getting the table with phrase translations, example: "DetailsLocalization", "Details", "PlaterLoc", _G.Plater
@object: any UIObject or table with SetText method
@vararg: arguments to pass for format(text, ...)
DetailsFramework.Language.RegisterTableKey(addonId, table, key, phraseId[, silent[, ...]])
RegisterTableKey(addonId, table, key, phraseId[, silent[, ...]])
when setting a languageId with DetailsFramework.Language.SetCurrentLanguage(), automatically change the text of all registered tables, table[key] = 'new translated text'
@addonId: an identifier, can be any table or string, will be used when getting the table with phrase translations, example: "DetailsLocalization", "Details", "PlaterLoc", _G.Plater
@table: a lua table
Expand All @@ -72,26 +74,38 @@
@silent: if true won't error on invalid phrase text or table already registered, it will still error on invalid addonId, table, key and phraseId
@vararg: arguments to pass for format(text, ...)
DetailsFramework.Language.UpdateTableKeyArguments(addonId, table, key, ...)
UpdateTableKeyArguments(addonId, table, key, ...)
same as UpdateObjectArguments() but for table keys
@addonId: an identifier, can be any table or string, will be used when getting the table with phrase translations, example: "DetailsLocalization", "Details", "PlaterLoc", _G.Plater
@table: a lua table
@key: any value except nil or boolean
@vararg: arguments to pass for format(text, ...)
DetailsFramework.Language.RegisterObjectWithDefault(addonId, object, phraseId, defaultText[, ...])
RegisterObjectWithDefault(addonId, object, phraseId, defaultText[, ...])
(helper function) register an object if a phraseID is valid or object:SetText(defaultText) is called
DetailsFramework.Language.RegisterTableKeyWithDefault(addonId, table, key, phraseId, defaultText[, ...])
RegisterTableKeyWithDefault(addonId, table, key, phraseId, defaultText[, ...])
(helper function) register a tableKey if a phraseID is valid or table[key] = defaultText
CreateLocTable(addonId, phraseId, shouldRegister[, ...])
make a table to pass instead of the text while using DetailsFramework widgets
this avoid to call the register object function right after creating the widget
also make easy to register the same phraseID in many different widgets
SetTextWithLocTable(object, locTable)
set the text of an object using a locTable, the object need the method SetText
--]=]

local DF = _G["DetailsFramework"]
if (not DF or not DetailsFrameworkCanLoad) then
return
end

local format = string.format
local unpack = table.unpack or unpack
local GetLocale = _G.GetLocale

local CONST_LANGAGEID_ENUS = "enUS"

local supportedGameLanguages = {
Expand Down Expand Up @@ -123,6 +137,13 @@ local functionSignature = {

["RegisterObjectWithDefault"] = "RegisterObjectWithDefault(addonId, object, phraseId, defaultText[, ...])",
["RegisterTableKeyWithDefault"] = "RegisterTableKeyWithDefault(addonId, table, key, phraseId, defaultText[, ...])",

["CreateLocTable"] = "CreateLocTable(addonId, phraseId, shouldRegister[, ...])",
["UnpackLocTable"] = "UnpackLocTable(locTable)",
["CanRegisterLocTable"] = "CanRegisterLocTable(locTable)",
["RegisterObjectWithLocTable"] = "RegisterObjectWithLocTable(object, locTable)",
["SetTextWithLocTable"] = "SetTextWithLocTable(object, locTable)",
["IsLocTable"] = "IsLocTable(locTable)",
}

local functionCallPath = {
Expand All @@ -138,10 +159,18 @@ local functionCallPath = {

["RegisterObjectWithDefault"] = "DetailsFramework.Language.RegisterObjectWithDefault",
["RegisterTableKeyWithDefault"] = "DetailsFramework.Language.RegisterTableKeyWithDefault",

["CreateLocTable"] = "DetailsFramework.Language.CreateLocTable",
["UnpackLocTable"] = "DetailsFramework.Language.UnpackLocTable",
["CanRegisterLocTable"] = "DetailsFramework.Language.CanRegisterLocTable",
["RegisterObjectWithLocTable"] = "DetailsFramework.Language.RegisterObjectWithLocTable",
["SetTextWithLocTable"] = "DetailsFramework.Language.SetTextWithLocTable",
["IsLocTable"] = "DetailsFramework.Language.IsLocTable",
}

local errorText = {
["AddonID"] = "require a valid addonID (table or string) on #%d argument",
["AddonIDInvalidOrNotRegistered"] = "invalid addonID or no languages registered",
["LanguageID"] = "require a languageID supported by the game on #%d argument",
["PhraseID"] = "require a string on #%d argument",
["NoLanguages"] = "no languages registered for addonId",
Expand All @@ -154,6 +183,8 @@ local errorText = {
["InvalidTable"] = "require a table on #%d argument",
["InvalidTableKey"] = "require a table key on #%d argument",
["TableKeyAlreadyRegistered"] = "table already registered", --not in use
["InvalidLocTable"] = "invalid locTable on #%d argument",
["LocTableCantRegister"] = "cannot register object, locTable.register == false",
}


Expand Down Expand Up @@ -743,4 +774,107 @@ function DF.Language.RegisterObjectWithDefault(addonId, object, phraseId, defaul
else
object:SetText(defaultText)
end
end


function DF.Language.CreateLocTable(addonId, phraseId, shouldRegister, ...)
if (not isValid_AddonID(addonId)) then
error(functionCallPath["CreateLocTable"] .. ": " .. format(errorText["AddonID"], 1) .. ", use: " .. functionSignature["CreateLocTable"] .. ".")
end

if (not isValid_PhraseID(phraseId)) then
error(functionCallPath["CreateLocTable"] .. ": " .. format(errorText["PhraseID"], 2) .. ", use: " .. functionSignature["CreateLocTable"] .. ".")
end

local newLocTable = {
addonId = addonId,
phraseId = phraseId,
shouldRegister = shouldRegister,
arguments = parseArguments(...),
}

return newLocTable
end

function DF.Language.IsLocTable(locTable)
if (type(locTable) ~= "table") then
return false

elseif (locTable.addonId and locTable.phraseId) then
return true
end

return false
end


function DF.Language.CanRegisterLocTable(locTable)
if (not DF.Language.IsLocTable(locTable)) then
error(functionCallPath["CanRegisterLocTable"] .. ": " .. format(errorText["InvalidLocTable"], 1) .. ", use: " .. functionSignature["CanRegisterLocTable"] .. ".")
end
return locTable.shouldRegister
end


function DF.Language.UnpackLocTable(locTable)
if (type(locTable) ~= "table") then
error(functionCallPath["UnpackLocTable"] .. ": " .. format(errorText["InvalidLocTable"], 1) .. ", use: " .. functionSignature["UnpackLocTable"] .. ".")
end
return locTable.addonId, locTable.phraseId, locTable.shouldRegister or false, locTable.arguments
end


function DF.Language.RegisterObjectWithLocTable(object, locTable)
if (not isValid_Object(object)) then
error(functionCallPath["RegisterObjectWithLocTable"] .. ": " .. format(errorText["InvalidObject"], 1) .. ", use: " .. functionSignature["RegisterObjectWithLocTable"] .. ".")
end

if (not DF.Language.IsLocTable(locTable)) then
error(functionCallPath["RegisterObjectWithLocTable"] .. ": " .. format(errorText["InvalidLocTable"], 2) .. ", use: " .. functionSignature["RegisterObjectWithLocTable"] .. ".")
end

local addonId, phraseId, shouldRegister, arguments = DF.Language.UnpackLocTable(locTable)

if (not isValid_AddonID(addonId)) then
error(functionCallPath["RegisterObjectWithLocTable"] .. ": " .. format(errorText["AddonID"], 1) .. ", use: " .. functionSignature["RegisterObjectWithLocTable"] .. ".")
end

if (not isValid_PhraseID(phraseId)) then
error(functionCallPath["RegisterObjectWithLocTable"] .. ": " .. format(errorText["PhraseID"], 2) .. ", use: " .. functionSignature["RegisterObjectWithLocTable"] .. ".")
end

if (not shouldRegister) then
error(functionCallPath["RegisterObjectWithLocTable"] .. ": " .. errorText["LocTableCantRegister"] .. ", use: " .. functionSignature["RegisterObjectWithLocTable"] .. ".")
end

DF.Language.RegisterObject(addonId, object, phraseId, true, arguments and unpack(arguments))
end


function DF.Language.SetTextWithLocTable(object, locTable)
if (not isValid_Object(object)) then
error(functionCallPath["SetTextWithLocTable"] .. ": " .. format(errorText["InvalidObject"], 1) .. ", use: " .. functionSignature["SetTextWithLocTable"] .. ".")
end

if (not DF.Language.IsLocTable(locTable)) then
error(functionCallPath["SetTextWithLocTable"] .. ": " .. format(errorText["InvalidLocTable"], 2) .. ", use: " .. functionSignature["SetTextWithLocTable"] .. ".")
end

local addonId, phraseId, shouldRegister, arguments = DF.Language.UnpackLocTable(locTable)

local addonNamespaceTable = getAddonNamespace(addonId)
if (not addonNamespaceTable) then
error(functionCallPath["SetTextWithLocTable"] .. ": " .. errorText["AddonIDInvalidOrNotRegistered"] .. ", use: " .. functionSignature["RegisterLanguage"] .. ".")
end

if (DF.Language.CanRegisterLocTable(locTable)) then
DF.Language.RegisterObjectWithLocTable(object, locTable)
return true
end

local text = getText(addonNamespaceTable, phraseId)

--can use the locTable instead of the phraseInfoTable because both has the .arguments member
setObject_Text(object, locTable, text)
return true
end
8 changes: 4 additions & 4 deletions Libs/LibOpenRaid/GetPlayerInformation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ end

function openRaidLib.GetTalentVersion()
local _, _, _, buildInfo = GetBuildInfo()
local gamePatch = buildInfo / 10000
if (gamePatch >= 1 and gamePatch <= 4) then --vanilla tbc wotlk cataclysm

if (buildInfo >= 1 and buildInfo <= 40000) then --vanilla tbc wotlk cataclysm
return CONST_TALENT_VERSION_CLASSIC
end

if (gamePatch >= 7 and gamePatch <= 9) then --legion bfa shadowlands
if (buildInfo >= 70000 and buildInfo <= 100000) then --legion bfa shadowlands
return CONST_TALENT_VERSION_LEGION
end

if (gamePatch >= 10 and gamePatch <= 20) then --dragonflight
if (buildInfo >= 100000 and buildInfo <= 200000) then --dragonflight
return CONST_TALENT_VERSION_DRAGONFLIGHT
end
end
Expand Down
2 changes: 1 addition & 1 deletion Libs/LibOpenRaid/LibOpenRaid.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ if (WOW_PROJECT_ID ~= WOW_PROJECT_MAINLINE and not isExpansion_Dragonflight()) t
end

local major = "LibOpenRaid-1.0"
local CONST_LIB_VERSION = 58
local CONST_LIB_VERSION = 59
LIB_OPEN_RAID_CAN_LOAD = false

--declae the library within the LibStub
Expand Down
12 changes: 8 additions & 4 deletions boot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
--> global name declaration

_ = nil
_detalhes = LibStub("AceAddon-3.0"):NewAddon("_detalhes", "AceTimer-3.0", "AceComm-3.0", "AceSerializer-3.0", "NickTag-1.0")
_G._detalhes = LibStub("AceAddon-3.0"):NewAddon("_detalhes", "AceTimer-3.0", "AceComm-3.0", "AceSerializer-3.0", "NickTag-1.0")

local version, build, date, tocversion = GetBuildInfo()

_detalhes.build_counter = 10033
_detalhes.alpha_build_counter = 10033 --if this is higher than the regular counter, use it instead
_detalhes.build_counter = 10129
_detalhes.alpha_build_counter = 10129 --if this is higher than the regular counter, use it instead
_detalhes.dont_open_news = true
_detalhes.game_version = version
_detalhes.userversion = version .. " " .. _detalhes.build_counter
Expand Down Expand Up @@ -845,7 +845,11 @@ do
function Details.SendHighFive()
Details.users = {{UnitName("player"), GetRealmName(), (Details.userversion or "") .. " (" .. Details.APIVersion .. ")"}}
Details.sent_highfive = GetTime()
Details:SendRaidData (Details.network.ids.HIGHFIVE_REQUEST)
if (IsInRaid()) then
Details:SendRaidData(Details.network.ids.HIGHFIVE_REQUEST)
else
Details:SendPartyData(Details.network.ids.HIGHFIVE_REQUEST)
end
end

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Expand Down
18 changes: 9 additions & 9 deletions classes/class_instance.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1924,29 +1924,29 @@ end

------------------------------------------------------------------------------------------------------------------------

function _detalhes:InstanceReset (instance)
function _detalhes:InstanceReset(instance)
if (instance) then
self = instance
end
Details.FadeHandler.Fader (self, "in", nil, "barras")
self:AtualizaSegmentos (self)

Details.FadeHandler.Fader(self, "in", nil, "barras")
self:AtualizaSegmentos(self)
self:AtualizaSoloMode_AfertReset()
self:ResetaGump()

if (not _detalhes.initializing) then
_detalhes:RefreshMainWindow (self, true) --atualiza todas as instancias
_detalhes:RefreshMainWindow(self, true) --atualiza todas as instancias
end
end

function _detalhes:RefreshBars (instance)
function _detalhes:RefreshBars(instance)
if (instance) then
self = instance
end
self:InstanceRefreshRows (instancia)
self:InstanceRefreshRows(instance)
end

function _detalhes:SetBackgroundColor (...)

function _detalhes:SetBackgroundColor(...)
local red = select (1, ...)
if (not red) then
self.bgdisplay:SetBackdropColor (self.bg_r, self.bg_g, self.bg_b, self.bg_alpha)
Expand Down
Loading

0 comments on commit e449983

Please sign in to comment.