Skip to content

Commit 06768ab

Browse files
committed
[ROMM-2336] Config entry for EJS_CacheLimit
1 parent 27189eb commit 06768ab

11 files changed

Lines changed: 30 additions & 3 deletions

File tree

backend/config/config_manager.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class Config:
5959
FIRMWARE_FOLDER_NAME: str
6060
HIGH_PRIO_STRUCTURE_PATH: str
6161
EJS_DEBUG: bool
62+
EJS_CACHE_LIMIT: int | None
6263
EJS_SETTINGS: dict[str, EjsOption] # core_name -> EjsOption
6364
EJS_CONTROLS: dict[str, EjsControls] # core_name -> EjsControls
6465

@@ -169,6 +170,9 @@ def _parse_config(self):
169170
self._raw_config, "filesystem.firmware_folder", "bios"
170171
),
171172
EJS_DEBUG=pydash.get(self._raw_config, "emulatorjs.debug", False),
173+
EJS_CACHE_LIMIT=pydash.get(
174+
self._raw_config, "emulatorjs.cache_limit", None
175+
),
172176
EJS_SETTINGS=pydash.get(self._raw_config, "emulatorjs.settings", {}),
173177
EJS_CONTROLS=self._get_ejs_controls(),
174178
)
@@ -273,6 +277,14 @@ def _validate_config(self):
273277
log.critical("Invalid config.yml: emulatorjs.debug must be a boolean")
274278
sys.exit(3)
275279

280+
if self.config.EJS_CACHE_LIMIT is not None and not isinstance(
281+
self.config.EJS_CACHE_LIMIT, int
282+
):
283+
log.critical(
284+
"Invalid config.yml: emulatorjs.cache_limit must be an integer"
285+
)
286+
sys.exit(3)
287+
276288
if not isinstance(self.config.EJS_SETTINGS, dict):
277289
log.critical("Invalid config.yml: emulatorjs.settings must be a dictionary")
278290
sys.exit(3)

backend/endpoints/configs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def get_config() -> ConfigResponse:
3737
PLATFORMS_BINDING=cfg.PLATFORMS_BINDING,
3838
PLATFORMS_VERSIONS=cfg.PLATFORMS_VERSIONS,
3939
EJS_DEBUG=cfg.EJS_DEBUG,
40+
EJS_CACHE_LIMIT=cfg.EJS_CACHE_LIMIT,
4041
EJS_CONTROLS=cfg.EJS_CONTROLS,
4142
EJS_SETTINGS=cfg.EJS_SETTINGS,
4243
)

backend/endpoints/responses/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ class ConfigResponse(TypedDict):
1313
PLATFORMS_BINDING: dict[str, str]
1414
PLATFORMS_VERSIONS: dict[str, str]
1515
EJS_DEBUG: bool
16+
EJS_CACHE_LIMIT: int | None
1617
EJS_SETTINGS: dict[str, dict[str, str]]
1718
EJS_CONTROLS: dict[str, EjsControls]

backend/tests/config/fixtures/config/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ filesystem:
3232

3333
emulatorjs:
3434
debug: true
35+
cache_limit: 1000
3536
settings:
3637
parallel_n64:
3738
vsync: disable

backend/tests/config/test_config_loader.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def test_config_loader():
2020
assert loader.config.ROMS_FOLDER_NAME == "ROMS"
2121
assert loader.config.FIRMWARE_FOLDER_NAME == "BIOS"
2222
assert loader.config.EJS_DEBUG
23+
assert loader.config.EJS_CACHE_LIMIT == 1000
2324
assert loader.config.EJS_SETTINGS == {
2425
"parallel_n64": {"vsync": "disable"},
2526
"snes9x": {"snes9x_region": "ntsc"},
@@ -52,5 +53,6 @@ def test_empty_config_loader():
5253
assert loader.config.ROMS_FOLDER_NAME == "roms"
5354
assert loader.config.FIRMWARE_FOLDER_NAME == "bios"
5455
assert not loader.config.EJS_DEBUG
56+
assert not loader.config.EJS_CACHE_LIMIT
5557
assert loader.config.EJS_SETTINGS == {}
5658
assert loader.config.EJS_CONTROLS == {}

examples/config.example.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ filesystem: {} # { roms_folder: 'roms' } For example if your folder structure is
5050
# EmulatorJS per-core options
5151
emulatorjs:
5252
# debug: true # Available options will be logged to the browser console
53+
# cache_limit: 100000000 # Cache limit per ROM (in bytes)
5354
settings:
5455
parallel_n64: # Use the exact core name
5556
# vsync: disable

frontend/src/__generated__/models/ConfigResponse.ts

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/src/components/common/Navigation/ConsoleModeBtn.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function enterConsoleMode() {
5555
class="text-caption text-center"
5656
:class="{ 'text-primary': route.path.startsWith('/console') }"
5757
>
58-
Play
58+
Console
5959
</span>
6060
</v-expand-transition>
6161
</div>

frontend/src/console/views/Play.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,10 @@ async function boot() {
420420
if (ejsControls) window.EJS_defaultControls = ejsControls;
421421
window.EJS_language = selectedLanguage.value.value.replace("_", "-");
422422
window.EJS_disableAutoLang = true;
423-
window.EJS_DEBUG_XX = configStore.config.EJS_DEBUG;
423+
424+
const { EJS_DEBUG, EJS_CACHE_LIMIT } = configStore.config;
425+
if (EJS_CACHE_LIMIT) window.EJS_CacheLimit = EJS_CACHE_LIMIT;
426+
window.EJS_DEBUG_XX = EJS_DEBUG;
424427
425428
// Set a valid game name (affects per-game settings keys)
426429
window.EJS_gameName = rom.fs_name_no_tags

frontend/src/stores/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const defaultConfig = {
2121
PLATFORMS_BINDING: {},
2222
PLATFORMS_VERSIONS: {},
2323
EJS_DEBUG: false,
24+
EJS_CACHE_LIMIT: 1073741824,
2425
EJS_SETTINGS: {},
2526
EJS_CONTROLS: {},
2627
} as ConfigResponse;

0 commit comments

Comments
 (0)