Beispiel #1
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")
Beispiel #2
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)
Beispiel #3
0
    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")
Beispiel #4
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)
Beispiel #5
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.")