Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/input.js
Context not available. | |||||
const g_FreehandSelection_MinNumberOfUnits = 2; | const g_FreehandSelection_MinNumberOfUnits = 2; | ||||
/** | /** | ||||
* To change from FreehandSelection to freehandFormation function you need a minimum number of units. | |||||
* Minimum must be 5, for better performance you could set it higher. | |||||
*/ | |||||
const g_FreehandFormation_MinNumberOfUnits = 5; | |||||
/** | |||||
* Says how many units stand behind in a line. | |||||
*/ | |||||
const g_FreehandFormation_DeepOfLine = 4; | |||||
lyv: Shouldn't it be DepthOfLine? | |||||
/** | |||||
* Number of pixels the mouse can move before the action is considered a drag. | * Number of pixels the mouse can move before the action is considered a drag. | ||||
*/ | */ | ||||
const g_MaxDragDelta = 4; | const g_MaxDragDelta = 4; | ||||
Context not available. | |||||
return !!action && doAction(action, ev); | return !!action && doAction(action, ev); | ||||
} | } | ||||
// Change to freehand formation position. | |||||
let freehandFormation = false; | |||||
// if (ev.button == ALT && selection.length >= g_FreehandFormation_MinNumberOfUnits) | |||||
freehandFormation = true; | |||||
// Even distribution of the units on the line. | // Even distribution of the units on the line. | ||||
let p0 = inputLine[0]; | let p0 = inputLine[0]; | ||||
let entityDistribution = [p0]; | let entityDistribution = [p0]; | ||||
let distanceBetweenEnts = lengthOfLine / (selection.length - 1); | let distanceBetweenEnts; | ||||
if (freehandFormation == true) | |||||
lyvUnsubmitted Not Done Inline Actionsif (freehandFormation) lyv: if (freehandFormation) | |||||
{ | |||||
distanceBetweenEnts = lengthOfLine / (Math.ceil(selection.length / g_FreehandFormation_DeepOfLine) - 1); | |||||
let v0 = Vector2D.sub(inputLine[1], inputLine[0]).perpendicular().normalize().mult(3); | |||||
for (let i = 1; i < g_FreehandFormation_DeepOfLine; ++i) | |||||
entityDistribution.push(Vector2D.add(p0, Vector2D.mult(v0, i))); | |||||
} | |||||
else | |||||
distanceBetweenEnts = lengthOfLine / (selection.length - 1); | |||||
let freeDist = -distanceBetweenEnts; | let freeDist = -distanceBetweenEnts; | ||||
for (let i = 1; i < inputLine.length; ++i) | for (let i = 1; i < inputLine.length; ++i) | ||||
Context not available. | |||||
p0 = Vector2D.sub(p0, p1).normalize().mult(freeDist).add(p1); | p0 = Vector2D.sub(p0, p1).normalize().mult(freeDist).add(p1); | ||||
entityDistribution.push(p0); | entityDistribution.push(p0); | ||||
freeDist -= distanceBetweenEnts; | freeDist -= distanceBetweenEnts; | ||||
if (freehandFormation == true) | |||||
{ | |||||
let v0 = Vector2D.sub(inputLine[i], inputLine[i - 1]).perpendicular().normalize().mult(3); | |||||
for (let j = 1; j < g_FreehandFormation_DeepOfLine; ++j) | |||||
entityDistribution.push(Vector2D.add(p0, Vector2D.mult(v0, j))); | |||||
} | |||||
} | } | ||||
} | } | ||||
// Rounding errors can lead to missing or too many points. | // Rounding errors can lead to missing or too many points. | ||||
entityDistribution.slice(0, selection.length); | if (freehandFormation == true) | ||||
{ | |||||
let v0 = Vector2D.sub(inputLine[inputLine.length - 1], inputLine[inputLine.length - 1 - g_FreehandFormation_DeepOfLine]).perpendicular().normalize().mult(3); | |||||
for (let i = 0; i < g_FreehandFormation_DeepOfLine; ++i) | |||||
entityDistribution.push(Vector2D.add(inputLine[inputLine.length -1], Vector2D.mult(v0, i))); | |||||
} | |||||
entityDistribution = entityDistribution.slice(0, selection.length); | |||||
entityDistribution = entityDistribution.concat(new Array(selection.length - entityDistribution.length).fill(inputLine[inputLine.length - 1])); | entityDistribution = entityDistribution.concat(new Array(selection.length - entityDistribution.length).fill(inputLine[inputLine.length - 1])); | ||||
if (Vector2D.from3D(GetEntityState(selection[0]).position).distanceTo(entityDistribution[0]) + | if (Vector2D.from3D(GetEntityState(selection[0]).position).distanceTo(entityDistribution[0]) + | ||||
Context not available. | |||||
"queued": Engine.HotkeyIsPressed("session.queue") | "queued": Engine.HotkeyIsPressed("session.queue") | ||||
}); | }); | ||||
// Add target markers with a minimum distance of 5 to each other. | // Add target markers with a minimum distance of 5 to each other. Shows only markers in a line. | ||||
let entitiesBetweenMarker = Math.ceil(5 / distanceBetweenEnts); | let entitiesBetweenMarker = Math.ceil(5 / distanceBetweenEnts); | ||||
if (freehandFormation == true) | |||||
entitiesBetweenMarker *= g_FreehandFormation_DeepOfLine; | |||||
for (let i = 0; i < entityDistribution.length; i += entitiesBetweenMarker) | for (let i = 0; i < entityDistribution.length; i += entitiesBetweenMarker) | ||||
DrawTargetMarker({ "x": entityDistribution[i].x, "z": entityDistribution[i].y }); | DrawTargetMarker({ "x": entityDistribution[i].x, "z": entityDistribution[i].y }); | ||||
Context not available. |
Wildfire Games · Phabricator
Shouldn't it be DepthOfLine?