コード例 #1
0
CLoadMenu::CLoadMenu() :
GalaxyMenu( GsRect<float>(0.1f, 0.0f, 0.8f, 1.0f) )
{
	// Load the state-file list
	std::vector<std::string> StateFileList = gpSaveGameController->getSlotList();
	std::vector<std::string>::iterator it = StateFileList.begin();

	Uint32 i=1;
	GsButton *button;
	std::string text;

	for( ; it != StateFileList.end() && i<8 ; i++,it++ )
	{
		text = *it;

		if( !text.empty() )
		{
            button = new BorderedButton( text,
                                    new LoadGameSlotFunctorEvent(i) );
			mpMenuDialog->addControl( button );

			button->enable( true );
		}
	}

	for( int j = i ; j<8 ; j++ )
	{
		text = "Empty";
        button = new BorderedButton( text,
                                new LoadGameSlotFunctorEvent(j));
		mpMenuDialog->addControl( button );

		button->enable( false );
	}

	setMenuLabel("LOADMENULABEL");
}
コード例 #2
0
void MainMenu::createVorticonMenu( const bool openedGamePlay )
{

#if defined (SINGLEPLAYER)
    g_pBehaviorEngine->mPlayers = 1;
    Button *button = new Button( "New Game",
                                 new OpenMenuEvent(new CDifficultySelection) );
#else
    Button *button = new Button
    ( "New Game",
      new OpenMenuEvent
      (
          new vorticon::CPlayersSelection
          <NewGamePlayersEvent>
          (true)
      )
    );
#endif

    mpMenuDialog->addControl( button );


    // TODO: Some items are still disabled, because those are not yet implemented in Galaxy

    GsButton *loadButton = new Button( "Load",
                                       new OpenMenuEvent( new CLoadMenu() ) );
    mpMenuDialog->addControl( loadButton );
    loadButton->enable(true);

    Button *saveButton = new Button( "Save",
                                     new OpenMenuEvent( new CSaveMenu() ) );
    mpMenuDialog->addControl( saveButton );
    saveButton->enable(openedGamePlay);

    mpMenuDialog->addControl(new Button( "Configure",
                                         new OpenMenuEvent( new CSettingsMenu() ) ) );

    GsButton *highscoreButton = new Button( "High Scores",
                                            new StartInfoSceneEvent( new CHighScores ) );
    mpMenuDialog->addControl( highscoreButton );
    highscoreButton->enable(true);

    GsButton *infoButton = new Button( "Info",
                                       new OpenMenuEvent( new CHelpMenu() ) );
    mpMenuDialog->addControl( infoButton );
    infoButton->enable(true);

    mpMenuDialog->addControl(new Button( "End Game", new EventEndGamePlay() ) );

    mpMenuDialog->addControl(new Button( "Quit", new GMQuit() ) );

}
コード例 #3
0
////
// Initialization Routine
////
bool CGameLauncher::setupMenu()
{
    m_mustquit      = false;
    mDonePatchSelection = false;
    m_chosenGame    = -1;
    m_ep1slot       = -1;
    mLauncherDialog.initEmptyBackground();
    mSelection      = -1;

    bool gamesDetected = false;

    // TODO: Put that scanning into a separate so we can show a loading menu
    // Scan for games...
    m_DirList.clear();
    m_Entries.clear();

    gLogging.ftextOut("Game Autodetection Started<br>" );

    // Process any custom labels
    getLabels();

    // Scan VFS DIR_ROOT for exe's
    gamesDetected |= scanExecutables(DIR_ROOT);
    mGameScanner.setPermilage(100);

    // Recursivly scan into DIR_GAMES subdir's for exe's
    gamesDetected |= scanSubDirectories(DIR_GAMES, DEPTH_MAX_GAMES, 200, 900);

    mpSelList = new CGUITextSelectionList();

    // Save any custom labels
    putLabels();

    // Create an empty Bitmap control
    mLauncherDialog.addControl( new CGUIBitmap(),
                                GsRect<float>(0.51f, 0.07f, 0.48f, 0.48f) );

    mCurrentBmp = std::dynamic_pointer_cast< CGUIBitmap >
                  ( mLauncherDialog.getControlList().back() );

    mpPrevievBmpVec.resize(m_Entries.size());

	std::vector<GameEntry>::iterator it = m_Entries.begin();
    unsigned int i=0;
    for( ; it != m_Entries.end() ; it++	)
    {
    	mpSelList->addText(it->name);

        // And try to add a preview bitmap
        std::string fullfilename = "preview.bmp";
        fullfilename = getResourceFilename(fullfilename, it->path, false);
        fullfilename = GetFullFileName(fullfilename);

        if(IsFileAvailable(fullfilename))
        {
            SDL_Surface *pPrimBmp = SDL_LoadBMP(GetFullFileName(fullfilename).c_str());
            std::shared_ptr<SDL_Surface> bmpSfcPtr( pPrimBmp );
            std::shared_ptr<GsBitmap> pBmp(new GsBitmap(bmpSfcPtr));
            mpPrevievBmpVec[i] = pBmp;
        }
        i++;
    }

    mpSelList->setConfirmButtonEvent(new GMStart());
    mpSelList->setBackButtonEvent(new GMQuit());

    mLauncherDialog.addControl(new CGUIText("Pick a Game"), GsRect<float>(0.0f, 0.0f, 1.0f, 0.05f));
    mLauncherDialog.addControl(new GsButton( "x", new GMQuit() ), GsRect<float>(0.0f, 0.0f, 0.07f, 0.07f) );
    mLauncherDialog.addControl(mpSelList, GsRect<float>(0.01f, 0.07f, 0.49f, 0.79f));


    mLauncherDialog.addControl(new GsButton( "Start >", new GMStart() ), GsRect<float>(0.65f, 0.865f, 0.3f, 0.07f) );

#ifdef DBFUSION

    GsButton *fusionShellBtn = new GsButton( "DosFusion Shell >", new GMDBFusionStart() );
    GsButton *fusionBtn = new GsButton( "DosFusion! >", new GMDosGameFusionStart() );

    if(disallowDBFusion)
    {
        fusionShellBtn->enable(false);
        fusionBtn->enable(false);
    }

    mLauncherDialog.addControl( fusionShellBtn, GsRect<float>(0.01f, 0.865f, 0.3f, 0.07f) );
    mLauncherDialog.addControl( fusionBtn, GsRect<float>(0.35f, 0.865f, 0.3f, 0.07f) );
#endif



#ifdef DOWNLOADER
    GsButton *downloadBtn = new GsButton( "New Stuff", new GMDownloadDlgOpen() );
    mLauncherDialog.addControl( downloadBtn, GsRect<float>(0.35f, 0.865f, 0.3f, 0.07f) );
#endif

    mpEpisodeText = new CGUIText("Game");
    mpVersionText = new CGUIText("Version");
    mLauncherDialog.addControl(mpEpisodeText, GsRect<float>(0.5f, 0.75f, 0.5f, 0.05f));
    mLauncherDialog.addControl(mpVersionText, GsRect<float>(0.5f, 0.80f, 0.5f, 0.05f));

    // This way it goes right to the selection list.
    mLauncherDialog.setSelection(2);

    mGameScanner.setPermilage(1000);

    gLogging.ftextOut("Game Autodetection Finished<br>" );
    // Banner. TODO: Create a class for that...
    CGUIBanner *banner = new CGUIBanner("Commander Genius " CGVERSION "\n"
                    "By Gerstrong,\n"
                    "Hagel,\n"
                    "Tulip,\n"
                    "NY00123,\n"
                    "Pelya,\n"
					"and the CG Contributors\n");
    mLauncherDialog.addControl( banner, GsRect<float>(0.0f, 0.95f, 1.0f, 0.05f) );

    if(!gamesDetected)
        return false;

    const std::string gameDir = gArgs.getValue("dir");
    if(!gameDir.empty())
    {
        int chosenGame = 0;
        bool found=false;

        // Check if the given parameter makes one game start.
        for( GameEntry &entry : m_Entries)
        {
            if(entry.path == gameDir)
            {
                // found!
                m_chosenGame = chosenGame;
                gLogging.textOut("Launching game from directory: \"" + gameDir + "\"\n");
                gArgs.removeTag("dir");

                setupModsDialog();
                // Nothing else to do, break the loop
                found = true;
                break;
            }
            chosenGame++;
        }

        if(!found)
        {
            const std::string err = "The game from directory: \"" + gameDir + "\" cannot the launched." +
                    "Maybe it's missing or not compatible. Please check if you can run that through the game launcher.\n";

            gLogging.textOut(err);

            showMessageBox("Given path :\"" + gameDir + "\" unknown.\nPlease check the CGLog File!");
        }
    }

    return true;
}