// Copyright (c) 2026 Dominic Masters // // This software is released under the MIT License. // https://opensource.org/licenses/MIT var Dropdown = require('./Dropdown.js'); var Button = require('./Button.js'); // A plain class, not a UIElement -- it owns no visual tree of its own. // Its widgets are handed to Settings.js's pageMenu (via menuItems), // which owns their parenting/rendering/disposal; this only holds // load()/apply()/hasChanges() logic, mirroring the old settings system's // per-tab def struct. class SettingsGeneral { constructor() { this.dropdown = new Dropdown(); this.dropdown.text = 'Language'; this.dropdown.options = ['en-US', 'ja-JP', 'es-MX']; this.applyButton = new Button(); this.applyButton.text = 'Apply'; this.applyButton.y = 40; this.applyButton.onSelect = () => this.apply(); this._loadedIndex = 0; } get menuItems() { return [this.dropdown, this.applyButton]; } load() { const index = this.dropdown.options.indexOf(Locale.current); this.dropdown.selectedIndex = index >= 0 ? index : 0; this._loadedIndex = this.dropdown.selectedIndex; } apply() { Locale.set(this.dropdown.options[this.dropdown.selectedIndex]); this._loadedIndex = this.dropdown.selectedIndex; } hasChanges() { return this.dropdown.selectedIndex !== this._loadedIndex; } } module.exports = SettingsGeneral;