Content refresh improvements.

Closes #259.
* On-focus refresh now listens to window event instead of checking for
state change every 0.5s.
* Added setting to enable/disable on-focus refresh.
* Added File menu item to manually refresh content.
* Old settings files get updated when parsed.
* The installer settings file has been updated.
* Swapped the masterlist update icon to a download icon, as it's more
suitable.
This commit is contained in:
WrinklyNinja
2014-08-29 16:52:45 +01:00
parent 91d9f2757b
commit f02f95c4e9
4 changed files with 24 additions and 14 deletions
+18 -13
View File
@@ -198,6 +198,7 @@ var loot = {
document.getElementById('languageSelect').value = this.settings.language;
document.getElementById('enableDebugLogging').checked = this.settings.enableDebugLogging;
document.getElementById('updateMasterlist').checked = this.settings.updateMasterlist;
document.getElementById('autoRefresh').checked = this.settings.autoRefresh;
this.updateEnabledGames();
this.game.updateSelectedGame();
@@ -1044,8 +1045,17 @@ function closeSettingsDialog(evt) {
lastGame: loot.settings.lastGame,
updateMasterlist: document.getElementById('updateMasterlist').checked,
filters: loot.settings.filters,
autoRefresh: document.getElementById('autoRefresh').checked,
};
/* There's no easy way to check if an event listener has been added
already, so just remove the window focus listener, and add it again
if auto-refresh is enabled. */
window.removeEventListener('focus', onFocus, false);
if (settings.autoRefresh) {
window.addEventListener('focus', onFocus, false);
}
/* Send the settings back to the C++ side. */
var request = JSON.stringify({
name: 'closeSettings',
@@ -1167,6 +1177,7 @@ function setupEventHandlers() {
document.getElementById('openLogButton').addEventListener('click', openLogLocation, false);
document.getElementById('wipeUserlistButton').addEventListener('click', clearAllMetadata, false);
document.getElementById('copyContentButton').addEventListener('click', copyContent, false);
document.getElementById('refreshContentButton').addEventListener('click', onFocus, false);
document.getElementById('gameMenu').addEventListener('click', openMenu, false);
document.getElementById('settingsButton').addEventListener('click', showSettingsDialog, false);
document.getElementById('helpMenu').addEventListener('click', openMenu, false);
@@ -1313,11 +1324,17 @@ function initVars() {
}
closeProgressDialog();
/* So much easier than trying to set up my own C++ message loop to listen
to window messages looking for a focus change. */
if (loot.settings.autoRefresh) {
window.addEventListener('focus', onFocus, false);
}
}).catch(processCefError);
}).catch(processCefError);
}
function onFocus() {
function onFocus(evt) {
/* Send a query for updated load order and plugin header info. */
updateProgressDialog('Refreshing data...');
openProgressDialog();
@@ -1389,14 +1406,6 @@ function onFocus() {
closeProgressDialog();
}).catch(processCefError);
}
function checkFocus(){
if (document.hasFocus() && !loot.hasFocus) {
loot.hasFocus = true;
onFocus();
} else if (!document.hasFocus() && loot.hasFocus) {
loot.hasFocus = false;
}
}
require.config({
baseUrl: "js",
@@ -1411,8 +1420,4 @@ require(['marked', 'order!custom', 'order!plugin'], function(response) {
});
setupEventHandlers();
initVars();
/* So much easier than trying to set up my own C++ message loop to listen
to window messages looking for a focus change. */
loot.hasFocus = document.hasFocus();
setInterval(checkFocus, 500);
});
+3 -1
View File
@@ -421,6 +421,7 @@
<li id="openLogButton"><span class="fa fa-fw fa-folder-open"></span>Open Debug Log Location
<li id="wipeUserlistButton"><span class="fa fa-fw fa-trash-o"></span>Clear All User Metadata
<li id="copyContentButton"><span class="fa fa-fw fa-copy"></span>Copy Content As Text
<li id="refreshContentButton"><span class="fa fa-fw fa-refresh"></span>Refresh Content
</ol>
<li id="gameMenu">Game
<ol class="hidden">
@@ -434,7 +435,7 @@
</ol>
</ol>
<ol>
<li id="updateMasterlistButton"><span class="fa fa-fw fa-refresh"></span>Update Masterlist
<li id="updateMasterlistButton"><span class="fa fa-fw fa-download"></span>Update Masterlist
<li id="sortButton"><span class="fa fa-fw fa-magic"></span>Sort
<li id="applySortButton" class="hidden"><span class="fa fa-fw fa-check"></span>Apply
<li id="cancelSortButton" class="hidden"><span class="fa fa-fw fa-times"></span>Cancel
@@ -543,6 +544,7 @@ along with LOOT. If not, see &lt;http://www.gnu.org/licenses/&gt;.
</select><br>
<p><input type="checkbox" id="enableDebugLogging"><label for="enableDebugLogging" title="The output is logged to the LOOTDebugLog.txt file.">Enable debug logging</label>
<p><input type="checkbox" id="updateMasterlist"><label for="updateMasterlist">Update masterlist before sorting</label>
<p><input type="checkbox" id="autoRefresh"><label for="autoRefresh">Automatically refresh content on window refocus</label>
<table is="editable-table" id="gameTable" data-template="gameRow">
<thead>
<tr><th>Name<th>Base Game<th>LOOT Folder<th>Master File<th>Masterlist Repository URL<th>Masterlist Repository Branch<th>Install Path<th>Install Path Registry Key<th>
+1
View File
@@ -7,6 +7,7 @@ game: auto # auto, or one of the 'folder' values below.
lastGame: auto # auto, or one of the 'folder' values below.
enableDebugLogging: false
updateMasterlist: true
autoRefresh: true
# Games. The four types are 'Oblivion', 'Skyrim', 'Fallout3' and 'FalloutNV'. They correspond to each base game's libespm and libloadorder settings.
games:
+2
View File
@@ -407,6 +407,8 @@ namespace loot {
else
return false;
}
if (!_settings["autoRefresh"])
_settings["autoRefresh"] = true;
if (_settings["windows"])
_settings.remove("windows");