axmol/cocos2dx/platform/bada/CCApplication_bada.cpp

161 lines
2.9 KiB
C++
Raw Normal View History

2011-09-19 18:05:40 +08:00
#include "CCApplication_bada.h"
#include "CCDirector.h"
using namespace Osp::App;
using namespace Osp::System;
using namespace Osp::Base;
using namespace Osp::Base::Runtime;
2011-10-29 14:47:13 +08:00
using namespace Osp::Locales;
2011-09-19 18:05:40 +08:00
NS_CC_BEGIN;
static CCApplication * s_pApplication = NULL;
static long long s_nAnimationInterval = 1000/60;
2011-09-19 18:05:40 +08:00
CCApplication::CCApplication() :
m_pTimer(null)
2011-09-19 18:05:40 +08:00
{
2011-09-19 18:17:19 +08:00
CCLog("CCApplication constructor...");
2011-09-19 18:05:40 +08:00
s_pApplication = this;
2011-09-19 18:05:40 +08:00
}
CCApplication::~CCApplication()
{
s_pApplication = NULL;
}
CCApplication::Orientation CCApplication::setOrientation(CCApplication::Orientation orientation)
{
return orientation;
2011-09-19 18:05:40 +08:00
}
CCRect CCApplication::statusBarFrame(CCRect * rect)
{
if (rect)
{
// bada doesn't have status bar.
*rect = CCRectMake(0, 0, 0, 0);
}
return *rect;
2011-09-19 18:05:40 +08:00
}
//////////////////////////////////////////////////////////////////////////
/// Implement static class member
//////////////////////////////////////////////////////////////////////////
CCApplication& CCApplication::sharedApplication()
{
CC_ASSERT(s_pApplication);
return *s_pApplication;
}
ccLanguageType CCApplication::getCurrentLanguage()
{
2011-10-14 15:54:18 +08:00
ccLanguageType ret = kLanguageEnglish;
2011-11-01 23:32:26 +08:00
result r = E_SUCCESS;
String value;
r = SettingInfo::GetValue(L"Language", value);
if (value.Equals("ZHO", false))
2011-10-14 15:54:18 +08:00
{
2011-11-01 23:32:26 +08:00
ret = kLanguageChinese;
}
else if (value.Equals("FRA", false))
{
ret = kLanguageFrench;
}
else if (value.Equals("ITA", false))
{
ret = kLanguageItalian;
}
else if (value.Equals("DEU", false))
{
ret = kLanguageGerman;
}
else if (value.Equals("SPA", false))
{
ret = kLanguageSpanish;
}
else if (value.Equals("RUS", false))
{
ret = kLanguageRussian;
}
2011-10-14 15:54:18 +08:00
return ret;
}
2011-09-19 18:05:40 +08:00
void CCApplication::setAnimationInterval(double interval)
{
s_nAnimationInterval = (long long)(interval * 1000.0f);
2011-09-19 18:05:40 +08:00
}
bool CCApplication::OnAppInitializing(AppRegistry& appRegistry)
{
result r = E_FAILURE;
2011-09-20 02:19:26 +08:00
if (! initInstance() || !applicationDidFinishLaunching())
return false;
2011-10-29 14:47:13 +08:00
CCEGLView::sharedOpenGLView().AddKeyEventListener(*this);
m_pTimer = new Timer;
if (null == m_pTimer)
{
return E_FAILURE;
}
r = m_pTimer->Construct(*this);
if (IsFailed(r))
{
delete m_pTimer;
m_pTimer = null;
return E_FAILURE;
}
2011-09-20 02:19:26 +08:00
return true;
2011-09-19 18:05:40 +08:00
}
bool CCApplication::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination)
{
if (m_pTimer)
{
m_pTimer->Cancel();
delete m_pTimer;
m_pTimer = null;
}
2011-09-19 18:05:40 +08:00
return true;
}
void CCApplication::OnForeground(void)
{
if (m_pTimer)
m_pTimer->Start(s_nAnimationInterval);
2011-10-29 14:47:13 +08:00
applicationWillEnterForeground();
2011-09-19 18:05:40 +08:00
}
void CCApplication::OnBackground(void)
{
if (m_pTimer)
m_pTimer->Cancel();
2011-10-29 14:47:13 +08:00
applicationDidEnterBackground();
2011-09-19 18:05:40 +08:00
}
void CCApplication::OnLowMemory(void)
{
}
void CCApplication::OnBatteryLevelChanged(BatteryLevel batteryLevel)
{
}
void CCApplication::OnTimerExpired(Timer& timer)
{
m_pTimer->Start(s_nAnimationInterval);
CCDirector::sharedDirector()->mainLoop();
}
2011-09-19 18:05:40 +08:00
NS_CC_END;