Exemplo n.º 1
0
bool retcon::OnInit() {
	raii_set rs;
	//wxApp::OnInit();	//don't call this, it just calls the default command line processor
	SetAppName(appname);
	InitWxLogger();
	rs.add([&]() { DeInitWxLogger(); });
	::wxInitAllImageHandlers();
	srand((unsigned int) time(nullptr));
	datadir = stdstrwx(wxStandardPaths::Get().GetUserDataDir());
	cmdlineproc(argv, argc);
	if(terms_requested) return false;
	if(!globallogwindow) new log_window(nullptr, LOGT::GROUP_LOGWINDEF, false);
	if(!datadir.empty() && datadir.back() == '/') datadir.pop_back();
	wxString wxdatadir = wxstrstd(datadir);
	if(!::wxDirExists(wxdatadir)) {
		::wxMkdir(wxdatadir, 0700);
	}
	InitCFGDefaults();
	SetTermSigHandler();
	sm.InitMultiIOHandler();
	rs.add([&]() { sm.DeInitMultiIOHandler(); });
	bool res = DBC_Init(datadir + "/retcondb.sqlite3");
	if(!res) return false;
	rs.add([&]() { DBC_DeInit(); });
	if(terms_requested) return false;
	pool.reset(new ThreadPool::Pool(gc.threadpoollimit));

	InitGlobalFilters();

	RestoreWindowLayout();
	if(mainframelist.empty()) {
		mainframe *mf = new mainframe( appversionname, wxPoint(50, 50), wxSize(450, 340));

		if(alist.empty() && ad.tpanels.empty()) {
			//everything is empty, maybe new user
			//make 3 basic auto tpanels to make things more obvious
			auto flags = TPF::AUTO_ALLACCS | TPF::DELETEONWINCLOSE;
			auto tpt = tpanel::MkTPanel("", "", flags | TPF::AUTO_TW, 0);
			tpt->MkTPanelWin(mf, true);
			auto tpm = tpanel::MkTPanel("", "", flags | TPF::AUTO_MN, 0);
			tpm->MkTPanelWin(mf, false);
			auto tpd = tpanel::MkTPanel("", "", flags | TPF::AUTO_DM, 0);
			tpd->MkTPanelWin(mf, false);
		}
	}

	if(terms_requested) return false;

	mainframelist[0]->Show(true);
	for(auto it=alist.begin(); it!=alist.end(); ++it) {
		(*it)->Setup();
		(*it)->CalcEnabled();
		(*it)->Exec();
	}

	if(terms_requested) return false;

	rs.cancel();
	return true;
}
Exemplo n.º 2
0
	TestInitializer()
	{
		InitWxLogger();
	}