def LoadRegKeysInFolder(self): """ Load all keys on Specified Folder :param reg_dir:Specified Folder :return: """ if self.Reg_Path == "": raise Exception("Registry Path was not set.") reg_dir = self.Reg_Path # -- FIX for working on Windows -- # self.Reg_Path = self.SourceFolder + reg_dir.replace( self.SourceFolder, "") self.Reg_Path = self.Reg_Path.replace( "/", CorePaths.TaiyouPath_CorrectSlash) start_time = time.time() # -- Unload the Registry -- # self.UnloadRegistry() print("Taiyou.ContentManager.LoadRegistry : Loading Registry...") temp_reg_keys = UTILS.Directory_FilesList(reg_dir) index = -1 for x in temp_reg_keys: if self.StopLongOperations: break index += 1 CorrectKeyName = x.replace(reg_dir, "").replace(".data", "") file = open(x, "r") CurrentLine = file.read().splitlines() AllData = "" for x in CurrentLine: if not x.startswith("#"): AllData += x + "\n" # -- Format the Text -- # AllData = AllData.rstrip().replace("%n", "\n").replace( "%t", "\t").replace("%s", " ") self.reg_keys.append(CorrectKeyName) self.reg_contents.append(AllData) print("Taiyou.ContentManager.LoadRegistry : KeyLoaded[" + CorrectKeyName + "]") print( "Taiyou.ContentManager.LoadRegistry : Total of {0} registry keys loaded. In {1} seconds." .format(str(len(self.reg_keys)), UTILS.FormatNumber(time.time() - start_time, 4))) UTILS.GarbageCollector_Collect()
def LoadApplicationsList(self): # List all valid folders folder_list = CoreUtils.Directory_FilesList( "." + CorePaths.TaiyouPath_CorrectSlash) BootFolders = list() for file in folder_list: if file.endswith(CorePaths.TaiyouPath_CorrectSlash + "boot"): BootFolders.append(file) ListInstalledApplications(BootFolders, self.ApplicationSelector) if len(BootFolders) == 0 or len( self.ApplicationSelector.SeletorItems_ModulePath) == 0: self.NoFoldersFound = True
def UpdateFileList(self): print("Load : Updating File List...") self.FolderList.ClearItems() AllFilesInDir = Utils.Directory_FilesList( CorePaths.GetAppDataFromAppName("OneTrack")) for file in AllFilesInDir: # Check if file is a valid OneTrack Project if file.endswith(".oneprj"): FileAllPath = file FileName = file.replace( CorePaths.GetAppDataFromAppName("OneTrack"), "").replace(".oneprj", "") ItemName = FileName[1:] ItemDescription = "Saved on: {0}".format(FileAllPath) self.FolderList.AddItem(ItemName, ItemDescription)
def LoadSoundsInFolder(self): """ Load all sounds on the specified folder\n :param FolderName:Folder Path Name :return: """ if SoundDisabled: return if self.Sound_Path == "": raise Exception("Sound Path was not set.") FolderName = self.Sound_Path self.InitSoundSystem() temp_sound_files = UTILS.Directory_FilesList(FolderName) index = -1 print("ContentManager.LoadSoundsInFolder : Loading Sounds") for x in temp_sound_files: if self.StopLongOperations: break try: index += 1 print("\nContentManager.LoadSoundsInFolder : File[" + x + "] detected; Index[" + str(index) + "]") CorrectKeyName = x.replace(FolderName, "") self.AllLoadedSounds[CorrectKeyName] = (pygame.mixer.Sound(x)) except pygame.error: break print("ContentManager.LoadSoundsInFolder : ItemAdded[" + CorrectKeyName + "]; Index[" + str(index) + "]\n") print("ContentManager.LoadSoundsInFolder : Operation Completed")
def UpdatePackpageList(self): print("Updating Packpages lists...") self.PackpageVerticalList.ClearItems() self.PackpageVerticalList.ResetSelectedItem() PackpagesList = CoreUtils.Directory_FilesList(CorePaths.TaiyouPath_UserPackpagesPath) for Packpage in PackpagesList: if Packpage.endswith(self.ContentManager.Get_RegKey("packpage_file_format")): Name = Packpage.rstrip().replace(CorePaths.TaiyouPath_UserPackpagesPath, "").replace(self.ContentManager.Get_RegKey("packpage_file_format"), "") print("Found Packpage {0}".format(Name)) self.PackpageVerticalList.AddItem(Name, self.ContentManager.Get_RegKey("packpage_description")) if len(self.PackpageVerticalList.ItemsName) == 0: print("No packpages has been found.") self.NoPackpagesFoundMode = True self.SetStatusText(self.ContentManager.Get_RegKey("/strings/no_packpage_found_mode_title")) self.DownToolbar.GetWidget(1).SetText(self.ContentManager.Get_RegKey("/strings/no_packpage_found_mode_refresh")) else: self.NoPackpagesFoundMode = False print("Some packpage has been found.") self.DownToolbar.GetWidget(1).SetText(self.ContentManager.Get_RegKey("/strings/install_button")) self.SetStatusText(self.ContentManager.Get_RegKey("/strings/select_app_list"))
def __init__(self, pPID, pProcessName, pROOT_MODULE, pInitArgs, pProcessIndex): self.ImagesHasBeenLoaded = False self.Timer = pygame.time.Clock() self.BootloaderKeys = Core.CntMng.ContentManager() self.BootloaderKeys.SetSourceFolder("", True) self.BootloaderKeys.SetRegKeysPath("reg/BOOTLOADER") self.BootloaderKeys.LoadRegKeysInFolder() # Load DefaultUI Contents UI.SystemResources = Core.CntMng.ContentManager() UI.SystemResources.SetSourceFolder("", True) UI.SystemResources.SetFontPath("fonts") UI.SystemResources.SetImageFolder("img") UI.SystemResources.SetRegKeysPath("reg") UI.SystemResources.SetSoundPath("sound") UI.SystemResources.SetFontPath("fonts") UI.SystemResources.InitSoundSystem() UI.SystemResources.LoadRegKeysInFolder() UI.SystemResources.LoadSoundsInFolder() UI.SystemSoundsVolume = float( UI.SystemResources.Get_RegKey("UI/system_sounds_volume")) self.DefaultContent = UI.SystemResources self.Progress = 0 self.ProgressAddDelay = 0 self.ProgressProgression = True self.ProgressMax = 2 self.LoadingComplete = False self.InitialLoadingDelay = 0 self.LastProgress = 0 self.NoFoldersFound = False self.FatalErrorScreen = False self.ApplicationSeletorWelcomeSound = False self.InitialSignal = False super().__init__(pPID, pProcessName, pROOT_MODULE, pInitArgs, pProcessIndex) self.CenterX = self.DISPLAY.get_width() / 2 self.CenterY = self.DISPLAY.get_height() / 2 self.ApplicationSeletor = False self.ApplicationSeletorAnimatorStart = UTILS.AnimationController( 0.5, multiplierRestart=True) self.ApplicationSelectorObj = ApplicationSelector( self.DefaultContent, self.CenterX - 550 / 2, self.CenterY - 120 / 2) # List all valid folders folder_list = UTILS.Directory_FilesList( "." + CorePaths.TaiyouPath_CorrectSlash) BootFolders = list() for file in folder_list: if file.endswith(CorePaths.TaiyouPath_CorrectSlash + "boot"): BootFolders.append(file) ListInstalledApplications(BootFolders, self.ApplicationSelectorObj) if len(BootFolders) == 0 or len( self.ApplicationSelectorObj.SeletorItems_Index) == 0: self.NoFoldersFound = True