WI slash only reload world if it was selected

This commit is contained in:
Wolfsblvt 2024-07-22 02:11:11 +02:00
parent 788a13d7e3
commit 41c709e291
1 changed files with 8 additions and 2 deletions

View File

@ -885,9 +885,15 @@ function setWorldInfoSettings(settings, data) {
} }
function registerWorldInfoSlashCommands() { function registerWorldInfoSlashCommands() {
function reloadEditor(file) { /**
* Reloads the editor with the specified world info file
* @param {string} file - The file to load in the editor
* @param {boolean} [loadIfNotSelected=false] - Indicates whether to load the file even if it's not currently selected
*/
function reloadEditor(file, loadIfNotSelected = false) {
const currentIndex = $('#world_editor_select').val();
const selectedIndex = world_names.indexOf(file); const selectedIndex = world_names.indexOf(file);
if (selectedIndex !== -1) { if (selectedIndex !== -1 && (loadIfNotSelected || currentIndex === selectedIndex)) {
$('#world_editor_select').val(selectedIndex).trigger('change'); $('#world_editor_select').val(selectedIndex).trigger('change');
} }
} }