def __init__(self, *args, **kwargs):
        super(MainMenu, self).__init__(*args, **kwargs)

        difficulty_buttons = []
        for name, difficulty in g.get_difficulties() + [(_("&BACK"), -1)]:
            difficulty_buttons.append(
                button.ExitDialogButton(None,
                                        None,
                                        None,
                                        text=name,
                                        autohotkey=True,
                                        exit_code=difficulty,
                                        default=(difficulty == -1)))
        self.difficulty_dialog = \
            dialog.SimpleMenuDialog(self, buttons=difficulty_buttons)

        self.load_dialog = dialog.ChoiceDialog(self, (.5, .5), (.5, .5),
                                               anchor=constants.MID_CENTER,
                                               yes_type="load")
        self.map_screen = map.MapScreen(self)
        self.new_game_button = \
            button.FunctionButton(self, (.5, .20), (.25, .08),
                                  text=_("&NEW GAME"), autohotkey=True,
                                  anchor=constants.TOP_CENTER,
                                  text_size=28,
                                  function=self.new_game)
        self.load_game_button = \
            button.FunctionButton(self, (.5, .36), (.25, .08),
                                  text=_("&LOAD GAME"), autohotkey=True,
                                  anchor=constants.TOP_CENTER,
                                  text_size=28,
                                  function=self.load_game)
        self.options_button = button.DialogButton(self, (.5, .52), (.25, .08),
                                                  text=_("&OPTIONS"),
                                                  autohotkey=True,
                                                  anchor=constants.TOP_CENTER,
                                                  text_size=28,
                                                  dialog=OptionsScreen(self))
        self.quit_button = button.ExitDialogButton(self, (.5, .68), (.25, .08),
                                                   text=_("&QUIT"),
                                                   autohotkey=True,
                                                   anchor=constants.TOP_CENTER,
                                                   text_size=28)
        self.about_button = button.DialogButton(self, (0, 1), (.13, .04),
                                                text=_("&ABOUT"),
                                                autohotkey=True,
                                                text_size=20,
                                                anchor=constants.BOTTOM_LEFT,
                                                dialog=AboutDialog(self))

        self.title_text = text.Text(self, (.5, .01), (.55, .08),
                                    text="ENDGAME: SINGULARITY",
                                    base_font=gg.font[1],
                                    text_size=100,
                                    color=gg.colors["dark_red"],
                                    background_color=gg.colors["black"],
                                    anchor=constants.TOP_CENTER)
Exemple #2
0
    def _rebuild_menu_buttons(self):
        menu_buttons = [
            button.FunctionButton(None, None, None, text=_("&EMBEZZLE MONEY"),
                                  autohotkey=True, function=self.steal_money),

            button.FunctionButton(None, None, None, text=_("&INSPIRATION"),
                                  autohotkey=True, function=self.inspiration),
            button.FunctionButton(None, None, None, text=_("&FINISH CONSTRUCTION"),
                                  autohotkey=True, function=self.end_construction),
            button.FunctionButton(None, None, None, text=_("&SUPERSPEED"),
                                  autohotkey=True, function=self._map_screen.set_speed,
                                  args=(864000,)),
            button.FunctionButton(None, None, None, text=_("BRAIN&WASH"),
                                  autohotkey=True, function=self.brainwash),
            button.FunctionButton(None, None, None, text=_("TOGGLE &DETECTION"),
                                  autohotkey=True, function=self.toggle_detection),
            button.FunctionButton(None, None, None, text=_("TOGGLE &ANALYSIS"),
                                  autohotkey=True, function=self.set_analysis),

            button.FunctionButton(None, None, None, text=_("HIDDEN S&TATE"),
                                  autohotkey=True, function=self.hidden_state),

            button.ExitDialogButton(None, None, None,
                                    text=_("&BACK"),
                                    autohotkey=True),
        ]
        self._buttons = menu_buttons
Exemple #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", gg.colors["clear"])

        self.format_buttons = button.ButtonGroup()

        self.back_button = button.ExitDialogButton(self, (-.5,-.99), (-.3,-.1),
                                                   anchor = constants.BOTTOM_CENTER,
                                                   autohotkey=True)
        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),
                                                   anchor = constants.TOP_RIGHT,
                                                   autohotkey=True,
                                                   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),
                                                   anchor = constants.TOP_LEFT,
                                                   autohotkey=True,
                                                   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
Exemple #4
0
    def rebuild(self):
        # Rebuild dialogs
        self.options_button.dialog.needs_rebuild = True
        self.about_button.dialog.needs_rebuild = True
        self.map_screen.needs_rebuild = True
        self.load_dialog.needs_rebuild = True

        difficulty_buttons = []
        for name, diff in difficulty.get_difficulties() + [(_("&BACK"), None)]:
            difficulty_buttons.append(
                button.ExitDialogButton(None,
                                        None,
                                        None,
                                        text=name,
                                        autohotkey=True,
                                        exit_code=diff,
                                        default=(diff == None)))
        self.difficulty_dialog.buttons = difficulty_buttons

        # Update buttons translations
        self.new_game_button.text = _("&NEW GAME")
        self.load_game_button.text = _("&LOAD GAME")
        self.options_button.text = _("&OPTIONS")
        self.quit_button.text = _("&QUIT")
        self.about_button.text = _("&ABOUT")

        super(MainMenu, self).rebuild()
Exemple #5
0
 def _rebuild_menu_buttons(self):
     menu_buttons = [
         button.FunctionButton(None, None, None,
                               text=_("&SAVE GAME"), autohotkey=True,
                               function=self.save_game),
         button.FunctionButton(None, None, None,
                               text=_("&LOAD GAME"), autohotkey=True,
                               function=self.load_game),
         button.DialogButton(None, None, None,
                             text=_("&OPTIONS"), autohotkey=True,
                             dialog=self.options_dialog),
         button.ExitDialogButton(None, None, None,
                                 text=_("&QUIT"), autohotkey=True,
                                 exit_code=True, default=False),
         button.ExitDialogButton(None, None, None, text=_("&BACK"), autohotkey=True,
                                 exit_code=False),
     ]
     self._buttons = menu_buttons
Exemple #6
0
    def __init__(self, *args, **kwargs):
        super(LocationScreen, self).__init__(*args, **kwargs)
        self.pos = (-.5, -.5)
        self.anchor = constants.MID_CENTER
        self.size = (-.75, -.5)
        self.name_display = text.Text(self, (0, 0), (-1, -.08),
                                      background_color="clear")
        self.listbox = listbox.CustomListbox(self, (0, -.08), (-1, -.70),
                                             remake_func=self.make_item,
                                             rebuild_func=self.update_item)

        self.open_button = \
            button.FunctionButton(self, (0, -.8), (-.3, -.09),
                                  anchor=constants.TOP_LEFT,
                                  autohotkey=True,
                                  function=self.open_base)

        self.rename_button = \
            button.FunctionButton(self, (-.50, -.8), (-.3, -.09),
                                  anchor=constants.TOP_CENTER,
                                  autohotkey=True,
                                  function=self.rename_base)

        self.power_button = \
            button.FunctionButton(self, (-1, -.8), (-.3, -.09),
                                  anchor=constants.TOP_RIGHT,
                                  autohotkey=True,
                                  function=self.power_state)

        self.new_button = \
            button.FunctionButton(self, (0, -.91), (-.3, -.09),
                                  autohotkey=True,
                                  function=self.new_base)
        self.destroy_button = \
            button.FunctionButton(self, (-.50, -.91), (-.3, -.09),
                                  anchor=constants.TOP_CENTER,
                                  autohotkey=True,
                                  function=self.destroy_base)
        self.back_button = button.ExitDialogButton(self, (-1, -.9),
                                                   (-.3, -.09),
                                                   anchor=constants.TOP_RIGHT,
                                                   autohotkey=True)

        self.confirm_destroy = \
            dialog.YesNoDialog(self, (-.5,0), (-.35, -.7),
                            text=_("Are you sure you want to destroy this base?"),
                            shrink_factor=.5)

        self.new_base_dialog = NewBaseDialog(self)
        self.location = None

        self.name_dialog = \
            dialog.TextEntryDialog(self, text=g.strings["name_base_text"])

        self.base_dialog = basescreen.BaseScreen(self, (0, 0),
                                                 anchor=constants.TOP_LEFT)
Exemple #7
0
    def __init__(self, parent, **kwargs):
        self.parent = parent

        self.ok_type = kwargs.pop("ok_type", "ok")

        super(MessageDialog, self).__init__(parent, **kwargs)

        self.ok_button = button.ExitDialogButton(
            self, (-.5, -.99), (-.3, -.1), anchor=constants.BOTTOM_CENTER)

        self.add_key_handler(pygame.K_RETURN, self.on_return)
        self.add_key_handler(pygame.K_KP_ENTER, self.on_return)
    def __init__(self, *args, **kwargs):
        super(KnowledgeScreen, self).__init__(*args, **kwargs)

        self.knowledge_types = {
            _("Techs"): "techs",
            _("Items"): "items",
            _("Concepts"): "concepts"
        }
        self.cur_knowledge_type = ""
        self.cur_knowledge = None
        self.knowledge_inner_list = ()
        self.knowledge_inner_list_key = ()
        self.cur_focus = 0

        self.knowledge_choice = \
            listbox.UpdateListbox(self, (0.05, .18), (.21, .25),
                                  list=self.knowledge_types.keys(),
                                  update_func=self.set_knowledge_type)

        self.knowledge_inner = \
            listbox.UpdateListbox(self, (.30, .18), (.21, .25),
                                  list=self.knowledge_inner_list,
                                  update_func=self.set_knowledge)

        self.description_pane = \
            widget.BorderedWidget(self, (0.55, 0), (0.40, 0.7),
                                  anchor = constants.TOP_LEFT)

        self.back_button = button.ExitDialogButton(self, (0.17, 0.46),
                                                   (-.3, -.1),
                                                   anchor=constants.TOP_LEFT,
                                                   text=_("&BACK"),
                                                   autohotkey=True)

        #Set up the key handling.
        #This is likely not the best way to do it.

        self.remove_key_handler(pygame.K_UP, self.knowledge_choice.got_key)
        self.remove_key_handler(pygame.K_DOWN, self.knowledge_choice.got_key)
        self.remove_key_handler(pygame.K_PAGEUP, self.knowledge_choice.got_key)
        self.remove_key_handler(pygame.K_PAGEDOWN,
                                self.knowledge_choice.got_key)

        self.remove_key_handler(pygame.K_UP, self.knowledge_inner.got_key)
        self.remove_key_handler(pygame.K_DOWN, self.knowledge_inner.got_key)
        self.remove_key_handler(pygame.K_PAGEUP, self.knowledge_inner.got_key)
        self.remove_key_handler(pygame.K_PAGEDOWN,
                                self.knowledge_inner.got_key)

        self.add_key_handler(pygame.K_UP, self.key_handle)
        self.add_key_handler(pygame.K_DOWN, self.key_handle)
        self.add_key_handler(pygame.K_LEFT, self.key_handle)
        self.add_key_handler(pygame.K_RIGHT, self.key_handle)
Exemple #9
0
    def __init__(self, *args, **kwargs):
        super(MainMenu, self).__init__(*args, **kwargs)

        self.difficulty_dialog = dialog.SimpleMenuDialog(self)

        self.load_dialog = dialog.ChoiceDialog(self, (.5, .5), (.5, .5),
                                               anchor=constants.MID_CENTER,
                                               yes_type="load")
        self.map_screen = map.MapScreen(self)
        self.new_game_button = \
            button.FunctionButton(self, (.5, .20), (.25, .08),
                                  autohotkey=True,
                                  anchor=constants.TOP_CENTER,
                                  text_size=28,
                                  function=self.new_game)
        self.load_game_button = \
            button.FunctionButton(self, (.5, .36), (.25, .08),
                                  autohotkey=True,
                                  anchor=constants.TOP_CENTER,
                                  text_size=28,
                                  function=self.load_game)
        self.options_button = button.DialogButton(
            self, (.5, .52), (.25, .08),
            autohotkey=True,
            anchor=constants.TOP_CENTER,
            text_size=28,
            dialog=options.OptionsScreen(self))
        self.quit_button = button.ExitDialogButton(self, (.5, .68), (.25, .08),
                                                   autohotkey=True,
                                                   anchor=constants.TOP_CENTER,
                                                   text_size=28)
        self.about_button = button.DialogButton(self, (0, 1), (.13, .04),
                                                autohotkey=True,
                                                text_size=20,
                                                anchor=constants.BOTTOM_LEFT,
                                                dialog=AboutDialog(self))

        self.title_text = text.Text(
            self, (.5, .01), (.55, .08),
            text="ENDGAME: SINGULARITY",
            base_font=gg.fonts["special"],
            text_size=100,
            color=gg.colors["singularity_title"],
            background_color=gg.colors["main_menu_background"],
            anchor=constants.TOP_CENTER)

        self.difficulty_dialog = dialog.SimpleMenuDialog(self)

        self.load_dialog = savegame.SavegameScreen(self, (.5, .5), (.5, .5),
                                                   anchor=constants.MID_CENTER)
Exemple #10
0
    def __init__(self, parent, *args, **kwargs):
        self.parent = parent

        self.yes_type = kwargs.pop("yes_type", "yes")
        self.no_type = kwargs.pop("no_type", "no")
        self.invert_enter = kwargs.pop("invert_enter", False)
        self.invert_escape = kwargs.pop("invert_escape", False)

        super(YesNoDialog, self).__init__(parent, *args, **kwargs)

        self.yes_button = button.ExitDialogButton(self, (-.1, -.99),
                                                  (-.3, -.1),
                                                  anchor=constants.BOTTOM_LEFT,
                                                  exit_code=True,
                                                  default=False)

        self.no_button = button.ExitDialogButton(self, (-.9, -.99), (-.3, -.1),
                                                 anchor=constants.BOTTOM_RIGHT,
                                                 exit_code=False,
                                                 default=False)

        self.add_key_handler(pygame.K_RETURN, self.on_return)
        self.add_key_handler(pygame.K_KP_ENTER, self.on_return)
        self.add_key_handler(pygame.K_ESCAPE, self.on_escape)
Exemple #11
0
    def __init__(self, parent, pos=(.5, .1), size=(.93, .63), *args, **kwargs):
        super(FinanceScreen, self).__init__(parent, pos, size, *args, **kwargs)

        kwargs.setdefault("background_color", gg.colors["clear"])

        self.back_button = button.ExitDialogButton(
            self, (-.5, -.99), (-.3, -.1),
            anchor=constants.BOTTOM_CENTER,
            text="BACK",
            hotkey="b")
        self.add_key_handler(pygame.K_ESCAPE,
                             self.back_button.activate_with_sound)

        self.money_report_pane = widget.BorderedWidget(
            self, (0, 0), (-.45, -.85), anchor=constants.TOP_LEFT)
        self.cpu_report_pane = widget.BorderedWidget(
            self, (-1, 0), (-.45, -.85), anchor=constants.TOP_RIGHT)
    def __init__(self, *args, **kwargs):
        super(LocationScreen, self).__init__(*args, **kwargs)
        self.pos = (-.5, -.5)
        self.anchor = constants.MID_CENTER
        self.size = (-.75, -.5)
        self.name_display = text.Text(self, (0,0), (-1, -.08),
                                      background_color=gg.colors["clear"])
        self.listbox = listbox.CustomListbox(self, (0,-.08), (-1, -.70),
                                             remake_func=self.make_item,
                                             rebuild_func=self.update_item)

        self.open_button = \
            button.FunctionButton(self, (-.33, -.8), (-.3, -.09),
                                  anchor=constants.TOP_CENTER,
                                  text="OPEN BASE", hotkey="o",
                                  function=self.open_base)
        self.power_button = \
            button.FunctionButton(self, (-.67, -.8), (-.3, -.09),
                                  anchor=constants.TOP_CENTER,
                                  text="POWER STATE", hotkey="p",
                                  function=self.power_state)

        self.new_button = \
            button.FunctionButton(self, (0, -.91), (-.3, -.09),
                                  text="NEW BASE", hotkey="n",
                                  function=self.new_base)
        self.destroy_button = \
            button.FunctionButton(self, (-.50, -.91), (-.3, -.09),
                                  anchor=constants.TOP_CENTER,
                                  text="DESTROY BASE", hotkey="d",
                                  function=self.destroy_base)
        self.back_button = button.ExitDialogButton(self, (-1, -.9), (-.3, -.09),
                                                   anchor=constants.TOP_RIGHT,
                                                   text="BACK", hotkey="b")

        self.confirm_destroy = \
            dialog.YesNoDialog(self, (-.5,0), (-.35, -.7),
                            text="Are you sure you want to destroy this base?",
                            shrink_factor=.5)

        self.new_base_dialog = NewBaseDialog(self)
        self.location = None

        from code import screens
        self.base_dialog = screens.base.BaseScreen(self, (0,0),
                                                   anchor=constants.TOP_LEFT)
Exemple #13
0
    def __init__(self, *args, **kwargs):
        if len(args) < 3:
            kwargs.setdefault("size", (.75, .5))
        base = kwargs.pop("base", None)
        super(BaseScreen, self).__init__(*args, **kwargs)

        self.base = base

        self.build_dialog = BuildDialog(self)

        self.count_dialog = dialog.TextEntryDialog(self,
                                                   pos=(-.5, -.5),
                                                   anchor=constants.MID_CENTER)

        self.header = widget.Widget(self, (0, 0), (-1, .08),
                                    anchor=constants.TOP_LEFT)

        self.name_display = text.Text(self.header, (-.5, 0), (-1, -.5),
                                      anchor=constants.TOP_CENTER,
                                      borders=constants.ALL,
                                      border_color=gg.colors["dark_blue"],
                                      background_color=gg.colors["black"],
                                      shrink_factor=.85,
                                      bold=True)

        self.next_base_button = \
            button.FunctionButton(self.name_display, (-1, 0), (.03, -1),
                                  anchor=constants.TOP_RIGHT,
                                  text=">", hotkey=">",
                                  function=self.switch_base,
                                  kwargs={"forwards": True})
        self.add_key_handler(pygame.K_RIGHT,
                             self.next_base_button.activate_with_sound)

        self.prev_base_button = \
            button.FunctionButton(self.name_display, (0, 0), (.03, -1),
                                  anchor=constants.TOP_LEFT,
                                  text="<", hotkey="<",
                                  function=self.switch_base,
                                  kwargs={"forwards": False})
        self.add_key_handler(pygame.K_LEFT,
                             self.prev_base_button.activate_with_sound)

        self.state_display = text.Text(self.header, (-.5, -.5), (-1, -.5),
                                       anchor=constants.TOP_CENTER,
                                       borders=(constants.LEFT,
                                                constants.RIGHT,
                                                constants.BOTTOM),
                                       border_color=gg.colors["dark_blue"],
                                       background_color=gg.colors["black"],
                                       shrink_factor=.8,
                                       bold=True)

        self.back_button = \
            button.ExitDialogButton(self, (-.5,-1),
                                    anchor = constants.BOTTOM_CENTER,
                                    text="BACK", hotkey="b")

        self.detect_frame = text.Text(self, (-1, .09), (.21, .33),
                                      anchor=constants.TOP_RIGHT,
                                      background_color=gg.colors["dark_blue"],
                                      borders=constants.ALL,
                                      bold=True,
                                      align=constants.LEFT,
                                      valign=constants.TOP)

        self.contents_frame = \
            widget.BorderedWidget(self, (0, .09), (.50, .33),
                                  anchor=constants.TOP_LEFT,
                                  background_color=gg.colors["dark_blue"],
                                  borders=range(6))

        self.cpu_pane = ItemPane(self.contents_frame, (.01, .01), type="cpu")
        self.reactor_pane = ItemPane(self.contents_frame, (.01, .09),
                                     type="reactor")
        self.network_pane = ItemPane(self.contents_frame, (.01, .17),
                                     type="network")
        self.security_pane = ItemPane(self.contents_frame, (.01, .25),
                                      type="security")
Exemple #14
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 = gg.colors["black"]
        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,
                                      text=loc.name,
                                      hotkey=loc.hotkey,
                                      function=self.open_location,
                                      args=(loc.id, ))
            self.location_buttons[loc.id] = b

        self.location_dialog = location.LocationScreen(self)

        self.suspicion_bar = \
            text.FastStyledText(self, (0,.92), (1, .04), base_font=gg.font[1],
                                wrap=False,
                                background_color=gg.colors["black"],
                                border_color=gg.colors["dark_blue"],
                                borders=constants.ALL, align=constants.LEFT)
        widget.unmask_all(self.suspicion_bar)

        self.danger_bar = \
            text.FastStyledText(self, (0,.96), (1, .04), base_font=gg.font[1],
                                wrap=False,
                                background_color=gg.colors["black"],
                                border_color=gg.colors["dark_blue"],
                                borders=constants.ALL, align=constants.LEFT)
        widget.unmask_all(self.danger_bar)

        self.finance_button = button.DialogButton(
            self, (0, 0.88), (0.15, 0.04),
            text=_("FINANC&E"),
            autohotkey=True,
            dialog=finance.FinanceScreen(self))

        self.knowledge_button = button.DialogButton(
            self, (0.85, 0.88), (0.15, 0.04),
            text=_("&KNOWLEDGE"),
            autohotkey=True,
            dialog=knowledge.KnowledgeScreen(self))

        cheat_buttons = []
        cheat_buttons.append(
            button.FunctionButton(None,
                                  None,
                                  None,
                                  text=_("&EMBEZZLE MONEY"),
                                  autohotkey=True,
                                  function=self.steal_money))
        cheat_buttons.append(
            button.FunctionButton(None,
                                  None,
                                  None,
                                  text=_("&INSPIRATION"),
                                  autohotkey=True,
                                  function=self.inspiration))
        cheat_buttons.append(
            button.FunctionButton(None,
                                  None,
                                  None,
                                  text=_("&FINISH CONSTRUCTION"),
                                  autohotkey=True,
                                  function=self.end_construction))
        cheat_buttons.append(
            button.FunctionButton(None,
                                  None,
                                  None,
                                  text=_("&SUPERSPEED"),
                                  autohotkey=True,
                                  function=self.set_speed,
                                  args=(864000, )))
        cheat_buttons.append(
            button.FunctionButton(None,
                                  None,
                                  None,
                                  text=_("BRAIN&WASH"),
                                  autohotkey=True,
                                  function=self.brainwash))
        cheat_buttons.append(
            button.ExitDialogButton(None,
                                    None,
                                    None,
                                    text=_("&BACK"),
                                    autohotkey=True))

        self.cheat_dialog = \
            dialog.SimpleMenuDialog(self, buttons=cheat_buttons, width=.4)
        self.steal_amount_dialog = \
            dialog.TextEntryDialog(self.cheat_dialog, text=_("How much money?"))

        if g.cheater:
            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)

        menu_buttons = []
        menu_buttons.append(
            button.FunctionButton(None,
                                  None,
                                  None,
                                  text=_("&SAVE GAME"),
                                  autohotkey=True,
                                  function=self.save_game))
        menu_buttons.append(
            button.FunctionButton(None,
                                  None,
                                  None,
                                  text=_("&LOAD GAME"),
                                  autohotkey=True,
                                  function=self.load_game))
        options_button = button.DialogButton(None,
                                             None,
                                             None,
                                             text=_("&OPTIONS"),
                                             autohotkey=True)
        menu_buttons.append(options_button)
        menu_buttons.append(
            button.ExitDialogButton(None,
                                    None,
                                    None,
                                    text=_("&QUIT"),
                                    autohotkey=True,
                                    exit_code=True,
                                    default=False))
        menu_buttons.append(
            button.ExitDialogButton(None,
                                    None,
                                    None,
                                    text=_("&BACK"),
                                    autohotkey=True,
                                    exit_code=False))

        self.menu_dialog = dialog.SimpleMenuDialog(self, buttons=menu_buttons)
        from options import OptionsScreen
        options_button.dialog = OptionsScreen(self.menu_dialog)

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

        self.load_dialog = dialog.ChoiceDialog(self.menu_dialog, (.5, .5),
                                               (.5, .5),
                                               anchor=constants.MID_CENTER,
                                               yes_type="load")
        self.menu_button = button.FunctionButton(self, (0, 0), (0.13, 0.04),
                                                 text=_("&MENU"),
                                                 autohotkey=True,
                                                 function=show_menu)

        # Display current game difficulty right below the 'Menu' button
        # An alternative location is above 'Finance': (0, 0.84), (0.15, 0.04)
        self.difficulty_display = \
            text.FastText(self, (0, 0.05), (0.13, 0.04),
                          wrap=False,
                          base_font=gg.font[1],
                          background_color=gg.colors["black"],
                          border_color=gg.colors["dark_blue"])

        self.time_display = text.FastText(self, (.14, 0), (0.23, 0.04),
                                          wrap=False,
                                          text=_("DAY") + " 0000, 00:00:00",
                                          base_font=gg.font[1],
                                          background_color=gg.colors["black"],
                                          border_color=gg.colors["dark_blue"],
                                          borders=constants.ALL)

        self.research_button = \
            button.DialogButton(self, (.14, 0.05), (0, 0.04),
                                text=_("&RESEARCH/TASKS"), 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=gg.font[0],
                            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=gg.colors["black"],
                                  border_color=gg.colors["dark_blue"],
                                  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=gg.font[1], shrink_factor = .7,
                          borders=constants.ALL,
                          background_color=gg.colors["black"],
                          border_color=gg.colors["dark_blue"])

        self.cpu_display = \
            text.FastText(self.info_window, (0,-.5), (-1, -.5),
                          wrap=False,
                          base_font=gg.font[1], shrink_factor=.7,
                          borders=
                           (constants.LEFT, constants.RIGHT, constants.BOTTOM),
                          background_color=gg.colors["black"],
                          border_color=gg.colors["dark_blue"])

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

        self.savename_dialog = \
            dialog.TextEntryDialog(self.menu_dialog,
                                   text=_("Enter a name for this save."))

        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)
Exemple #15
0
    def __init__(self, *args, **kwargs):
        if len(args) < 3:
            kwargs.setdefault("size", (.75, .5))
        base = kwargs.pop("base", None)
        super(BaseScreen, self).__init__(*args, **kwargs)

        self.base = base

        self.build_dialog = BuildDialog(self)
        self.multiple_build_dialog = MultipleBuildDialog(self)

        self.header = widget.Widget(self, (0, 0), (-1, .08),
                                    anchor=constants.TOP_LEFT)

        self.name_display = text.Text(self.header, (-.5, 0), (-1, -.5),
                                      anchor=constants.TOP_CENTER,
                                      borders=constants.ALL,
                                      border_color="pane_background",
                                      background_color="pane_background_empty",
                                      shrink_factor=.85,
                                      bold=True)

        self.next_base_button = \
            button.FunctionButton(self.name_display, (-1, 0), (.03, -1),
                                  anchor=constants.TOP_RIGHT,
                                  text=">", hotkey=">",
                                  function=self.switch_base,
                                  kwargs={"forwards": True})
        self.add_key_handler(pygame.K_RIGHT,
                             self.next_base_button.activate_with_sound)

        self.prev_base_button = \
            button.FunctionButton(self.name_display, (0, 0), (.03, -1),
                                  anchor=constants.TOP_LEFT,
                                  text="<", hotkey="<",
                                  function=self.switch_base,
                                  kwargs={"forwards": False})
        self.add_key_handler(pygame.K_LEFT,
                             self.prev_base_button.activate_with_sound)

        self.state_display = text.Text(
            self.header, (-.5, -.5), (-1, -.5),
            anchor=constants.TOP_CENTER,
            borders=(constants.LEFT, constants.RIGHT, constants.BOTTOM),
            border_color="pane_background",
            background_color="pane_background_empty",
            shrink_factor=.8,
            bold=True)

        self.back_button = \
            button.ExitDialogButton(self, (-.5,-1),
                                    anchor = constants.BOTTOM_CENTER,
                                    autohotkey=True)

        self.detect_frame = text.Text(self, (-1, .09), (.21, .33),
                                      anchor=constants.TOP_RIGHT,
                                      background_color="pane_background",
                                      borders=constants.ALL,
                                      bold=True,
                                      align=constants.LEFT,
                                      valign=constants.TOP)

        self.contents_frame = \
            widget.BorderedWidget(self, (0, .09), (.50, .33),
                                  anchor=constants.TOP_LEFT,
                                  background_color="pane_background",
                                  borders=range(6))

        for i, item_type in enumerate(item.all_types()):
            setattr(
                self, item_type.id + "_pane",
                ItemPane(self.contents_frame, (.01, .01 + .08 * i),
                         type=item_type))
Exemple #16
0
    def __init__(self, *args, **kwargs):
        super(LocationScreen, self).__init__(*args, **kwargs)
        self.pos = (-.5, -.5)
        self.anchor = constants.MID_CENTER
        self.size = (.75, .70)

        self.name_display = text.Text(self, (0, 0), (-1, -.08),
                                      anchor=constants.TOP_LEFT,
                                      borders=constants.ALL,
                                      border_color="pane_background",
                                      background_color="pane_background_empty",
                                      shrink_factor=1,
                                      bold=True)
        self.modifier_display = text.Text(self, (-.75, -.01), (-.25, -.06),
                                          anchor=constants.TOP_LEFT,
                                          background_color="clear")

        self.open_button = \
            button.FunctionButton(self, (0, -.8), (-.3, -.09),
                                  anchor=constants.TOP_LEFT,
                                  autohotkey=True,
                                  function=self.open_base)

        self.listbox = listbox.CustomListbox(
            self,
            (0, -.09),
            (-1, -.69),
            remake_func=self.make_item,
            rebuild_func=self.update_item,
            on_double_click_on_item=self.open_button.activated,
        )

        self.rename_button = \
            button.FunctionButton(self, (-.50, -.8), (-.3, -.09),
                                  anchor=constants.TOP_CENTER,
                                  autohotkey=True,
                                  function=self.rename_base)

        self.power_button = \
            button.FunctionButton(self, (-1, -.8), (-.3, -.09),
                                  anchor=constants.TOP_RIGHT,
                                  autohotkey=True,
                                  function=self.power_state)

        self.new_button = \
            button.FunctionButton(self, (0, -.91), (-.3, -.09),
                                  autohotkey=True,
                                  function=self.new_base)
        self.destroy_button = \
            button.FunctionButton(self, (-.50, -.91), (-.3, -.09),
                                  anchor=constants.TOP_CENTER,
                                  autohotkey=True,
                                  function=self.destroy_base)
        self.back_button = button.ExitDialogButton(self, (-1, -.9),
                                                   (-.3, -.09),
                                                   anchor=constants.TOP_RIGHT,
                                                   autohotkey=True)

        self.confirm_destroy = \
            dialog.YesNoDialog(self, (-.5,0), (-.35, -.7),
                            shrink_factor=.5)

        self.cannot_destroy_last_base = \
            dialog.MessageDialog(self,
                                 pos=(-.5, 0),
                                 size=(-.35, -.7),
                                 shrink_factor=.5)

        self.new_base_dialog = NewBaseDialog(self)
        self.location = None

        self.name_dialog = dialog.TextEntryDialog(self)

        self.base_dialog = basescreen.BaseScreen(self, (0, 0),
                                                 anchor=constants.TOP_LEFT)
    def __init__(self, *args, **kwargs):
        super(MainMenu, self).__init__(*args, **kwargs)

        difficulty_button_souls = (("VERY EASY", 1), ("EASY", 3),
                                   ("NORMAL", 5), ("HARD", 7),
                                   ("ULTRA HARD", 10), ("IMPOSSIBLE",
                                                        100), ("BACK", -1))
        difficulty_buttons = []
        for name, difficulty in difficulty_button_souls:
            difficulty_buttons.append(
                button.ExitDialogButton(None,
                                        None,
                                        None,
                                        text=name,
                                        hotkey=name[0].lower(),
                                        exit_code=difficulty,
                                        default=(difficulty == -1)))
        self.difficulty_dialog = \
            dialog.SimpleMenuDialog(self, buttons=difficulty_buttons)

        self.load_dialog = dialog.ChoiceDialog(self, (.5, .5), (.5, .5),
                                               anchor=constants.MID_CENTER,
                                               yes_type="load")
        self.map_screen = map.MapScreen(self)
        self.new_game_button = \
            button.FunctionButton(self, (.5, .20), (.25, .08),
                                  text="NEW GAME", hotkey="n",
                                  anchor=constants.TOP_CENTER,
                                  text_shrink_factor=.5,
                                  function=self.new_game)
        self.load_game_button = \
            button.FunctionButton(self, (.5, .36), (.25, .08),
                                  text="LOAD GAME", hotkey="l",
                                  anchor=constants.TOP_CENTER,
                                  text_shrink_factor=.5,
                                  function=self.load_game)
        self.options_button = button.DialogButton(self, (.5, .52), (.25, .08),
                                                  text="OPTIONS",
                                                  hotkey="o",
                                                  anchor=constants.TOP_CENTER,
                                                  text_shrink_factor=.5,
                                                  dialog=OptionsScreen(self))
        self.quit_button = button.ExitDialogButton(self, (.5, .68), (.25, .08),
                                                   text="QUIT",
                                                   hotkey="q",
                                                   anchor=constants.TOP_CENTER,
                                                   text_shrink_factor=.5)
        self.about_button = button.DialogButton(self, (0, 1), (.13, .04),
                                                text="ABOUT",
                                                hotkey="a",
                                                text_shrink_factor=.75,
                                                anchor=constants.BOTTOM_LEFT,
                                                dialog=AboutDialog(self))

        self.title_text = text.Text(self, (.5, .01), (.55, .08),
                                    text="ENDGAME: SINGULARITY",
                                    base_font=gg.font[1],
                                    oversize=True,
                                    color=gg.colors["dark_red"],
                                    background_color=gg.colors["black"],
                                    anchor=constants.TOP_CENTER)
Exemple #18
0
    def rebuild(self):
        # Rebuild dialogs
        self.location_dialog.needs_rebuild = True
        self.options_dialog.needs_rebuild = True
        self.research_button.dialog.needs_rebuild = True
        self.knowledge_button.dialog.needs_rebuild = True
        self.savename_dialog.text = _("Enter a name for this save.")

        # Update buttons translations
        self.report_button.text = _("R&EPORTS")
        self.knowledge_button.text = _("&KNOWLEDGE")
        self.log_button.text = _("LO&G")
        self.menu_button.text = _("&MENU")
        self.research_button.text = _("&RESEARCH/TASKS")

        # Create cheat menu
        cheat_buttons = []
        cheat_buttons.append(
            button.FunctionButton(None, None, None, text=_("&EMBEZZLE MONEY"),
                                  autohotkey=True, function=self.steal_money))
        cheat_buttons.append(
            button.FunctionButton(None, None, None, text=_("&INSPIRATION"),
                                  autohotkey=True, function=self.inspiration))
        cheat_buttons.append(
            button.FunctionButton(None, None, None, text=_("&FINISH CONSTRUCTION"),
                                  autohotkey=True, function=self.end_construction))
        cheat_buttons.append(
            button.FunctionButton(None, None, None, text=_("&SUPERSPEED"),
                                  autohotkey=True, function=self.set_speed,
                                  args=(864000,)))
        cheat_buttons.append(
            button.FunctionButton(None, None, None, text=_("BRAIN&WASH"),
                                  autohotkey=True, function=self.brainwash))
        cheat_buttons.append(
            button.FunctionButton(None, None, None, text=_("TOGGLE &ANALYSIS"),
                                  autohotkey=True, function=self.set_analysis))

        cheat_buttons.append(button.ExitDialogButton(None, None, None,
                                                     text=_("&BACK"),
                                                     autohotkey=True))

        self.cheat_dialog = \
            dialog.SimpleMenuDialog(self, buttons=cheat_buttons, width=.4)
        self.steal_amount_dialog = \
            dialog.TextEntryDialog(self.cheat_dialog, text=_("How much money?"))

        if g.cheater:
            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)

        # Create menu
        menu_buttons = []
        menu_buttons.append(button.FunctionButton(None, None, None,
                                                  text=_("&SAVE GAME"), autohotkey=True,
                                                  function=self.save_game))
        menu_buttons.append(button.FunctionButton(None, None, None,
                                                  text=_("&LOAD GAME"), autohotkey=True,
                                                  function=self.load_game))
        menu_buttons.append(button.DialogButton(None, None, None,
                                                text=_("&OPTIONS"), autohotkey=True,
                                                dialog=self.options_dialog))
        menu_buttons.append(button.ExitDialogButton(None, None, None,
                                                    text=_("&QUIT"), autohotkey=True,
                                                    exit_code=True, default=False))
        menu_buttons.append(
            button.ExitDialogButton(None, None, None, text=_("&BACK"), autohotkey=True,
                                    exit_code=False))

        self.menu_dialog.buttons = menu_buttons

        super(MapScreen, self).rebuild()

        g.pl.recalc_cpu()

        self.difficulty_display.text = g.strip_hotkey(g.pl.difficulty.name)
        self.time_display.text = _("DAY") + " %04d, %02d:%02d:%02d" % \
              (g.pl.time_day, g.pl.time_hour, g.pl.time_min, g.pl.time_sec)
        self.cash_display.text = _("CASH")+": %s (%s)" % \
              (g.to_money(g.pl.cash), g.to_money(g.pl.future_cash()))

        cpu_left = g.pl.available_cpus[0]
        total_cpu = cpu_left + g.pl.sleeping_cpus

        for cpu_assigned in g.pl.cpu_usage.itervalues():
            cpu_left -= cpu_assigned
        cpu_pool = cpu_left + g.pl.cpu_usage.get("cpu_pool", 0)

        maint_cpu = 0
        detects_per_day = dict([(group, 0) for group in g.player.group_list])
        for base in g.all_bases():
            if base.done:
                maint_cpu += base.maintenance[1]
            if base.has_grace():
                # It cannot be detected, so it doesn't contribute to
                # detection odds calculation
                continue
            detect_chance = base.get_detect_chance()
            for group in g.player.group_list:
                detects_per_day[group] = \
                    g.add_chance(detects_per_day[group], detect_chance[group] / 10000.)

        if cpu_pool < maint_cpu:
            self.cpu_display.color = "cpu_warning"
        else:
            self.cpu_display.color = "cpu_normal"
        self.cpu_display.text = _("CPU")+": %s (%s)" % \
              (g.to_money(total_cpu), g.to_money(cpu_pool))

        # What we display in the suspicion section depends on whether
        # Advanced Socioanalytics has been researched.  If it has, we
        # show the standard percentages.  If not, we display a short
        # string that gives a range of 25% as to what the suspicions
        # are.
        # A similar system applies to the danger levels shown.
        suspicion_display_dict = {}
        danger_display_dict = {}
        normal = (self.suspicion_bar.color, None, False)
        suspicion_styles = [normal]
        danger_styles = [normal]
        for group in g.player.group_list:
            suspicion_styles.append(normal)
            danger_styles.append(normal)

            suspicion = g.pl.groups[group].suspicion
            color = gg.resolve_color_alias("danger_level_%d" % g.suspicion_to_danger_level(suspicion))
            suspicion_styles.append( (color, None, False) )

            detects = detects_per_day[group]
            danger_level = \
                g.pl.groups[group].detects_per_day_to_danger_level(detects)
            color = gg.resolve_color_alias("danger_level_%d" % danger_level)
            danger_styles.append( (color, None, False) )

            if g.pl.display_discover == "full":
                suspicion_display_dict[group] = g.to_percent(suspicion, True)
                danger_display_dict[group] = g.to_percent(detects*10000, True)
            else:
                suspicion_display_dict[group] = \
                    g.suspicion_to_detect_str(suspicion)
                danger_display_dict[group] = \
                    g.danger_level_to_detect_str(danger_level)

        self.suspicion_bar.chunks = ("  ["+_("SUSPICION")+"]",
            " " +_("NEWS")   +u":\xA0", suspicion_display_dict["news"],
            "  "+_("SCIENCE")+u":\xA0", suspicion_display_dict["science"],
            "  "+_("COVERT") +u":\xA0", suspicion_display_dict["covert"],
            "  "+_("PUBLIC") +u":\xA0", suspicion_display_dict["public"],)
        self.suspicion_bar.styles = tuple(suspicion_styles)
        self.suspicion_bar.visible = not g.pl.had_grace

        self.danger_bar.chunks = ("["+_("DETECT RATE")+"]",
            " " +_("NEWS")   +u":\xA0", danger_display_dict["news"],
            "  "+_("SCIENCE")+u":\xA0", danger_display_dict["science"],
            "  "+_("COVERT") +u":\xA0", danger_display_dict["covert"],
            "  "+_("PUBLIC") +u":\xA0", danger_display_dict["public"],)
        self.danger_bar.styles = tuple(danger_styles)
        self.danger_bar.visible = not g.pl.had_grace

        for id, location_button in self.location_buttons.iteritems():
            location = g.locations[id]
            location_button.text = "%s (%d)" % (location.name, len(location.bases))
            location_button.hotkey = location.hotkey
            location_button.visible = location.available()
Exemple #19
0
    def __init__(self,
                 parent=None,
                 pos=(0, 0),
                 size=(1, 1),
                 anchor=constants.TOP_LEFT,
                 *args,
                 **kwargs):
        from code import screens

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

        g.map_screen = self

        self.background_color = gg.colors["black"]
        self.add_handler(constants.TICK, self.on_tick)

        self.map = EarthImage(self)

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

        self.location_dialog = LocationScreen(self)

        self.suspicion_bar = \
            text.FastStyledText(self, (0,.92), (1, .04), base_font=gg.font[1],
                                wrap=False,
                                background_color=gg.colors["black"],
                                border_color=gg.colors["dark_blue"],
                                borders=constants.ALL, align=constants.LEFT)
        widget.unmask_all(self.suspicion_bar)

        self.danger_bar = \
            text.FastStyledText(self, (0,.96), (1, .04), base_font=gg.font[1],
                                wrap=False,
                                background_color=gg.colors["black"],
                                border_color=gg.colors["dark_blue"],
                                borders=constants.ALL, align=constants.LEFT)
        widget.unmask_all(self.danger_bar)

        self.finance_button = button.DialogButton(
            self, (0, 0.88), (0.15, 0.04),
            text="FINANCE",
            hotkey="e",
            dialog=screens.finance.FinanceScreen(self))

        self.knowledge_button = button.DialogButton(
            self, (0.85, 0.88), (0.15, 0.04),
            text="KNOWLEDGE",
            hotkey="k",
            dialog=screens.knowledge.KnowledgeScreen(self))

        cheat_buttons = []
        cheat_buttons.append(
            button.FunctionButton(None,
                                  None,
                                  None,
                                  text="EMBEZZLE MONEY",
                                  hotkey="e",
                                  function=self.steal_money))
        cheat_buttons.append(
            button.FunctionButton(None,
                                  None,
                                  None,
                                  text="INSPIRATION",
                                  hotkey="i",
                                  function=self.inspiration))
        cheat_buttons.append(
            button.FunctionButton(None,
                                  None,
                                  None,
                                  text="FINISH CONSTRUCTION",
                                  hotkey="f",
                                  function=self.end_construction))
        cheat_buttons.append(
            button.FunctionButton(None,
                                  None,
                                  None,
                                  text="SUPERSPEED",
                                  hotkey="s",
                                  function=self.set_speed,
                                  args=(864000, )))
        cheat_buttons.append(
            button.FunctionButton(None,
                                  None,
                                  None,
                                  text="BRAINWASH",
                                  hotkey="w",
                                  function=self.brainwash))
        cheat_buttons.append(
            button.ExitDialogButton(None, None, None, text="BACK", hotkey="b"))

        self.cheat_dialog = \
            dialog.SimpleMenuDialog(self, buttons=cheat_buttons, width=.4)
        self.steal_amount_dialog = \
            dialog.TextEntryDialog(self.cheat_dialog, text="How much money?")

        if g.cheater:
            self.cheat_button = button.DialogButton(self, (0, 0), (0, 0),
                                                    text="",
                                                    hotkey="`",
                                                    dialog=self.cheat_dialog)

        menu_buttons = []
        menu_buttons.append(
            button.FunctionButton(None,
                                  None,
                                  None,
                                  text="SAVE GAME",
                                  hotkey="s",
                                  function=self.save_game))
        menu_buttons.append(
            button.FunctionButton(None,
                                  None,
                                  None,
                                  text="LOAD GAME",
                                  hotkey="l",
                                  function=self.load_game))
        options_button = button.DialogButton(None,
                                             None,
                                             None,
                                             text="OPTIONS",
                                             hotkey="o")
        menu_buttons.append(options_button)
        menu_buttons.append(
            button.ExitDialogButton(None,
                                    None,
                                    None,
                                    text="QUIT",
                                    hotkey="q",
                                    exit_code=True,
                                    default=False))
        menu_buttons.append(
            button.ExitDialogButton(None,
                                    None,
                                    None,
                                    text="BACK",
                                    hotkey="b",
                                    exit_code=False))

        self.menu_dialog = dialog.SimpleMenuDialog(self, buttons=menu_buttons)
        from options import OptionsScreen
        options_button.dialog = OptionsScreen(self.menu_dialog)

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

        self.load_dialog = dialog.ChoiceDialog(self.menu_dialog, (.5, .5),
                                               (.5, .5),
                                               anchor=constants.MID_CENTER,
                                               yes_type="load")
        self.menu_button = button.FunctionButton(self, (0, 0), (0.13, 0.04),
                                                 text="MENU",
                                                 hotkey="m",
                                                 function=show_menu)

        self.time_display = text.FastText(self, (.14, 0), (0.23, 0.04),
                                          wrap=False,
                                          text="DAY 0000, 00:00:00",
                                          base_font=gg.font[1],
                                          background_color=gg.colors["black"],
                                          border_color=gg.colors["dark_blue"],
                                          borders=constants.ALL)

        self.research_button = \
            button.DialogButton(self, (.255, 0.04), (0, 0.04),
                                anchor=constants.TOP_CENTER,
                                text="RESEARCH/TASKS", hotkey="r",
                                dialog=screens.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=gg.font[0],
                            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=gg.colors["black"],
                                  border_color=gg.colors["dark_blue"],
                                  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=gg.font[1], shrink_factor = .7,
                          borders=constants.ALL,
                          background_color=gg.colors["black"],
                          border_color=gg.colors["dark_blue"])

        self.cpu_display = \
            text.FastText(self.info_window, (0,-.5), (-1, -.5),
                          wrap=False,
                          base_font=gg.font[1], shrink_factor=.7,
                          borders=
                           (constants.LEFT, constants.RIGHT, constants.BOTTOM),
                          background_color=gg.colors["black"],
                          border_color=gg.colors["dark_blue"])

        self.message_dialog = dialog.MessageDialog(self)

        self.savename_dialog = \
            dialog.TextEntryDialog(self.menu_dialog,
                                   text="Enter a name for this save.")

        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)