Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/input.js
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
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; | ||||
var g_Hotkeys = { | |||||
"session.backtowork": { "hotkeydown": () => backToWork() }, | |||||
"session.gui.tutorial.toggle": { "hotkeydown": () => toggleTutorial() }, | |||||
"silhouettes": { "hotkeydown": () => toggleConfigBool("silhouettes") }, | |||||
"session.stop": { "hotkeydown": () => stopUnits(g_Selection.toList()) }, | |||||
"quicksave": { "hotkeydown": () => Engine.QuickSave() }, | |||||
"quickload": { "hotkeydown": () => Engine.QuickLoad() }, | |||||
"session.kill": { "hotkeydown": () => performCommand(g_Selection.toList().map(ent => GetEntityState(ent)), "delete") }, | |||||
"session.unload": { "hotkeydown": () => unloadAll() }, | |||||
"session.batchtrain": { "hotkeydown": () => updateSelectionDetails(), "hotkeyup": () => updateSelectionDetails() }, | |||||
"session.massbarter": { "hotkeydown": () => { | |||||
updateSelectionDetails(); | |||||
updateBarterButtons(); | |||||
}, | |||||
"hotkeyup": () => { | |||||
updateSelectionDetails(); | |||||
updateBarterButtons(); | |||||
} }, | |||||
"cancel": { "hotkeydown": () => closeOpenDialogs() }, | |||||
"teamchat": { "hotkeydown": () => openChat(g_IsObserver ? "/observers" : "/allies") }, | |||||
"privatechat": { "hotkeydown": () => openChat(g_LastChatAddressee) }, | |||||
"session.gui.toggle": { "hotkeydown": () => g_ShowGUI = !g_ShowGUI }, | |||||
"showsky": { "hotkeydown": () => { | |||||
var newSetting = !Engine.Renderer_GetShowSkyEnabled(); | |||||
Engine.Renderer_SetShowSkyEnabled(newSetting); | |||||
} }, | |||||
// Find idle warrior - TODO: Potentially move this to own UI button? | |||||
"selection.idlewarrior": { "hotkeydown": () => findIdleUnit(g_MilitaryTypes) }, | |||||
"selection.idleunit": { "hotkeydown": () => findIdleUnit(["!Domestic"]) }, | |||||
"selection.cancel": { "hotkeydown": () => clearSelection() }, | |||||
"session.toggleattackrange": { "hotkeydown": () => toggleRangeOverlay("Attack") }, | |||||
"session.toggleaurasrange": { "hotkeydown": () => toggleRangeOverlay("Auras") }, | |||||
"session.togglehealrange": { "hotkeydown": () => toggleRangeOverlay("Heal") }, | |||||
"session.showstatusbars": { "hotkeydown": () => { | |||||
g_ShowAllStatusBars = !g_ShowAllStatusBars; | |||||
recalculateStatusBarDisplay(); | |||||
} } | |||||
}; | |||||
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)) | ||||
{ | { | ||||
let action = determineAction(mouseX, mouseY); | let action = determineAction(mouseX, mouseY); | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | if (placementSupport.template && placementSupport.position) | ||||
"x": placementSupport.position.x, | "x": placementSupport.position.x, | ||||
"z": placementSupport.position.z, | "z": placementSupport.position.z, | ||||
"range": placementSupport.attack.Ranged.maxRange, | "range": placementSupport.attack.Ranged.maxRange, | ||||
"elevationBonus": placementSupport.attack.Ranged.elevationBonus, | "elevationBonus": placementSupport.attack.Ranged.elevationBonus, | ||||
}; | }; | ||||
var averageRange = Math.round(Engine.GuiInterfaceCall("GetAverageRangeForBuildings", cmd) - cmd.range); | var averageRange = Math.round(Engine.GuiInterfaceCall("GetAverageRangeForBuildings", cmd) - cmd.range); | ||||
var range = Math.round(cmd.range); | var range = Math.round(cmd.range); | ||||
placementSupport.tooltipMessage = sprintf(translatePlural("Basic range: %(range)s meter", "Basic range: %(range)s meters", range), { "range": range }) + "\n" + | placementSupport.tooltipMessage = sprintf(translatePlural("Basic range: %(range)s meter", "Basic range: %(range)s meters", range), { "range": range }) + "\n" + | ||||
sprintf(translatePlural("Average bonus range: %(range)s meter", "Average bonus range: %(range)s meters", averageRange), { "range": averageRange }); | sprintf(translatePlural("Average bonus range: %(range)s meter", "Average bonus range: %(range)s meters", averageRange), { "range": averageRange }); | ||||
ffffffff: ...AndType() | |||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
else if (placementSupport.mode === "wall") | else if (placementSupport.mode === "wall") | ||||
{ | { | ||||
if (placementSupport.wallSet && placementSupport.position) | if (placementSupport.wallSet && placementSupport.position) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 625 Lines • ▼ Show 20 Lines | if (ev.hotkey == "session.highlightguarding") | ||||
g_ShowGuarding = (ev.type == "hotkeydown"); | g_ShowGuarding = (ev.type == "hotkeydown"); | ||||
updateAdditionalHighlight(); | updateAdditionalHighlight(); | ||||
} | } | ||||
else if (ev.hotkey == "session.highlightguarded") | else if (ev.hotkey == "session.highlightguarded") | ||||
{ | { | ||||
g_ShowGuarded = (ev.type == "hotkeydown"); | g_ShowGuarded = (ev.type == "hotkeydown"); | ||||
updateAdditionalHighlight(); | updateAdditionalHighlight(); | ||||
} | } | ||||
else if (!!g_Hotkeys[ev.hotkey] && !!g_Hotkeys[ev.hotkey][ev.type]) | |||||
g_Hotkeys[ev.hotkey][ev.type](); | |||||
if (inputState != INPUT_NORMAL && inputState != INPUT_SELECTING) | if (inputState != INPUT_NORMAL && inputState != INPUT_SELECTING) | ||||
Not Done Inline Actions// Look for function, that takes the hit and demands no more hotkey functions to execute. ffffffff: // Look for function, that takes the hit and demands no more hotkey functions to execute. | |||||
clickedEntity = INVALID_ENTITY; | clickedEntity = INVALID_ENTITY; | ||||
// State-machine processing: | // State-machine processing: | ||||
switch (inputState) | switch (inputState) | ||||
{ | { | ||||
case INPUT_NORMAL: | case INPUT_NORMAL: | ||||
switch (ev.type) | switch (ev.type) | ||||
▲ Show 20 Lines • Show All 704 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
...AndType()