project-navigation
Personal tools

Author Topic: Changing Unit's name in Equipment menu help  (Read 4230 times)

Offline joe davis

  • Rookie
  • ***
  • Posts: 55
    • View Profile
Changing Unit's name in Equipment menu help
« on: January 29, 2010, 09:04:35 pm »
I was attempting to modify the equipment menu where I equip my units in the aircraft.  In the section   
Quote
     // ==================
     // inventory
     // ==================
directly under:
Quote
   string txt_actorname
   {
      string   *cvar:mn_name
      pos      "544 24"
      size   "300 20"
   }

I inserted this code that I copied and modified from the hire.ufo:
      textentry name
   {      
      string      *cvar:mn_name
      pos         "539 24"
      size      "300 20"
      onChange   { cmd "employee_changename;" }
   }

      pic bt_edit
   {      
      tooltip      "_Rename your unit"
      image      ui/buttons_small
      pos         "780 24"
      texl      "0 48"
      texh      "16 64"      
   }

The above code works fine in allowing me to click on the text, but not the pen icon, to change the text there.  However it does not save the changes I put here to the units name.  Any ideas what I need to do to make this work?

Offline geever

  • Project Coder
  • PHALANX Commander
  • ***
  • Posts: 2561
    • View Profile
Re: Changing Unit's name in Equipment menu help
« Reply #1 on: January 29, 2010, 09:59:02 pm »
The above code works fine in allowing me to click on the text, but not the pen icon, to change the text there.  However it does not save the changes I put here to the units name.  Any ideas what I need to do to make this work?

For the pen icon you haven't assigned any actions. Add
Code: [Select]
onClick { call *node:parent.name@click }

so it will call the name entry's click event.

About the other issue, hmm yes, You can't do (easily). The hire menu sets a selectedEmployee variable and renamer uses that. Team selection doesn't set it and it couldn't set it because this code is shared between different game modes (in skirmish there is no selectedEmployee for example).

The solution is to make the renamer function not rely on the selectedEmployee but use for example UCN instead. (UCN stands unique character number.) For this we should register the selected employee's UCN.... So things are not always easy ... :)

-geever

Offline joe davis

  • Rookie
  • ***
  • Posts: 55
    • View Profile
Re: Changing Unit's name in Equipment menu help
« Reply #2 on: January 29, 2010, 10:52:02 pm »
Ok, I added the action onClick { call *node:parent.name@edit } instead of @click.  I had removed the original action I found onClick { call *node:root.name@edit } because it didn't like me, so I figured the pen would be fine for aesthetic purposes since when you click on the text it allows you to edit it, and the pen would provide the visual cue that the text is editable.  Though I like this better now, thank you for assisting with that.

As to the unique character number, where do I find and how do I reference it?

Offline geever

  • Project Coder
  • PHALANX Commander
  • ***
  • Posts: 2561
    • View Profile
Re: Changing Unit's name in Equipment menu help
« Reply #3 on: January 29, 2010, 11:12:08 pm »
yes, I was wrong with @click, @edit is correct. UCNs are in C code only yet. But I'm on the issue already. If you don't mind I'll adjust the code to be able to rename on equip screen too. (I have a working version already, only some visual bugs left)

-geever

Offline joe davis

  • Rookie
  • ***
  • Posts: 55
    • View Profile
Re: Changing Unit's name in Equipment menu help
« Reply #4 on: January 29, 2010, 11:55:38 pm »
AWESOME ;D

Offline geever

  • Project Coder
  • PHALANX Commander
  • ***
  • Posts: 2561
    • View Profile
Re: Changing Unit's name in Equipment menu help
« Reply #5 on: January 30, 2010, 12:07:41 am »
Implemented in r28331.

-geever

Offline joe davis

  • Rookie
  • ***
  • Posts: 55
    • View Profile
Re: Changing Unit's name in Equipment menu help
« Reply #6 on: January 30, 2010, 03:41:45 am »
Wicked :D