mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2025-08-17 16:46:31 +00:00
quitting apps now has a confirmation dialog
This commit is contained in:
parent
00437e6e60
commit
9401443c4f
@ -23,7 +23,7 @@ function attachListeners() {
|
|||||||
$('#cancelQuitApp').on('click', cancelQuitApp);
|
$('#cancelQuitApp').on('click', cancelQuitApp);
|
||||||
$('#backIcon').on('click', showHostsAndSettingsMode);
|
$('#backIcon').on('click', showHostsAndSettingsMode);
|
||||||
$('#continueQuitApp').on('click', continueQuitApp);
|
$('#continueQuitApp').on('click', continueQuitApp);
|
||||||
$('#quitGameButton').on('click', stopGame);
|
$('#quitCurrentApp').on('click', stopGameWithConfirmation);
|
||||||
$(window).resize(fullscreenNaclModule);
|
$(window).resize(fullscreenNaclModule);
|
||||||
chrome.app.window.current().onMaximized.addListener(fullscreenChromeWindow);
|
chrome.app.window.current().onMaximized.addListener(fullscreenChromeWindow);
|
||||||
}
|
}
|
||||||
@ -470,7 +470,6 @@ function cancelQuitApp() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function continueQuitApp(sourceEvent) {
|
function continueQuitApp(sourceEvent) {
|
||||||
// I want the sourceEvent's sourceEvent
|
|
||||||
console.log('stopping game, and closing app dialog, and returning');
|
console.log('stopping game, and closing app dialog, and returning');
|
||||||
stopGame(
|
stopGame(
|
||||||
function() {
|
function() {
|
||||||
@ -479,7 +478,6 @@ function continueQuitApp(sourceEvent) {
|
|||||||
// wants to set it again.
|
// wants to set it again.
|
||||||
var event = relaunchSourceEvent;
|
var event = relaunchSourceEvent;
|
||||||
relaunchSourceEvent = null;
|
relaunchSourceEvent = null;
|
||||||
|
|
||||||
startGame(event);
|
startGame(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -518,6 +516,20 @@ function fullscreenNaclModule() {
|
|||||||
module.style.paddingTop = ((screenHeight - module.height) / 2) + "px";
|
module.style.paddingTop = ((screenHeight - module.height) / 2) + "px";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function stopGameWithConfirmation() {
|
||||||
|
if (api.currentGame === 0) {
|
||||||
|
snackbarLog('Nothing was running');
|
||||||
|
} else {
|
||||||
|
api.getAppById(api.currentGame).then(function (currentGame) {
|
||||||
|
var quitAppDialog = document.querySelector('#quitAppDialog');
|
||||||
|
document.getElementById('quitAppDialogText').innerHTML =
|
||||||
|
' Are you sure you would like to quit ' +
|
||||||
|
currentGame.title + '? Unsaved progress will be lost.';
|
||||||
|
quitAppDialog.showModal();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function stopGame(callbackFunction) {
|
function stopGame(callbackFunction) {
|
||||||
api.refreshServerInfo().then(function (ret) {
|
api.refreshServerInfo().then(function (ret) {
|
||||||
api.getAppById(api.currentGame).then(function (runningApp) {
|
api.getAppById(api.currentGame).then(function (runningApp) {
|
||||||
@ -530,10 +542,12 @@ function stopGame(callbackFunction) {
|
|||||||
api.quitApp().then(function (ret2) {
|
api.quitApp().then(function (ret2) {
|
||||||
api.refreshServerInfo().then(function (ret3) { // refresh to show no app is currently running.
|
api.refreshServerInfo().then(function (ret3) { // refresh to show no app is currently running.
|
||||||
showAppsMode();
|
showAppsMode();
|
||||||
|
stylizeBoxArt(api, runningApp.id);
|
||||||
if (typeof(callbackFunction) === "function") callbackFunction();
|
if (typeof(callbackFunction) === "function") callbackFunction();
|
||||||
}, function (failedRefreshInfo2) {
|
}, function (failedRefreshInfo2) {
|
||||||
console.log('ERROR: failed to refresh server info!');
|
console.log('ERROR: failed to refresh server info!');
|
||||||
console.log('Returned error was: ' + failedRefreshInfo2);
|
console.log('Returned error was: ' + failedRefreshInfo2);
|
||||||
|
console.log('failed server was: ' + api.toString());
|
||||||
});
|
});
|
||||||
}, function (failedQuitApp) {
|
}, function (failedQuitApp) {
|
||||||
console.log('ERROR: failed to quit app!');
|
console.log('ERROR: failed to quit app!');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user