WI slash only reload world if it was selected
This commit is contained in:
parent
788a13d7e3
commit
41c709e291
|
@ -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');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue