UFO:Alien Invasion

Development => Coding => Topic started by: H-Hour on December 24, 2011, 03:56:03 pm

Title: Adding a node on top of the dragButton area in UI window
Post by: H-Hour on December 24, 2011, 03:56:03 pm
A window node has the ability to set closebutton and dragbutton, which automatically places nodes for closing and dragging the window.

I would like to keep the dragbutton option but use my own custom node for closebutton. However, because the dragbutton is added after the UI script is read, it "covers up" my closebutton, so I can't place my own clickable node over the drag area.

Is there any way to add a node on top of another node that is added automatically? Or, alternatively, is there a way I can create a a custom node that will have the drag functionality?

The attached image shows the default closebutton. If I remove the closebutton from the window and then add a node in roughly the same place with the same functionality, it doesn't work because the dragbutton area covers it up.
Title: Re: Adding a node on top of the dragButton area in UI window
Post by: MCR on December 24, 2011, 04:21:37 pm

Use this before you place your close button on top of it.

Code: [Select]
controls drag {
               tooltip   "_LMB:Drag/RMB:Close"
               pos        "x y"
               size       "x y"
               OnRClick { cmd "ui_pop;" }
       }
Title: Re: Adding a node on top of the dragButton area in UI window
Post by: MCR on December 24, 2011, 04:23:28 pm
Here I used this technique to extend the drag controls over the whole window for inventory and physdata:

http://ufoai.git.sourceforge.net/git/gitweb.cgi?p=ufoai/ufoai;a=blobdiff;f=base/ufos/ui/inventory.ufo;h=64fd86e6e82fd3a8a5cf3114637e81c703eb7244;hp=e8238c00d5c20a4eb38ac8a8f18d804c6bbdf45e;hb=e595912a131da704fc4a82d41d12b90a847f6ad1;hpb=a9ce63d36594871ceede5f704d8fde1245dca341

http://ufoai.git.sourceforge.net/git/gitweb.cgi?p=ufoai/ufoai;a=blobdiff;f=base/ufos/ui/physdat.ufo;h=a20ee92a0c7ef1fd02e658647bffa89e587816d4;hp=e8782c24842b02e3a2fd471f500caeaff1fa7b91;hb=a9ce63d36594871ceede5f704d8fde1245dca341;hpb=2a3e6cc5063fe834b69fc1f0d650420fa74f3826

& the exit button for those windows is on top of the drag controls or in the script code below of them.
Title: Re: Adding a node on top of the dragButton area in UI window
Post by: geever on December 24, 2011, 04:34:49 pm
As MCR found out, you can't change the layout but you can use a custom drag node (controls).

-geever
Title: Re: Adding a node on top of the dragButton area in UI window
Post by: H-Hour on December 24, 2011, 04:37:08 pm
thanks guys, will try it
Title: Re: Adding a node on top of the dragButton area in UI window
Post by: H-Hour on December 24, 2011, 09:00:57 pm
Worked perfectly, thanks. But the wiki says the node type is going to be removed... (http://ufoai.ninex.info/wiki/index.php/UI_node_behaviours/2.4-dev#controls)
Title: Re: Adding a node on top of the dragButton area in UI window
Post by: geever on December 24, 2011, 09:33:10 pm
Actually the window node creates a controls subnode dynamically, so it won't disappear without notice.

-geever
Title: Re: Adding a node on top of the dragButton area in UI window
Post by: bayo on December 25, 2011, 09:50:13 pm
The problem is it can became a mess to recode everytime you need a movable window with this layout. I think there is some easy way to code "window" node customization with scripts. But the full system still need fixe (padding-top with influencies into child node, which IMO will broke everything) to be better.