mirror of https://github.com/axmolengine/axmol.git
[uphone]fixed #315,remove the way which use resource in ResourceMap.
This commit is contained in:
parent
5fe891408c
commit
acff950860
|
@ -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)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -188,14 +188,6 @@
|
|||
RelativePath="..\uphone\FileUtils.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\uphone\ResourceHandle.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\uphone\ResourceHandle.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\uphone\SimpleAudioEngine.cpp"
|
||||
>
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#ifndef _SOUND_DATA_MANAGER_H_
|
||||
#define _SOUND_DATA_MANAGER_H_
|
||||
|
||||
#include "ResourceHandle.h"
|
||||
#include <map>
|
||||
#include "uthash.h"
|
||||
#include "SimpleAudioEngine.h"
|
||||
#include <string>
|
||||
#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<std::string, int> SoundInfoMap;
|
||||
SoundInfoMap* m_pSoundMap;
|
||||
};
|
||||
|
||||
} // end of namespace CocosDenshion
|
||||
|
|
|
@ -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
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -96,6 +96,7 @@
|
|||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
CommandLine="mkdir D:\Work7\NEWPLUS\TDA_DATA\Data\APPS\cocos2d_helloworld
copy ..\Resource\*.* D:\Work7\NEWPLUS\TDA_DATA\Data\APPS\cocos2d_helloworld"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
|
@ -277,10 +278,6 @@
|
|||
RelativePath=".\NewDeleteOp.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Resource.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\TG3AppDllEntry.cpp"
|
||||
>
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<RES_VERSION
|
||||
#error Resource file version too low!Must be compiled with higher version TR3C.
|
||||
#endif
|
||||
|
||||
|
||||
/************************************************************
|
||||
* Language:CHS
|
||||
*************************************************************/
|
||||
|
||||
|
||||
const ResProjectType HELLOW_project=
|
||||
{
|
||||
320, //screenWidth
|
||||
480, //screenHeight
|
||||
16500, //screenDPI
|
||||
};
|
||||
|
||||
|
||||
/*-------------------------------------------------------------
|
||||
* ID为HELLOW_ID_Form1002窗体的数据
|
||||
------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*"Main"*/
|
||||
const TUChar HELLOW_Form1002TitleStr[]={0x004D,0x0061,0x0069,0x006E,0x0000};
|
||||
|
||||
const ResWindowType HELLOW_Form1002 =
|
||||
{
|
||||
{//资源公共头部定义
|
||||
HELLOW_ID_Form1002,//资源ID
|
||||
RES_CLASS_FORM,//资源类型为FORM(窗体)类型
|
||||
sizeof(ResWindowType),//资源大小
|
||||
-1,//父资源ID(窗体没有故为-1)
|
||||
0,//Tag
|
||||
0//StyleOption
|
||||
},//资源公共头部定义结束
|
||||
{//ControlAttrType属性
|
||||
0,//Enabled,(nouse here)
|
||||
0,//Visibled,(nouse here)
|
||||
0,//Ctl3D,,(nouse here)
|
||||
0,//TabStop,(nouse here)
|
||||
0,//ReadOnly,(nouse here)
|
||||
0,//ImeEnable,(nouse here)
|
||||
0,//WordWrap,(nouse here)
|
||||
0,//TopLeftIsLock,(nouse here)
|
||||
0,//Check,(nouse here)
|
||||
0,//MultiLine,(nouse here)
|
||||
0,//AutoSize,(nouse here)
|
||||
0,//Modal,
|
||||
0,//Numeric ,Field Use
|
||||
0,//AutoShift,Field Use
|
||||
0,//DynamicSize,Field Use
|
||||
0,//UnderLine,Field Use
|
||||
1,//BIClose
|
||||
0,//HasStatusBar
|
||||
0,//BIAction
|
||||
0,//BIMaximize
|
||||
0,//ForceShowTitle
|
||||
0,//Graphical,(nouse here)
|
||||
0,//sbmHasVertical,垂直滚动条
|
||||
0,//sbmHasHorizontal,水平滚动条
|
||||
0,//sbmAuto,滚动条自动出现
|
||||
0,//hasImage
|
||||
0,//hasCheckBox
|
||||
1,//UseSYSDefColor
|
||||
0,//Smooth
|
||||
0,//ShowText
|
||||
1,//TransParent
|
||||
0//OwnerDraw
|
||||
},
|
||||
{//PanelAttr
|
||||
2,//HScrollMode,0-auto,1-enable,2-disable
|
||||
0,//VScrollMode,0-auto,1-enable,2-disable
|
||||
},
|
||||
0X3, // BackColor
|
||||
0X2, // ForeColor
|
||||
{{0, 24}, {320, 456}}, // RectangleType windowBounds
|
||||
0, // 控件个数
|
||||
{//ResWindowExAttrType
|
||||
0,//closeBtnStyle
|
||||
0,//actionBtnStyle
|
||||
1,//DisableSystemStatusBar
|
||||
1,//fullScreen
|
||||
0,//rotateMode
|
||||
},
|
||||
(TUChar *)HELLOW_Form1002TitleStr, //标题文本(在上!)
|
||||
NULL, // 关闭按钮文字(当前为空!)
|
||||
NULL, // action button text = null
|
||||
0, //CharSet
|
||||
stdFont,//Font
|
||||
-1, //MainMenuID(-1为没有主菜单)
|
||||
TG3_WINDOW_MOVIE_MODE_DEFAULT , // 启动动画模式
|
||||
TG3_WINDOW_MOVIE_MODE_DEFAULT , // 关闭动画模式
|
||||
NULL, // 指向控件列表(没有控件,所以为空!)
|
||||
0, // 旋转参考表子项个数
|
||||
NULL // 界面旋转参考表(空)
|
||||
};//窗体HELLOW_Form1002资源数据常量结束
|
||||
const ResourceLangRegisterEntry HELLOW_CHS_Resource[] =
|
||||
{
|
||||
{kProjectRscType,0,(void*)&HELLOW_project,sizeof(HELLOW_project)}
|
||||
,{kWindowRscType,HELLOW_ID_Form1002,(void*)&HELLOW_Form1002,sizeof(HELLOW_Form1002)}
|
||||
};
|
||||
|
||||
const ResourceLangRegisterEntry2 HELLOW_CHS_ResourceEntry =
|
||||
{
|
||||
tgresource_tag,
|
||||
11,//res version
|
||||
0,//subVersionValue
|
||||
0,//reserved1
|
||||
0,//reserved2
|
||||
HELLOW_CHS_Resource
|
||||
};
|
||||
|
||||
|
||||
/************************************************************
|
||||
* Language:ENU
|
||||
*************************************************************/
|
||||
|
||||
|
||||
const ResProjectType HELLOW_ENU_project=
|
||||
{
|
||||
320, //screenWidth
|
||||
480, //screenHeight
|
||||
16500, //screenDPI
|
||||
};
|
||||
|
||||
|
||||
/*-------------------------------------------------------------
|
||||
* ID为HELLOW_ID_Form1002窗体的数据
|
||||
------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*"Main"*/
|
||||
const TUChar HELLOW_ENU_Form1002TitleStr[]={0x004D,0x0061,0x0069,0x006E,0x0000};
|
||||
|
||||
const ResWindowType HELLOW_ENU_Form1002 =
|
||||
{
|
||||
{//资源公共头部定义
|
||||
HELLOW_ID_Form1002,//资源ID
|
||||
RES_CLASS_FORM,//资源类型为FORM(窗体)类型
|
||||
sizeof(ResWindowType),//资源大小
|
||||
-1,//父资源ID(窗体没有故为-1)
|
||||
0,//Tag
|
||||
0//StyleOption
|
||||
},//资源公共头部定义结束
|
||||
{//ControlAttrType属性
|
||||
0,//Enabled,(nouse here)
|
||||
0,//Visibled,(nouse here)
|
||||
0,//Ctl3D,,(nouse here)
|
||||
0,//TabStop,(nouse here)
|
||||
0,//ReadOnly,(nouse here)
|
||||
0,//ImeEnable,(nouse here)
|
||||
0,//WordWrap,(nouse here)
|
||||
0,//TopLeftIsLock,(nouse here)
|
||||
0,//Check,(nouse here)
|
||||
0,//MultiLine,(nouse here)
|
||||
0,//AutoSize,(nouse here)
|
||||
0,//Modal,
|
||||
0,//Numeric ,Field Use
|
||||
0,//AutoShift,Field Use
|
||||
0,//DynamicSize,Field Use
|
||||
0,//UnderLine,Field Use
|
||||
1,//BIClose
|
||||
0,//HasStatusBar
|
||||
0,//BIAction
|
||||
0,//BIMaximize
|
||||
0,//ForceShowTitle
|
||||
0,//Graphical,(nouse here)
|
||||
0,//sbmHasVertical,垂直滚动条
|
||||
0,//sbmHasHorizontal,水平滚动条
|
||||
0,//sbmAuto,滚动条自动出现
|
||||
0,//hasImage
|
||||
0,//hasCheckBox
|
||||
1,//UseSYSDefColor
|
||||
0,//Smooth
|
||||
0,//ShowText
|
||||
1,//TransParent
|
||||
0//OwnerDraw
|
||||
},
|
||||
{//PanelAttr
|
||||
2,//HScrollMode,0-auto,1-enable,2-disable
|
||||
0,//VScrollMode,0-auto,1-enable,2-disable
|
||||
},
|
||||
0X3, // BackColor
|
||||
0X2, // ForeColor
|
||||
{{0, 24}, {320, 456}}, // RectangleType windowBounds
|
||||
0, // 控件个数
|
||||
{//ResWindowExAttrType
|
||||
0,//closeBtnStyle
|
||||
0,//actionBtnStyle
|
||||
0,//DisableSystemStatusBar
|
||||
1,//fullScreen
|
||||
0,//rotateMode
|
||||
},
|
||||
(TUChar *)HELLOW_ENU_Form1002TitleStr, //标题文本(在上!)
|
||||
NULL, // 关闭按钮文字(当前为空!)
|
||||
NULL, // action button text = null
|
||||
0, //CharSet
|
||||
stdFont,//Font
|
||||
-1, //MainMenuID(-1为没有主菜单)
|
||||
TG3_WINDOW_MOVIE_MODE_DEFAULT , // 启动动画模式
|
||||
TG3_WINDOW_MOVIE_MODE_DEFAULT , // 关闭动画模式
|
||||
NULL, // 指向控件列表(没有控件,所以为空!)
|
||||
0, // 旋转参考表子项个数
|
||||
NULL // 界面旋转参考表(空)
|
||||
};//窗体HELLOW_ENU_Form1002资源数据常量结束
|
||||
const ResourceLangRegisterEntry HELLOW_ENU_Resource[] =
|
||||
{
|
||||
{kProjectRscType,0,(void*)&HELLOW_ENU_project,sizeof(HELLOW_ENU_project)}
|
||||
,{kWindowRscType,HELLOW_ID_Form1002,(void*)&HELLOW_ENU_Form1002,sizeof(HELLOW_ENU_Form1002)}
|
||||
};
|
||||
|
||||
const ResourceLangRegisterEntry2 HELLOW_ENU_ResourceEntry =
|
||||
{
|
||||
tgresource_tag,
|
||||
11,//res version
|
||||
0,//subVersionValue
|
||||
0,//reserved1
|
||||
0,//reserved2
|
||||
HELLOW_ENU_Resource
|
||||
};
|
||||
|
||||
//资源定义
|
||||
#define TG_RESOURCE_DEFINE \
|
||||
{SYS_LANGUAGE_CHS,sizeof( HELLOW_CHS_Resource )/ sizeof(ResourceLangRegisterEntry), &HELLOW_CHS_ResourceEntry}, \
|
||||
{SYS_LANGUAGE_ENU,sizeof( HELLOW_ENU_Resource )/ sizeof(ResourceLangRegisterEntry), &HELLOW_ENU_ResourceEntry},
|
|
@ -1 +0,0 @@
|
|||
6caa77edabcea33d4fd038849d191fc0d9ea49a1
|
|
@ -7,7 +7,7 @@
|
|||
//
|
||||
//---┤编译器信息├---
|
||||
// 编译器名称: TR3C.exe
|
||||
// 编译器版本: TG3 资源编译器 版本V1.5 Build 92
|
||||
// 编译器版本: TG3 资源编译器 版本V1.5 Build 94
|
||||
//
|
||||
//---┤注意├---
|
||||
// 警告:未经允许,任何人不准擅自修改此文件!!!否则后果自负!
|
||||
|
@ -18,7 +18,4 @@
|
|||
|
||||
#define HELLOW_ID_Form1002 1073742826 /*"Main"*/
|
||||
|
||||
#define HELLOW_ID_BITMAP_CloseNormal 1073742827
|
||||
#define HELLOW_ID_BITMAP_CloseSelected 1073742828
|
||||
#define HELLOW_ID_BITMAP_HelloWorld 1073742829
|
||||
#endif
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
//
|
||||
//---┤编译器信息├---
|
||||
// 编译器名称: TR3C.exe
|
||||
// 编译器版本: TG3 资源编译器 版本V1.5 Build 92
|
||||
// 编译器版本: TG3 资源编译器 版本V1.5 Build 94
|
||||
//
|
||||
//---┤注意├---
|
||||
// 警告:未经允许,任何人不准擅自修改此文件!!!否则后果自负!
|
||||
|
@ -19,10 +19,5 @@
|
|||
#include "ResTypes.h"
|
||||
|
||||
#include "helloworld_res_def.h"
|
||||
//----------------资源声明(外部可直接使用)-------------
|
||||
extern const BitmapType HELLOW_Bitmap_CloseNormal;
|
||||
extern const BitmapType HELLOW_Bitmap_CloseSelected;
|
||||
extern const BitmapType HELLOW_Bitmap_HelloWorld;
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
#ifndef _RESOURCE_H_
|
||||
#define _RESOURCE_H_
|
||||
|
||||
#include "helloworld_res_def.h"
|
||||
#include "cocos2d.h"
|
||||
|
||||
const T_ResourceInfo ResInfo[] =
|
||||
{
|
||||
{ "HelloWorld.png", HELLOW_ID_BITMAP_HelloWorld },
|
||||
{ "CloseNormal.png", HELLOW_ID_BITMAP_CloseNormal },
|
||||
{ "CloseSelected.png", HELLOW_ID_BITMAP_CloseSelected },
|
||||
};
|
||||
|
||||
#endif
|
|
@ -9,17 +9,13 @@
|
|||
|
||||
// cocos2d
|
||||
#include "AppDelegate.h"
|
||||
#include "cocos2d.h"
|
||||
|
||||
// cocos2d-uphone
|
||||
#include "Resource.h"
|
||||
|
||||
const ResourceRegisterEntry ResRegList_HelloWorld[] =
|
||||
{
|
||||
TG_RESOURCE_DEFINE
|
||||
};
|
||||
|
||||
extern const AppResourceEntry HelloWorldResourceEntry =
|
||||
const AppResourceEntry HelloWorldResourceEntry =
|
||||
{
|
||||
(ResourceRegisterEntry*)ResRegList_HelloWorld, // res list in this app
|
||||
sizeof(ResRegList_HelloWorld) / sizeof(ResourceRegisterEntry), //number of item in res
|
||||
|
@ -28,13 +24,7 @@ extern const AppResourceEntry HelloWorldResourceEntry =
|
|||
|
||||
Int32 TG3AppMain(const TUChar * pAppID, UInt32 nCmd, void * pCmdParam)
|
||||
{
|
||||
// set the ResourceEntry
|
||||
cocos2d::CCFileUtils::setResourceEntry(&HelloWorldResourceEntry);
|
||||
// set the Images ResInfo (name and ResID)
|
||||
cocos2d::CCFileUtils::setResourceInfo(ResInfo, sizeof(ResInfo) / sizeof(T_ResourceInfo));
|
||||
|
||||
AppDelegate app;
|
||||
app.WM_SetResourceEntry(&HelloWorldResourceEntry);
|
||||
app.Run();
|
||||
|
||||
return 1;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
// Original file name: TestAudioEngine_Res.ENU.tr3
|
||||
// Generated by TOPS Builder 1.2.3.246 Date:2011-1-11
|
||||
// Generated by TOPS Builder 1.2.4.249 Date:2011-1-14
|
||||
|
||||
|
||||
//$VERSION 60006
|
||||
|
@ -16,7 +16,7 @@ PROJECT
|
|||
BEGIN
|
||||
ScreenWidth 320
|
||||
ScreenHeight 480
|
||||
ScreenDPI 165
|
||||
ScreenDPI 16500
|
||||
END
|
||||
|
||||
|
||||
|
@ -211,14 +211,5 @@ BEGIN
|
|||
END
|
||||
// raw data
|
||||
|
||||
RAWDATA ID background FileName $0073$006F$0075$006E$0064$0073$005C$0062$0061$0063$006B$0067$0072$006F$0075$006E$0064$002E$006D$0070$0033
|
||||
//sounds\background.mp3
|
||||
|
||||
RAWDATA ID Effect1 FileName $0073$006F$0075$006E$0064$0073$005C$0045$0066$0066$0065$0063$0074$0031$002E$0077$0061$0076
|
||||
//sounds\Effect1.wav
|
||||
|
||||
RAWDATA ID Effect2 FileName $0073$006F$0075$006E$0064$0073$005C$0045$0066$0066$0065$0063$0074$0032$002E$0077$0061$0076
|
||||
//sounds\Effect2.wav
|
||||
|
||||
// Application
|
||||
|
||||
|
|
|
@ -4,6 +4,6 @@
|
|||
// update the controls' trnaslation status.
|
||||
|
||||
// Original file name: TestAudioEngine_Res.ENU.tr3.tts
|
||||
// Generated by TOPS Builder 1.2.3.246 Date:2011-1-11
|
||||
// Generated by TOPS Builder 1.2.4.249 Date:2011-1-14
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
// Original file name: TestAudioEngine_Res.TR3
|
||||
// Generated by TOPS Builder 1.2.3.246 Date:2011-1-11
|
||||
// Generated by TOPS Builder 1.2.4.249 Date:2011-1-14
|
||||
|
||||
|
||||
#include "TestAudioEngine_Res.h"
|
||||
|
@ -18,7 +18,7 @@ PROJECT
|
|||
BEGIN
|
||||
ScreenWidth 320
|
||||
ScreenHeight 480
|
||||
ScreenDPI 165
|
||||
ScreenDPI 16500
|
||||
END
|
||||
|
||||
|
||||
|
@ -213,14 +213,5 @@ BEGIN
|
|||
END
|
||||
// raw data
|
||||
|
||||
RAWDATA ID background FileName $0073$006F$0075$006E$0064$0073$005C$0062$0061$0063$006B$0067$0072$006F$0075$006E$0064$002E$006D$0070$0033
|
||||
//sounds\background.mp3
|
||||
|
||||
RAWDATA ID Effect1 FileName $0073$006F$0075$006E$0064$0073$005C$0045$0066$0066$0065$0063$0074$0031$002E$0077$0061$0076
|
||||
//sounds\Effect1.wav
|
||||
|
||||
RAWDATA ID Effect2 FileName $0073$006F$0075$006E$0064$0073$005C$0045$0066$0066$0065$0063$0074$0032$002E$0077$0061$0076
|
||||
//sounds\Effect2.wav
|
||||
|
||||
// Application
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Original file name: TestAudioEngine_Res.h
|
||||
// Generated by TOPS Builder 1.2.3.246 Date:2011-1-11
|
||||
// Generated by TOPS Builder 1.2.4.249 Date:2011-1-14
|
||||
|
||||
#define ResFolder1001 1001
|
||||
#define Form1002 1002
|
||||
|
@ -8,9 +8,6 @@
|
|||
#define LoadEffect 1005
|
||||
#define PlayEffect 1007
|
||||
#define UnLoadBtn 1008
|
||||
#define background 1009
|
||||
#define Effect1 1010
|
||||
#define Effect2 1011
|
||||
#define PauseBack 1012
|
||||
#define BackVolumeUp 1013
|
||||
#define BackVolumeDown 1014
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1 +0,0 @@
|
|||
6bcf03d4775aa81a096afe3d42c6609513a7ecfe
|
|
@ -38,7 +38,4 @@
|
|||
|
||||
#define TESTAU_ID_Form1002_EffectVolumeDown 1073742840/*"EffectVolumeDown"*/
|
||||
|
||||
#define TESTAU_ID_RAWDATA_background 1073742833
|
||||
#define TESTAU_ID_RAWDATA_Effect1 1073742834
|
||||
#define TESTAU_ID_RAWDATA_Effect2 1073742835
|
||||
#endif
|
||||
|
|
|
@ -96,7 +96,7 @@
|
|||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
CommandLine=""
|
||||
CommandLine="mkdir D:\Work7\NEWPLUS\TDA_DATA\Data\APPS\TestAudioEngine
copy .\Res\sounds\*.* D:\Work7\NEWPLUS\TDA_DATA\Data\APPS\TestAudioEngine"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
|
|
|
@ -14,7 +14,7 @@ const ResourceRegisterEntry ResRegList_TestAudioEngine[] =
|
|||
TG_RESOURCE_DEFINE
|
||||
};
|
||||
|
||||
extern const AppResourceEntry TestAudioEngineResourceEntry =
|
||||
const AppResourceEntry TestAudioEngineResourceEntry =
|
||||
{
|
||||
(ResourceRegisterEntry*)ResRegList_TestAudioEngine, // res list in this app
|
||||
sizeof(ResRegList_TestAudioEngine) / sizeof(ResourceRegisterEntry), //number of item in res
|
||||
|
|
|
@ -13,19 +13,6 @@
|
|||
|
||||
using namespace CocosDenshion;
|
||||
|
||||
extern const AppResourceEntry TestAudioEngineResourceEntry;
|
||||
|
||||
/**
|
||||
@warning 在声音数据信息的结构体中,FileName必须包含文件的扩展名,并且需要与原始文件的扩展名一致
|
||||
否则无法播。另:音效文件只支持 wav 格式。
|
||||
*/
|
||||
const T_SoundResInfo SoundResInfo[] =
|
||||
{
|
||||
{ "background.mp3", TESTAU_ID_RAWDATA_background },
|
||||
{ "Effect1.wav", TESTAU_ID_RAWDATA_Effect1 },
|
||||
{ "Effect2.wav", TESTAU_ID_RAWDATA_Effect2 },
|
||||
};
|
||||
|
||||
TMainForm::TMainForm(TApplication * pApp):TWindow(pApp)
|
||||
, m_nEffect2ID(0)
|
||||
{
|
||||
|
@ -45,14 +32,7 @@ Boolean TMainForm::EventHandler(TApplication * pApp, EventType * pEvent)
|
|||
{
|
||||
case EVENT_WinInit:
|
||||
{
|
||||
#if 1
|
||||
SimpleAudioEngine::sharedEngine()->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;
|
||||
|
|
|
@ -51,10 +51,6 @@ typedef enum
|
|||
SAX_STRING
|
||||
}CCSAXState;
|
||||
|
||||
typedef map<std::string, int> 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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -99,10 +99,6 @@
|
|||
RelativePath=".\Templates\1033\uphone\NewDeleteOp.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Templates\1033\uphone\Resource.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Templates\1033\uphone\rootUnicodeScript.h"
|
||||
>
|
||||
|
|
|
@ -31,8 +31,7 @@
|
|||
<SYMBOL NAME='CCX_USE_BOX2D' TYPE="checkbox" VALUE="true"></SYMBOL>
|
||||
<SYMBOL NAME='CCX_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE' TYPE="checkbox" VALUE="false"></SYMBOL>
|
||||
<SYMBOL NAME='CCX_HAS_MAIN_FORM' TYPE="checkbox" VALUE="true"></SYMBOL>
|
||||
|
||||
<SYMBOL NAME='CCX_USE_UI_RESOURCE' TYPE="checkbox" VALUE="false"></SYMBOL>
|
||||
|
||||
<SYMBOL NAME='CCX_USE_TCOM_SUPPORT' TYPE="checkbox" VALUE="false"></SYMBOL>
|
||||
|
||||
<!-- Page 3 Controls -->
|
||||
|
@ -212,11 +211,6 @@
|
|||
|
||||
</UL>
|
||||
</SPAN> Application feature:<UL>
|
||||
<LI CLASS="LIST">
|
||||
<SPAN CLASS="SideBtnHidden" ID="CCX_UI_RESOURCE_SUMMARY" TITLE="">
|
||||
<LABEL FOR="CCX_UI_RESOURCE_SUMMARY"></LABEL>
|
||||
</SPAN>
|
||||
</LI>
|
||||
|
||||
<LI CLASS="LIST">
|
||||
<SPAN CLASS="SideBtnHidden" ID="CCX_TCOM_SUPPORT_SUMMARY" TITLE="">
|
||||
|
@ -379,15 +373,6 @@ function OnInit()
|
|||
CCX_AUDIO_ENGINE_SUMMARY.innerText = "None Audio Engine";
|
||||
}
|
||||
|
||||
if (window.external.FindSymbol("CCX_USE_UI_RESOURCE"))
|
||||
{
|
||||
CCX_UI_RESOURCE_SUMMARY.innerText = "Has UI Resource";
|
||||
}
|
||||
else
|
||||
{
|
||||
CCX_UI_RESOURCE_SUMMARY.innerText = "None UI Resource";
|
||||
}
|
||||
|
||||
if (window.external.FindSymbol("CCX_USE_TCOM_SUPPORT"))
|
||||
{
|
||||
CCX_TCOM_SUPPORT_SUMMARY.innerText = "Has TCOM Support";
|
||||
|
|
|
@ -232,15 +232,7 @@
|
|||
</TD>
|
||||
<TD VALIGN="top" COLSPAN="7">
|
||||
Select application feature:<br />
|
||||
<br />
|
||||
<input id="CCX_USE_UI_RESOURCE" accesskey="U" class="CheckBoxA"
|
||||
name="CCX_USE_UI_RESOURCE" title="Application has UI resource project."
|
||||
type="checkbox" value="ON" onClick="OnUseUIResource();"/>
|
||||
<DIV CLASS="itemTextCheckboxB" ID="CCX_USE_UI_RESOURCE_DIV" FOR ="CCX_USE_UI_RESOURCE">
|
||||
<LABEL ID="CCX_USE_UI_RESOURCE_LABLE" TITLE="Add UPhone resource files to project.">
|
||||
<U>U</U>I Resource</LABEL>
|
||||
</DIV>
|
||||
<br />
|
||||
<br />
|
||||
<input id="CCX_USE_TCOM_SUPPORT" accesskey="T" class="CheckBoxA"
|
||||
name="CCX_USE_TCOM_SUPPORT" title="Application has TCOM support."
|
||||
type="checkbox" value="ON" onClick="OnUseTCOMSupport();"/>
|
||||
|
@ -376,14 +368,7 @@ function OnInit()
|
|||
{
|
||||
CCX_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE.checked = true;
|
||||
}
|
||||
|
||||
CCX_USE_UI_RESOURCE.disabled = false;
|
||||
CCX_USE_TCOM_SUPPORT.disabled = false;
|
||||
|
||||
if (window.external.FindSymbol("CCX_USE_UI_RESOURCE"))
|
||||
{
|
||||
CCX_USE_UI_RESOURCE.checked = true;
|
||||
}
|
||||
if (window.external.FindSymbol("CCX_USE_TCOM_SUPPORT"))
|
||||
{
|
||||
CCX_USE_TCOM_SUPPORT.checked = true;
|
||||
|
@ -415,18 +400,6 @@ function OnUseChipmunk()
|
|||
}
|
||||
}
|
||||
|
||||
function OnUseUIResource()
|
||||
{
|
||||
if (CCX_USE_UI_RESOURCE.checked)
|
||||
{
|
||||
window.external.AddSymbol("CCX_USE_UI_RESOURCE", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
window.external.AddSymbol("CCX_USE_UI_RESOURCE", false);
|
||||
}
|
||||
}
|
||||
|
||||
function OnUseTCOMSupport()
|
||||
{
|
||||
if (CCX_USE_TCOM_SUPPORT.checked)
|
||||
|
|
|
@ -127,12 +127,6 @@ function AddFilters(proj) {
|
|||
group = proj.Object.AddFilter('include');
|
||||
group.Filter = strSrcFilter;
|
||||
|
||||
if (wizard.FindSymbol('CCX_USE_UI_RESOURCE')) {
|
||||
strSrcFilter = wizard.FindSymbol('RESOURCE_FILTER');
|
||||
group = proj.Object.AddFilter('resource');
|
||||
group.Filter = strSrcFilter;
|
||||
}
|
||||
|
||||
strSrcFilter = wizard.FindSymbol('MAKEFILE_FILTER');
|
||||
group = proj.Object.AddFilter('makefile');
|
||||
group.Filter = strSrcFilter;
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
|
||||
[! endif]
|
||||
#include "HelloWorldScene.h"
|
||||
[! if CCX_USE_UI_RESOURCE]
|
||||
|
||||
#include "Resource.h"
|
||||
[! endif]
|
||||
|
||||
using namespace cocos2d;
|
||||
|
||||
[! if CCX_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE]
|
||||
using namespace CocosDenshion;
|
||||
[! endif]
|
||||
|
||||
AppDelegate::AppDelegate()
|
||||
:m_pMainWnd(NULL)
|
||||
{
|
||||
|
@ -21,7 +21,7 @@ AppDelegate::AppDelegate()
|
|||
AppDelegate::~AppDelegate()
|
||||
{
|
||||
[! if CCX_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE]
|
||||
SimpleAudioEngine::release();
|
||||
SimpleAudioEngine::end();
|
||||
[! endif]
|
||||
}
|
||||
|
||||
|
@ -44,15 +44,6 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
|
||||
// set the resource path
|
||||
CCFileUtils::setResourcePath("/NEWPLUS/TDA_DATA/Data/[!output PROJECT_NAME]/");
|
||||
[! if CCX_USE_UI_RESOURCE]
|
||||
|
||||
// cocos2d find image in ResourceEntry first, in ResourcePath second.
|
||||
// set the ResourceEntry,
|
||||
CCFileUtils::setResourceEntry(&[!output PROJECT_NAME]ResourceEntry);
|
||||
|
||||
// set the Images ResInfo (name and ResID)
|
||||
CCFileUtils::setResourceInfo(ResInfo, sizeof(ResInfo) / sizeof(T_ResourceInfo));
|
||||
[! endif]
|
||||
|
||||
CCScene * pScene = HelloWorld::scene();
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#include "HelloWorldScene.h"
|
||||
|
||||
#include "Resource.h"
|
||||
|
||||
using namespace cocos2d;
|
||||
|
||||
CCScene* HelloWorld::scene()
|
||||
|
@ -35,8 +33,8 @@ bool HelloWorld::init()
|
|||
|
||||
// add a "close" icon to exit the progress. it's an autorelease object
|
||||
CCMenuItemImage *pCloseItem = CCMenuItemImage::itemFromNormalImage(
|
||||
(ResInfo[0]).ResName,
|
||||
(ResInfo[1]).ResName,
|
||||
"CloseNormal.png",
|
||||
"CloseSelected.png",
|
||||
this,
|
||||
menu_selector(HelloWorld::menuCloseCallback) );
|
||||
pCloseItem->setPosition( ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20) );
|
||||
|
@ -50,7 +48,7 @@ bool HelloWorld::init()
|
|||
// 3. add your codes below...
|
||||
// add a label shows "Hello World"
|
||||
// create and initialize a label
|
||||
CCLabel* pLabel = CCLabel::labelWithString("HelloWorld", "Thonburi", 64);
|
||||
CCLabelTTF* pLabel = CCLabelTTF::labelWithString("HelloWorld", "Thonburi", 64);
|
||||
|
||||
// ask director the window size
|
||||
CGSize size = CCDirector::sharedDirector()->getWinSize();
|
||||
|
|
|
@ -11,17 +11,6 @@ uphone/resource.h
|
|||
uphone/rootUnicodeScript.h
|
||||
uphone/rootUnicodeScript_str.h
|
||||
|
||||
[! if CCX_USE_UI_RESOURCE]
|
||||
uphone/Res/root_Res.ENU.tr3
|
||||
uphone/Res/root_Res.ENU.tr3.tts
|
||||
uphone/Res/root_Res.h
|
||||
uphone/Res/root_Res.TR3
|
||||
uphone/Res/root_Res.TRG
|
||||
uphone/Res/root_res_c.h
|
||||
uphone/Res/root_res_def.h
|
||||
uphone/Res/root_res_h.h
|
||||
[! endif]
|
||||
|
||||
[! if CCX_USE_TCOM_SUPPORT]
|
||||
uphone/TCOM/root_TcomRegist.cpp
|
||||
[! endif]
|
||||
|
|
|
@ -1,26 +1,8 @@
|
|||
#include "AppDelegate.h"
|
||||
|
||||
[! if CCX_USE_UI_RESOURCE]
|
||||
#include "[!output PROJECT_NAME_LOWER]_res_c.h"
|
||||
|
||||
const ResourceRegisterEntry ResRegList_[!output PROJECT_NAME][] =
|
||||
{
|
||||
TG_RESOURCE_DEFINE
|
||||
};
|
||||
|
||||
extern const AppResourceEntry [!output PROJECT_NAME]ResourceEntry =
|
||||
{
|
||||
(ResourceRegisterEntry*)ResRegList_[!output PROJECT_NAME], // res list in this app
|
||||
sizeof(ResRegList_[!output PROJECT_NAME]) / sizeof(ResourceRegisterEntry), //number of item in res
|
||||
};
|
||||
|
||||
[! endif]
|
||||
Int32 TG3AppMain(const TUChar * pAppID, UInt32 nCmd, void * pCmdParam)
|
||||
{
|
||||
AppDelegate app;
|
||||
[! if CCX_USE_UI_RESOURCE]
|
||||
app.WM_SetResourceEntry(&[!output PROJECT_NAME]ResourceEntry);
|
||||
[! endif]
|
||||
app.Run();
|
||||
|
||||
return 1;
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
#ifndef __RESOURCE_H__
|
||||
#define __RESOURCE_H__
|
||||
|
||||
#include "[!output PROJECT_NAME]UnicodeScript_str.h";
|
||||
[! if CCX_USE_UI_RESOURCE]
|
||||
|
||||
#include "[!output PROJECT_NAME_LOWER]_res_def.h"
|
||||
extern const AppResourceEntry [!output PROJECT_NAME]ResourceEntry;
|
||||
[! endif]
|
||||
|
||||
#include "cocos2d.h"
|
||||
|
||||
const T_ResourceInfo ResInfo[] =
|
||||
{
|
||||
{ "CloseNormal.png", [! if CCX_USE_UI_RESOURCE][!output PRO_NAME_PREFIX]_ID_BITMAP_CloseNormal[! else]0[! endif] },
|
||||
{ "CloseSelected.png", [! if CCX_USE_UI_RESOURCE][!output PRO_NAME_PREFIX]_ID_BITMAP_CloseSelected[! else]0[! endif] },
|
||||
};
|
||||
|
||||
#endif // __RESOURCE_H__
|
Loading…
Reference in New Issue