Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/input.js
Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | |||||
* If any mousedown or mouseup of a sequence of clicks lands on a unit, | * If any mousedown or mouseup of a sequence of clicks lands on a unit, | ||||
* that unit will be selected, which makes it easier to click on moving units. | * that unit will be selected, which makes it easier to click on moving units. | ||||
*/ | */ | ||||
var clickedEntity = INVALID_ENTITY; | var clickedEntity = INVALID_ENTITY; | ||||
// Same double-click behaviour for hotkey presses | // Same double-click behaviour for hotkey presses | ||||
const doublePressTime = 500; | const doublePressTime = 500; | ||||
var doublePressTimer = 0; | var doublePressTimer = 0; | ||||
var prevHotkey = 0; | var prevHotkey = 0; | ||||
vladislavbelov: What's the default value for the variable? | |||||
Done Inline ActionsDefault is undefined. Just like g_DragStartfor example. Imarok: Default is undefined. Just like `g_DragStart`for example.
For how I use this variable look at… | |||||
function updateCursorAndTooltip() | function updateCursorAndTooltip() | ||||
{ | { | ||||
var cursorSet = false; | var cursorSet = false; | ||||
var tooltipSet = false; | var tooltipSet = false; | ||||
var informationTooltip = Engine.GetGUIObjectByName("informationTooltip"); | var informationTooltip = Engine.GetGUIObjectByName("informationTooltip"); | ||||
if (!mouseIsOverObject && (inputState == INPUT_NORMAL || inputState == INPUT_PRESELECTEDACTION)) | if (!mouseIsOverObject && (inputState == INPUT_NORMAL || inputState == INPUT_PRESELECTEDACTION)) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | function updateBuildingPlacementPreview() | ||||
return false; | return false; | ||||
} | } | ||||
/** | /** | ||||
* Determine the context-sensitive action that should be performed when the mouse is at (x,y) | * Determine the context-sensitive action that should be performed when the mouse is at (x,y) | ||||
*/ | */ | ||||
function determineAction(x, y, fromMinimap) | function determineAction(x, y, fromMinimap) | ||||
{ | { | ||||
var selection = g_Selection.toList(); | var selection = g_Selection.toList(); | ||||
Done Inline ActionsWhat does the r mean? vladislavbelov: What does the `r` mean? | |||||
Done Inline ActionsI guess it just means result or return. Imarok: I guess it just means result or return.
It's already used multiple times across `input.js`. | |||||
// No action if there's no selection | // No action if there's no selection | ||||
if (!selection.length) | if (!selection.length) | ||||
{ | { | ||||
preSelectedAction = ACTION_NONE; | preSelectedAction = ACTION_NONE; | ||||
return undefined; | return undefined; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,017 Lines • ▼ Show 20 Lines | function positionUnitsFreehandSelectionMouseUp(ev) | ||||
Engine.GuiInterfaceCall("PlaySound", { | Engine.GuiInterfaceCall("PlaySound", { | ||||
"name": "order_walk", | "name": "order_walk", | ||||
"entity": selection[0] | "entity": selection[0] | ||||
}); | }); | ||||
return true; | return true; | ||||
} | } | ||||
function handleMinimapEvent(target) | function handleMinimapEvent(data) | ||||
{ | { | ||||
switch(data.type) | |||||
{ | |||||
case "mouserightrelease": | |||||
case "mouserightdoubleclick": | |||||
Done Inline Actionsone scope { } per case and let, so that the variable of one case can't be used in the other case, and one is free to use the same variable name in each case without any worries elexis: one scope { } per case and let, so that the variable of one case can't be used in the other… | |||||
// Partly duplicated from handleInputAfterGui(), but with the input being | // Partly duplicated from handleInputAfterGui(), but with the input being | ||||
// world coordinates instead of screen coordinates. | // world coordinates instead of screen coordinates. | ||||
if (inputState != INPUT_NORMAL) | if (inputState != INPUT_NORMAL) | ||||
return false; | return false; | ||||
Done Inline ActionsNo chance to make that a constant you can reuse? Stan: No chance to make that a constant you can reuse? | |||||
Done Inline Actionsgood point. Imarok: good point. | |||||
var fromMinimap = true; | var fromMinimap = true; | ||||
var action = determineAction(undefined, undefined, fromMinimap); | var action = determineAction(undefined, undefined, fromMinimap); | ||||
if (!action) | if (!action) | ||||
return false; | return false; | ||||
var selection = g_Selection.toList(); | var selection = g_Selection.toList(); | ||||
var queued = Engine.HotkeyIsPressed("session.queue"); | var queued = Engine.HotkeyIsPressed("session.queue"); | ||||
if (g_UnitActions[action.type] && g_UnitActions[action.type].execute) | if (g_UnitActions[action.type] && g_UnitActions[action.type].execute) | ||||
return g_UnitActions[action.type].execute(target, action, selection, queued); | return g_UnitActions[action.type].execute(data.target, action, selection, queued); | ||||
error("Invalid action.type " + action.type); | error("Invalid action.type " + action.type); | ||||
break; | |||||
case "mousemiddlerelease": | |||||
case "mousemiddledoubleclick": | |||||
DisplayMapPing(data.target); | |||||
Engine.PostNetworkCommand({ | |||||
"type": "map-ping", | |||||
"target": data.target | |||||
}); | |||||
break; | |||||
} | |||||
return false; | return false; | ||||
} | } | ||||
function getEntityLimitAndCount(playerState, entType) | function getEntityLimitAndCount(playerState, entType) | ||||
{ | { | ||||
let ret = { | let ret = { | ||||
"entLimit": undefined, | "entLimit": undefined, | ||||
"entCount": undefined, | "entCount": undefined, | ||||
▲ Show 20 Lines • Show All 377 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
What's the default value for the variable?