project-navigation
Personal tools

Author Topic: Question on List Formatting  (Read 9813 times)

Offline Battlescared

  • Squad Leader
  • ****
  • Posts: 107
    • View Profile
Question on List Formatting
« on: May 21, 2012, 11:55:28 pm »
Hi,

I thought I'd take a stab at modifying the transfer screen to tell me how much of each item is at a destination site.  Figured that out, great, but for the life of me I can't figure out how the string is actually formatted for display on screen.  My small mod works ok for low quantities, though a bit ugly.  I chose to just add it to the "amounts" list and if there is more than 0 items at the destination site, display it in the same field, with a simple separator char to distinguish the two numbers.  Seemed the easiest way with least impact.  But if the item number gets over 2 chars at each site, then the display reads "..." since it can't fit the required chars into the space provided.

I'd like to clean it up and submit for your approval, assuming I can get it looking halfway decent, but I can't seem to figure out where the formatting or control of the field width is provided.  It seems to be shot off into the global void where some function not related to the actual transfer screen functions picks it up and decides what to do with it, and I don't see where that is.  Can anyone give me a quick synopsis on it and where to look?

Offline H-Hour

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 1923
    • View Profile
Re: Question on List Formatting
« Reply #1 on: May 22, 2012, 12:01:16 am »
/base/ufos/ui/transfer.ufo

That is the UI script file that handles the transfer window. The UI is constructed of different nodes which can display different things and have different properties. Read more about the UI system here and especially the node properties here.

I think you can bring down the console and type ui_push editor. That will give you a little interface you can use to look at the nodes. You can find out the node name that way to easily find it in transfer.ufo.

Offline Battlescared

  • Squad Leader
  • ****
  • Posts: 107
    • View Profile
Re: Question on List Formatting
« Reply #2 on: May 22, 2012, 12:08:45 am »
Thank you, H-hour.  That should get me started.  I hadn't started looking at the scripting yet.

Offline Battlescared

  • Squad Leader
  • ****
  • Posts: 107
    • View Profile
Re: Question on List Formatting
« Reply #3 on: May 22, 2012, 01:14:04 am »
Well, now I'm even more confused.  I have no script files on my 2.4/base install, just ones under unittest.  I see the base/etc.../*.ufo scripts in my old 2.2 and 2.3 installation directories, but I have nothing in the 2.4.  I know I have compiled them in because the there are UI's that are different in 2.4 from 2.3 and earlier.  The game is working fine.

I downloaded the sources listed http://ufoai.org/wiki/index.php/Download and extracted.  Are they by chance in the .pk3 files now?  And I need to extract them?  I don't see anything like that mentioned in the wiki, but there are only *.pk3 files under base.

Offline Battlescared

  • Squad Leader
  • ****
  • Posts: 107
    • View Profile
Re: Question on List Formatting
« Reply #4 on: May 22, 2012, 01:36:08 am »
Ok, figured out the ui editor, sort of.  I was able to modify the field width in there and found the extracted window in my local directory.  The editor could really use some better documentation, but I guess it worked.

I guess I can submit the extracted window script file as part of a solution when I'm done.  I am not sure how to make it part of the game, but if you like the change I come up with, you can decide how to make that happen.  If not at least I'll know how to modify it for my games in the future.

Offline DarkRain

  • Project Coder
  • Captain
  • ***
  • Posts: 746
    • View Profile
Re: Question on List Formatting
« Reply #5 on: May 22, 2012, 01:45:32 am »
Yes, the *.ufo files should be in one of the *.pk3 (ufos.pk3), its a simple zip file so you can extract them easily.

Offline Battlescared

  • Squad Leader
  • ****
  • Posts: 107
    • View Profile
Re: Question on List Formatting
« Reply #6 on: May 22, 2012, 01:51:17 am »
Yes, the *.ufo files should be in one of the *.pk3 (ufos.pk3), its a simple zip file so you can extract them easily.

Ah-ha.  I guess the pk was a clue to pkzip, but hadn't run across that yet in my wanderings.  Thanks!

Offline bayo

  • Professional loser
  • Project Coder
  • Captain
  • ***
  • Posts: 733
    • View Profile
Re: Question on List Formatting
« Reply #7 on: May 22, 2012, 09:52:37 am »
here you have most of the documentation http://ufoai.org/wiki/index.php/UI_node_behaviours/2.4-dev
here you have other relative content http://ufoai.org/wiki/index.php/Category:GUIs but it is usually outdated

but for the api between game and script you need to check the code

Anyway feel free to ask specific question here or on irc. We can answer and update the wiki. You also can updater the wiki BTW :-)

Offline Battlescared

  • Squad Leader
  • ****
  • Posts: 107
    • View Profile
Re: Question on List Formatting
« Reply #8 on: May 22, 2012, 10:54:41 pm »
Guys,

Attached is a screen shot of the small mod I did.  Asking for feedback if it's something you would like to add permanently, or if you'd like changes to the way it's coded.

Coding wise, it's a bit of a hack to use the existing field and zero pad it to make everything line up.  It also had the side effect of changing the title on all the tabs for the transfer, so I still have to clean that up.   To line it all up correctly and get rid of the zero padding, I'd have to add another column to it.  I'd be happy to do that if you want me to, but that will take longer.  I also added the amount of free storage at the destination base in the base description, which I'd like to adjust it as you add items to transfer, but that will involve changing some function calls that might not work in all places.

Fire away.  I don't want to make the jump to full time programmer yet and start working on the main trunk, sorry, but this was something that was bothering me while playing the game and seemed easy to do, but little enough that you guys might not want to spend time on it.  Again, happy to make it conform to your design goals better if you want, just let me know.  When I'm done I'll submit it to you for review.

Offline H-Hour

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 1923
    • View Profile
Re: Question on List Formatting
« Reply #9 on: May 22, 2012, 11:52:44 pm »
I'm not a coder so can't comment on that, but I think they'll need to see a patch or diff with your changes.

I am a UI designer, though, and I would prefer to have the values passed to the UI separately. This way I can place them how I want rather than having a single string "12345 | 12345" that already determines the layout for me.

Offline bayo

  • Professional loser
  • Project Coder
  • Captain
  • ***
  • Posts: 733
    • View Profile
Re: Question on List Formatting
« Reply #10 on: May 23, 2012, 12:31:54 am »
* yes, "zero pad" is quite bad, and as suggests h-hour, if you split the values into 2 nodes, you can align content for both to the right.
* and imo the spinner node should be closer to the number it control, then between the 2 numbers.

Offline Kildor

  • Project Artist
  • Captain
  • ***
  • Posts: 757
  • Project mapper and some other stuff`er
    • View Profile
    • http://ufoai.nx0.ru
Re: Question on List Formatting
« Reply #11 on: May 23, 2012, 04:43:16 am »
I agree with H-Hour and bayo about splitting the string into two. Also, I think that it will be nice to have horizontal spinners between this two fields.

Offline Battlescared

  • Squad Leader
  • ****
  • Posts: 107
    • View Profile
Re: Question on List Formatting
« Reply #12 on: May 24, 2012, 12:25:57 am »
Ok, I agree.  Was fine for me, but not for your overall design.  I'll work on putting them in two columns and move the spinners between the columns.  Will take a bit longer and I just got swamped with more RL.  I'll work on it though.  I saw on one of the web pages that you'll take submissions anonymously.  Well, you know where it will come from, but I'll tap that input line and when I finish it I'll send it all to you with a write up and fully commented code to do with as you will.  If I get a little more ambitious I'll download the 2.5 trunk and make sure the two baselines aren't diverging with my changes.

Offline Battlescared

  • Squad Leader
  • ****
  • Posts: 107
    • View Profile
Re: Question on List Formatting
« Reply #13 on: May 24, 2012, 03:14:00 am »
Can you confirm something for me?  I thought spinners were supposed to be on all the transfer tabs... but I seem to have lost them.  I just read a comment that they are only on the Items page?  Does that mean you can't transfer employees, aircraft, or Aliens?  I never used those functions in game so now that I've modified my source code, I'm not sure if I broke something or if that is normal.

As it is right now, I only have spinners on the Items page.  Correct?

Offline geever

  • Project Coder
  • PHALANX Commander
  • ***
  • Posts: 2561
    • View Profile
Re: Question on List Formatting
« Reply #14 on: May 24, 2012, 10:25:35 am »
Can you confirm something for me?  I thought spinners were supposed to be on all the transfer tabs... but I seem to have lost them.  I just read a comment that they are only on the Items page?  Does that mean you can't transfer employees, aircraft, or Aliens?  I never used those functions in game so now that I've modified my source code, I'm not sure if I broke something or if that is normal.

As it is right now, I only have spinners on the Items page.  Correct?

Yes it's correct, as only items have huge number of stuff...

-geever