Thread Tools Display Modes
10-01-16, 10:37 AM   #1
TokyoGhost
Guest
Posts: n/a
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!
  Reply With Quote
10-01-16, 12:38 PM   #2
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Here's something to get you started.
http://wow.gamepedia.com/Making_drag...ames#Using_Lua
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
10-01-16, 12:50 PM   #3
TokyoGhost
Guest
Posts: n/a
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

Last edited by TokyoGhost : 10-01-16 at 01:00 PM.
  Reply With Quote
10-01-16, 01:02 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
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.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
10-01-16, 05:36 PM   #5
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
Originally Posted by Seerah View Post
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.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
10-05-16, 02:38 PM   #6
TokyoGhost
Guest
Posts: n/a
Originally Posted by Torhal View Post
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?
  Reply With Quote
10-06-16, 12:36 AM   #7
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by TokyoGhost View Post
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.

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.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
10-06-16, 01:29 AM   #8
TokyoGhost
Guest
Posts: n/a
So basically, you are saying code you wrote is less likely to ever change and doesn't need any kind of updates?
  Reply With Quote
10-06-16, 04:47 AM   #9
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by TokyoGhost View Post
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"
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Moving PvP scoreboard

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off