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
{
kLanguageEnglish = 0,
kLanguageChinese,
kLanguageFrench,
kLanguageItalian,
kLanguageGerman,
kLanguageSpanish,
kLanguageRussian
kLanguageChinese_Simplified,
kLanguageChinese_Traditional,
kLanguageJapanese,
} ccLanguageType;
NS_CC_END;

View File

@ -78,38 +78,38 @@ CCApplication& CCApplication::sharedApplication()
ccLanguageType CCApplication::getCurrentLanguage()
{
const char *pLanguageName = getCurrentLanguageJNI();
std::string localInfo = getCurrentLanguageJNI();
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;
}
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;
}

View File

@ -58,7 +58,7 @@ void CCEGLView::create(int width, int height)
m_sSizeInPoint.height = height;
// 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);
int viewPortW = (int)(m_sSizeInPoint.width * m_fScreenScaleFactor);
int viewPortH = (int)(m_sSizeInPoint.height * m_fScreenScaleFactor);
@ -194,5 +194,12 @@ void CCEGLView::setIMEKeyboardState(bool 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();
void setIMEKeyboardState(bool bOpen);
void getScreenRectInView(CCRect& rect);
// static function
/**
@brief get the shared main open gl window

View File

@ -74,33 +74,24 @@ CCApplication& CCApplication::sharedApplication()
ccLanguageType CCApplication::getCurrentLanguage()
{
ccLanguageType ret = kLanguageEnglish;
result r = E_SUCCESS;
String value;
r = SettingInfo::GetValue(L"Language", value);
if (value.Equals("ZHO", false))
do
{
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;
}
result r = E_SUCCESS;
String value;
r = SettingInfo::GetValue(L"Language", value);
if (value.Equals("ZHO", false))
{
r = SettingInfo::GetValue(L"Country", value);
if (value.Equals("HK", false) || value.Equals("TW", false))
{
ret = kLanguageChinese_Traditional;
}
else
{
ret = kLanguageChinese_Simplified;
}
}
} while (0);
return ret;
}

View File

@ -311,10 +311,10 @@ void CCEGLView::setScissorInPoints(float x, float y, float w, float h)
void CCEGLView::setIMEKeyboardState(bool bOpen)
{
if (bOpen)
{
const char * pszText = CCIMEDispatcher::sharedDispatcher()->getContentText();
m_pKeypad->SetText(pszText);
m_pKeypad->SetShowState(bOpen);
{
const char * pszText = CCIMEDispatcher::sharedDispatcher()->getContentText();
m_pKeypad->SetText(pszText);
m_pKeypad->SetShowState(bOpen);
m_pKeypad->Show();
}
}
@ -668,6 +668,14 @@ void CCEGLView::OnTextValueChangeCanceled(const Control& source)
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()
{
CC_ASSERT(s_pMainWindow);

View File

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

View File

@ -127,32 +127,39 @@ CCApplication& CCApplication::sharedApplication()
ccLanguageType CCApplication::getCurrentLanguage()
{
int arrayChineseCode[] = {
2052, 4100, 1028, 3076, 5124
};
LCID LanguageID = GetUserDefaultLCID();
ccLanguageType ret = kLanguageEnglish;
LCID localeID = GetUserDefaultLCID();
unsigned short primaryLanguageID = localeID & 0xFF;
switch (primaryLanguageID)
{
case LANG_CHINESE:
ret = kLanguageChinese;
break;
case LANG_FRENCH:
ret = kLanguageFrench;
break;
case LANG_ITALIAN:
ret = kLanguageItalian;
break;
case LANG_GERMAN:
ret = kLanguageGerman;
break;
case LANG_SPANISH:
ret = kLanguageSpanish;
break;
case LANG_RUSSIAN:
ret = kLanguageRussian;
break;
}
do
{
int nCount = sizeof(arrayChineseCode) / sizeof(int);
for (int i = 0; i < nCount; ++i)
{
if (arrayChineseCode[i] == LanguageID)
{
if (LanguageID == 2052)
{
ret = kLanguageChinese_Simplified;
}
else
{
ret = kLanguageChinese_Traditional;
}
break;
}
}
CC_BREAK_IF(kLanguageEnglish != ret);
if (1041 == LanguageID)
{
ret = kLanguageJapanese;
}
} while (0);
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
kWindowClassName, // Class Name
pTitle, // Window Title
WS_CAPTION | WS_POPUPWINDOW | WS_MINIMIZEBOX, // Defined Window Style
WS_CAPTION | WS_POPUPWINDOW, // Defined Window Style
0, 0, // Window Position
0, // Window Width
0, // Window Height
@ -373,7 +373,8 @@ LRESULT CCEGLView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
break;
case WM_CLOSE:
CCDirector::sharedDirector()->end();
CCKeypadDispatcher::sharedDispatcher()->dispatchKeypadMSG(kTypeBackClicked);
// CCDirector::sharedDirector()->end();
break;
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()
{
return m_hWnd;

View File

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