Skip to content

Commit

Permalink
feat: config options for changing hotkeys
Browse files Browse the repository at this point in the history
  • Loading branch information
liana-p committed Dec 28, 2023
1 parent 96d757b commit 17718f8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/narrat/src/components/debug/debug-menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ import { useRenderingStore } from '@/stores/rendering-store';
import { autoSaveGame, resetGlobalSave } from '@/application/saving';
import { getAllStates, overrideStates } from '@/data/all-stores';
import { useScenes } from '@/stores/scenes-store';
import { getCommonConfig } from '@/config';
export default defineComponent({
components: {
ModalWindow,
Expand All @@ -148,12 +148,14 @@ export default defineComponent({
mounted() {
const rendering = useRenderingStore();
const debugHotkey = getCommonConfig().hotkeys.debugMenu ?? 'd';
const jumpHotkey = getCommonConfig().hotkeys.jumpMenu ?? 'j';
rendering.inputsContainer.addEventListener('keydown', (event) => {
if (!this.jumping) {
if (event.key === 'd') {
if (event.key === debugHotkey) {
this.toggle();
}
if (event.key === 'j') {
if (event.key === jumpHotkey) {
this.jump();
}
}
Expand Down
11 changes: 11 additions & 0 deletions packages/narrat/src/config/common-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ import {
import { SettingsConfig, SettingsConfigSchema } from './settings-config';
import { DEFAULT_TEXT_SPEED } from '@/constants';

export const HotkeysConfigSchema = Type.Optional(
Type.Object({
debugMenu: Type.Optional(Type.String()),
jumpMenu: Type.Optional(Type.String()),
}),
);
export type HotkeysConfig = Static<typeof HotkeysConfigSchema>;

export const DialogPanelConfigSchema = Type.Optional(
Type.Object({
animateText: Type.Optional(Type.Boolean()),
Expand Down Expand Up @@ -151,6 +159,7 @@ export const CommonConfigInputSchema = Type.Object({
menuButtons: Type.Optional(MenuButtonsConfigSchema),
debugging: Type.Optional(DebuggingConfigSchema),
saves: Type.Optional(SavesConfigSchema),
hotkeys: HotkeysConfigSchema,
});
export type CommonConfigInput = Static<typeof CommonConfigInputSchema>;

Expand All @@ -176,6 +185,7 @@ export interface CommonConfig {
menuButtons: MenuButtonsConfig;
debugging: DebuggingConfig;
saves: SavesConfig;
hotkeys: HotkeysConfig;
}

export const defaultCommonConfig: CommonConfig = {
Expand Down Expand Up @@ -219,4 +229,5 @@ export const defaultCommonConfig: CommonConfig = {
mode: 'manual',
slots: 10,
},
hotkeys: {},
};

1 comment on commit 17718f8

@vercel
Copy link

@vercel vercel bot commented on 17718f8 Dec 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

narrat-editor-demo – ./packages/narrat-editor

narrat-editor-demo-git-main-nialna.vercel.app
narrat-editor-demo-nialna.vercel.app
narrat-editor-demo.vercel.app
demo.narrat.dev

Please sign in to comment.