Exemplo n.º 1
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 = (.80, .85)
        self.pos = (.5, .5)
        self.anchor = constants.MID_CENTER
        self.background_color = "options_background"
        self.borders = ()

        # Tabs panel
        self.general_pane = GeneralPane(None, (0, .1), (.80, .75))
        self.video_pane = VideoPane(None, (0, .1), (.80, .75))
        self.audio_pane = AudioPane(None, (0, .1), (.80, .75))
        self.gui_pane = GUIPane(None, (0, .1), (.80, .75))

        self.tabs_panes = (self.general_pane, self.video_pane, self.audio_pane,
                           self.gui_pane)

        # Tabs buttons
        self.tabs_buttons = button.ButtonGroup()

        self.general_tab = OptionButton(self, (-.20, .01), (-.20, .05),
                                        anchor=constants.TOP_CENTER,
                                        autohotkey=True,
                                        function=self.set_tabs_pane,
                                        args=(self.general_pane, ))
        self.tabs_buttons.add(self.general_tab)

        self.video_tab = OptionButton(self, (-.40, .01), (-.20, .05),
                                      anchor=constants.TOP_CENTER,
                                      autohotkey=True,
                                      function=self.set_tabs_pane,
                                      args=(self.video_pane, ))
        self.tabs_buttons.add(self.video_tab)

        self.audio_tab = OptionButton(self, (-.60, .01), (-.20, .05),
                                      anchor=constants.TOP_CENTER,
                                      autohotkey=True,
                                      function=self.set_tabs_pane,
                                      args=(self.audio_pane, ))
        self.tabs_buttons.add(self.audio_tab)

        self.gui_tab = OptionButton(self, (-.80, .01), (-.202, .05),
                                    anchor=constants.TOP_CENTER,
                                    autohotkey=True,
                                    function=self.set_tabs_pane,
                                    args=(self.gui_pane, ))
        self.tabs_buttons.add(self.gui_tab)

        self.general_tab.chosen_one()
        self.set_tabs_pane(self.general_pane)

        # YesNoDialog buttons
        self.yes_button.size = (.15, .05)
        self.no_button.size = (.15, .05)
Exemplo n.º 2
0
    def __init__(self, *args, **kwargs):
        kwargs.setdefault("yes_type", N_("&OK"))
        kwargs.setdefault("no_type", N_("&CANCEL"))
        super(OptionsScreen, self).__init__(*args, **kwargs)
        self.yes_button.function = self.check_restart

        self.size = (.80, .85)
        self.pos = (.5, .5)
        self.anchor = constants.MID_CENTER
        self.background_color = "options_background"

        # Tabs panel
        self.general_pane   = GeneralPane(None, (0, .1), (.80, .75))
        self.video_pane     = VideoPane(None, (0, .1), (.80, .75))
        self.audio_pane     = AudioPane(None, (0, .1), (.80, .75))
        self.gui_pane       = GUIPane(None, (0, .1), (.80, .75))

        self.tabs_panes = (self.general_pane, self.video_pane, self.audio_pane, self.gui_pane)

        # Tabs buttons
        self.tabs_buttons = button.ButtonGroup()

        self.general_tab = OptionGroupButton(self, (-.135, .01), (-.240, .05),
                                             autotranslate=True,
                                             text=N_("&General"),
                                             anchor=constants.TOP_CENTER,
                                             function=self.set_tabs_pane, args=(self.general_pane,))
        self.tabs_buttons.add(self.general_tab)

        self.video_tab = OptionGroupButton(self, (-.3790, .01), (-.240, .05),
                                           autotranslate=True,
                                           text=N_("&Video"),
                                           anchor = constants.TOP_CENTER,
                                           function=self.set_tabs_pane, args=(self.video_pane,))
        self.tabs_buttons.add(self.video_tab)

        self.audio_tab = OptionGroupButton(self, (-.6230, .01), (-.240, .05),
                                           autotranslate=True,
                                           text=N_("&Audio"),
                                           anchor=constants.TOP_CENTER,
                                           function=self.set_tabs_pane, args=(self.audio_pane,))
        self.tabs_buttons.add(self.audio_tab)

        self.gui_tab = OptionGroupButton(self, (-.865, .01), (-.235, .05),
                                         autotranslate=True,
                                         text=N_("&Interface"),
                                         anchor=constants.TOP_CENTER,
                                         function=self.set_tabs_pane, args=(self.gui_pane,))
        self.tabs_buttons.add(self.gui_tab)

        self.general_tab.chosen_one()
        self.set_tabs_pane(self.general_pane)

        # YesNoDialog buttons
        self.yes_button.size = (.15, .05)
        self.no_button.size = (.15, .05)
Exemplo n.º 3
0
    def __init__(self, parent, pos=(.5, .1), size=(.93, .73), *args, **kwargs):
        super(ReportScreen, self).__init__(parent, pos, size, *args, **kwargs)

        kwargs.setdefault("background_color", "clear")

        self.format_buttons = button.ButtonGroup()

        self.stats_button = button.DialogButton(self, (-.49, -.99), (-.3, -.1),
                                                autotranslate=True,
                                                text=N_("&STATISTICS"),
                                                anchor=constants.BOTTOM_RIGHT,
                                                dialog=stat.StatScreen(self))
        self.back_button = button.ExitDialogButton(
            self,
            (-.51, -.99),
            (-.3, -.1),
            autotranslate=True,
            text=N_("&BACK"),
            anchor=constants.BOTTOM_LEFT,
        )
        self.add_key_handler(pygame.K_ESCAPE,
                             self.back_button.activate_with_sound)

        self.money_report_pane = widget.BorderedWidget(
            self, (0, .08), (-.45, -.72), anchor=constants.TOP_LEFT)
        self.cpu_report_pane = widget.BorderedWidget(
            self, (-1, .08), (-.45, -.72), anchor=constants.TOP_RIGHT)

        self.format_button_midnight = FormatButton(self, (-.5, 0),
                                                   (-.15, -.08),
                                                   autotranslate=True,
                                                   text=N_("&Midnight"),
                                                   anchor=constants.TOP_RIGHT,
                                                   function=self.format_toggle)
        self.format_button_midnight.args = (self.format_button_midnight, True)
        self.format_buttons.add(self.format_button_midnight)

        self.format_button_24hours = FormatButton(self, (-.5, 0), (-.15, -.08),
                                                  autotranslate=True,
                                                  text=N_("24 &Hours"),
                                                  anchor=constants.TOP_LEFT,
                                                  function=self.format_toggle)
        self.format_button_24hours.args = (self.format_button_24hours, False)
        self.format_buttons.add(self.format_button_24hours)

        self.format_button_midnight.chosen_one()
        self.midnight_stop = True
Exemplo n.º 4
0
    def __init__(self,
                 parent=None,
                 pos=(0, 0),
                 size=(1, 1),
                 anchor=constants.TOP_LEFT,
                 *args,
                 **kwargs):

        super(MapScreen, self).__init__(parent, pos, size, anchor, *args,
                                        **kwargs)

        g.map_screen = self

        self.background_color = "map_background"
        self.add_handler(constants.TICK, self.on_tick)

        self.map = EarthImage(self)

        self.location_buttons = {}
        for loc in g.locations.values():
            if loc.absolute:
                button_parent = self
            else:
                button_parent = self.map
            b = button.FunctionButton(button_parent, (loc.x, loc.y),
                                      anchor=constants.MID_CENTER,
                                      function=self.open_location,
                                      args=(loc.id, ))
            self.location_buttons[loc.id] = b

        self.location_dialog = LocationScreen(self)

        self.suspicion_bar = \
            text.FastStyledText(self, (0,.92), (1, .04), base_font="special",
                                wrap=False,
                                background_color="pane_background_empty",
                                border_color="pane_background",
                                borders=constants.ALL, align=constants.LEFT)
        widget.unmask_all(self.suspicion_bar)

        self.danger_bar = \
            text.FastStyledText(self, (0,.96), (1, .04), base_font="special",
                                wrap=False,
                                background_color="pane_background_empty",
                                border_color="pane_background",
                                borders=constants.ALL, align=constants.LEFT)
        widget.unmask_all(self.danger_bar)

        self.report_button = button.DialogButton(
            self, (0, 0.88), (0.15, 0.04),
            autohotkey=True,
            dialog=report.ReportScreen(self))

        self.knowledge_button = button.DialogButton(
            self, (0.85, 0.88), (0.15, 0.04),
            autohotkey=True,
            dialog=knowledge.KnowledgeScreen(self))

        self.log_button = button.DialogButton(self, (0.5, 0.88), (0.15, 0.04),
                                              autohotkey=True,
                                              anchor=constants.TOP_CENTER,
                                              dialog=log.LogScreen(self))

        if g.cheater:
            # Create cheat menu
            # Cheat menu button must be created before menu button to avoid bug.

            self.cheat_dialog = CheatMenuDialog(self)
            self.cheat_button = button.DialogButton(
                self,
                (0, 0),
                (.01, .01),
                text="",
                # Translators: hotkey to open the cheat screen menu.
                # Should preferably be near the ESC key, and it must not be a
                # dead key (ie, it must print a char with a single keypress)
                hotkey=_("`"),
                dialog=self.cheat_dialog)

        self.menu_dialog = GameMenuDialog(self)

        def show_menu():
            exit = dialog.call_dialog(self.menu_dialog, self)
            if exit:
                raise constants.ExitDialog

        self.menu_button = button.FunctionButton(self, (0, 0), (0.13, 0.04),
                                                 autohotkey=True,
                                                 function=show_menu)

        # Display current game difficulty right below the 'Menu' button
        # An alternative location is above 'Reports': (0, 0.84), (0.15, 0.04)
        self.difficulty_display = \
            text.FastText(self, (0, 0.05), (0.13, 0.04),
                          wrap=False,
                          base_font="special",
                          background_color="pane_background_empty",
                          border_color="pane_background")

        self.time_display = text.FastText(
            self, (.14, 0), (0.23, 0.04),
            wrap=False,
            text=_("DAY") + " 0000, 00:00:00",
            base_font="special",
            background_color="pane_background_empty",
            border_color="pane_background",
            borders=constants.ALL)

        self.research_button = \
            button.DialogButton(self, (.14, 0.05), (0, 0.04),
                                autohotkey=True,
                                dialog=research.ResearchScreen(self))

        bar = u"\u25AE"
        arrow = u"\u25B6"
        speed_button_souls = [(bar * 2, .025, speeds[0]),
                              (arrow, .024, speeds[1]),
                              (arrow * 2, .033, speeds[2]),
                              (arrow * 3, .044, speeds[3]),
                              (arrow * 4, .054, speeds[4])]

        self.speed_buttons = button.ButtonGroup()
        hpos = .38
        for index, (text_, hsize, speed) in enumerate(speed_button_souls):
            hotkey = str(index)
            b = SpeedButton(self, (hpos, 0), (hsize, .04),
                            text=text_,
                            hotkey=hotkey,
                            base_font="normal",
                            text_shrink_factor=.75,
                            align=constants.CENTER,
                            function=self.set_speed,
                            args=(speed, False))
            hpos += hsize
            self.speed_buttons.add(b)

        self.info_window = \
            widget.BorderedWidget(self, (.56, 0), (.44, .08),
                                  background_color="pane_background_empty",
                                  border_color="pane_background",
                                  borders=constants.ALL)
        widget.unmask_all(self.info_window)

        self.cash_display = \
            text.FastText(self.info_window, (0,0), (-1, -.5),
                          wrap=False,
                          base_font="special", shrink_factor = .7,
                          borders=constants.ALL,
                          background_color="pane_background_empty",
                          border_color="pane_background")

        self.cpu_display = \
            text.FastText(self.info_window, (0,-.5), (-1, -.5),
                          wrap=False,
                          base_font="special", shrink_factor=.7,
                          borders=
                           (constants.LEFT, constants.RIGHT, constants.BOTTOM),
                          background_color="pane_background_empty",
                          border_color="pane_background")

        self.message_dialog = dialog.MessageDialog(self, text_size=20)

        self.messages = message.MessageDialogs(self)
        self.needs_warning = True

        self.add_key_handler(pygame.K_ESCAPE, self.got_escape)

        self.add_key_handler(constants.XO1_X, self.got_XO1)
        self.add_key_handler(constants.XO1_O, self.got_XO1)
        self.add_key_handler(constants.XO1_SQUARE, self.got_XO1)
Exemplo n.º 5
0
    def __init__(self, *args, **kwargs):
        super(AudioPane, self).__init__(*args, **kwargs)

        self.sound_label = button.HotkeyText(self, (-.49, .01), (.10, .05),
                                             anchor=constants.TOP_RIGHT,
                                             align=constants.LEFT,
                                             autohotkey=True,
                                             background_color="clear")
        self.sound_toggle = OptionButton(self, (-.51, .01), (.07, .05),
                                         anchor=constants.TOP_LEFT,
                                         text_shrink_factor=.75,
                                         force_underline=-1,
                                         function=self.set_sound,
                                         args=(button.TOGGLE_VALUE, ))
        self.sound_label.hotkey_target = self.sound_toggle

        self.gui_label = text.Text(self, (.01, .08), (.22, .05),
                                   anchor=constants.TOP_LEFT,
                                   align=constants.LEFT,
                                   background_color="clear")
        self.gui_slider = slider.UpdateSlider(self, (.24, .08), (.53, .05),
                                              anchor=constants.TOP_LEFT,
                                              horizontal=True,
                                              priority=150,
                                              slider_max=100,
                                              slider_size=5)
        self.gui_slider.update_func = self.on_gui_volume_change

        self.music_label = text.Text(self, (.01, .15), (.22, .05),
                                     anchor=constants.TOP_LEFT,
                                     align=constants.LEFT,
                                     background_color="clear")
        self.music_slider = slider.UpdateSlider(self, (.24, .15), (.53, .05),
                                                anchor=constants.TOP_LEFT,
                                                horizontal=True,
                                                priority=150,
                                                slider_max=100,
                                                slider_size=5)
        self.music_slider.update_func = self.on_music_volume_change

        self.soundbuf_label = text.Text(self, (.01, .22), (.25, .05),
                                        text=_("Sound buffering:"),
                                        align=constants.LEFT,
                                        background_color="clear")
        self.soundbuf_group = button.ButtonGroup()

        self.soundbuf_low = OptionButton(self, (.24, .22), (.14, .05),
                                         text=_("&LOW"),
                                         autohotkey=True,
                                         function=self.set_soundbuf,
                                         args=(1024, ))
        self.soundbuf_group.add(self.soundbuf_low)

        self.soundbuf_normal = OptionButton(self, (.42, .22), (.17, .05),
                                            text=_("&NORMAL"),
                                            autohotkey=True,
                                            function=self.set_soundbuf,
                                            args=(1024 * 2, ))
        self.soundbuf_group.add(self.soundbuf_normal)

        self.soundbuf_high = OptionButton(self, (.63, .22), (.14, .05),
                                          text=_("&HIGH"),
                                          autohotkey=True,
                                          function=self.set_soundbuf,
                                          args=(1024 * 4, ))
        self.soundbuf_group.add(self.soundbuf_high)