modify create_project

This commit is contained in:
chuanweizhang 2013-12-25 15:53:47 +08:00
parent 94420563b3
commit c53537e7c2
8 changed files with 64 additions and 26 deletions

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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 \

View File

@ -0,0 +1 @@
#create_project

View File

@ -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)

View File

@ -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: win32androidios
platform: "ios_mac", "android", "win32", "linux"
"""
# determine proj_path

View File

@ -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)