1
0
forked from 0ad/0ad

Some small fixes for the AutoQueue feature.

51ab4315ff
Fix using the hotkey on entities that don't have a Production Queue.
Fix showing the icon on entities that don't produce entities.

Differential revision: https://code.wildfiregames.com/D3932
Fixes: #6172
Comment by: @wraitii
Tested by: @Langbart
This was SVN commit r25396.
This commit is contained in:
Freagarach 2021-05-07 07:01:39 +00:00
parent 64b475b390
commit d2d0c6b347
2 changed files with 6 additions and 4 deletions

View File

@ -553,7 +553,8 @@ function turnAutoQueueOn()
"type": "autoqueue-on",
"entities": g_Selection.toList().filter(ent => {
let state = GetEntityState(ent);
return state && !!state.production.entities;
return !!state?.production?.entities.length &&
!state.production.autoqueue;
})
});
}
@ -564,7 +565,8 @@ function turnAutoQueueOff()
"type": "autoqueue-off",
"entities": g_Selection.toList().filter(ent => {
let state = GetEntityState(ent);
return state && !!state.production.entities;
return !!state?.production?.entities.length &&
state.production.autoqueue;
})
});
}

View File

@ -1720,7 +1720,7 @@ var g_EntityCommands =
"autoqueue-on": {
"getInfo": function(entStates)
{
if (entStates.every(entState => !entState.production || !entState.production.entities || entState.production.autoqueue))
if (entStates.every(entState => !entState.production || !entState.production.entities.length || entState.production.autoqueue))
return false;
return {
"tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.queueunit.autoqueueon") +
@ -1740,7 +1740,7 @@ var g_EntityCommands =
"autoqueue-off": {
"getInfo": function(entStates)
{
if (entStates.every(entState => !entState.production || !entState.production.entities || !entState.production.autoqueue))
if (entStates.every(entState => !entState.production || !entState.production.entities.length || !entState.production.autoqueue))
return false;
return {
"tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.queueunit.autoqueueoff") +