void GUI::UnloadVersion() { UnnamedRenderingLock(); gfx.clear(); current_brush = nullptr; previous_brush = nullptr; house_brush = nullptr; house_exit_brush = nullptr; waypoint_brush = nullptr; optional_brush = nullptr; eraser = nullptr; normal_door_brush = nullptr; locked_door_brush = nullptr; magic_door_brush = nullptr; quest_door_brush = nullptr; hatch_door_brush = nullptr; window_door_brush = nullptr; if(loaded_version != CLIENT_VERSION_NONE) { //g_gui.UnloadVersion(); materials.clear(); brushes.clear(); item_db.clear(); gfx.clear(); FileName cdb = getLoadedVersion()->getLocalDataPath(); cdb.SetFullName(wxT("creatures.xml")); creature_db.saveToXML(cdb); creature_db.clear(); loaded_version = CLIENT_VERSION_NONE; } }
bool GUI::LoadVersion(ClientVersionID version, wxString& error, wxArrayString& warnings, bool force) { if(ClientVersion::get(version) == nullptr) { error = wxT("Unsupported client version! (8)"); return false; } if(version != loaded_version || force) { if(getLoadedVersion() != nullptr) // There is another version loaded right now, save window layout g_gui.SavePerspective(); // Disable all rendering so the data is not accessed while reloading UnnamedRenderingLock(); DestroyPalettes(); DestroyMinimap(); // Destroy the previous version UnloadVersion(); loaded_version = version; if(!getLoadedVersion()->hasValidPaths()) { if(!getLoadedVersion()->loadValidPaths()) { error = wxT("Couldn't load relevant data files"); loaded_version = CLIENT_VERSION_NONE; return false; } } bool ret = LoadDataFiles(error, warnings); if(ret) g_gui.LoadPerspective(); else loaded_version = CLIENT_VERSION_NONE; return ret; } return true; }
bool MainFrame::DoQuerySave(bool doclose) { if (!gui.IsEditorOpen()) { return true; } Editor& editor = *gui.GetCurrentEditor(); if (editor.IsLiveClient()) { long ret = gui.PopupDialog( wxT("Disconnect"), wxT("Do you want to disconnect?"), wxYES | wxNO ); if (ret != wxID_YES) { return false; } editor.CloseLiveServer(); return DoQuerySave(doclose); } else if (editor.IsLiveServer()) { long ret = gui.PopupDialog( wxT("Shutdown"), wxT("Do you want to shut down the server? (any clients will be disconnected)"), wxYES | wxNO ); if (ret != wxID_YES) { return false; } editor.CloseLiveServer(); return DoQuerySave(doclose); } else if (gui.ShouldSave()) { long ret = gui.PopupDialog( wxT("Save changes"), wxT("Do you want to save your changes to \"") + wxstr(gui.GetCurrentMap().getName()) + wxT("\"?"), wxYES | wxNO | wxCANCEL ); if (ret == wxID_YES) { if (gui.GetCurrentMap().hasFile()) { gui.SaveCurrentMap(true); } else { wxFileDialog file( this, wxT("Save..."), wxT(""), wxT(""), wxT("*.otbm"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); int32_t result = file.ShowModal(); if (result == wxID_OK) { gui.SaveCurrentMap(file.GetPath(), true); } else { return false; } } } else if (ret == wxID_CANCEL) { return false; } } if (doclose) { UnnamedRenderingLock(); gui.CloseCurrentEditor(); } return true; }