-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbin.js
62 lines (55 loc) · 1.47 KB
/
bin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
var genieHki = require('.')
var vkey = require('vkey')
var fs = require('fs')
var filename = process.argv[2]
if (!filename) {
console.error('usage: genie-hki <filename>')
process.exit(1)
}
var buffer = fs.readFileSync(filename)
var hki = genieHki.load(buffer)
console.log('File version:', hki.version)
hki.groups.forEach(function (group, id) {
console.log()
console.log(groupName(id))
group.forEach(function (hotkey, keyId) {
var line = '- ' + hotkeyName(id, keyId).padEnd(32)
if (hotkey.key === 0) {
line += ' (Unbound)'
} else {
line += ' '
if (hotkey.ctrl) line += 'Ctrl+'
if (hotkey.shift) line += 'Shift+'
if (hotkey.alt) line += 'Alt+'
line += vkey[hotkey.key]
}
console.log(line)
})
})
function groupName (id) {
return Object.entries(genieHki.HotkeyGroups).find(function (pair) {
return pair[1] === id
})[0]
}
function hotkeyName (group, id) {
var keys = [
genieHki.UnitCommandHotkeys,
genieHki.GameCommandHotkeys,
genieHki.ScrollHotkeys,
genieHki.VillagerHotkeys,
genieHki.TownCenterHotkeys,
genieHki.DockHotkeys,
genieHki.BarracksHotkeys,
genieHki.ArcheryRangeHotkeys,
genieHki.StableHotkeys,
genieHki.SiegeWorkshopHotkeys,
genieHki.MonasteryHotkeys,
genieHki.MarketHotkeys,
genieHki.MilitaryUnitHotkeys,
genieHki.CastleHotkeys,
genieHki.MillHotkeys
][group]
return Object.entries(keys).find(function (pair) {
return pair[1] === id
})[0]
}