bool CameraCapture::OnAppInitializing(AppRegistry& appRegistry) { result r = E_SUCCESS; IAppFrame* pAppFrame = GetAppFrame(); if (NULL == pAppFrame) { AppLog("GetAppFrame has failed.."); goto CATCH; } __pFrame = pAppFrame->GetFrame(); if (!__pFrame) { AppLog("GetFrame has failed.."); goto CATCH; } // initialize forms __pMainForm = new MainForm(); if( !__pMainForm ) { AppLog( ">>>>>> MainForm creation has failed."); return false; } //------------------------------ // Construct form //------------------------------ if( __pMainForm->Construct() != E_SUCCESS ) { AppLog( ">>>>>> Construct has failed."); goto CATCH; } //------------------------------ // Attach Form to Frame //------------------------------ r = __pFrame->AddControl( *__pMainForm ); if( IsFailed(r)) { AppLog( ">>>>>> Adding MainForm has failed."); goto CATCH; } __pFrame->SetCurrentForm( *__pMainForm ); // You should comment following statement if you do not listen to the screen on/off events. PowerManager::SetScreenEventListener(*this); return true; CATCH: if ( __pMainForm ) delete __pMainForm; return false; }
result badaJS::__CreateWebForm(void) { result r = E_SUCCESS; Rectangle bound; IAppFrame* pAppFrame = GetAppFrame(); if (NULL == pAppFrame) { AppLog("GetAppFrame() has failed.\n"); goto CATCH; } /*form*/ __pMainForm = new Form(); r = __pMainForm->Construct(FORM_STYLE_SOFTKEY_1|FORM_STYLE_INDICATOR); TryCatch(r == E_SUCCESS, , "form is not constructed\n "); __pMainForm->SetBackgroundColor(Color(85,104,114)); __pMainForm->SetSoftkeyText (SOFTKEY_1 , L"Exit"); __pMainForm->SetSoftkeyActionId (SOFTKEY_1, AC_SOFTKEY_EXIT); __pMainForm->AddSoftkeyActionListener (SOFTKEY_1, *this); pAppFrame->GetFrame()->AddControl(*__pMainForm); /*Web*/ __pWeb = new Web(); r = __pWeb->Construct(Rectangle(0, 0, 480, 760)); TryCatch(r == E_SUCCESS, ,"Web is not constructed\n "); r = __pMainForm->AddControl(*__pWeb); TryCatch(r == E_SUCCESS, ,"Web is not attached\n "); __pWeb->SetFocus(); __pWeb->LoadUrl(L"/Res/index.html"); //__pWeb->EvaluateJavascriptN(L"alert('aaa');"); return r; CATCH: AppLog("Error = %s\n", GetErrorMessage(r)); return r; }
bool Wonderland::OnAppInitializing(AppRegistry& appRegistry) { result r = E_SUCCESS; IAppFrame* pAppFrame = GetAppFrame(); __pForm = new GlesForm(this); if (null == __pForm) { AppLog("[Wonderland] Allocation of GlesForm has failed.\n"); Cleanup(); return false; } r = __pForm->Construct(FORM_STYLE_NORMAL); if (IsFailed(r)) { AppLog("[Wonderland] __pForm->Construct(FORM_STYLE_NORMAL) has failed.\n"); delete __pForm; __pForm = null; return false; } __pForm->SetOrientation(ORIENTATION_PORTRAIT); r = GetAppFrame()->GetFrame()->AddControl(*__pForm); if (IsFailed(r)) { AppLog("[Wonderland] GetAppFrame()->GetFrame()->AddControl(*__pForm) has failed.\n"); delete __pForm; __pForm = null; return false; } if (null == pAppFrame) { Cleanup(); return false; } r = pAppFrame->AddKeyEventListener(*this); if (IsFailed(r)) { Cleanup(); return false; } // if(!Game::getInstance().initializeGraphics((EGLNativeWindowType)__pForm)) // { // Cleanup(); // AppLog("Could not initializeGraphics"); // return false; // } __pTimer = new Timer; if (null == __pTimer) { Cleanup(); return false; } r = __pTimer->Construct(*this); if (IsFailed(r)) { Cleanup(); return false; } // Comment the following statement to stop listen to the screen on/off events. PowerManager::SetScreenEventListener(*this); BallsGameController* controller = new BallsGameController(); controller->setDifficulty(BallsGameController::GD_EASY); // Game::getInstance().initializeController(controller); // Log("Before set HUD"); // Game::getInstance().setHUD(std::auto_ptr<HUD>(new BallsHUD(SCREEN_WIDTH, SCREEN_HEIGHT))); Game::getInstance().initialize(std::auto_ptr<GameController>(controller)); Game::getInstance().initializeGraphics((EGLNativeWindowType)__pForm); Game::getInstance().setHud(std::auto_ptr<HUD>(new BallsHUD())); // Game::getInstance().initializeActors(); // Game::getInstance().getRenderer().getCamera().initialize(SCREEN_WIDTH, SCREEN_HEIGHT, 27, 1, 100, Vector(0, 0, -20)); // Game::getInstance().getHUD().initialize(); // Game::getInstance().getResourceManager().initialize(); // Game::getInstance().getMaterialsManager().initialize(); __pForm->AddTouchEventListener(*this); return true; }