Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/common/hotkeys.js
- This file was added.
/** | |||||
* Holds a map of scancode name -> user keyboard name | |||||
*/ | |||||
var g_ScancodesMap; | |||||
function hotkeySort(a, b) | |||||
{ | |||||
const specialKeys = ["Shift", "Alt", "Ctrl", "Super"]; | |||||
// Quick hack to put those first. | |||||
if (specialKeys.indexOf(a) !== -1) | |||||
a = ' ' + a; | |||||
if (specialKeys.indexOf(b) !== -1) | |||||
b = ' ' + b; | |||||
return a.localeCompare(b, Engine.GetCurrentLocale().substr(0, 2), { "numeric": true }); | |||||
} | |||||
function formatHotkeyCombination(comb) | |||||
{ | |||||
if (!g_ScancodesMap) | |||||
g_ScancodesMap = Engine.GetScancodeKeyNames(); | |||||
let str = comb.sort(hotkeySort).map(hk => g_ScancodesMap[hk]).join("+"); | |||||
Stan: inline? | |||||
return str;//.replace('\\', '\\\\').replace('[', '\\['); | |||||
Lint: ESLintBear (spaced-comment) Expected space or tab after '//' in comment. Lint: ESLintBear (spaced-comment): `Expected space or tab after '//' in comment.` | |||||
} | |||||
Done Inline Actionsleftover? Silier: leftover? | |||||
function formatHotkeyCombinations(combinations) | |||||
{ | |||||
let combs = combinations.map(formatHotkeyCombination); | |||||
combs.sort((a, b) => a.length > b.length || a > b); | |||||
return combs.join(", "); | |||||
} |
Wildfire Games · Phabricator
inline?