WIN_SPARKLE_API void win_sparkle_check_update_with_ui() { try { // Initialize UI thread and show progress indicator. UI::ShowCheckingUpdates(); // Then run the actual check in the background. UpdateChecker *check = new ManualUpdateChecker(); check->Start(); } CATCH_ALL_EXCEPTIONS }
WIN_SPARKLE_API void win_sparkle_init() { try { bool checkUpdates; if ( Settings::ReadConfigValue("CheckForUpdates", checkUpdates) ) { if ( checkUpdates ) { static const time_t ONE_DAY = 60*60*24; time_t lastCheck = 0; Settings::ReadConfigValue("LastCheckTime", lastCheck); const time_t currentTime = time(NULL); // Only check for updates in reasonable intervals: const int interval = win_sparkle_get_update_check_interval(); if ( currentTime - lastCheck >= interval ) { // Run the check in background. Only show UI if updates // are available. UpdateChecker *check = new UpdateChecker(); check->Start(); } } } else // not yet configured { bool didRunOnce; Settings::ReadConfigValue("DidRunOnce", didRunOnce, false); if ( !didRunOnce ) { // Do nothing on the first execution of the app, for better // first-time impression. Settings::WriteConfigValue("DidRunOnce", true); } else { // Only when the app is launched for the second time, ask the // user for their permission to check for updates. UI::AskForPermission(); } } } CATCH_ALL_EXCEPTIONS }
void MAJ::CheckForUpdate() { UpdateChecker * checker = UpdateChecker::Get(); checker->DownloadInformation(/*excludeFromStatistics=*/true); versionMAJTxt->SetLabel(gd::String::From(checker->newMajor)+"."+gd::String::From(checker->newMinor)+"."+gd::String::From(checker->newBuild)+"."+gd::String::From(checker->newRevision)); wxString info = _("No informations about the new version."); if ( !checker->info.empty() ) info = checker->info; wxString link = _("No link"); if ( !checker->link.empty() ) link = checker->link; infoEdit->ChangeValue(info); linkCtrl->SetLabel(link); linkCtrl->SetURL(link); linkCtrl->Refresh(); //Need to call manually update. //Too slow /*if ( checker->newVersionAvailable ) downloadAndInstallBt->Enable(true);*/ }
/** * Program entry point */ bool Game_Develop_EditorApp::OnInit() { //Setting up working directory: #ifdef LINUX string tmp; //Make sure current working directory is executable directory. if ( string(argv[0]) != "/" ) { char buffer[1024]; tmp += ( getcwd( buffer, 1024 ) ); tmp += "/"; } tmp += argv[0]; tmp = tmp.substr( 0, tmp.find_last_of( "/" ) ); chdir( tmp.c_str() ); #endif #ifdef WINDOWS wxString exeDirectory = argv[0]; //Make sure current working directory is executable directory. unsigned int backslashpos = exeDirectory.find_last_of( "\\" ); if ( backslashpos > exeDirectory.length() ) backslashpos = 0; unsigned int slashpos = exeDirectory.find_last_of( "/" ); if ( slashpos > exeDirectory.length() ) slashpos = 0; exeDirectory = exeDirectory.substr( 0, slashpos > backslashpos ? slashpos : backslashpos ); chdir( exeDirectory.c_str() ); #endif //Parse command line: wxCmdLineEntryDesc cmdLineDesc[] = { {wxCMD_LINE_PARAM, NULL, NULL, ("Files to open"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_MULTIPLE | wxCMD_LINE_PARAM_OPTIONAL}, {wxCMD_LINE_SWITCH, "h", "help", ("Display help about launching GDevelop using command line") }, {wxCMD_LINE_SWITCH, "v", "version", ("Display GDevelop version and quit"), wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP }, {wxCMD_LINE_OPTION, NULL, ("lang"), ("Force loading a specific language ( Example : /lang=en_GB )"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, {wxCMD_LINE_SWITCH, NULL, ("allowMultipleInstances"), ("Allow to launch GDevelop even if it is already opened") }, {wxCMD_LINE_SWITCH, NULL, ("noCrashCheck"), ("Don't check if GDevelop crashed during last use.") }, {wxCMD_LINE_NONE} }; wxCmdLineParser parser (cmdLineDesc, argc, argv); parser.AddUsageText("For more information about using GDevelop, please refer to the online help."); if ( parser.Parse(false) > 0 ) ; else if ( parser.Found( wxT("version") ) ) { cout << gd::VersionWrapper::FullString() << endl; return false; } else if ( parser.Found( wxT("help") ) ) { cout << parser.GetUsageString(); return false; } cout << "GDevelop initialization started:" << endl; SetAppName("GDIDE"); SetAppDisplayName("GDevelop IDE"); std::vector<std::string> filesToOpen; for (unsigned int i = 0;i<parser.GetParamCount();++i) { filesToOpen.push_back(string(parser.GetParam(i).mb_str())); } //Load configuration #if defined(LINUX) wxString ConfigPath = wxFileName::GetHomeDir() + "/.config/GDevelop/"; #else wxString ConfigPath = wxFileName::GetHomeDir() + "/.GDevelop/"; #endif if ( !wxDirExists( ConfigPath ) ) wxMkdir( ConfigPath ); wxFileConfig *config = new wxFileConfig( _T( "GDevelop" ), _T( "Compil Games" ), ConfigPath + "options.cfg" ); wxConfigBase::Set( config ); cout << "* Config file set." << endl; //Set language { wxString wantedLanguage; if ( !parser.Found( wxT("lang") )) config->Read("/Lang", &wantedLanguage); else parser.Found( wxT("lang"), &wantedLanguage); //If SelectLanguage.cfg file exists, then read the language from it if ( wxFileExists(ConfigPath+"SelectLanguage.cfg") ) { wxTextFile languageFile; languageFile.Open(ConfigPath+"SelectLanguage.cfg"); wantedLanguage = languageFile.GetFirstLine(); languageFile.Close(); wxRemoveFile(ConfigPath+"SelectLanguage.cfg"); } //Retrieve languages files std::vector <std::string> languagesAvailables; wxDir dir(wxGetCwd()+"/locale/"); wxString filename; bool cont = dir.GetFirst(&filename, "", wxDIR_DIRS); while ( cont ) { languagesAvailables.push_back(string(filename.mb_str())); cont = dir.GetNext(&filename); } //Retrieve selected language int languageId = wxLANGUAGE_DEFAULT; for (unsigned int i = 0;i<languagesAvailables.size();++i) { if ( wxLocale::FindLanguageInfo(languagesAvailables[i])->CanonicalName == wantedLanguage ) languageId = wxLocale::FindLanguageInfo(languagesAvailables[i])->Language; } gd::LocaleManager::Get()->SetLanguage(languageId); } cout << "* Language loaded" << endl; #ifdef RELEASE { wxLogNull noLogPlease; singleInstanceChecker = new wxSingleInstanceChecker; if ( singleInstanceChecker->IsAnotherRunning() && !parser.Found( wxT("allowMultipleInstances") ) ) { //There is already another instance running: Ask it to open the requested files. cout << "* Instance already existing: Redirecting the file to open to it." << endl; STClient * client = new STClient; wxString hostName = "localhost"; //Mandatory to provide the host ( for TCP/IP based implementations ). wxConnectionBase * connection = client->MakeConnection(hostName, "GDIDE", "GDevelop IDE"); if ( connection ) { for (unsigned int i = 0; i < filesToOpen.size(); ++i) connection->Execute(filesToOpen[i]); connection->Disconnect(); delete connection; } else { if ( !filesToOpen.empty() ) wxMessageBox(_("It seems that GDevelop is busy and can't open the requested file.\nPlease close any open dialogs and retry."), _("Sorry! :/"), wxICON_INFORMATION|wxOK); } delete client; delete singleInstanceChecker; cout << "* Bye!" << endl; return false; // OnExit() won't be called if we return false } else { //No other instance running: Set this instance as the main one, creating a server that will //be called by other instance if necessary. server = new STServer; if ( !server->Create("GDIDE") ) cout << " * FAILED to create an IPC service."; } } #endif cout << "* Single instance handling done" << endl; wxInitAllImageHandlers(); cout << "* Image handlers loaded" << endl; //Check if the last session terminated not normally. bool recoveringFromBug = false; #if defined(RELEASE) if ( !parser.Found( wxT("noCrashCheck") ) && wxFileExists(wxFileName::GetTempDir()+"/GameDevelopRunning.log") && !wxFileExists(wxFileName::GetTempDir()+"/ExtensionBeingLoaded.log") ) { recoveringFromBug = true; //Get the files opened during the last crash std::vector<string> openedFiles; wxTextFile projectsLogFile(wxFileName::GetTempDir()+"/GameDevelopRunning.log"); if (projectsLogFile.Open()) { for (wxString str = projectsLogFile.GetFirstLine(); !projectsLogFile.Eof(); str = projectsLogFile.GetNextLine()) openedFiles.push_back(gd::ToString(str)); } projectsLogFile.Close(); //Show an explanation window and offer the user to load the autosaves. BugReport dialog(NULL, openedFiles); if ( dialog.ShowModal() == 1 ) { for (unsigned int i = 0; i < openedFiles.size(); ++i) { if ( wxFileExists(openedFiles[i]+".autosave") ) filesToOpen.push_back(openedFiles[i]+".autosave"); } } } #endif cout << "* Crash management ended" << endl; //Creating the console Manager /* Deactivated, as the compilation thread can output messages at any time, resulting in the wxTextCtrl of console frame to be updated at any time which is dangerous ( GUI must be only updated from main thread ) #if defined(RELEASE) && defined(WINDOWS) ConsoleManager * consoleManager; consoleManager = ConsoleManager::Get(); cout << "ConsoleManager created" << endl; #endif */ //Splash screen wxBitmap bitmap; bitmap.LoadFile( wxString("res/GD-Splashscreen.png"), wxBITMAP_TYPE_PNG ); SplashScreen * splash = new SplashScreen(bitmap, 2, 0, -1, wxNO_BORDER | wxFRAME_SHAPED); cout << "* Splash Screen created" << endl; //Create the file logging the opened projects wxFile errorDetectFile(wxFileName::GetTempDir()+"/GameDevelopRunning.log", wxFile::write); errorDetectFile.Write(" "); errorDetectFile.Close(); //Les log cout << "* Displaying GDevelop version information :" << endl; cout << "GDevelop " << gd::VersionWrapper::FullString() << ", built " << gd::VersionWrapper::Date() << "/" << gd::VersionWrapper::Month() << "/" << gd::VersionWrapper::Year() << endl; cout << "* Creating a useless SFML texture" << endl; sf::RenderWindow window; sf::Window window2; cout << "* Removing CppPlatform/Extensions/AStarAutomatism.xgdle" << endl; if ( wxFileExists("CppPlatform/Extensions/AStarAutomatism.xgdle") ) wxRemoveFile("CppPlatform/Extensions/AStarAutomatism.xgdle"); //Load platforms and extensions cout << "* Loading platforms and extensions:" << endl; bool loadExtensions = true; #if defined(RELEASE) if ( !parser.Found( wxT("noCrashCheck") ) && wxFileExists(wxFileName::GetTempDir()+"/ExtensionBeingLoaded.log") ) { int whattodo = 0; { wxTextFile extensionErrorDetectFile; extensionErrorDetectFile.Open(wxFileName::GetTempDir()+"/ExtensionBeingLoaded.log"); ExtensionBugReportDlg dialog(NULL, extensionErrorDetectFile.GetFirstLine()); whattodo = dialog.ShowModal(); } wxRemoveFile(wxFileName::GetTempDir()+"/ExtensionBeingLoaded.log"); if ( whattodo == 0 ) return false; else if ( whattodo == 1 ) loadExtensions = false; } #endif if ( loadExtensions ) gd::PlatformLoader::LoadAllPlatformsInManager("."); #if defined(RELEASE) wxSetAssertHandler(NULL); //Don't want to have annoying assert dialogs in release #endif cout << "* Platform and extensions loading ended." << endl; wxFileSystem::AddHandler( new wxZipFSHandler ); //Creating main window cout << "* Creating main window" << endl; mainEditor = new MainFrame( 0 ); SetTopWindow( mainEditor ); //Open files for (unsigned int i = 0;i<filesToOpen.size();++i) mainEditor->Open(filesToOpen[i]); cout << "* Connecting shortcuts" << endl; Connect(wxID_ANY,wxEVT_KEY_DOWN, wxKeyEventHandler(Game_Develop_EditorApp::OnKeyPressed)); //Set help provider { gd::HelpFileAccess::Get()->SetHelpProvider(::HelpProvider::Get()); ::HelpProvider::Get()->SetParentWindow(mainEditor); } cout << "* Help provider set" << endl; cout << "* Loading events editor configuration" << endl; gd::InstructionSentenceFormatter::Get()->LoadTypesFormattingFromConfig(); //Save the event to log file cout << "* Creating log file (if activated)" << endl; LogFileManager::Get()->InitalizeFromConfig(); LogFileManager::Get()->WriteToLogFile("GDevelop initialization ended"), //Fin du splash screen, affichage de la fenêtre splash->Destroy(); mainEditor->Show(); cout << "* Initializing platforms..." << endl; gd::PlatformManager::Get()->NotifyPlatformIDEInitialized(); cout << "* Initialization ended." << endl; //gd::LogWarning(_("This is a beta version of GDevelop 3.\n\nSome features may be missing and bugs present: Report any feedback on www.forum.compilgames.net.\nThanks!")); //Checking for updates { wxString result; config->Read( "Startup/CheckUpdate", &result ); if ( result != "false" ) { UpdateChecker * checker = UpdateChecker::Get(); checker->DownloadInformation(); if ( checker->newVersionAvailable ) { MAJ dialog(mainEditor, true); if ( dialog.ShowModal() == 2 ) { mainEditor->Destroy(); return true; } } } mainEditor->RefreshNews(); } //Pay what you want reminder if (!recoveringFromBug) { int result = 3; config->Read( "Startup/Reminder", &result ); //Force again the display when upgrading from a version older than 3.3.71 bool reminder3371Shown = false; config->Read( "Startup/Reminder3371Shown", &reminder3371Shown ); if (!reminder3371Shown) { result = 3; config->Write( "Startup/Reminder3371Shown", true); } //Decrement the counter and show the reminder only after 3 launch in a row. if ( result > 0 ) { result--; config->Write( "Startup/Reminder", result); } if ( result == 0 ) { ReminderDialog dialog(mainEditor); dialog.ShowModal(); } } return true; }
bool Application::OnInit() { #if defined __DEBUG_MODE__ && defined __WINDOWS__ _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); #endif std::cout << "This is free software: you are free to change and redistribute it." << std::endl; std::cout << "There is NO WARRANTY, to the extent permitted by law." << std::endl; std::cout << "Review COPYING in RME distribution for details." << std::endl; mt_seed(time(nullptr)); srand(time(nullptr)); // Discover data directory gui.discoverDataDirectory("clients.xml"); // Tell that we are the real thing wxAppConsole::SetInstance(this); // Load some internal stuff settings.load(); FixVersionDiscrapencies(); gui.LoadHotkeys(); ClientVersion::loadVersions(); #ifdef _USE_PROCESS_COM proc_server = nullptr; // Setup inter-process communice! if(settings.getInteger(Config::ONLY_ONE_INSTANCE)) { { // Prevents WX from complaining 'bout there being no server. wxLogNull nolog; RMEProcessClient client; wxConnectionBase* n_connection = client.MakeConnection(wxT("localhost"), wxT("rme_host"), wxT("rme_talk")); if(n_connection) { RMEProcessConnection* connection = dynamic_cast<RMEProcessConnection*>(n_connection); ASSERT(connection); std::pair<bool, FileName> ff = ParseCommandLineMap(); if(ff.first) { connection->AskToLoad(ff.second); connection->Disconnect(); #if defined __DEBUG_MODE__ && defined __WINDOWS__ gui.SaveHotkeys(); settings.save(true); #endif return false; } connection->Disconnect(); } } // We act as server then proc_server = newd RMEProcessServer(); if(!proc_server->Create(wxT("rme_host"))) { // Another instance running! delete proc_server; proc_server = nullptr; } } #endif // Image handlers //wxImage::AddHandler(newd wxBMPHandler); wxImage::AddHandler(newd wxPNGHandler); wxImage::AddHandler(newd wxJPEGHandler); wxImage::AddHandler(newd wxTGAHandler); gui.gfx.loadEditorSprites(); #ifndef __DEBUG_MODE__ //wxHandleFatalExceptions(true); #endif // Load all the dependency files std::string error; StringVector warnings; gui.root = newd MainFrame(wxT("Remere's Map Editor"), wxDefaultPosition, wxSize(700,500) ); SetTopWindow(gui.root); gui.SetTitle(wxT("")); gui.root->LoadRecentFiles(); // Load palette gui.LoadPerspective(); // Show all windows gui.root->Show(true); // Set idle event handling mode wxIdleEvent::SetMode(wxIDLE_PROCESS_SPECIFIED); // Goto RME website? if(settings.getInteger(Config::GOTO_WEBSITE_ON_BOOT) == 1) { ::wxLaunchDefaultBrowser(wxT("http://www.remeresmapeditor.com/"), wxBROWSER_NEW_WINDOW); settings.setInteger(Config::GOTO_WEBSITE_ON_BOOT, 0); } // Check for updates #ifdef _USE_UPDATER_ if(settings.getInteger(Config::USE_UPDATER) == -1) { int ret = gui.PopupDialog( wxT("Notice"), wxT("Do you want the editor to automatically check for updates?\n") wxT("It will connect to the internet if you choose yes.\n") wxT("You can change this setting in the preferences later."), wxYES | wxNO); if(ret == wxID_YES) { settings.setInteger(Config::USE_UPDATER, 1); } else { settings.setInteger(Config::USE_UPDATER, 0); } } if(settings.getInteger(Config::USE_UPDATER) == 1) { UpdateChecker updater; updater.connect(gui.root); } #endif FileName save_failed_file = gui.GetLocalDataDirectory(); save_failed_file.SetName(wxT(".saving.txt")); if(save_failed_file.FileExists()) { std::ifstream f(nstr(save_failed_file.GetFullPath()).c_str(), std::ios::in); std::string backup_otbm, backup_house, backup_spawn; getline(f, backup_otbm); getline(f, backup_house); getline(f, backup_spawn); // Remove the file f.close(); std::remove(nstr(save_failed_file.GetFullPath()).c_str()); // Query file retrieval if possible if(!backup_otbm.empty()) { int ret = gui.PopupDialog( wxT("Editor Crashed"), wxString( wxT("IMPORTANT! THE EDITOR CRASHED WHILE SAVING!\n\n") wxT("Do you want to recover the lost map? (it will be opened immedietely):\n")) << wxstr(backup_otbm) << wxT("\n") << wxstr(backup_house) << wxT("\n") << wxstr(backup_spawn) << wxT("\n"), wxYES | wxNO); if(ret == wxID_YES) { // Recover if the user so wishes std::remove(backup_otbm.substr(0, backup_otbm.size() - 1).c_str()); std::rename(backup_otbm.c_str(), backup_otbm.substr(0, backup_otbm.size() - 1).c_str()); if(backup_house.size()) { std::remove(backup_house.substr(0, backup_house.size() - 1).c_str()); std::rename(backup_house.c_str(), backup_house.substr(0, backup_house.size() - 1).c_str()); } if(backup_spawn.size()) { std::remove(backup_spawn.substr(0, backup_spawn.size() - 1).c_str()); std::rename(backup_spawn.c_str(), backup_spawn.substr(0, backup_spawn.size() - 1).c_str()); } // Load the map gui.LoadMap(wxstr(backup_otbm.substr(0, backup_otbm.size() - 1))); return true; } } } // Keep track of first event loop entry startup = true; return true; }
// Application entry point int main( int argc, char *argv[] ) { QT_REQUIRE_VERSION( argc, argv, "4.7.0" ); #ifndef QT_DEBUG qInstallMsgHandler( MessageHandler ); #endif MainApplication app( argc, argv ); XercesExt::XercesInit init; try { // We prevent Qt from constantly creating and deleting threads. // Using a negative number forces the threads to stay around; // that way, we always have a steady number of threads ready to do work. QThreadPool::globalInstance()->setExpiryTimeout( -1 ); // Specify the plugin folders // (language codecs and image loaders) app.addLibraryPath( "codecs" ); app.addLibraryPath( "iconengines" ); app.addLibraryPath( "imageformats" ); // Set application information for // easier use of QSettings classes QCoreApplication::setOrganizationName( "sigil-ebook" ); QCoreApplication::setOrganizationDomain("sigil-ebook.com"); QCoreApplication::setApplicationName( "sigil" ); QCoreApplication::setApplicationVersion(SIGIL_VERSION); // Setup the translator and load the translation for the selected language QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8")); QTranslator translator; SettingsStore settings; const QString qm_name = QString("sigil_%1").arg(settings.uiLanguage()); // Run though all locations and stop once we find and are able to load // an appropriate translation. foreach (QString path, UILanguage::GetPossibleTranslationPaths()) { if (QDir(path).exists()) { if (translator.load(qm_name, path)) { break; } } } app.installTranslator(&translator); // We set the window icon explicitly on Linux. // On Windows this is handled by the RC file, // and on Mac by the ICNS file. #ifdef Q_WS_X11 app.setWindowIcon( GetApplicationIcon() ); #endif // On Unix systems, we make sure that the temp folder we // create is accessible by all users. On Windows, there's // a temp folder per user. #ifndef Q_WS_WIN CreateTempFolderWithCorrectPermissions(); #endif // Needs to be created on the heap so that // the reply has time to return. UpdateChecker *checker = new UpdateChecker( &app ); checker->CheckForUpdate(); // Install an event filter for the application // so we can catch OS X's file open events AppEventFilter *filter = new AppEventFilter( &app ); app.installEventFilter( filter ); const QStringList &arguments = QCoreApplication::arguments(); if (arguments.contains("-t")) { std::cout << TempFolder::GetPathToSigilScratchpad().toStdString() << std::endl; return 1; //} else if (arguments.count() == 3) { // Used for an undocumented, unsupported *-to-epub // console conversion. USE AT YOUR OWN PERIL! return QuickConvert( arguments ); } else { // Normal startup MainWindow *widget = GetMainWindow( arguments ); widget->show(); return app.exec(); } } catch ( ExceptionBase &exception ) { Utility::DisplayExceptionErrorDialog( Utility::GetExceptionInfo( exception ) ); return 1; } }