WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Moving PvP scoreboard (https://www.wowinterface.com/forums/showthread.php?t=54577)

TokyoGhost 10-01-16 10:37 AM

Moving PvP scoreboard
 
Hi there!

I was looking for addon that will make me be able to move "PvP objectives + score" frame located on middle top screen.

Since I don't wanna use MoveAnything for this simple action, I decided to write my own, first addon.

Can someone help me, where to start and what to do?

I have basic knoweledge of C, Perl and php, so getting into Lua won't be a problem.

Thank you!

Seerah 10-01-16 12:38 PM

Here's something to get you started. :)
http://wow.gamepedia.com/Making_drag...ames#Using_Lua

TokyoGhost 10-01-16 12:50 PM

Ill need help about this :P Can't I just use some old code and update it for current version of the game?

EDIT: found this: http://www.wowinterface.com/forums/s...ad.php?t=45570 Can I somehow use it? Ty

Phanx 10-01-16 01:02 PM

If you have some old code that moves a frame, the only thing you should need to change is the name of the frame it moves. None of the API functions/methods related to moving/dragging frames has changed since its inception about a decade ago, but the names of some default UI frames have been changed.

You can use the "/fstack" command in-game to find the names of frames, and browse the default UI source code if you need help figuring out the hierarchy of children and regions.

Torhal 10-01-16 05:36 PM

Quote:

Originally Posted by Seerah (Post 319569)
Here's something to get you started. :)
http://wow.gamepedia.com/Making_drag...ames#Using_Lua

A section of that page will be obsolete in 7.1; TitleRegion is being removed, so anything using one will need to be updated to use manual drag handlers.

TokyoGhost 10-05-16 02:38 PM

Quote:

Originally Posted by Torhal (Post 319584)
A section of that page will be obsolete in 7.1; TitleRegion is being removed, so anything using one will need to be updated to use manual drag handlers.

So then I will have to update this code Im using from Phanx?

Phanx 10-06-16 12:36 AM

Quote:

Originally Posted by TokyoGhost (Post 319697)
So then I will have to update this code Im using from Phanx?

The WorldStateFrame doesn't have (and has never had) a TitleRegion, so the code you are using is not affected.

TitleRegion objects are typically used on "panel" type frames like the character window, LFG window, etc. to enable dragging the window around by its title bar (hence the name). It's always been kind of a redundant object type, and seems to only exist to enable dragging with a few less lines of code. I am surprised to hear it's being removed, but that's because I generally expect Blizzard to lazily leave ancient legacy code (and sometimes just hilariously bad code in general) around for all eternity, not because the object type is actually useful. :p

With a title region:
Code:

local dragger = frame:CreateTitleRegion()
dragger:SetPoint("TOPLEFT")
dragger:SetPoint("TOPRIGHT")
dragger:SetHeight(20)

Without a title region:
Code:

local dragger = CreateFrame("Frame", nil, frame)
dragger:SetPoint("TOPLEFT")
dragger:SetPoint("TOPRIGHT")
dragger:SetHeight(20)

dragger:RegisterForDrag("LeftButton")

dragger:SetScript("OnDragStart", function()
    frame:StartMovingOrSizing()
end)

dragger:SetScript("OnDragStop", function()
    frame:StopMoving()
end)

Addons rarely, if ever, use a TitleRegion anyway because it handles the movement automatically -- it doesn't give you a way to detect when the frame stops moving so you can save the new position into your addon's saved variables.

TokyoGhost 10-06-16 01:29 AM

So basically, you are saying code you wrote is less likely to ever change and doesn't need any kind of updates?

Phanx 10-06-16 04:47 AM

Quote:

Originally Posted by TokyoGhost (Post 319705)
So basically, you are saying code you wrote is less likely to ever change and doesn't need any kind of updates?

It does not need any kind of updates now or in the known future, no.

I'm not sure what you're asking about it being "less likely to ever change" ... less likely than what? The whole topic of a TitleRegion is absolutely irrelevant to that code. I didn't have two options when I wrote the code, and chose the one I thought was more future-proof... the WorldStateFrame does not have, and has never had, a TitleRegion, so unless I wanted to create one (which I didn't, and pretty much never would in an addon, for reasons explained in my previous post) there was only one option, and that was to use OnDragStart/Stop scripts. I doubt the basic API for making a frame draggable will ever be changed. The TitleRegion object type is redundant, and its removal will affect a very small number of addons. The use of OnDragStart/Stop scripts is not redundant, and its removal would affect thousands of addons.

The only change I would expect the code in this thread to need an update for would be if Blizzard replaced the WorldStateFrame with something else, the way they replaced the old quest tracker frame with a totally new system in WoD. For something as small and simple as the WorldStateFrame, I'd rate the likelihood of such a change as "very low"


All times are GMT -6. The time now is 05:51 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI