def getExePath(): settings = helper.loadSettings("Legend") ret = settings.get("legend_path", "") if len(ret) == 0: sublime.error_message("EXE path is not set!") return False return ret
def getStoragePath(): settings = helper.loadSettings("Legend") ret = settings.get("storage_path", "") if len(ret) == 0: sublime.error_message("Storage path is not set!") return False return ret
def on_done(self, index): if index == -1: return item = self.matchList[index] src_file = helper.loadSettings("Cocos2dJSDev").get("cocos2d_html5_root") + "/" + item[2] line_no = helper.line_no_in_text(src_file, item[3]) self.view.window().open_file(src_file + ":" + str(line_no), sublime.ENCODED_POSITION)
def checkRoot(showError=True): settings = helper.loadSettings("lufylegendDev") lufylegend_root = settings.get("lufylegend_root", "") if len(lufylegend_root)==0 and showError: sublime.error_message("lufylegend_root no set") return False return lufylegend_root
def on_done(self, path, name): filePath = os.path.join(path, name) if os.path.exists(filePath): sublime.error_message("Unable to create file, file exists.") else: code = luaTemplate # add attribute settings = helper.loadSettings("quick-comminuty-dev") format = settings.get("date_format", "%Y-%m-%d %H:%M:%S") date = datetime.datetime.now().strftime(format) code = code.replace("${date}", date) author=settings.get("author", "Your Name") code = code.replace("${author}", author) _name=settings.get("_name", name) code = code.replace("${_name}", _name) _myclass = _name.split('.')[0] code = code.replace("${_class}", _myclass) # save helper.writeFile(filePath, code) v=sublime.active_window().open_file(filePath) # cursor v.run_command("insert_snippet",{"contents":code}) sublime.status_message("Lua file create success!")
def run(self, edit): # select text sel=self.view.substr(self.view.sel()[0]) if len(sel)==0: return # quick_cocos2dx_root settings = helper.loadSettings("quickx") quick_cocos2dx_root = settings.get("quick_cocos2dx_root", "") if len(quick_cocos2dx_root)==0: sublime.error_message("quick_cocos2dx_root no set") return # find all match file matchList=[] showList=[] for item in DEFINITION_LIST: for key in item[0]: if key==sel: matchList.append(item) showList.append(item[1]) if len(matchList)==0: sublime.status_message("Can not find definition '%s'"%(sel)) elif len(matchList)==1: filepath=os.path.join(quick_cocos2dx_root,matchList[0][2]) if os.path.exists(filepath): self.view.window().open_file(filepath+":"+str(matchList[0][3]),sublime.ENCODED_POSITION) else: sublime.status_message("%s not exists"%(filepath)) else: # multi match self.matchList=matchList self.quick_cocos2dx_root=quick_cocos2dx_root on_done = functools.partial(self.on_done) self.view.window().show_quick_panel(showList,on_done)
def create_ant_folder(self): ant_folder = self.target_directory + '/' + 'ant' helper.create_directory(ant_folder) # create build.xml build_file = sublime.packages_path() + "/Cocos2dJSDev/cocos2d_js_lib/ant/build.xml" build_content = helper.readFile(build_file) build_content = build_content.replace("%MODE%", helper.loadSettings("Cocos2dJSDev").get("ant").get("mode")) build_content = build_content.replace("%DEBUG%", helper.loadSettings("Cocos2dJSDev").get("ant").get("debug")) build_content = build_content.replace("%OUTPUT.js%", helper.loadSettings("Cocos2dJSDev").get("ant").get("output")) build_content = build_content.replace("%COMPLIER_JAR_PATH%", sublime.packages_path() + "/Cocos2dJSDev/cocos2d_js_lib/ant") build_content = build_content.replace("%COCOS2D_ROOT_PATH%", helper.loadSettings("Cocos2dJSDev").get("cocos2d_html5_root")) helper.writeFile(ant_folder + "/build.xml", build_content) # create cocos2d_extern.js cocos2d_externs_file = sublime.packages_path() + "/Cocos2dJSDev/cocos2d_js_lib/ant/cocos2d_externs.js" cocos2d_externs_content = helper.readFile(cocos2d_externs_file) helper.writeFile(ant_folder + "/cocos2d_externs.js", cocos2d_externs_content)
def run(self, dirs): settings = helper.loadSettings("QuickXDev") quick_cocos2dx_root = settings.get("quick_cocos2dx_root", "") if len(quick_cocos2dx_root)==0: sublime.error_message("quick_cocos2dx_root no set") return cmdPath="" if sublime.platform()=="osx": cmdPath=quick_cocos2dx_root+"/bin/compile_scripts.sh" elif sublime.platform()=="windows": cmdPath=quick_cocos2dx_root+"/bin/compile_scripts.bat" if not os.path.exists(cmdPath): helper.writeFile(cmdPath,compile_scripts_bat) if cmdPath=="" or not os.path.exists(cmdPath): sublime.error_message("compile_scripts no exists") return self.cmdPath=cmdPath self.compile_scripts_key=settings.get("compile_scripts_key", "") self.window.run_command("hide_panel") output="res/game.zip" on_done = functools.partial(self.on_done, dirs[0]) v = self.window.show_input_panel( "Output File:", output, on_done, None, None) v.sel().clear() v.sel().add(sublime.Region(4, 8))
def run(self, dirs): settings = helper.loadSettings("QuickXDev") quick_cocos2dx_root = settings.get("quick_cocos2dx_root", "") if len(quick_cocos2dx_root) == 0: sublime.error_message("quick_cocos2dx_root no set") return cmdPath = "" if sublime.platform() == "osx": cmdPath = quick_cocos2dx_root + "/bin/compile_scripts.sh" elif sublime.platform() == "windows": cmdPath = quick_cocos2dx_root + "/bin/compile_scripts.bat" if not os.path.exists(cmdPath): helper.writeFile(cmdPath, compile_scripts_bat) if cmdPath == "" or not os.path.exists(cmdPath): sublime.error_message("compile_scripts no exists") return self.cmdPath = cmdPath self.compile_scripts_key = settings.get("compile_scripts_key", "") self.window.run_command("hide_panel") output = "res/game.zip" on_done = functools.partial(self.on_done, dirs[0]) v = self.window.show_input_panel("Output File:", output, on_done, None, None) v.sel().clear() v.sel().add(sublime.Region(4, 8))
def checkRoot(): # quick_cocos2dx_root settings = helper.loadSettings("QuickXDev") quick_cocos2dx_root = settings.get("quick_cocos2dx_root", "") if len(quick_cocos2dx_root)==0: sublime.error_message("quick_cocos2dx_root no set") return False return quick_cocos2dx_root
def checkQuickxRoot(): # quick_cocos2dx_root settings = helper.loadSettings("QuickXDev") quick_cocos2dx_root = settings.get("quick_cocos2dx_root", "") if len(quick_cocos2dx_root) == 0: sublime.error_message("quick_cocos2dx_root no set") return False return quick_cocos2dx_root
def checkCocos2dxRoot(): # cocos2dx_root settings = helper.loadSettings("QuickXDev") cocos2dx_root = settings.get("cocos2dx_root", "") if len(cocos2dx_root) == 0: sublime.error_message("cocos2dx_root no set") return False return cocos2dx_root
def checkUnityVersion(): global U_Version settings = helper.loadSettings("UnityShader") SUnity_Version = settings.get("Unity_Version", "") if (len(SUnity_Version) == 0): U_Version = 4 elif "U4" in SUnity_Version: U_Version = 4 elif "U5" in SUnity_Version: U_Version = 5
def checkUnityVersion(): global U_Version settings = helper.loadSettings("UnityShader") SUnity_Version = settings.get("Unity_Version", "") if( len(SUnity_Version) == 0 ): U_Version =4 elif "U4" in SUnity_Version: U_Version =4 elif "U5" in SUnity_Version: U_Version =5
def run(self, files): # list all browsers self.target_file = files[0] self.browsers = helper.loadSettings("Cocos2dJSDev").get("browsers") self.browser_names = [] for browser_name in self.browsers.keys(): self.browser_names.append(browser_name) # list all browser name select_browser_done = functools.partial(self.select_browser_done) self.window.show_quick_panel(self.browser_names, select_browser_done)
def select_browser_done(self, index): if index == -1: return selected_browser = self.browsers.get(self.browser_names[index]) if not selected_browser or selected_browser == "": sublime.error_message("Browser not set!") else: # is local server set local_server_path = helper.loadSettings("Cocos2dJSDev").get("local_server_path") print(selected_browser) if local_server_path and local_server_path != "": self.target_file = local_server_path + "/" + os.path.basename(self.target_file) webbrowser.get(selected_browser + " %s").open_new_tab(self.target_file)
def on_done(self, path, name): filePath = os.path.join(path, name) if os.path.exists(filePath): sublime.error_message("Unable to create file, file exists.") else: code = template.buildTemplate settings = helper.loadSettings("lufylegendDev") compiler_path=settings.get("google_closure_compiler_path", "") if len(compiler_path)==0: compiler_path="<path>/compiler-latest/compiler.jar" code = code.replace("${compiler}", compiler_path) # save helper.writeFile(filePath, code) sublime.active_window().open_file(filePath) sublime.status_message(name+" create success!")
def run(self, files): settings = helper.loadSettings("lufylegendDev") ant_path = settings.get("ant_path", "") if len(ant_path)==0: sublime.error_message("ant_path no set") return cmdPath=ant_path arr=os.path.split(files[0]) path=arr[0] args=[ant_path,"-buildfile",arr[1]] if sublime.platform()=="osx": subprocess.Popen(args,cwd=path) elif sublime.platform()=="windows": child=subprocess.Popen(args,cwd=path) child.wait() self.window.run_command("refresh_folder_list")
def checkUnityShaderRoot(): global U_Version settings = helper.loadSettings("UnityShader") Shader_path = settings.get("Shader_path", "") if U_Version == 5: U5_path = settings.get("U5_Shader_path", "") if len(U5_path) == 0: sublime.error_message("U5_Shader_path no set") return False else: return U5_path else: if len(Shader_path) == 0: sublime.error_message("Shader_path no set") return False return Shader_path
def on_done(self, path, name): filePath = os.path.join(path, name) if os.path.exists(filePath): sublime.error_message("Unable to create file, file exists.") else: code = luaTemplate # add attribute settings = helper.loadSettings("QuickXDev") format = settings.get("date_format", "%Y-%m-%d %H:%M:%S") date = datetime.datetime.now().strftime(format) code = code.replace("${date}", date) author=settings.get("author", "Your Name") code = code.replace("${author}", author) # save helper.writeFile(filePath, code) v=sublime.active_window().open_file(filePath) # cursor v.run_command("insert_snippet",{"contents":code}) sublime.status_message("Lua file create success!")
def checkUnityShaderRoot(): global U_Version settings = helper.loadSettings("UnityShader") Shader_path = settings.get("Shader_path", "") if U_Version== 5: U5_path =settings.get("U5_Shader_path", "") if len(U5_path)==0: sublime.error_message("U5_Shader_path no set") return False else: return U5_path else: if len(Shader_path)==0 : sublime.error_message("Shader_path no set") return False return Shader_path
def on_done(self, path, name): filePath = os.path.join(path, name) if os.path.exists(filePath): sublime.error_message("Unable to create file, file exists.") else: # load template file tmplPath = os.path.join(CUR_PATH,LIB_PATH, "lua.tmpl") code = helper.readFile(tmplPath) # add attribute settings = helper.loadSettings("quickx") format = settings.get("date_format", "%Y-%m-%d %H:%M:%S") date = datetime.datetime.now().strftime(format) code = code.replace("${date}", date) attr = settings.get("template_attr", {}) for key in attr: code = code.replace("${%s}" % (key), attr.get(key, "")) # save helper.writeFile(filePath, code) v=sublime.active_window().open_file(filePath) # cursor v.run_command("insert_snippet",{"contents":code}) sublime.status_message("Lua file create success!")
def run(self, edit): # select text sel = self.view.substr(self.view.sel()[0]) if len(sel) == 0: return # find all match file self.matchList = [] showList = [] for item in DEFINITION_LIST: if item[0] == sel: self.matchList.append(item) showList.append(item[1]) if len(self.matchList) == 0: sublime.error_message("Can not find definition '%s'"%(sel)) elif len(self.matchList) == 1: src_file = helper.loadSettings("Cocos2dJSDev").get("cocos2d_html5_root") + "/" + self.matchList[0][2] line_no = helper.line_no_in_text(src_file, self.matchList[0][3]) self.view.window().open_file(src_file + ":" + str(line_no), sublime.ENCODED_POSITION) else: # multi match on_done = functools.partial(self.on_done) self.view.window().show_quick_panel(showList, on_done)
def loadRoot(): global lufylegend_root settings = helper.loadSettings("lufylegendDev") lufylegend_root = settings.get("lufylegend_root", "")
def loadRoot(): global quick_cocos2dx_root settings = helper.loadSettings("QuickXDev") quick_cocos2dx_root = settings.get("quick_cocos2dx_root", "")
def runWithPlayer(scriptsDir): global process # root quick_cocos2dx_root = checkRoot() if not quick_cocos2dx_root: return # player path for platform playerPath="" if sublime.platform()=="osx": playerPath=quick_cocos2dx_root+"/player/mac/player.app/Contents/MacOS/player" elif sublime.platform()=="windows": playerPath=quick_cocos2dx_root+"/player/win/player.exe" if playerPath=="" or not os.path.exists(playerPath): sublime.error_message("player no exists") return args=[playerPath] # param path=scriptsDir args.append("-workdir") args.append(os.path.split(path)[0]) args.append("-file") args.append("scripts/main.lua") args.append("-load-framework") configPath=path+"/config.lua" if os.path.exists(configPath): f=codecs.open(configPath,"r","utf-8") width=640 height=960 while True: line=f.readline() if line: # debug m=re.match("^DEBUG\s*=\s*(\d+)",line) if m: debug=m.group(1) if debug=="0": args.append("-disable-write-debug-log") args.append("-disable-console") elif debug=="1": args.append("-disable-write-debug-log") args.append("-console") else: args.append("-write-debug-log") args.append("-console") else: break f.close() settings = helper.loadSettings("QuickXDev") # resolution by [email protected] width = str(settings.get("player_width", 640)) height = str(settings.get("player_height", 960)) args.append("-size") args.append(width+"x"+height) if process: try: process.terminate() except Exception: pass if sublime.platform()=="osx": process=subprocess.Popen(args) elif sublime.platform()=="windows": process=subprocess.Popen(args)
def check_root(): settings = helper.loadSettings("Cocos2dJSDev") cocos2d_html5_root = settings.get("cocos2d_html5_root", "") if len(cocos2d_html5_root) == 0: return False return True
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = "Gerrit Wyen <*****@*****.**>" __license__ = "GNU General Public License v2 or later (GPLv2+)" from Gui import Gui from helper import loadSettings if __name__=="__main__": settings = loadSettings() camgui = Gui(settings) camgui.runMainLoop()