From d697f16a4dfd2833cd121c4f4dfb52f6ae0e0196 Mon Sep 17 00:00:00 2001 From: Alexey Nurgaliev Date: Sun, 12 Jan 2025 17:04:57 +0300 Subject: [PATCH] move .cue creation setting to game settings --- assets/l10n/en_US.json | 2 +- assets/l10n/ru_RU.json | 2 +- storage/defaults.go | 1 - storage/types.go | 2 +- templates/includes/form_game_settings.twig | 7 +++++++ templates/includes/platform_settings/emulation.twig | 6 ------ templates/play.twig | 2 +- web/handlers_game.go | 9 ++++++--- web/handlers_settings.go | 2 +- 9 files changed, 18 insertions(+), 15 deletions(-) diff --git a/assets/l10n/en_US.json b/assets/l10n/en_US.json index dd829a9..07ac723 100644 --- a/assets/l10n/en_US.json +++ b/assets/l10n/en_US.json @@ -73,6 +73,7 @@ "game.edit.auto-save-enabled.label": "Auto save enabled", "game.edit.auto-save-interval.label": "Auto save interval (minutes)", "game.edit.auto-save-capacity": "Auto save capacity", + "game.edit.cue-enabled.label": "Enable creation of .cue file", "game.edit.tags.undefined": "Choose or enter a tag...", "game.edit.tags.label": "Tags", "game.edit.submit": "Save", @@ -229,7 +230,6 @@ "settings-platform.emulation.threads.label": "Use threads", "settings-platform.emulation.disable-vsync.label": "Disable VSync", "settings-platform.emulation.disable-browser-db.label": "Disable browser DB", - "settings-platform.emulation.cue-enabled.label": "Enable creation of .cue file", "settings-platform.core.title": "Core", "settings-platform.core.empty": "No options for selected core", "settings-platform.play.title": "Play", diff --git a/assets/l10n/ru_RU.json b/assets/l10n/ru_RU.json index 2375429..ac14ee8 100644 --- a/assets/l10n/ru_RU.json +++ b/assets/l10n/ru_RU.json @@ -73,6 +73,7 @@ "game.edit.auto-save-enabled.label": "Включить авто сохранение", "game.edit.auto-save-interval.label": "Интервал авто сохранения (минут)", "game.edit.auto-save-capacity": "Количество авто сохранений", + "game.edit.cue-enabled.label": "Включить создание файлов .cue", "game.edit.tags.undefined": "Введите или выберите теги...", "game.edit.tags.label": "Теги", "game.edit.submit": "Сохранить", @@ -229,7 +230,6 @@ "settings-platform.emulation.threads.label": "Использовать потоки", "settings-platform.emulation.disable-vsync.label": "Отключить вертикальную синхронизацию", "settings-platform.emulation.disable-browser-db.label": "Отключить использование БД браузера", - "settings-platform.emulation.cue-enabled.label": "Включить создание файлов .cue", "settings-platform.core.title": "Ядро", "settings-platform.core.empty": "Нет настроек для выбранного ядра", "settings-platform.play.title": "Игра", diff --git a/storage/defaults.go b/storage/defaults.go index 26bcc96..daa2b58 100644 --- a/storage/defaults.go +++ b/storage/defaults.go @@ -1143,7 +1143,6 @@ func DefaultEmulatorSettings(systemType string) EmulatorSettings { settings.Shader = Shaders[0].Value settings.Buttons = DefaultButtons settings.Controls = [4]EmulatorControls{controls} - settings.CueEnabled = true return settings } diff --git a/storage/types.go b/storage/types.go index 4d84e54..5b6b6e3 100644 --- a/storage/types.go +++ b/storage/types.go @@ -46,6 +46,7 @@ type Game struct { AutoSaveEnabled bool AutoSaveInterval int AutoSaveCapacity int + CueEnabled bool OverrideEmulatorSettings bool EmulatorSettings EmulatorSettings } @@ -91,7 +92,6 @@ type EmulatorSettings struct { Threads bool DisableBrowserDB bool DisableVSync bool - CueEnabled bool } type EmulatorControls struct { diff --git a/templates/includes/form_game_settings.twig b/templates/includes/form_game_settings.twig index 4edab91..471d56b 100644 --- a/templates/includes/form_game_settings.twig +++ b/templates/includes/form_game_settings.twig @@ -45,3 +45,10 @@ + +
+
+ + +
+
diff --git a/templates/includes/platform_settings/emulation.twig b/templates/includes/platform_settings/emulation.twig index 70366c2..c6656db 100644 --- a/templates/includes/platform_settings/emulation.twig +++ b/templates/includes/platform_settings/emulation.twig @@ -33,11 +33,5 @@ -
-
- - -
-
diff --git a/templates/play.twig b/templates/play.twig index b74d8b8..5829c8c 100644 --- a/templates/play.twig +++ b/templates/play.twig @@ -86,7 +86,7 @@ window.EJS_disableDatabases = true; {% endif %} - {% if not emulator_settings.CueEnabled %} + {% if not game.CueEnabled %} window.EJS_disableCue = true; {% endif %} diff --git a/web/handlers_game.go b/web/handlers_game.go index 5a08dd2..ed7d2a4 100644 --- a/web/handlers_game.go +++ b/web/handlers_game.go @@ -3,12 +3,13 @@ package web import ( "errors" "fmt" - "github.com/flosch/pongo2/v6" - "github.com/labstack/echo/v4" - log "github.com/sirupsen/logrus" "net/http" "playtime/storage" "strconv" + + "github.com/flosch/pongo2/v6" + "github.com/labstack/echo/v4" + log "github.com/sirupsen/logrus" ) func (s *Server) games(c echo.Context) error { @@ -77,6 +78,7 @@ func (s *Server) gameUpload(c echo.Context) error { AutoSaveEnabled: settings.DefaultGameSettings.AutoSaveEnabled, AutoSaveInterval: settings.DefaultGameSettings.AutoSaveInterval, AutoSaveCapacity: settings.DefaultGameSettings.AutoSaveCapacity, + CueEnabled: settings.DefaultGameSettings.CueEnabled, OverrideEmulatorSettings: false, EmulatorSettings: storage.DefaultEmulatorSettings(""), } @@ -193,6 +195,7 @@ func (s *Server) gameEditSubmit(c echo.Context) error { game.AutoSaveEnabled = c.FormValue("auto-save-enabled") == "1" game.AutoSaveInterval = autoSaveInterval * 60 game.AutoSaveCapacity = autoSaveCapacity + game.CueEnabled = c.FormValue("cue-enabled") == "1" newPlatform := c.FormValue("platform") if game.Platform != newPlatform { diff --git a/web/handlers_settings.go b/web/handlers_settings.go index 5b98263..1ca1e38 100644 --- a/web/handlers_settings.go +++ b/web/handlers_settings.go @@ -58,6 +58,7 @@ func (s *Server) settingsGeneralSubmit(c echo.Context) error { settings.DefaultGameSettings.AutoSaveEnabled = c.FormValue("auto-save-enabled") == "1" settings.DefaultGameSettings.AutoSaveInterval = autoSaveInterval * 60 settings.DefaultGameSettings.AutoSaveCapacity = autoSaveCapacity + settings.DefaultGameSettings.CueEnabled = c.FormValue("cue-enabled") == "1" if _, err := s.storage.SettingsSave(*settings); err != nil { return err @@ -243,7 +244,6 @@ func settingsCollectFormData(c echo.Context) storage.EmulatorSettings { Threads: c.FormValue("threads") == "1", DisableBrowserDB: c.FormValue("disable-browser-db") == "1", DisableVSync: c.FormValue("disable-vsync") == "1", - CueEnabled: c.FormValue("cue-enabled") == "1", VideoRotation: videoRotation, Buttons: buttons, Controls: settingsCollectControls(c),