Exemplo n.º 1
0
 def runInNewThread(self):
     t = threading.Thread(target=self.makeWinPack)
     t.start()
     print('started')
     t.join()
     print('finished')
     getMessageBoxYesNo("Packing finised. Please check your PROJECT_NAME/Package folder.", "OK")
Exemplo n.º 2
0
    def deleteAsset(self, item, instance):

        self.assetsStore = JsonStore('projects/' +
                                     self.engineConfig.currentProjectName +
                                     '/data/assets.json')
        currElements = self.assetsStore.get('assetsComponentArray')['elements']

        isDeleted = False
        for index, itemA in enumerate(currElements):
            if itemA['name'] == item['name']:
                currElements.pop(index)
                isDeleted = True
                self.assetsStore.put('assetsComponentArray',
                                     elements=currElements)
                break

        if isDeleted == True:
            self.engineRoot.resourceGUIContainer.selfUpdate()
            self.selfUpdate(currElements)
            rmtree('projects/' + self.engineConfig.currentProjectName +
                   '/data/' + item['name'])
        else:
            getMessageBoxYesNo(
                message="Something wrong with delete operation.",
                msgType="OK",
                callback=wtf)
    def resolveAssetPathFolder(self, typeOfAsset):

        CURRENT_ASSETPACK_PATH = os.path.abspath(
          os.path.join(os.path.dirname(__file__), '../../projects/' + self.engineConfig.currentProjectName + "/data/" + self.assetName.text)
        )

        collectExt = ''
        local = self.fileBrowser.selection[0][::-1]
        for item in local:
            if item == '.':
                print("Create Image Resource -> Break EXT = ", collectExt)
                break
            else:
                collectExt += item;
        collectExt = collectExt[::-1]
        # print(collectExt)

        if not os.path.exists(CURRENT_ASSETPACK_PATH):
            print("MAKE_ASSETS_PACK_DIR")
            os.mkdir(CURRENT_ASSETPACK_PATH)
        else:
            if self.currentAsset == None:
                print("SOMETHIND WRONG - ASSETS ALREADY EXIST")
                getMessageBoxYesNo(
                    message="Asset reference path with this name already exist. Please use some different name.",
                    msgType="OK")
                    #callback=wtf)
                return None

        self.operationStatus = False
        print("Assets pack write meta data...")
        copyfile(self.fileBrowser.selection[0], CURRENT_ASSETPACK_PATH + '/' + str(self.assetName.text) + '.' + collectExt)
        self.assetsStore = JsonStore(self.engineConfig.currentProjectAssetPath+ '/assets.json')
        localElements = self.assetsStore.get('assetsComponentArray')['elements']

        asset = {
            'name': self.assetName.text,
            'type': typeOfAsset,
            'ext': collectExt,
            'source': CURRENT_ASSETPACK_PATH + '/' + str(self.assetName.text) + '.' + collectExt,
            'path': 'projects/' + self.engineConfig.currentProjectName + "/data/"+ str(self.assetName.text) + "/" + str(self.assetName.text) + "." + collectExt,
            'version': self.engineConfig.getVersion()
        }

        # Check it if exist
        localCheckDouble = False
        for checkItem in localElements:
            if checkItem['name'] == asset['name']:
                localCheckDouble = True
                getMessageBoxYesNo(
                    message="Asset reference with this name already exist. Please use some different name.",
                    msgType="OK")
                    #callback=wtf)
        if localCheckDouble == False:
            localElements.append(asset)
            self.assetsStore.put('assetsComponentArray', elements=localElements)
            self.engineRoot.resourceGUIContainer.selfUpdate()
Exemplo n.º 4
0
    def resolveAssetPathFolder(self):

        if len(self.fileBrowser.selection) == 0:

            def wtf():
                print('wtf')

            getMessageBoxYesNo(
                message="Nothing to update. Please select new source file.",
                msgType="OK",
                callback=wtf)
            return 0

        CURRENT_ASSETPACK_PATH = os.path.abspath(
            os.path.join(
                os.path.dirname(__file__),
                '../../projects/' + self.engineConfig.currentProjectName +
                "/data/" + self.assetName.text))

        collectExt = ''
        print("Create Image Resource ->")
        local = self.fileBrowser.selection[0][::-1]
        for item in local:
            if item == '.':
                print("Create Image Resource -> Break EXT = ", collectExt)
                break
            else:
                collectExt += item
        collectExt = collectExt[::-1]
        print(collectExt)

        if not os.path.exists(CURRENT_ASSETPACK_PATH):
            print("MAKE ASSETS PACK DIR")
            os.mkdir(CURRENT_ASSETPACK_PATH)
        else:
            if self.currentAsset == None:
                print('current asset need load')
                print("SOMETHIND WRONG - ASSETS ALREADY EXIST")
                return None

        print("Assets pack write meta data.")

        copyfile(
            self.fileBrowser.selection[0], CURRENT_ASSETPACK_PATH + '/' +
            str(self.assetName.text) + '.' + collectExt)
        self.assetsStore = JsonStore(
            self.engineConfig.currentProjectAssetPath + '/assets.json')
        localElements = self.assetsStore.get(
            'assetsComponentArray')['elements']

        ########################
        # Must be detail show
        if self.currentAsset != None:
            print('# Must be detail show')

        ########################
        asset = {
            'name':
            self.assetName.text,
            'type':
            'ImageResource',
            'ext':
            collectExt,
            'source':
            CURRENT_ASSETPACK_PATH + '/' + str(self.assetName.text) + '.' +
            collectExt,
            'path':
            'projects/' + self.engineConfig.currentProjectName + "/data/" +
            str(self.assetName.text) + "/" + str(self.assetName.text) + "." +
            collectExt,
            'version':
            self.engineConfig.getVersion()
        }

        localCheckIsExist = False
        for _index, item in enumerate(localElements):
            if item['name'] == asset['name']:
                localCheckIsExist = True
                localElements[_index] = asset

        def catchErr1():
            print("catchErr1")

        if localCheckIsExist == True:
            self.assetsStore.put('assetsComponentArray',
                                 elements=localElements)
            # resourceGUIContainer
            self.popup.dismiss()
        else:
            getMessageBoxYesNo(
                message='Something wrong with updating asset name => ' +
                asset['name'],
                msgType='OK',
                callback=catchErr1)