project-navigation
Personal tools

Author Topic: Lazy battlescape HUD  (Read 10377 times)


Offline MCR

  • PHALANX veteran
  • ******
  • Posts: 1244
    • View Profile
Re: A try at a wheel-intensive HUD
« Reply #16 on: December 26, 2011, 10:10:00 pm »
Take a look @ hud_phone.ufo

There you can find something like this

Code: [Select]
panel actionselection_controls {
{
pos "0 0"
size "622 768"
ghost true
}

panel buttons {
{
pos "0 0"
size "122 768"
ghost true
layout LAYOUT_TOP_DOWN_FLOW
}
custombutton up {
size "122 148"
background "hudphone/sprites/button"
icon "hudphone/sprites/arrowup"
onClick {
*node:parent.parent.elements@viewpos = ( *node:parent.parent.elements@viewpos - 150 )
}
}
custombutton down {
size "122 148"
background "hudphone/sprites/button"
icon "hudphone/sprites/arrowdown"
onClick {
*node:parent.parent.elements@viewpos = ( *node:parent.parent.elements@viewpos + 150 )
}
}
custombutton cancel {
size "122 148"
background "hudphone/sprites/button"
icon "hudphone/sprites/cancel"
onClick {
*cvar:mn_controlaction_mode = ""
*cvar:mn_control_mode = ""
call *node:root.update_control_mode
// cancel the firemode aiming
cmd "hud_movemode"
}
}
}

panel elements {
{
pos "122 0"
size "500 768"
ghost true
layout LAYOUT_TOP_DOWN_FLOW
}

confunc hud_phone_actionlistener {
if (<1> eq "begin") {
call *node:parent@removeAllChild
// call *node:parent@createChild("cancel", "hud_phone_firemodeentry")
// call *node:parent.cancel.init_cancel
} elif (<1> eq "firemode") {
call *node:parent@createChild("<2>", "hud_phone_firemodeentry")
call *node:parent.<2>.init(<2>, <3>, <4>, <5>, <6>, <7>, <8>, <9>, <10>)
} elif (<1> eq "reaction") {
call *node:parent.<2>.init_reaction(<3>)
} elif (<1> eq "reload") {
call *node:parent@createChild("<2>", "hud_phone_firemodeentry")
call *node:parent.<2>.init_reload(<2>, <3>, <4>, <5>, <6>)
} elif (<1> eq "end") {
} else {
cmd "echo firemode_listener: unknown \"<1>\" command"
}
}

}
}

It does more or less what you need to get done (& several other things ;)) - the position of the panel elements is moved up/downwards by 150 point by clicking on the up/down buttons.

Another tip: Open the console and type "debug_ui 1" without quotes to enable the UI Debug mode. Could be very helpful :)

Offline homunculus

  • Sergeant
  • *****
  • Posts: 380
    • View Profile
Re: A try at a wheel-intensive HUD
« Reply #17 on: December 26, 2011, 10:20:27 pm »
:) relocating things works now.

hopefully assigning child node properties will also work in components.
then it should be just a bit of typing, as far as i can see.
unless... well, whatever.
« Last Edit: December 26, 2011, 10:22:54 pm by homunculus »

Offline geever

  • Project Coder
  • PHALANX Commander
  • ***
  • Posts: 2538
    • View Profile
Re: A try at a wheel-intensive HUD
« Reply #18 on: December 26, 2011, 10:48:19 pm »
Are you sure? or somebody implement it? i know it is a feature request only.

CVAR listener was available in C code before and mattn did the UI binding a few days ago.

-geever

Offline geever

  • Project Coder
  • PHALANX Commander
  • ***
  • Posts: 2538
    • View Profile
Re: A try at a wheel-intensive HUD
« Reply #19 on: December 26, 2011, 10:53:49 pm »
0. Thanks, that makes me feel better (it does feel bit strange doing things not according to spec otherwise).

My fault, I badly needed align functionality for images (in building preview window for 1x1 and 2x1 building images) so I've reused the textalign stuff and renamed to show it's not for text only anymore, but I missed the wiki documentation.... because... not even know where should I doc it, I don't get the system behind it and don't know if the auto-generated behaviour pages are really auto-generated, or generated by scripts a year ago or before...

-geever

Offline homunculus

  • Sergeant
  • *****
  • Posts: 380
    • View Profile
Re: A try at a wheel-intensive HUD
« Reply #20 on: December 27, 2011, 05:14:12 am »
Another curiosity:
Code: [Select]
confunc updateLevelStatus
{
*node:parent.controls.level.scroll@left = ((*cvar:cl_worldlevel * 50) / (*cvar:cl_maxworldlevel + 1))
// when i increase level from 0 to 1, i get this (and a crash):
// UI_GetNodeAbsPos: Node 'hud_wheel.controls.level.scroll' position 12.500000,0.000000 is not integer
}
Quote
left    V_FLOAT    Left position of the node (see also pos)
If 'left' and 'top' can be set as floats, it seems like those could be used as a way to enter 'pos' safely even if they might not be integers (seems the other way round atm--a way to enter invalid 'pos').
Probably same about 'width' and 'height', but didn't try those yet.

Any way I could force it to be int in my scipt?
« Last Edit: December 27, 2011, 05:15:43 am by homunculus »

Offline bayo

  • Professional loser
  • Project Coder
  • Captain
  • ***
  • Posts: 733
    • View Profile
Re: A try at a wheel-intensive HUD
« Reply #21 on: December 27, 2011, 11:13:00 am »
I dont remember a function to round the number


Offline bayo

  • Professional loser
  • Project Coder
  • Captain
  • ***
  • Posts: 733
    • View Profile
Re: A try at a wheel-intensive HUD
« Reply #22 on: December 27, 2011, 06:33:54 pm »
[...] and don't know if the auto-generated behaviour pages are really auto-generated, or generated by scripts a year ago or before...
I update the documentation and add comment into the page to explain how to update it. I also can create a script to autoupdate it, but not sure it is need.

Offline homunculus

  • Sergeant
  • *****
  • Posts: 380
    • View Profile
Re: A try at a wheel-intensive HUD
« Reply #23 on: December 31, 2011, 05:08:38 pm »
Code: [Select]
cmd "ui_addcvarlistener mn_rweapon_item testlistener;"Could not register change listener, cvar 'mn_rweapon_item' wasn't found

not that it would be the only way to do it.

Offline bayo

  • Professional loser
  • Project Coder
  • Captain
  • ***
  • Posts: 733
    • View Profile
Re: A try at a wheel-intensive HUD
« Reply #24 on: January 01, 2012, 09:45:23 am »
everything is on the comment.

listener do not work when:
* cvar do not exist and created later
* cvar is deleted and created again

Offline MCR

  • PHALANX veteran
  • ******
  • Posts: 1244
    • View Profile
Re: A try at a wheel-intensive HUD
« Reply #25 on: January 02, 2012, 01:04:32 pm »
homunculus, I already posted a link, where you can see how you can use the cvarlistener correctly, see above (second link in that post):

http://ufoai.ninex.info/forum/index.php/topic,6398.msg50074.html#msg50074

Offline homunculus

  • Sergeant
  • *****
  • Posts: 380
    • View Profile
Re: A try at a wheel-intensive HUD
« Reply #26 on: January 07, 2012, 06:04:24 am »
@MCR: Actually this is the very text I copy pasted from, and replaced with my own variable names.
So, I slowed down a bit, and tried the exact example with the insides of listener confunc replaced with echo, no error message but nothing was echoed.
The game says the update is from Dec 30 and the cvarlistener should be earlier, so I don't have many ideas at the moment.
BTW in the wiki there is such thing as spec about unimplemented but planned cvarfunc that should have done the same thing.
You were right about this thing taking more time than it looked like, I guess I'll get to the cvarlistener thing (or else a workaround) after some time.

At the moment I am doing weapon hands for the n-th time.
With moving panel visual that indicates scroll position: cannot set 'left' as float.
With double bar: the bars updating asynchronously looks wobbly.
With scrollable viewpos like in phone HUD: wheel-scrolling does not update mouse-over unless the mouse is moved (common case is the opposite), and the click seems to happen at the item that had the last mouse-over.
With one node that gets updated from invisible firemode data nodes with one bar as the visual: the scrolling seemed hard to control and the bar hard to read behind the text.
And even a little bit with vscrollbar: such a short scrollbar has the minimum bar size too long to be of any use.
 :P 8) :-[ (lots of drama)

And now I finally think I have a good version (people like images, i guess, so i'll post a little image).
A panel with firemodes is shown when the mouse enters the weapon area, and disappears when the mouse leaves the (weapon area + the panel with firemodes).
Could also be used to trigger the classic firemode selection without the extra click, I guess.
I wonder if I should make the firemode selection wheel-scrollable at all, because move-and-click seems more comfy than scroll-and-click.

Offline MCR

  • PHALANX veteran
  • ******
  • Posts: 1244
    • View Profile
Re: A try at a wheel-intensive HUD
« Reply #27 on: January 07, 2012, 10:18:58 am »
I think the cvarlistener confunc is just allowed to contain two parameters - oldValue of the cvar, and newValue of the cvar - maybe that is the problem, but I am not sure about that.

Again it seems I have to steal ;) some ideas from you - the MiniHUD has already "wheel-intensive" options integrated, but the weapon hand is not finished & final there either...

The only thing I can say about your other troubles is: There are always many roads, which lead to Rome, so if one thing does not work like intended there is another way that does for sure ;)

Other than that: Remember that this game is WIP as is the UI and you might find things that are not intended to work like they do, not only when scripting the UI.
So if you find obvious and reproducable bugs regarding UI script commands, please write a bugreport on our sourceforge tracker and let us know about it so it can be fixed...
Bayo, the master of the UIverse, usually fixes valid reported bugs with it quite quickly...

Bugtracker: http://sourceforge.net/tracker/?group_id=157793&atid=805242



Offline bayo

  • Professional loser
  • Project Coder
  • Captain
  • ***
  • Posts: 733
    • View Profile
Re: A try at a wheel-intensive HUD
« Reply #28 on: January 07, 2012, 06:43:13 pm »
Quote
master of the UIverse
i would prefer prince of the UIverse; i love Queen, but not He-Man ;)
BTW it sounds like a bug

Offline homunculus

  • Sergeant
  • *****
  • Posts: 380
    • View Profile
Re: A try at a wheel-intensive HUD
« Reply #29 on: January 17, 2012, 09:29:50 pm »
Trying to place the soldier selection near active soldier, either to the side or at the low edge of the screen below weapons and things, I unfortunately ended up making a few compromises in the intended placements, partially caused by the space reserved by the floor container (invisible in the shot as nothing is currently being d'n'd-d).
As for the looks of it, I think I am starting to like it, and hopefully the buttons might be ok in the grid as there are not too many, but that remains to be seen.

Well, here's something to entertain people a bit with: