Example #1
0
	KVOID AppFrame::CreateWidgets()
	{
 		if (!OgreRoot::Initialized())
 			KNEW OgreRoot();
		if (!DataManager::Initialized())
			KNEW DataManager();
		//////////////////////////////////////////////////////////////////////////
		m_pSceneMgr = m_pRoot->createSceneManager("OctreeSceneManager");//Ogre::ST_EXTERIOR_CLOSE);

		// set shadow properties
// 		m_pSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_NONE);
// 		m_pSceneMgr->setShadowColour(Ogre::ColourValue(0.5, 0.5, 0.5));
// 		m_pSceneMgr->setShadowTextureSize(1024);
// 		m_pSceneMgr->setShadowTextureCount(1);

		//////////////////////////////////////////////////////////////////////////
		Ogre::Camera* pCam = OgreRoot::GetSingletonPtr()->CreateCamera("$MainCamera");
		if (pCam)
		{
			OgreRoot::GetSingletonPtr()->CreateViewports(pCam);
		}
		// splash
		Kylin::LoadingProgress* pLoading = KNEW Kylin::LoadingProgress();
		pLoading->Initialize();
		pLoading->SetVisible(true);
		//////////////////////////////////////////////////////////////////////////
		Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
		//////////////////////////////////////////////////////////////////////////
		m_pInputMgr = KNEW InputManager();
		m_pInputMgr->Initialize();
		//////////////////////////////////////////////////////////////////////////
		m_pGuiMgr = KNEW GuiManager();
		m_pGuiMgr->Create(m_pWindow,m_pSceneMgr);
		m_pGuiMgr->RegisterGui(pLoading);
		//////////////////////////////////////////////////////////////////////////
		m_pScriptVM = KNEW ScriptVM();
		if(m_pScriptVM->Init())
		{
			OpenScriptBinding(m_pScriptVM->GetLuaState());
			m_pScriptVM->ExecuteScriptFile("./Data/script/startvm.lua");
		}

		//////////////////////////////////////////////////////////////////////////
		if (!EffectManager::Initialized())
			KNEW EffectManager();
		EffectManager::GetSingletonPtr()->Initialize();

		OgreOggSound::OgreOggSoundManager::getSingletonPtr()->init();
		//////////////////////////////////////////////////////////////////////////
		if (!m_pRenderableMgr)
			m_pRenderableMgr = KNEW RenderableManager();
Example #2
0
bool GameFlow::Initialize()
{
	IGameApp::Initialize();
	return cPres.Load("configs/game.config", [&](Presentation *, Viewport *aborted)
	{
		if (!aborted)
		{
			pSoundSystem->SetMusicVolume(0.6f);
			pSoundSystem->SetSfxVolume(0.5f);

			// Create the State Machine Data
			gGameData = sdNew(GameData());

			if (this->SaveSystemFlow())
				pSaveSystem->Load(0, &gGameData->sPlayer, &gGameData->sOptions);

			// Create the transitions
			cMenuToGame.Initialize(&cMenu, &cOnGame, &cGame);
			cMenuToOptions.Initialize(&cMenu, &cOnOptions, &cOptions);
			cMenuToCredits.Initialize(&cMenu, &cOnCredits, &cCredits);
			cOptionsToMenu.Initialize(&cOptions, &cOnMenu, &cMenu);
			cCreditsToMenu.Initialize(&cCredits, &cOnMenu, &cMenu);
			cGameToMenu.Initialize(&cGame, &cOnMenu, &cMenu);
			cGameToLoad.Initialize(&cGame, &cOnLoad, &cLoad);
			cLoadToGame.Initialize(&cLoad, &cOnGame, &cGame);

			// Create the State Machine.
			cFlow.RegisterTransition(&cMenuToGame);
			cFlow.RegisterTransition(&cMenuToOptions);
			cFlow.RegisterTransition(&cMenuToCredits);
			cFlow.RegisterTransition(&cOptionsToMenu);
			cFlow.RegisterTransition(&cCreditsToMenu);
			cFlow.RegisterTransition(&cGameToMenu);
			cFlow.RegisterTransition(&cGameToLoad);
			cFlow.RegisterTransition(&cLoadToGame);

			pSystem->AddListener(this);
			pInput->AddKeyboardListener(this);

			auto viewport = cPres.GetViewportByName("MainView");
			pScene = viewport->GetScene();
			pCamera = viewport->GetCamera();

			sdNew(GuiManager());
			gGui->Initialize();
			pScene->Add(gGui->GetSceneObject());

			cFlow.Initialize(&cMenu);
		}
	});
}