ProjectConfig.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. #ifndef __PROJECT_CONFIG_H_
  2. #define __PROJECT_CONFIG_H_
  3. #include <string>
  4. #include <vector>
  5. using namespace std;
  6. #include "cocos2d.h"
  7. #include "SimulatorExport.h"
  8. #define kCCRuntimeDebuggerNone 0
  9. #define kCCRuntimeDebuggerLDT 1
  10. #define kCCRuntimeDebuggerCodeIDE 2
  11. #define kCCRuntimeDebuggerStudio 3
  12. #define kProjectConfigProjectDir 1 // -workdir "PATH"
  13. #define kProjectConfigScriptFile 2 // -script "FILENAME"
  14. #define kProjectConfigPackagePath 4 // -package.path "PATH;PATH"
  15. #define kProjectConfigWritablePath 8 // -writable "PATH"
  16. #define kProjectConfigFrameSize 16 // -size 960x640
  17. #define kProjectConfigFrameScale 32 // -scale 1.0
  18. #define kProjectConfigShowConsole 64 // -console, -disable-console
  19. #define kProjectConfigLoadPrecompiledFramework 128 // -load-framework, -disable-load-framework
  20. #define kProjectConfigWriteDebugLogToFile 256 // -write-debug-log, -disable-write-debug-log
  21. #define kProjectConfigWindowOffset 512 // -offset {0,0}
  22. #define kProjectConfigDebugger 1024 // -debugger-ldt, -debugger-codeide, -disable-debugger
  23. #define kProjectConfigListen 2048 //
  24. #define kProjectConfigSearchPath 4096 //
  25. #define kProjectConfigFirstSearchPath 8192 // -first-search-path
  26. #define kProjectConfigOpenRecent (kProjectConfigProjectDir | kProjectConfigScriptFile | kProjectConfigPackagePath | kProjectConfigWritablePath | kProjectConfigFrameSize | kProjectConfigFrameScale | kProjectConfigShowConsole | kProjectConfigLoadPrecompiledFramework | kProjectConfigWriteDebugLogToFile)
  27. #define kProjectConfigAll (kProjectConfigProjectDir | kProjectConfigScriptFile | kProjectConfigPackagePath | kProjectConfigWritablePath | kProjectConfigFrameSize | kProjectConfigFrameScale | kProjectConfigShowConsole | kProjectConfigLoadPrecompiledFramework | kProjectConfigWriteDebugLogToFile | kProjectConfigWindowOffset | kProjectConfigDebugger | kProjectConfigListen | kProjectConfigSearchPath | kProjectConfigFirstSearchPath)
  28. #define kProjectConfigConsolePort 6010
  29. #define kProjectConfigUploadPort 6020
  30. #define kProjectConfigDebugPort 5086
  31. class CC_LIBSIM_DLL ProjectConfig
  32. {
  33. public:
  34. ProjectConfig();
  35. static const int DEFAULT_WIDTH = 640;
  36. static const int DEFAULT_HEIGHT = 960;
  37. string getProjectDir() const;
  38. void setProjectDir(const string &projectDir);
  39. string getScriptFile() const;
  40. string getScriptFileRealPath() const;
  41. void setScriptFile(const string &scriptFile);
  42. string getWritablePath() const;
  43. string getWritableRealPath() const;
  44. void setWritablePath(const string &writablePath);
  45. string getPackagePath() const;
  46. string getNormalizedPackagePath() const;
  47. void setPackagePath(const string &packagePath);
  48. void addPackagePath(const string &packagePath);
  49. vector<string> getPackagePathArray() const;
  50. cocos2d::Size getFrameSize() const;
  51. void setFrameSize(const cocos2d::Size &frameSize);
  52. bool isLandscapeFrame() const;
  53. bool isPortraitFrame() const;
  54. void changeFrameOrientation();
  55. void changeFrameOrientationToPortait();
  56. void changeFrameOrientationToLandscape();
  57. float getFrameScale() const;
  58. void setFrameScale(float frameScale);
  59. bool isShowConsole() const;
  60. void setShowConsole(bool showConsole);
  61. bool isLoadPrecompiledFramework() const;
  62. void setLoadPrecompiledFramework(bool load);
  63. bool isWriteDebugLogToFile() const;
  64. void setWriteDebugLogToFile(bool writeDebugLogToFile);
  65. void setDebugLogFilePath(const std::string &logFile);
  66. string getDebugLogFilePath() const;
  67. cocos2d::Vec2 getWindowOffset() const;
  68. void setWindowOffset(const cocos2d::Vec2 &windowOffset);
  69. int getDebuggerType() const;
  70. void setDebuggerType(int debuggerType);
  71. void parseCommandLine(const vector<string> &args);
  72. string makeCommandLine(unsigned int mask = kProjectConfigAll) const;
  73. vector<string> makeCommandLineVector(unsigned int mask = kProjectConfigAll) const;
  74. void setConsolePort(int port);
  75. int getConsolePort();
  76. void setFileUploadPort(int port);
  77. int getFileUploadPort();
  78. // @address: 127.0.0.1
  79. void setBindAddress(const std::string &address);
  80. const std::string &getBindAddress() const;
  81. void setSearchPath(const vector<string> &args);
  82. const vector<string> &getSearchPath() const;
  83. void setFirstSearchPath(const vector<string> &args);
  84. const vector<string> &getFirstSearchPath() const;
  85. void setLanguageDataPath(const std::string &filePath);
  86. bool isAppMenu() const;
  87. bool isResizeWindow() const;
  88. bool isRetinaDisplay() const;
  89. bool validate() const;
  90. void dump();
  91. private:
  92. string _projectDir;
  93. string _scriptFile;
  94. string _packagePath;
  95. string _writablePath;
  96. cocos2d::Size _frameSize;
  97. float _frameScale;
  98. bool _showConsole;
  99. bool _loadPrecompiledFramework;
  100. bool _writeDebugLogToFile;
  101. bool _restartProcess;
  102. cocos2d::Vec2 _windowOffset;
  103. int _debuggerType;
  104. bool _isAppMenu;
  105. bool _isResizeWindow;
  106. bool _isRetinaDisplay;
  107. string _debugLogFile;
  108. int _consolePort;
  109. int _fileUploadPort;
  110. string _bindAddress;
  111. vector<string> _searchPath;
  112. vector<string> _firstSearchPath;
  113. string _languageDataPath;
  114. void normalize();
  115. string replaceProjectDirToMacro(const string &path) const;
  116. string replaceProjectDirToFullPath(const string &path) const;
  117. bool isAbsolutePath(const string &path) const;
  118. /**
  119. * windows : Y:\Documents\CocosProjects\Cocos Project\ -> "Y:\Documents\CocosProjects\Cocos Project\\"
  120. * other : return @path
  121. */
  122. string dealWithSpaceWithPath(const string &path) const;
  123. };
  124. #endif // __PROJECT_CONFIG_H_