Lua code for name and portrait
Code:
function MyReputationFrame_OnLoad (self)
self:RegisterEvent("UNIT_NAME_UPDATE");
self:RegisterEvent("UNIT_PORTRAIT_UPDATE");
end
function MyReputationFrame_OnEvent (self, event, ...)
if ( not self:IsShown() ) then
return;
end
local arg1 = ...;
if ( event == "UNIT_PORTRAIT_UPDATE" ) then
if ( arg1 == "player" ) then
SetPortraitTexture(MyReputationPortraitFrame, arg1);
end
return;
elseif ( event == "UNIT_NAME_UPDATE" ) then
if ( arg1 == "player" ) then
CharacterNameText:SetText(UnitName(arg1));
end
end
end
function MyReputationFrame_OnShow (self)
SetPortraitTexture(MyReputationPortraitFrame, "player");
CharacterNameText:SetText(UnitName("player"));
end
This is the xml frame for the portrait.
Code:
<Frame name="PortraitFrame">
<!--<FrameSkin skinid="f15d4970-d66d-444e-bb2d-1ad102c87fed" frameid="f15d4979-d66d-444e-bb2d-1ad102c87fed" />-->
<Size>
<AbsDimension x="54" y="54" />
</Size>
<Anchors>
<Anchor point="TOPLEFT">
<Offset>
<AbsDimension x="7" y="-7" />
</Offset>
</Anchor>
</Anchors>
<Layers>
<Layer>
<Texture name="$parentTexture" setAllPoints="true">
<TexCoords left="0" right="1" top="0" bottom="1" />
</Texture>
</Layer>
</Layers>
</Frame>
This is the xml frame for the character name.
Code:
<Frame name="NameFrame">
<!--<FrameSkin skinid="f15d4970-d66d-444e-bb2d-1ad102c87fed" frameid="f15d4978-d66d-444e-bb2d-1ad102c87fed" />-->
<Size>
<AbsDimension x="247" y="32" />
</Size>
<Anchors>
<Anchor point="TOPLEFT">
<Offset>
<AbsDimension x="265" y="-7" />
</Offset>
</Anchor>
</Anchors>
<Layers>
<Layer>
<FontString name="$parentLabel" setAllPoints="true" font="Fonts\FRIZQT__.TTF" justifyH="LEFT">
<FontHeight>
<AbsValue val="12" />
</FontHeight>
<Color r="1" g="0.8196079" b="0" />
<Shadow>
<Color r="0" g="0" b="0" />
<Offset>
<AbsDimension x="1" y="-1" />
</Offset>
</Shadow>
</FontString>
</Layer>
</Layers>
</Frame>
Any help would be greatly appreciated...thx in advance|||Problem solved. Managed to sort out the issue by accident. A little advice would have been appreciated....|||For those curious seenig as its a hot topic...below are the snippets I used.
replace YOURMOD with the name of you own mod and the AAAA with a unique identifier for your mod frame. Also place the xml code at the beginning of your frame on the next line after the </Anchors> tag and hopefully it should work for you too. (NO GUARANTEES)
the main Lua file:
Code:
function YOURMODFrame_OnLoad ()
this:RegisterEvent("VARIABLES_LOADED");
this:RegisterEvent("ADDON_LOADED");
this:RegisterEvent("PLAYER_LOGOUT");
end
function YOURMODFrame_OnShow (self)
SetPortraitTexture(AAAACharacterFramePortrait, "player");
AAAACharacterNameText:SetText(UnitPVPName("player"));
end
in the xml file at the beginning:
Code:
<HitRectInsets>|||Oh and I forgot to add the code for the base of the xml I used.
<AbsInset left="0" right="30" top="0" bottom="45"/>
</HitRectInsets>
<Layers>
<Layer level="ARTWORK">
<Texture name="AAAACharacterFramePortrait">
<Size>
<AbsDimension x="60" y="60"/>
</Size>
<Anchors>
<Anchor point="TOPLEFT">
<Offset>
<AbsDimension x="36" y="-22"/>
</Offset>
</Anchor>
</Anchors>
</Texture>
</Layer>
</Layers>
<Frames>
<Frame name="AAAACharacterNameFrame">
<Size>
<AbsDimension x="335" y="32"/>
</Size>
<Anchors>
<Anchor point="TOPLEFT">
<Offset>
<AbsDimension x="126" y="-34"/>
</Offset>
</Anchor>
</Anchors>
<Layers>
<Layer>
<FontString name="AAAACharacterNameText" inherits="GameFontNormal" text="NAME">
<Size>
<AbsDimension x="96" y="-34"/>
</Size>
<Anchors>
<Anchor point="CENTER"/>
</Anchors>
<Color r="1.0" g="1.0" b="1.0"/>
</FontString>
</Layer>
</Layers>
<Scripts>
<OnLoad function="RaiseFrameLevel"/>
</Scripts>
</Frame>
<Scripts>
<OnLoad function="YOURMODFrame_OnLoad"/>
<OnEvent function="YOURMODFrame_OnEvent"/>
<OnShow function="YOURMODFrame_OnShow"/>
<OnHide function="YOURMODFrame_OnHide"/>
</Scripts>
</Frame>
</Frames>
</Frame>
</Ui>
No comments:
Post a Comment