Ticket #859: 859.patch

File 859.patch, 1.2 KB (added by gruby, 13 years ago)
  • binaries/data/mods/public/gui/session/selection.js

     
    392392
    393393EntityGroupsContainer.prototype.update = function()
    394394{
     395    this.checkRenamedEntities();
    395396    for each (var group in this.groups)
    396397    {
    397398        for (var ent in group.ents)
     
    407408    }
    408409}
    409410
     411/**
     412 * Update control groups if some entities in them was renamed
     413 * (in case of unit promotion or finishing building structure)
     414 */
     415EntityGroupsContainer.prototype.checkRenamedEntities = function()
     416{
     417    var renamedEntities = Engine.GuiInterfaceCall("GetRenamedEntities", true);
     418    if (renamedEntities.length > 0)
     419    {
     420        for each (var group in this.groups)
     421        {
     422            var addToGroup = [];
     423            for each (var renamedEntity in renamedEntities)
     424            {
     425                if (renamedEntity.entity in group.ents)
     426                {
     427                    group.removeEnt(renamedEntity.entity);
     428                    addToGroup.push(renamedEntity.newentity);
     429                }
     430            }
     431            group.add(addToGroup);
     432        }
     433    }
     434}
     435
    410436var g_Groups = new EntityGroupsContainer();