コード例 #1
0
def NewMusicFile():
    global track_list

    track_list = UI.TrackList()
    del track_list
    tge.Utils.GarbageCollector_Collect()

    # -- Unload the Current SoundCahce -- #
    UI.ContentManager.UnloadSoundTuneCache()

    # -- Update Tittlebar -- #
    var.ProcessReference.TITLEBAR_TEXT = "OneTrack v{0}".format(
        var.ProcessReference.DefaultContents.Get_RegKey("/version"))

    track_list = UI.TrackList()
    track_list.Rectangle = pygame.Rect(0, 100, Core.MAIN.ScreenWidth,
                                       Core.MAIN.ScreenHeight - 200)

    var.BPM = 150
    var.Rows = 32
    var.GenerateSoundCache = True
    var.SelectedTrack = 0
    var.Highlight = 4
    var.HighlightSecond = 16
    var.Patterns = 2

    OptionsBar.UpdateChanger()
    OptionsBar.Update()

    var.ProcessReference.DefaultContents.Write_RegKey(
        "/dialog/imported_older_version/show_once", "False")
コード例 #2
0
 def __init__(self, Text, FontSize, X, Y, WidgetID):
     if WidgetID == -1:
         raise ValueError("WidgetID cannot be -1")
     self.ID = WidgetID
     self.InteractionType = None
     self.Active = True
     self.EventUpdateable = True
     self.AwaysUpdate = False
     self.X = X
     self.Y = Y
     self.Text = Text
     self.FontSize = FontSize
     self.TextWidth = UI.ContentManager.GetFont_width(
         "/Ubuntu_Bold.ttf", self.FontSize, self.Text)
     self.TextHeight = UI.ContentManager.GetFont_height(
         "/Ubuntu_Bold.ttf", self.FontSize, self.Text)
     self.Rectangle = Utils.Convert.List_PygameRect(
         (X - 2, Y - 2, self.TextWidth + 4, self.TextHeight + 4))
     self.LastRect = self.Rectangle
     self.Surface = pygame.Surface((self.Rectangle[2], self.Rectangle[3]))
     self.Centred_X = self.Rectangle[
         2] / 2 - UI.ContentManager.GetFont_width(
             "/Ubuntu_Bold.ttf", self.FontSize - 2, self.Text) / 2
     self.Centred_Y = self.Rectangle[
         3] / 2 - UI.ContentManager.GetFont_height(
             "/Ubuntu_Bold.ttf", self.FontSize - 2, self.Text) / 2
     self.ButtonState = 0
     self.CursorOffset = (0, 0)
     self.BgColor = UI.ThemesManager_GetProperty("Button_BackgroundColor")
     self.IndicatorColor = UI.ThemesManager_GetProperty(
         "Button_Inactive_IndicatorColor")
コード例 #3
0
    def __init__(self, pRootProcess):
        self.RootProcess = pRootProcess

        # Set the correct screen size
        self.RootProcess.DISPLAY = pygame.Surface((300, 350))

        self.FolderList = UI.VerticalListWithDescription(
            pygame.Rect(0, 24, 300, 15))

        ButtonsList = list()
        ButtonsList.append(UI.Button(pygame.Rect(0, 0, 0, 0), "Select", 12))

        self.OptionsBar = UI.ButtonsBar((0, 0, 0, 0), ButtonsList)
        self.RootProcess.TITLEBAR_TEXT = "Open File"
        self.FileListUpdated = False
コード例 #4
0
ファイル: __init__.py プロジェクト: aragubas/OneTrack
    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)
コード例 #5
0
def GameDraw(DISPLAY):
    global track_list
    global TopBarControls
    global DropDownFileMenu
    global LastScreenFrame

    if not var.DisableControls:
        if not var.FileMenuEnabled:
            DISPLAY.fill((UI.ThemesManager_GetProperty("BackgroundColor")))

            track_list.Render(DISPLAY)
            TopBarControls.Render(DISPLAY)

            OptionsBar.Draw(DISPLAY)
            EditorBar.Draw(DISPLAY)

            SoundCacheMessage.Draw(DISPLAY)

            LastScreenFrame = DISPLAY.copy()

        else:
            DISPLAY.blit(LastScreenFrame, (0, 0))

            TopBarControls.Render(DISPLAY)

            DropDownFileMenu.Render(DISPLAY)
コード例 #6
0
 def WhenClosing(self):
     # Reload UI Theme
     var.LoadDefaultValues()
     UI.ThemesManager_LoadTheme(
         UI.ContentManager.Get_RegKey("/selected_theme"))
     var.GenerateSoundCache = True
     var.PlayMode = True
コード例 #7
0
ファイル: __init__.py プロジェクト: aragubas/OneTrack
    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()
コード例 #8
0
ファイル: __init__.py プロジェクト: aragubas/OneTrack
    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"))
コード例 #9
0
    def __init__(self, pRoot_Process):
        self.RootProcess = pRoot_Process

        # Set the correct screen size
        self.RootProcess.DISPLAY = pygame.Surface((300, 350))

        self.FolderList = UI.VerticalListWithDescription(
            pygame.Rect(0, 24, 300, 15))
        ButtonsList = list()
        ButtonsList.append(UI.Button(pygame.Rect(0, 0, 0, 0), "Select", 14))
        ButtonsList.append(UI.Button((0, 0, 0, 0), "New", 14))

        self.OptionsBar = UI.ButtonsBar((0, 0, 0, 0), ButtonsList)
        self.RootProcess.TITLEBAR_TEXT = "Save File"
        self.Inputbox_FileName = UI.InputBox(5, 25, 250, 25, "Default", 14)

        self.FileListUpdated = False
        self.FileListUpdate = False
        self.EnterFileNameEnabled = False
コード例 #10
0
    def Initialize(self):
        global RootDefaultContents

        RootDefaultContents = None
        # Focus to this window
        Core.wmm.WindowManagerSignal(self, 0)

        # Initialize Content Manager
        self.DefaultContents = CntMng.ContentManager()
        self.DefaultContents.SetSourceFolder("OneTrack/UnatachedDialog/")
        self.DefaultContents.SetFontPath("Data/fonts")
        self.DefaultContents.SetImageFolder("Data/img")
        self.DefaultContents.SetRegKeysPath("Data/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)

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

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

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

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

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


        except:
            self.BGColor = (16, 14, 18)
コード例 #11
0
ファイル: __init__.py プロジェクト: aragubas/OneTrack
    def Update(self):
        # -- Check if surface has the correct size -- #
        if not self.LastRect == self.Rectangle:
            self.Surface = pygame.Surface(
                (self.Rectangle[2], self.Rectangle[3]))

            # -- Update all Size and Position Variables -- #
            self.TextWidth = UI.ContentManager.GetFont_width(
                "/Ubuntu_Bold.ttf", self.FontSize, self.Text)
            self.TextHeight = UI.ContentManager.GetFont_height(
                "/Ubuntu_Bold.ttf", self.FontSize, self.Text)
            self.Rectangle = Utils.Convert.List_PygameRect(
                (self.Rectangle[0] - 2, self.Rectangle[1] - 2,
                 self.TextWidth + 4, self.TextHeight + 4))
            self.Centred_X = self.Rectangle[
                2] / 2 - UI.ContentManager.GetFont_width(
                    "/Ubuntu_Bold.ttf", self.FontSize - 2, self.Text) / 2
            self.Centred_Y = self.Rectangle[
                3] / 2 - UI.ContentManager.GetFont_height(
                    "/Ubuntu_Bold.ttf", self.FontSize - 2, self.Text) / 2

            self.LastRect = self.Rectangle

        self.BgColor = UI.ThemesManager_GetProperty("Button_BackgroundColor")
        self.IndicatorColor = UI.ThemesManager_GetProperty(
            "Button_Inactive_IndicatorColor")

        if not self.Active:
            self.IndicatorColor = UI.ThemesManager_GetProperty(
                "Button_Inactive_IndicatorColor")

            return

        if self.ButtonState == 0:
            self.IndicatorColor = UI.ThemesManager_GetProperty(
                "Button_Inactive_IndicatorColor")

        elif self.ButtonState == 1:
            self.IndicatorColor = UI.ThemesManager_GetProperty(
                "Button_Active_IndicatorColor")
コード例 #12
0
    def Update(self):
        # -- Resize the Textbox -- #
        try:
            if not self.CustomWidth:
                self.Width = max(
                    100,
                    UI.ContentManager.GetFont_width(
                        UI.ThemesManager_GetProperty("InputBox_FontFile"),
                        self.FontSize, self.Text) + 10)
            self.Rectangle[2] = self.Width
            self.Rectangle[3] = UI.ContentManager.GetFont_height(
                UI.ThemesManager_GetProperty("InputBox_FontFile"),
                self.FontSize, self.Text)
            self.LastHeight = self.Rectangle[3]
        except:
            if not self.CustomWidth:
                self.Rectangle[2] = 100
            self.Rectangle[3] = self.LastHeight

        if self.Text == "":
            self.Rectangle = pygame.Rect(self.Rectangle[0], self.Rectangle[1],
                                         self.Rectangle[2], self.Height)
コード例 #13
0
    def Render(self, DISPLAY):
        # -- Render Background -- #
        BGColor = UI.ThemesManager_GetProperty("Button_BackgroundColor")
        LineColor = UI.ThemesManager_GetProperty(
            "Button_Active_IndicatorColor")

        if not self.Active:
            LineColor = UI.ThemesManager_GetProperty(
                "Button_Inactive_IndicatorColor")

        Shape.Shape_Rectangle(DISPLAY, BGColor, self.Rectangle)
        Shape.Shape_Rectangle(DISPLAY, LineColor, self.Rectangle, 1)

        # -- Render Change Title -- #
        TitleX = self.Rectangle[
            0] + self.Rectangle[2] / 2 - UI.ContentManager.GetFont_width(
                "/Ubuntu_Bold.ttf", 12, self.TitleName) / 2

        UI.ContentManager.FontRender(DISPLAY, "/Ubuntu_Bold.ttf", 12,
                                     self.TitleName, (230, 230, 230), TitleX,
                                     self.Rectangle[1])

        # -- Render EditableNumberView -- #
        self.Changer.Render(DISPLAY)
コード例 #14
0
    def Render(self, DISPLAY):
        # Blit the rect.
        Shape.Shape_Rectangle(DISPLAY, (15, 15, 15), self.Rectangle)

        if self.Text == self.DefaultText:
            UI.ContentManager.FontRender(
                DISPLAY, UI.ThemesManager_GetProperty("InputBox_FontFile"),
                self.FontSize, self.Text, (140, 140, 140), self.Rectangle[0],
                self.Rectangle[1])
        else:
            if not self.Text == "":
                UI.ContentManager.FontRender(
                    DISPLAY, UI.ThemesManager_GetProperty("InputBox_FontFile"),
                    self.FontSize, self.Text, (240, 240, 240),
                    self.Rectangle[0], self.Rectangle[1])

        if not self.Active:
            Shape.Shape_Rectangle(DISPLAY, (255, 51, 102),
                                  (self.Rectangle[0], self.Rectangle[1] - 1,
                                   self.Rectangle[2], 1))
        else:
            Shape.Shape_Rectangle(DISPLAY, (46, 196, 182),
                                  (self.Rectangle[0], self.Rectangle[1] - 1,
                                   self.Rectangle[2], 1))
コード例 #15
0
def Initialize():
    global track_list
    global TopBarControls
    global DropDownFileMenu

    # Add all widgets
    ButtonsList = list()
    ButtonsList.append(UI.Button(pygame.Rect(0, 0, 0, 0), "File", 14))
    TopBarControls = UI.ButtonsBar((3, 5, Core.MAIN.ScreenWidth, 32),
                                   ButtonsList)
    DropDownFileMenuList = (("Load", DropDownButtonsActions_LoadButton),
                            ("Save", DropDownButtonsActions_SaveButton),
                            ("New File", DropDownButtonsActions_NewFileButton),
                            ("About", DropDownButtonsActions_AboutButton),
                            ("Settings",
                             DropDownButtonsActions_SettingsButton))
    DropDownFileMenu = UI.DropDownMenu(pygame.Rect(10, 35, 120, 65),
                                       DropDownFileMenuList)

    OptionsBar.Initialize()
    EditorBar.Initialize()
    SoundCacheMessage.Initialize()

    NewMusicFile()
コード例 #16
0
    def __init__(self, Position, TitleName, ChangerInitialValue, WidgetID):
        if WidgetID == -1:
            raise ValueError("WidgetID cannot be -1")

        self.Rectangle = Utils.Convert.List_PygameRect(
            (Position[0], Position[1], 48, 34))
        self.TitleName = TitleName
        self.ID = WidgetID
        self.Changer = UI.EditableNumberView(
            pygame.Rect(self.Rectangle[0], self.Rectangle[1] + 17,
                        self.Rectangle[2], self.Rectangle[3] - 17),
            ChangerInitialValue)
        self.LastValue = ChangerInitialValue
        self.InteractionType = None
        self.Active = False
        self.EventUpdateable = True
        self.AwaysUpdate = False
        self.CursorOffset = (0, 0)
コード例 #17
0
def LoadMusicData(FileName):
    global track_list

    FileName = FileName + ".oneprj"
    print("Loading Music {0}...".format(FileName))

    # -- Unload the Current SoundCahce -- #
    UI.ContentManager.UnloadSoundTuneCache()

    # -- Clear the Current Patterns -- #
    track_list.PatternList.clear()

    FileDataRead = open(FileName, "r").readlines()

    FileImportedFromOlderVersion = False
    IsReadingRegion = False
    IsReadingMetadata = False
    LastReadingRegion_Name = ""

    MusicData_BPM = 0
    MusicData_Rows = 0
    MusicData_Highlight = 0
    MusicData_HighlightSecound = 0
    MusicData_Patterns = 0
    MusicData_VersionSaved = ""

    RowReading_LastRowID = 0
    RowReading_IsReadingRow = False
    RowReading_BlocksList = list()

    ReadPatternsList = list()

    for line in FileDataRead:
        line = line.rstrip()
        if not IsReadingRegion:
            if line.startswith("#region"):
                IsReadingRegion = True
                SplitRegionRead = line.replace("#region", "").split(",")
                LastReadingRegion_Name = SplitRegionRead[1]

                # Check what type of data is being read
                IsReadingMetadata = LastReadingRegion_Name == "METADATA"

                # Create the Pattern
                if not IsReadingMetadata:
                    ObjToAdd = UI.Pattern(
                        int(LastReadingRegion_Name.split(":")[1]), False)
                    ReadPatternsList.append(ObjToAdd)

                    print("CreatedPattern_ID : " +
                          str(LastReadingRegion_Name.split(":")[1]))

            continue

        # Check if reading hit it's end
        if line == "$end":
            print(
                "Finished reading region ({0})".format(LastReadingRegion_Name))
            IsReadingRegion = False
            if not IsReadingMetadata:
                ReadPatternsList[int(LastReadingRegion_Name.split(":")
                                     [1])].UpdateTracksPosition()

                LastReadingRegion_Name = ""
            IsReadingMetadata = False
            continue

        # Read Metadata
        if IsReadingMetadata:
            ArgsSplit = line.split(":")

            if ArgsSplit[0] == "BPM":
                MusicData_BPM = int(ArgsSplit[1])
                print("BPM was set to: {0}".format(str(MusicData_BPM)))
                continue

            if ArgsSplit[0] == "Rows":
                MusicData_Rows = int(ArgsSplit[1])
                print("Rows was set to: {0}".format(str(MusicData_Rows)))
                continue

            if ArgsSplit[0] == "Highlight":
                MusicData_Highlight = int(ArgsSplit[1])
                print("Highlight was set to: {0}".format(
                    str(MusicData_Highlight)))
                continue

            if ArgsSplit[0] == "HighlightSecond":
                MusicData_HighlightSecound = int(ArgsSplit[1])
                print("HighlightSecond was set to: {0}".format(
                    str(MusicData_HighlightSecound)))
                continue

            if ArgsSplit[0] == "Patterns":
                MusicData_Patterns = int(ArgsSplit[1])
                print("Patterns was set to: {0}".format(
                    str(MusicData_Patterns)))
                continue

            if ArgsSplit[0] == "SavedVersion":
                MusicData_VersionSaved = ArgsSplit[1]
                print("VersionSaved was set to: {0}".format(
                    MusicData_VersionSaved))
                continue

            print("Invalid Metadata Argument ({0})".format(ArgsSplit[0]))
            continue

        # Start Row Reading
        if line.startswith("%Row") and not RowReading_IsReadingRow:
            LineSplit = line.split(":")

            RowReading_IsReadingRow = True
            RowReading_LastRowID = int(LineSplit[1])
            print("RowReading : RowID {0}".format(str(RowReading_LastRowID)))
            continue

        # Finish Row Reading
        if line == "%row_end" and RowReading_IsReadingRow:
            print("RowReading : Finished Reading Row {0}".format(
                RowReading_LastRowID))

            ObjToAdd = UI.TrackColection(int(RowReading_LastRowID), False)
            for block in RowReading_BlocksList:
                ObjToAdd.Tracks.append(block)

            ReadPatternsList[int(
                LastReadingRegion_Name.split(":")[1])].Tracks.append(ObjToAdd)

            RowReading_IsReadingRow = False
            RowReading_LastRowID = 0

            RowReading_BlocksList.clear()
            continue

        # Get BlockData
        BlockData = line.split(":")

        BlockFrequency = BlockData[0]
        BlockDuration = BlockData[1]

        TrackblockToAdd = UI.TrackBlock((BlockFrequency, BlockDuration))

        RowReading_BlocksList.append(TrackblockToAdd)

    # Set the VarValues
    var.BPM = MusicData_BPM
    var.Rows = MusicData_Rows
    var.Highlight = MusicData_Highlight
    var.HighlightSecond = MusicData_HighlightSecound
    var.Patterns = MusicData_Patterns
    var.SelectedTrack = 0

    # Replace the Patterns List
    track_list.PatternList.clear()
    track_list.PatternList = ReadPatternsList

    # -- Set to the Pattern 0 -- #
    track_list.SetCurrentPattern_ByID(0)

    if MusicData_VersionSaved != var.ProcessReference.DefaultContents.Get_RegKey(
            "/version"):
        FileImportedFromOlderVersion = True

    OptionsBar.UpdateChanger()

    # Re-Update all tracks
    for track in track_list.PatternList:
        track.UpdateTracksPosition()
        for TrackCol in track.Tracks:
            for block in TrackCol.Tracks:
                block.Active = True
                block.HighlightUpdated = False
                block.SurfaceUpdateTrigger = True
                block.DisabledTrigger = False
                block.RootActivated = True
                block.ResetSurface()
                block.Update()
                block.ReRender()

    if FileImportedFromOlderVersion and not var.ProcessReference.DefaultContents.Get_RegKey(
            "/dialog/imported_older_version/show_once", bool):
        var.ProcessReference.GreyDialog(
            var.ProcessReference.DefaultContents.Get_RegKey(
                "/dialog/imported_older_version/title"),
            var.ProcessReference.DefaultContents.Get_RegKey(
                "/dialog/imported_older_version/text"))
        var.ProcessReference.DefaultContents.Write_RegKey(
            "/dialog/imported_older_version/show_once", "True")
コード例 #18
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()
コード例 #19
0
ファイル: __init__.py プロジェクト: aragubas/OneTrack
    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.")