void CSpaceInvadersAppUi::ConstructL()
{
	// Initialise app UI with standard value.
	BaseConstructL(CAknAppUi::EAknEnableSkin);

	// Create the highscore holder to use highscores
	CSpaceInvadersDocument* ptr = (CSpaceInvadersDocument*)Document();
	iHighscoreHolder            = ptr->Holder();

	TInt error;
	
	// Create the audioplayer
	TRAP(error, iAudioPlayer = CSpaceInvadersAudioPlayer::NewL());
	if( error )
	{
		Exit();
	}
	
	// Create the ship
	TRAP(error, iShip = CShipEngine::NewL(0, 0 ));
	if ( error )
	{
		Exit();
	}

	// Create view objects
	TRAP(error, iAppView = CSpaceInvadersAppView::NewL( ClientRect(),this,iShip,
			                                iHighscoreHolder));
	if ( error )
	{
		Exit();
	}
	
	iAppView->MakeVisible(EFalse);
	
	TRAP(error, iStartMenuView = CSpaceInvadersStartMenuAppView::
								 NewL(ClientRect(), this, iHighscoreHolder) );
	if ( error )
	{
		Exit();
	}
	iStartMenuView->MakeVisible(ETrue);
	
	TRAP(error, iHighscoreView = CSpaceInvadersHighscoreView::
								 NewL(ClientRect(), this, iHighscoreHolder) );
	if ( error )
	{
		Exit();
	}
	iHighscoreView->MakeVisible(EFalse);
	iCurrentView = iStartMenuView;
	
	AddToStackL( iCurrentView );

	// Hiding the status pane
	CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane();
	sp->MakeVisible(EFalse);

}
Exemple #2
0
// -----------------------------------------------------------------------------
// COsmo4AppUi::HandleCommandL()
// Takes care of command handling.
// -----------------------------------------------------------------------------
//
void COsmo4AppUi::HandleCommandL( TInt aCommand )
{
	GF_Err e;
#ifndef GPAC_GUI_ONLY
	switch( aCommand ) {
	case EAknSoftkeyBack:
		if (view_mode==1) TogglePlaylist();
		break;
    case EEikCmdExit:
    case EAknSoftkeyExit:
        iAppView->Shutdown();
		Exit();
        break;
	/*PLAYLIST commands*/
	case EOsmo4PlayListAdd:
		iPlaylist->PlaylistAct(Osmo4PLAdd);
		break;
	case EOsmo4PlayListRem:
		iPlaylist->PlaylistAct(Osmo4PLRem);
		break;
	case EOsmo4PlayListMoveUp:
		iPlaylist->PlaylistAct(Osmo4PLMoveUp);
		break;
	case EOsmo4PlayListMoveDown:
		iPlaylist->PlaylistAct(Osmo4PLMoveDown);
		break;
	case EOsmo4PlayListClear:
		iPlaylist->PlaylistAct(Osmo4PLClear);
		break;
	case EOsmo4PlayListMode:
		iPlaylist->PlaylistAct(Osmo4PLToggleMode);
		break;
	case EOsmo4PlayListAllFiles:
		iPlaylist->PlaylistAct(Osmo4PLToggleAllFiles);
		break;

	/*FILE menu command*/
	case EOsmo4PlayListView:
		TogglePlaylist();
		break;
	case EOsmo4OpenURL:
		break;
	case EOsmo4Fullscreen:
		break;
	case EOsmo4ViewMaxSize:
	{
		CEikStatusPane* statusPane = StatusPane();
		if (statusPane->IsVisible()) statusPane->MakeVisible(EFalse);
		else statusPane->MakeVisible(ETrue);
	}
		break;
	case EOsmo4AROriginal:
		gf_term_set_option(iAppView->m_term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_KEEP);
		break;
	case EOsmo4ARFillScreen:
		gf_term_set_option(iAppView->m_term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_FILL_SCREEN);
		break;
	case EOsmo4AR4_3:
		gf_term_set_option(iAppView->m_term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_4_3);
		break;
	case EOsmo4AR16_9:
		gf_term_set_option(iAppView->m_term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_16_9);
		break;

	case EOsmo4NavReset:
		gf_term_set_option(iAppView->m_term, GF_OPT_NAVIGATION_TYPE, 0);
		break;
	case EOsmo4NavNone:
		gf_term_set_option(iAppView->m_term, GF_OPT_NAVIGATION, GF_NAVIGATE_NONE);
		break;
	case EOsmo4NavSlide:
		e = gf_term_set_option(iAppView->m_term, GF_OPT_NAVIGATION, GF_NAVIGATE_SLIDE);
		if (e) {
			GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("Cannot set navigation: %s", gf_error_to_string(e) ));
		}
		break;
	case EOsmo4NavWalk:
		gf_term_set_option(iAppView->m_term, GF_OPT_NAVIGATION, GF_NAVIGATE_WALK);
		break;
	case EOsmo4NavFly:
		gf_term_set_option(iAppView->m_term, GF_OPT_NAVIGATION, GF_NAVIGATE_FLY);
		break;
	case EOsmo4NavExamine:
		gf_term_set_option(iAppView->m_term, GF_OPT_NAVIGATION, GF_NAVIGATE_EXAMINE);
		break;
	case EOsmo4NavHeadlight:
		gf_term_set_option(iAppView->m_term, GF_OPT_HEADLIGHT, !gf_term_get_option(iAppView->m_term, GF_OPT_HEADLIGHT) );
		break;
	case EOsmo4CollideNone:
		gf_term_set_option(iAppView->m_term, GF_OPT_COLLISION, GF_COLLISION_NONE);
		break;
	case EOsmo4CollideSimple:
		gf_term_set_option(iAppView->m_term, GF_OPT_COLLISION, GF_COLLISION_NORMAL);
		break;
	case EOsmo4CollideDisp:
		gf_term_set_option(iAppView->m_term, GF_OPT_COLLISION, GF_COLLISION_DISPLACEMENT);
		break;
	case EOsmo4NavGravity:
		gf_term_set_option(iAppView->m_term, GF_OPT_GRAVITY, !gf_term_get_option(iAppView->m_term, GF_OPT_GRAVITY));
		break;
	case EOsmo4ViewRTI:
		iAppView->show_rti = !iAppView->show_rti;
		break;

    case EOsmo4OptEnableLogs:
    {
		const char *opt = gf_cfg_get_key(iAppView->m_user.config, "General", "Logs");
		if (opt && !stricmp(opt, "@debug")) {
			gf_cfg_set_key(iAppView->m_user.config, "General", "Logs", "all@error");
		} else {
			gf_cfg_set_key(iAppView->m_user.config, "General", "Logs", "all@debug");
		}
		iAppView->SetupLogs();
    }
        break;
	case EOsmo4OptOpenGL:
	{
		const char *opt = gf_cfg_get_key(iAppView->m_user.config, "Compositor", "ForceOpenGL");
		Bool use_gl = (opt && !strcmp(opt, "yes")) ? 1 : 0;
		gf_cfg_set_key(iAppView->m_user.config, "Compositor", "ForceOpenGL", use_gl ? "no" : "yes");
		gf_term_set_option(iAppView->m_term, GF_OPT_USE_OPENGL, !use_gl);
	}
		break;
	case EOsmo4OptDirectDraw:
	{
		const char *opt = gf_cfg_get_key(iAppView->m_user.config, "Compositor", "DirectDraw");
		Bool use_dd = (opt && !strcmp(opt, "yes")) ? 1 : 0;
		gf_cfg_set_key(iAppView->m_user.config, "Compositor", "DirectDraw", use_dd ? "no" : "yes");
		gf_term_set_option(iAppView->m_term, GF_OPT_DIRECT_DRAW, !use_dd);
	}
		break;
	case EOsmo4OptXMLProgressive:
	{
		const char *opt = gf_cfg_get_key(iAppView->m_user.config, "SAXLoader", "Progressive");
		Bool use_prog = (opt && !strcmp(opt, "yes")) ? 1 : 0;
		gf_cfg_set_key(iAppView->m_user.config, "SAXLoader", "Progressive", use_prog ? "no" : "yes");
		gf_cfg_set_key(iAppView->m_user.config, "SAXLoader", "MaxDuration", "100");
	}
		break;

    default:
		if ((aCommand>=EOsmo4OpenRecentFirst) && (aCommand<=EOsmo4OpenRecentLast)) {
			const char *sOpt = gf_cfg_get_key_name(iAppView->m_user.config, "RecentFiles", aCommand - EOsmo4OpenRecentFirst);
			if (sOpt) iAppView->Connect(sOpt);
		} else {
			iAppView->MessageBox("Unandled command - panic", "Osmo4");
			Panic( EOsmo4Ui );
		}
        break;
    }
#endif
}