project-navigation
Personal tools

Author Topic: Adding property to UI node spinner  (Read 6158 times)

Offline H-Hour

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 1923
    • View Profile
Adding property to UI node spinner
« on: December 24, 2011, 11:12:45 am »
I'm trying to add a width/height property to the spinner node. Currently they are fixed in the spinner code. (I know that I will also probably need to add a size property, but I'm trying one step at a time.)

So I've added the definition in ui_node_spinner.h and ui_node_spinner.c. And I added a width/height property to a spinner node in my custom UI .ufo file. But when I try to run it I get the following error:

Code: [Select]
------- input initialization -------
0 possible joysticks
no joystick found.
Allocate 2 megabytes for the ui hunkUI_InitializeNodeBehaviour: property 'width' from node behaviour 'spinner' overwrite another property
FS_RemoveFile: remove C:\Users\NateW\AppData\Roaming\UFOAI/2.4-dev/uidev/keys.cfg
There are still 1 opened files

Shutdown

You can see a diff with my changes here. I've also attached it to this post.

I'm not much of a coder so I probably went about it the wrong way... advice welcome.

Offline geever

  • Project Coder
  • PHALANX Commander
  • ***
  • Posts: 2561
    • View Profile
Re: Adding property to UI node spinner
« Reply #1 on: December 24, 2011, 12:30:21 pm »
Why don't U use the size property?

-geever

Offline H-Hour

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 1923
    • View Profile
Re: Adding property to UI node spinner
« Reply #2 on: December 24, 2011, 01:13:27 pm »
Geever, my understanding is that the TILE_SIZE specifies the spacing between different states in the spinner image file (ie - it is set to 32 because the top-left pixel of the disabled spinner in /pics/ui/spinner_blue.png is at 32x32). The BUTTON_TOP_SIZE and BUTTON_BOTTOM_SIZE specify the y-value of where the up or down buttons should be.

It is the SPINNER_WIDTH and SPINNER_HEIGHT values that actually specify the size of the portion of the image that is drawn. All will eventually need to be customizable for my changes to work properly. But for now I am just trying to get the width/height parameters added.
« Last Edit: December 24, 2011, 01:15:22 pm by H-Hour »

Offline geever

  • Project Coder
  • PHALANX Commander
  • ***
  • Posts: 2561
    • View Profile
Re: Adding property to UI node spinner
« Reply #3 on: December 24, 2011, 01:49:17 pm »
For every other node the size property determines the, well... the size of the node. Please don't add extra width and height parameters for that.

You are right about SPINNER_WIDTH and SPINNER_HEIGHT, if you get a closer look, you'll see they override node->size property in UI_SpinnerNodeLoaded. Please use node->size.

/off
awww, This node has way too much data hardcoded!!
/on

Edit: width and height are aliases to size[0] and size[1] AFAIR, maybe adding them to extradata failed due to that.

-geever
« Last Edit: December 24, 2011, 01:52:41 pm by geever »

Offline bayo

  • Professional loser
  • Project Coder
  • Captain
  • ***
  • Posts: 733
    • View Profile
Re: Adding property to UI node spinner
« Reply #4 on: December 25, 2011, 10:10:00 pm »
"width" and "height" are already used properties, then u can't define them again.

"Sprite" was done to allow better customization of this kind of nodes. I think we can convert that node to use 2 sprites. It should help you to do more things. Then, can you post somewhere the thing you want to create, then we can think about it better.

Offline H-Hour

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 1923
    • View Profile
Re: Adding property to UI node spinner
« Reply #5 on: December 25, 2011, 11:43:01 pm »
I only want to create a spinner with a different size. Other than the size restriction, the spinner is nice and easy for all those options panels.

Offline bayo

  • Professional loser
  • Project Coder
  • Captain
  • ***
  • Posts: 733
    • View Profile
Re: Adding property to UI node spinner
« Reply #6 on: December 26, 2011, 12:18:59 pm »
Which mean you want to stretch the current texture into the node size? in this case, geever is right, the node already have a size, you dont need to create another one.

Anyway, can you send the new skin you want to apply?

Offline H-Hour

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 1923
    • View Profile
Re: Adding property to UI node spinner
« Reply #7 on: December 26, 2011, 01:49:41 pm »
Anyway, can you send the new skin you want to apply?

I don't have a set graphic yet, so can't say precisely what the dimensions will be. But my main concern was that the checkbox is wider than the spinner, so I would probably try to choose something that had the same width as the checkbox in order to have a consistent line on the right.

Offline bayo

  • Professional loser
  • Project Coder
  • Captain
  • ***
  • Posts: 733
    • View Profile
Re: Adding property to UI node spinner
« Reply #8 on: December 26, 2011, 06:00:08 pm »
Ok, i think i can spend some time on it.

Offline bayo

  • Professional loser
  • Project Coder
  • Captain
  • ***
  • Posts: 733
    • View Profile
Re: Adding property to UI node spinner
« Reply #9 on: December 28, 2011, 12:55:50 am »
I push a "spinner2" node.

It use 3 sprites to draw the node. One for the background, one for the top arrow, one for the bottom arrow. All this 3 sprites are displayed in the center of the node and stacked. Then all should use the same size, and the node size should be the same too.

This way should also reduce/remove graphical glitch there is with some resolutions with the "old" spinner.

Here the component i used to test. And all images i posted also use a size of 20x20. But sure you can use the size you want.
Code: [Select]
component spinner2 myFunkySpinner {
size "20 20"
background "test/spinner"
topIcon "test/spinner_top"
bottomIcon "test/spinner_bottom"
}

Offline H-Hour

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 1923
    • View Profile
Re: Adding property to UI node spinner
« Reply #10 on: December 28, 2011, 08:28:50 am »
Thanks bayo! I'll give it a try soon.

Offline bayo

  • Professional loser
  • Project Coder
  • Captain
  • ***
  • Posts: 733
    • View Profile
Re: Adding property to UI node spinner
« Reply #11 on: December 28, 2011, 03:08:40 pm »