Detailed changes for version 1.023

View previous topic View next topic Go down

Detailed changes for version 1.023

Post  Ellypse on Thu Feb 20, 2014 5:33 am

You can find below all the detailed changes, explained, made to the code for version 1.023

Functions added to totalRP2/totalRP2_API.lua:
TRP2_SimplifyNameIfPlayer(unit):

This function is used when we have the name of a unit (the player or an other player), and we are going to use it to get informations from Total RP. Unit is a string with the format Player-Realm.
The function compare the unit it received and the current player. Other players are now always stored in the registry as Player-Realm, but the player himself is stored as Player. When wanting to get information about a unit, format has to be Player-Realm for an other player and Player for the current player.
Code:
function TRP2_SimplifyNameIfPlayer(unit)
         local playerName, playerRealm = UnitFullName("player");
         local senderName = string.gsub(unit, "-.*","");
         local senderRealm = string.gsub(unit, ".*-","")
            if senderRealm == playerRealm and senderName == playerName then
            return playerName;
            else
              return unit;
         end
end

TRP2_UnitNameWithRealm(unit):

As we are now always using Player-Realm to identify a player, this function is aimed to replace the old UnitName(unit) that only return the realm if the unit is from another realm. This function will always return the unit name as Player-Realm (if the other player is from the same realm as the current player, realm will be nil after UnitName(unit), then it will receive the current realm name without spaces.
Code:
function TRP2_UnitNameWithRealm(unit)
    local name, realm = UnitName(unit);
    if not realm then
         realm = GetRealmName():gsub("%s+", "");
    end
    if name and realm then
         return name.."-"..realm;
    else
         return nil;
    end
end

TRP2_RemoveRealm(name):

Purely aesthetic, this function return the name of a player without the realm at the end. It is used on for display purpose for default values (like TRP2_GetWithDefaut(TRP2_GetInfo(name,"Registre",{}),"Prenom",TRP2_RemoveRealm(name)) )
Code:
function TRP2_RemoveRealm(name)
    return string.gsub(name, "-.*","");
end

Changes to totalRP2/totalRP2_UI_Registre.xml:
GameTooltip, Line 2437:

replaced
Code:
if self.Nom ~= UnitName(self.TT_Type) then
for
Code:
if self.Nom ~= TRP2_UnitNameWithRealm(self.TT_Type) then
So the Nom (name) given to the tooltip is correctly compared to the name of the unit over the mouse.
Entire code:

Code:
<GameTooltip name="TRP2_PersoTooltip" frameStrata="TOOLTIP" parent="UIParent" inherits="GameTooltipTemplate">
         <Scripts>
              <OnUpdate>
                   if self.Nom and self.TT_Type and not self.isFading then
                        if self.Nom ~= TRP2_UnitNameWithRealm(self.TT_Type) then
                             self.isFading = true;
                             self.Nom = nil;
                             self:FadeOut();
                             TRP2_MountTooltip.isFading = true;
                             TRP2_MountTooltip:FadeOut();
                        end
                   end
              </OnUpdate>
              <OnHide>
                   self.isFading = nil;
                   TRP2_MountTooltip.isFading = nil;
              </OnHide>
         </Scripts>
    </GameTooltip>

Changes to totalRP2_Auras/totalRP2_Auras_Main.lua:
TRP2_UpdateAuraTargetFrame():

replaced
Code:
if not TRP2_Module_Interface["BannedID"][k] and (auraInfo ~= nil or TRP2_AuraTargetFrame.target==TRP2_Joueur or TRP2_AuraTargetFrame.master == TRP2_Joueur) then
for
Code:
if not TRP2_Module_Interface["BannedID"][k] and (auraInfo ~= nil or TRP2_AuraTargetFrame.target==TRP2_Joueur.."-"..GetRealmName():gsub("%s+", "") or TRP2_AuraTargetFrame.master == TRP2_Joueur.."-"..GetRealmName():gsub("%s+", "")) then
So the TRP2_AuraTargetFrame.master is correctly compared to the player full name TRP2_Joueur.."-"..GetRealmName():gsub("%s+", ""). (Note, might be better to use TRP2_SimplifyNameIfPlayer(TRP2_AuraTargetFrame.master ) )

Changes to totalRP2_Creation/totalRP2_Creation_Objet.lua (version 1.022):
TRP2_CreateObjetTabCreation:

replaced
Code:
objet["Qualite"] = math.floor(TRP2_DefautToNil(tonumber(TRP2_CreationFrameObjetFrameGeneralQualite:GetValue()),1));
for
Code:
objet["Qualite"] = TRP2_DefautToNil(TRP2_GetInt(TRP2_CreationFrameObjetFrameGeneralQualite:GetValue()),1);
To correctly use TRP2_GetInt() introduced in version 1.021 to handle incorrect values (float) inserted in objet["Qualite"]

Changes to totalRP2_Interface/totalRP2_Interface_GestionChatFrame.lua:
TRP2_ChatFrame_OnEvent():

Code:
local coloredName = GetColoredName(event, texte, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12);
This is what made the chat frame go crazy. Since 5.4.7, GetColoredName() always Ambiguate() the name it's given. As GetColoredName() was called on every chatFrame event, it was sometime called with nil values, that was okay before but now it's not as Ambiguate() does not accept nil values. (A huge thanks to Telkostrasz for helping me with this issue).
We are now only calling GetColoredName() if we are in the context of a discussion
Code:
local coloredName;
         if event=="CHAT_MSG_SAY" or event=="CHAT_MSG_PARTY" or event=="CHAT_MSG_RAID" or event=="CHAT_MSG_GUILD" or event=="CHAT_MSG_YELL"
       or event=="CHAT_MSG_PARTY_LEADER" or event=="CHAT_MSG_RAID_LEADER" or event=="CHAT_MSG_OFFICER" or event=="CHAT_MSG_EMOTE"
       or event=="CHAT_MSG_TEXT_EMOTE" or event=="CHAT_MSG_WHISPER" or event=="CHAT_MSG_WHISPER_INFORM" then
         coloredName = GetColoredName(event, texte, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12);
         end
In that same function, every time the variable arg2 (containing the name of the sender of a message) is used, it is now used with TRP2_SimplifyNameIfPlayer() to go from Player-Realm to Player if the sender is the current player so we can correctly pull informations from Total RP (first name, last name, title...)
lines 121, 122, 127, 129, 130, 134, 141, 155, 181, 263, 264, 268, 270, 271, 274, 275, 285, 286, 290, 292, 293, 296

I've accidentally deleted the function to delete color code in the player name before line 134. The following code needs to be added back (and optimized)
Code:
if TRP2_GetConfigValueFor("UseColorInChat",true) then
else
     personnage = TRP2_DeleteColorCode(personnage);
end

Changes to totalRP2_Interface/totalRP2_Interface_Main.lua:
TRP2_PlacerIconeCible():

replaced
Code:
local nom, royaume  = UnitName("target");
         if royaume then
              nom = nom.."-"..royaume;
         end
for
Code:
nom = TRP2_UnitNameWithRealm("target");
to always use the name with the format Player-Realm

replaced
Code:
if nom == TRP2_Joueur then
for
Code:
if TRP2_SimplifyNameIfPlayer(nom) == TRP2_Joueur then
to correctly compare the name of the unit to the name of the current player

replaced
Code:
TRP2_SetTooltipForFrame(TRP2_TargetButton,TRP2_TargetButton,"BOTTOMRIGHT",10,0,"{v}"..TRP2_nomComplet(nom,true));
for
Code:
TRP2_SetTooltipForFrame(TRP2_TargetButton,TRP2_TargetButton,"BOTTOMRIGHT",10,0,"{v}"..TRP2_nomComplet(TRP2_Joueur,true));
as this is about the current player tooltip, TRP2_Joueur is more relevant and is better than calling again TRP2_SimplifyNameIfPlayer(nom)

added
Code:
maitre = TRP2_SimplifyNameIfPlayer(maitre);
after
Code:
local nomPet, maitre = TRP2_RecupTTInfo();
if nomPet and maitre then
so if the owner of the pet is the current player his name is simplified

TRP2_MouseOverTooltip():

replaced
Code:
local Nom, royaume = UnitName(TT_Type);
    if royaume then
         Nom = Nom.."-"..royaume;
    end
for
Code:
local Nom = TRP2_UnitNameWithRealm (TT_Type);
to always get the full unit name

replaced
Code:
TRP2_TraiterTooltipPerso(Nom,infoTab,i,TT_Type,royaume);
for
Code:
TRP2_TraiterTooltipPerso(TRP2_SimplifyNameIfPlayer(Nom),infoTab,i,TT_Type,royaume);
for current player support

replaced
Code:
nomMaitre = TRP2_IsolerNomMaitre(nomMaitre);
for
Code:
nomMaitre = TRP2_SimplifyNameIfPlayer(TRP2_IsolerNomMaitre(nomMaitre));
for current player support

Changes to totalRP2_Inventaire/totalRP2_Inventaire_GestionSlot.lua:
TRP2_SlotOnDragStop() and TRP2_GoldOnDragStop():

replaced
Code:
local name, royaume = UnitName("mouseover");
              if royaume then
                   name = name.."-"..royaume;
              end
for
Code:
local name = TRP2_UnitNameWithRealm("mouseover");
to always get the full name

Changes to totalRP2_Inventaire/totalRP2_Inventaire_Main.lua:
TRP2_StartExchange() and TRP2_StartExchangeAsk():

replaced
Code:
local mouseover, realm = UnitName("mouseover");
         if realm then
              mouseover = mouseover.."-"..realm;
         end
local target, realm = UnitName("target");
         if realm then
              target = target.."-"..realm;
         end
for
Code:
local mouseover = TRP2_UnitNameWithRealm("mouseover");
local target = TRP2_UnitNameWithRealm("mouseover");
to always get the full name (also, it looks better, no? ^^)

replaced
Code:
elseif sender == UnitName("target") then
for
Code:
elseif sender == target then
to use the variable seen previously

TRP2_ExchangeReceiveTab():

replaced
Code:
if tostring(tab[1]) ~= TRP2_Joueur and tostring(tab[1]) ~= TRP2_Joueur.."-"..TRP2_Royaume then
for
Code:
if tostring(tab[1]) ~= TRP2_Joueur.."-"..GetRealmName():gsub("%s+", "") then
as TRP2_Royaume contains spaces.
Possible future optimisation :
Code:
if tostring(TRP2_SimplifyNameIfPlayer(tab[1])) ~= TRP2_Joueur then

Changes to totalRP2_Language/totalRP2_Language_Main.lua:

TRP2_TransformMessage():

added
Code:
TRP2_OpenPanelLangues();
at the beginning of the function. It doesn't open the panel but as it still launches the function, if it is the first time the player is using TRP, it will load the languages and the player will learn his default languages. This fix the bug with players unable to send messages.

removed that big block of nonsense
Code:
--if (TRP2_GetInfo(TRP2_Joueur,"Langues",{}) and TRP2_GetInfo(TRP2_Joueur,"Langues",{})[ID] and TRP2_GetInfo(TRP2_Joueur,"Langues",{})[ID]["bMother"]) or string.find(msg,"|H") or string.find(TRP2_DIALBASETAB[TRP2_enRace],ID) or string.sub(msg,1,1) == "|" then
         englishFaction, localizedFaction = UnitFactionGroup("player"); --Added by Ephedrae. ^ That breaks native race languages. Like Night elfs trying to speak darnassian ...
         if (TRP2_GetInfo(TRP2_Joueur,"SelectDial", select(1, GetDefaultLanguage("player"))) == GetDefaultLanguage("player")  and englishFaction == "Alliance") or (TRP2_GetInfo(TRP2_Joueur,"SelectDial", select(1, GetDefaultLanguage("player"))) == GetDefaultLanguage("player")  and englishFaction == "Horde") then --Exclude common/orcish from translation on their respective factions.
         TRP2_DernierePhrase = "";--Added by Lixxel. Clear out translation requests.
               return msg;--and just return the message. No translations!
    end
added variable
Code:
local msgTransformed = "";
to store the transformed message and leave msg intact

replaced
Code:
msg = msg..stringTab[texte];
for
Code:
msgTransformed = msgTransformed..stringTab[texte];
and
Code:
msg = "["..TRP2_GetWithDefaut(LangueTab,"Entete",ID).."] "..msg;
for
Code:
msgTransformed = "["..TRP2_GetWithDefaut(LangueTab,"Entete",ID).."] "..msgTransformed;
as texte contains the transformed messaged it is stored in that variable

add at the end of the function
Code:
-- Modified by Ellypse in version 1.023
    -- Return the original message if native language
    if TRP2_GetInfo(TRP2_Joueur,"Langues",{})[ID]["bMother"] or string.find(msg,"|H") or string.find(TRP2_DIALBASETAB[TRP2_enRace],ID) or string.sub(msg,1,1) == "|" then
         -- TRP2_GetInfo(TRP2_Joueur,"SelectDial", select(1, GetDefaultLanguage("player"))) -> Currently selected language localized
         -- GetDefaultLanguage("player") -> Faction language (Orcish or common) localized
         if TRP2_GetInfo(TRP2_Joueur,"SelectDial", select(1, GetDefaultLanguage("player"))) == GetDefaultLanguage("player") then
              TRP2_DernierePhrase = "";--Added by Lixxel. Clear out translation requests.
       end
       return msg;--and just return the message. No translations!
    end
    return msgTransformed;

The first condition means we are going to send the message untouched in that case. So for :
Code:
TRP2_GetInfo(TRP2_Joueur,"Langues",{})[ID]["bMother"]
means the language is one of all "mother" language of the player.
Code:
string.find(msg,"|H")
means the message is not RP (using parentheses or not an RP channel)
Code:
string.sub(msg,1,1) == "|"
means the message is an emote with the name of the player in front of it (/say | The wind is blowing)
Code:
string.find(TRP2_DIALBASETAB[TRP2_enRace],ID)
I admit I have no idea what this means x) It was there before, so I left it

then, the second condition
Code:
if TRP2_GetInfo(TRP2_Joueur,"SelectDial", select(1, GetDefaultLanguage("player"))) == GetDefaultLanguage("player") then
means that if the message is the faction language of the player (orcish or common), we are erasing TRP2_DernierePhrase, used later for translation request, as we do not need to translater that

If all the above are not true, we return the transformed message.

Changes to totalRP2_PlayerInfo/totalRP2_PlayerInfo_Main.lua:
TRP2_TraiterTooltipPet():

added
Code:
NomMaitre = TRP2_SimplifyNameIfPlayer(NomMaitre);
to get only the name of the player if it is the current player

replaced
Code:
if string.find(infoTab[2],NomMaitre) then
for
Code:
if string.find(infoTab[2],TRP2_RemoveRealm(NomMaitre)) or string.find(infoTab[3],NomMaitre:gsub("-.*", ""))  then
as the realm is not displayed in pets and companions tooltip we need to remove it from the owner name to compare it. Also, companions owners are now int the third line, not the second, so we need the second condition

replaced
Code:
local Phrase = "{w}< "..infoTab[2].." >";
for
Code:
local Phrase ="";
                   if string.find(infoTab[2],TRP2_RemoveRealm(NomMaitre)) then
                   Phrase = "{w}< "..infoTab[2].." >";
                   else
                   Phrase = "{w}< "..infoTab[3].." >";
                   end
to get the string "Player's pet" from the second line that's where it is or the third

replaced
Code:
Phrase = string.gsub(Phrase,NomMaitre,"{o}"..NomMaitre.."{w}");
for
Code:
Phrase = string.gsub(Phrase,NomMaitre,"{o}"..TRP2_RemoveRealm(NomMaitre).."{w}");
Well, if for some reason there is still the realm in that name... Honestly, I think this one is not useful.

TRP2_DD_PotraitIconeClick() (by the way, there's a typo in the functions name, might be corrected some day):

replaced
Code:
if not nom then
         nom, royaume = UnitName("target");
         if royaume then
              nom = nom.."-"..royaume;
         end
    end
for
Code:
if not nom then
         nom, royaume = UnitName("target");
         if not royaume then
              royaume = GetRealmName():gsub("%s+", "");
         end
         nom = nom.."-"..royaume;
    end
This is wrong and has to be replaced quickly for
Code:
local name = TRP2_UnitNameWithRealm("target");

replaced
Code:
if nom == TRP2_Joueur then
for
Code:
if nom == TRP2_Joueur.."-"..GetRealmName():gsub("%s+", "") then
consider using TRP2_SimplifyNameIfPlayer(nom) == TRP2_Joueur

replaced
Code:
info.text = TRP2_CTS(TRP2_FT(TRP2_LOC_FICHE,nom));
for
Code:
info.text = TRP2_CTS(TRP2_FT(TRP2_LOC_FICHE,TRP2_Joueur));
as we are talking about the current player we can use TRP2_Joueur

Changes to totalRP2_Registre/totalRP2_Registre_Main.lua:
TRP2_nomComplet():

added
Code:
local realm = string.gsub(nom,".*-","");
to store the realm attached to the unit name

removed
Code:
if royaume then
         Prenom = string.gsub(nom,"-"..royaume,"");
    end
for a better way of handling the realm in the player name

added
Code:
Prenom = string.gsub(Prenom, "-"..realm, "");
before the return statement, to remove the realm of the unit from its "prenom" (first name) if it is still there

TRP2_IsolerNomMaitre():

added
Code:
if not string.find(nomMaitre,"-") then
         nomMaitre = nomMaitre.."-"..GetRealmName():gsub("%s+", "");
    end
this is was added when testing and is wrong. It doesn't make the add-on bug but should be removed in the next version

_________________
Ellypse, Culte de la Rive Noire, FR
Moedra, Kirin Tor, FR
Maison Celwë'Belore, Officer
avatar
Ellypse
Admin

Posts : 215
Join date : 2013-09-26
Age : 26
Location : Paris, France

View user profile http://renaudparize.fr

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum