Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/session/MenuButtons.js
Show First 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | Engine.PushGuiPage( | ||||
"timeElapsed": simState.timeElapsed | "timeElapsed": simState.timeElapsed | ||||
}, | }, | ||||
"gui": { | "gui": { | ||||
"dialog": true, | "dialog": true, | ||||
"isInGame": true | "isInGame": true | ||||
}, | }, | ||||
"selectedData": this.selectedData | "selectedData": this.selectedData | ||||
}, | }, | ||||
data => | data => { | ||||
{ | |||||
this.selectedData = data.summarySelectedData; | this.selectedData = data.summarySelectedData; | ||||
this.pauseControl.implicitResume(); | this.pauseControl.implicitResume(); | ||||
}); | }); | ||||
} | } | ||||
}; | }; | ||||
MenuButtons.prototype.Lobby = class | MenuButtons.prototype.Lobby = class | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | MenuButtons.prototype.Resign = class | ||||
rebuild() | rebuild() | ||||
{ | { | ||||
this.button.enabled = !g_IsObserver; | this.button.enabled = !g_IsObserver; | ||||
} | } | ||||
onPress() | onPress() | ||||
{ | { | ||||
closeOpenDialogs(); | (new ResignConfirmation()).display(); | ||||
this.pauseControl.implicitPause(); | |||||
messageBox( | |||||
400, 200, | |||||
translate("Are you sure you want to resign?"), | |||||
translate("Confirmation"), | |||||
[translate("No"), translate("Yes")], | |||||
[ | |||||
resumeGame, | |||||
() => { | |||||
Engine.PostNetworkCommand({ | |||||
"type": "resign" | |||||
}); | |||||
resumeGame(); | |||||
} | |||||
]); | |||||
} | } | ||||
}; | }; | ||||
MenuButtons.prototype.Exit = class | MenuButtons.prototype.Exit = class | ||||
{ | { | ||||
constructor(button, pauseControl) | constructor(button, pauseControl) | ||||
{ | { | ||||
this.button = button; | this.button = button; | ||||
this.button.caption = translate("Exit"); | this.button.caption = translate("Exit"); | ||||
this.button.enabled = !Engine.IsAtlasRunning(); | this.button.enabled = !Engine.IsAtlasRunning(); | ||||
this.pauseControl = pauseControl; | this.pauseControl = pauseControl; | ||||
} | } | ||||
onPress() | onPress() | ||||
{ | { | ||||
closeOpenDialogs(); | for (let name in QuitConfirmationMenu.prototype) | ||||
this.pauseControl.implicitPause(); | { | ||||
let quitConfirmation = new QuitConfirmationMenu.prototype[name](); | |||||
let messageType = g_IsNetworked && g_IsController ? "host" : | if (quitConfirmation.enabled()) | ||||
(g_IsNetworked && !g_IsObserver ? "client" : "singleplayer"); | quitConfirmation.display(); | ||||
messageBox( | |||||
400, 200, | |||||
this.Confirmation[messageType].caption(), | |||||
translate("Confirmation"), | |||||
[translate("No"), translate("Yes")], | |||||
this.Confirmation[messageType].buttons()); | |||||
} | |||||
}; | |||||
MenuButtons.prototype.Exit.prototype.Confirmation = { | |||||
"host": { | |||||
"caption": () => translate("Are you sure you want to quit? Leaving will disconnect all other players."), | |||||
"buttons": () => [resumeGame, endGame] | |||||
}, | |||||
"client": { | |||||
"caption": () => translate("Are you sure you want to quit?"), | |||||
"buttons": () => [ | |||||
resumeGame, | |||||
() => { | |||||
messageBox( | |||||
400, 200, | |||||
translate("Do you want to resign or will you return soon?"), | |||||
translate("Confirmation"), | |||||
[translate("I will return"), translate("I resign")], | |||||
[ | |||||
endGame, | |||||
() => { | |||||
Engine.PostNetworkCommand({ | |||||
"type": "resign" | |||||
}); | |||||
resumeGame(); | |||||
} | |||||
]); | |||||
} | } | ||||
] | |||||
}, | |||||
"singleplayer": { | |||||
"caption": () => translate("Are you sure you want to quit?"), | |||||
"buttons": () => [resumeGame, endGame] | |||||
} | } | ||||
}; | }; |
Wildfire Games · Phabricator