void Game::ShowSplashScreen()
{	
  SplashScreen splashScreen;

  splashScreen.Show(_mainWindow);
 _gameState = Game::ShowingMenu;
}
예제 #2
0
파일: drawapp.cpp 프로젝트: Strongc/szarp
bool DrawApp::OnInit() {


	/* Read params from szarp.cfg. */
#if wxUSE_UNICODE
	libpar_read_cmdline_w(&argc, argv);
#else
	libpar_read_cmdline(&argc, argv);
#endif

#if BOOST_FILESYSTEM_VERSION == 3
	boost::filesystem::wpath::imbue(std::locale("C")); 	
#else
	boost::filesystem::wpath_traits::imbue(std::locale("C")); 	
#endif

	if (!DrawGLApp::OnInit())
		return false;


	SetProgName(_T("Draw 3"));
	//signal(SIGINT, INThandler);

	if (m_just_print_version) {
		std::cout << SZARP_VERSION << std::endl;
		return false;
	}
	m_server = NULL;
	m_db_queue = NULL;
	m_executor = NULL;
	m_remarks_handler = NULL;

#ifdef __WXGTK__
	libpar_init();

	char *base = NULL;
	if (m_base == wxEmptyString) {
		base = libpar_getpar("", "config_prefix", 1);
		m_base = SC::L2S(base);
		free(base);
	}

	{

		if (m_base_type != IKS_BASE) {
			char *iks_server = libpar_getpar("draw3", "iks_server", 0);
			if (iks_server) {
				m_iks_server = SC::L2S(iks_server);
				m_base_type = IKS_BASE;
				free(iks_server);
			}

			char *iks_port = libpar_getpar("draw3", "iks_server_port", 0);
			if (iks_port) {
				m_iks_port = SC::L2S(iks_port);
				free(iks_port);
			}
		}
	}

	m_probers_from_szarp_cfg = get_probers_addresses();
#endif

#ifdef MINGW32
	WORD wVersionRequested = MAKEWORD(2, 2);
	WSADATA wsaData;
	WSAStartup(wVersionRequested, &wsaData);
#endif
	/* Set logging to stderr. */
	wxLog *logger = new wxLogStderr();
	//wxLog *logger = new wxLogGui();
	wxLog::SetActiveTarget(logger);


	m_instance = new szSingleInstanceChecker(_T(".szarp_m_instance_lock"), wxEmptyString, 
			_T("draw3"));
	if (m_instance->IsAnotherRunning()) {
		if (!m_url.IsEmpty()) {
			if (m_url_open_in_existing)
				SendToRunningInstance(_T("START_URL"), m_url.c_str());
			else
				SendToRunningInstance(_T("START_URL_EXISTING"), m_url.c_str());
		} else if (!m_base.IsEmpty()) {		
			SendToRunningInstance(_T("START_BASE"), m_base.c_str());
		} else {
			wxLogError(_T("base not given"));
			return false;
		}
		return false;
	}
        

	InitGL();

	SplashScreen *splash = NULL;
	wxBitmap bitmap;

	// this loads draw64_xpm under Linux, or draw64 icon resource under Windows
	szFrame::setDefaultIcon(wxICON(draw64));

	wxString splashimage = GetSzarpDir();

#ifndef MINGW32
	splashimage += _T("resources/wx/images/szarp-logo.png");
#else
	splashimage += _T("resources\\wx\\images\\szarp-logo.png");
#endif

#if wxUSE_LIBPNG
	/* Activate PNG image handler. */
	wxImage::AddHandler( new wxPNGHandler );
#endif

	if (bitmap.LoadFile(splashimage, wxBITMAP_TYPE_PNG))
		splash = new SplashScreen(&bitmap);
	else
		splash = new SplashScreen();
	splash->Show(true);

	splash->PushStatusText(_("Setting locale..."));
	
	/* Set locale. */
	this->InitializeLocale(_T("draw3"), locale);

	splash->PushStatusText(_("Reading params from szarp.cfg..."));

	wxString _lang = wxConfig::Get()->Read(_T("LANGUAGE"), AUTO_LANGUAGE);
	if (_lang == AUTO_LANGUAGE)
		_lang = DEFAULT_LANGUAGE;

	splash->PushStatusText(_("Initializing IPKContainer..."));
	IPKContainer::Init(GetSzarpDataDir().c_str(), 
			GetSzarpDir().c_str(), 
			_lang.c_str());
	m_cfg_mgr = new ConfigManager(GetSzarpDataDir(), IPKContainer::GetObject());

	m_cfg_mgr->SetSplashScreen(splash);

	splash->PushStatusText(_("Initializing szbase..."));

	splash->PushStatusText(_("Initializing XML Resources..."));
    
	InitXmlResource();

	splash->PushStatusText(_("Starting database query mechanism..."));

	m_db_queue = new DatabaseQueryQueue();
	m_dbmgr = new DatabaseManager(m_db_queue, m_cfg_mgr);
	m_db_queue->SetDatabaseManager(m_dbmgr);
	m_dbmgr->SetProbersAddresses(GetProbersAddresses());

	Draw3Base* draw_base;
	switch (m_base_type) {
		case SZBASE_BASE:
			draw_base = new SzbaseBase(m_dbmgr, GetSzarpDataDir().c_str(),
				&ConfigurationFileChangeHandler::handle,
				wxConfig::Get()->Read(_T("SZBUFER_IN_MEMORY_CACHE"), 0L));
			break;
		case SZ4_BASE:
			draw_base = new Sz4Base(m_dbmgr, GetSzarpDataDir().c_str(),
				IPKContainer::GetObject());
			break;
		case IKS_BASE:
			draw_base = new Sz4ApiBase(m_dbmgr, m_iks_server.c_str(), m_iks_port.c_str(),
				IPKContainer::GetObject());
			break;
	}

	m_executor = new QueryExecutor(m_db_queue, m_dbmgr, draw_base);
	m_executor->Create();
	m_executor->SetPriority((WXTHREAD_MAX_PRIORITY + WXTHREAD_DEFAULT_PRIORITY) / 2);
	m_executor->Run();

	m_cfg_mgr->SetDatabaseManager(m_dbmgr);

	ConfigurationFileChangeHandler::database_manager = m_dbmgr;

	/* default config */
	wxString defid;

	DrawsSets *config = NULL;

	splash->PushStatusText(_("Loading configuration..."));

	/* init activity logger with base name as server name. This assumes that 
	 * server has written basename to /etc/hosts on linux machines and probably
	 * doesn't work on windows.
	 */
	UDPLogger::SetAppName( "draw3" );
	UDPLogger::SetAddress( (const char*)m_base.mb_str(wxConvUTF8) );
	UDPLogger::SetPort   ( "7777" );
	UDPLogger::LogEvent  ( "drawapp:start" );



	wxString prefix, window;
	PeriodType pt = PERIOD_T_YEAR;
	time_t time = -1;
	int selected_draw = 0;

	if (!m_url.IsEmpty()) {
		if (!decode_url(m_url, prefix, window, pt, time, selected_draw)) {
			wxLogError(_T("Invalid URL"));
			StopThreads();
			return FALSE;
		}
	} else if (!m_base.IsEmpty()) {
		if ((config = m_cfg_mgr->LoadConfig(m_base,std::wstring(),m_show_logparams)) == NULL) {
			wxLogError(_("Error occurred while loading default configuration. Check your szarp.cfg file."));
			StopThreads();
			return FALSE;
		}
		prefix = m_base;
	} else {
		wxLogError(_("Missing starting base specification."));
		StopThreads();
		return FALSE;
	}


#ifndef MINGW32
	libpar_done();
#endif

	m_help = new szHelpController;
#ifndef MINGW32
	m_help->AddBook(wxGetApp().GetSzarpDir() + L"/resources/documentation/new/draw3/html/draw3.hhp");
#else
	m_help->AddBook(wxGetApp().GetSzarpDir() + L"\\resources\\documentation\\new\\draw3\\html\\draw3.hhp");
#endif
	szHelpControllerHelpProvider* provider = new szHelpControllerHelpProvider;
	wxHelpProvider::Set(provider);
	provider->SetHelpController(m_help);

	splash->PushStatusText(_("Initizalizing remarks..."));
	
	m_remarks_handler = new RemarksHandler(m_cfg_mgr);
	m_remarks_handler->Start();
	
	splash->PushStatusText(_("Creating Frame Manager..."));

	VersionChecker* version_checker = new VersionChecker(argv[0]);
	version_checker->Start();

	FrameManager *fm = new FrameManager(m_dbmgr, m_cfg_mgr, m_remarks_handler);

	/*@michal  */
	if (!fm->CreateFrame(prefix, window, pt, time, wxSize(width, height), wxPoint(x, y), selected_draw, m_url.IsEmpty(), m_full_screen)) {
		StopThreads();
		wxLogError(_T("Unable to load base: %s"), prefix.c_str());
		return FALSE;
	}

	StartInstanceServer(fm, m_cfg_mgr);

	wxToolTip::SetDelay(1000);
    
	SetAppName(_T("SZARPDRAW3"));

	splash->Destroy();

	m_cfg_mgr->ResetSplashScreen();

#ifndef NO_GSTREAMER
	if (!gst_init_check(NULL, NULL, NULL)) 
		return 1;
#endif

	return TRUE;
}