![]() |
Centering Level Text
1 Attachment(s)
Attached is a Target frame default (with a couple of modifacations) I was wondering how I would center the Level Text to look better?
I searcher playerframeleveltext and found this in the PlayerFrame.xml Code:
<FontString name="PlayerLevelText" inherits="GameFontNormalSmall"> Thanks Coke |
Lua Code:
|
The numbers in an AbsDimension inside an Offset inside an Anchor are just like the values you pass to SetPoint in Lua. The Lua equivalent of that XML would be:
Code:
<parent frame reference>:CreateFontString("PlayerLevelText", <draw layer>, "GameFontNormalSmall") |
so would this one:
Code:
<FontString name="$parentLevelText" inherits="GameFontNormalSmall"> Code:
TargetFrameLevelText:ClearAllPoints() |
well the numbers would probably be positive because the targetframe is reversed, but yeah
|
Quote:
Code:
5x CokeUI\Unitframes.lua:115: attempt to index global 'TargetFrameLevelText' (a nil value) |
You're getting that error because "$parent" (when creating an object) refers to the name of the object's immediate parent. In the case of the level text on the target frame, that parent isn't "TargetFrame" -- there's another frame in between:
http://www.townlong-yak.com/framexml...tFrame.xml#184 |
I think it need to be done in some kinda function because nothing seems to be moving it, maybe its because of me scaling it up not sure, but thanks for the attempt.
Coke |
On second glance at the relevant XML:
Code:
<FontString name="$parentLevelText" inherits="GameNormalNumberFont" justifyH="CENTER"> http://www.townlong-yak.com/framexml...argetFrame.lua and search through for "leveltext" and find this function: http://www.townlong-yak.com/framexml...tFrame.lua#302 which you can hook (using securehookfunc) to re-set your desired position after the default UI sets it. |
Quote:
Player: Code:
hooksecurefunc("PlayerFrame_UpdateLevelTextAnchor", function(level) Code:
hooksecurefunc("TargetFrame_UpdateLevelTextAnchor", function(self, targetLevel) Oh BTW thanks for the link to the lua on the web I like how you can click to follow functions. here is the code I found and I think is what I need to change but it doesn't seems to work (used deadmines normal as a test beings it shows the boss frames) Boss: Code:
hooksecurefunc("BossTargetFrame_OnLoad", function(self, unit, event) Coke |
You can't hook the OnLoad for a frame created in Blizzard XML. Well, you can, but it won't actually do anything, since OnLoad scripts are executed immediately when the frame is created, so by the time your addon code is running, the OnLoad is long since over and done with. You should just be able to set the scale once anywhere, even in the main chunk of your addon:
Code:
for i = 1, 5 do |
Quote:
Quote:
would I be able to put all this: Code:
-- Player Frame Code:
hooksecurefunc("UnitFrame_Update", function(self, level, targetLevel, isParty, isBossFrame) Coke |
No. When defining variables, you should limit them to the narrowest scope necessary. Likewise, when hooking functions, you should limit your hooks to the most specific functions necessary. If you're hooking a function for the purpose of moving the level text, you should hook the actual function that moves the level text, not some other function that calls the function that moves the level text, particularly in this case where you're running different code inside each different function hook. If you hooked UnitFrame_Update instead, you'd have to add additional logic to check which unit was being updated.
Some other things: Code:
hooksecurefunc("PartyMemberFrame_UpdateMember", function(self) You cannot move unit frames while in combat, so you need to check for InCombatLockdown() before attempting to move a unit frame. PartyMemberFrame_UpdateMember doesn't move the party frames, so hooking it is probably not a very good way to move the party frames. I don't know that the default UI ever moves the party frames, but if it does, you should find the function that actually does it, and hook that instead. If it doesn't, then you can just move them once and not worry about it. PartyMemberFrame_UpdateMember is called for each frame being updated, but you're updating all the frames there, leading to a lot of extra updates. Also, the default UI never calls SetScale on the party frames, so you can just do that once, as with the boss frames. Code:
if not ArenaEnemyFrame1 then Instead, if the arena frames don't exist yet, you should delay dealing with them until they are created: Code:
local function ScaleArenaFrames() And as for the boss frame code itself: Code:
if (event == "INSTANCE_ENCOUNTER_ENGAGE_UNIT") then However, the boss frames are already created when your addon loads, so you can just run your "for" loop right away; there's no need to delay or listen for any events. Overall your coding skills are improving. You're just overthinking/overcomplicating things here. :) |
Thank You again like always for the help.
I went with a simple approach when creating this new UI. If I would have kept on with BasicUI I would be totally lost. im using the (local _, ns = ...) for my variables then as you see in the code ns.variable. Everything so far seems to be going better no errors with boss fights (just doing the "for" instead of a function works great. Here is what my unitframe.lua looks like now. and these are the options for it: Code:
ns.unitframesEnable = true Coke |
Code:
if InCombatLockdown() == true then Code:
local addonTable = {} |
so would something like this work?
Code:
local partyPosition = CreateFrame("Frame") |
I think you missed the point of my last two posts, which is that as far as I can tell, the default UI never moves the party frames, so you do not need to hook any functions or wait for any events to move them. Just move them, without any wrapping:
Code:
PartyMemberFrame1:SetPoint(ns.unitframesPartyPosition.relAnchor, UIParent, ns.unitframesPartyPosition.offSetX, ns.unitframesPartyPosition.offSetY) |
Quote:
Thank You Coke |
Thank You
1 Attachment(s)
Phanx I just want to say Thank You for the help you have given me with coding, below is a screenshot of all the work (even tho to most it will look like the normal wow UI)
Coke |
All times are GMT -6. The time now is 01:11 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI