From c53537e7c28e6362948e07391663f410897d1e8f Mon Sep 17 00:00:00 2001 From: chuanweizhang Date: Wed, 25 Dec 2013 15:53:47 +0800 Subject: [PATCH] modify create_project --- README.md | 4 +- .../multi-platform-cpp/proj.linux/Makefile | 2 +- .../multi-platform-js/Classes/AppDelegate.cpp | 4 +- .../multi-platform-lua/proj.linux/Makefile | 2 +- tools/project-creator/README.md | 1 + .../{create_project.py => create_project.pyw} | 5 ++- tools/project-creator/module/core.py | 39 +++++++++++++------ tools/project-creator/module/ui.py | 33 ++++++++++++---- 8 files changed, 64 insertions(+), 26 deletions(-) create mode 100644 tools/project-creator/README.md rename tools/project-creator/{create_project.py => create_project.pyw} (83%) mode change 100755 => 100644 diff --git a/README.md b/README.md index c5d464e62f..edf7822ec5 100644 --- a/README.md +++ b/README.md @@ -30,8 +30,8 @@ How to start a new game Example: $ cd cocos2d-x/tools/project-creator - $ ./create-multi-platform-projects.py -p mygame -k com.your_company.mygame -l cpp - $ cd ../../projects/mygame + $ ./create-multi-platform-projects.py -n mygame -k com.your_company.mygame -l cpp -p /usr/mygame + $ cd /usr/mygame Main features diff --git a/template/multi-platform-cpp/proj.linux/Makefile b/template/multi-platform-cpp/proj.linux/Makefile index 1b851ad66a..170b1d2c95 100644 --- a/template/multi-platform-cpp/proj.linux/Makefile +++ b/template/multi-platform-cpp/proj.linux/Makefile @@ -6,7 +6,7 @@ SOURCES = main.cpp \ ../Classes/AppDelegate.cpp \ ../Classes/HelloWorldScene.cpp -COCOS_ROOT = ../../.. +COCOS_ROOT = ../cocos2d include $(COCOS_ROOT)/cocos2dx/proj.linux/cocos2dx.mk SHAREDLIBS += -lcocos2d diff --git a/template/multi-platform-js/Classes/AppDelegate.cpp b/template/multi-platform-js/Classes/AppDelegate.cpp index 0794c10c9a..13f0345ccc 100644 --- a/template/multi-platform-js/Classes/AppDelegate.cpp +++ b/template/multi-platform-js/Classes/AppDelegate.cpp @@ -5,7 +5,7 @@ #include "ScriptingCore.h" #include "jsb_cocos2dx_auto.hpp" #include "jsb_cocos2dx_extension_auto.hpp" -#include "jsb_cocos2dx_spine_auto.hpp" +//#include "jsb_cocos2dx_spine_auto.hpp" #include "cocos2d_specifics.hpp" #include "extension/jsb_cocos2dx_extension_manual.h" #include "chipmunk/js_bindings_chipmunk_registration.h" @@ -41,7 +41,7 @@ bool AppDelegate::applicationDidFinishLaunching() sc->addRegisterCallback(register_all_cocos2dx_extension); sc->addRegisterCallback(register_cocos2dx_js_extensions); sc->addRegisterCallback(register_all_cocos2dx_extension_manual); - sc->addRegisterCallback(register_all_cocos2dx_spine); + //sc->addRegisterCallback(register_all_cocos2dx_spine); sc->addRegisterCallback(jsb_register_chipmunk); sc->addRegisterCallback(JSB_register_opengl); sc->addRegisterCallback(jsb_register_system); diff --git a/template/multi-platform-lua/proj.linux/Makefile b/template/multi-platform-lua/proj.linux/Makefile index b9cdb5c66c..368020726c 100644 --- a/template/multi-platform-lua/proj.linux/Makefile +++ b/template/multi-platform-lua/proj.linux/Makefile @@ -1,6 +1,6 @@ EXECUTABLE = HelloLua -COCOS_ROOT = ../../.. +COCOS_ROOT = ../cocos2d INCLUDES = -I../ -I../Classes -I$(COCOS_ROOT)/audio/include \ -I$(COCOS_ROOT)/scripting/lua/lua \ -I$(COCOS_ROOT)/scripting/lua/tolua \ diff --git a/tools/project-creator/README.md b/tools/project-creator/README.md new file mode 100644 index 0000000000..1b03809589 --- /dev/null +++ b/tools/project-creator/README.md @@ -0,0 +1 @@ +#create_project diff --git a/tools/project-creator/create_project.py b/tools/project-creator/create_project.pyw old mode 100755 new mode 100644 similarity index 83% rename from tools/project-creator/create_project.py rename to tools/project-creator/create_project.pyw index a2ca8122c4..86ff095181 --- a/tools/project-creator/create_project.py +++ b/tools/project-creator/create_project.pyw @@ -6,8 +6,6 @@ # Author: chuanwei import sys -from module.ui import createTkCocosDialog -from module.core import CocosProject # ------------ main -------------- if __name__ == '__main__': @@ -15,11 +13,14 @@ if __name__ == '__main__': There have double ways to create cocos project. 1.UI 2.console + #create_project.py --help #create_project.py -n MyGame -k com.MyCompany.AwesomeGame -l javascript -p c:/mycompany """ if len(sys.argv)==1: + from module.ui import createTkCocosDialog createTkCocosDialog() else: + from module.core import CocosProject project = CocosProject() name, package, language, path = project.checkParams() project.createPlatformProjects(name, package, language, path) diff --git a/tools/project-creator/module/core.py b/tools/project-creator/module/core.py index d453ee565a..9fab6d4ac3 100644 --- a/tools/project-creator/module/core.py +++ b/tools/project-creator/module/core.py @@ -1,11 +1,28 @@ #!/usr/bin/python #coding=utf-8 -# create_project.py -# Create cross-platform cocos2d-x project -# Copyright (c) 2012 cocos2d-x.org -# Author: WangZhe -#modify:chuanwei 2013.12.23 +"""**************************************************************************** +Copyright (c) 2010 cocos2d-x.org +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************""" import sys import os, os.path @@ -145,7 +162,7 @@ class CocosProject: else: shutil.copytree(self.context["src_project_path"], self.context["dst_project_path"], True) - # + # check cocos engine exist dirlist = os.listdir(self.cocos_root) if (not "cocos" in dirlist) or (not "extensions" in dirlist): print ("The Cocos2d Engine doesn\'t exist." \ @@ -161,7 +178,7 @@ class CocosProject: # copy cocos2d engine. if not self.__copyCocos2dEngine(): - print "New project Failure" + print ("New project Failure") if os.path.exists(self.context["dst_project_path"]): shutil.rmtree(self.context["dst_project_path"]) return False @@ -198,8 +215,6 @@ class CocosProject: filepath = os.path.join(self.cocos_root,line) showMsg = "%s\t\t\t: Done!" % line self.step += 1 - if self.callbackfun: - self.callbackfun(self.step,self.totalStep,showMsg) if ignoreList.has_key(line): continue if os.path.isdir(filepath): @@ -207,13 +222,15 @@ class CocosProject: print (showMsg) else: shutil.copyfile(filepath, os.path.join(dstPath,line)) - #print ("%s\t\t\t: Done!" % line) + + if self.callbackfun: + self.callbackfun(self.step,self.totalStep,showMsg) return True def __processPlatformProjects(self, platform): """ Process each platform project. Arg: - platform: win32、android、ios + platform: "ios_mac", "android", "win32", "linux" """ # determine proj_path diff --git a/tools/project-creator/module/ui.py b/tools/project-creator/module/ui.py index 1b0b1b06c6..5151630c62 100644 --- a/tools/project-creator/module/ui.py +++ b/tools/project-creator/module/ui.py @@ -1,29 +1,48 @@ #!/usr/bin/python #coding=utf-8 -# ui.py -# Create cross-platform cocos2d-x project -# Copyright (c) 2012 cocos2d-x.org -# Author: chuanwei +"""**************************************************************************** +Copyright (c) 2010 cocos2d-x.org +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************""" import platform import os, os.path import shutil import threading -import Queue import time -from core import CocosProject +from module.core import CocosProject #import head files by python version. if int(platform.python_version().split('.')[0])>=3: from tkinter import * from tkinter.filedialog import * from tkinter.messagebox import * + from queue import * else: from Tkinter import * from tkFileDialog import * from tkMessageBox import * + from Queue import * class ThreadedTask(threading.Thread): @@ -235,7 +254,7 @@ class TkCocosDialog(Frame): #create a new thread to deal with create new project. self.btnCreate['state'] = DISABLED - self.queue = Queue.Queue() + self.queue = Queue() ThreadedTask(self.queue, projectName, packageName, language, projectPath).start() self.parent.after(100, self.process_queue)