Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/input.js
Show First 20 Lines • Show All 350 Lines • ▼ Show 20 Lines | function updateBandbox(bandbox, ev, hidden) | ||||
var x0 = dragStart[0]; | var x0 = dragStart[0]; | ||||
var y0 = dragStart[1]; | var y0 = dragStart[1]; | ||||
var x1 = ev.x; | var x1 = ev.x; | ||||
var y1 = ev.y; | var y1 = ev.y; | ||||
// normalize the orientation of the rectangle | // normalize the orientation of the rectangle | ||||
if (x0 > x1) { let t = x0; x0 = x1; x1 = t; } | if (x0 > x1) { let t = x0; x0 = x1; x1 = t; } | ||||
if (y0 > y1) { let t = y0; y0 = y1; y1 = t; } | if (y0 > y1) { let t = y0; y0 = y1; y1 = t; } | ||||
let scale = +Engine.ConfigDB_GetValue("user", "gui.scale"); | let scale = getUserConfigNumber("gui.scale"); | ||||
bandbox.size = new GUISize(x0 / scale, y0 / scale, x1 / scale, y1 / scale); | bandbox.size = new GUISize(x0 / scale, y0 / scale, x1 / scale, y1 / scale); | ||||
bandbox.hidden = hidden; | bandbox.hidden = hidden; | ||||
return [x0, y0, x1, y1]; | return [x0, y0, x1, y1]; | ||||
} | } | ||||
// Define some useful unit filters for getPreferredEntities | // Define some useful unit filters for getPreferredEntities | ||||
Show All 26 Lines | return entState && | ||||
entState.unitAI.isIdle && | entState.unitAI.isIdle && | ||||
!hasClass(entState, "Domestic"); | !hasClass(entState, "Domestic"); | ||||
}, | }, | ||||
"isWounded": entity => { | "isWounded": entity => { | ||||
let entState = GetEntityState(entity); | let entState = GetEntityState(entity); | ||||
return entState && | return entState && | ||||
hasClass(entState, "Unit") && | hasClass(entState, "Unit") && | ||||
entState.maxHitpoints && | entState.maxHitpoints && | ||||
100 * entState.hitpoints <= entState.maxHitpoints * Engine.ConfigDB_GetValue("user", "gui.session.woundedunithotkeythreshold"); | 100 * entState.hitpoints <= entState.maxHitpoints * getUserConfigNumber("gui.session.woundedunithotkeythreshold"); | ||||
}, | }, | ||||
"isAnything": entity => { | "isAnything": entity => { | ||||
return true; | return true; | ||||
} | } | ||||
}; | }; | ||||
// Choose, inside a list of entities, which ones will be selected. | // Choose, inside a list of entities, which ones will be selected. | ||||
// We may use several entity filters, until one returns at least one element. | // We may use several entity filters, until one returns at least one element. | ||||
▲ Show 20 Lines • Show All 799 Lines • ▼ Show 20 Lines | return entitiesToCheck.filter(entity => { | ||||
let state = GetEntityState(entity); | let state = GetEntityState(entity); | ||||
return state && state.production && state.production.entities.length && | return state && state.production && state.production.entities.length && | ||||
state.production.entities.indexOf(trainEntType) != -1; | state.production.entities.indexOf(trainEntType) != -1; | ||||
}); | }); | ||||
} | } | ||||
function getBatchTrainingSize() | function getBatchTrainingSize() | ||||
{ | { | ||||
let num = +Engine.ConfigDB_GetValue("user", "gui.session.batchtrainingsize"); | return getUserConfigNumber("gui.session.batchtrainingsize") || 5; | ||||
ffffffff: Number check redundant.
```return getUserConfigNumber("gui.session.batchtrainingsize") || 5… | |||||
return Number.isInteger(num) && num > 0 ? num : 5; | |||||
} | } | ||||
// Add the unit shown at position to the training queue for all entities in the selection | // Add the unit shown at position to the training queue for all entities in the selection | ||||
function addTrainingByPosition(position) | function addTrainingByPosition(position) | ||||
{ | { | ||||
let playerState = GetSimState().players[Engine.GetPlayerID()]; | let playerState = GetSimState().players[Engine.GetPlayerID()]; | ||||
let selection = g_Selection.toList(); | let selection = g_Selection.toList(); | ||||
▲ Show 20 Lines • Show All 276 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Number check redundant.
Maybe whole function can be inlined.