Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fc-pregmod
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
macaronideath
fc-pregmod
Commits
6bdf9e94
Commit
6bdf9e94
authored
4 years ago
by
Arkerthan
Browse files
Options
Downloads
Patches
Plain Diff
Add minimal implementation for a layer between mousetrap and the actual code
parent
5e7e37dc
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
devTools/FC.ts
+1
-0
1 addition, 0 deletions
devTools/FC.ts
src/002-config/mousetrapConfig.js
+129
-21
129 additions, 21 deletions
src/002-config/mousetrapConfig.js
src/gui/quicklinks.js
+70
-56
70 additions, 56 deletions
src/gui/quicklinks.js
with
200 additions
and
77 deletions
devTools/FC.ts
+
1
−
0
View file @
6bdf9e94
...
@@ -256,6 +256,7 @@ namespace App {
...
@@ -256,6 +256,7 @@ namespace App {
declare
function
appendNewElement
<
K
extends
keyof
HTMLElementTagNameMap
>
(
tag
:
K
,
parent
:
ParentNode
,
content
?:
string
|
Node
,
classNames
?:
string
|
string
[]):
HTMLElementTagNameMap
[
K
];
declare
function
appendNewElement
<
K
extends
keyof
HTMLElementTagNameMap
>
(
tag
:
K
,
parent
:
ParentNode
,
content
?:
string
|
Node
,
classNames
?:
string
|
string
[]):
HTMLElementTagNameMap
[
K
];
}
}
namespace
View
{
}
namespace
View
{
}
namespace
Navigation
{
}
namespace
SlaveSummary
{
namespace
SlaveSummary
{
type
AppendRenderer
=
(
slave
:
FC
.
SlaveState
,
parentNode
:
Node
)
=>
void
;
type
AppendRenderer
=
(
slave
:
FC
.
SlaveState
,
parentNode
:
Node
)
=>
void
;
...
...
This diff is collapsed.
Click to expand it.
src/002-config/mousetrapConfig.js
+
129
−
21
View file @
6bdf9e94
/* eslint-disable */
/**
Mousetrap
.
bind
(
"
enter
"
,
function
()
{
* Expand mousetrap with multiple binds per key, passage dependent bindings and a menu for custom rebinding.
$
(
"
#story-caption #endWeekButton a.macro-link
"
).
trigger
(
"
click
"
);
*/
App
.
UI
.
Navigation
=
(
function
()
{
/**
* @typedef action
* @property {Function} callback
* @property {Array<string>} combinations 0 <= length <= 2
* @property {Array<string>} [passages] not existing means everywhere
* @property {string|function(): string} [uiName] allow different name in hotkey settings
*/
/**
* The key is used in the hotkey settings to describe the action
* @type {object.<string, action>}
*/
const
actions
=
{};
/**
* References a key combination to a set of actions
* @type {object.<string, Array<string>>}
*/
const
bindings
=
{};
/**
* @param {string} name used as key
* @param {action} action
*/
function
addDefault
(
name
,
action
)
{
actions
[
name
]
=
action
;
for
(
const
binding
of
action
.
combinations
)
{
addBinding
(
name
,
binding
);
}
}
/**
* @param {string} action
* @param {string} combination
*/
function
addBinding
(
action
,
combination
)
{
if
(
bindings
[
combination
])
{
bindings
[
combination
].
push
(
action
);
}
else
{
bindings
[
combination
]
=
[
action
];
Mousetrap
.
bind
(
combination
,
()
=>
{
for
(
const
binding
of
bindings
[
combination
])
{
const
action
=
actions
[
binding
];
// only activate callback if we are on the right passage
if
(
!
action
.
passages
||
action
.
passages
.
includes
(
State
.
passage
))
{
action
.
callback
();
}
}
});
}
}
/**
* @param {string} combination
*/
function
removeBinding
(
combination
)
{
if
(
bindings
[
combination
])
{
const
index
=
bindings
[
combination
].
indexOf
(
category
);
if
(
index
>
-
1
)
{
bindings
[
combination
].
splice
(
index
,
1
);
}
if
(
bindings
[
combination
].
length
===
0
)
{
delete
bindings
[
combination
];
Mousetrap
.
unbind
(
combination
);
}
}
}
function
hotkeysForAction
(
name
)
{
if
(
!
actions
[
name
])
{
return
""
;
}
const
c
=
actions
[
name
].
combinations
if
(
c
.
length
===
0
)
{
return
""
;
}
// TODO make key combinations look nicer
if
(
c
.
length
===
1
)
{
return
`[
${
c
[
0
]}
]`
;
}
return
`[
${
c
[
0
]}
,
${
c
[
1
]}
]`
;
}
return
{
add
:
addDefault
,
hotkeys
:
hotkeysForAction
,
//init: loadFromStorage,
//settings: settingsMenu,
};
})();
// add hotkeys
App
.
UI
.
Navigation
.
add
(
"
Advance week
"
,
{
callback
:
function
()
{
$
(
"
#story-caption #endWeekButton a.macro-link
"
).
trigger
(
"
click
"
);
},
combinations
:
[
"
enter
"
]
});
});
Mousetrap
.
bind
(
"
space
"
,
function
()
{
App
.
UI
.
Navigation
.
add
(
"
Continue/Back
"
,
{
$
(
"
#story-caption #nextButton a.macro-link
"
).
trigger
(
"
click
"
);
callback
:
function
()
{
$
(
"
#story-caption #nextButton a.macro-link
"
).
trigger
(
"
click
"
);
},
combinations
:
[
"
space
"
]
});
});
Mousetrap
.
bind
(
"
left
"
,
function
()
{
App
.
UI
.
Navigation
.
add
(
"
Previous Slave
"
,
{
$
(
"
#prevSlave a.macro-link
"
).
trigger
(
"
click
"
);
callback
:
function
()
{
$
(
"
#prevChild a.macro-link
"
).
trigger
(
"
click
"
);
$
(
"
#prevSlave a.macro-link
"
).
trigger
(
"
click
"
);
},
combinations
:
[
"
left
"
,
"
q
"
]
});
});
Mousetrap
.
bind
(
"
q
"
,
function
()
{
App
.
UI
.
Navigation
.
add
(
"
Next Slave
"
,
{
$
(
"
#prevSlave a.macro-link
"
).
trigger
(
"
click
"
);
callback
:
function
()
{
$
(
"
#prevChild a.macro-link
"
).
trigger
(
"
click
"
);
$
(
"
#nextSlave a.macro-link
"
).
trigger
(
"
click
"
);
},
combinations
:
[
"
right
"
,
"
e
"
]
});
});
Mousetrap
.
bind
(
"
right
"
,
function
()
{
App
.
UI
.
Navigation
.
add
(
"
Previous Child
"
,
{
$
(
"
#nextSlave a.macro-link
"
).
trigger
(
"
click
"
);
callback
:
function
()
{
$
(
"
#nextChild a.macro-link
"
).
trigger
(
"
click
"
);
$
(
"
#prevChild a.macro-link
"
).
trigger
(
"
click
"
);
},
combinations
:
[
"
left
"
,
"
q
"
]
});
});
Mousetrap
.
bind
(
"
e
"
,
function
()
{
App
.
UI
.
Navigation
.
add
(
"
Next Child
"
,
{
$
(
"
#nextSlave a.macro-link
"
).
trigger
(
"
click
"
);
callback
:
function
()
{
$
(
"
#nextChild a.macro-link
"
).
trigger
(
"
click
"
);
$
(
"
#nextChild a.macro-link
"
).
trigger
(
"
click
"
);
},
combinations
:
[
"
right
"
,
"
e
"
]
});
});
Mousetrap
.
bind
(
"
f
"
,
function
()
{
App
.
UI
.
Navigation
.
add
(
"
walkpast
"
,
{
$
(
"
#walkpast a.macro-link
"
).
trigger
(
"
click
"
);
callback
:
function
()
{
$
(
"
#walkpast a.macro-link
"
).
trigger
(
"
click
"
);
},
combinations
:
[
"
f
"
]
});
});
Mousetrap
.
bind
(
"
h
"
,
function
()
{
App
.
UI
.
Navigation
.
add
(
"
Manage HG
"
,
{
$
(
"
#manageHG a
"
).
trigger
(
"
click
"
);
callback
:
function
()
{
$
(
"
#manageHG a
"
).
trigger
(
"
click
"
);
},
combinations
:
[
"
h
"
]
});
});
This diff is collapsed.
Click to expand it.
src/gui/quicklinks.js
+
70
−
56
View file @
6bdf9e94
...
@@ -177,49 +177,6 @@ App.UI.quickMenu = (function() {
...
@@ -177,49 +177,6 @@ App.UI.quickMenu = (function() {
"
Manage Corporation
"
:
()
=>
V
.
corp
.
SpecToken
>
0
&&
V
.
corp
.
SpecTimer
===
0
,
"
Manage Corporation
"
:
()
=>
V
.
corp
.
SpecToken
>
0
&&
V
.
corp
.
SpecTimer
===
0
,
});
});
// setup hotkeys list, upper/lower case is important!
// Due to limitation to the key capture library keys cannot be used when they are already used in
// src/002-config/mousetrapConfig.js
const
hotkeys
=
cleanPassageMapping
({
"
BG Select
"
:
"
b
"
,
"
Buy Slaves
"
:
"
s
"
,
edicts
:
"
E
"
,
Firebase
:
"
z
"
,
"
Future Society
"
:
"
f
"
,
Main
:
"
m
"
,
"
Manage Arcology
"
:
"
c
"
,
"
Manage Corporation
"
:
"
C
"
,
"
Manage Penthouse
"
:
"
p
"
,
"
Manage Personal Affairs
"
:
"
x
"
,
"
Neighbor Interact
"
:
"
d
"
,
Options
:
"
o
"
,
"
Personal assistant options
"
:
"
t
"
,
"
Personal Attention Select
"
:
"
a
"
,
Policies
:
"
y
"
,
propagandaHub
:
"
H
"
,
"
Recruiter Select
"
:
"
u
"
,
riotControlCenter
:
"
R
"
,
"
Rules Assistant
"
:
"
r
"
,
secBarracks
:
"
A
"
,
securityHQ
:
"
S
"
,
"
Universal Rules
"
:
"
v
"
,
// Facilities
Brothel
:
"
1
"
,
Club
:
"
2
"
,
Arcade
:
"
3
"
,
Dairy
:
"
4
"
,
Farmyard
:
"
5
"
,
"
Servants' Quarters
"
:
"
6
"
,
"
Master Suite
"
:
"
7
"
,
Schoolroom
:
"
8
"
,
Spa
:
"
9
"
,
Nursery
:
"
0
"
,
Clinic
:
"
shift+1
"
,
Cellblock
:
"
shift+2
"
,
Incubator
:
"
shift+3
"
,
Pit
:
"
shift+4
"
,
});
/**
/**
* The DOM element of name of the currently played passage or any of it's parents. Used during generation to
* The DOM element of name of the currently played passage or any of it's parents. Used during generation to
* uncollapse the category with the current passage.
* uncollapse the category with the current passage.
...
@@ -235,14 +192,73 @@ App.UI.quickMenu = (function() {
...
@@ -235,14 +192,73 @@ App.UI.quickMenu = (function() {
let
hotkeysEnabled
=
false
;
let
hotkeysEnabled
=
false
;
// register hotkeys
// register hotkeys
for
(
const
passage
in
hotkeys
)
{
// this is in it's own scope as we can forget the hotkeys object immediately afterwards
Mousetrap
.
bind
(
hotkeys
[
passage
],
()
=>
{
{
if
(
hotkeysEnabled
// setup hotkeys list, upper/lower case is important!
// the passage is accessible
const
hotkeys
=
cleanPassageMapping
({
&&
!
(
hiddenPassages
[
passage
]
&&
hiddenPassages
[
passage
]()))
{
"
BG Select
"
:
"
b
"
,
Engine
.
play
(
passage
);
"
Buy Slaves
"
:
"
s
"
,
}
edicts
:
"
E
"
,
Firebase
:
"
z
"
,
"
Future Society
"
:
"
f
"
,
Main
:
"
m
"
,
"
Manage Arcology
"
:
"
c
"
,
"
Manage Corporation
"
:
"
C
"
,
"
Manage Penthouse
"
:
"
p
"
,
"
Manage Personal Affairs
"
:
"
x
"
,
"
Neighbor Interact
"
:
"
d
"
,
Options
:
"
o
"
,
"
Personal assistant options
"
:
"
t
"
,
"
Personal Attention Select
"
:
"
a
"
,
Policies
:
"
y
"
,
propagandaHub
:
"
H
"
,
"
Recruiter Select
"
:
"
u
"
,
riotControlCenter
:
"
R
"
,
"
Rules Assistant
"
:
"
r
"
,
secBarracks
:
"
A
"
,
securityHQ
:
"
S
"
,
"
Universal Rules
"
:
"
v
"
,
// Facilities
Brothel
:
"
1
"
,
Club
:
"
2
"
,
Arcade
:
"
3
"
,
Dairy
:
"
4
"
,
Farmyard
:
"
5
"
,
"
Servants' Quarters
"
:
"
6
"
,
"
Master Suite
"
:
"
7
"
,
Schoolroom
:
"
8
"
,
Spa
:
"
9
"
,
Nursery
:
"
0
"
,
Clinic
:
"
shift+1
"
,
Cellblock
:
"
shift+2
"
,
Incubator
:
"
shift+3
"
,
Pit
:
"
shift+4
"
,
});
});
// register
for
(
const
passage
of
jumpTo
)
{
if
(
!
hidden
.
includes
(
passage
))
{
const
action
=
{
callback
:
()
=>
{
if
(
hotkeysEnabled
// the passage is accessible
&&
!
(
hiddenPassages
[
passage
]
&&
hiddenPassages
[
passage
]()))
{
Engine
.
play
(
passage
);
}
},
combinations
:
[],
};
// add hotkey if there is one
if
(
hotkeys
[
passage
])
{
action
.
combinations
.
push
(
hotkeys
[
passage
]);
}
// custom ui text
if
(
uiNames
[
passage
])
{
action
.
uiName
=
uiNames
[
passage
];
}
App
.
UI
.
Navigation
.
add
(
passage
,
action
);
}
}
}
}
// setup history
// setup history
...
@@ -268,10 +284,7 @@ App.UI.quickMenu = (function() {
...
@@ -268,10 +284,7 @@ App.UI.quickMenu = (function() {
history
.
shift
();
history
.
shift
();
}
}
});
});
Mousetrap
.
bind
(
"
backspace
"
,
()
=>
{
App
.
UI
.
Navigation
.
add
(
"
Back in history
"
,
{
callback
:
goBack
,
combinations
:
[
"
backspace
"
]});
// jump back in history
goBack
();
});
/**
/**
* Goes back in history if possible.
* Goes back in history if possible.
...
@@ -447,8 +460,9 @@ App.UI.quickMenu = (function() {
...
@@ -447,8 +460,9 @@ App.UI.quickMenu = (function() {
Engine
.
play
(
passage
);
Engine
.
play
(
passage
);
};
};
div
.
prepend
(
a
);
div
.
prepend
(
a
);
if
(
hotkeys
[
passage
])
{
const
hotkeyString
=
App
.
UI
.
Navigation
.
hotkeys
(
passage
);
div
.
append
(
"
"
,
App
.
UI
.
DOM
.
makeElement
(
"
span
"
,
`[
${
hotkeys
[
passage
]}
]`
,
"
hotkey
"
));
if
(
hotkeyString
!==
""
)
{
div
.
append
(
"
"
,
App
.
UI
.
DOM
.
makeElement
(
"
span
"
,
hotkeyString
,
"
hotkey
"
));
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment