mirror of https://github.com/axmolengine/axmol.git
[WIN32] Enabled retina. Updated the implementation of fullPathFromRelativePath.
This commit is contained in:
parent
a8e4cbe3b5
commit
369eb3daa3
|
@ -149,6 +149,7 @@ void CCEGLViewProtocol::setTouchDelegate(EGLTouchDelegate * pDelegate)
|
||||||
|
|
||||||
bool CCEGLViewProtocol::setContentScaleFactor(float contentScaleFactor)
|
bool CCEGLViewProtocol::setContentScaleFactor(float contentScaleFactor)
|
||||||
{
|
{
|
||||||
|
m_fScaleX = m_fScaleY = contentScaleFactor;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -210,7 +210,7 @@ LRESULT CCEGLView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
if (m_pDelegate && MK_LBUTTON == wParam)
|
if (m_pDelegate && MK_LBUTTON == wParam)
|
||||||
{
|
{
|
||||||
POINT point = {(short)LOWORD(lParam), (short)HIWORD(lParam)};
|
POINT point = {(short)LOWORD(lParam), (short)HIWORD(lParam)};
|
||||||
CCPoint pt(point.x/CC_CONTENT_SCALE_FACTOR(), point.y/CC_CONTENT_SCALE_FACTOR());
|
CCPoint pt(point.x, point.y);
|
||||||
CCPoint tmp = ccp(pt.x, m_obScreenSize.height - pt.y);
|
CCPoint tmp = ccp(pt.x, m_obScreenSize.height - pt.y);
|
||||||
if (m_obViewPortRect.equals(CCRectZero) || m_obViewPortRect.containsPoint(tmp))
|
if (m_obViewPortRect.equals(CCRectZero) || m_obViewPortRect.containsPoint(tmp))
|
||||||
{
|
{
|
||||||
|
@ -226,7 +226,7 @@ LRESULT CCEGLView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
if (MK_LBUTTON == wParam && m_bCaptured)
|
if (MK_LBUTTON == wParam && m_bCaptured)
|
||||||
{
|
{
|
||||||
POINT point = {(short)LOWORD(lParam), (short)HIWORD(lParam)};
|
POINT point = {(short)LOWORD(lParam), (short)HIWORD(lParam)};
|
||||||
CCPoint pt(point.x/CC_CONTENT_SCALE_FACTOR(), point.y/CC_CONTENT_SCALE_FACTOR());
|
CCPoint pt(point.x, point.y);
|
||||||
int id = 0;
|
int id = 0;
|
||||||
handleTouchesMove(1, &id, &pt.x, &pt.y);
|
handleTouchesMove(1, &id, &pt.x, &pt.y);
|
||||||
}
|
}
|
||||||
|
@ -236,7 +236,7 @@ LRESULT CCEGLView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
if (m_bCaptured)
|
if (m_bCaptured)
|
||||||
{
|
{
|
||||||
POINT point = {(short)LOWORD(lParam), (short)HIWORD(lParam)};
|
POINT point = {(short)LOWORD(lParam), (short)HIWORD(lParam)};
|
||||||
CCPoint pt(point.x/CC_CONTENT_SCALE_FACTOR(), point.y/CC_CONTENT_SCALE_FACTOR());
|
CCPoint pt(point.x, point.y);
|
||||||
int id = 0;
|
int id = 0;
|
||||||
handleTouchesEnd(1, &id, &pt.x, &pt.y);
|
handleTouchesEnd(1, &id, &pt.x, &pt.y);
|
||||||
|
|
||||||
|
@ -370,6 +370,11 @@ void CCEGLView::setIMEKeyboardState(bool /*bOpen*/)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CCEGLView::enableRetina()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
HWND CCEGLView::getHWnd()
|
HWND CCEGLView::getHWnd()
|
||||||
{
|
{
|
||||||
return m_hWnd;
|
return m_hWnd;
|
||||||
|
|
|
@ -47,7 +47,7 @@ public:
|
||||||
virtual bool setContentScaleFactor(float contentScaleFactor);
|
virtual bool setContentScaleFactor(float contentScaleFactor);
|
||||||
virtual void setFrameSize(float width, float height);
|
virtual void setFrameSize(float width, float height);
|
||||||
virtual void setIMEKeyboardState(bool bOpen);
|
virtual void setIMEKeyboardState(bool bOpen);
|
||||||
|
virtual bool enableRetina();
|
||||||
private:
|
private:
|
||||||
virtual bool Create(LPCTSTR pTitle, int w, int h);
|
virtual bool Create(LPCTSTR pTitle, int w, int h);
|
||||||
bool initGL();
|
bool initGL();
|
||||||
|
|
|
@ -37,17 +37,11 @@ static void _CheckPath()
|
||||||
{
|
{
|
||||||
if (! s_pszResourcePath[0])
|
if (! s_pszResourcePath[0])
|
||||||
{
|
{
|
||||||
WCHAR wszPath[MAX_PATH];
|
WCHAR wszPath[MAX_PATH] = {0};
|
||||||
int nNum = WideCharToMultiByte(CP_ACP, 0, wszPath,
|
int nNum = WideCharToMultiByte(CP_ACP, 0, wszPath,
|
||||||
GetCurrentDirectoryW(sizeof(wszPath), wszPath),
|
GetCurrentDirectoryW(sizeof(wszPath), wszPath),
|
||||||
s_pszResourcePath, MAX_PATH, NULL, NULL);
|
s_pszResourcePath, MAX_PATH, NULL, NULL);
|
||||||
s_pszResourcePath[nNum] = '\\';
|
s_pszResourcePath[nNum] = '\\';
|
||||||
const char* resDir = CCFileUtils::sharedFileUtils()->getResourceDirectory();
|
|
||||||
if (resDir != NULL)
|
|
||||||
{
|
|
||||||
strcat(s_pszResourcePath, resDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +52,7 @@ CCFileUtils* CCFileUtils::sharedFileUtils()
|
||||||
if (s_pFileUtils == NULL)
|
if (s_pFileUtils == NULL)
|
||||||
{
|
{
|
||||||
s_pFileUtils = new CCFileUtils();
|
s_pFileUtils = new CCFileUtils();
|
||||||
|
_CheckPath();
|
||||||
}
|
}
|
||||||
return s_pFileUtils;
|
return s_pFileUtils;
|
||||||
}
|
}
|
||||||
|
@ -79,10 +74,10 @@ void CCFileUtils::purgeCachedEntries()
|
||||||
|
|
||||||
const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
|
const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
|
||||||
{
|
{
|
||||||
_CheckPath();
|
bool bFileExist = true;
|
||||||
|
const char* resDir = CCFileUtils::sharedFileUtils()->getResourceDirectory();
|
||||||
|
CCString* pRet = CCString::create("");
|
||||||
|
|
||||||
CCString * pRet = new CCString();
|
|
||||||
pRet->autorelease();
|
|
||||||
if ((strlen(pszRelativePath) > 1 && pszRelativePath[1] == ':'))
|
if ((strlen(pszRelativePath) > 1 && pszRelativePath[1] == ':'))
|
||||||
{
|
{
|
||||||
// path start with "x:", is absolute path
|
// path start with "x:", is absolute path
|
||||||
|
@ -99,19 +94,35 @@ const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pRet->m_sString = s_pszResourcePath;
|
pRet->m_sString = s_pszResourcePath;
|
||||||
|
pRet->m_sString += resDir;
|
||||||
pRet->m_sString += pszRelativePath;
|
pRet->m_sString += pszRelativePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If file or directory doesn't exist, try to find it in the root path.
|
||||||
|
if (GetFileAttributesA(pRet->m_sString.c_str()) == -1)
|
||||||
|
{
|
||||||
|
pRet->m_sString = s_pszResourcePath;
|
||||||
|
pRet->m_sString += pszRelativePath;
|
||||||
|
|
||||||
|
if (GetFileAttributesA(pRet->m_sString.c_str()) == -1)
|
||||||
|
{
|
||||||
|
bFileExist = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!bFileExist)
|
||||||
|
{ // Can't find the file, return the relative path.
|
||||||
|
pRet->m_sString = pszRelativePath;
|
||||||
|
}
|
||||||
|
|
||||||
return pRet->m_sString.c_str();
|
return pRet->m_sString.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *CCFileUtils::fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile)
|
const char *CCFileUtils::fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile)
|
||||||
{
|
{
|
||||||
_CheckPath();
|
|
||||||
// std::string relativeFile = fullPathFromRelativePath(pszRelativeFile);
|
// std::string relativeFile = fullPathFromRelativePath(pszRelativeFile);
|
||||||
std::string relativeFile = pszRelativeFile;
|
std::string relativeFile = pszRelativeFile;
|
||||||
CCString *pRet = new CCString();
|
CCString *pRet = CCString::create("");
|
||||||
pRet->autorelease();
|
|
||||||
pRet->m_sString = relativeFile.substr(0, relativeFile.find_last_of("/\\") + 1);
|
pRet->m_sString = relativeFile.substr(0, relativeFile.find_last_of("/\\") + 1);
|
||||||
pRet->m_sString += pszFilename;
|
pRet->m_sString += pszFilename;
|
||||||
return pRet->m_sString.c_str();
|
return pRet->m_sString.c_str();
|
||||||
|
|
Loading…
Reference in New Issue