Detailed changes for version 1.025
Total RP 2 :: Development :: Discussion
Page 1 of 1
Detailed changes for version 1.025
You can find here the detailed changes for version 1.025
- Changes related to the new minimap icon:
New libraries :
added to totalRP2/libs :- AceDB-3.0
- CallbackHandler-1.0
- LibDataBroker-1.1
- LibDBIcon-1.0
totalRP2/embeds.xml
added- Code:
<Include file="libs\AceDB-3.0\AceDB-3.0.xml »/>
totalRP2/totalRP2.toc
added- Code:
## SavedVariables: totalRP2
added- Code:
libs\LibStub\LibStub.lua
libs\CallbackHandler-1.0\CallbackHandler-1.0.lua
libs\LibDataBroker-1.1\LibDataBroker-1.1.lua
libs\LibDBIcon-1.0\LibDBIcon-1.0.lua
totalRP2/totalRP2.lua
code to create the minimap button with its functions- Spoiler:
- Code:
-- Chargement de la librarie LibDGIcon-1.0 grâce à LibStub (gestionnaire de libraires)
local icon = LibStub("LibDBIcon-1.0")
-- Création d'un objet LDB, LibDataBroker, avec plusieurs attributs
local TRP2_MinimapButton = LibStub("LibDataBroker-1.1"):NewDataObject("TRP2_MinimapButton", {
type = "data source",
text = "Total RP 2",
icon = "Interface\\AddOns\\totalRP2\\Images\\icon.tga",
OnClick = function(clickedframe, button) if button == "LeftButton" then
TRP2_OpenMainMenu(not TRP2MainFrame:IsVisible());
elseif button == "RightButton" then
if TRP2_RaccBar:IsVisible() then
TRP2_RaccBar:Hide();
else
TRP2_RaccBar:Show();
end
end
end,
OnLoad = function() self:RegisterForClicks("LeftButtonUp","RightButtonUp");end,
OnTooltipShow = function(tooltip)
TRP2_Libs:Tooltip_LDB(tooltip)
end,
})
-- Populates the LDB tooltip
function TRP2_Libs:Tooltip_LDB(tooltip)
tooltip:AddLine("Total RP 2");
tooltip:AddLine(TRP2_LOC_CLIC.." : "..TRP2_LOC_OPENMENU);
tooltip:AddLine(TRP2_LOC_CLICDROIT.." : "..TRP2_LOC_OPENRACC);
end
-- Fonction qui se lance au chargement de l'addon
function TRP2_Libs:OnInitialize()
-- Enregistre une variable à partir de l'objet
self.db = LibStub("AceDB-3.0"):New("totalRP2", {
profile = {
minimap = {
hide = false,
},
},
})
icon:Register("TRP2_MinimapButton", TRP2_MinimapButton, self.db.profile.minimap)
end
totalRP2/totalRP2_UI_Interface.xml
Removed code related to the old minimap button- Spoiler:
- Code:
<!-- Bouton Mini Map -->
<Button name="TRP2_MinimapButton" parent="Minimap" frameStrata="LOW">
<Size x="32" y="32"/>
<Anchors>
<Anchor point="CENTER" x="0" y="0"/>
</Anchors>
<Layers>
<Layer level="NORMAL">
<Texture name="$parentIcon" file="Interface\AddOns\totalRP2\Images\icon.tga">
<Size x="18" y="18"/>
<Anchors>
<Anchor point="TOPLEFT" x="7" y="-7"/>
</Anchors>
</Texture>
</Layer>
<Layer level="OVERLAY">
<Texture name="$parentIcon" file="Interface\MINIMAP\MiniMap-TrackingBorder.blp">
<Size x="53" y="53"/>
<Anchors>
<Anchor point="CENTER" x="11" y="-11"/>
</Anchors>
</Texture>
</Layer>
</Layers>
<HighlightTexture file="Interface\Minimap\UI-Minimap-ZoomButton-Highlight" alphaMode="ADD"/>
<Scripts>
<OnClick>
if button == "LeftButton" then
TRP2_OpenMainMenu(not TRP2MainFrame:IsVisible());
elseif button == "RightButton" then
if TRP2_RaccBar:IsVisible() then
TRP2_RaccBar:Hide();
else
TRP2_RaccBar:Show();
end
end
</OnClick>
<OnLoad>
self:RegisterForClicks("LeftButtonUp","RightButtonUp");
</OnLoad>
<OnEnter>
TRP2_RefreshTooltipForFrame(self);
</OnEnter>
<OnLeave>
TRP2_MainTooltip:Hide();
</OnLeave>
</Scripts>
</Button>
- AceDB-3.0
- totalRP2/totalRP2_API.lua:
- TRP2_SimplifyNameIfPlayer(unit):
added a condition to check if the unit given is not null, as you cannot use gsub with a null argument. If it is null, we return null.- Code:
if unit then
local playerName, playerRealm = UnitFullName("player");
local senderName = string.gsub(unit, "-.*","");
local senderRealm = string.gsub(unit, ".*-","")
if senderRealm == playerRealm and senderName == playerName then
return playerName;
end
return unit;
end
return unit;
- TRP2_RemoveRealm(name):
same idea, new condition to check if the name is not null before doing anything- Code:
if name then
return string.gsub(name, "-.*","");
end
return name;
- TRP2_UnitNameWithRealm(unit):
A lot of changes to make it work in contexts where the unit passed is « mouseover » or « target », and also will only try to parse the full unite name (Name-Realm) if we can find a - .- Code:
-- if the unit passed is a unitID then we use that to determine the name and realm of that unit
if unit == "mouseover" or unit == "target" or unit == "player" then
name, realm = UnitName(unit);
elseif string.find(unit,"-") then
-- If it's not, we are parsing the unit name to separate the name from the realm
name = string.gsub(unit, "-.*","");
realm = string.gsub(unit, ".*-","")
else
name = unit;
end
-- If the realm is not defined then the unit is from our realm so we define it ourself
if not realm or realm == "" then
realm = GetRealmName():gsub("%s+", "");
end
if name and realm then
unit = name.."-"..realm;
end
return unit;
- New function : TRP2_UnitNameWithRealmByGUID(guid):
New function used to get the full names in chat messages.
Blizzard is being inconsistent… Chat messages in /say and /yell have their sender formatted as Player-Realm, but emotes has they sender sent as Player only if the realm is not necessary in this context. This function uses the GUID given by any message (a unique random identifier for each player) to get the sender’s name and realm.- Code:
-- Added by Ellypse
-- Used for getting the realm of the player via chat messages
function TRP2_UnitNameWithRealmByGUID(guid)
className, classId, raceName, raceId, gender, name, realm = GetPlayerInfoByGUID(guid);
if not realm or realm == "" then
realm = GetRealmName():gsub("%s+", "");
end
return name.."-"..realm;
end
- totalRP2_Config/totalRP2_Configuration_Main.lua:
Removed the code related to the old minimap button’s settings L. 347- Code:
{ -- ICONE PRINCIPALE
["Nom"] = "TRP2ConfigStringTRPIcon";
["Type"] = "Frame";
["Inherit"] = "TRP2_ListSeparator";
["Titre"] = "TRP2_LOC_PAR_ICONEMM";
["DiffX"] = 0;
["DiffY"] = -20;
},
{ -- Rotation Minimap
["Nom"] = "TRP2ConfigSliderMiniMapIconDegree";
["Type"] = "Slider";
["Inherit"] = "TRP2_SliderWithTitlePlusAndMinus";
["VarName"] = "MiniMapIconDegree";
["DiffX"] = 0;
["DiffY"] = -15;
["Default"] = 210;
["Titre"] = "TRP2_LOC_PAR_MMRotation";
["OnChange"] = function(self)
if not self._onsetting then -- is single threaded
self._onsetting = true
self:SetValue(self:GetValue())
value = self:GetValue() -- cant use original 'value' parameter
self._onsetting = false
else return end -- ignore recursion for actual event handler
-- end fix
TRP2_Module_Configuration[TRP2_Royaume][TRP2_Joueur][self.VarName] = TRP2_GetInt(value);
TRP2_IconePosition();
end;
["SliderMin"] = 0;
["SliderMax"] = 360;
["Width"] = 150;
},
{ -- Position Minimap
["Nom"] = "TRP2ConfigSliderMiniMapIconPosition";
["Type"] = "Slider";
["Inherit"] = "TRP2_SliderWithTitlePlusAndMinus";
["VarName"] = "MiniMapIconPosition";
["DiffX"] = 0;
["DiffY"] = -25;
["Default"] = 80;
["Titre"] = "TRP2_LOC_PAR_MMPosition";
["OnChange"] = function(self)
if not self._onsetting then -- is single threaded
self._onsetting = true
self:SetValue(self:GetValue())
value = self:GetValue() -- cant use original 'value' parameter
self._onsetting = false
else return end -- ignore recursion for actual event handler
-- end fix
TRP2_Module_Configuration[TRP2_Royaume][TRP2_Joueur][self.VarName] = TRP2_GetInt(value);
TRP2_IconePosition();
end;
["SliderMin"] = 0;
["SliderMax"] = 160;
["Width"] = 150;
},
{ -- Minimap à utiliser
["Nom"] = "TRP2ConfigEditBoxMiniMapToUse";
["Type"] = "EditBox";
["Inherit"] = "TRP2_EditBoxSmallText";
["VarName"] = "MiniMapToUse";
["DiffX"] = 0;
["DiffY"] = -25;
["Default"] = "Minimap";
["OnChange"] = function(self)
TRP2_Module_Configuration[TRP2_Royaume][TRP2_Joueur][self.VarName] = TRP2_EmptyToNil(self:GetText());
if getglobal(TRP2_GetConfigValueFor(self.VarName,"Minimap")) then
TRP2_IconePosition();
self.texte = TRP2_CTS("{o}"..TRP2_LOC_PAR_MMtoUse.." {v}(Ok)");
else
self.texte = TRP2_CTS("{o}"..TRP2_LOC_PAR_MMtoUse.." {r}(Outch!)");
end
end;
},
- totalRP2_Interface/totalRP2_Interface_GestionChatFrame.lua:
- TRP2_Hooking_FrameEvent():
added- Code:
arg2 = TRP2_UnitNameWithRealmByGUID(arg12);
- TRP2_AnalyserEmote(emote,perso,myChatFrame,event,coloredName):
changed- Code:
personnage = personnage..TRP2_GetWithDefaut(TRP2_GetInfo(TRP2_SimplifyNameIfPlayer(perso),"Registre",{}),"Prenom",TRP2_RemoveRealm(perso));
- Code:
prenom = TRP2_GetWithDefaut(TRP2_GetInfo(perso,"Registre",{}),"Prenom",TRP2_RemoveRealm(perso));
personnage = personnage..prenom;
NOTICE : While bugging I made it a two line instruction, but it might be better to go back to a one line instruction later
replaced- Code:
myChatFrame:AddMessage(TRP2_CTS(personnage.."|r "..string.sub(emote,string.len(perso)+2)),info.r,info.g,info.b,info.id);
- Code:
myChatFrame:AddMessage(TRP2_CTS(personnage.."|r "..string.sub(emote,string.len(Ambiguate(perso,"none"))+2)),info.r,info.g,info.b,info.id);
- totalRP2_Interface/totalRP2_Interface_Main.lua:
Removed the functions used to display the old minimap icon- Code:
-- Position de l'icone minimap
TRP2_IconePosition();
- Code:
function TRP2_IconePosition()
if getglobal(TRP2_GetConfigValueFor("MiniMapToUse","Minimap")) then
local x = sin(TRP2_GetConfigValueFor("MiniMapIconDegree",210))*TRP2_GetConfigValueFor("MiniMapIconPosition",80);
local y = cos(TRP2_GetConfigValueFor("MiniMapIconDegree",210))*TRP2_GetConfigValueFor("MiniMapIconPosition",80);
TRP2_MinimapButton:SetParent(getglobal(TRP2_GetConfigValueFor("MiniMapToUse","Minimap")));
TRP2_MinimapButton:SetPoint("CENTER",getglobal(TRP2_GetConfigValueFor("MiniMapToUse","Minimap")),"CENTER",x,y);
end
end
and
TRP2_SetTooltipForFrame(TRP2_MinimapButton,TRP2_MinimapButton,"LEFT",10,0,"{v}"..TRP2_LOC_TOTALRP,
"{j}"..TRP2_LOC_CLIC.." {w}: "..TRP2_LOC_OPENMENU.."\n{j}"..TRP2_LOC_CLICDROIT.." {w}: "..TRP2_LOC_OPENRACC);
- totalRP2_Language/totalRP2_Language_Main.lua:
line 634 modified- Code:
TRP2_SecureSendAddonMessage("LATR",requete,cible);
- Code:
TRP2_SecureSendAddonMessage("LATR",requete,cible,"ALERT");
- Code:
TRP2_SecureSendAddonMessage("LASN",textToSend,cible);
- Code:
TRP2_SecureSendAddonMessage("LASN",textToSend,cible, "ALERT");
Ellypse- Admin
- Posts : 215
Join date : 2013-09-26
Age : 33
Location : Paris, France
Similar topics
» Detailed changes for version 1.023
» Detailed changes for version 1.024
» Total RP 2 version 1.021 (and 1.022)
» New functions added in version 1.021
» Total RP 2 version 1.025
» Detailed changes for version 1.024
» Total RP 2 version 1.021 (and 1.022)
» New functions added in version 1.021
» Total RP 2 version 1.025
Total RP 2 :: Development :: Discussion
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|