Example #1
0
    def Initialize(self):
        self.SetVideoMode(True, (800, 600), True)
        self.SetTitle("OneTrack")
        self.DeleteInstanceOnFirstCycle = False
        self.Timer = pygame.time.Clock()
        self.DialogPID = -1
        self.CalcFPS = 0
        self.CurrentScreenToUpdate = Editor
        print("Initializing {0}...".format(self.TITLEBAR_TEXT))

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

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

        self.DefaultContents.InitSoundSystem()

        self.ICON = self.DefaultContents.GetImage("/icon.png")

        # Set the default content manager for the UI
        UI.ContentManager = self.DefaultContents
        var.DefaultContent = self.DefaultContents

        # Load UI Theme
        try:
            UI.ThemesManager_LoadTheme(
                self.DefaultContents.Get_RegKey("/selected_theme"))
        except:
            print("Error while loading selected theme\nUsing fallback theme")
            self.DefaultContents.Write_RegKey("/selected_theme", "default")

            UI.ThemesManager_LoadTheme(
                self.DefaultContents.Get_RegKey("/selected_theme"))

        MAIN.ReceiveCommand(0, 60)

        self.SetTitle("OneTrack v{0}".format(
            self.DefaultContents.Get_RegKey("/version")))

        var.ProcessReference = self
        var.LoadDefaultValues()
        Editor.Initialize()
        LagIndicator.Initialize(self)
Example #2
0
 def WhenClosing(self):
     # Reload UI Theme
     var.LoadDefaultValues()
     UI.ThemesManager_LoadTheme(
         UI.ContentManager.Get_RegKey("/selected_theme"))
     var.GenerateSoundCache = True
     var.PlayMode = True
Example #3
0
    def Initialize(self):
        var.ProcessReference = self

        print("Initializing {0}...".format(self.TITLEBAR_TEXT))

        # Initialize Variables
        self.CurrentScreenToUpdate = Editor

        # Initialize Content Manager
        self.DefaultContents.SetSourceFolder("OneTrack/")
        self.DefaultContents.SetFontPath("Data/fonts")
        self.DefaultContents.SetImageFolder("Data/img")
        self.DefaultContents.SetRegKeysPath("Data/reg")

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

        self.DefaultContents.InitSoundSystem()

        if self.CheckForAnotherInstances():
            return

        # Set the default content manager for the UI
        UI.ContentManager = self.DefaultContents
        var.DefaultContent = self.DefaultContents

        # Load UI Theme
        try:
            UI.ThemesManager_LoadTheme(
                self.DefaultContents.Get_RegKey("/selected_theme"))
        except:
            print("Error while loading selected theme\nUsing fallback theme")
            self.DefaultContents.Write_RegKey("/selected_theme", "default")

            UI.ThemesManager_LoadTheme(
                self.DefaultContents.Get_RegKey("/selected_theme"))

        MAIN.ReceiveCommand(0, 60)

        self.TITLEBAR_TEXT = "OneTrack v{0}".format(
            self.DefaultContents.Get_RegKey("/version"))

        var.LoadDefaultValues()
        Editor.Initialize()
        LagIndicator.Initialize()
Example #4
0
    def EventUpdate(self, event):
        self.CurrentScreenToUpdate.EventUpdate(event)

        if event.type == pygame.KEYUP:
            if event.key == 1073741895:
                print("Theme & RegKeys reloaded")
                UI.ContentManager.ReloadRegistry()
                UI.ThemesManager_LoadTheme(
                    self.DefaultContents.Get_RegKey("/selected_theme"))
Example #5
0
    def Update(self):
        self.WidgetController.Update()

        # SmoothScrolling Option
        if self.WidgetController.LastInteractionID == 0:
            if var.DefaultContent.Get_RegKey("/options/smooth_scroll", bool):
                var.DefaultContent.Write_RegKey("/options/smooth_scroll",
                                                "False")
            else:
                var.DefaultContent.Write_RegKey("/options/smooth_scroll",
                                                "True")
            self.ReloadUI()

        # Disabled Block Color
        if self.WidgetController.LastInteractionID == 2:
            if var.DefaultContent.Get_RegKey("/options/disabled_block_color",
                                             bool):
                var.DefaultContent.Write_RegKey(
                    "/options/disabled_block_color", "False")
            else:
                var.DefaultContent.Write_RegKey(
                    "/options/disabled_block_color", "True")
            self.ReloadUI()

        # Trackpointer Animation
        if self.WidgetController.LastInteractionID == 4:
            if var.DefaultContent.Get_RegKey("/options/trackpointer_animation",
                                             bool):
                var.DefaultContent.Write_RegKey(
                    "/options/trackpointer_animation", "False")
            else:
                var.DefaultContent.Write_RegKey(
                    "/options/trackpointer_animation", "True")
            self.ReloadUI()

        # Theme Name textbox
        if self.WidgetController.LastInteractionID == 6:
            CurrentText = self.WidgetController.LastInteractionType

            if len(CurrentText) == 0:
                CurrentText = "default"

            CurrentText = CurrentText.replace(" ", "_")

            # Check if theme exists
            self.LastThemeName = CurrentText

        # Theme Apply
        if self.WidgetController.LastInteractionID == 8:
            # Check if theme exists
            try:
                UwU = var.DefaultContent.Get_RegKey("/theme/{0}".format(
                    self.LastThemeName))
                UwU = self.LastThemeName

            except:
                print("Cannot find the theme file ({0}).".format(
                    self.LastThemeName))
                UwU = "default"

            var.DefaultContent.Write_RegKey("/selected_theme", UwU)

            UI.ThemesManager_LoadTheme(
                UI.ContentManager.Get_RegKey("/selected_theme"))
            self.ReloadUI()

        # Animation Scale Textbox
        if self.WidgetController.LastInteractionID == 9:
            CurrentText = self.WidgetController.LastInteractionType

            if not CurrentText.isdigit():
                CurrentText = "10"

            if len(CurrentText) == 0:
                CurrentText = "10"

            # Check if theme exists
            self.LastAnimationScale = CurrentText

        # Animation Apply
        if self.WidgetController.LastInteractionID == 11:
            UwU = self.LastAnimationScale
            if not UwU.isdigit():
                UwU = "10"

            # Check if theme exists
            var.DefaultContent.Write_RegKey("/options/animation_scale", UwU)

            self.ReloadUI()

        # Volume Multiplier Textbox
        if self.WidgetController.LastInteractionID == 12:
            CurrentText = self.WidgetController.LastInteractionType

            # Check if theme exists
            self.LastVolumeMultiplier = CurrentText

        # Volume Multiplier Apply
        if self.WidgetController.LastInteractionID == 14:
            ActualValue = self.LastVolumeMultiplier
            print(ActualValue)

            try:
                ValueConverted = float(ActualValue)

            except Exception:
                ValueConverted = 0.1

            if ValueConverted >= 1.0:
                ValueConverted = 0.1

            # Check if theme exists
            var.DefaultContent.Write_RegKey("/options/VolumeMultiplier",
                                            str(ValueConverted))

            self.ReloadUI()

        # Per-Track Scroll
        if self.WidgetController.LastInteractionID == 15:
            if var.DefaultContent.Get_RegKey("/options/per_track_scroll",
                                             bool):
                var.DefaultContent.Write_RegKey("/options/per_track_scroll",
                                                "False")
            else:
                var.DefaultContent.Write_RegKey("/options/per_track_scroll",
                                                "True")
            self.ReloadUI()

        # Looking Glass Option
        if self.WidgetController.LastInteractionID == 17:
            if var.DefaultContent.Get_RegKey("/options/looking_glass", bool):
                var.DefaultContent.Write_RegKey("/options/looking_glass",
                                                "False")
            else:
                var.DefaultContent.Write_RegKey("/options/looking_glass",
                                                "True")
            self.ReloadUI()

        # Block Trackpointer Option
        if self.WidgetController.LastInteractionID == 19:
            if var.DefaultContent.Get_RegKey("/options/block_trackpointer",
                                             bool):
                var.DefaultContent.Write_RegKey("/options/block_trackpointer",
                                                "False")
            else:
                var.DefaultContent.Write_RegKey("/options/block_trackpointer",
                                                "True")
            self.ReloadUI()