Exemplo n.º 1
0
void Show(void)
{
	/* 初始化控制台 */
	ConSetBackgroundColor(ConBlack);
	ConSetTextColor(ConWhite);
	ConClear();

	switch(iGameStatus)
	{
		case GameMainMenu:
			ShowMenu();
			break;
		case GameRunning:
			ShowGame();
			break;
		case GameWon:
			ShowWon();
			break;
		case GameLostLife:
			ShowLostLife();
			break;
		case GameLost:
			ShowLost();
			break;
		case GameExit:
			ShowExit();
			break;
		case GameSplashScreen:
			ShowSplash();
			break;

		default:
			break;
	}/* switch */
}
Exemplo n.º 2
0
void Magazin::appLoop()
{
    switch(_state)
    {
    case exitingState:
        _mainWindow.close();
        break;
    case showingSplashState:
        ShowSplash();
        break;
    case showingMenuState:
        ShowMenu();
        break;
    case showingLogInfoState:
        ShowLogInfo();
        break;
    case loggingState:
        ShowLogScreen();
        break;
    case registeringState:
        ShowRegisterScreen();
        break;
    case displayingCarsState:
        DisplayCars();
        break;
    case showingCarScreenState:
        ShowCarScreen();
        break;
    case showingMyCartState:
        ShowMyCartScreen();
        break;
    }
}
Exemplo n.º 3
0
void Game::GameLoop() {

    switch(_gameState)
    {
    case ShowingSplash:
        ShowSplash();
        break;
    case ShowingMenu:
        ShowMenu();
        break;
    case Playing:
        _mainWindow.clear(sf::Color::Black);

        _gameObjectManager.UpdateAll();
        _gameObjectManager.DrawAll(_mainWindow);
        _mainWindow.display();

        sf::Event gameEvent;

        while (_mainWindow.pollEvent(gameEvent))
        {
            switch (gameEvent.type)
            {
            case sf::Event::KeyPressed:
                if (gameEvent.key.code == sf::Keyboard::Escape) _gameState = ShowingMenu;
            break;
            case sf::Event::Closed:
            _gameState = Exiting;
            break;
            break;
            }
        }

        break;
    }

}
Exemplo n.º 4
0
CCoreApplication< APPLICATION, SETTINGS >::CCoreApplication( int &argc, char **argv, bool GUIenabled, QString customConfigPath )	//customConfigPath = QString() 

	: base_t( argc, argv, GUIenabled, customConfigPath.isEmpty() ? smApplicationPaths->mInternalDataDir.c_str() : customConfigPath )

	, mSettings( *smApplicationPaths, "ESA", q2t< std::string >( QgsApplication::applicationName() ) )

{
	LOG_TRACE( "Starting application instance construction..." );

// v4
//#ifdef WIN32
//#ifdef _DEBUG
//	_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
//#endif
//#endif

    assert__( smPrologueCalled );
	if ( !smPrologueCalled )
		throw CException( "CCoreApplication Prologue must be called before application construction." );

	
	CheckRunMode();

	
	CreateSplash();


	// QGIS paths
	//
	setPkgDataPath( mSettings.BratPaths().mInternalDataDir.c_str() ); // returned by QgsApplication::srsDbFilePath();	variable: mPkgDataPath
	LOG_TRACE( "srsDbFilePath==" + srsDbFilePath() );
	LOG_TRACE( "showSettings==" + showSettings() );
	LOG_TRACE( "qgisSettingsDirPath==" + qgisSettingsDirPath() );
	LOG_TRACE( "qgisUserDbFilePath==" + qgisUserDbFilePath() );		//variable mConfigPath
    LOG_TRACEstd( "Qt plugins==" + mSettings.BratPaths().mQtPluginsDir );
    LOG_TRACEstd( "QGIS plugins==" + mSettings.BratPaths().mQgisPluginsDir );


	// To be sure that number have always a decimal point (and not a comma or something else)
	//
	setlocale( LC_NUMERIC, "C" );


	ShowSplash( "Loading application settings..." );

	// Load configuration - I
	//
    if ( !mSettings.LoadConfig() )
	{		
		throw CException( "Error reading the configuration. Settings file: " + mSettings.FilePath() );
	}


	// Keep v3 happy
	//
	CTools::SetInternalDataDir( mSettings.BratPaths().mInternalDataDir );	assert__( CTools::DirectoryExists( CTools::GetInternalDataDir() ) );


	// Register Brat algorithms
	//
	LOG_TRACE( "Registering algorithms..." );
	RegisterAlgorithms();


	// OpenGL
	//
	ShowSplash( "Checking OpenGL..." );
	if ( mSettings.mCheckOpenGL )
	{
		CheckOpenGL();							//throws on failure
		LOG_TRACE( "OpenGL check successful." );
	}


	// Use application paths to initialize COperation internal path references
	//
	COperation::SetExecNames( mSettings.BratPaths() );


	// Load physical units system
	//
	std::string errorMsg;
	if ( !CTools::LoadAndCheckUdUnitsSystem( errorMsg ) )
	{
		std::cerr << errorMsg << std::endl;
		SimpleErrorBox( errorMsg.c_str() );
		throw false;
	}


	// Load aliases dictionary
	//
	CAliasesDictionary::LoadAliasesDictionary( &errorMsg, false );
	if ( !errorMsg.empty() )
	{
		std::cerr << "WARNING: " << errorMsg << std::endl;
		SimpleWarnBox( errorMsg );
	}

	
	// CODA - can only be done after SetInternalDataDir
	//
	assert__( CProduct::GetRefCount() <= 0 );
	//
	CProduct::CodaInit();


	// Load configuration - II - can only be done after CodaInit
	//
    if ( !mSettings.LoadConfigSelectionCriteria() )
	{		
		throw CException( "Error reading the configuration file." );
	}


    // (*) this can be statically set, but not statically 
	//	queried before ctor call (issues Qt assertion)
    //
#if defined (Q_OS_LINUX)
    mDefaultAppStyle = t2q( mSettings.getNameOfStyle( new QCleanlooksStyle, true ) );	//(*)
#else
	mDefaultAppStyle = getCurrentStyleName();											//(*)
#endif

    mSettings.setApplicationStyle( *this, mDefaultAppStyle );

	// Load XML processor and TasksProcessor
	//
	ShowSplash( "Loading scheduled tasks processor." );

    ::xercesc::XMLPlatformUtils::Initialize();

    if ( !CTasksProcessor::GetInstance() )
        CTasksProcessor::CreateInstance( mSettings.BratPaths().mExecutableDir );

	LOG_TRACE( "Scheduled tasks processor loaded." );


    //v4: remaining initialization in charge of the main window

	LOG_TRACE( "Finished application instance construction." );
}
Exemplo n.º 5
0
INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg)
	{
		case WM_INITDIALOG:
		{
			TranslateDialogDefault(hwndDlg);
			if (!png2dibavail) {
				ShowWindow(GetDlgItem(hwndDlg, IDC_PNG2DIBWARN), SW_SHOW);
				EnableWindow(GetDlgItem(hwndDlg, IDC_ACTIVE), false);
				EnableWindow(GetDlgItem(hwndDlg, IDC_RANDOM), false);
				EnableWindow(GetDlgItem(hwndDlg, IDC_SPLASHPATH), false);
				EnableWindow(GetDlgItem(hwndDlg, IDC_CHOOSESPLASH), false);
				EnableWindow(GetDlgItem(hwndDlg, IDC_SHOWVERSION), false);
				EnableWindow(GetDlgItem(hwndDlg, IDC_VERSIONPREFIX), false);
				EnableWindow(GetDlgItem(hwndDlg, IDC_SHOWTIME), false);
				EnableWindow(GetDlgItem(hwndDlg, IDC_ST_SPIN), false);
				EnableWindow(GetDlgItem(hwndDlg, IDC_FADEIN), false);
				EnableWindow(GetDlgItem(hwndDlg, IDC_FISTEP), false);
				EnableWindow(GetDlgItem(hwndDlg, IDC_FI_SPIN), false);
				EnableWindow(GetDlgItem(hwndDlg, IDC_FADEOUT), false);
				EnableWindow(GetDlgItem(hwndDlg, IDC_FOSTEP), false);
				EnableWindow(GetDlgItem(hwndDlg, IDC_FO_SPIN), false);
			} else {
				ReadDbConfig();
				TCHAR inBuf[80];
				DBVARIANT dbv = {0};
				if (!db_get_ts(NULL, MODNAME, "Path", &dbv))
				{
					_tcscpy_s(inBuf, dbv.ptszVal);
					db_free(&dbv);
				}
				else
					_tcscpy_s(inBuf, _T("splash\\splash.png"));
				SetDlgItemText(hwndDlg, IDC_SPLASHPATH, inBuf);

				if (!db_get_ts(NULL, MODNAME, "Sound", &dbv))
				{
					_tcscpy_s(inBuf, dbv.ptszVal);
					db_free(&dbv);
				}
				else
					_tcscpy_s(inBuf, _T("sounds\\startup.wav"));
				SetDlgItemText(hwndDlg, IDC_SNDPATH, inBuf);

				if (!db_get_ts(NULL, MODNAME, "VersionPrefix", &dbv))
				{
					_tcscpy_s(inBuf, dbv.ptszVal);
					db_free(&dbv);
				}
				else
					_tcscpy_s(inBuf, _T(""));
				SetDlgItemText(hwndDlg, IDC_VERSIONPREFIX, inBuf);

				if (options.active)
					CheckDlgButton(hwndDlg, IDC_ACTIVE, BST_CHECKED);
				if (options.playsnd && !options.inheritGS)
					CheckDlgButton(hwndDlg, IDC_PLAYSND, BST_INDETERMINATE);
				else if (options.playsnd)
					CheckDlgButton(hwndDlg, IDC_PLAYSND, BST_CHECKED);
				EnableWindow(GetDlgItem(hwndDlg, IDC_LOOPSOUND), false);
				if (options.fadein)
					CheckDlgButton(hwndDlg, IDC_FADEIN, BST_CHECKED);
				if (options.fadeout)
					CheckDlgButton(hwndDlg, IDC_FADEOUT, BST_CHECKED);
				if (options.random)
					CheckDlgButton(hwndDlg, IDC_RANDOM, BST_CHECKED);
				if (options.showversion)
					CheckDlgButton(hwndDlg, IDC_SHOWVERSION, BST_CHECKED);

				SetWindowText(GetDlgItem(hwndDlg, IDC_SHOWTIME), _itot(options.showtime, inBuf, 10));
				SetWindowText(GetDlgItem(hwndDlg, IDC_FISTEP), _itot(options.fisteps, inBuf, 10));
				SetWindowText(GetDlgItem(hwndDlg, IDC_FOSTEP), _itot(options.fosteps, inBuf, 10));

				SendDlgItemMessage(hwndDlg, IDC_SHOWTIME, EM_LIMITTEXT, 5, 0);
			}

			return TRUE;
		}

		case WM_COMMAND:
		{
			switch(LOWORD(wParam))
			{
				case IDC_PREVIEW:
				{
					ShowSplash(true);
					break;
				}

				case IDC_ACTIVE:
				case IDC_PLAYSND:
				case IDC_LOOPSOUND:
				case IDC_FADEIN:
				case IDC_FADEOUT:
				case IDC_SHOWTIME:
				case IDC_RANDOM:
				case IDC_SHOWVERSION:
				case IDC_FISTEP:
				case IDC_FOSTEP:
				{
					if (IsDlgButtonChecked(hwndDlg, IDC_FADEIN))
					{
						EnableWindow(GetDlgItem(hwndDlg, IDC_FISTEP), true);
						EnableWindow(GetDlgItem(hwndDlg, IDC_FI_SPIN), true);
					}
					else
					{
						EnableWindow(GetDlgItem(hwndDlg, IDC_FISTEP), false);
						EnableWindow(GetDlgItem(hwndDlg, IDC_FI_SPIN), false);
					}
					if (IsDlgButtonChecked(hwndDlg, IDC_FADEOUT))
					{
						EnableWindow(GetDlgItem(hwndDlg, IDC_FOSTEP), true);
						EnableWindow(GetDlgItem(hwndDlg, IDC_FO_SPIN), true);
					}
					else
					{
						EnableWindow(GetDlgItem(hwndDlg, IDC_FOSTEP), false);
						EnableWindow(GetDlgItem(hwndDlg, IDC_FO_SPIN), false);
					}

					if ((HWND)lParam != GetFocus())
						return 0;
					else {
						SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
						break;
					}
					break;
				}

				case IDC_CHOOSESPLASH:
				{
					TCHAR szTempPath[MAX_PATH], initDir[MAX_PATH];
					TCHAR *pos;

					if (Exists(szSplashFile))
					{
						_tcscpy_s(initDir, szSplashFile);
						pos = _tcsrchr(initDir, _T('\\'));
						if(pos != NULL) *pos = 0;
					}
					else
					{
						szMirDir = Utils_ReplaceVarsT(_T("%miranda_path%"));
						_tcscpy_s(initDir, szMirDir);
						mir_free(szMirDir);
					}

					OPENFILENAME ofn = {0};
					ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
					TCHAR tmp[MAX_PATH];
					mir_sntprintf(tmp, SIZEOF(tmp), _T("%s (*.png, *.bmp)%c*.png;*.bmp%c%c"), TranslateT("Graphic files"), 0, 0, 0);
					ofn.lpstrFilter = tmp;
					ofn.hwndOwner = 0;
					ofn.lpstrFile = szTempPath;
					ofn.nMaxFile = MAX_PATH;
					ofn.nMaxFileTitle = MAX_PATH;
					ofn.Flags = OFN_HIDEREADONLY;
					ofn.lpstrInitialDir = initDir;
					*szTempPath = '\0';
					ofn.lpstrDefExt = _T("");

					if (GetOpenFileName(&ofn)) 
					{
						_tcscpy_s(szSplashFile, szTempPath);

						#ifdef _DEBUG
							logMessage(_T("Set path"), szSplashFile);
						#endif

						// Make path relative
						int result = PathToRelativeT(szTempPath, szPath2Spash);			
						if(result && lstrlen(szPath2Spash) > 0)
						{
							if (options.random)
							{
								TCHAR *pos;
								pos = _tcsrchr(szPath2Spash, _T('\\'));
								if (pos != NULL) 
								{
									*pos = 0;
									_tcscat_s(szPath2Spash, _T("\\"));
								}
							}

							SetWindowText(GetDlgItem(hwndDlg, IDC_SPLASHPATH), szPath2Spash);
						}

						SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
					}

				break;
				}

				case IDC_CHOOSESND:
				{
					TCHAR szTempPath[MAX_PATH], initDir[MAX_PATH];
					TCHAR *pos;

					if (Exists(szSoundFile))
					{
						_tcscpy_s(initDir, szSoundFile);
						pos = _tcsrchr(initDir, _T('\\'));
						if(pos != NULL) *pos = 0;
					}
					else
					{
						szMirDir = Utils_ReplaceVarsT(_T("%miranda_path%"));
						_tcscpy_s(initDir, szMirDir);
						mir_free(szMirDir);
					}

					OPENFILENAME ofn = {0};
					ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
					TCHAR tmp[MAX_PATH];
					mir_sntprintf(tmp, SIZEOF(tmp), _T("%s (*.wav, *.mp3)%c*.wav;*.mp3%c%c"), TranslateT("Sound Files"), 0, 0, 0);
					ofn.lpstrFilter = tmp;
					ofn.hwndOwner = 0;
					ofn.lpstrFile = szTempPath;
					ofn.nMaxFile = MAX_PATH;
					ofn.nMaxFileTitle = MAX_PATH;
					ofn.Flags = OFN_HIDEREADONLY;
					ofn.lpstrInitialDir = initDir;
					*szTempPath = '\0';
					ofn.lpstrDefExt = _T("");

					if (GetOpenFileName(&ofn))
					{
						_tcscpy_s(szSoundFile,szTempPath);

						#ifdef _DEBUG
							logMessage(_T("Set sound path"), szSoundFile);
						#endif

						// Make path relative
						int result = PathToRelativeT(szTempPath, szSoundFilePath);			
						if(result && lstrlen(szSoundFile) > 0)
							SetWindowText(GetDlgItem(hwndDlg, IDC_SNDPATH),szSoundFilePath);

						SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
					}

				break;
				}
			}

				default:
				{
					if (HIWORD(wParam) != EN_CHANGE || (HWND) lParam != GetFocus())
						return 0;
					else
						SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
				}
			break;
		}

		case WM_NOTIFY:
		{
			if (((LPNMHDR)lParam)->idFrom == 0)
				switch (((LPNMHDR)lParam)->code)
				{
					case PSN_APPLY:
					{
						TCHAR tmp[MAX_PATH];

						GetWindowText(GetDlgItem(hwndDlg, IDC_SPLASHPATH), tmp, MAX_PATH);
						db_set_ts(NULL, MODNAME, "Path", tmp);

						GetWindowText(GetDlgItem(hwndDlg, IDC_SNDPATH), tmp, MAX_PATH);
						db_set_ts(NULL, MODNAME, "Sound", tmp);

						GetWindowText(GetDlgItem(hwndDlg, IDC_VERSIONPREFIX), tmp, MAX_PATH);
						db_set_ts(NULL, MODNAME, "VersionPrefix", tmp);
						_tcscpy_s(szPrefix, tmp);

						GetWindowText(GetDlgItem(hwndDlg, IDC_SHOWTIME), tmp, MAX_PATH);
						db_set_dw(NULL, MODNAME, "TimeToShow", _ttoi(tmp));
						options.showtime = _ttoi(tmp);

						GetWindowText(GetDlgItem(hwndDlg, IDC_FISTEP), tmp, MAX_PATH);
						db_set_dw(NULL, MODNAME, "FadeinSpeed", _ttoi(tmp));
						options.fisteps = _ttoi(tmp);

						GetWindowText(GetDlgItem(hwndDlg, IDC_FOSTEP), tmp, MAX_PATH);
						db_set_dw(NULL, MODNAME, "FadeoutSpeed", _ttoi(tmp));
						options.fosteps = _ttoi(tmp);

						if (IsDlgButtonChecked(hwndDlg, IDC_ACTIVE))
						{
							db_set_b(NULL, MODNAME, "Active", 1);
							options.active = 1;
						}
						else
						{
							db_set_b(NULL, MODNAME, "Active", 0);
							options.active = 0;
						}

						if (IsDlgButtonChecked(hwndDlg, IDC_PLAYSND))
						{
							db_set_b(NULL, MODNAME, "PlaySound", 1);
							options.playsnd = 1;
							db_set_b(NULL, MODNAME, "InheritGlobalSound", 1);
							options.inheritGS = 1;
						}
						else
						{
							db_set_b(NULL, MODNAME, "PlaySound", 0);
							options.playsnd = 0;
							db_set_b(NULL, MODNAME, "InheritGlobalSound", 0);
							options.inheritGS = 0;
						}

						if (IsDlgButtonChecked(hwndDlg, IDC_PLAYSND) == BST_INDETERMINATE)
						{
							db_set_b(NULL, MODNAME, "PlaySound", 1);
							options.playsnd = 1;
							db_set_b(NULL, MODNAME, "InheritGlobalSound", 0);
							options.inheritGS = 0;
						}
						
						/*
						if (IsDlgButtonChecked(hwndDlg, IDC_LOOPSOUND))
						{
							WritePrivateProfileString("Splash","LoopSound","1",szIniFile);
							options.loopsnd = 1;
						}
						else
						{
							WritePrivateProfileString("Splash","LoopSound","0",szIniFile);
							options.loopsnd = 0;
						}
						*/

						if (IsDlgButtonChecked(hwndDlg, IDC_FADEIN))
						{
							db_set_b(NULL, MODNAME, "FadeIn", 1);
							options.fadein = 1;
						}
						else
						{
							db_set_b(NULL, MODNAME, "FadeIn", 0);
							options.fadein = 0;
						}
						if (IsDlgButtonChecked(hwndDlg, IDC_FADEOUT))
						{
							db_set_b(NULL, MODNAME, "FadeOut", 1);
							options.fadeout = 1;
						}
						else
						{
							db_set_b(NULL, MODNAME, "FadeOut", 0);
							options.fadeout = 0;
						}
						if (IsDlgButtonChecked(hwndDlg, IDC_RANDOM))
						{
							db_set_b(NULL, MODNAME, "Random", 1);
							options.random = 1;
						}
						else
						{
							db_set_b(NULL, MODNAME, "Random", 0);
							options.random = 0;
						}
						if (IsDlgButtonChecked(hwndDlg, IDC_SHOWVERSION))
						{
							db_set_b(NULL, MODNAME, "ShowVersion", 1);
							options.showversion = 1;
						}
						else
						{
							db_set_b(NULL, MODNAME, "ShowVersion", 0);
							options.showversion = 0;
						}
						return TRUE;
					}
				}
			}

		case WM_DESTROY:
			break;
	}
	return FALSE;
}
Exemplo n.º 6
0
int main(int argc, char* argv[])
{
    std::cout<<"Starting Snake v1.1 [EZX]...\n Author:  Schan\n Porting: BruceLee\n\n";
    // some inits...
    srand(time(0));
    if (TTF_Init() > 0) {
        fprintf(stderr, "Unable to TTF SDL: %s\n", TTF_GetError());
        exit(1);
    }

    // create game
    CGameEngine *game = new CGameEngine(30,false,10);
    game->SetTitle("Loading...");
    game->Init();

    SDL_ShowCursor(false);

    int lang = 0;
    // load options
    FILE *fp = fopen("snake.cfg","r");
    if (fp!=NULL)
    {
        char str[32];
        int v;
        fscanf(fp,"%s %d",&str,&v);
        if (strcmp(str,"lang")==0)
        {
            lang = v;
        }
        fclose(fp);
    }


    // create info object.
    // need game->Init(). actually, need a video mode set (made in game->Init());
    CSnakeGameInfo *info = new CSnakeGameInfo(lang);


    // create and add states. need info created
    CGameState *startingLevelState = new CStartingLevelState(info);
    CGameState *playingState = new CPlayingState(info);
    CGameState *pauseState = new CPauseState(info);
    CGameState *exitState = new CExitRequestedState(info);
    CGameState *lostLifeState = new CLostLifeState(info);
    CGameState *lostLastLifeState = new CLostLastLifeState(info);
    CGameState *menuState = new CMenuState(info);
    CGameState *optionsState = new COptionsState(info);
    CGameState *helpState = new CHelpState(info);

    game->AddState(startingLevelState,ST_STARTING_LEVEL);
    game->AddState(playingState,ST_PLAYING);
    game->AddState(pauseState,ST_PAUSE);
    game->AddState(lostLifeState,ST_LOST_LIFE);
    game->AddState(lostLastLifeState,ST_LOST_LAST_LIFE);
    game->AddState(exitState,ST_EXIT_REQUESTED);
    game->AddState(menuState,ST_MENU);
    game->AddState(optionsState,ST_OPTIONS);
    game->AddState(helpState,ST_HELP);

    // Show Splash
    ShowSplash();

    // start game
    game->SetTitle("Snake!");
    game->Start(ST_MENU);
    game->SetTitle("Quiting...");

    // clean
    delete startingLevelState;
    delete playingState;
    delete pauseState;
    delete exitState;
    delete lostLifeState;
    delete lostLastLifeState;
    delete menuState;
    delete optionsState;
    delete helpState;
    /*	chdir("/usr/gp2x");
      	execl("/usr/gp2x/gp2xmenu", "/usr/gp2x/gp2xmenu", NULL);*/
    return 0;

}
Exemplo n.º 7
0
int DoWinMain ( HINSTANCE hLauncherInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
    AddUtf8FileHooks();

#if defined(_DEBUG) 
    SharedUtil_Tests ();
#endif

    //
    // Init
    //

    // Let install manager figure out what MTASA path to use
    GetInstallManager()->SetMTASAPathSource( lpCmdLine );

    // Start logging.....now
    BeginEventLog();

    // Start localization if possible
    InitLocalization( false );

    // Handle commands from the installer
    HandleSpecialLaunchOptions();

    // Check MTA is launched only once
    HandleDuplicateLaunching();

    // Show logo
    ShowSplash( g_hInstance );

    // Other init stuff
    ClearPendingBrowseToSolution();


    //
    // Update
    //

    // Continue any update procedure
    SString strCmdLine = GetInstallManager()->Continue();


    //
    // Launch
    //

    // Ensure localization is started
    InitLocalization( true );

    // Setup/test various counters and flags for monitoring problems
    PreLaunchWatchDogs();

    // Stuff
    HandleCustomStartMessage();
    ForbodenProgramsMessage();
    CycleEventLog();
    BsodDetectionPreLaunch();
    MaybeShowCopySettingsDialog ();

    // Make sure GTA is not running
    HandleIfGTAIsAlreadyRunning();

    // Find GTA path to use
    ValidateGTAPath();

    // Maybe warn user if no anti-virus running
    CheckAntiVirusStatus();

    // Ensure logo is showing
    ShowSplash( g_hInstance );

    // Check MTA files look good
    CheckDataFiles();
    CheckLibVersions();

    // Go for launch
    int iReturnCode = LaunchGame( strCmdLine );

    PostRunWatchDogs( iReturnCode );

    //
    // Quit
    //

    HandleOnQuitCommand();

    // Maybe show help if trouble was encountered
    ProcessPendingBrowseToSolution();

    AddReportLog ( 1044, SString ( "* End (0x%X)* pid:%d", iReturnCode, GetCurrentProcessId() ) );

    RemoveUtf8FileHooks();
    return iReturnCode;
}
Exemplo n.º 8
0
static void DoTask()
{
	fs::path gExecutableDirectory = ydwe::path::get(ydwe::path::DIR_EXE).remove_filename();

	ydwe::i18n::textdomain("YDWEStartup");
	ydwe::i18n::bindtextdomain("YDWEStartup", gExecutableDirectory / L"share" / L"locale");

	if (gExecutableDirectory != fs::path(gExecutableDirectory.string()))
	{
		BOOST_THROW_EXCEPTION(std::domain_error(_("Error YDWE directory.")));
	}

	fs::path gWarcraftDirectory;
	if (!warcraft3_directory::get(__("Please choose your Warcraft 3 installation directory"), gWarcraftDirectory))
	{
		return ;
	}

	MoveDetouredSystemDll(gWarcraftDirectory);

	// Set current directory
	SetCurrentDirectoryW(gExecutableDirectory.c_str());

	if (fs::exists(gWarcraftDirectory / L"YDDllFixer.dll"))
	{
		if (!fs::remove(gWarcraftDirectory / L"YDDllFixer.dll"))
		{
			BOOST_THROW_EXCEPTION(std::domain_error(_("Cannot delete YDDllFixer.dll in war3 directory.")));
		}
	}

	if (fs::exists(gExecutableDirectory / L"YDDllFixer.dll"))
	{
		if (!fs::remove(gExecutableDirectory / L"YDDllFixer.dll"))
		{
			BOOST_THROW_EXCEPTION(std::domain_error(_("Cannot delete YDDllFixer.dll in ydwe directory.")));
		}
	}

	// Prefered path
	fs::path worldeditPreferredPath = gWarcraftDirectory / L"worldeditydwe.exe";
	// Attached path
	fs::path worldeditAttachedPath = gExecutableDirectory / L"bin" / L"worldedit.exe";

	// Check if attached executable exists
	if (fs::exists(worldeditAttachedPath))
	{
		// Copy it
		CheckedCopyFile(worldeditAttachedPath, worldeditPreferredPath);
	}
	else
	{
		BOOST_THROW_EXCEPTION(std::domain_error(_("Cannot find main executable file of world editor in YDWE/bin directory.")));
	}

	CreateDotNetConfig(gWarcraftDirectory / L"worldeditydwe.exe.config");

	ydwe::win::process worldedit_process;
	bool result = worldedit_process.create(worldeditPreferredPath, std::wstring(::GetCommandLineW()));

	if (!result)
	{
		throw ydwe::windows_exception(_("Failed to launch world editor."));
	}

	ShowSplash(gExecutableDirectory);
}
Exemplo n.º 9
0
BOOL CCustomPlayer::InitPlayer(HWND iMainWindow, HWND iRenderWindow, int iConfig, const void* iData,int iDataSize)
{

	// keep a reference on the main/render window
	m_MainWindow = iMainWindow;
	m_RenderWindow = iRenderWindow;



	// start the Virtools Engine
	//CKInitCustomPlayer(false);
	CKStartUp();


	




	//////////////////////////////////////////////////////////////////////////
	// we have unmet requirements ? 
	XString errorText;
	int hasError  = DoSystemCheck(errorText);

	//////////////////////////////////////////////////////////////////////////
	//  show splash when we have no error and we are not in the explicit configuration mode ( invoked by : "CustomPlayer.exe -c ") : 
	if( GetPAppStyle()->UseSplash() && !hasError && PGetApplicationMode() != config )
	{
		ShowSplash();
	}


	// retrieve the plugin manager ...
	CKPluginManager* pluginManager = CKGetPluginManager();

	//////////////////////////////////////////////////////////////////////////
	//  ... to intialize plugins ...
	if (!_InitPlugins(*pluginManager)) {
		MessageBox(NULL,UNABLE_TO_INIT_PLUGINS,INIT_ERROR,MB_OK|MB_ICONERROR);
		return FALSE;
	}

	//////////////////////////////////////////////////////////////////////////
	// ... and the render engine.
	int renderEngine = _InitRenderEngines(*pluginManager);
	if (renderEngine==-1) 
	{
		MessageBox(NULL,UNABLE_TO_LOAD_RENDERENGINE,INIT_ERROR,MB_OK|MB_ICONERROR);
		return FALSE;
	}

	//////////////////////////////////////////////////////////////////////////
	// now create the CK context
	XString inifile = CKGetStartPath();
	inifile << "CompositionPrefs_R_Hi.ini";
	CKERROR res = CKCreateContext(&m_CKContext,m_MainWindow,inifile.Str());
	if (res!=CK_OK) {
		MessageBox(NULL,UNABLE_TO_INIT_CK,INIT_ERROR,MB_OK|MB_ICONERROR);
		return FALSE;
	}

	





#if defined(CUSTOM_PLAYER_STATIC)
	// if the player is not static

	char BehaviorPath[_MAX_PATH];
	char szPath[_MAX_PATH];
	VxGetModuleFileName(NULL,szPath,_MAX_PATH);
	CKPathSplitter ps(szPath);
	sprintf(BehaviorPath,"%s%s%s",ps.GetDrive(),ps.GetDir(),GetEPathProfile()->BehaviorPath.Str());
	pluginManager->ParsePlugins(BehaviorPath);

#endif
	//////////////////////////////////////////////////////////////////////////
	//  adding load callback
	if(GetPAppStyle()->UseSplash() && !m_LastError && PGetApplicationMode() != config )
	{
		if (GetPAppStyle()->ShowLoadingProcess())
		{
			
			m_CKContext->SetInterfaceMode(FALSE,LoadCallBack,NULL);
		}
	}

	// retrieve the main managers which will be used by the player
	m_MessageManager	= m_CKContext->GetMessageManager();
	m_RenderManager		= m_CKContext->GetRenderManager();
	m_TimeManager		= m_CKContext->GetTimeManager();
	m_AttributeManager	= m_CKContext->GetAttributeManager();
	
	m_EnginePointers.TheMessageManager = m_MessageManager;
	m_EnginePointers.TheRenderManager =  m_RenderManager;
	m_EnginePointers.TheTimeManager = m_TimeManager;
	m_EnginePointers.TheCKContext  = m_CKContext;
	

	//We have an error,  show our dialog :  
	if (hasError)
	{
		AfxInitRichEdit2();
		CustomPlayerDialog k(NULL,CString(errorText.Str()));
		k.DoModal();
		if (CPA_ABORT_ON_ERROR)
		{
			return FALSE;
		}
	}
	



	m_InputManager		= (CKInputManager*)m_CKContext->GetManagerByGuid(INPUT_MANAGER_GUID);
	if (!m_MessageManager || !m_RenderManager || !m_TimeManager || !m_AttributeManager || !m_InputManager) {
		MessageBox(NULL,UNABLE_TO_INIT_MANAGERS,INIT_ERROR,MB_OK|MB_ICONERROR);
		return FALSE;
	}


	// initialize the display driver using the player configuration (resolution, rasterizer, ...)
	if (!_InitDriver()) {		
		MessageBox(NULL,UNABLE_TO_INIT_DRIVER,INIT_ERROR,MB_OK|MB_ICONERROR);
		return FALSE;
	}


	PLoadResourcePaths(CUSTOM_PLAYER_CONFIG_FILE,"Textures",0);
	PLoadResourcePaths(CUSTOM_PLAYER_CONFIG_FILE,"Data",1);
	PLoadResourcePaths(CUSTOM_PLAYER_CONFIG_FILE,"Music",2);



	// now load the composition
	if (iDataSize) { // if iDataSize is not null it means the composition is already in memory
		if (_Load(iData,iDataSize)!=CK_OK) {
			MessageBox(NULL,"Unable to load composition from memory.","Initialization Error",MB_OK|MB_ICONERROR);
			return FALSE;
		}
	} else if (_Load((const char*)iData)!=CK_OK) { // else we load it from a file (iData contains the filename)
		MessageBox(NULL,"Unable to load composition from file.","Initialization Error",MB_OK|MB_ICONERROR);
		return FALSE;
	}

	//GetPlayer().HideSplash();

	//show our dialog  ? 
	if (GetPAppStyle()->g_ShowDialog)
	{
		AfxInitRichEdit2();
		CustomPlayerDialog k(NULL,CString(errorText.Str()));
		k.DoModal();
	}

	


	////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
	// update of our member variables
	vtPlayer::Structs::xSEnginePointers* ep = GetPlayer().GetEnginePointers();
	vtPlayer::Structs::xSEngineWindowInfo* ewinfo = GetPlayer().GetEngineWindowInfo();
	m_WindowedHeight  = ewinfo->g_HeightW;
	m_WindowedWidth = ewinfo->g_WidthW;
	
	m_FullscreenWidth  = ewinfo->g_Width;
	m_FullscreenHeight  = ewinfo->g_Height;

	if(ewinfo->g_GoFullScreen)
		m_Driver  =  ewinfo->g_FullScreenDriver;
	else
		m_Driver  =  ewinfo->g_WindowedDriver;

	m_FullscreenBpp  = ewinfo->g_Bpp;
	
	//////////////////////////////////////////////////////////////////////////

	CKVariableManager *vm = (CKVariableManager *)m_EnginePointers.TheCKContext->GetVariableManager();
	vm->SetValue("CK2_3D/Antialias", GetEWindowInfo()->FSSA * 2 );
    

	if(PGetApplicationMode() != config)
	{
		  
		if (GetPlayer().GetPAppStyle()->IsRenderering())
		{
			
			//////////////////////////////////////////////////////////////////////////
			// create the render context
			if (GetEWindowInfo()->g_GoFullScreen) 
			{
				// in fullscreen we specify the rendering size using a rectangle (CKRECT)
				CKRECT rect;
				rect.left = 0;
				rect.top = 0;
				rect.right = m_FullscreenWidth;
				rect.bottom = m_FullscreenHeight;
				// create the render context
			
				m_RenderContext = m_RenderManager->CreateRenderContext(m_RenderWindow,GetEWindowInfo()->g_FullScreenDriver,&rect,TRUE,m_FullscreenBpp);

				// set the position of the render window

				::SetWindowPos(m_RenderWindow,NULL,0,0,m_FullscreenWidth,m_FullscreenHeight,SWP_NOMOVE|SWP_NOZORDER);

				// resize the render context
				if (m_RenderContext) {
					m_RenderContext->Resize(0,0,m_FullscreenWidth,m_FullscreenHeight);
				}
			} else {
				
				//////////////////////////////////////////////////////////////////////////
				//  [2/18/2008 mc007]
                //  we only repositioning the window when we are not displayed by a hosting application like
				//  a charp panel !
				if (!GetPAppStyle()->g_OwnerDrawed)
				{
					LONG st = GetWindowLong(m_MainWindow,GWL_STYLE);
					st|=WS_THICKFRAME;
					st&=~WS_SIZEBOX;
					SetWindowLong(m_MainWindow,GWL_STYLE,st);

					//reposition the window
					m_MainWindowRect.left = (GetSystemMetrics(SM_CXSCREEN)-m_WindowedWidth)/2;
					m_MainWindowRect.right = m_WindowedWidth+m_MainWindowRect.left;
					m_MainWindowRect.top = (GetSystemMetrics(SM_CYSCREEN)-m_WindowedHeight)/2;
					m_MainWindowRect.bottom = m_WindowedHeight+m_MainWindowRect.top;
					BOOL ret = AdjustWindowRect(&m_MainWindowRect,WS_OVERLAPPEDWINDOW & ~(WS_SYSMENU|WS_SIZEBOX|WS_MAXIMIZEBOX|WS_MINIMIZEBOX|WS_SIZEBOX),FALSE);
					::SetWindowPos(m_MainWindow,0,m_MainWindowRect.left,m_MainWindowRect.top,m_MainWindowRect.right - m_MainWindowRect.left,m_MainWindowRect.bottom - m_MainWindowRect.top,NULL);

					// set the position of the render window
					::SetWindowPos(m_RenderWindow,NULL,0,0,m_WindowedWidth,m_WindowedHeight,SWP_NOMOVE|SWP_NOZORDER);
				}
				// create the render context
				m_RenderContext = m_RenderManager->CreateRenderContext(m_RenderWindow,m_Driver,0,FALSE);

				// resize the render context
				if (m_RenderContext) {
					m_RenderContext->Resize(0,0,m_WindowedWidth,m_WindowedHeight);
				}
			}
			//////////////////////////////////////////////////////////////////////////
			// when somebody changed any resolution in the configuration tab , we should update our windows : 
			//store current size
			/*
			GetWindowRect(m_MainWindow,&m_MainWindowRect);

			LONG st = GetWindowLong(m_MainWindow,GWL_STYLE);
			st|=WS_THICKFRAME;
			st&=~WS_SIZEBOX;
			SetWindowLong(m_MainWindow,GWL_STYLE,st);

			//reposition the window
			m_MainWindowRect.left = (GetSystemMetrics(SM_CXSCREEN)-m_WindowedWidth)/2;
			m_MainWindowRect.right = m_WindowedWidth+m_MainWindowRect.left;
			m_MainWindowRect.top = (GetSystemMetrics(SM_CYSCREEN)-m_WindowedHeight)/2;
			m_MainWindowRect.bottom = m_WindowedHeight+m_MainWindowRect.top;
			BOOL ret = AdjustWindowRect(&m_MainWindowRect,WS_OVERLAPPEDWINDOW & ~(WS_SYSMENU|WS_SIZEBOX|WS_MAXIMIZEBOX|WS_MINIMIZEBOX|WS_SIZEBOX),FALSE);
			::SetWindowPos(m_MainWindow,0,m_MainWindowRect.left,m_MainWindowRect.top,m_MainWindowRect.right - m_MainWindowRect.left,m_MainWindowRect.bottom - m_MainWindowRect.top,NULL);

			// and set the position of the render window in the main window
			::SetWindowPos(m_RenderWindow,NULL,0,0,m_WindowedWidth,m_WindowedHeight,SWP_NOMOVE|SWP_NOZORDER);
			m_RenderContext->Resize(0,0,GetEWindowInfo()->g_GoFullScreen ? m_FullscreenWidth : m_WindowedWidth, GetEWindowInfo()->g_GoFullScreen ? m_FullscreenHeight :  m_WindowedHeight);*/


			if (!m_RenderContext) {
				MessageBox(NULL,UNABLE_TO_CREATE_RENDERCONTEXT,INIT_ERROR,MB_OK|MB_ICONERROR);
				return FALSE;
			}


			
			//////////////////////////////////////////////////////////////////////////
			// clear the render view
			m_RenderContext->Clear();
			m_RenderContext->BackToFront();
			m_RenderContext->Clear();
		}


		// finalize the loading
		if (!_FinishLoad()) 
		{
			return FALSE;
		}
	}

	return TRUE;
}