mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-04-07 02:26:29 +02:00
Improve config version management
This commit is contained in:
parent
d0e8abf2c5
commit
d9818df879
1 changed files with 35 additions and 18 deletions
|
@ -13,8 +13,27 @@ bool MyApp::OnInit() {
|
||||||
CONFIG_CLOSE(conf);
|
CONFIG_CLOSE(conf);
|
||||||
|
|
||||||
// Advertise for configuration file version
|
// Advertise for configuration file version
|
||||||
if(version != CONFIG_VERSION)
|
if (version != CONFIG_VERSION) {
|
||||||
SHOW_DIALOG_INFO("Configuration files version missmatch. Expected "+std::string(CONFIG_VERSION)+" but got "+version+".\nPlease remove the current configuration file as it may crash the application.");
|
wxMessageDialog *dial = new wxMessageDialog(
|
||||||
|
NULL,
|
||||||
|
wxT("Configuration files version missmatch. Expected " +
|
||||||
|
std::string(CONFIG_VERSION) + " but got " + version +
|
||||||
|
".\nExisting OChess configuration must be erased.\n" +
|
||||||
|
"Do you still want to proceed?"),
|
||||||
|
wxT("Information"), wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION);
|
||||||
|
|
||||||
|
if (dial->ShowModal() != wxID_YES)
|
||||||
|
return false;
|
||||||
|
// First remove everything:
|
||||||
|
CONFIG_OPEN(conf2);
|
||||||
|
conf2->DeleteAll();
|
||||||
|
conf2->Write("version", CONFIG_VERSION);
|
||||||
|
CONFIG_CLOSE(conf2);
|
||||||
|
// Now Create new configuration:
|
||||||
|
CONFIG_OPEN(conf3);
|
||||||
|
conf3->Write("version", CONFIG_VERSION);
|
||||||
|
CONFIG_CLOSE(conf3);
|
||||||
|
}
|
||||||
|
|
||||||
// Main frame
|
// Main frame
|
||||||
MainWindow *frame = new MainWindow();
|
MainWindow *frame = new MainWindow();
|
||||||
|
@ -45,8 +64,6 @@ void MyApp::NewGame(std::shared_ptr<Game> g){
|
||||||
w->NewGame(g);
|
w->NewGame(g);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
wxIMPLEMENT_APP(MyApp);
|
wxIMPLEMENT_APP(MyApp);
|
||||||
|
|
||||||
void Abort(std::string msg) {
|
void Abort(std::string msg) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue