Aller au contenu

Photo

XML function to return position of cursor on GUI


  • Veuillez vous connecter pour répondre
4 réponses à ce sujet

#1
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Is there an XML function which returns the position of the cursor on the GUI to the server?

#2
0100010

0100010
  • Members
  • 87 messages
No but you can use



OnMouseEnter=ExecueServerScript("gui_getapproxcurpos", xmin, ymin, xmax, ymax)



Where xmin = the x position of the object the callback is attached to, ymin is its y position, xmax = xmin plus the objects width, ymax = ymin plus the objects height. Or skip all relative position stuff that and pass in use some unique ID value that tells you which object is currently being hovered over.



This however gives you knowledge of the screen coordinates. I might not be entirely sure of your question. You can't get world (server map position) of the cursor without performing the click action of the ActionTarget script and thus obtaining the location data of the click point, in game.






#3
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Thanks for the response. I'll try to clarify my question.



I have created a GUI of an area in my game. It is an overhead map that looks alot like the map you can bring up in the game. I was wondering if it is possible to click on the GUI and send the location of the cursor on the GUI when it was clicked.



Example, if I clicked on a pixel with an x valuce of 56 and y value of 56 in the GUI, not the game screen, I would like to send that information back to an NWScript.



I was planning on making a system where I could scry locations in an area and using this GUI. i want the player to be able to click on the GUI and then scry the corresponding location in the Area.



I thought this might be possible since it is possible to click on the minimap and add cusom map points. That makes me think there must be some sort of communication going on there. I just am not sure if it accessible through XML or NWScript coding.



Your reply seems to be the answer I was looking for. When you write:



...This however gives you knowledge of the screen coordinates.




It seems that you mean that it gives you the coordinates of the cursor on the GUI that the callback is attatched to. Do I understand you properly?




#4
0100010

0100010
  • Members
  • 87 messages
Here is what you'll want to do.

Logically divide up your scry area into a grid, perhaps every 10 meters or so. How finely divided it will be is a matter of how much work you are willing to do.

Drop some waypoints labeled uniquely according to their grid position in your scry area.

On your scry gui overlay of the area map, you will create a grid of "buttons" (no textures or images just a object used to capture mouse clicks) Name the buttons to match your unique waypoints on a one to one basis.

Add a common OnClick callback to each one, and pass in a variable which identifies the tag of the target waypoint that grid button corresponded to. Now you know the destination the player has chosen.

Don't even try to go at a pixel by pixel basis unless you feel like making
1024x768 = 786,432 xml gui objects in your file with a size of 1 pixel each.

Modifié par 0100010, 31 décembre 2010 - 05:27 .


#5
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Thanks for the response. So I guess I'll just have to put a bunch of buttons on my UI and make them correspond with areas to scry. Thanks for the help.