2011-09-19 18:05:40 +08:00
|
|
|
#include "CCApplication_bada.h"
|
|
|
|
#include "CCDirector.h"
|
|
|
|
|
|
|
|
using namespace Osp::App;
|
|
|
|
using namespace Osp::System;
|
2011-09-29 02:32:01 +08:00
|
|
|
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;
|
2011-09-29 02:32:01 +08:00
|
|
|
static long long s_nAnimationInterval = 1000/60;
|
2011-09-19 18:05:40 +08:00
|
|
|
|
2011-09-29 02:32:01 +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-29 02:32:01 +08:00
|
|
|
|
2011-09-19 18:05:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCApplication::~CCApplication()
|
|
|
|
{
|
|
|
|
s_pApplication = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCApplication::Orientation CCApplication::setOrientation(CCApplication::Orientation orientation)
|
|
|
|
{
|
2011-11-07 18:18:10 +08:00
|
|
|
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);
|
|
|
|
}
|
2011-09-29 02:32:01 +08:00
|
|
|
return *rect;
|
2011-09-19 18:05:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
/// Implement static class member
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
CCApplication& CCApplication::sharedApplication()
|
|
|
|
{
|
|
|
|
CC_ASSERT(s_pApplication);
|
|
|
|
return *s_pApplication;
|
|
|
|
}
|
|
|
|
|
2011-09-20 12:39:44 +08:00
|
|
|
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-20 12:39:44 +08:00
|
|
|
}
|
|
|
|
|
2011-09-19 18:05:40 +08:00
|
|
|
void CCApplication::setAnimationInterval(double interval)
|
|
|
|
{
|
2011-09-29 15:52:16 +08:00
|
|
|
s_nAnimationInterval = (long long)(interval * 1000.0f);
|
2011-09-19 18:05:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CCApplication::OnAppInitializing(AppRegistry& appRegistry)
|
|
|
|
{
|
2011-09-29 02:32:01 +08:00
|
|
|
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);
|
|
|
|
|
2011-09-29 15:52:16 +08:00
|
|
|
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)
|
|
|
|
{
|
2011-09-29 15:52:16 +08:00
|
|
|
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)
|
|
|
|
{
|
2011-09-29 15:52:16 +08:00
|
|
|
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)
|
|
|
|
{
|
2011-09-29 15:52:16 +08:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-09-29 02:32:01 +08:00
|
|
|
void CCApplication::OnTimerExpired(Timer& timer)
|
|
|
|
{
|
2011-09-29 15:52:16 +08:00
|
|
|
m_pTimer->Start(s_nAnimationInterval);
|
|
|
|
CCDirector::sharedDirector()->mainLoop();
|
2011-09-29 02:32:01 +08:00
|
|
|
}
|
2011-09-19 18:05:40 +08:00
|
|
|
|
2011-10-29 15:38:15 +08:00
|
|
|
NS_CC_END;
|