From acff950860f6219f08a538a0d83176f1eaf5dd64 Mon Sep 17 00:00:00 2001 From: natural-law Date: Fri, 14 Jan 2011 17:42:37 +0800 Subject: [PATCH] [uphone]fixed #315,remove the way which use resource in ResourceMap. --- CocosDenshion/android/SimpleAudioEngine.cpp | 13 +- CocosDenshion/include/SimpleAudioEngine.h | 20 - CocosDenshion/iphone/SimpleAudioEngine.mm | 13 +- .../proj.uphone/CocosDenshion.uphone.vcproj | 8 - CocosDenshion/uphone/ResourceHandle.cpp | 44 - CocosDenshion/uphone/ResourceHandle.h | 43 - CocosDenshion/uphone/SimpleAudioEngine.cpp | 10 - CocosDenshion/uphone/SoundDataManager.cpp | 137 +- CocosDenshion/uphone/SoundDataManager.h | 21 - CocosDenshion/win32/SimpleAudioEngine.cpp | 12 - HelloWorld/AppDelegate.cpp | 4 + HelloWorld/uphone/HelloWorld.uphone.vcproj | 5 +- HelloWorld/uphone/Res/HelloWorld_Res.ENU.tr3 | 18 +- .../uphone/Res/HelloWorld_Res.ENU.tr3.tts | 2 +- HelloWorld/uphone/Res/HelloWorld_Res.TR3 | 18 +- HelloWorld/uphone/Res/HelloWorld_Res.h | 5 +- HelloWorld/uphone/Res/HelloWorld_res_c.h | 245 +++ .../Res/HelloWorld_res_c.h.REMOVED.git-id | 1 - HelloWorld/uphone/Res/HelloWorld_res_def.h | 5 +- HelloWorld/uphone/Res/HelloWorld_res_h.h | 7 +- HelloWorld/uphone/Resource.h | 14 - HelloWorld/uphone/main.cpp | 12 +- .../Res/TestAudioEngine_Res.ENU.tr3 | 13 +- .../Res/TestAudioEngine_Res.ENU.tr3.tts | 2 +- .../Res/TestAudioEngine_Res.TR3 | 13 +- .../Res/TestAudioEngine_Res.h | 5 +- .../Res/testaudioengine_res_c.h | 1639 +++++++++++++++++ .../testaudioengine_res_c.h.REMOVED.git-id | 1 - .../Res/testaudioengine_res_def.h | 3 - TestAudioEngine.uphone/TestAudioEngine.vcproj | 2 +- .../TestAudioEngineEntry.cpp | 2 +- .../TestAudioEngineMainForm.cpp | 28 +- .../platform/uphone/CCXFileUtils_uphone.cpp | 101 +- .../platform/uphone/CCXFileUtils_uphone.h | 46 +- .../platform/uphone/CCXUIImage_uphone.cpp | 43 +- .../CCXAppWiz.uphone/CCXAppWiz.uphone.vcproj | 4 - .../CCXAppWiz.uphone/HTML/1033/default.htm | 17 +- .../CCXAppWiz.uphone/HTML/1033/features.htm | 29 +- .../CCXAppWiz.uphone/Scripts/1033/default.js | 6 - .../Templates/1033/Classes/AppDelegate.cpp | 19 +- .../1033/Classes/HelloWorldScene.cpp | 8 +- .../Templates/1033/Templates.inf | 11 - .../Templates/1033/uphone/main.cpp | 18 - .../Templates/1033/uphone/resource.h | 19 - 44 files changed, 1966 insertions(+), 720 deletions(-) delete mode 100644 CocosDenshion/uphone/ResourceHandle.cpp delete mode 100644 CocosDenshion/uphone/ResourceHandle.h create mode 100644 HelloWorld/uphone/Res/HelloWorld_res_c.h delete mode 100644 HelloWorld/uphone/Res/HelloWorld_res_c.h.REMOVED.git-id delete mode 100644 HelloWorld/uphone/Resource.h create mode 100644 TestAudioEngine.uphone/Res/testaudioengine_res_c.h delete mode 100644 TestAudioEngine.uphone/Res/testaudioengine_res_c.h.REMOVED.git-id delete mode 100644 template/CCXAppWiz.vs/CCXAppWiz.uphone/Templates/1033/uphone/resource.h diff --git a/CocosDenshion/android/SimpleAudioEngine.cpp b/CocosDenshion/android/SimpleAudioEngine.cpp index 12bef067c0..8767aa65d2 100644 --- a/CocosDenshion/android/SimpleAudioEngine.cpp +++ b/CocosDenshion/android/SimpleAudioEngine.cpp @@ -63,18 +63,7 @@ namespace CocosDenshion } - void SimpleAudioEngine::setSoundResInfo(const T_SoundResInfo ResInfo[], int nCount) - { - - } - - - void SimpleAudioEngine::setResourceEntry(const void* pResEntry) - { - - } - - void SimpleAudioEngine::preloadBackgroundMusic(const char* pszFilePath) + void SimpleAudioEngine::preloadBackgroundMusic(const char* pszFilePath) { } diff --git a/CocosDenshion/include/SimpleAudioEngine.h b/CocosDenshion/include/SimpleAudioEngine.h index 30c405a1d4..3b027878c6 100644 --- a/CocosDenshion/include/SimpleAudioEngine.h +++ b/CocosDenshion/include/SimpleAudioEngine.h @@ -29,16 +29,6 @@ THE SOFTWARE. namespace CocosDenshion { -/** -@struct T_SoundResInfo -@brief The data type of resource name and resource ID -*/ -typedef struct _tResourceInfo -{ - const char* FileName; - int nResID; -} T_SoundResInfo; - /** @class SimpleAudioEngine @brief offer a VERY simple interface to play background music & sound effect @@ -72,16 +62,6 @@ public: */ static void setResourceZipFile(const char* pszZipPath); - /** - @brief set the sound ResInfo,it's only used on platform-uphone now - */ - void setSoundResInfo(const T_SoundResInfo ResInfo[], int nCount); - - /** - @brief Set the resource entry,it's only used on platform-uphone now - */ - void setResourceEntry(const void* pResEntry); - /** @brief Preload background music @param pszFilePath The path of the background music file,or the FileName of T_SoundResInfo diff --git a/CocosDenshion/iphone/SimpleAudioEngine.mm b/CocosDenshion/iphone/SimpleAudioEngine.mm index e29355f98e..c900243bde 100644 --- a/CocosDenshion/iphone/SimpleAudioEngine.mm +++ b/CocosDenshion/iphone/SimpleAudioEngine.mm @@ -153,20 +153,9 @@ namespace CocosDenshion void SimpleAudioEngine::setResourceZipFile(const char* pszZipPath) { - } - - void SimpleAudioEngine::setSoundResInfo(const T_SoundResInfo ResInfo[], int nCount) - { - - } - - - void SimpleAudioEngine::setResourceEntry(const void* pResEntry) - { - } - void SimpleAudioEngine::preloadBackgroundMusic(const char* pszFilePath) + void SimpleAudioEngine::preloadBackgroundMusic(const char* pszFilePath) { static_preloadBackgroundMusic(pszFilePath); } diff --git a/CocosDenshion/proj.uphone/CocosDenshion.uphone.vcproj b/CocosDenshion/proj.uphone/CocosDenshion.uphone.vcproj index 1217961f07..c2584c1f39 100644 --- a/CocosDenshion/proj.uphone/CocosDenshion.uphone.vcproj +++ b/CocosDenshion/proj.uphone/CocosDenshion.uphone.vcproj @@ -188,14 +188,6 @@ RelativePath="..\uphone\FileUtils.h" > - - - - diff --git a/CocosDenshion/uphone/ResourceHandle.cpp b/CocosDenshion/uphone/ResourceHandle.cpp deleted file mode 100644 index db4958c901..0000000000 --- a/CocosDenshion/uphone/ResourceHandle.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include "ResourceHandle.h" -#include "TG3.h" - -namespace CocosDenshion { - -ResourceHandle::ResourceHandle() -:m_pResLib(NULL) -{ -} - -ResourceHandle::~ResourceHandle() -{ - release(); -} - -void ResourceHandle::release() -{ - if (m_pResLib) - { - delete m_pResLib; - m_pResLib = NULL; - } -} - -void ResourceHandle::setResourceEntry(const void* pResEntry) -{ - release(); - - m_pResLib = new TResourceLib((const AppResourceEntry*)pResEntry); -} - -const void* ResourceHandle::LoadConstRawData(int nResID, unsigned int* nLen) -{ - const void* pResult = NULL; - - if (m_pResLib) - { - pResult = m_pResLib->LoadConstRawData(nResID, nLen); - } - - return pResult; -} - -} // end of namespace CocosDenshion diff --git a/CocosDenshion/uphone/ResourceHandle.h b/CocosDenshion/uphone/ResourceHandle.h deleted file mode 100644 index dfa9b3df54..0000000000 --- a/CocosDenshion/uphone/ResourceHandle.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef _RESOURCE_HANDLE_H_ -#define _RESOURCE_HANDLE_H_ - -struct AppResourceEntry; -class TResourceLib; - -namespace CocosDenshion { - -/** -@class ResourceHandle -@brief Object that contains the ResourceEntry -*/ -class ResourceHandle -{ -public: - ResourceHandle(); - ~ResourceHandle(); - - /** - @brief Set the ResourceEntry - */ - void setResourceEntry(const void* pResEntry); - - /** - @brief Release the ResourceEntry - */ - void release(); - - /** - @brief Load the file data from ResourceEntry - @param[in] nResID The resource id which is generated by TOPS Builder - @param[out] nLen The size of file data. - @return The pointer of file data. - */ - const void* LoadConstRawData(int nResID, unsigned int* nLen); - -private: - TResourceLib* m_pResLib; -}; - -} // end of namespace CocosDenshion - -#endif diff --git a/CocosDenshion/uphone/SimpleAudioEngine.cpp b/CocosDenshion/uphone/SimpleAudioEngine.cpp index 908cf41e44..9c643db152 100644 --- a/CocosDenshion/uphone/SimpleAudioEngine.cpp +++ b/CocosDenshion/uphone/SimpleAudioEngine.cpp @@ -252,16 +252,6 @@ void SimpleAudioEngine::unloadEffect(const char* pszFilePath) s_pDataManager->unloadEffect(pszFilePath); } -void SimpleAudioEngine::setSoundResInfo(const T_SoundResInfo ResInfo[], int nCount) -{ - s_pDataManager->setSoundResInfo(ResInfo, nCount); -} - -void SimpleAudioEngine::setResourceEntry(const void* pResEntry) -{ - s_pDataManager->setResEntry(pResEntry); -} - void SimpleAudioEngine::unloadEffectAll() { s_pDataManager->removeAllEffects(); diff --git a/CocosDenshion/uphone/SoundDataManager.cpp b/CocosDenshion/uphone/SoundDataManager.cpp index a46f756baf..8b82bd4be2 100644 --- a/CocosDenshion/uphone/SoundDataManager.cpp +++ b/CocosDenshion/uphone/SoundDataManager.cpp @@ -9,68 +9,39 @@ namespace CocosDenshion { SoundDataManager::SoundDataManager() : m_pEffects(NULL) { - m_pHRes = new ResourceHandle; - m_pSoundMap = new SoundInfoMap; } SoundDataManager::~SoundDataManager() { removeAllEffects(); - - if (m_pHRes) - { - delete m_pHRes; - m_pHRes = NULL; - } - - if (m_pSoundMap) - { - delete m_pSoundMap; - m_pSoundMap = NULL; - } -} - -void SoundDataManager::setResEntry(const void* pResEntry) -{ - if (pResEntry) - { - m_pHRes->setResourceEntry(pResEntry); - } -} - -void SoundDataManager::setSoundResInfo(const T_SoundResInfo ResInfo[], int nCount) -{ - // first, clear the map before - if (!m_pSoundMap->empty()) - { - m_pSoundMap->clear(); - } - - // second, insert the pairs - for (int i = 0; i < nCount; ++i) - { - std::string name = (ResInfo[i]).FileName; - int nResID = (ResInfo[i]).nResID; - - m_pSoundMap->insert(SoundInfoMap::value_type(name, nResID)); - } } void SoundDataManager::loadSoundData(const char* pszFilePath) { - SoundInfoMap::iterator iter; - iter = m_pSoundMap->find(pszFilePath); + do + { + BREAK_IF(! FileUtils::isFileExisted(pszFilePath)); - if (iter != m_pSoundMap->end()) - { - // if the file is not existed, find in the ResourceInfo - loadFromResourceInfo(pszFilePath); - } - else - { - // load effect info from file - loadFromFile(pszFilePath); - } + // if we have loaded the file before,break + tEffectElement *pElement = NULL; + HASH_FIND_STR(m_pEffects, pszFilePath, pElement); + if (pElement) + { + break; + } + + // load the file data + unsigned long nBufferSize = 0; + unsigned char* buffer = FileUtils::getFileData(pszFilePath, "rb", &nBufferSize); + BREAK_IF(!buffer || nBufferSize <= 0); + + // add the data to hash map + pElement = (tEffectElement*)calloc(sizeof(*pElement), 1); + pElement->pDataBuffer = buffer; + pElement->nDataSize = nBufferSize; + strcpy(pElement->FileName, pszFilePath); + HASH_ADD_STR(m_pEffects, FileName, pElement); + } while (0); } tEffectElement* SoundDataManager::getSoundData(const char* pFileName) @@ -105,66 +76,4 @@ void SoundDataManager::removeAllEffects() } } -void SoundDataManager::loadFromResourceInfo(const char* pFileKey) -{ - SoundInfoMap::iterator iter; - iter = m_pSoundMap->find(pFileKey); - - do - { - BREAK_IF(iter == m_pSoundMap->end()); - - // if we have loaded the file before,break - tEffectElement *pElement = NULL; - HASH_FIND_STR(m_pEffects, pFileKey, pElement); - if (pElement) - { - break; - } - - unsigned int nSize = 0; - const void* pData = m_pHRes->LoadConstRawData(iter->second, &nSize); - BREAK_IF(!pData); - - // copy the data - unsigned char* pSoundData = new unsigned char[nSize]; - MemCopy(pSoundData, pData, nSize); - - // add the data to hash map - pElement = (tEffectElement*)calloc(sizeof(*pElement), 1); - pElement->pDataBuffer = pSoundData; - pElement->nDataSize = nSize; - strcpy(pElement->FileName, pFileKey); - HASH_ADD_STR(m_pEffects, FileName, pElement); - } while (0); -} - -void SoundDataManager::loadFromFile(const char* pFilePath) -{ - do - { - BREAK_IF(! FileUtils::isFileExisted(pFilePath)); - - // if we have loaded the file before,break - tEffectElement *pElement = NULL; - HASH_FIND_STR(m_pEffects, pFilePath, pElement); - if (pElement) - { - break; - } - - // load the file data - unsigned long nBufferSize = 0; - unsigned char* buffer = FileUtils::getFileData(pFilePath, "rb", &nBufferSize); - BREAK_IF(!buffer || nBufferSize <= 0); - - // add the data to hash map - pElement = (tEffectElement*)calloc(sizeof(*pElement), 1); - pElement->pDataBuffer = buffer; - pElement->nDataSize = nBufferSize; - strcpy(pElement->FileName, pFilePath); - HASH_ADD_STR(m_pEffects, FileName, pElement); - } while (0); -} - } // end of namespace CocosDenshion diff --git a/CocosDenshion/uphone/SoundDataManager.h b/CocosDenshion/uphone/SoundDataManager.h index 15015105b8..491a10ba8d 100644 --- a/CocosDenshion/uphone/SoundDataManager.h +++ b/CocosDenshion/uphone/SoundDataManager.h @@ -1,10 +1,8 @@ #ifndef _SOUND_DATA_MANAGER_H_ #define _SOUND_DATA_MANAGER_H_ -#include "ResourceHandle.h" #include #include "uthash.h" -#include "SimpleAudioEngine.h" #include #include "TG3.h" @@ -32,16 +30,6 @@ public: SoundDataManager(); ~SoundDataManager(); - /** - @brief Set the resource entry,it's only used on platform-uphone now - */ - void setResEntry(const void* pResEntry); - - /** - @brief set the sound ResInfo,it's only used on platform-uphone now - */ - void setSoundResInfo(const T_SoundResInfo ResInfo[], int nCount); - /** @brief Load the sound data @param pszFilePath The path of the effect file,or the FileName of T_SoundResInfo @@ -67,17 +55,8 @@ public: void removeAllEffects(); private: - void loadFromResourceInfo(const char* pFileKey); - void loadFromFile(const char* pFilePath); - -private: - ResourceHandle* m_pHRes; - // use hash map to save the effects loaded struct _hashElement * m_pEffects; - - typedef std::map SoundInfoMap; - SoundInfoMap* m_pSoundMap; }; } // end of namespace CocosDenshion diff --git a/CocosDenshion/win32/SimpleAudioEngine.cpp b/CocosDenshion/win32/SimpleAudioEngine.cpp index 27554dd302..65d0f5c331 100644 --- a/CocosDenshion/win32/SimpleAudioEngine.cpp +++ b/CocosDenshion/win32/SimpleAudioEngine.cpp @@ -186,18 +186,6 @@ void SimpleAudioEngine::setEffectsVolume(int volume) { } -////////////////////////////////////////////////////////////////////////// -// resource function -////////////////////////////////////////////////////////////////////////// - -void SimpleAudioEngine::setSoundResInfo(const T_SoundResInfo ResInfo[], int nCount) -{ -} - -void SimpleAudioEngine::setResourceEntry(const void* pResEntry) -{ -} - ////////////////////////////////////////////////////////////////////////// // static function ////////////////////////////////////////////////////////////////////////// diff --git a/HelloWorld/AppDelegate.cpp b/HelloWorld/AppDelegate.cpp index 0475674862..a95ec8a77e 100644 --- a/HelloWorld/AppDelegate.cpp +++ b/HelloWorld/AppDelegate.cpp @@ -46,6 +46,10 @@ bool AppDelegate::applicationDidFinishLaunching() return false; } +#if defined(CCX_PLATFORM_UPHONE) + // set the resource path + CCFileUtils::setResourcePath("/NEWPLUS/TDA_DATA/Data/APPS/cocos2d_helloworld/"); +#endif // init director CCDirector *pDirector = CCDirector::sharedDirector(); diff --git a/HelloWorld/uphone/HelloWorld.uphone.vcproj b/HelloWorld/uphone/HelloWorld.uphone.vcproj index c3b993610e..3a4f44c5cc 100644 --- a/HelloWorld/uphone/HelloWorld.uphone.vcproj +++ b/HelloWorld/uphone/HelloWorld.uphone.vcproj @@ -96,6 +96,7 @@ /> - - diff --git a/HelloWorld/uphone/Res/HelloWorld_Res.ENU.tr3 b/HelloWorld/uphone/Res/HelloWorld_Res.ENU.tr3 index 4bcffe5a9f..af7bd0fc6d 100644 --- a/HelloWorld/uphone/Res/HelloWorld_Res.ENU.tr3 +++ b/HelloWorld/uphone/Res/HelloWorld_Res.ENU.tr3 @@ -1,9 +1,9 @@ // Original file name: HelloWorld_Res.ENU.tr3 -// Generated by TOPS Builder 1.2.3.239 Date:2010-11-26 +// Generated by TOPS Builder 1.2.4.249 Date:2011-1-14 -//$VERSION 60005 +//$VERSION 60006 //$SETTINGS //$Begin //$VCPRJFILE=$002E$002E$005C$0048$0065$006C$006C$006F$0057$006F$0072$006C$0064$002E$0075$0070$0068$006F$006E$0065$002E$0076$0063$0070$0072$006F$006A @@ -16,7 +16,7 @@ PROJECT BEGIN ScreenWidth 320 ScreenHeight 480 - ScreenDPI 165 + ScreenDPI 16500 END @@ -57,18 +57,6 @@ END IMAGEFOLDER ID ResFolder1001 FOLDERNAME $0052$006F$006F$0074$0028$0041$006C$006C$0029 // 文件夹: Root(All) BEGIN - BITMAP ID CloseNormal NOCOMPRESS HasAlphaData TRANSPARENTCOLOR $FFFFFFFF - FileName $002E$002E$005C$002E$002E$005C$0052$0065$0073$006F$0075$0072$0063$0065$005C$0043$006C$006F$0073$0065$004E$006F$0072$006D$0061$006C$002E$0070$006E$0067 - //..\..\Resource\CloseNormal.png - - BITMAP ID CloseSelected NOCOMPRESS HasAlphaData TRANSPARENTCOLOR $FFFFFFFF - FileName $002E$002E$005C$002E$002E$005C$0052$0065$0073$006F$0075$0072$0063$0065$005C$0043$006C$006F$0073$0065$0053$0065$006C$0065$0063$0074$0065$0064$002E$0070$006E$0067 - //..\..\Resource\CloseSelected.png - - BITMAP ID HelloWorld NOCOMPRESS TRANSPARENTCOLOR $FFFFFFFF - FileName $002E$002E$005C$002E$002E$005C$0052$0065$0073$006F$0075$0072$0063$0065$005C$0048$0065$006C$006C$006F$0057$006F$0072$006C$0064$002E$0070$006E$0067 - //..\..\Resource\HelloWorld.png - END // raw data diff --git a/HelloWorld/uphone/Res/HelloWorld_Res.ENU.tr3.tts b/HelloWorld/uphone/Res/HelloWorld_Res.ENU.tr3.tts index 041a5d2ef0..2086b0820d 100644 --- a/HelloWorld/uphone/Res/HelloWorld_Res.ENU.tr3.tts +++ b/HelloWorld/uphone/Res/HelloWorld_Res.ENU.tr3.tts @@ -4,6 +4,6 @@ // update the controls' trnaslation status. // Original file name: HelloWorld_Res.ENU.tr3.tts -// Generated by TOPS Builder 1.2.3.239 Date:2010-11-26 +// Generated by TOPS Builder 1.2.4.249 Date:2011-1-14 diff --git a/HelloWorld/uphone/Res/HelloWorld_Res.TR3 b/HelloWorld/uphone/Res/HelloWorld_Res.TR3 index 4baaa1c589..5f2e16ba33 100644 --- a/HelloWorld/uphone/Res/HelloWorld_Res.TR3 +++ b/HelloWorld/uphone/Res/HelloWorld_Res.TR3 @@ -1,11 +1,11 @@ // Original file name: HelloWorld_Res.TR3 -// Generated by TOPS Builder 1.2.3.239 Date:2010-11-26 +// Generated by TOPS Builder 1.2.4.249 Date:2011-1-14 #include "HelloWorld_Res.h" -//$VERSION 60005 +//$VERSION 60006 //$SETTINGS //$Begin //$VCPRJFILE=$002E$002E$005C$0048$0065$006C$006C$006F$0057$006F$0072$006C$0064$002E$0075$0070$0068$006F$006E$0065$002E$0076$0063$0070$0072$006F$006A @@ -18,7 +18,7 @@ PROJECT BEGIN ScreenWidth 320 ScreenHeight 480 - ScreenDPI 165 + ScreenDPI 16500 END @@ -60,18 +60,6 @@ END IMAGEFOLDER ID ResFolder1001 FOLDERNAME $0052$006F$006F$0074$0028$0041$006C$006C$0029 // 文件夹: Root(All) BEGIN - BITMAP ID CloseNormal NOCOMPRESS HasAlphaData TRANSPARENTCOLOR $FFFFFFFF - FileName $002E$002E$005C$002E$002E$005C$0052$0065$0073$006F$0075$0072$0063$0065$005C$0043$006C$006F$0073$0065$004E$006F$0072$006D$0061$006C$002E$0070$006E$0067 - //..\..\Resource\CloseNormal.png - - BITMAP ID CloseSelected NOCOMPRESS HasAlphaData TRANSPARENTCOLOR $FFFFFFFF - FileName $002E$002E$005C$002E$002E$005C$0052$0065$0073$006F$0075$0072$0063$0065$005C$0043$006C$006F$0073$0065$0053$0065$006C$0065$0063$0074$0065$0064$002E$0070$006E$0067 - //..\..\Resource\CloseSelected.png - - BITMAP ID HelloWorld NOCOMPRESS TRANSPARENTCOLOR $FFFFFFFF - FileName $002E$002E$005C$002E$002E$005C$0052$0065$0073$006F$0075$0072$0063$0065$005C$0048$0065$006C$006C$006F$0057$006F$0072$006C$0064$002E$0070$006E$0067 - //..\..\Resource\HelloWorld.png - END // raw data diff --git a/HelloWorld/uphone/Res/HelloWorld_Res.h b/HelloWorld/uphone/Res/HelloWorld_Res.h index ca8f817513..9573ce1f2b 100644 --- a/HelloWorld/uphone/Res/HelloWorld_Res.h +++ b/HelloWorld/uphone/Res/HelloWorld_Res.h @@ -1,8 +1,5 @@ // Original file name: HelloWorld_Res.h -// Generated by TOPS Builder 1.2.3.239 Date:2010-11-26 +// Generated by TOPS Builder 1.2.4.249 Date:2011-1-14 #define ResFolder1001 1001 #define Form1002 1002 -#define CloseNormal 1003 -#define CloseSelected 1004 -#define HelloWorld 1005 diff --git a/HelloWorld/uphone/Res/HelloWorld_res_c.h b/HelloWorld/uphone/Res/HelloWorld_res_c.h new file mode 100644 index 0000000000..819a696e7a --- /dev/null +++ b/HelloWorld/uphone/Res/HelloWorld_res_c.h @@ -0,0 +1,245 @@ +//------------------------------------------------------------------------------ +// HelloWorld_Res_c.h +// 资源编译器转换文件数据定义文件 +// +// +// Copyright (C) Tranzda CORPORATION +// +//---┤编译器信息├--- +// 编译器名称: TR3C.exe +// 编译器版本: TG3 资源编译器 版本V1.5 Build 94 +// +//---┤注意├--- +// 警告:未经允许,任何人不准擅自修改此文件!!!否则后果自负! +// +//------------------------------------------------------------------------------ +#include "helloworld_res_h.h" //类型定义头文件 +#ifndef WIN32 +//#pragma diag_remark 1296 +#endif +#if 11 setResourceEntry(&TestAudioEngineResourceEntry); - SimpleAudioEngine::sharedEngine()->setSoundResInfo(SoundResInfo, sizeof(SoundResInfo) / sizeof(T_SoundResInfo)); -#else SimpleAudioEngine::setResourcePath("/NEWPLUS/TDA_DATA/Data/APPS/TestAudioEngine/"); - SimpleAudioEngine::setResourceZipFile("/NEWPLUS/TDA_DATA/Data/APPS/TestAudioEngine/TestAudioEngine.zip"); -#endif - SimpleAudioEngine::sharedEngine()->setBackgroundMusicVolume(30); SimpleAudioEngine::sharedEngine()->setEffectsVolume(30); bHandled = TRUE; @@ -99,7 +79,7 @@ Boolean TMainForm::CtrlSelected(TApplication * pApp, EventType * pEvent) { case TESTAU_ID_Form1002_PlayBack: // play background music - pAudioEngine->playBackgroundMusic(SoundResInfo[0].FileName, true); + pAudioEngine->playBackgroundMusic("background.mp3", true); bHandled = TRUE; break; @@ -133,19 +113,19 @@ Boolean TMainForm::CtrlSelected(TApplication * pApp, EventType * pEvent) case TESTAU_ID_Form1002_LoadEffect: // load effect1 - pAudioEngine->preloadEffect(SoundResInfo[1].FileName); + pAudioEngine->preloadEffect("Effect1.wav"); bHandled = TRUE; break; case TESTAU_ID_Form1002_UnLoadBtn: // unload effect1 - pAudioEngine->unloadEffect(SoundResInfo[1].FileName); + pAudioEngine->unloadEffect("Effect1.wav"); bHandled = TRUE; break; case TESTAU_ID_Form1002_PlayEffect: // play effect2 - m_nEffect2ID = pAudioEngine->playEffect(SoundResInfo[2].FileName); + m_nEffect2ID = pAudioEngine->playEffect("Effect2.wav"); /* assert(m_nEffect2ID >= 0);*/ bHandled = TRUE; break; diff --git a/cocos2dx/platform/uphone/CCXFileUtils_uphone.cpp b/cocos2dx/platform/uphone/CCXFileUtils_uphone.cpp index 53c05ec089..4e37fa81ba 100644 --- a/cocos2dx/platform/uphone/CCXFileUtils_uphone.cpp +++ b/cocos2dx/platform/uphone/CCXFileUtils_uphone.cpp @@ -51,10 +51,6 @@ typedef enum SAX_STRING }CCSAXState; -typedef map ResourceMap; -static ResourceMap s_ResMap; -static ResourceHandle s_HRes; - class CCDictMaker { public: @@ -350,36 +346,6 @@ const char* CCFileUtils::getDiffResolutionPath(const char *pszPath) return pRet->m_sString.c_str(); } -void CCFileUtils::setResourceEntry(const AppResourceEntry* pResEntry) -{ - if (pResEntry) - { - s_HRes.setResourceEntry(pResEntry); - } -} - -void CCFileUtils::setResourceInfo(const T_ResourceInfo ResInfo[], int nCount) -{ - // first, clear the map before - if (!s_ResMap.empty()) - { - s_ResMap.clear(); - } - - // second, insert the pairs - for (int i = 0; i < nCount; ++i) - { - /** - @brief Here we call fullPathFromRelativePath because when the UIImage find the ResName in s_ResMap, - the UIImage only have the ResName with fullpath.So we must save the ResName with fullpath. - */ - std::string key = CCFileUtils::fullPathFromRelativePath((ResInfo[i]).ResName); - int nResID = (ResInfo[i]).nResID; - - s_ResMap.insert(ResourceMap::value_type(key, nResID)); - } -} - bool CCFileUtils::isResourceExist(const char* pszResName) { bool bRet = false; @@ -404,11 +370,8 @@ bool CCFileUtils::isResourceExist(const char* pszResName) } else { - // find in the resource map and find in the hardware - ResourceMap::iterator iter; - iter = s_ResMap.find(pszResName); - - if (iter != s_ResMap.end() || EOS_IsFileExist(FilePath)) + // find in the hardware + if (EOS_IsFileExist(FilePath)) { bRet = true; } @@ -445,23 +408,6 @@ unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* psz return pBuffer; } -const TBitmap* CCFileUtils::getBitmapByResName(const char* pszBmpName) -{ - const TBitmap* pBmp = NULL; - - do - { - // load bitmap from TResource - ResourceMap::iterator iter; - iter = s_ResMap.find(pszBmpName); - CCX_BREAK_IF(iter == s_ResMap.end()); - - pBmp = s_HRes.LoadConstBitmap(iter->second); - } while (0); - - return pBmp; -} - int CCFileUtils::ccLoadFileIntoMemory(const char *filename, unsigned char **out) { ///@todo @@ -498,47 +444,4 @@ const char* CCFileUtils::ccRemoveHDSuffixFromFile( const char *path ) return path; } - -////////////////////////////////////////////////// -// -// ResourceHandle -// -////////////////////////////////////////////////// -ResourceHandle::ResourceHandle() -:m_pResLib(NULL) -{ -} - -ResourceHandle::~ResourceHandle() -{ - release(); -} - -void ResourceHandle::release() -{ - if (m_pResLib) - { - delete m_pResLib; - m_pResLib = NULL; - } -} - -void ResourceHandle::setResourceEntry(const AppResourceEntry* pResEntry) -{ - release(); - - m_pResLib = new TResourceLib(pResEntry); -} - -const TBitmap* ResourceHandle::LoadConstBitmap(int nResID) -{ - const TBitmap* pResult = NULL; - - if (m_pResLib) - { - pResult = m_pResLib->LoadConstBitmap(nResID); - } - - return pResult; -} }//namespace cocos2d diff --git a/cocos2dx/platform/uphone/CCXFileUtils_uphone.h b/cocos2dx/platform/uphone/CCXFileUtils_uphone.h index eed2fadcef..5c9e982286 100644 --- a/cocos2dx/platform/uphone/CCXFileUtils_uphone.h +++ b/cocos2dx/platform/uphone/CCXFileUtils_uphone.h @@ -31,31 +31,7 @@ THE SOFTWARE. #include "NSMutableDictionary.h" #include "FileUtils.h" -class TBitmap; -class TResourceLib; -struct AppResourceEntry; - -typedef struct -{ - const char* ResName; - int nResID; -} T_ResourceInfo; - -namespace cocos2d { - -class ResourceHandle -{ -public: - ResourceHandle(); - ~ResourceHandle(); - - void setResourceEntry(const AppResourceEntry* pResEntry); - void release(); - const TBitmap* LoadConstBitmap(int nResID); - -private: - TResourceLib* m_pResLib; -}; +namespace cocos2d { //! @brief Helper class to handle file operations class CCX_DLL CCFileUtils : public FileUtils @@ -91,19 +67,6 @@ public: */ static void setResourcePath(const char *pszResourcePath); - /** - @brief Set the Resource Entry - @param pResEntry The pointer of the Application's ResourceEntry - */ - static void setResourceEntry(const AppResourceEntry* pResEntry); - - /** - @brief Set the Resource Info(ResourceName and ResID) - @param ResInfo Array of T_ResourceInfo,contain all resource names and ids. - @param nCount The count of the array elements. - */ - static void setResourceInfo(const T_ResourceInfo ResInfo[], int nCount); - /** @brief Whether the resource is exist or not.The function find the resource in hardware,if not find,it will find in resource map. @param pszResName The name of resource @@ -111,13 +74,6 @@ public: */ static bool isResourceExist(const char* pszResName); - /** - @brief Get bitmap data from resource map - @param pszBmpName The name of the bitmap - @return If can find the name in resource map, return the pointer of the bitmap.Otherwise return NULL - */ - static const TBitmap* getBitmapByResName(const char* pszBmpName); - /** @brief Set the absolute path of the .zip file which contains all resource files @param pszZipPath The absolute path of the .zip file diff --git a/cocos2dx/platform/uphone/CCXUIImage_uphone.cpp b/cocos2dx/platform/uphone/CCXUIImage_uphone.cpp index b190b783cb..16a2db3f5d 100644 --- a/cocos2dx/platform/uphone/CCXUIImage_uphone.cpp +++ b/cocos2dx/platform/uphone/CCXUIImage_uphone.cpp @@ -120,36 +120,25 @@ bool UIImage::initWithContentsOfFile(const string &strPath, eImageFormat imageTy { bool bRet = false; - // attempt load image from the ResourceMap. - const TBitmap* pBmp = CCFileUtils::getBitmapByResName(strPath.c_str()); - if (pBmp) - { - initWithBitmap(pBmp); - bRet = true; - } - // attempt load image from file - if (!bRet) + FileData data; + unsigned long nSize = 0; + unsigned char* pBuffer = data.getFileData(strPath.c_str(), "rb", &nSize); + if (pBuffer) { - FileData data; - unsigned long nSize = 0; - unsigned char* pBuffer = data.getFileData(strPath.c_str(), "rb", &nSize); - if (pBuffer) + switch (imageType) { - switch (imageType) - { - case kCCImageFormatPNG: - // use libpng load image - bRet = loadPngFromStream(pBuffer, nSize); - break; - case kCCImageFormatJPG: - bRet = loadJpgFromStream(pBuffer, nSize); - break; - default: - // unsupported image type - bRet = false; - break; - } + case kCCImageFormatPNG: + // use libpng load image + bRet = loadPngFromStream(pBuffer, nSize); + break; + case kCCImageFormatJPG: + bRet = loadJpgFromStream(pBuffer, nSize); + break; + default: + // unsupported image type + bRet = false; + break; } } diff --git a/template/CCXAppWiz.vs/CCXAppWiz.uphone/CCXAppWiz.uphone.vcproj b/template/CCXAppWiz.vs/CCXAppWiz.uphone/CCXAppWiz.uphone.vcproj index 08bac362ac..571d660466 100644 --- a/template/CCXAppWiz.vs/CCXAppWiz.uphone/CCXAppWiz.uphone.vcproj +++ b/template/CCXAppWiz.vs/CCXAppWiz.uphone/CCXAppWiz.uphone.vcproj @@ -99,10 +99,6 @@ RelativePath=".\Templates\1033\uphone\NewDeleteOp.cpp" > - - diff --git a/template/CCXAppWiz.vs/CCXAppWiz.uphone/HTML/1033/default.htm b/template/CCXAppWiz.vs/CCXAppWiz.uphone/HTML/1033/default.htm index 21833ae498..15496eb708 100644 --- a/template/CCXAppWiz.vs/CCXAppWiz.uphone/HTML/1033/default.htm +++ b/template/CCXAppWiz.vs/CCXAppWiz.uphone/HTML/1033/default.htm @@ -31,8 +31,7 @@ - - + @@ -212,11 +211,6 @@  Application feature: