diff --git a/HelloWorld/AppDelegate.cpp b/HelloWorld/AppDelegate.cpp index c130608c93ae..73de86ad4884 100644 --- a/HelloWorld/AppDelegate.cpp +++ b/HelloWorld/AppDelegate.cpp @@ -29,6 +29,20 @@ bool AppDelegate::initInstance() #endif // CCX_PLATFORM_WIN32 +#if (CCX_TARGET_PLATFORM == CCX_PLATFORM_UPHONE) + + // Initialize OpenGLView instance, that release by CCDirector when application terminate. + // The HelloWorld is designed as HVGA. + CCXEGLView* pMainWnd = new CCXEGLView(this); + CCX_BREAK_IF(! pMainWnd || ! pMainWnd->Create(320,480)); + +#ifndef _TRANZDA_VM_ + // on uphone emulator, we copy resources files to Work7/TG3/APP/ folder instead of zip file + cocos2d::CCFileUtils::setResource("HelloWorld.zip"); +#endif + +#endif // CCX_PLATFORM_UPHONE + bRet = true; } while (0); return bRet; diff --git a/HelloWorld/uphone/Application.h b/HelloWorld/uphone/Application.h deleted file mode 100644 index 83b9b39bbed4..000000000000 --- a/HelloWorld/uphone/Application.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef __COCOS2D_HELLOWORLD_APP_H__ -#define __COCOS2D_HELLOWORLD_APP_H__ -#include "TG3.h" -#include "cocos2d.h" -#include "AppDelegate.h" - -class Application : public TApplication, public cocos2d::ccxApplication -{ -public: - Application(); - virtual ~Application(); - - virtual Boolean EventHandler(EventType * pEvent); - -public: - // implement the virtual interface of class ccxApplication - virtual bool initInstance(); - virtual void setAnimationInterval(double interval); - virtual Orientation setOrientation(Orientation orientation); - virtual void statusBarFrame(cocos2d::CGRect * rect); - virtual const char* getAppDataPath(); - virtual void switchNotify(int nTurnOn); - -protected: - bool isInBackground(); - void StartMainLoop(); - void StopMainLoop(); - -private: - static Int32 _OnAppIdle(MESSAGE_t * pMsg, UInt32 uData); - - MESSAGE_t m_tMsg; - bool m_bRunning; - bool m_bNeedStop; - bool m_bInBackground; - char m_AppDataPath[EOS_FILE_MAX_PATH]; - AppDelegate m_Delegate; -}; - - -#endif diff --git a/HelloWorld/uphone/HelloWorld.TMK3 b/HelloWorld/uphone/HelloWorld.TMK3 index c88a89e74b90..19587f1368c9 100644 --- a/HelloWorld/uphone/HelloWorld.TMK3 +++ b/HelloWorld/uphone/HelloWorld.TMK3 @@ -34,10 +34,10 @@ DEFINES=-DCCX_UNDER_UPHONE ; ;DEFINES=-D__TCOM_SUPPORT__ ;生成的是TCOM组件(注意:TOPS应用也可以同时是TCOM组件) ;包含路径,可以使用多个INCLUDE_PATH串,也可以使用INCLUDE_PATH1、INCLUDE_PATH2等方式,MakeFile中依据出现顺序(不是数字大小)排列 -INCLUDE_PATH=-I./Res -I../ -I../uphone -I../cocos2dx -I../cocos2dx/include ;应用额外的包含路径。注意:ITOPS自己的所有路径都会自动包含,故此这里仅仅包含应用自己特有的路径即可 +INCLUDE_PATH=-I./Res -I../ -I../uphone -I../cocos2dx -I../cocos2dx/include -I../platform_support/include ;应用额外的包含路径。注意:ITOPS自己的所有路径都会自动包含,故此这里仅仅包含应用自己特有的路径即可 ;连接的库文件,可以使用多个LIBS串,也可以使用LIBS1、LIBS2等方式,MakeFile中依据出现顺序(不是数字大小)排列 -LIBS=-lCocos2dStatic -lTG3_GLESv1_CM -lTG3_EGL -lz -lxml2 -lpng14 -lImageToolKit -ljpeg ;应用额外的连接库。注意:ITOPS自己的所需库自动包含,而且库包含路径也已经包含,故此这里仅仅包含应用自己特有的库的名字即可 +LIBS=-lCocos2dStatic -lPlatformSupportStatic -lTG3_GLESv1_CM -lTG3_EGL -lz -lxml2 -lpng14 -lImageToolKit -ljpeg ;应用额外的连接库。注意:ITOPS自己的所需库自动包含,而且库包含路径也已经包含,故此这里仅仅包含应用自己特有的库的名字即可 ;强制包含文件的名字,不能使用通配符,一定要使用相对或者绝对路径 ;极力要求使用相对路径,多个文件之间使用“|”分隔 @@ -50,4 +50,7 @@ INCLUDEFILE= ;只能对.c、.cpp文件进行排除 ;如果要排除本目录的文件也要加入"./" ;可以使用多个EXCLUDEFILE串,也可以使用EXCLUDEFILE1、EXCLUDEFILE2等方式,MakeFile中依据出现顺序(不是数字大小)排列 -EXCLUDEFILE= +EXCLUDEFILE=./android +EXCLUDEFILE=./iphone +EXCLUDEFILE=./win32 +EXCLUDEFILE=./uphone/NewDeleteOp.cpp diff --git a/HelloWorld/uphone/HelloWorld.uphone.vcproj b/HelloWorld/uphone/HelloWorld.uphone.vcproj index 03b3df55ce62..050ba87cc181 100644 --- a/HelloWorld/uphone/HelloWorld.uphone.vcproj +++ b/HelloWorld/uphone/HelloWorld.uphone.vcproj @@ -201,42 +201,6 @@ > - - - - - - - - - - - - - - - - - - @@ -252,14 +216,6 @@ - - - - diff --git a/HelloWorld/uphone/Makefile.ARM b/HelloWorld/uphone/Makefile.ARM index 1747c0c72aa3..19bfe88db401 100644 --- a/HelloWorld/uphone/Makefile.ARM +++ b/HelloWorld/uphone/Makefile.ARM @@ -32,7 +32,6 @@ first: all OBJECTS = \ $(OBJECTS_DIR)/AppDelegate.o \ - $(OBJECTS_DIR)/Application.o \ $(OBJECTS_DIR)/HelloWorldScene.o \ $(OBJECTS_DIR)/main.o \ $(OBJECTS_DIR)/TG3AppDllEntry.o @@ -57,9 +56,6 @@ clean : $(OBJECTS_DIR)/AppDelegate.o : ../AppDelegate.cpp $(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/AppDelegate.o ../AppDelegate.cpp -$(OBJECTS_DIR)/Application.o : ./Application.cpp - $(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/Application.o ./Application.cpp - $(OBJECTS_DIR)/HelloWorldScene.o : ../HelloWorldScene.cpp $(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/HelloWorldScene.o ../HelloWorldScene.cpp diff --git a/HelloWorld/uphone/Res/HelloWorld_Res.ENU.tr3 b/HelloWorld/uphone/Res/HelloWorld_Res.ENU.tr3 deleted file mode 100644 index af7bd0fc6dfd..000000000000 --- a/HelloWorld/uphone/Res/HelloWorld_Res.ENU.tr3 +++ /dev/null @@ -1,64 +0,0 @@ - -// Original file name: HelloWorld_Res.ENU.tr3 -// Generated by TOPS Builder 1.2.4.249 Date:2011-1-14 - - -//$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 -//$End -LANGUAGE = 1033 -// ImageLists - -// Project -PROJECT -BEGIN - ScreenWidth 320 - ScreenHeight 480 - ScreenDPI 16500 -END - - -// TComObject - -// Forms - -FORM ID Form1002 AT(0,24,320,456) - FRAME - NOSAVEBEHIND - BIClose - FullScreen - VISIBLED - ENABLED - CHARSET 0 - UseSYSDefColor - TRANSPARENT - BACKCOLOR $0003 - FORECOLOR $0002 - FOCUSBACKCOLOR $0006 - FOCUSFORECOLOR $0007 - SELECTEDFORECOLOR $0005 - SELECTEDBACKCOLOR $0004 -BEGIN - TITLE $004D$0061$0069$006E -END - -// Menus - -// Alerts 警告消息 - -// Strings - -// Fonts - -// Bitmaps - -IMAGEFOLDER ID ResFolder1001 FOLDERNAME $0052$006F$006F$0074$0028$0041$006C$006C$0029 -// 文件夹: Root(All) -BEGIN -END -// raw data - -// Application - diff --git a/HelloWorld/uphone/Res/HelloWorld_Res.ENU.tr3.tts b/HelloWorld/uphone/Res/HelloWorld_Res.ENU.tr3.tts deleted file mode 100644 index 2086b0820d8c..000000000000 --- a/HelloWorld/uphone/Res/HelloWorld_Res.ENU.tr3.tts +++ /dev/null @@ -1,9 +0,0 @@ - -// Tranzda Translation File. -// TOPS Builder use infomation contained by this file to -// update the controls' trnaslation status. - -// Original file name: HelloWorld_Res.ENU.tr3.tts -// 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 deleted file mode 100644 index 5f2e16ba338a..000000000000 --- a/HelloWorld/uphone/Res/HelloWorld_Res.TR3 +++ /dev/null @@ -1,67 +0,0 @@ - -// Original file name: HelloWorld_Res.TR3 -// Generated by TOPS Builder 1.2.4.249 Date:2011-1-14 - - -#include "HelloWorld_Res.h" - -//$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 -//$End -LANGUAGE = 2052 -// ImageLists - -// Project -PROJECT -BEGIN - ScreenWidth 320 - ScreenHeight 480 - ScreenDPI 16500 -END - - -// TComObject - -// Forms - -FORM ID Form1002 AT(0,24,320,456) - FRAME - NOSAVEBEHIND - BIClose - DisableSystemStatusBar - FullScreen - VISIBLED - ENABLED - CHARSET 0 - UseSYSDefColor - TRANSPARENT - BACKCOLOR $0003 - FORECOLOR $0002 - FOCUSBACKCOLOR $0006 - FOCUSFORECOLOR $0007 - SELECTEDFORECOLOR $0005 - SELECTEDBACKCOLOR $0004 -BEGIN - TITLE $004D$0061$0069$006E -END - -// Menus - -// Alerts 警告消息 - -// Strings - -// Fonts - -// Bitmaps - -IMAGEFOLDER ID ResFolder1001 FOLDERNAME $0052$006F$006F$0074$0028$0041$006C$006C$0029 -// 文件夹: Root(All) -BEGIN -END -// raw data - -// Application - diff --git a/HelloWorld/uphone/Res/HelloWorld_Res.TRG b/HelloWorld/uphone/Res/HelloWorld_Res.TRG deleted file mode 100644 index 3e94d07ad639..000000000000 --- a/HelloWorld/uphone/Res/HelloWorld_Res.TRG +++ /dev/null @@ -1,19 +0,0 @@ -// Application resource group file. - -// Original file name: HelloWorld_Res.TRG -// Generated by TOPS Builder:Project wizard,Date:2010-09-29 - - - -VERSION 60001 -PROJECT -Begin - IsLangBase - FileName = ".\HelloWorld_Res.TR3" -End - -PROJECT -Begin - FileName = ".\HelloWorld_Res.ENU.tr3" -End - diff --git a/HelloWorld/uphone/Res/HelloWorld_Res.h b/HelloWorld/uphone/Res/HelloWorld_Res.h deleted file mode 100644 index 9573ce1f2bba..000000000000 --- a/HelloWorld/uphone/Res/HelloWorld_Res.h +++ /dev/null @@ -1,5 +0,0 @@ -// Original file name: HelloWorld_Res.h -// Generated by TOPS Builder 1.2.4.249 Date:2011-1-14 - -#define ResFolder1001 1001 -#define Form1002 1002 diff --git a/HelloWorld/uphone/Res/HelloWorld_res_c.h b/HelloWorld/uphone/Res/HelloWorld_res_c.h deleted file mode 100644 index 819a696e7a79..000000000000 --- a/HelloWorld/uphone/Res/HelloWorld_res_c.h +++ /dev/null @@ -1,245 +0,0 @@ -//------------------------------------------------------------------------------ -// 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 11Create(320,480)); - -#ifndef _TRANZDA_VM_ - // on uphone emulator, we copy resources files to Work7/TG3/APP/ folder instead of zip file - cocos2d::CCFileUtils::setResource("HelloWorld.zip"); -#endif +#include "CCScheduler.h" - bRet = true; - } while (0); +NS_CC_BEGIN; - return bRet; -} +// sharedApplication pointer +ccxApplication * ccxApplication::sm_pSharedApplication = 0; static const Int32 CCX_ON_APPLICATION_IDLE = (EVENT_FirstUser + EVENT_LastUser) / 2; @@ -42,7 +28,7 @@ static long long getTimeOfDayMicroSecond() } #endif -Application::Application() +ccxApplication::ccxApplication() : m_bRunning(FALSE) , m_bNeedStop(FALSE) , m_bInBackground(FALSE) @@ -51,7 +37,7 @@ Application::Application() SS_GetCurrentGTID(&m_tMsg.gtid); m_tMsg.type = CCX_ON_APPLICATION_IDLE; - Sys_RegisterMessageCallBack(CCX_ON_APPLICATION_IDLE, Application::_OnAppIdle, (UInt32)this); + Sys_RegisterMessageCallBack(CCX_ON_APPLICATION_IDLE, ccxApplication::_OnAppIdle, (UInt32)this); memset(m_AppDataPath, 0, sizeof(char) * EOS_FILE_MAX_PATH); @@ -66,22 +52,27 @@ Application::Application() SS_GetApplicationPath(AppID, SS_APP_PATH_TYPE_EXECUTABLE, AppPath); TUString::StrUnicodeToStrUtf8((Char*) m_AppDataPath, AppPath); } while (0); + + CCX_ASSERT(! sm_pSharedApplication); + sm_pSharedApplication = this; } -Application::~Application() +ccxApplication::~ccxApplication() { Sys_RegisterMessageCallBack(CCX_ON_APPLICATION_IDLE, NULL, NULL); + + CCX_ASSERT(this == sm_pSharedApplication); + sm_pSharedApplication = NULL; } -Boolean Application::EventHandler(EventType* pEvent) +Boolean ccxApplication::EventHandler(EventType* pEvent) { Boolean bHandled = FALSE; switch(pEvent->eType) { case EVENT_AppLoad: - setSharedApplication(*this); - if (! m_Delegate.applicationDidFinishLaunching()) + if (! initInstance() || ! applicationDidFinishLaunching()) { CCScheduler::purgeSharedScheduler(); SendStopEvent(); @@ -103,7 +94,7 @@ Boolean Application::EventHandler(EventType* pEvent) { if (!m_bInBackground) { - m_Delegate.applicationDidEnterBackground(); + applicationDidEnterBackground(); m_bInBackground = true; } @@ -118,7 +109,7 @@ Boolean Application::EventHandler(EventType* pEvent) { if (m_bInBackground) { - m_Delegate.applicationWillEnterForeground(); + applicationWillEnterForeground(); m_bInBackground = false; } @@ -141,7 +132,7 @@ Boolean Application::EventHandler(EventType* pEvent) return bHandled; } -void Application::setAnimationInterval(double interval) +void ccxApplication::setAnimationInterval(double interval) { #ifdef _TRANZDA_VM_ LARGE_INTEGER nFreq; @@ -152,21 +143,21 @@ void Application::setAnimationInterval(double interval) #endif } -Application::Orientation Application::setOrientation(Application::Orientation orientation) +ccxApplication::Orientation ccxApplication::setOrientation(ccxApplication::Orientation orientation) { return orientation; } -void Application::statusBarFrame(CGRect * rect) +void ccxApplication::statusBarFrame(CGRect * rect) { } -const char* Application::getAppDataPath() +const char* ccxApplication::getAppDataPath() { return m_AppDataPath; } -void Application::switchNotify(int nTurnOn) +void ccxApplication::switchNotify(int nTurnOn) { bool bInBack = isInBackground(); @@ -178,24 +169,24 @@ void Application::switchNotify(int nTurnOn) if (! nTurnOn) // turn off screen { // CCDirector::sharedDirector()->pause(); - m_Delegate.applicationDidEnterBackground(); + applicationDidEnterBackground(); StopMainLoop(); } else { // CCDirector::sharedDirector()->resume(); - m_Delegate.applicationWillEnterForeground(); + applicationWillEnterForeground(); StartMainLoop(); } } while (0); } -bool Application::isInBackground() +bool ccxApplication::isInBackground() { return m_bInBackground; } -void Application::StartMainLoop() +void ccxApplication::StartMainLoop() { if (m_bRunning) { @@ -206,14 +197,14 @@ void Application::StartMainLoop() m_bRunning = TRUE; } -void Application::StopMainLoop() +void ccxApplication::StopMainLoop() { m_bNeedStop = TRUE; } -Int32 Application::_OnAppIdle(MESSAGE_t * pMsg, UInt32 uData) +Int32 ccxApplication::_OnAppIdle(MESSAGE_t * pMsg, UInt32 uData) { - Application& rThis = (Application&) Application::sharedApplication(); + ccxApplication& rThis = (ccxApplication&) ccxApplication::sharedApplication(); CCXEGLView * pView = CCDirector::sharedDirector()->getOpenGLView(); if (pView && rThis.m_bRunning) { @@ -249,3 +240,14 @@ Int32 Application::_OnAppIdle(MESSAGE_t * pMsg, UInt32 uData) } return 1; } + +////////////////////////////////////////////////////////////////////////// +// static member function +////////////////////////////////////////////////////////////////////////// +ccxApplication& ccxApplication::sharedApplication() +{ + CCX_ASSERT(sm_pSharedApplication); + return *sm_pSharedApplication; +} + +NS_CC_END; diff --git a/cocos2dx/platform/uphone/ccxApplication_uphone.h b/cocos2dx/platform/uphone/ccxApplication_uphone.h new file mode 100644 index 000000000000..b91d6003316a --- /dev/null +++ b/cocos2dx/platform/uphone/ccxApplication_uphone.h @@ -0,0 +1,107 @@ +#ifndef __CCX_APPLICATION_UPHONE_H__ +#define __CCX_APPLICATION_UPHONE_H__ + +#include "TG3.h" +#include "CCDirector.h" + +NS_CC_BEGIN; + +class CCX_DLL ccxApplication : public TApplication +{ +public: + ccxApplication(); + virtual ~ccxApplication(); + + virtual Boolean EventHandler(EventType * pEvent); + +public: + /** + @brief Implement for initialize OpenGL instance, set source path, etc... + */ + virtual bool initInstance() = 0; + + /** + @brief Implement CCDirector and CCScene init code here. + @return true Initialize success, app continue. + @return false Initialize failed, app terminate. + */ + virtual bool applicationDidFinishLaunching() = 0; + + /** + @brief The function be called when the application enter background + @param the pointer of the application + */ + virtual void applicationDidEnterBackground() = 0; + + /** + @brief The function be called when the application enter foreground + @param the pointer of the application + */ + virtual void applicationWillEnterForeground() = 0; + + /** + @brief Callback by CCDirector for limit FPS. + @interval The time, which expressed in second in second, between current frame and next. + */ + void setAnimationInterval(double interval); + + typedef enum + { + /// Device oriented vertically, home button on the bottom + kOrientationPortrait = 0, + /// Device oriented vertically, home button on the top + kOrientationPortraitUpsideDown = 1, + /// Device oriented horizontally, home button on the right + kOrientationLandscapeLeft = 2, + /// Device oriented horizontally, home button on the left + kOrientationLandscapeRight = 3, + } Orientation; + + /** + @brief Callback by CCDirector for change device orientation. + @orientation The defination of orientation which CCDirector want change to. + @return The actual orientation of the application. + */ + Orientation setOrientation(Orientation orientation); + + /** + @brief Get status bar rectangle in EGLView window. + */ + void statusBarFrame(CGRect * rect); + + /** + @brief Get current applicaiton instance. + @return Current application instance pointer. + */ + static ccxApplication& sharedApplication(); + + /** + @brief Get the data path of the Application. + @return If the app is installed,the return value is the path of .so file. + else the return value is "/NEWPLUS/TG3/APP/" + */ + const char* getAppDataPath(); + + + void switchNotify(int nTurnOn); + +protected: + bool isInBackground(); + void StartMainLoop(); + void StopMainLoop(); + +protected: + static Int32 _OnAppIdle(MESSAGE_t * pMsg, UInt32 uData); + + MESSAGE_t m_tMsg; + bool m_bRunning; + bool m_bNeedStop; + bool m_bInBackground; + char m_AppDataPath[EOS_FILE_MAX_PATH]; + + static ccxApplication * sm_pSharedApplication; +}; + +NS_CC_END; + +#endif // __CCX_APPLICATION_UPHONE_H__ diff --git a/cocos2dx/proj.uphone/Makefile.ARM b/cocos2dx/proj.uphone/Makefile.ARM index db269fd3f2d0..ff5df7ee1065 100644 --- a/cocos2dx/proj.uphone/Makefile.ARM +++ b/cocos2dx/proj.uphone/Makefile.ARM @@ -85,6 +85,7 @@ OBJECTS = \ $(OBJECTS_DIR)/CCTransition_mobile.o \ $(OBJECTS_DIR)/platform.o \ $(OBJECTS_DIR)/CCNS_uphone.o \ + $(OBJECTS_DIR)/ccxApplication_uphone.o \ $(OBJECTS_DIR)/CCXEGLView_uphone.o \ $(OBJECTS_DIR)/CCXFileUtils_uphone.o \ $(OBJECTS_DIR)/CCXUIAccelerometer_uphone.o \ @@ -293,6 +294,9 @@ $(OBJECTS_DIR)/platform.o : ../platform/platform.cpp $(OBJECTS_DIR)/CCNS_uphone.o : ../platform/uphone/CCNS_uphone.cpp $(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCNS_uphone.o ../platform/uphone/CCNS_uphone.cpp +$(OBJECTS_DIR)/ccxApplication_uphone.o : ../platform/uphone/ccxApplication_uphone.cpp + $(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/ccxApplication_uphone.o ../platform/uphone/ccxApplication_uphone.cpp + $(OBJECTS_DIR)/CCXEGLView_uphone.o : ../platform/uphone/CCXEGLView_uphone.cpp $(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCXEGLView_uphone.o ../platform/uphone/CCXEGLView_uphone.cpp diff --git a/cocos2dx/proj.uphone/cocos2d-uphone.TMK3 b/cocos2dx/proj.uphone/cocos2d-uphone.TMK3 index bdc4ee3ae962..a01cee8a2028 100644 --- a/cocos2dx/proj.uphone/cocos2d-uphone.TMK3 +++ b/cocos2dx/proj.uphone/cocos2d-uphone.TMK3 @@ -36,7 +36,9 @@ DEFINES=-DUSE_FILE32API ; ;包含路径,可以使用多个INCLUDE_PATH串,也可以使用INCLUDE_PATH1、INCLUDE_PATH2等方式,MakeFile中依据出现顺序(不是数字大小)排列 ;应用额外的包含路径。注意:ITOPS自己的所有路径都会自动包含,故此这里仅仅包含应用自己特有的路径即可 -INCLUDE_PATH=-I./ -I./Res -I./include -I$(TO_PROJECT_ROOT)/Include/ThirdParty/libxml2 +INCLUDE_PATH=-I../ -I../include +INCLUDE_PATH=-I../../platform_support/include +INCLUDE_PATH=-I$(TO_PROJECT_ROOT)/Include/ThirdParty/libxml2 INCLUDE_PATH=-I$(TO_PROJECT_ROOT)/Include/ThirdParty/iconv INCLUDE_PATH=-I$(TO_PROJECT_ROOT)/Include/ThirdParty/libpng INCLUDE_PATH=-I$(TO_PROJECT_ROOT)/Include/ThirdParty/libjpeg diff --git a/cocos2dx/proj.uphone/cocos2d-uphone.vcproj b/cocos2dx/proj.uphone/cocos2d-uphone.vcproj index f407b1c99077..03f8940f4755 100644 --- a/cocos2dx/proj.uphone/cocos2d-uphone.vcproj +++ b/cocos2dx/proj.uphone/cocos2d-uphone.vcproj @@ -979,6 +979,14 @@ RelativePath="..\platform\uphone\CCNS_uphone.cpp" > + + + + diff --git a/platform_support/proj.uphone/Makefile.ARM b/platform_support/proj.uphone/Makefile.ARM index 4328cfc44324..3ed3b77140c1 100644 --- a/platform_support/proj.uphone/Makefile.ARM +++ b/platform_support/proj.uphone/Makefile.ARM @@ -29,7 +29,6 @@ MKDIR = mkdir -p first: all OBJECTS = \ - $(OBJECTS_DIR)/ccxApplication.o \ $(OBJECTS_DIR)/ccxCommon.o \ $(OBJECTS_DIR)/ccxGL.o \ $(OBJECTS_DIR)/ccxImage.o \ @@ -53,9 +52,6 @@ clean : -$(DEL_FILE) $(OBJECTS) -$(DEL_FILE) $(TARGET) -$(OBJECTS_DIR)/ccxApplication.o : ../src/ccxApplication.cpp - $(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/ccxApplication.o ../src/ccxApplication.cpp - $(OBJECTS_DIR)/ccxCommon.o : ../src/ccxCommon.cpp $(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/ccxCommon.o ../src/ccxCommon.cpp diff --git a/platform_support/proj.uphone/PlatformSupport.uphone.vcproj b/platform_support/proj.uphone/PlatformSupport.uphone.vcproj index 7040330ad010..250e5d84b000 100644 --- a/platform_support/proj.uphone/PlatformSupport.uphone.vcproj +++ b/platform_support/proj.uphone/PlatformSupport.uphone.vcproj @@ -185,10 +185,6 @@ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > - - @@ -217,10 +213,6 @@ - - diff --git a/platform_support/proj.uphone/PlatformSupport_Arm.TMK3 b/platform_support/proj.uphone/PlatformSupport_Arm.TMK3 index f7a3cfc77c72..47743c992e29 100644 --- a/platform_support/proj.uphone/PlatformSupport_Arm.TMK3 +++ b/platform_support/proj.uphone/PlatformSupport_Arm.TMK3 @@ -52,3 +52,5 @@ INCLUDEFILE= ;可以使用多个EXCLUDEFILE串,也可以使用EXCLUDEFILE1、EXCLUDEFILE2等方式,MakeFile中依据出现顺序(不是数字大小)排列 EXCLUDEFILE= ./src/uphone/ EXCLUDEFILE= ./src/win32/ +EXCLUDEFILE= ./src/android/ +EXCLUDEFILE= ./src/ios/ diff --git a/tests/AppDelegate.cpp b/tests/AppDelegate.cpp index 7844c880d2a7..8863d91d86aa 100644 --- a/tests/AppDelegate.cpp +++ b/tests/AppDelegate.cpp @@ -29,6 +29,20 @@ bool AppDelegate::initInstance() #endif // CCX_PLATFORM_WIN32 +#if (CCX_TARGET_PLATFORM == CCX_PLATFORM_UPHONE) + + // Initialize OpenGLView instance, that release by CCDirector when application terminate. + // The tests is designed as HVGA. + CCXEGLView* pMainWnd = new CCXEGLView(this); + CCX_BREAK_IF(! pMainWnd || ! pMainWnd->Create(320,480)); + +#ifndef _TRANZDA_VM_ + // on uphone emulator, we copy resources files to Work7/TG3/APP/ folder instead of zip file + cocos2d::CCFileUtils::setResource("TestCocos2dx.zip"); +#endif + +#endif + bRet = true; } while (0); return bRet; diff --git a/tests/test.uphone/Application.cpp b/tests/test.uphone/Application.cpp deleted file mode 100644 index 800db6a275de..000000000000 --- a/tests/test.uphone/Application.cpp +++ /dev/null @@ -1,251 +0,0 @@ -#include "Application.h" -#include "ssBackLightControl.h" -#include "ssKeyLockControl.h" - -using namespace cocos2d; - -static const Int32 CCX_ON_APPLICATION_IDLE = (EVENT_FirstUser + EVENT_LastUser) / 2; - -#ifdef _TRANZDA_VM_ -static LARGE_INTEGER s_nAnimationInterval; -static LARGE_INTEGER s_nFreq; -static LARGE_INTEGER s_nLast; -#else -#include -static long long s_nAnimationInterval; -static long long s_nLast; -static long long getTimeOfDayMicroSecond() -{ - timeval val; - gettimeofday(&val, NULL); - return (long long)val.tv_sec * 1000 * 1000 + val.tv_usec; -} -#endif - -Application::Application() -: m_bRunning(FALSE) -, m_bNeedStop(FALSE) -, m_bInBackground(FALSE) -{ - memset(&m_tMsg, 0, sizeof(m_tMsg)); - SS_GetCurrentGTID(&m_tMsg.gtid); - m_tMsg.type = CCX_ON_APPLICATION_IDLE; - - Sys_RegisterMessageCallBack(CCX_ON_APPLICATION_IDLE, Application::_OnAppIdle, (UInt32)this); - - memset(m_AppDataPath, 0, sizeof(char) * EOS_FILE_MAX_PATH); - - do - { - TUChar AppID[EOS_FILE_MAX_PATH] = {0}; - UInt32 nCmdType = 0; - Int32 nRet = SS_AppRequest_GetAppName(AppID, &nCmdType); - CCX_BREAK_IF(nRet < 0); - - TUChar AppPath[EOS_FILE_MAX_PATH] = {0}; - SS_GetApplicationPath(AppID, SS_APP_PATH_TYPE_EXECUTABLE, AppPath); - TUString::StrUnicodeToStrUtf8((Char*) m_AppDataPath, AppPath); - } while (0); -} - -Application::~Application() -{ - Sys_RegisterMessageCallBack(CCX_ON_APPLICATION_IDLE, NULL, NULL); -} - -Boolean Application::EventHandler(EventType* pEvent) -{ - Boolean bHandled = FALSE; - - switch(pEvent->eType) - { - case EVENT_AppLoad: - setSharedApplication(*this); - if (! m_Delegate.applicationDidFinishLaunching()) - { - CCScheduler::purgeSharedScheduler(); - SendStopEvent(); - } -#ifdef _TRANZDA_VM_ - QueryPerformanceFrequency(&s_nFreq); - QueryPerformanceCounter(&s_nLast); -#else - s_nLast = getTimeOfDayMicroSecond(); -#endif - bHandled = TRUE; - break; - - case EVENT_AppStopNotify: - break; - - case EVENT_AppActiveNotify: - if (pEvent->sParam1 == 0) - { - if (!m_bInBackground) - { - m_Delegate.applicationDidEnterBackground(); - m_bInBackground = true; - } - - if (CCDirector::sharedDirector()->isPaused()) - { - StopMainLoop(); - } - CfgTurnOnBackLight(); - EnableKeyLock(); - } - else if (pEvent->sParam1 > 0) - { - if (m_bInBackground) - { - m_Delegate.applicationWillEnterForeground(); - m_bInBackground = false; - } - - StartMainLoop(); - - CfgTurnOnBackLightDelay(0x7fffffff); - // if KeyLock disactived, disable it. - if (! CfgKeyLock_GetActive()) - { - DisableKeyLock(); - } - } - break; - } - if (FALSE == bHandled) - { - return TApplication::EventHandler(pEvent); - } - - return bHandled; -} - -bool Application::initInstance() -{ - CCXEGLView* pMainWnd = new CCXEGLView(this); - bool bRet = false; - - do - { - CCX_BREAK_IF(! pMainWnd || ! pMainWnd->Create(320,480)); - -#ifndef _TRANZDA_VM_ - // on uphone emulator, we copy resources files to Work7/TG3/APP/ folder instead of zip file - cocos2d::CCFileUtils::setResource("TestCocos2dx.zip"); -#endif - - bRet = true; - } while (0); - - return bRet; -} - -void Application::setAnimationInterval(double interval) -{ -#ifdef _TRANZDA_VM_ - LARGE_INTEGER nFreq; - QueryPerformanceFrequency(&nFreq); - s_nAnimationInterval.QuadPart = (LONGLONG)(interval * nFreq.QuadPart); -#else - s_nAnimationInterval = (long long)(interval * 1000 * 1000); -#endif -} - -Application::Orientation Application::setOrientation(Application::Orientation orientation) -{ - return orientation; -} - -void Application::statusBarFrame(CGRect * rect) -{ -} - -const char* Application::getAppDataPath() -{ - return m_AppDataPath; -} - -void Application::switchNotify(int nTurnOn) -{ - bool bInBack = isInBackground(); - - do - { - // if the app have be in background,don't handle this message - CCX_BREAK_IF(bInBack); - - if (! nTurnOn) // turn off screen - { - // CCDirector::sharedDirector()->pause(); - m_Delegate.applicationDidEnterBackground(); - StopMainLoop(); - } - else - { - // CCDirector::sharedDirector()->resume(); - m_Delegate.applicationWillEnterForeground(); - StartMainLoop(); - } - } while (0); -} - -bool Application::isInBackground() -{ - return m_bInBackground; -} - -void Application::StartMainLoop() -{ - if (m_bRunning) - { - m_bNeedStop = FALSE; - return; - } - Sys_PostMessage2(MESSAGE_PRIOR_LOWEST, &m_tMsg); - m_bRunning = TRUE; -} - -void Application::StopMainLoop() -{ - m_bNeedStop = TRUE; -} - -Int32 Application::_OnAppIdle(MESSAGE_t * pMsg, UInt32 uData) -{ - Application& rThis = (Application&) Application::sharedApplication(); - CCXEGLView * pView = CCDirector::sharedDirector()->getOpenGLView(); - if (pView && rThis.m_bRunning) - { - if (rThis.m_bNeedStop) - { - rThis.m_bNeedStop = FALSE; - rThis.m_bRunning = FALSE; - } - else - { -#ifdef _TRANZDA_VM_ - LARGE_INTEGER nNow; - QueryPerformanceCounter(&nNow); - if (nNow.QuadPart - s_nLast.QuadPart >= s_nAnimationInterval.QuadPart) - { - pView->UpdateWindow(0); - s_nLast.QuadPart = nNow.QuadPart; - } -#else - long long nNow = getTimeOfDayMicroSecond(); - if (nNow - s_nLast >= s_nAnimationInterval) - { - pView->UpdateWindow(0); - s_nLast = nNow; - } -#endif - else - { - Sys_Sleep(0); - } - Sys_PostMessage2(MESSAGE_PRIOR_LOWEST, &rThis.m_tMsg); - } - } - return 1; -} diff --git a/tests/test.uphone/Application.h b/tests/test.uphone/Application.h deleted file mode 100644 index f8305c5953ed..000000000000 --- a/tests/test.uphone/Application.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef __COCOS2D_HELLOWORLD_APP_H__ -#define __COCOS2D_HELLOWORLD_APP_H__ -#include "TG3.h" -#include "cocos2d.h" -#include "../AppDelegate.h" - -class Application : public TApplication, public cocos2d::ccxApplication -{ -public: - Application(); - virtual ~Application(); - - virtual Boolean EventHandler(EventType * pEvent); - -public: - // implement the virtual interface of class ccxApplication - virtual bool initInstance(); - virtual void setAnimationInterval(double interval); - virtual Orientation setOrientation(Orientation orientation); - virtual void statusBarFrame(cocos2d::CGRect * rect); - virtual const char* getAppDataPath(); - virtual void switchNotify(int nTurnOn); - -protected: - bool isInBackground(); - void StartMainLoop(); - void StopMainLoop(); - -private: - static Int32 _OnAppIdle(MESSAGE_t * pMsg, UInt32 uData); - - MESSAGE_t m_tMsg; - bool m_bRunning; - bool m_bNeedStop; - bool m_bInBackground; - char m_AppDataPath[EOS_FILE_MAX_PATH]; - AppDelegate m_Delegate; -}; - - -#endif diff --git a/tests/test.uphone/Makefile.ARM b/tests/test.uphone/Makefile.ARM index 5783b80140f2..938fa48bfbd2 100644 --- a/tests/test.uphone/Makefile.ARM +++ b/tests/test.uphone/Makefile.ARM @@ -35,7 +35,6 @@ first: all OBJECTS = \ $(OBJECTS_DIR)/AppDelegate.o \ - $(OBJECTS_DIR)/Application.o \ $(OBJECTS_DIR)/main.o \ $(OBJECTS_DIR)/NewDeleteOp.o \ $(OBJECTS_DIR)/TG3AppDllEntry.o \ @@ -117,9 +116,6 @@ clean : $(OBJECTS_DIR)/AppDelegate.o : ../AppDelegate.cpp $(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/AppDelegate.o ../AppDelegate.cpp -$(OBJECTS_DIR)/Application.o : ./Application.cpp - $(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/Application.o ./Application.cpp - $(OBJECTS_DIR)/main.o : ./main.cpp $(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/main.o ./main.cpp diff --git a/tests/test.uphone/main.cpp b/tests/test.uphone/main.cpp index ec6795ddef11..569dc8581d3e 100644 --- a/tests/test.uphone/main.cpp +++ b/tests/test.uphone/main.cpp @@ -7,13 +7,13 @@ #include "TG3.h" // game -#include "Application.h" +#include "../AppDelegate.h" Int32 TG3AppMain(const TUChar * pAppID, UInt32 nCmd, void * pCmdParam) { - Application app; - app.Run(); + AppDelegate app; + cocos2d::ccxApplication::sharedApplication().Run(); return 1; } diff --git a/tests/test.uphone/test.uphone.vcproj b/tests/test.uphone/test.uphone.vcproj index 36d1667a6b5d..64ef08cbe9ac 100644 --- a/tests/test.uphone/test.uphone.vcproj +++ b/tests/test.uphone/test.uphone.vcproj @@ -211,14 +211,6 @@ - - - - @@ -508,14 +500,14 @@