2011-11-28 18:05:38 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2010 cocos2d-x.org
|
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
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
|
|
|
{
|
|
|
|
s_pApplication = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|