Skip to content

Commit

Permalink
Keybinding support
Browse files Browse the repository at this point in the history
  • Loading branch information
mclemente committed Jan 6, 2022
1 parent a530168 commit 39fde37
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 6 deletions.
14 changes: 14 additions & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@
"system": "System {name}"
}
},
"keybinds": {
"open": {
"name": "Open Party Overview",
"hint": "Opens the Party Overview window."
},
"close": {
"name": "Close Party Overview",
"hint": "Closes the Party Overview window."
},
"toggle": {
"name": "Toggle Party Overview",
"hint": "Opens or closes the Party Overview window."
}
},
"GENERAL": "General",
"LIMIT": "Limit",
"NAME": "Name",
Expand Down
26 changes: 20 additions & 6 deletions lang/es.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
{
"party-overview": {
"EnablePlayerAccess": {
"Name": "¿Permitir a jugadores una visión general del grupo?",
"Hint": "Permite a los jugadores para acceder la ventana del Grupo."
}
}
"party-overview": {
"EnablePlayerAccess": {
"Name": "¿Permitir a jugadores una visión general del grupo?",
"Hint": "Permite a los jugadores para acceder la ventana del Grupo."
},
"keybinds": {
"open": {
"name": "Abrir el Party Overview",
"hint": "Abre la ventana de el Party Overview."
},
"close": {
"name": "Cierrar Party Overview",
"hint": "Cierra la ventana de el Party Overview."
},
"toggle": {
"name": "Alternar el Party Overview",
"hint": "Abre o cierra la ventana de el Party Overview."
}
}
}
}
14 changes: 14 additions & 0 deletions lang/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@
"system": "Sistema {name}"
}
},
"keybinds": {
"open": {
"name": "Abrir o Party Overview",
"hint": "Abre a janela do Party Overview."
},
"close": {
"name": "Fechar Party Overview",
"hint": "Fecha a janela do Party Overview."
},
"toggle": {
"name": "Alternar o Party Overview",
"hint": "Abre ou fecha a janela do Party Overview."
}
},
"GENERAL": "Geral",
"LIMIT": "Limite",
"NAME": "Nome",
Expand Down
11 changes: 11 additions & 0 deletions module/logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class PartyOverviewApp extends Application {
this.state = {};
this.displayMode = DISPLAY_MODE.SHOW_VISIBLE;
this.activeTab = "general";
this.rendering = false;
}

update() {
Expand Down Expand Up @@ -122,6 +123,16 @@ class PartyOverviewApp extends Application {

super.activateListeners(html);
}

render(force, options) {
this.rendering = true;
super.render(force, options);
}

close() {
this.rendering = false;
super.close();
}
}

export default PartyOverviewApp;
28 changes: 28 additions & 0 deletions party-overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,34 @@ Hooks.once("init", () => {
registerApiSettings();
partyOverview = new PartyOverviewApp();

game.keybindings.register("party-overview", "openPartyOverview", {
name: game.i18n.localize("party-overview.keybinds.open.name"),
hint: game.i18n.localize("party-overview.keybinds.open.hint"),
onDown: () => {
partyOverview.render(true);
},
onUp: () => {},
precedence: CONST.KEYBINDING_PRECEDENCE.NORMAL,
});
game.keybindings.register("party-overview", "closePartyOverview", {
name: game.i18n.localize("party-overview.keybinds.close.name"),
hint: game.i18n.localize("party-overview.keybinds.close.hint"),
onDown: () => {
partyOverview.close();
},
onUp: () => {},
precedence: CONST.KEYBINDING_PRECEDENCE.NORMAL,
});
game.keybindings.register("party-overview", "togglePartyOverview", {
name: game.i18n.localize("party-overview.keybinds.toggle.name"),
hint: game.i18n.localize("party-overview.keybinds.toggle.hint"),
onDown: () => {
if (!partyOverview.rendering) partyOverview.render(true);
else partyOverview.close();
},
onUp: () => {},
precedence: CONST.KEYBINDING_PRECEDENCE.NORMAL,
});
return loadTemplates([
"modules/party-overview/templates/parts/Tabs.html",
"modules/party-overview/templates/parts/FilterButton.html",
Expand Down

0 comments on commit 39fde37

Please sign in to comment.