Ejemplo n.º 1
0
    def __init__(self,
                 parent,
                 pos=(0, 0),
                 size=(-1, -1),
                 anchor=constants.TOP_LEFT,
                 *args,
                 **kwargs):
        kwargs["yes_type"] = "ok"
        kwargs["no_type"] = "back"
        super(NewBaseDialog, self).__init__(parent, pos, size, anchor, *args,
                                            **kwargs)
        self.listbox.size = (-.53, -.75)
        self.description_pane.size = (-.45, -.75)

        self.text_label = text.Text(self, (.01, -.87), (-.25, -.1),
                                    anchor=constants.BOTTOM_LEFT,
                                    borders=(constants.TOP, constants.BOTTOM,
                                             constants.LEFT),
                                    shrink_factor=.88,
                                    background_color="pane_background",
                                    text=g.strings["name_base_text"])

        self.text_field = text.EditableText(self, (-.26, -.87), (-.73, -.1),
                                            anchor=constants.BOTTOM_LEFT,
                                            borders=constants.ALL,
                                            base_font="normal")

        self.desc_func = self.on_change

        self.yes_button.function = self.finish
Ejemplo n.º 2
0
    def __init__(self,
                 parent,
                 pos=(-.50, -.50),
                 size=(.50, .10),
                 anchor=constants.MID_CENTER,
                 **kwargs):
        kwargs.setdefault('wrap', False)
        kwargs.setdefault("shrink_factor", 1)
        kwargs.setdefault("text_size", 20)
        self.default_text = kwargs.pop("default_text", "")
        self.ok_type = kwargs.pop("ok_type", "ok")
        self.cancel_type = kwargs.pop("cancel_type", "cancel")
        super(TextEntryDialog, self).__init__(parent, pos, size, anchor,
                                              **kwargs)

        self.text_field = text.EditableText(self, (0, -.50), (-.71, -.50),
                                            borders=constants.ALL,
                                            base_font="normal")

        self.ok_button = button.FunctionButton(self, (-.72, -.50),
                                               (-.14, -.50),
                                               function=self.return_text)
        self.cancel_button = button.FunctionButton(
            self, (-.86, -.50), (-.14, -.50), function=self.return_nothing)

        self.add_key_handler(pygame.K_RETURN, self.return_text)
        self.add_key_handler(pygame.K_KP_ENTER, self.return_text)
        self.add_key_handler(pygame.K_ESCAPE, self.return_nothing)
Ejemplo n.º 3
0
    def __init__(self, *args, **kwargs):
        super(VideoPane, self).__init__(*args, **kwargs)
        
        self.resolution_initialized = False
        
        self.resolution_label = text.Text(self, (.01, .01), (.14, .05),
                                          align=constants.LEFT,
                                          background_color="clear")

        self.resolution_choice = \
            listbox.UpdateListbox(self, (.16, .01), (.20, .25),
                                  update_func=self.update_resolution)

        self.resolution_custom = OptionButton(self, (.01, .28), (.14, .05),
                                              autohotkey=True,
                                              function=self.set_resolution_custom)

        self.resolution_custom_horiz = \
            text.EditableText(self, (.16, .28), (.14, .05),
                              text=str(gg.default_screen_size[0]),
                              borders=constants.ALL,
                              border_color="widget_border",
                              background_color=(0,0,50,255))

        self.resolution_custom_X = text.Text(self,
                                             (.30, .28),
                                             (.02, .05),
                                             text="X",
                                             base_font="special",
                                             background_color="clear")

        self.resolution_custom_vert = \
            text.EditableText(self, (.32, .28), (.14, .05),
                              text=str(gg.default_screen_size[1]),
                              borders=constants.ALL,
                              border_color="widget_border",
                              background_color=(0,0,50,255))

        self.fullscreen_label = button.HotkeyText(self, (.40, .01), (.30, .05),
                                                  autohotkey=True,
                                                  align=constants.LEFT,
                                                  background_color="clear")
        self.fullscreen_toggle = OptionButton(self, (.71, .01), (.07, .05),
                                              text_shrink_factor=.75,
                                              force_underline=-1,
                                              function=self.set_fullscreen,
                                              args=(button.TOGGLE_VALUE,))
        self.fullscreen_label.hotkey_target = self.fullscreen_toggle

        self.daynight_label = button.HotkeyText(self, (.40, .08), (.30, .05),
                                                autohotkey=True,
                                                align=constants.LEFT,
                                                background_color="clear")
        self.daynight_toggle = OptionButton(self, (.71, .08), (.07, .05),
                                        text_shrink_factor=.75,
                                        force_underline=-1,
                                        function=self.set_daynight,
                                        args=(button.TOGGLE_VALUE,))
        self.daynight_label.hotkey_target = self.daynight_toggle

        self.grab_label = button.HotkeyText(self, (.40, .15), (.30, .05),
                                            autohotkey=True,
                                            align=constants.LEFT,
                                            background_color="clear")
        self.grab_toggle = OptionButton(self, (.71, .15), (.07, .05),
                                        text_shrink_factor=.75,
                                        force_underline=-1,
                                        function=self.set_grab,
                                        args=(button.TOGGLE_VALUE,))
        self.grab_label.hotkey_target = self.grab_toggle
Ejemplo n.º 4
0
    def __init__(self, *args, **kwargs):

        super(GeneralPane, self).__init__(*args, **kwargs)

        # First row
        self.fullscreen_label = button.HotkeyText(self, (.01, .01), (.14, .05),
                                                  autohotkey=True,
                                                  align=constants.LEFT,
                                                  background_color="clear")
        self.fullscreen_toggle = OptionButton(self, (.16, .01), (.07, .05),
                                              text_shrink_factor=.75,
                                              force_underline=-1,
                                              function=self.set_fullscreen,
                                              args=(button.TOGGLE_VALUE, ))
        self.fullscreen_label.hotkey_target = self.fullscreen_toggle

        self.daynight_label = button.HotkeyText(self, (.25, .01), (.20, .05),
                                                autohotkey=True,
                                                background_color="clear")
        self.daynight_toggle = OptionButton(self, (.46, .01), (.07, .05),
                                            text_shrink_factor=.75,
                                            force_underline=-1,
                                            function=self.set_daynight,
                                            args=(button.TOGGLE_VALUE, ))
        self.daynight_label.hotkey_target = self.daynight_toggle

        self.grab_label = button.HotkeyText(self, (.55, .01), (.15, .05),
                                            autohotkey=True,
                                            background_color="clear")
        self.grab_toggle = OptionButton(self, (.71, .01), (.07, .05),
                                        text_shrink_factor=.75,
                                        force_underline=-1,
                                        function=self.set_grab,
                                        args=(button.TOGGLE_VALUE, ))
        self.grab_label.hotkey_target = self.grab_toggle

        # Second and third row
        self.resolution_label = text.Text(self, (.01, .08), (.14, .05),
                                          align=constants.LEFT,
                                          background_color="clear")

        self.resolution_group = button.ButtonGroup()

        rows = 2
        cols = 4

        def xpos(i):
            return .16 + .16 * (i % cols)

        def ypos(i):
            return .08 + .07 * int(i / cols)

        for index, (xres,
                    yres) in enumerate(sorted(gg.resolutions[0:rows * cols])):
            self.resolution_group.add(
                OptionButton(self, (xpos(index), ypos(index)), (.14, .05),
                             text="%sx%s" % (xres, yres),
                             function=self.set_resolution,
                             args=((xres, yres), )))
        # Adjust index to full row
        index += cols - (index % cols) - 1

        # Forth row
        self.resolution_custom = OptionButton(
            self, (xpos(0), ypos(index + 1)), (.14, .05),
            autohotkey=True,
            function=self.set_resolution_custom)
        self.resolution_group.add(self.resolution_custom)

        self.resolution_custom_horiz = \
            text.EditableText(self, (xpos(1), ypos(index+1)), (.14, .05),
                              text=str(gg.default_screen_size[0]),
                              borders=constants.ALL,
                              border_color="widget_border",
                              background_color=(0,0,50,255))

        self.resolution_custom_X = text.Text(self,
                                             (xpos(2) - .02, ypos(index + 1)),
                                             (.02, .05),
                                             text="X",
                                             base_font="special",
                                             background_color="clear")

        self.resolution_custom_vert = \
            text.EditableText(self, (xpos(2), ypos(index+1)), (.14, .05),
                              text=str(gg.default_screen_size[1]),
                              borders=constants.ALL,
                              border_color="widget_border",
                              background_color=(0,0,50,255))

        # Fifth row
        self.language_label = text.Text(self, (.01, .30), (.14, .05),
                                        align=constants.LEFT,
                                        background_color="clear")

        self.languages = get_languages_list()
        self.language_choice = \
            listbox.UpdateListbox(self, (.16, .30), (.20, .25),
                                  list=[lang[1] for lang in self.languages],
                                  update_func=self.set_language)

        self.theme_label = text.Text(self, (.37, .30), (.09, .05),
                                     text=_("Theme:"),
                                     align=constants.LEFT,
                                     background_color="clear")

        self.theme_choice = \
            listbox.UpdateListbox(self, (.47, .30), (.12, .25),
                                  update_func=theme.set_theme,
                                  list_pos=theme.get_theme_pos())
Ejemplo n.º 5
0
    def __init__(self, *args, **kwargs):
        kwargs.setdefault("yes_type", "ok")
        kwargs.setdefault("no_type", "cancel")
        super(OptionsScreen, self).__init__(*args, **kwargs)
        self.yes_button.function = self.check_restart

        self.size = (.79, .63)
        self.pos = (.5, .5)
        self.anchor = constants.MID_CENTER
        self.background_color = (0, 0, 50)
        self.borders = ()

        labels = {
            'fullscreen': g.hotkey(_("&Fullscreen:")),
            'sound': g.hotkey(_("&Sound:")),
            'mousegrab': g.hotkey(_("&Mouse grab:")),
            'daynight': g.hotkey(_("Da&y/night display:")),
        }

        # First row
        self.fullscreen_label = text.Text(
            self, (.01, .01), (.14, .05),
            text=labels['fullscreen']['text'],
            underline=labels['fullscreen']['pos'],
            align=constants.LEFT,
            background_color=gg.colors["clear"])
        self.fullscreen_toggle = OptionButton(
            self, (.16, .01), (.07, .05),
            text=_("NO"),
            text_shrink_factor=.75,
            hotkey=labels['fullscreen']['key'],
            force_underline=-1,
            function=self.set_fullscreen,
            args=(button.TOGGLE_VALUE, ))
        self.sound_label = text.Text(self, (.28, .01), (.15, .05),
                                     text=labels['sound']['text'],
                                     underline=labels['sound']['pos'],
                                     background_color=gg.colors["clear"])
        self.sound_toggle = OptionButton(self, (.44, .01), (.07, .05),
                                         text=_("YES"),
                                         text_shrink_factor=.75,
                                         hotkey=labels['sound']['key'],
                                         force_underline=-1,
                                         function=self.set_sound,
                                         args=(button.TOGGLE_VALUE, ))
        self.grab_label = text.Text(self, (.55, .01), (.15, .05),
                                    text=labels['mousegrab']['text'],
                                    underline=labels['mousegrab']['pos'],
                                    background_color=gg.colors["clear"])
        self.grab_toggle = OptionButton(self, (.71, .01), (.07, .05),
                                        text=_("NO"),
                                        text_shrink_factor=.75,
                                        hotkey=labels['mousegrab']['key'],
                                        force_underline=-1,
                                        function=self.set_grab,
                                        args=(button.TOGGLE_VALUE, ))

        # Second and third row
        self.resolution_label = text.Text(self, (.01, .08), (.14, .05),
                                          text=_("Resolution:"),
                                          align=constants.LEFT,
                                          background_color=gg.colors["clear"])

        self.resolution_group = button.ButtonGroup()

        rows = 2
        cols = 4

        def xpos(i):
            return .16 + .16 * (i % cols)

        def ypos(i):
            return .08 + .07 * int(i / cols)

        for index, (xres,
                    yres) in enumerate(sorted(gg.resolutions[0:rows * cols])):
            self.resolution_group.add(
                OptionButton(self, (xpos(index), ypos(index)), (.14, .05),
                             text="%sx%s" % (xres, yres),
                             function=self.set_resolution,
                             args=((xres, yres), )))
        # Adjust index to full row
        index += cols - (index % cols) - 1

        # Forth row
        self.resolution_custom = OptionButton(
            self, (xpos(0), ypos(index + 1)), (.14, .05),
            text=_("&CUSTOM:"),
            autohotkey=True,
            function=self.set_resolution_custom)
        self.resolution_group.add(self.resolution_custom)

        self.resolution_custom_horiz = \
            text.EditableText(self, (xpos(1), ypos(index+1)), (.14, .05),
                              text=str(gg.default_screen_size[0]),
                              borders=constants.ALL,
                              border_color=gg.colors["white"],
                              background_color=(0,0,50,255))

        self.resolution_custom_X = text.Text(
            self, (xpos(2) - .02, ypos(index + 1)), (.02, .05),
            text="X",
            base_font=gg.font[1],
            background_color=gg.colors["clear"])

        self.resolution_custom_vert = \
            text.EditableText(self, (xpos(2), ypos(index+1)), (.14, .05),
                              text=str(gg.default_screen_size[1]),
                              borders=constants.ALL,
                              border_color=gg.colors["white"],
                              background_color=(0,0,50,255))

        # Fifth row
        self.language_label = text.Text(self, (.01, .30), (.14, .05),
                                        text=_("Language:"),
                                        align=constants.LEFT,
                                        background_color=gg.colors["clear"])

        self.languages = get_languages_list()
        self.language_choice = \
            listbox.UpdateListbox(self, (.16, .30), (.21, .25),
                                  list=[lang[1] for lang in self.languages],
                                  update_func=self.set_language)

        self.daynight_label = text.Text(self, (.50, .30), (.20, .05),
                                        text=labels['daynight']['text'],
                                        underline=labels['daynight']['pos'],
                                        background_color=gg.colors["clear"])
        self.daynight_toggle = OptionButton(self, (.71, .30), (.07, .05),
                                            text=_("NO"),
                                            text_shrink_factor=.75,
                                            hotkey=labels['daynight']['key'],
                                            force_underline=-1,
                                            function=self.set_daynight,
                                            args=(button.TOGGLE_VALUE, ))
Ejemplo n.º 6
0
    def __init__(self, *args, **kwargs):
        super(OptionsScreen, self).__init__(*args, **kwargs)

        self.size = (.79, .63)
        self.pos = (.5, .5)
        self.anchor = constants.MID_CENTER
        self.background_color = (0,0,50)
        self.borders = ()

        self.fullscreen_label = text.Text(self, (.01, .01), (.15, .05),
                                          text="Fullscreen:", underline=0,
                                          align=constants.LEFT,
                                          background_color=gg.colors["clear"])
        self.fullscreen_toggle = OptionButton(self, (.17, .01), (.07, .05),
                                              text="NO", text_shrink_factor=.75,
                                              hotkey="f", force_underline=-1,
                                              function=self.set_fullscreen,
                                              args=(button.TOGGLE_VALUE,))
        self.sound_label = text.Text(self, (.28, .01), (.15, .05),
                                     text="Sound:", underline=0,
                                     background_color=gg.colors["clear"])
        self.sound_toggle = OptionButton(self, (.44, .01), (.07, .05),
                                         text="YES", text_shrink_factor=.75,
                                         hotkey="s", force_underline=-1,
                                         function=self.set_sound,
                                         args=(button.TOGGLE_VALUE,))
        self.grab_label = text.Text(self, (.55, .01), (.15, .05),
                                    text="Mouse grab:", underline=0,
                                    background_color=gg.colors["clear"])
        self.grab_toggle = OptionButton(self, (.71, .01), (.07, .05),
                                        text="NO", text_shrink_factor=.75,
                                        hotkey="m", force_underline=-1,
                                        function=self.set_grab,
                                        args=(button.TOGGLE_VALUE,))
        self.resolution_label = text.Text(self, (.01, .08), (.15, .05),
                                          text="Resolution:",
                                          align=constants.LEFT,
                                          background_color=gg.colors["clear"])

        self.resolution_group = button.ButtonGroup()
        self.resolution_640x480 = OptionButton(self, (.17, .08), (.12, .05),
                                               text="640X480",
                                               text_shrink_factor=.5,
                                               function=self.set_resolution,
                                               args=((640,480),))
        self.resolution_group.add(self.resolution_640x480)
        self.resolution_800x600 = OptionButton(self, (.333, .08), (.12, .05),
                                               text="800X600",
                                               text_shrink_factor=.5,
                                               function=self.set_resolution,
                                               args=((800,600),))
        self.resolution_group.add(self.resolution_800x600)
        self.resolution_1024x768 = OptionButton(self, (.496, .08), (.12, .05),
                                                text="1024X768",
                                                text_shrink_factor=.5,
                                                function=self.set_resolution,
                                                args=((1024,768),))
        self.resolution_group.add(self.resolution_1024x768)
        self.resolution_1280x1024 = OptionButton(self, (.66, .08), (.12, .05),
                                                 text="1280X1024",
                                                 text_shrink_factor=.5,
                                                 function=self.set_resolution,
                                                 args=((1280,1024),))
        self.resolution_group.add(self.resolution_1280x1024)

        self.resolution_custom = OptionButton(self, (.17, .15), (.12, .05),
                                              text="CUSTOM:",
                                              text_shrink_factor=.5)
        self.resolution_group.add(self.resolution_custom)

        self.resolution_custom_horiz = \
            text.EditableText(self, (.333, .15), (.12, .05), text="1400",
                              borders=constants.ALL,
                              border_color=gg.colors["white"],
                              background_color=(0,0,50,255))

        self.resolution_custom_X = text.Text(self, (.46, .15), (.03, .05),
                                             text="X", base_font=gg.font[1],
                                             background_color=gg.colors["clear"])

        self.resolution_custom_vert = \
            text.EditableText(self, (.496, .15), (.12, .05), text="1050",
                              borders=constants.ALL,
                              border_color=gg.colors["white"],
                              background_color=(0,0,50,255))

        self.resolution_apply = \
            button.FunctionButton(self, (.66, .15), (.12, .05),
                                  text="APPLY", text_shrink_factor=.75, hotkey="a",
                                  function=self.set_resolution_custom)

        self.soundbuf_label = text.Text(self, (.01, .22), (.25, .05),
                                        text="Sound buffering:",
                                        align=constants.LEFT,
                                        background_color=gg.colors["clear"])

        self.soundbuf_group = button.ButtonGroup()

        self.soundbuf_low = OptionButton(self, (.27, .22), (.14, .05),
                                         text="LOW", hotkey="l",
                                         function=self.set_soundbuf,
                                         args=(1024,))
        self.soundbuf_group.add(self.soundbuf_low)

        self.soundbuf_normal = OptionButton(self, (.44, .22), (.17, .05),
                                            text="NORMAL", hotkey="n",
                                            function=self.set_soundbuf,
                                            args=(1024*2,))
        self.soundbuf_group.add(self.soundbuf_normal)

        self.soundbuf_high = OptionButton(self, (.64, .22), (.14, .05),
                                          text="HIGH", hotkey="h",
                                          function=self.set_soundbuf,
                                          args=(1024*4,))
        self.soundbuf_group.add(self.soundbuf_high)

        self.language_label = text.Text(self, (.01, .30), (.15, .05),
                                        text="Language:", align=constants.LEFT,
                                        background_color=gg.colors["clear"])

        self.language_choice = \
            listbox.UpdateListbox(self, (.17, .30), (.21, .25),
                                  list=g.available_languages(),
                                  update_func=self.set_language)

        self.daynight_label = text.Text(self, (.55, .30), (.15, .05),
                                        text="Day/night display:", underline=2,
                                        background_color=gg.colors["clear"])
        self.daynight_toggle = OptionButton(self, (.71, .30), (.07, .05),
                                        text="NO", text_shrink_factor=.75,
                                        hotkey="y", force_underline=-1,
                                        function=self.set_daynight,
                                        args=(button.TOGGLE_VALUE,))

        self.save_button = button.FunctionButton(self, (.42, .45), (.34, .05),
                                                 text="SAVE OPTIONS TO DISK",
                                                 hotkey="d",
                                                 function=save_options)