Not logged inOpenClonk Forum
Up Topic Development / Developer's Corner / Landscape Coordinates <=> GUI Coordinates
- - By MimmoO Date 2010-05-06 13:22
hey. the ringmenu now uses GUI-coordinates, but how does those exactly work?

how do i calculate the gui-cooridnates from landscape coordinates and vice versa, or are those not connected in any way? how do i get the cursor gui-coordinates?
Parent - - By Newton [de] Date 2010-05-06 13:52
Didn't you read my pm reply? I already explained that.

Point is: I don't know what exactly you are planning, but I can tell you that you won't have to "calculate the gui-cooridnates from landscape coordinates" for whatever you are doing. Not as someone who is using the ring menu, anyway, because you don't need to forward the mouse events to the ring menu, the clonk control library does that. The clonk control library gets the gui-mouse-position events and feeds them into the menu. Interesting for the content developer are only the callbacks to the control/menu objects.

Regarding the positions:

  • A normal object that exists at position 100,100 is displayed at the position 100,100 relative to the landscape

  • An object with category C4D_Foreground (or possibly C4D_GUI soon) that exists at position 100,100 is displayed at the position 100,100 relative to the screen.


It is not possible to convert gui coordinates into landscape coordinates and it is also not needed.

What exactly do you want to do?
Parent - - By B_E [de] Date 2010-05-06 14:23

>C4D_Foreground (or possibly C4D_GUI soon)


Don't you mean C4D_Paralax? =)
Parent - - By Ringwaul [ca] Date 2010-05-06 16:16
Hmm, these are slightly different things. C4D_Parallax can make things move contrary to the screen's direction, and isn't meant to be for GUI as far as I can tell.
Reply
Parent - By Zapper [de] Date 2010-05-06 17:19

>and isn't meant to be for GUI as far as I can tell.


As is C4D_Foreground ;)
Parent - - By MimmoO Date 2010-05-06 14:41 Edited 2010-05-06 14:43
point is, that whatever i try, the ringmenu does not go to the position i want it to go.

i tried different parameters. at first i tried:

    menuitem=clonk->CreateRingMenu(Clonk,0,0,this);
(which is called by an object, which contains the clonk)
result: ringmenu in the top left corner

then:
    menuitem=clonk->CreateRingMenu(Clonk,GetX(),GetY(),this);
result: ringmenu almost on the position i want it to, but only in fullscreen mode. in developer mode, its somehow shifted. but acceptable...

now to an object the clonk carries. on ControlUse(), it calls:
Contained()->CreateRingMenu(SpellCaster,x+GetX(),y+GetY(),this);
result: the ringmenu appears somewhere aound the clonk. i couldnt figure out a pattern yet.
additionally, after i opened the ringmenu and chose a point, i cant use that object anymore. i need to ctrl+click (does that have any function yet?) and after that, i can use the object once again.
ControlUse() returns true.

the whole ControlUse() script is here: (with debuglogs)

func ControlUse(object clonk, int x, int y)
{
  Log("%d und %d",x,y);
  Contained()->CreateRingMenu(SpellCaster,x+GetX(),y+GetY(),this);
  for(var i=0; i<GetLength(spells); i++)  Contained()->GetMenu()->AddItem(spells);
  Contained()->GetMenu()->Show();
        return true; 
}
Parent - - By Newton [de] Date 2010-05-06 15:49
Hmm, right. Now I see your point and I have to admit that there is a design fault. The backpack button gets the current GUI mouse position and just creates the ring menu at that position. But you are right, this is not possible for any other call to CreateRingMenu because the gui cursor position is just not known during e.g. ControlUse.

The interface of the ringmenu should look like CreateRingMenu(object menuobject, object controlobject) because the ringmenu should always be created at the cursor position but can also be created at any time in any script. Somehow, The ring menu needs a way to retrieve the cursors gui position right in place, the solution of a property of a button to send gui-coordinates/cursor coordinates does not suffice here.

So ATM it is really not possible to create a correct ring menu at the right position and to make it possible will require engine changes. Sven, what do you say to this, how can this be solved?
Parent - - By Sven2 [de] Date 2010-05-07 15:03
fixed
Parent - By MimmoO Date 2010-05-07 15:12
/cheer Sven2
Up Topic Development / Developer's Corner / Landscape Coordinates <=> GUI Coordinates

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill