General > User modifications

Changing Unit's name in Equipment menu help

(1/2) > >>

joe davis:
I was attempting to modify the equipment menu where I equip my units in the aircraft.  In the section   
--- Quote ---     // ==================
     // inventory
     // ==================

--- End quote ---
directly under:

--- Quote ---   string txt_actorname
   {
      string   *cvar:mn_name
      pos      "544 24"
      size   "300 20"
   }
--- End quote ---

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?

geever:

--- Quote from: joe davis on January 29, 2010, 09:04:35 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?

--- End quote ---

For the pen icon you haven't assigned any actions. Add

--- Code: ---onClick { call *node:parent.name@click }

--- End code ---

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

joe davis:
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?

geever:
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

joe davis:
AWESOME ;D

Navigation

[0] Message Index

[#] Next page

Go to full version