mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
@@ -850,7 +850,7 @@ function applySort(evt) {
|
||||
loot.newLoadOrder
|
||||
]
|
||||
});
|
||||
loot.query(request).then(function(result){
|
||||
return loot.query(request).then(function(result){
|
||||
/* Remove old load order storage. */
|
||||
delete loot.lastLoadOrder;
|
||||
delete loot.newLoadOrder;
|
||||
@@ -864,17 +864,19 @@ function applySort(evt) {
|
||||
}).catch(processCefError);
|
||||
}
|
||||
function cancelSort(evt) {
|
||||
/* Sort UI elements again according to stored old load order. */
|
||||
sortUIElements(loot.lastLoadOrder);
|
||||
delete loot.lastLoadOrder;
|
||||
delete loot.newLoadOrder;
|
||||
return loot.query('cancelSort').then(function(){
|
||||
/* Sort UI elements again according to stored old load order. */
|
||||
sortUIElements(loot.lastLoadOrder);
|
||||
delete loot.lastLoadOrder;
|
||||
delete loot.newLoadOrder;
|
||||
|
||||
/* Now show the masterlist update buttons, and hide the accept and
|
||||
cancel sort buttons. */
|
||||
showElement(document.getElementById('updateMasterlistButton'));
|
||||
showElement(document.getElementById('sortButton'));
|
||||
hideElement(document.getElementById('applySortButton'));
|
||||
hideElement(document.getElementById('cancelSortButton'));
|
||||
/* Now show the masterlist update buttons, and hide the accept and
|
||||
cancel sort buttons. */
|
||||
showElement(document.getElementById('updateMasterlistButton'));
|
||||
showElement(document.getElementById('sortButton'));
|
||||
hideElement(document.getElementById('applySortButton'));
|
||||
hideElement(document.getElementById('cancelSortButton'));
|
||||
}).catch(processCefError);
|
||||
}
|
||||
function redatePlugins(evt) {
|
||||
if (evt.target.classList.contains('disabled')) {
|
||||
@@ -1154,6 +1156,19 @@ function focusSearch(evt) {
|
||||
function closeFirstRunDialog(evt) {
|
||||
evt.target.parentElement.close();
|
||||
}
|
||||
function handleUnappliedChangesClose() {
|
||||
showMessageDialog('Unapplied Sorting Changes', 'You have not yet applied or cancelled your sorted load order. Apply your load order before quitting?', function(result){
|
||||
if (result) {
|
||||
applySort().then(function(){
|
||||
window.close();
|
||||
});
|
||||
} else {
|
||||
cancelSort().then(function(){
|
||||
window.close();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
function setupEventHandlers() {
|
||||
var elements;
|
||||
/*Set up filter value and CSS setting storage read/write handlers.*/
|
||||
|
||||
+1
-1
@@ -113,7 +113,7 @@ namespace loot {
|
||||
// LootState member functions
|
||||
//---------------------------
|
||||
|
||||
LootState::LootState() : _currentGame(0) {}
|
||||
LootState::LootState() : _currentGame(0), isMidSort(false) {}
|
||||
|
||||
void LootState::Init(const std::string& cmdLineGame) {
|
||||
// Do some preliminary locale / UTF-8 support setup here, in case the settings file reading requires it.
|
||||
|
||||
@@ -78,6 +78,9 @@ namespace loot {
|
||||
const YAML::Node& GetSettings() const;
|
||||
void UpdateSettings(const YAML::Node& settings);
|
||||
void SaveSettings();
|
||||
|
||||
// Used to check if LOOT has unaccepted sorting changes on quit.
|
||||
bool isMidSort;
|
||||
private:
|
||||
YAML::Node _settings;
|
||||
std::vector<Game> _games;
|
||||
|
||||
@@ -166,6 +166,11 @@ namespace loot {
|
||||
callback->Success("null");
|
||||
return true;
|
||||
}
|
||||
else if (request == "cancelSort") {
|
||||
g_app_state.isMidSort = false;
|
||||
callback->Success("");
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
// May be a request with arguments.
|
||||
YAML::Node req;
|
||||
@@ -273,6 +278,7 @@ namespace loot {
|
||||
return true;
|
||||
}
|
||||
else if (requestName == "applySort") {
|
||||
g_app_state.isMidSort = false;
|
||||
BOOST_LOG_TRIVIAL(trace) << "User has accepted sorted load order, applying it.";
|
||||
try {
|
||||
g_app_state.CurrentGame().SetLoadOrder(request["args"][0].as<list<string>>());
|
||||
@@ -888,6 +894,7 @@ namespace loot {
|
||||
pluginNode["isDummy"] = plugin.FormIDs().size() == 0;
|
||||
node.push_back(pluginNode);
|
||||
}
|
||||
g_app_state.isMidSort = true;
|
||||
|
||||
if (node.size() > 0)
|
||||
callback->Success(JSON::stringify(node));
|
||||
@@ -1093,6 +1100,12 @@ namespace loot {
|
||||
bool LootHandler::DoClose(CefRefPtr<CefBrowser> browser) {
|
||||
assert(CefCurrentlyOn(TID_UI));
|
||||
|
||||
// Check if unapplied sorting changes exist.
|
||||
if (g_app_state.isMidSort) {
|
||||
browser->GetMainFrame()->ExecuteJavaScript("handleUnappliedChangesClose();", browser->GetMainFrame()->GetURL(), 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Closing the main window requires special handling. See the DoClose()
|
||||
// documentation in the CEF header for a detailed destription of this
|
||||
// process.
|
||||
|
||||
Reference in New Issue
Block a user