Skip to content
Permalink
Browse files

Show warning when attempting to load an old savegame (#1941)

  • Loading branch information
lluchs committed Dec 28, 2017
1 parent df979bb commit 2b3863a12cf94faf27629c1f6cbcaad3bbf20377
@@ -693,6 +693,7 @@ IDS_MSG_REPLAYPLRS_DESC=In den Hauptrollen
IDS_MSG_RESOLUTION_DESC=Bildschirmauflösung im Vollbildmodus.
IDS_MSG_RESTARTCHANGECFG=Änderungen werden erst übernommen, wenn das Spiel neu gestartet wurde.
IDS_MSG_RNDTEAM=Zufallsteam
IDS_MSG_SAVEGAMEVERSIONMISMATCH=Dieser Spielstand stammt aus OpenClonk %d.%d und wird mit hoher Warscheinlichkeit mit dieser OpenClonk-Version nicht funktionieren. Trotzdem starten?
IDS_MSG_SCENARIODESC=Szenariobeschreibung
IDS_MSG_SCENARIODESC_LOADING=Lade... (%d%%)
IDS_MSG_SELECT=%s auswählen
@@ -693,6 +693,7 @@ IDS_MSG_REPLAYPLRS_DESC=Starring
IDS_MSG_RESOLUTION_DESC=Select screen resolution in fullscreen mode.
IDS_MSG_RESTARTCHANGECFG=For changes to take effect the program has to be restarted.
IDS_MSG_RNDTEAM=Random team
IDS_MSG_SAVEGAMEVERSIONMISMATCH=This savegame was created in OpenClonk %d.%d. It will likely not work with this version of OpenClonk. Start anyways?
IDS_MSG_SCENARIODESC=Scenario description
IDS_MSG_SCENARIODESC_LOADING=Loading... (%d%%)
IDS_MSG_SELECT=Select %s
@@ -761,7 +761,7 @@ bool C4ScenarioListLoader::Scenario::Start()
return (C4StartupScenSelDlg::pInstance)->StartScenario(this);
}

bool C4ScenarioListLoader::Scenario::CanOpen(StdStrBuf &sErrOut)
bool C4ScenarioListLoader::Scenario::CanOpen(StdStrBuf &sErrOut, bool &CanHide)
{
// safety
C4StartupScenSelDlg *pDlg = C4StartupScenSelDlg::pInstance;
@@ -793,6 +793,14 @@ bool C4ScenarioListLoader::Scenario::CanOpen(StdStrBuf &sErrOut)
// Some scenarios have adjusted MaxPlayerCount to 0 after starting to prevent future joins
// make sure it's possible to start the savegame anyway
iMaxPlrCount = std::max<int32_t>(iMinPlrCount, iMaxPlrCount);

// <Sven2> Savegames store a lot of internal stuff. If you updated clonk in the meantime, many things tend to break
if (C4S.Head.C4XVer[0] != C4XVER1 || C4S.Head.C4XVer[1] != C4XVER2)
{
// Only show a warning to let players try it anyways.
sErrOut.Format(LoadResStr("IDS_MSG_SAVEGAMEVERSIONMISMATCH"), C4S.Head.C4XVer[0], C4S.Head.C4XVer[1]);
CanHide = false;
}
}
// normal scenarios: At least one player except in network mode, where it is possible to wait for the additional players
// Melees need at least two
@@ -803,6 +811,7 @@ bool C4ScenarioListLoader::Scenario::CanOpen(StdStrBuf &sErrOut)
// network game: Players may yet join in lobby
// only issue a warning for too few players (by setting the error but not returning false here)
sErrOut.Format(LoadResStr("IDS_MSG_TOOFEWPLAYERSNET"), (int) iMinPlrCount);
CanHide = true;
}
else
{
@@ -1298,8 +1307,8 @@ C4StartupScenSelDlg::ScenListItem::ScenListItem(C4GUI::ListBox *pForListBox, C4S
{
assert(pScenListEntry);
CStdFont &rUseFont = C4Startup::Get()->Graphics.BookFont;
StdStrBuf sIgnore;
bool fEnabled = pScenListEntry->CanOpen(sIgnore) && !pScenListEntry->IsGrayed();
StdStrBuf sIgnore; bool bIgnore;
bool fEnabled = pScenListEntry->CanOpen(sIgnore, bIgnore) && !pScenListEntry->IsGrayed();
// calc height
int32_t iHeight = rUseFont.GetLineHeight() + 2 * IconLabelSpacing;
// create subcomponents
@@ -1779,15 +1788,16 @@ bool C4StartupScenSelDlg::DoOK()
if (!pSel) return false;
// check if open is possible
StdStrBuf sError;
if (!pSel->CanOpen(sError))
bool CanHide = false;
if (!pSel->CanOpen(sError, CanHide))
{
GetScreen()->ShowMessage(sError.getData(), LoadResStr("IDS_MSG_CANNOTSTARTSCENARIO"), C4GUI::Ico_Error);
return false;
}
// if CanOpen returned true but set an error message, that means it's a warning. Display it!
if (sError.getLength())
{
if (!GetScreen()->ShowMessageModal(sError.getData(), LoadResStrNoAmp("IDS_DLG_STARTGAME"), C4GUI::MessageDialog::btnOKAbort, C4GUI::Ico_Notify, &Config.Startup.HideMsgStartDedicated))
if (!GetScreen()->ShowMessageModal(sError.getData(), LoadResStrNoAmp("IDS_DLG_STARTGAME"), C4GUI::MessageDialog::btnOKAbort, C4GUI::Ico_Notify, CanHide ? &Config.Startup.HideMsgStartDedicated : nullptr))
// user chose to not start it
return false;
}
@@ -88,7 +88,7 @@ class C4ScenarioListLoader

static Entry *CreateEntryForFile(const StdStrBuf &sFilename, C4ScenarioListLoader *pLoader, Folder *pParent); // create correct entry type based on file extension

virtual bool CanOpen(StdStrBuf &sError) { return true; } // whether item can be started/opened (e.g. mission access, unregistered)
virtual bool CanOpen(StdStrBuf &sError, bool &CanHide) { return true; } // whether item can be started/opened (e.g. mission access, unregistered)
virtual bool IsGrayed() { return false; } // additional condition for graying out - notice unreg folders are grayed but can still be opened
virtual bool IsHidden() { return false; } // condition for hiding element completely
virtual bool HasMissionAccess() const { return true; }
@@ -126,7 +126,7 @@ class C4ScenarioListLoader
bool LoadCustomPre(C4Group &rGrp) override; // load scenario core
bool Start() override; // launch scenario!

bool CanOpen(StdStrBuf &sError) override; // check mission access, player count, etc.
bool CanOpen(StdStrBuf &sError, bool &CanHide) override; // check mission access, player count, etc.
bool IsGrayed() override { return false; } // additional option for graying out
bool IsHidden() override { return C4S.Head.Secret && !HasMissionAccess(); } // condition for hiding element completely
bool HasMissionAccess() const override { return !fNoMissionAccess; }; // check mission access only
@@ -176,7 +176,7 @@ class C4ScenarioListLoader
void Resort() { Sort(); }
Entry *FindEntryByName(const char *szFilename) const; // find entry by filename comparison

bool CanOpen(StdStrBuf &sError) override { return true; } // can always open folders
bool CanOpen(StdStrBuf &sError, bool &CanHide) override { return true; } // can always open folders
bool IsGrayed() override; // unreg folders can be opened to view stuff but they are still grayed out for clarity
StdStrBuf GetOpenText() override; // get open button text
StdStrBuf GetOpenTooltip() override;

0 comments on commit 2b3863a

Please sign in to comment.
You can’t perform that action at this time.