1
0
forked from 0ad/0ad

Fixes promoted entities dropping from control groups, based on patch from gruby. Fixes #859.

This was SVN commit r10140.
This commit is contained in:
historic_bruno 2011-08-30 22:29:03 +00:00
parent a9e3368c8b
commit 1ff6d44f9e
3 changed files with 39 additions and 7 deletions

View File

@ -233,12 +233,12 @@ EntitySelection.prototype.update = function()
};
/**
* Update selection if some selected entities was renamed
* Update selection if some selected entities were renamed
* (in case of unit promotion or finishing building structure)
*/
EntitySelection.prototype.checkRenamedEntities = function()
{
var renamedEntities = Engine.GuiInterfaceCall("GetRenamedEntities", true);
var renamedEntities = Engine.GuiInterfaceCall("GetRenamedEntities");
if (renamedEntities.length > 0)
{
var removeFromSelectionList = [];
@ -392,6 +392,7 @@ EntityGroupsContainer.prototype.addEntities = function(groupName, ents)
EntityGroupsContainer.prototype.update = function()
{
this.checkRenamedEntities();
for each (var group in this.groups)
{
for (var ent in group.ents)
@ -407,4 +408,29 @@ EntityGroupsContainer.prototype.update = function()
}
}
/**
* Update control group if some entities in the group were renamed
* (in case of unit promotion or finishing building structure)
*/
EntityGroupsContainer.prototype.checkRenamedEntities = function()
{
var renamedEntities = Engine.GuiInterfaceCall("GetRenamedEntities");
if (renamedEntities.length > 0)
{
for each (var group in this.groups)
{
var addToGroup = [];
for each (var renamedEntity in renamedEntities)
{
if (renamedEntity.entity in group.ents)
{
group.removeEnt(renamedEntity.entity);
addToGroup.push(renamedEntity.newentity);
}
}
group.add(addToGroup);
}
}
}
var g_Groups = new EntityGroupsContainer();

View File

@ -179,6 +179,9 @@ function onTick()
getGUIObjectByName("resourcePop").textcolor = "255 165 0";
else
getGUIObjectByName("resourcePop").textcolor = "white";
// Clear renamed entities list
Engine.GuiInterfaceCall("ClearRenamedEntities", {});
}
function checkPlayerState()

View File

@ -102,12 +102,14 @@ GuiInterface.prototype.GetExtendedSimulationState = function(player)
return ret;
};
GuiInterface.prototype.GetRenamedEntities = function(player, clearList)
GuiInterface.prototype.GetRenamedEntities = function(player)
{
var result = this.renamedEntities;
if (clearList)
this.renamedEntities = [];
return result;
return this.renamedEntities;
};
GuiInterface.prototype.ClearRenamedEntities = function(player)
{
this.renamedEntities = [];
};
GuiInterface.prototype.GetEntityState = function(player, ent)
@ -668,6 +670,7 @@ var exposedFunctions = {
"GetSimulationState": 1,
"GetExtendedSimulationState": 1,
"GetRenamedEntities": 1,
"ClearRenamedEntities": 1,
"GetEntityState": 1,
"GetTemplateData": 1,
"GetNextNotification": 1,