Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/input.js
Show First 20 Lines • Show All 232 Lines • ▼ Show 20 Lines | if (!fromMiniMap) | ||||
if (ent != INVALID_ENTITY) | if (ent != INVALID_ENTITY) | ||||
target = ent; | target = ent; | ||||
} | } | ||||
// Decide between the following ordered actions, | // Decide between the following ordered actions, | ||||
// if two actions are possible, the first one is taken | // if two actions are possible, the first one is taken | ||||
// thus the most specific should appear first. | // thus the most specific should appear first. | ||||
let actionInfo = undefined; | let actionInfo = undefined; | ||||
Lint: ESLintBear (no-undef-init): `It's not necessary to initialize 'actionInfo' to undefined.` | |||||
if (preSelectedAction != ACTION_NONE) | if (preSelectedAction != ACTION_NONE) | ||||
{ | { | ||||
for (let action of g_UnitActionsSortedKeys) | for (let action of g_UnitActionsSortedKeys) | ||||
if (g_UnitActions[action].preSelectedActionCheck) | if (g_UnitActions[action].preSelectedActionCheck) | ||||
{ | { | ||||
let r = g_UnitActions[action].preSelectedActionCheck(target, selection); | let r = g_UnitActions[action].preSelectedActionCheck(target, selection); | ||||
if (r) | if (r) | ||||
return r; | return r; | ||||
▲ Show 20 Lines • Show All 168 Lines • ▼ Show 20 Lines | var unitFilters = { | ||||
"isNonMilitary": entity => { | "isNonMilitary": entity => { | ||||
var entState = GetEntityState(entity); | var entState = GetEntityState(entity); | ||||
return entState && | return entState && | ||||
hasClass(entState, "Unit") && | hasClass(entState, "Unit") && | ||||
!g_MilitaryTypes.some(c => hasClass(entState, c)); | !g_MilitaryTypes.some(c => hasClass(entState, c)); | ||||
}, | }, | ||||
"isIdle": entity => { | "isIdle": entity => { | ||||
var entState = GetEntityState(entity); | var entState = GetEntityState(entity); | ||||
return entState && | return entState && | ||||
hasClass(entState, "Unit") && | hasClass(entState, "Unit") && | ||||
entState.unitAI && | entState.unitAI && | ||||
entState.unitAI.isIdle && | entState.unitAI.isIdle && | ||||
!hasClass(entState, "Domestic"); | !hasClass(entState, "Domestic"); | ||||
}, | }, | ||||
"isWounded": entity => { | "isWounded": entity => { | ||||
let entState = GetEntityState(entity); | let entState = GetEntityState(entity); | ||||
Show All 36 Lines | |||||
function handleInputBeforeGui(ev, hoveredObject) | function handleInputBeforeGui(ev, hoveredObject) | ||||
{ | { | ||||
if (GetSimState().cinemaPlaying) | if (GetSimState().cinemaPlaying) | ||||
return false; | return false; | ||||
// Capture mouse position so we can use it for displaying cursors, | // Capture mouse position so we can use it for displaying cursors, | ||||
// and key states | // and key states | ||||
switch (ev.type) | switch (ev.type) | ||||
Lint: ESLintBear (default-case) Expected a default case. Lint: ESLintBear (default-case): `Expected a default case.` | |||||
{ | { | ||||
case "mousebuttonup": | case "mousebuttonup": | ||||
case "mousebuttondown": | case "mousebuttondown": | ||||
case "mousemotion": | case "mousemotion": | ||||
mouseX = ev.x; | mouseX = ev.x; | ||||
mouseY = ev.y; | mouseY = ev.y; | ||||
break; | break; | ||||
} | } | ||||
// Remember whether the mouse is over a GUI object or not | // Remember whether the mouse is over a GUI object or not | ||||
mouseIsOverObject = (hoveredObject != null); | mouseIsOverObject = (hoveredObject != null); | ||||
// Close the menu when interacting with the game world | // Close the menu when interacting with the game world | ||||
if (!mouseIsOverObject && (ev.type =="mousebuttonup" || ev.type == "mousebuttondown") | if (!mouseIsOverObject && (ev.type =="mousebuttonup" || ev.type == "mousebuttondown") | ||||
&& (ev.button == SDL_BUTTON_LEFT || ev.button == SDL_BUTTON_RIGHT)) | && (ev.button == SDL_BUTTON_LEFT || ev.button == SDL_BUTTON_RIGHT)) | ||||
Lint: ESLintBear (operator-linebreak) '&&' should be placed at the end of the line. Lint: ESLintBear (operator-linebreak): `'&&' should be placed at the end of the line.` | |||||
g_Menu.close(); | g_Menu.close(); | ||||
// State-machine processing: | // State-machine processing: | ||||
// | // | ||||
// (This is for states which should override the normal GUI processing - events will | // (This is for states which should override the normal GUI processing - events will | ||||
// be processed here before being passed on, and propagation will stop if this function | // be processed here before being passed on, and propagation will stop if this function | ||||
// returns true) | // returns true) | ||||
// | // | ||||
// TODO: it'd probably be nice to have a better state-machine system, with guaranteed | // TODO: it'd probably be nice to have a better state-machine system, with guaranteed | ||||
// entry/exit functions, since this is a bit broken now | // entry/exit functions, since this is a bit broken now | ||||
switch (inputState) | switch (inputState) | ||||
Lint: ESLintBear (default-case) Expected a default case. Lint: ESLintBear (default-case): `Expected a default case.` | |||||
{ | { | ||||
case INPUT_BANDBOXING: | case INPUT_BANDBOXING: | ||||
var bandbox = Engine.GetGUIObjectByName("bandbox"); | var bandbox = Engine.GetGUIObjectByName("bandbox"); | ||||
switch (ev.type) | switch (ev.type) | ||||
{ | { | ||||
case "mousemotion": | case "mousemotion": | ||||
var rect = updateBandbox(bandbox, ev, false); | var rect = updateBandbox(bandbox, ev, false); | ||||
▲ Show 20 Lines • Show All 1,181 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
It's not necessary to initialize 'actionInfo' to undefined.