Esempio n. 1
0
    def UnloadSoundTuneCache(self):
        print("ContentManager.UnloadSoundTuneCache : Clearing FrequencyGenerator Cache...")
        self.SoundTuneCache_Cache.clear()
        self.SoundTuneCache_Names.clear()
        Utils.GarbageCollector_Collect()

        del self.SoundTuneCache_Cache
        del self.SoundTuneCache_Names
        Utils.GarbageCollector_Collect()

        self.SoundTuneCache_Cache = list()
        self.SoundTuneCache_Names = list()
        Utils.GarbageCollector_Collect()
        print("ContentManager.UnloadSoundTuneCache : Done")
Esempio n. 2
0
    def UnloadImage(self):
        """
        Unload all loaded sprites
        :return:
        """
        print("Image.Unload : Unloading Images...")
        Utils.GarbageCollector_Collect()
        del self.Images_Data
        del self.Images_Name
        del CurrentLoadedFonts_Name
        Utils.GarbageCollector_Collect()

        self.Images_Data = list()
        self.Images_Name = list()

        print("Image.Unload : Done")
Esempio n. 3
0
    def ReloadRegistry(self):
        """
        Reload all Registry Keys
        :return:
        """
        print("Taiyou.ContentManager.ReloadRegistry : Reloading Registry...")
        self.UnloadRegistry()
        
        self.LoadRegKeysInFolder()

        Utils.GarbageCollector_Collect()
Esempio n. 4
0
    def UnloadRegistry(self):
        """
        Unload all registry keys
        :return:
        """

        # -- Clear the Registry -- #
        print("Taiyou.ContentManager.UnloadRegistry : Unloading Registry")
        self.reg_keys = list()
        self.reg_contents = list()

        Utils.GarbageCollector_Collect()
Esempio n. 5
0
def KillProcessByPID(PID):
    global ProcessListChanged
    Index = GetProcessIndexByPID(PID)

    ProcessList.pop(Index)
    ProcessList_PID.pop(Index)
    ProcessList_Names.pop(Index)
    Utils.GarbageCollector_Collect()

    print("Taiyou : Finished process index: " + str(Index))

    ProcessListChanged = True
Esempio n. 6
0
    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("/", tge.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:
            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()
Esempio n. 7
0
def CreateProcess(Path, ProcessName, pInitArgs=None, pPriority=0):
    """
     Set the Game Object
    :param GameFolder:Folder Path
    :return:
    """
    global ProcessList
    global ProcessList_Names
    global DISPLAY
    global ProcessListChanged
    global ProcessNextPID

    print("TaiyouFramework.CreateProcess : Creating Process: [" + ProcessName +
          "]")

    Path = Path.replace("/", tge.TaiyouPath_CorrectSlash)
    ProcessIndex = len(ProcessList_Names)
    print("ProcessIndex: " + str(ProcessIndex))
    print("Path: " + Path)
    print("ProcessName: " + ProcessName)

    ProcessNextPID += 1

    ProcessList_Names.append(ProcessName)
    Module = importlib.import_module(tge.Get_MainGameModuleName(Path))
    ProcessList.append(
        Module.Process(ProcessNextPID, ProcessName,
                       tge.Get_MainGameModuleName(Path), pInitArgs))
    ProcessList_PID.append(ProcessNextPID)

    importlib.reload(Module)
    del Module

    if tge.Get_MainGameModuleName(Path) in sys.modules:
        sys.modules.pop(tge.Get_MainGameModuleName(Path))
    Utils.GarbageCollector_Collect()

    # Inject Variables and Functions
    Index = ProcessList_PID.index(ProcessNextPID)
    ProcessList[Index].PROCESS_INDEX = ProcessIndex
    ProcessList[Index].WINDOW_DRAG_ENABLED = False
    ProcessList[Index].APPLICATION_HAS_FOCUS = True
    ProcessList[Index].EXECUTABLE_PATH = Path
    ProcessList[Index].PRIORITY = pPriority

    ProcessListChanged = True

    # Initialize
    try:
        # Intialize Process Code
        ProcessList[Index].Initialize()

    except Exception as ex:
        # Remove the last item from the lists
        print("TaiyouFramework.CreateProcess : Process: [" + ProcessName +
              "] thrown an error on while trying to initialize")

        del ProcessList[-1]
        del ProcessList_PID[-1]
        del ProcessList_Names[-1]
        Utils.GarbageCollector_Collect()

        raise ex

    print("TaiyouFramework.CreateProcess : Process: [" + ProcessName +
          "] created successfully.")

    return ProcessNextPID