project-navigation
Personal tools

Author Topic: UI Adjustments.  (Read 34449 times)

Offline bayo

  • Professional loser
  • Project Coder
  • Captain
  • ***
  • Posts: 733
    • View Profile
Re: UI Adjustments.
« Reply #30 on: October 30, 2010, 12:52:02 am »
I fix that in the master and i move all samples to unittest/ufos/uisample.
Then, now, everything is checked, and we should have less regressions

Offline H-Hour

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 1923
    • View Profile
Re: UI Adjustments.
« Reply #31 on: October 30, 2010, 04:27:07 am »
I'm trying to change the cvar's for a bar node in a confunc that get's called when the player clicks an image. I'm getting the following error:

Code: [Select]
Com_EParseValue: Illegal float statement '*cvar:mn_tu0' (file: 'C:\Program Files (x86)\UFOAI\ufoai\src\client\ui\ui_parse.c', line: 272)
The code for the bar, image and confunc is:

Code: [Select]
bar team_sld0_status
{
pos "65 10"
size "4 46"
color ".2187 .73 .23 1"
current *cvar:mn_hp0
max *cvar:mn_hpmax0
disabled true
direction "uc"
excluderect { pos "0 0" size "4 46" }
}

...

// Select tu button
image showtu_btn {
align LAYOUTALIGN_MIDDLE
src "hhud/tm_sldbg_sel"
pos "27 10"
size "64 64"
onClick { cmd "showtu;" }
}
confunc showtu {
*node:root.team.team_sld0_status@color = ".65 .23 .23 1"
*node:root.team.team_sld0_status@current = *cvar:mn_tu0
*node:root.team.team_sld0_status@max = *cvar:mn_tumax0
}

Am I doing something wrong or is it not possible to reassign the @current and @max values for a node this way?

Offline mor2

  • Squad Leader
  • ****
  • Posts: 145
    • View Profile
Re: UI Adjustments.
« Reply #32 on: October 30, 2010, 12:12:58 pm »
@H-Hour, i understand you want to force an update but i dont think its how it works, the way i understand it 'current' is of type "V_CVAR_OR_FLOAT"
which i assume is ufoai for pointer to/or float, so you already linked the cvar to current and any change will be reflected when the bar gets an update event, which i assume the mouse movement trigger(among other things) the question if it tigers an update or if its call for specific nodes update (like the TU).


~unrelated questions:
1. if the above is correct what is the syntax difference between getting V_CVAR and its value?
2. how 'excluderect' work, if i place buttons on panel without a a background and exclude all of it, the buttons will keep receive mouse event, right?  (e.g. use ghost?)
also excluding a node, means that the node under it will receive the mouse event in order of creation with zone render being the last?
3. how does the nodes capture zone is defined? a square by the pos/size or by the image (if present) because i seen few none square buttons?

« Last Edit: October 30, 2010, 01:45:51 pm by mor2 »

Offline H-Hour

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 1923
    • View Profile
Re: UI Adjustments.
« Reply #33 on: October 30, 2010, 12:40:12 pm »
@H-Hour, i understand you want to force an update but i dont think its how it works, the way i understand it...

I'm sorry but I don't understand your explanation. I'm not really a programmer. If this won't work I can do it by creating multiple nodes and swapping them out with invis, but it would be better if I could update swap the data used for a single node.

Offline mor2

  • Squad Leader
  • ****
  • Posts: 145
    • View Profile
Re: UI Adjustments.
« Reply #34 on: October 30, 2010, 01:18:13 pm »
neither do i, i wanted to explain this by providing an example of actor_select but it looks like i was wrong. i think that 'updateactorvalues' from the parent ahud class is what you are looking for (its in the_hud file) do the same for onclick event. also maybe try "*cvar:mn_tu0"


if not you'll have to do as i do wait for someone who actually knows this stuff  ;)  (if someone like that comes, then some help with the question in my previous post will be greatly appreciated)
« Last Edit: October 30, 2010, 02:08:15 pm by mor2 »

Offline bayo

  • Professional loser
  • Project Coder
  • Captain
  • ***
  • Posts: 733
    • View Profile
Re: UI Adjustments.
« Reply #35 on: October 31, 2010, 11:10:16 am »
I update the parser to allow to edit at runtime cvar name embedded into a property. Then u must use last commits.

This syntax set the value of the cvar to the property. If the cvar change, the property do NOT change.
Code: [Select]
*node:root.team.team_sld0_status@current = (*cvar:mn_tu0)It should work without parenthesis too, but i dont check it.

This syntax link the cvar to the property. If the cvar change, the property change.
Code: [Select]
*node:root.team.team_sld0_status@current = "*cvar:mn_tu0"

Offline bayo

  • Professional loser
  • Project Coder
  • Captain
  • ***
  • Posts: 733
    • View Profile
Re: UI Adjustments.
« Reply #36 on: October 31, 2010, 11:22:49 am »
Quote
1. if the above is correct what is the syntax difference between getting V_CVAR and its value?
You can't get the cvarname from a property. Anyway, I dont think it mean something, cause it is an abstraction.

Quote
2. how 'excluderect' work, if i place buttons on panel without a a background and exclude all of it, the buttons will keep receive mouse event, right?  (e.g. use ghost?)
also excluding a node, means that the node under it will receive the mouse event in order of creation with zone render being the last?
excluderect and ghost is the samething. The node will not receive events from the mouse. It is like there is not this node, then the parent node, or the node under it will receive the event.

In the case of bar:
* "readonly" property is more interesting
* "ghost" will do something like the same job, but without the right semantic
* "excluderect" on the full node size will do the same job as ghost, but it will be harder to manage

Quote
3. how does the nodes capture zone is defined? a square by the pos/size or by the image (if present) because i seen few none square buttons?
Only with the box of pos and size, and all parents pos and size. It mean a node must be inside his parent box, else we can't click on it (and we can't see it too).

Offline H-Hour

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 1923
    • View Profile
Re: UI Adjustments.
« Reply #37 on: October 31, 2010, 11:24:50 am »
The cvar thing works great. Thanks for the fast fix bayo.

Offline bayo

  • Professional loser
  • Project Coder
  • Captain
  • ***
  • Posts: 733
    • View Profile
Re: UI Adjustments.
« Reply #38 on: October 31, 2010, 11:41:17 am »
It looks (without parenthesis or quotes)
Code: [Select]
*node:root.team.team_sld0_status@current = *cvar:mn_tu0now work like a link (same as syntax with quotes).

No idea if it is good or bad.

The quote syntax is not very nice, but i am sure the one without anything is ambiguous with the one with parenthesis.

Offline mor2

  • Squad Leader
  • ****
  • Posts: 145
    • View Profile
Re: UI Adjustments.
« Reply #39 on: October 31, 2010, 03:13:23 pm »
thanks bayo, yesterday i decided to move from the planing stage and actually do something (so i can better understand how it works and what is possible) for the first time i spent some time working on it instead of just brief looks at it, so after 3 hours of mostly rearranging the file to my liking i finished it, i now have a working bottom bar with all the graphics and basic functions i intend to add.

its actually more simple than i though, thou i am still uncomfortable with some of the syntax, for example can i do this:
Code: [Select]
cmd "mn_modify *cvar:group +1 0 1;"
call *node:root.hudenable
and if so, will this?
Code: [Select]
onClick { cmd "actor_select (2 + (*cvar:group * 8)" } intended to work as either actor_select 2 or 10.


Quote
In the case of bar:
* "readonly" property is more interesting
then i should use the 'readonly' instead of the current used 'disable' property?


also is there some kind of array declaration or any chance i am allowed to declare something like that:
Code: [Select]
while (*cvar:i ...) {
*cvar:temp<*cvar:i> = 0
}

because
*cvar:temp0=
*cvar:temp1=
...
*cvar:temp7=
is just so wasteful, when all i need is 3...  


and last, according to this the button node has very limited use for 64x64 buttons, any chance there is some kind of hidden property that allows me to set the size for example 120x60 or should i stick with image and keep playing with the texl texh.


EDIT: sorry last, last (i am not near the pc with script, so i do this from memory and stuff just keep poping up into my head)
in the battlescape UI we use container node i want to display the weapon, so supposedly this should work:
Code: [Select]
displayammoofweapon truebut it doesnt, why? i also checked the equipment script and it used a different node for that called baseinventory which has no documentation of but in the container comments its mentioned, so should i work with baseinventory then?


thanks.
« Last Edit: October 31, 2010, 03:44:21 pm by mor2 »

Offline bayo

  • Professional loser
  • Project Coder
  • Captain
  • ***
  • Posts: 733
    • View Profile
Re: UI Adjustments.
« Reply #40 on: October 31, 2010, 05:38:28 pm »
Code: [Select]
cmd "mn_modify *cvar:group +1 0 1;"I remove mn_modify from 2.4.
It is more understandable to use math. For example (only an example, cause i dont remember mn_modify param and results):
Code: [Select]
*cvar:group = ((*cvar:group + 1) % 2)
Code: [Select]
call *node:root.hudenableFunction also support params. I dont know what u want to do, but it is often more easy to use params. Check unittest/uisample/* or unittest/uitest for examples.

Code: [Select]
onClick { cmd "actor_select (2 + (*cvar:group * 8)" }Everything inside quote is not evaluated, else very simple replacement using "<>".
Code: [Select]
onClick {
    *cvar:tmp = (2 + (*cvar:group * 8))
    cmd "actor_select <cvar:tmp>"
    delete *cvar:tmp
}

Quote
then i should use the 'readonly' instead of the current used 'disable' property?
Yes, 'disable=true' also should to the same result, but it is also not the same sementic. For example, disable should display bar with a grey color (but we dont do it at the moment).

Code: [Select]
*cvar:temp<*cvar:i>Thing like that should work. It can exists some case work it dont work, but in this case, we must fix it. Only rememeber to delete cvar when you no more need it, cause it is global values.

Quote
and last, according to this the button node has very limited use for 64x64 buttons, any chance there is some kind of hidden property that allows me to set the size for example 120x60 or should i stick with image and keep playing with the texl texh.
This is a constraint only for the skin of the random size button, not on the button size itself. You also can use "custombutton" which have is own contraint too. I should rework every about tiles. But i dont know when i will do it, if i do it one day. I think i easily can remove contraintes on the "custombutton".

About "displayammoofweapon", yes, it only work with "baseinventory". The "baseinventory" node display all items from a base in a scrollable container. It is not created for soldiers. To display ammo, we must use a "model" or an "item" node, but it also need to update the .c code somewhere, like we do it with soldier weapon. If it is need, i can do it.

Quote
for that called baseinventory which has no documentation
I will add now a cron to update wiki doc every day.

Offline mor2

  • Squad Leader
  • ****
  • Posts: 145
    • View Profile
Re: UI Adjustments.
« Reply #41 on: October 31, 2010, 07:05:18 pm »
Everything inside quote is not evaluated, else very simple replacement using "<>".
not evaluated? you mean in cmd, string or generally expression are not evaluated when injected?


Quote from: bayo
It is more understandable to use math.
it is more readable but unlike mn_modify you cannot use it with cmd, so like in the example before you get additional 2 lines to clutter the screen.  :(


Quote from: bayo
Thing like that should work. It can exists some case work it dont work, but in this case, we must fix it. Only rememeber to delete cvar when you no more need it, cause it is global values.
interesting, any chance i can create nodes this way as well? maybe with abstractnode createChild method?   i tried looking into it but coldnt find any documentation on how to use it...

the reason i want this is that yesterday i was dumb founded by the amount of manual data entry i has to do and would have to do again, for every ;ittle fix.
for a team of 8, i got: 8 head nodes, 8 models nodes, 3*8 bar nodes, 8 name nodes etc all of them with at least 5 properties, its ammounts to a shit load of lines, and its only 8!   >:(    

i was thinking on something along those lines:
Code: [Select]
confunc hudenable
{
*cvar:team_size = <1>
*cvar:position = 0
*cvar:i = 1

while ( *cvar:i < *cvar:team_size ){
call *node:root.team@createChild( ???   model head<*cvar:i> )
*node:root.team.head<*cvar:i>@src = *cvar:mn_head<*cvar:i>
*node:root.team.head<*cvar:i>@angles = "15 60 100"
*node:root.team.head<*cvar:i>@autoscale = true

*cvar:position = * 200 + (*cvar:i * 60 )
*node:root.team.head<*cvar:i>@pos = "<*cvar:position> 20"

*node:root.team.head<*cvar:i>@size = "50 78"
*node:root.team.head<*cvar:i>@ghost = true


same with the rest bars, strings etc nodes...
call *node:root.team@createChild ???  image bar_teambox<*cvar:i>
*node:root.team.bar_teambox<*cvar:i>@src

*cvar:i++
}
clean
}
is it possible? and is there some kind of documentation(or c declarations) on createChild and the like ?


Quote from: bayo
About "displayammoofweapon", yes, it only work with "baseinventory". The "baseinventory" node display all items from a base in a scrollable container. It is not created for soldiers. To display ammo, we must use a "model" or an "item" node, but it also need to update the .c code somewhere, like we do it with soldier weapon. If it is need, i can do it.
my best guess will be to add another container nodes for L/R ammo?
i mean there is already containers for: extension, right,left,backpack,belt,holster,headgear,armour   
why not for right_ammo, left_ammo, no?
« Last Edit: October 31, 2010, 07:23:26 pm by mor2 »

Offline bayo

  • Professional loser
  • Project Coder
  • Captain
  • ***
  • Posts: 733
    • View Profile
Re: UI Adjustments.
« Reply #42 on: October 31, 2010, 09:28:43 pm »
Quote
not evaluated?
cmd is like executing a shell command. It can't evaluate math operations.

Quote
interesting, any chance i can create nodes this way as well? maybe with abstractnode createChild method?
You can check unittest/ufos/uisample/unittest_nodeallocation.ufo. I think it is not very easy to use atm. I can create a little documentation. But you also should check "component" code too, it is also not fully usable, but it is useful. Anyway there is also an example in unittest_nodeallocation.ufo

Quote
my best guess will be to add another container nodes for L/R ammo?
I dont think. But it depend where you talking about. For the weapon container from the solider inventory, we can edit the containe code to display the ammo. But for the HUD, i dont know.

Offline mor2

  • Squad Leader
  • ****
  • Posts: 145
    • View Profile
Re: UI Adjustments.
« Reply #43 on: October 31, 2010, 09:52:39 pm »
1. ok, np.
2. where are all those "unittest/ufos/uisample/unittest_nodeallocation.ufo" examples you point me to? its not in the ufos.pk3 nor i seen it in the src folder  ???
3. i mean for our weapon/ammo concept,  for example like here.
all we need is something to show the ammo near the weapon, if you can make it in separate nodes then its will be more flexible but displayammoofweapon property will work too (i can always use them as ghost and place two buttons above it to capture onclick event over the weapon and over the ammo)

thanks.

Offline bayo

  • Professional loser
  • Project Coder
  • Captain
  • ***
  • Posts: 733
    • View Profile