mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-07-04 05:55:47 -07:00
When a patch version is released, it must declare compatibility with the previous patch versions of the same main release. This allows players to keep replaying their games and to keep playing online with users of other patches of the same main release. This should have anticipated fordae7a8c394(cherry picked from commit866d6f0527) Signed-off-by: phosit <phosit@autistici.org>
69 lines
2.1 KiB
JavaScript
69 lines
2.1 KiB
JavaScript
/**
|
||
* This class is responsible for display and performance of the Load button.
|
||
*/
|
||
class SavegameLoader
|
||
{
|
||
constructor(closePageCallback)
|
||
{
|
||
this.closePageCallback = closePageCallback;
|
||
this.confirmButton = Engine.GetGUIObjectByName("confirmButton");
|
||
this.confirmButton.caption = translate("Load");
|
||
this.confirmButton.enabled = false;
|
||
}
|
||
|
||
onSelectionChange(gameID, metadata, label)
|
||
{
|
||
this.confirmButton.enabled = !!metadata;
|
||
this.confirmButton.onPress = () => {
|
||
this.loadGame(gameID, metadata);
|
||
};
|
||
}
|
||
|
||
async loadGame(gameId, metadata)
|
||
{
|
||
// Check compatibility before really loading it
|
||
const engineInfo = Engine.GetEngineInfo();
|
||
const sameMods = hasSameMods(metadata.mods, engineInfo.mods);
|
||
const compatibleEngineVersions = metadata.engine_serialization_version && metadata.engine_serialization_version == engineInfo.engine_serialization_version;
|
||
|
||
if (compatibleEngineVersions && sameMods)
|
||
{
|
||
this.closePageCallback(gameId);
|
||
return;
|
||
}
|
||
|
||
// Version not compatible ... ask for confirmation
|
||
let message = "";
|
||
|
||
if (!compatibleEngineVersions)
|
||
{
|
||
if (metadata.engine_serialization_version)
|
||
message += sprintf(translate("This savegame needs 0 A.D. version %(requiredCompatibleVersion)s or compatible. You are running version %(currentVersion)s, compatible down to %(compatibleVersion)s."), {
|
||
"requiredCompatibleVersion": metadata.engine_serialization_version,
|
||
"currentVersion": engineInfo.engine_version,
|
||
"compatibleVersion": engineInfo.engine_serialization_version,
|
||
}) + "\n";
|
||
else
|
||
message += translate("This savegame needs an older version of 0 A.D.") + "\n";
|
||
}
|
||
|
||
if (!sameMods)
|
||
{
|
||
if (!metadata.mods)
|
||
metadata.mods = [];
|
||
|
||
message += translate("This savegame needs a different sequence of mods:") + "\n" +
|
||
comparedModsString(metadata.mods, engineInfo.mods) + "\n";
|
||
}
|
||
|
||
message += translate("Do you still want to proceed?");
|
||
|
||
const buttonIndex = await messageBox(
|
||
500, 250,
|
||
message,
|
||
translate("Warning"),
|
||
[translate("No"), translate("Yes")]);
|
||
if (buttonIndex === 1)
|
||
this.closePageCallback(gameId);
|
||
}
|
||
}
|