Fixed build buttons for new entities.Fixed command buttons for the new entities. Also fixed a bug where build buttons disappeared after you clicked a unit that couldn't build anything (there was a missing guiUnHide) and added infidelity aura to herdable animals.

This was SVN commit r3255.
This commit is contained in:
Matei 2005-12-16 07:12:19 +00:00
parent 3dc4d7d184
commit 59eadae140
2 changed files with 38 additions and 18 deletions

View File

@ -249,12 +249,16 @@ function resetUpdateVars()
function shouldUpdateStat( statname ) function shouldUpdateStat( statname )
{ {
if( selectionChanged || ( selectionTemplate != selection[0].template ) ) if( selectionChanged || ( selectionTemplate != selection[0].template ) )
{
return( true ); return( true );
}
for( var property in selectionPropertiesChanged ) for( var property in selectionPropertiesChanged )
{ {
// If property starts with statname // If property starts with statname
if( selectionPropertiesChanged[property].substring( 0, statname.length ) == statname ) if( selectionPropertiesChanged[property].substring( 0, statname.length ) == statname )
{
return( true ); return( true );
}
} }
return( false ); return( false );
} }

View File

@ -123,43 +123,48 @@ function UpdateList(listIcon, listCol)
&& selection[0].actions.create && selection[0].actions.create
&& selection[0].actions.create.list ) && selection[0].actions.create.list )
{ {
listName = ""; list = null;
switch (listIcon) switch (listIcon)
{ {
case action_tab_train: case action_tab_train:
if ( selection[0].actions.create.list.unit && shouldUpdateStat( "actions.create.list.unit" ) ) if ( selection[0].actions.create.list.unit && shouldUpdateStat( "actions.create.list.unit" ) )
listName = selection[0].actions.create.list.unit.toString(); list = selection[0].actions.create.list.unit;
break; break;
case action_tab_buildciv: case action_tab_buildciv:
if ( selection[0].actions.create.list.structciv && shouldUpdateStat( "actions.create.list.structciv" ) ) if ( selection[0].actions.create.list.structciv && shouldUpdateStat( "actions.create.list.structciv" ) )
listName = selection[0].actions.create.list.structciv.toString(); list = selection[0].actions.create.list.structciv;
break; break;
case action_tab_buildmil: case action_tab_buildmil:
if ( selection[0].actions.create.list.structmil && shouldUpdateStat( "actions.create.list.structmil" ) ) if ( selection[0].actions.create.list.structmil && shouldUpdateStat( "actions.create.list.structmil" ) )
listName = selection[0].actions.create.list.structmil.toString(); list = selection[0].actions.create.list.structmil;
break; break;
case action_tab_research: case action_tab_research:
if ( selection[0].actions.create.list.tech && shouldUpdateStat( "actions.create.list.tech" ) ) if ( selection[0].actions.create.list.tech && shouldUpdateStat( "actions.create.list.tech" ) )
listName = selection[0].actions.create.list.tech.toString(); list = selection[0].actions.create.list.tech;
break; break;
default: default:
return 0; return 0;
break; break;
} }
if (listName != "") if ( list )
{ {
// Enable tab portrait. // Enable tab portrait.
setPortrait("snStatusPaneCommand" + listCol + "_1", "sheet_action", "", listIcon); guiUnHide("snStatusPaneCommand" + "Group" + listCol);
guiUnHide("snStatusPaneCommand" + listCol + "_1"); guiUnHide("snStatusPaneCommand" + listCol + "_1");
setPortrait("snStatusPaneCommand" + listCol + "_1", "sheet_action", "", listIcon);
// Reset list length. // Reset list length.
snStatusPaneCommand[listCol][1].last = 0; snStatusPaneCommand[listCol][1].last = 0;
// Store content info in tab button for future reference. // Store content info in tab button for future reference.
snStatusPaneCommand[listCol][1].type = "list"; snStatusPaneCommand[listCol][1].type = "list";
// Extract entity list into an array. // Extract entity list into an array.
listArray = parseDelimiterString(listName, ";"); listArray = [];
for( i in list )
{
listArray[listArray.length] = i.toString();
}
// Populate appropriate command buttons. // Populate appropriate command buttons.
for (createLoop = 1; createLoop < snStatusPaneCommand.list.max; createLoop++) for (createLoop = 1; createLoop < snStatusPaneCommand.list.max; createLoop++)
@ -169,19 +174,24 @@ function UpdateList(listIcon, listCol)
// Get name of entity to display in list. // Get name of entity to display in list.
UpdateListEntityName = selection[0].traits.id.civ_code + "_" + listArray[createLoop]; UpdateListEntityName = selection[0].traits.id.civ_code + "_" + listArray[createLoop];
getGUIObjectByName ("snStatusPaneCommand" + listCol + "_" + createLoop).caption = ""; getGUIObjectByName ("snStatusPaneCommand" + listCol + "_" + (createLoop+1)).caption = "";
setPortrait("snStatusPaneCommand" + listCol + "_" + parseInt(createLoop+1), getEntityTemplate(UpdateListEntityName).traits.id.icon, selection[0].traits.id.civ_code, getEntityTemplate(UpdateListEntityName).traits.id.icon_cell); guiUnHide("snStatusPaneCommand" + listCol + "_" + (createLoop+1));
guiUnHide("snStatusPaneCommand" + listCol + "_" + parseInt(createLoop+1)); setPortrait("snStatusPaneCommand" + listCol + "_" + (createLoop+1),
getEntityTemplate(UpdateListEntityName).traits.id.icon,
selection[0].traits.id.civ_code,
getEntityTemplate(UpdateListEntityName).traits.id.icon_cell);
// Store content info in tab button for future reference. // Store content info in tab button for future reference.
snStatusPaneCommand[listCol][parseInt(createLoop+1)].name = listIcon; snStatusPaneCommand[listCol][createLoop+1].name = listIcon;
snStatusPaneCommand[listCol][parseInt(createLoop+1)].object = listArray[createLoop]; snStatusPaneCommand[listCol][createLoop+1].object = listArray[createLoop];
snStatusPaneCommand[listCol][parseInt(createLoop+1)].type = "list"; snStatusPaneCommand[listCol][createLoop+1].type = "list";
snStatusPaneCommand[listCol][parseInt(createLoop+1)].last++; snStatusPaneCommand[listCol][createLoop+1].last++;
} }
else else
{
guiHide("snStatusPaneCommand" + listCol + "_" + parseInt(createLoop+1)); guiHide("snStatusPaneCommand" + listCol + "_" + parseInt(createLoop+1));
}
} }
return listArray; return listArray;
} }
@ -248,11 +258,11 @@ console.write (snStatusPaneCommand[tab][list].type);
{ {
// Click the tab button to toggle visibility of its list (if it's of a list type). // Click the tab button to toggle visibility of its list (if it's of a list type).
guiToggle ("snStatusPaneCommand" + "Group" + tab); guiToggle ("snStatusPaneCommand" + "Group" + tab);
console.write ("Toggled " + "snStatusPaneCommand" + "Group" + tab); console.write ("Toggled " + "snStatusPaneCommand" + "Group" + tab);
} }
else else
{ {
console.write ("Some weird action."); console.write ("Some weird action.");
// Perform appropriate actions for different command buttons. // Perform appropriate actions for different command buttons.
switch (snStatusPaneCommand[tab][list].name) switch (snStatusPaneCommand[tab][list].name)
@ -302,6 +312,8 @@ function refreshCommandButtons()
{ {
if( shouldUpdateStat( "actions.create.list" ) ) if( shouldUpdateStat( "actions.create.list" ) )
{ {
console.write("need to update list!");
// Everything in this block is tied to properties in // Everything in this block is tied to properties in
// actions.create.list, the above check should limit the // actions.create.list, the above check should limit the
// number of times this update is needlessly made. // number of times this update is needlessly made.
@ -319,6 +331,10 @@ function refreshCommandButtons()
formationArray = UpdateList(action_tab_formation, listCounter); if (formationArray != 0) listCounter++; formationArray = UpdateList(action_tab_formation, listCounter); if (formationArray != 0) listCounter++;
stanceArray = UpdateList(action_tab_stance, listCounter); if (stanceArray != 0) listCounter++; stanceArray = UpdateList(action_tab_stance, listCounter); if (stanceArray != 0) listCounter++;
} }
else
{
console.write("don't need to update list!");
}
if( shouldUpdateStat( "actions" ) ) if( shouldUpdateStat( "actions" ) )
{ {