1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-09-16 01:56:55 +00:00

Add simple_path field to reorganize settings in simple view

This commit is contained in:
Dan Salvato 2024-02-08 14:23:22 -07:00
parent ee853c160c
commit 0997af44c3
2 changed files with 18 additions and 11 deletions

View file

@ -229,6 +229,10 @@ export default class MainMenu extends Module {
title: 'Show simple view.', title: 'Show simple view.',
component: 'setting-check-box', component: 'setting-check-box',
simple: true simple: true
},
changed: val => {
this.rebuildSettingsTree();
this.scheduleUpdate();
} }
}); });
@ -242,7 +246,7 @@ export default class MainMenu extends Module {
}); });
this.on('settings:added-definition', (key, definition) => { this.on('settings:added-definition', (key, definition) => {
this._addDefinitionToTree(key, definition); this._addDefinitionToTree(key, definition, false);
this.scheduleUpdate(); this.scheduleUpdate();
}); });
@ -556,12 +560,13 @@ export default class MainMenu extends Module {
rebuildSettingsTree() { rebuildSettingsTree() {
this._settings_tree = {}; this._settings_tree = {};
this._settings_count = 0; this._settings_count = 0;
const simple = this.settings.get('ffz.simple-view');
for(const [key, def] of this.settings.definitions) for(const [key, def] of this.settings.definitions)
this._addDefinitionToTree(key, def); this._addDefinitionToTree(key, def, simple);
for(const [key, def] of this.settings.ui_structures) for(const [key, def] of this.settings.ui_structures)
this._addDefinitionToTree(key, def); this._addDefinitionToTree(key, def, simple);
} }
@ -617,16 +622,16 @@ export default class MainMenu extends Module {
} }
} }
_addDefinitionToTree(key, def) { _addDefinitionToTree(key, def, simple) {
if ( ! def.ui || ! this._settings_tree ) if ( ! def.ui || ! this._settings_tree )
return; return;
if ( ! def.ui.path_tokens ) { if ( simple && def.ui.simple_path )
if ( def.ui.path ) def.ui.path_tokens = parse_path(def.ui.simple_path);
def.ui.path_tokens = parse_path(def.ui.path); else if ( def.ui.path )
else def.ui.path_tokens = parse_path(def.ui.path);
return; else
} return;
if ( ! def.ui || ! def.ui.path_tokens || ! this._settings_tree ) if ( ! def.ui || ! def.ui.path_tokens || ! this._settings_tree )
return; return;

View file

@ -166,8 +166,10 @@ export type SettingUi_Basic = {
description?: string; description?: string;
desc_i18n_key?: string; desc_i18n_key?: string;
// Whether to show up in Simple view // Whether to show up in simple view
simple?: boolean; simple?: boolean;
// Optional alternate setting placement for simple view
simple_path?: string;
/** /**
* Optional. If present, this method will be used to retrieve an array of * Optional. If present, this method will be used to retrieve an array of