add f project

This commit is contained in:
dumganhar 2011-11-29 12:38:20 +08:00
parent 4bdd70ab90
commit 0fff92236f
10 changed files with 120 additions and 89 deletions

View File

@ -57,12 +57,9 @@ void CC_DLL CCMessageBox(const char * pszMsg, const char * pszTitle);
typedef enum LanguageType typedef enum LanguageType
{ {
kLanguageEnglish = 0, kLanguageEnglish = 0,
kLanguageChinese, kLanguageChinese_Simplified,
kLanguageFrench, kLanguageChinese_Traditional,
kLanguageItalian, kLanguageJapanese,
kLanguageGerman,
kLanguageSpanish,
kLanguageRussian
} ccLanguageType; } ccLanguageType;
NS_CC_END; NS_CC_END;

View File

@ -78,37 +78,37 @@ CCApplication& CCApplication::sharedApplication()
ccLanguageType CCApplication::getCurrentLanguage() ccLanguageType CCApplication::getCurrentLanguage()
{ {
const char *pLanguageName = getCurrentLanguageJNI(); std::string localInfo = getCurrentLanguageJNI();
ccLanguageType ret = kLanguageEnglish; ccLanguageType ret = kLanguageEnglish;
if (0 == strcmp("zh", pLanguageName)) int pos = localInfo.find("@");
if (pos == std::string::npos)
{ {
ret = kLanguageChinese; return kLanguageEnglish;
} }
else if (0 == strcmp("en", pLanguageName))
std::string languageName = localInfo.substr(0, pos);
std::string countryName = localInfo.substr(pos + 1);
if (0 == languageName.compare("zh"))
{
if (0 == countryName.compare("CN"))
{
ret = kLanguageChinese_Simplified;
}
else
{
ret = kLanguageChinese_Traditional;
}
}
else if (0 == languageName.compare("ja"))
{
ret = kLanguageJapanese;
}
else if (0 == languageName.compare("en"))
{ {
ret = kLanguageEnglish; ret = kLanguageEnglish;
} }
else if (0 == strcmp("fr", pLanguageName))
{
ret = kLanguageFrench;
}
else if (0 == strcmp("it", pLanguageName))
{
ret = kLanguageItalian;
}
else if (0 == strcmp("de", pLanguageName))
{
ret = kLanguageGerman;
}
else if (0 == strcmp("es", pLanguageName))
{
ret = kLanguageSpanish;
}
else if (0 == strcmp("ru", pLanguageName))
{
ret = kLanguageRussian;
}
return ret; return ret;
} }

View File

@ -58,7 +58,7 @@ void CCEGLView::create(int width, int height)
m_sSizeInPoint.height = height; m_sSizeInPoint.height = height;
// calculate the factor and the rect of viewport // calculate the factor and the rect of viewport
m_fScreenScaleFactor = MIN((float)m_sSizeInPixel.width / m_sSizeInPoint.width, m_fScreenScaleFactor = MAX((float)m_sSizeInPixel.width / m_sSizeInPoint.width,
(float)m_sSizeInPixel.height / m_sSizeInPoint.height); (float)m_sSizeInPixel.height / m_sSizeInPoint.height);
int viewPortW = (int)(m_sSizeInPoint.width * m_fScreenScaleFactor); int viewPortW = (int)(m_sSizeInPoint.width * m_fScreenScaleFactor);
int viewPortH = (int)(m_sSizeInPoint.height * m_fScreenScaleFactor); int viewPortH = (int)(m_sSizeInPoint.height * m_fScreenScaleFactor);
@ -194,5 +194,12 @@ void CCEGLView::setIMEKeyboardState(bool bOpen)
setKeyboardStateJNI((int)bOpen); setKeyboardStateJNI((int)bOpen);
} }
} // end of namespace cocos2d void CCEGLView::getScreenRectInView(CCRect& rect)
{
rect.origin.x = -m_rcViewPort.origin.x / m_fScreenScaleFactor;
rect.origin.y = -m_rcViewPort.origin.y / m_fScreenScaleFactor;
rect.size.width = m_sSizeInPixel.width / m_fScreenScaleFactor;
rect.size.height = m_sSizeInPixel.height / m_fScreenScaleFactor;
}
} // end of namespace cocos2d

View File

@ -63,6 +63,8 @@ public:
float getScreenScaleFactor(); float getScreenScaleFactor();
void setIMEKeyboardState(bool bOpen); void setIMEKeyboardState(bool bOpen);
void getScreenRectInView(CCRect& rect);
// static function // static function
/** /**
@brief get the shared main open gl window @brief get the shared main open gl window

View File

@ -74,33 +74,24 @@ CCApplication& CCApplication::sharedApplication()
ccLanguageType CCApplication::getCurrentLanguage() ccLanguageType CCApplication::getCurrentLanguage()
{ {
ccLanguageType ret = kLanguageEnglish; ccLanguageType ret = kLanguageEnglish;
do
{
result r = E_SUCCESS; result r = E_SUCCESS;
String value; String value;
r = SettingInfo::GetValue(L"Language", value); r = SettingInfo::GetValue(L"Language", value);
if (value.Equals("ZHO", false)) if (value.Equals("ZHO", false))
{ {
ret = kLanguageChinese; r = SettingInfo::GetValue(L"Country", value);
} if (value.Equals("HK", false) || value.Equals("TW", false))
else if (value.Equals("FRA", false))
{ {
ret = kLanguageFrench; ret = kLanguageChinese_Traditional;
} }
else if (value.Equals("ITA", false)) else
{ {
ret = kLanguageItalian; ret = kLanguageChinese_Simplified;
} }
else if (value.Equals("DEU", false))
{
ret = kLanguageGerman;
}
else if (value.Equals("SPA", false))
{
ret = kLanguageSpanish;
}
else if (value.Equals("RUS", false))
{
ret = kLanguageRussian;
} }
} while (0);
return ret; return ret;
} }

View File

@ -668,6 +668,14 @@ void CCEGLView::OnTextValueChangeCanceled(const Control& source)
CCIMEDispatcher::sharedDispatcher()->dispatchInsertText("\n", 1); CCIMEDispatcher::sharedDispatcher()->dispatchInsertText("\n", 1);
} }
void CCEGLView::getScreenRectInView(CCRect& rect)
{
rect.origin.x = -m_rcViewPort.origin.x / m_fScreenScaleFactor;
rect.origin.y = -m_rcViewPort.origin.y / m_fScreenScaleFactor;
rect.size.width = m_sSizeInPixel.width / m_fScreenScaleFactor;
rect.size.height = m_sSizeInPixel.height / m_fScreenScaleFactor;
}
CCEGLView& CCEGLView::sharedOpenGLView() CCEGLView& CCEGLView::sharedOpenGLView()
{ {
CC_ASSERT(s_pMainWindow); CC_ASSERT(s_pMainWindow);

View File

@ -63,6 +63,9 @@ public:
void setScissorInPoints(float x, float y, float w, float h); void setScissorInPoints(float x, float y, float w, float h);
void setIMEKeyboardState(bool bOpen); void setIMEKeyboardState(bool bOpen);
void getScreenRectInView(CCRect& rect);
// static function // static function
/** /**
@brief get the shared main open gl window @brief get the shared main open gl window

View File

@ -127,32 +127,39 @@ CCApplication& CCApplication::sharedApplication()
ccLanguageType CCApplication::getCurrentLanguage() ccLanguageType CCApplication::getCurrentLanguage()
{ {
int arrayChineseCode[] = {
2052, 4100, 1028, 3076, 5124
};
LCID LanguageID = GetUserDefaultLCID();
ccLanguageType ret = kLanguageEnglish; ccLanguageType ret = kLanguageEnglish;
LCID localeID = GetUserDefaultLCID(); do
unsigned short primaryLanguageID = localeID & 0xFF;
switch (primaryLanguageID)
{ {
case LANG_CHINESE: int nCount = sizeof(arrayChineseCode) / sizeof(int);
ret = kLanguageChinese; for (int i = 0; i < nCount; ++i)
break; {
case LANG_FRENCH: if (arrayChineseCode[i] == LanguageID)
ret = kLanguageFrench; {
break; if (LanguageID == 2052)
case LANG_ITALIAN: {
ret = kLanguageItalian; ret = kLanguageChinese_Simplified;
break; }
case LANG_GERMAN: else
ret = kLanguageGerman; {
break; ret = kLanguageChinese_Traditional;
case LANG_SPANISH: }
ret = kLanguageSpanish;
break;
case LANG_RUSSIAN:
ret = kLanguageRussian;
break; break;
} }
}
CC_BREAK_IF(kLanguageEnglish != ret);
if (1041 == LanguageID)
{
ret = kLanguageJapanese;
}
} while (0);
return ret; return ret;
} }

View File

@ -235,7 +235,7 @@ bool CCEGLView::Create(LPCTSTR pTitle, int w, int h)
WS_EX_APPWINDOW | WS_EX_WINDOWEDGE, // Extended Style For The Window WS_EX_APPWINDOW | WS_EX_WINDOWEDGE, // Extended Style For The Window
kWindowClassName, // Class Name kWindowClassName, // Class Name
pTitle, // Window Title pTitle, // Window Title
WS_CAPTION | WS_POPUPWINDOW | WS_MINIMIZEBOX, // Defined Window Style WS_CAPTION | WS_POPUPWINDOW, // Defined Window Style
0, 0, // Window Position 0, 0, // Window Position
0, // Window Width 0, // Window Width
0, // Window Height 0, // Window Height
@ -373,7 +373,8 @@ LRESULT CCEGLView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
break; break;
case WM_CLOSE: case WM_CLOSE:
CCDirector::sharedDirector()->end(); CCKeypadDispatcher::sharedDispatcher()->dispatchKeypadMSG(kTypeBackClicked);
// CCDirector::sharedDirector()->end();
break; break;
case WM_DESTROY: case WM_DESTROY:
@ -480,6 +481,19 @@ void CCEGLView::setIMEKeyboardState(bool /*bOpen*/)
{ {
} }
void CCEGLView::getScreenRectInView(CCRect& rect)
{
RECT rcClient;
GetClientRect(m_hWnd, &rcClient);
RECT rcScreenRectInView = {0};
IntersectRect(&rcScreenRectInView, &rcClient, &m_rcViewPort);
rect.origin.x = float(- m_rcViewPort.left) / m_fScreenScaleFactor;
rect.origin.y = float((m_rcViewPort.bottom - m_rcViewPort.top) - (rcScreenRectInView.bottom - m_rcViewPort.top)) / m_fScreenScaleFactor;
rect.size.width = float(rcScreenRectInView.right - rcScreenRectInView.left) / m_fScreenScaleFactor;
rect.size.height = float(rcScreenRectInView.bottom - rcScreenRectInView.top) / m_fScreenScaleFactor;
}
HWND CCEGLView::getHWnd() HWND CCEGLView::getHWnd()
{ {
return m_hWnd; return m_hWnd;

View File

@ -62,6 +62,8 @@ public:
void setIMEKeyboardState(bool bOpen); void setIMEKeyboardState(bool bOpen);
void getScreenRectInView(CCRect& rect);
// win32 platform function // win32 platform function
HWND getHWnd(); HWND getHWnd();
void resize(int width, int height); void resize(int width, int height);