Allow values below entry count, just warn

5ef6315b25b244275cdb9662cb34253734cea39f

Wolfsblvt <wolfsblvt@gmail.com>

1 files changed, +4 -5Ignore whitespace
public/scripts/world-info.js+4 -5
@@ -1937,10 +1937,10 @@ function displayWorldEntries(name, data, navigation = navigation_option.none, fl
19371937
1938 let content = '<span>Apply your custom sorting to the "Order" field. The Order values will go down from the chosen number.</span>';1938 let content = '<span>Apply your custom sorting to the "Order" field. The Order values will go down from the chosen number.</span>';
1939 if (moreThan100) {1939 if (moreThan100) {
1940 content += `<div class="m-t-1"><i class="fa-solid fa-triangle-exclamation" style="color: #FFD43B;"></i> More than 100 entries in this world. You have to choose a number higher than that to work.<br />(Usual default: 100)<br />Minimum: ${entryCount}</div>`;1940 content += `<div class="m-t-1"><i class="fa-solid fa-triangle-exclamation" style="color: #FFD43B;"></i> More than 100 entries in this world. If you don't choose a number higher than that, the lower entries will default to 0.<br />(Usual default: 100)<br />Minimum: ${entryCount}</div>`;
1941 }1941 }
19421942
1943 const result = await Popup.show.input('Apply Custom Sorting', content, moreThan100 ? '' : '100', { okButton: 'Apply', cancelButton: 'Cancel' });1943 const result = await Popup.show.input('Apply Custom Sorting', content, '100', { okButton: 'Apply', cancelButton: 'Cancel' });
1944 if (!result) return;1944 if (!result) return;
19451945
1946 const start = Number(result);1946 const start = Number(result);
@@ -1949,13 +1949,12 @@ function displayWorldEntries(name, data, navigation = navigation_option.none, fl
1949 return;1949 return;
1950 }1950 }
1951 if (start < entryCount) {1951 if (start < entryCount) {
1952 toastr.warning('The number must be higher than the total entry count: ' + entryCount, 'Apply Custom Sorting');1952 toastr.warning('A number lower than the entry count has been chosen. All entries below that will default to 0.', 'Apply Custom Sorting');
1953 return;
1954 }1953 }
19551954
1956 let counter = 0;1955 let counter = 0;
1957 for (const entry of Object.values(data.entries)) {1956 for (const entry of Object.values(data.entries)) {
1958 const newOrder = start - (entry.displayIndex ?? 0);1957 const newOrder = Math.max(start - (entry.displayIndex ?? 0), 0);
1959 if (entry.order === newOrder) continue;1958 if (entry.order === newOrder) continue;
19601959
1961 entry.order = newOrder;1960 entry.order = newOrder;