Beispiel #1
0
    def Update(self):
        if not self.FileListUpdate:
            self.FileListUpdate = True
            self.UpdateFileList()

        #-------------------------------
        self.FolderList.Set_W(self.RootProcess.DISPLAY.get_width())
        self.FolderList.Set_H(self.RootProcess.DISPLAY.get_height() - 35)
        self.FolderList.ColisionXOffset = self.RootProcess.POSITION[
            0] + self.FolderList.Rectangle[0]
        self.FolderList.ColisionYOffset = self.RootProcess.POSITION[
            1] + 15 + self.FolderList.Rectangle[1]
        #-------------------------------
        self.OptionsBar.ColisionXOffset = self.RootProcess.POSITION[0]
        self.OptionsBar.ColisionYOffset = self.RootProcess.POSITION[1] + 15
        #--------------------------------
        self.Inputbox_FileName.ColisionOffsetX = self.RootProcess.POSITION[0]
        self.Inputbox_FileName.ColisionOffsetY = self.RootProcess.POSITION[
            1] + 15

        self.OptionsBar.Update()

        if not self.EnterFileNameEnabled:
            SelectedFile = self.FolderList.LastItemClicked

            if self.OptionsBar.ClickedButtonIndex == 0:
                self.OptionsBar.ClickedButtonIndex = -1

                if not SelectedFile == "null":
                    self.RootProcess.RootProcess.CurrentScreenToUpdate.SaveMusicData(
                        CorePaths.GetAppDataFromAppName("OneTrack") +
                        CorePaths.TaiyouPath_CorrectSlash + SelectedFile)
                    print("Music Data has been saved. on\n{0}".format(
                        SelectedFile))
                    CoreWMControl.WindowManagerSignal(self.RootProcess, 1)

            if self.OptionsBar.ClickedButtonIndex == 1:
                self.EnterFileNameEnabled = True

        else:
            if self.OptionsBar.ClickedButtonIndex == 1:

                # -- Write the File -- #
                if not self.Inputbox_FileName.text == "":
                    self.Inputbox_FileName.text = self.Inputbox_FileName.text.replace(
                        " ", "_")
                    self.RootProcess.RootProcess.CurrentScreenToUpdate.SaveMusicData(
                        CorePaths.GetAppDataFromAppName("OneTrack") +
                        CorePaths.TaiyouPath_CorrectSlash +
                        self.Inputbox_FileName.text)

                    print("Music Data has been created. on\n{0}".format(
                        self.Inputbox_FileName.text))
                    CoreWMControl.WindowManagerSignal(self.RootProcess, 1)
Beispiel #2
0
    def Update(self):
        if not self.FileListUpdated:
            self.FileListUpdated = True
            self.UpdateFileList()

        self.FolderList.Set_W(self.RootProcess.DISPLAY.get_width())
        self.FolderList.Set_H(self.RootProcess.DISPLAY.get_height() - 35)

        # -------------------------------------------------
        self.FolderList.ColisionXOffset = self.RootProcess.POSITION[
            0] + self.FolderList.Rectangle[0]
        self.FolderList.ColisionYOffset = self.RootProcess.POSITION[
            1] + 15 + self.FolderList.Rectangle[1]

        self.OptionsBar.Update()
        #-------------------------------
        self.OptionsBar.ColisionXOffset = self.RootProcess.POSITION[0]
        self.OptionsBar.ColisionYOffset = self.RootProcess.POSITION[1] + 15

        SelectedFile = self.FolderList.LastItemClicked

        if self.OptionsBar.ClickedButtonIndex == 0:
            self.OptionsBar.ClickedButtonIndex = -1

            if not SelectedFile == "null":
                self.RootProcess.RootProcess.CurrentScreenToUpdate.LoadMusicData(
                    CorePaths.GetAppDataFromAppName("OneTrack") +
                    CorePaths.TaiyouPath_CorrectSlash + SelectedFile)
                CoreWMControl.WindowManagerSignal(self.RootProcess, 1)
Beispiel #3
0
    def CloseSelectedProcess(self):
        if self.WindowList.LastItemIndex is not None:
            try:
                ProcessPID = self.WindowList.ItemProperties[
                    self.WindowList.LastItemIndex]
                CoreAccess.KillProcessByPID(ProcessPID)

                self.DefaultContent.PlaySound("/click.wav",
                                              UI.SystemSoundsVolume)

            except IndexError:
                self.WindowList.ResetSelectedItem()

            except Exception:
                Core.MAIN.SystemFault_Trigger = True
                Core.MAIN.SystemFault_Traceback = traceback.format_exc()
                Core.MAIN.SystemFault_ProcessObject = None
                WmControl.WindowManagerSignal(None, 4)

                print(
                    "AppSeletorModeInstance : Process Error Detected\nin Process PID(unknow)"
                )
                print("Traceback:\n" + Core.MAIN.SystemFault_Traceback)

                # Generate the Crash Log
                Core.MAIN.GenerateCrashLog()
                self.RootObj.SetMode(1)
                self.RootObj.Toggle()
Beispiel #4
0
def Update():
    global UnatachedDialogOpened
    global Enabled
    global OtherProcessPID

    if not Enabled:
        return

    # Open Dialog Process
    if not UnatachedDialogOpened:
        UnatachedDialogOpened = True
        Main.var.DisableControls = True
        Main.var.AwaysUpdate = True
        OtherProcessPID = CoreAccess.CreateProcess(
            "OneTrack/UnatachedDialog", "OneTrack File Operation",
            (var.ProcessReference, "OPEN"))

    # Operation has been completed
    if not OtherProcessPID in CoreAccess.ProcessAccess_PID:
        var.AwaysUpdate = False
        var.DisableControls = False
        Enabled = False
        UnatachedDialogOpened = False

        CoreWMControl.WindowManagerSignal(var.ProcessReference, 0)
Beispiel #5
0
    def SwitchToSelectedProcess(self):
        if self.WindowList.LastItemIndex is not None:
            try:
                ProcessPID = self.WindowList.ItemProperties[
                    self.WindowList.LastItemIndex]
                Process = CoreAccess.ProcessAccess[
                    CoreAccess.ProcessAccess_PID.index(ProcessPID)]

                WmControl.WindowManagerSignal(Process, 0)

                self.RootObj.RootProcess.UI_Call_Request()

                self.DefaultContent.PlaySound("/click.wav",
                                              UI.SystemSoundsVolume)

            except IndexError:
                self.WindowList.ResetSelectedItem()
Beispiel #6
0
    def EventUpdate(self, event):
        if self.ApplicationSeletor:
            self.ApplicationSelectorObj.EventUpdate(event)

            if event.type == pygame.KEYUP and event.key == pygame.K_RETURN:
                if not self.ApplicationSelectorObj.SelectedItemIndex == -1:
                    try:
                        # Create the Application Process
                        CoreAccess.CreateProcess(
                            self.ApplicationSelectorObj.SelectedItemModulePath,
                            self.ApplicationSelectorObj.SelectedItemModulePath)

                        # Allow Window Manager do receive request
                        WmControl.WindowManagerSignal(None, 4)

                        # Kills the Bootloader process
                        CoreAccess.KillProcessByPID(self.PID)

                    except Exception as e:
                        Traceback = traceback.format_exc()

                        self.GenerateCrashLog(
                            Traceback,
                            self.ApplicationSelectorObj.SelectedItemModulePath)

                        print(Traceback)
                        self.FatalErrorScreen = True
                        self.ApplicationSeletor = True
                        self.APPLICATION_HAS_FOCUS = True

        else:
            if event.type == pygame.KEYUP and event.key == pygame.K_ESCAPE and self.Progress < 3:
                self.LoadingComplete = True
                self.LoadingBarProgress = 0
                self.Progress = 0
                self.ProgressAddDelay = 0
                self.ProgressProgression = False

                self.ApplicationSeletor = True

        if self.FatalErrorScreen:
            if event.type == pygame.KEYUP and event.key == pygame.K_ESCAPE:
                self.FatalErrorScreen = False
                self.ApplicationSeletor = True
Beispiel #7
0
    def Update(self):
        if self.ApplicationSeletor:
            self.ApplicationSeletorAnimatorStart.Update()

            if self.ApplicationSeletorAnimatorStart.Value <= 10 and not self.FatalErrorScreen:
                self.ApplicationSeletorAnimatorStart.Enabled = True

            if not self.ApplicationSeletorWelcomeSound and not self.FatalErrorScreen:
                self.ApplicationSeletorWelcomeSound = True

                self.DefaultContent.PlaySound("/intro.wav")
            return

        if self.ProgressProgression and not self.LoadingComplete:
            self.ProgressAddDelay += 1

            if self.ProgressAddDelay == 5:
                self.ProgressAddDelay = 0
                self.Progress += 1

            if self.ProgressAddDelay == 1:
                self.LoadingSteps(self.Progress)

            if self.Progress >= self.ProgressMax and not self.LoadingComplete:
                self.LoadingComplete = True

                print("Taiyou.Bootloader : Loading Complete")

                # Start the Default Application
                CreatedProcessPID = 0
                try:
                    print(
                        "Taiyou.Bootloader : Loading has been completed\nStarting user selected applicaton..."
                    )
                    # Create the Application Process
                    CreatedProcessPID = CoreAccess.CreateProcess(
                        Core.GetUserSelectedApplication(),
                        Core.GetUserSelectedApplication())

                    # Allow Window Manager to receive request
                    WmControl.WindowManagerSignal(None, 4)

                    # Kills the Bootloader process
                    self.KillProcess(False)

                except Exception:
                    print(
                        "Taiyou.Bootloader : Fatal Error : Error while creating the process to the Auto-Start Application."
                    )

                    Traceback = traceback.format_exc()
                    print(Traceback)

                    CoreAccess.KillProcessByPID(CreatedProcessPID)

                    # Check if SelectedFile wax exists
                    try:
                        UserSelectedApplication = Core.GetUserSelectedApplication(
                        )

                        self.GenerateCrashLog(Traceback,
                                              UserSelectedApplication)
                        print(
                            "Something bad happened while creating the process for the default application."
                        )

                        self.FatalErrorScreen = True
                        self.ApplicationSeletor = True
                        self.APPLICATION_HAS_FOCUS = True

                    except:
                        print("Selected application file is not readable.")
                        self.ApplicationSeletor = True
                        self.APPLICATION_HAS_FOCUS = True
Beispiel #8
0
    def DrawProcess(self, process):
        if process is None:
            return

        try:
            # Set Cursor
            self.CurrentCursor = process.CURSOR

            # If is fullscreen process, just draw at max resolution at 0, 0
            if process.FULLSCREEN:
                # If application has focus, draw again it's content
                if process.APPLICATION_HAS_FOCUS:
                    self.DrawFullscreenProcess(process)

                # If not, just draw a copy of its screen
                self.DrawFullscreenProcess(process)

                if not process.APPLICATION_HAS_FOCUS:
                    WindowGeometry = [
                        process.POSITION[0], process.POSITION[1],
                        process.DISPLAY.get_width() + 1,
                        process.DISPLAY.get_height()
                    ]
                    process.TITLEBAR_RECTANGLE = pygame.Rect(
                        WindowGeometry[0], WindowGeometry[1],
                        DISPLAY.get_width(), 15)

                    # Draw the title bar
                    TitleBarColor = UI.ThemesManager_GetProperty(
                        "WM_FullscreenWindowTitleBarColor")
                    TextColor = UI.ThemesManager_GetProperty(
                        "WM_FullscreenWindowTitleBarTextColor")

                    Shape.Shape_Rectangle(
                        DISPLAY, TitleBarColor,
                        (0, 0, process.TITLEBAR_RECTANGLE[2] + 1,
                         process.TITLEBAR_RECTANGLE[3]))

                    # Draw Title Bar Text
                    TitleBarText = process.TITLEBAR_TEXT
                    FontSize = 12
                    Font = "/Ubuntu.ttf"

                    self.DefaultContent.FontRender(
                        DISPLAY, Font, FontSize, TitleBarText, TextColor,
                        DISPLAY.get_width() / 2 -
                        self.DefaultContent.GetFont_width(
                            Font, FontSize, TitleBarText) / 2, 0)
                return

            # If not, draw window decoration
            if not process.FRAMELESS:
                DISPLAY.blit(self.DrawWindow(process.LAST_SURFACE, process),
                             (process.POSITION[0], process.POSITION[1]))
            else:
                DISPLAY.blit(process.LAST_SURFACE,
                             (process.POSITION[0], process.POSITION[1]))

        except:
            Core.MAIN.SystemFault_Trigger = True
            Core.MAIN.SystemFault_Traceback = traceback.format_exc()
            Core.MAIN.SystemFault_ProcessObject = process
            self.FocusedProcess = None
            self.TaskBarInstance.SetMode(1)
            WmControl.WindowManagerSignal(None, 4)
            self.UI_Call_Request()
            print(
                "TaiyouApplicationDrawLoop : Process Error Detected\nin Process PID({0})"
                .format(process.PID))
            print("Traceback:\n" + Core.MAIN.SystemFault_Traceback)

            # Kill the Process
            try:
                Core.MAIN.KillProcessByPID(process.PID)
            except:
                print("Error while killing process")

            # Generate the Crash Log
            Core.MAIN.GenerateCrashLog()
            return
Beispiel #9
0
    def UpdateProcessWindowDrag(self, event, process):
        if self.FocusedProcess is None:
            return

        if self.FocusedProcess.FULLSCREEN or self.FocusedProcess.FRAMELESS:
            return

        if self.SomeWindowIsBeingMoved:
            if self.SomeWindowIsBeingMoved_PID != process.PID:
                return

        FocusedProcessColisor = pygame.Rect(
            self.FocusedProcess.POSITION[0], self.FocusedProcess.POSITION[1],
            self.FocusedProcess.DISPLAY.get_width(),
            self.FocusedProcess.DISPLAY.get_height())

        # Colisor = pygame.Rect(process.TITLEBAR_RECTANGLE[0], process.TITLEBAR_RECTANGLE[1], process.TITLEBAR_RECTANGLE[2], process.DISPLAY.get_height())

        # When clicking on the titlebar of focused process
        if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
            # Dont allow moving the window when another titlebar is behind the window
            if process.PID != self.FocusedProcess.PID and FocusedProcessColisor.collidepoint(
                    pygame.mouse.get_pos()):
                return

            pos = pygame.mouse.get_pos()

            if process.PID != self.FocusedProcess.PID and self.DefaultContent.Get_RegKey(
                    "UI/window_clicking_focus").lower() == "true":
                WindowColisor = pygame.Rect(process.TITLEBAR_RECTANGLE[0],
                                            process.TITLEBAR_RECTANGLE[1],
                                            process.DISPLAY.get_width(),
                                            process.DISPLAY.get_height())

                if WindowColisor.collidepoint(pos):
                    WmControl.WindowManagerSignal(process, 0)

            # Start moving the window
            if process.TITLEBAR_RECTANGLE.collidepoint(pos):
                process.WINDOW_DRAG_ENABLED = True
                self.SomeWindowIsBeingMoved = True
                self.SomeWindowIsBeingMoved_PID = process.PID
                process.WINDOW_DRAG_SP = (process.TITLEBAR_RECTANGLE[0] -
                                          pos[0],
                                          process.TITLEBAR_RECTANGLE[1] -
                                          pos[1])

                WmControl.WindowManagerSignal(process, 0)

        # When releasing the button on focused process titlebar
        elif event.type == pygame.MOUSEBUTTONUP:
            if process.WINDOW_DRAG_ENABLED:
                process.WINDOW_DRAG_ENABLED = False
                self.SomeWindowIsBeingMoved = False
                self.SomeWindowIsBeingMoved_PID = -1

        # Move window when moving window
        if process.WINDOW_DRAG_ENABLED and process.APPLICATION_HAS_FOCUS and self.SomeWindowIsBeingMoved_PID == process.PID:
            pos = pygame.mouse.get_pos()

            self.SomeWindowIsBeingMoved = True
            self.SomeWindowIsBeingMoved_PID = process.PID

            process.POSITION = (process.WINDOW_DRAG_SP[0] + pos[0],
                                process.WINDOW_DRAG_SP[1] + pos[1])
Beispiel #10
0
    def Initialize(self):
        print("Initialize OneTrack Dialog")
        self.SetVideoMode(False, (400, 320))
        self.SetTitle("OneTrack Dialog")
        self.RootDefaultContents = None
        # Focus to this window
        CoreWMControl.WindowManagerSignal(self, 0)

        # Initialize Content Manager
        self.DefaultContents = CntMng.ContentManager()
        self.DefaultContents.SetSourceFolder("OneTrack_data/UnatachedDialog/")
        self.DefaultContents.SetFontPath("fonts")
        self.DefaultContents.SetImageFolder("img")
        self.DefaultContents.SetRegKeysPath("reg")

        self.DefaultContents.LoadRegKeysInFolder()
        self.DefaultContents.LoadImagesInFolder()

        self.DefaultContents.InitSoundSystem()

        self.RootProcess = self.INIT_ARGS[0]
        self.OperationType = self.INIT_ARGS[1]

        try:
            self.OptionalParameters = self.INIT_ARGS[3]
            print("Optional parameters set")

        except IndexError:
            self.OptionalParameters = None
            print("No optional parameters set")

        self.SelectedModuleMode = None

        if self.OperationType == "OPEN":
            self.SelectedModuleMode = LoadFileScreen.Screen(self)

        elif self.OperationType == "SAVE":
            self.SelectedModuleMode = SaveFileScreen.Screen(self)

        elif self.OperationType == "DIALOG_OK":
            self.SelectedModuleMode = DialogOkOnlyScreen.Screen(self)

        elif self.OperationType == "DIALOG_SETTINGS":
            self.SelectedModuleMode = DialogSettingsScreen.Screen(self)

        else:
            raise Exception("Invalid Operation Type")

        self.POSITION = (Core.MAIN.ScreenWidth / 2 -
                         self.DISPLAY.get_width() / 2,
                         Core.MAIN.ScreenHeight / 2 -
                         self.DISPLAY.get_height() / 2)

        self.RootDefaultContents = self.RootProcess.DefaultContents
        if self.RootDefaultContents is None:
            raise Exception("Fatal Error")

        try:
            self.BGColor = UI.ThemesManager_GetProperty("Dialog_BG_Color")

        except:
            self.BGColor = (16, 14, 18)

        self.Initialized = True
        self.Timer = pygame.time.Clock()
        print("OneTrack Dialog initialized.")
Beispiel #11
0
 def CloseDialog(self):
     CoreWMControl.WindowManagerSignal(self, 1)
     CoreWMControl.WindowManagerSignal(self.RootProcess, 0)