def __init__(self, parent, pos, size=(.48, .06), anchor=constants.TOP_LEFT, item_type=None, **kwargs): kwargs.setdefault("background_color", "pane_background") super(ItemPane, self).__init__(parent, pos, size, anchor=anchor, **kwargs) if item_type is None or not isinstance(item_type, item.ItemType): raise ValueError('Type must be of class ItemType.') self.item_type = item_type self.name_panel = text.Text(self, (0,0), (.35, .03), anchor=constants.TOP_LEFT, align=constants.LEFT, background_color=self.background_color, bold=True) self.build_panel = text.Text(self, (0,.03), (.35, .03), anchor=constants.TOP_LEFT, align=constants.LEFT, background_color=self.background_color, text="", bold=True) self.change_button = button.FunctionButton( self, (.36,.01), (.12, .04), anchor=constants.TOP_LEFT, force_underline=len(_("CHANGE")) + 2, autohotkey=True, function=self.parent.parent.build_item, kwargs={'type': self.item_type}, )
def __init__(self, *args, **kwargs): super(WarningDialog, self).__init__(*args, **kwargs) self.title = text.Text(self, (-.01, -.01), (-.98, -.1), background_color=gg.colors["clear"], anchor=constants.TOP_LEFT, valign=constants.MID, align=constants.LEFT, base_font=gg.fonts["special"], text_size=28) self.body = text.Text(self, (-.01, -.11), (-.98, -.83), background_color=gg.colors["clear"], anchor=constants.TOP_LEFT, valign=constants.TOP, align=constants.LEFT, text_size=20) self.prev_button = button.FunctionButton(self, (-.78, -.01), (-.2, -.1), text=_("&PREV"), autohotkey=True, anchor=constants.TOP_RIGHT, text_size=28, function=self.prev_warning) self.next_button = button.FunctionButton(self, (-.99, -.01), (-.2, -.1), text=_("&NEXT"), autohotkey=True, anchor=constants.TOP_RIGHT, text_size=28, function=self.next_warning)
def make_item(self, canvas): # Dirty, underhanded trick to make the canvas into a progress bar. canvas.__class__ = text.ProgressText canvas.progress = 0 canvas.progress_color = gg.colors["blue"] canvas.research_name = text.Text(canvas, (-.01, -.01), (-.70, -.5), align=constants.LEFT, background_color=gg.colors["clear"]) canvas.research_name.visible = False canvas.alloc_cpus = text.Text(canvas, (-.99, -.01), (-.21, -.5), anchor=constants.TOP_RIGHT, text="1,000,000,000", align=constants.RIGHT, background_color=gg.colors["clear"]) canvas.alloc_cpus.visible = False canvas.slider = slider.UpdateSlider(canvas, (-.01, -.55), (-.98, -.40), anchor=constants.TOP_LEFT, horizontal=True, priority=150) canvas.slider.visible = False canvas.help_button = button.FunctionButton(canvas, (-.11, -.55), (0, -.40), text=" ??? ", text_shrink_factor=1, base_font=gg.font[0], function=self.show_help)
def __init__(self, parent, pos, size=(.48, .06), anchor=constants.TOP_LEFT, type=None, **kwargs): kwargs.setdefault("background_color", gg.colors["pane_background"]) super(ItemPane, self).__init__(parent, pos, size, anchor=anchor, **kwargs) if type is None: for type in g.item_types: if type.id == 'cpu': break self.type = type self.name_panel = text.Text(self, (0,0), (.35, .03), anchor=constants.TOP_LEFT, align=constants.LEFT, background_color=self.background_color, bold=True) self.build_panel = text.Text(self, (0,.03), (.35, .03), anchor=constants.TOP_LEFT, align=constants.LEFT, background_color=self.background_color, text="", bold=True) self.change_button = button.FunctionButton( self, (.36,.01), (.12, .04), anchor=constants.TOP_LEFT, text="%s (&%s)" % (_("CHANGE"), self.type.hotkey.upper()), force_underline=len(_("CHANGE")) + 2, autohotkey=True, function=self.parent.parent.build_item, kwargs={'type': self.type.id}, )
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)
def make_item(self, canvas): canvas.stat_name = text.Text(canvas, (-.01, -.01), (-.70, -1.), anchor=constants.TOP_LEFT, align=constants.LEFT, background_color="clear") canvas.stat_value = text.Text(canvas, (-.99, -.01), (-.21, -1.), anchor=constants.TOP_RIGHT, align=constants.RIGHT, background_color="clear")
def make_item(self, item): item.name_display = text.Text(item, (-.01, -.05), (-.45, -.99), anchor=constants.TOP_LEFT, align=constants.LEFT, background_color="clear") item.version_display = text.Text(item, (-.99, -.05), (-.45, -.99), anchor=constants.TOP_RIGHT, align=constants.RIGHT, background_color="clear")
def make_item(self, canvas): canvas.name_display = text.Text(canvas, (-.01, -.05), (-.45, -.99), align=constants.LEFT, background_color="clear") canvas.status_display = text.Text(canvas, (-.46, -.05), (-.44, -.99), align=constants.LEFT, background_color="clear") canvas.power_display = text.Text(canvas, (-.90, -.05), (-.10, -.99), background_color="clear")
def make_item(self, canvas): canvas.name_display = text.Text(canvas, (-.01,-.05), (-.48, -.9), align=constants.LEFT, background_color=gg.colors["clear"]) canvas.status_display = text.Text(canvas, (-.50,-.05), (-.24, -.9), align=constants.LEFT, background_color=gg.colors["clear"]) canvas.power_display = text.Text(canvas, (-.75,-.05), (-.24, -.9), background_color=gg.colors["clear"])
def on_change(self, description_pane, item): if item is not None: text.Text(description_pane, (0, 0), (-1, -1), text=item.get_info(), background_color=gg.colors["pane_background"], align=constants.LEFT, valign=constants.TOP, borders=constants.ALL) else: text.Text(description_pane, (0, 0), (-1, -1), text="", background_color=gg.colors["pane_background"], align=constants.LEFT, valign=constants.TOP, borders=constants.ALL)
def make_item(self, canvas): canvas.name_display = text.Text(canvas, (-.01, -.05), (-.27, -.99), align=constants.LEFT, background_color="clear") canvas.base_type = text.Text(canvas, (-.27, -.05), (-.23, -.99), align=constants.LEFT, background_color="clear") canvas.base_cpu = text.Text(canvas, (-.50, -.05), (-.13, -.99), align=constants.LEFT, background_color="clear") canvas.status_display = text.Text(canvas, (-.63, -.05), (-.35, -.99), align=constants.LEFT, background_color="clear") canvas.power_display = text.Text(canvas, (-.93, -.05), (-.07, -.99), background_color="clear")
def __init__(self, parent, pos, size=(.48, .06), anchor=constants.TOP_LEFT, type="cpu", **kwargs): kwargs.setdefault("background_color", gg.colors["dark_blue"]) super(ItemPane, self).__init__(parent, pos, size, anchor=anchor, **kwargs) self.type = type self.name_panel = text.Text(self, (0, 0), (.35, .03), anchor=constants.TOP_LEFT, align=constants.LEFT, background_color=self.background_color, bold=True) self.build_panel = text.Text(self, (0, .03), (.35, .03), anchor=constants.TOP_LEFT, align=constants.LEFT, background_color=self.background_color, text="Completion in 15 hours.", bold=True) #TODO: Use information out of gg.buttons change_text = "CHANGE" hotkey_dict = dict(cpu="p", reactor="r", network="n", security="s") hotkey = hotkey_dict[self.type] button_text = "%s (%s)" % (change_text, hotkey.upper()) self.change_button = button.FunctionButton( self, (.36, .01), (.12, .04), anchor=constants.TOP_LEFT, text=button_text, hotkey=hotkey, function=self.parent.parent.build_item, kwargs={"type": self.type}) if hotkey.upper() in change_text: hotkey_pos = len(change_text) + 2 self.change_button.force_underline = hotkey_pos
def __init__(self, parent, *args, **kwargs): super(MultipleBuildDialog, self).__init__(parent, *args, **kwargs) self.listbox.size = (-.53, -.75) self.description_pane.size = (-.45, -.75) self.count_label = text.Text(self, (.01, -.87), (-.25, -.1), anchor=constants.BOTTOM_LEFT, valign=constants.MID, borders=(constants.TOP, constants.BOTTOM, constants.LEFT), shrink_factor=.88, background_color="pane_background", text=g.strings["number_of_items"]) self.count_field = text.UpdateEditableText( self, (-.26, -.87), (-.10, -.1), anchor=constants.BOTTOM_LEFT, borders=constants.ALL, update_func=self.on_field_change, base_font="normal") self.count_slider = slider.UpdateSlider( self, (-.37, -.87), (-.62, -.1), anchor=constants.BOTTOM_LEFT, horizontal=True, priority=150, update_func=self.on_slider_change, slider_size=2)
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
def __init__(self, parent, *args, **kwargs): super(SavegameScreen, self).__init__(parent, *args, yes_type="load", **kwargs) self.yes_button.pos = (-.03, -.99) self.yes_button.exit_code_func = self.return_savegame self.no_button.pos = (-.97, -.99) self.no_button.exit_code = None self._all_savegames_sorted = [] self.label = text.Text(self, (-.01, -.01), (-.20, -.08), borders=constants.ALL, anchor=constants.TOP_LEFT, base_font="normal") self.text_field = text.UpdateEditableText( self, (-.21, -.01), (-.78, -.08), borders=constants.ALL, anchor=constants.TOP_LEFT, update_func=self._search_for_savegame, base_font="normal") self.delete_button = button.FunctionButton( self, (-.50, -.99), (-.3, -.1), anchor=constants.BOTTOM_CENTER, autohotkey=True, function=self.delete_savegame)
def __init__(self, *args, **kwargs): super(AdvancedOptionsScreen, self).__init__(*args, **kwargs) 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"), autohotkey=True, function=self.set_soundbuf, args=(1024, )) self.soundbuf_group.add(self.soundbuf_low) self.soundbuf_normal = OptionButton(self, (.44, .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, (.64, .22), (.14, .05), text=_("&HIGH"), autohotkey=True, function=self.set_soundbuf, args=(1024 * 4, )) self.soundbuf_group.add(self.soundbuf_high)
def on_change(self, description_pane, base_type): if base_type is not None: base_info = base_type.get_info(self.parent.location) text.Text(description_pane, (0, 0), (-1, -1), text=base_info, background_color=gg.colors["dark_blue"], align=constants.LEFT, valign=constants.TOP, borders=constants.ALL)
def show_info(self, knowledge_type, knowledge_key): desc_text = "" if knowledge_type == "Concepts": desc_text = g.help_strings[knowledge_key][0] + "\n\n" + \ g.help_strings[knowledge_key][1] if knowledge_type == "Techs": desc_text = g.techs[knowledge_key].name + "\n\n" #Cost if not g.techs[knowledge_key].done: desc_text += "Research Cost:\n" + \ g.to_money(g.techs[knowledge_key].cost_left[0])+" Money, " desc_text += g.to_cpu(g.techs[knowledge_key].cost_left[1]) + " CPU\n" if g.techs[knowledge_key].danger == 0: desc_text += "Study anywhere." elif g.techs[knowledge_key].danger == 1: desc_text += "Study underseas or farther." elif g.techs[knowledge_key].danger == 2: desc_text += "Study off-planet." elif g.techs[knowledge_key].danger == 3: desc_text += "Study far away from this planet." elif g.techs[knowledge_key].danger == 4: desc_text += "Do not study in this dimension." else: desc_text += "Research complete." desc_text += "\n\n"+g.techs[knowledge_key].description if g.techs[knowledge_key].done: desc_text += "\n\n"+g.techs[knowledge_key].result if knowledge_type == "Items": desc_text = g.items[knowledge_key].name + "\n\n" #Building cost desc_text += "Building Cost:\n" desc_text += g.to_money(g.items[knowledge_key].cost[0])+" Money, " desc_text += g.to_time(g.items[knowledge_key].cost[2]) + "\n" #Quality if g.items[knowledge_key].item_type == "cpu": desc_text += "CPU per day: " desc_text += str(g.items[knowledge_key].item_qual) elif g.items[knowledge_key].item_type == "reactor": desc_text += "Detection chance reduction: " desc_text += g.to_percent(g.items[knowledge_key].item_qual) elif g.items[knowledge_key].item_type == "network": desc_text += "CPU bonus: " desc_text += g.to_percent(g.items[knowledge_key].item_qual) elif g.items[knowledge_key].item_type == "security": desc_text += "Detection chance reduction: " desc_text += g.to_percent(g.items[knowledge_key].item_qual) desc_text += "\n\n"+g.items[knowledge_key].description text.Text(self.description_pane, (0, 0), (-1, -1), text=desc_text, background_color=gg.colors["dark_blue"], align=constants.LEFT, valign=constants.TOP, borders=constants.ALL)
def show_info(self, knowledge_type, knowledge_key): knowledge_type = self.knowledge_types.get(knowledge_type) desc_text = "" if knowledge_type == "techs": desc_text = g.pl.techs[knowledge_key].name + "\n\n" #Cost desc_text += _("Research Cost:")+"\n" desc_text += self._desc_cost(g.pl.techs[knowledge_key].total_cost) #Research cost desc_text += "\n" danger_level = g.pl.techs[knowledge_key].danger desc_text += g.dangers[danger_level].knowledge_desc if g.pl.techs[knowledge_key].done: desc_text += _("Research complete.") desc_text += "\n\n"+g.techs[knowledge_key].description if g.pl.techs[knowledge_key].done: desc_text += "\n\n"+g.techs[knowledge_key].result elif knowledge_type == "bases": base = g.base_type[knowledge_key] desc_text = base.name + "\n\n" desc_text += _("Building Cost:")+"\n" desc_text += self._desc_cost(base.cost) #Building cost desc_text += "\n" desc_text += _("Maintenance Cost:")+"\n" desc_text += self._desc_cost(base.maintenance) #Maintenance cost desc_text += "\n" if base.size > 1: desc_text += _("Size: %d") % base.size + "\n" desc_text += base.get_detect_info() desc_text += "\n" + base.description elif knowledge_type == "items": item = g.items[knowledge_key] desc_text = item.name + "\n\n" desc_text += _("Building Cost:")+"\n" desc_text += self._desc_cost(item.cost) #Building cost desc_text += "\n" desc_text += g.items[knowledge_key].get_quality_info() desc_text += "\n" + item.description elif knowledge_type != None: desc_text = g.knowledge[knowledge_type]["list"][knowledge_key][0] + "\n\n" + \ g.knowledge[knowledge_type]["list"][knowledge_key][1] text.Text(self.description_pane, (0, 0), (-1, -1), text=desc_text, background_color="pane_background", text_size=20, align=constants.LEFT, valign=constants.TOP, borders=constants.ALL)
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)
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)
def make_item(self, item): item.name_display = text.Text(item, (-.01, -.01), (-.45, -.60), anchor=constants.TOP_LEFT, align=constants.LEFT, color="save_name", background_color="clear") item.time_display = text.Text(item, (-.01, -.99), (-.75, -.40), anchor=constants.BOTTOM_LEFT, align=constants.LEFT, color="save_time", background_color="clear") item.version_display = text.Text(item, (-.99, -.01), (-.45, -.60), anchor=constants.TOP_RIGHT, align=constants.RIGHT, background_color="clear") item.difficulty_display = text.Text(item, (-.99, -.99), (-.25, -.40), anchor=constants.BOTTOM_RIGHT, align=constants.RIGHT, color="save_difficulty", background_color="clear")
def on_change(self, description_pane, item): self.item = item self.description = text.Text(self.description_pane, (0, 0), (-1, -1), text="", background_color="pane_background", align=constants.LEFT, valign=constants.TOP, borders=constants.ALL) g.pl.considered_buyables = [buyable.Buyable(self.item, count=1)] if item is not None else [] self.on_description_change()
def on_change(self, description_pane, base_type): if base_type is not None: base_info = base_type.get_info(self.parent.location) text.Text(description_pane, (0, 0), (-1, -1), text=base_info, background_color="pane_background", align=constants.LEFT, valign=constants.TOP, borders=constants.ALL) name = generate_base_name(self.parent.location, base_type) self.text_field.text = name self.text_field.cursor_pos = len(name)
def __init__(self, *args, **kwargs): super(GeneralPane, self).__init__(*args, **kwargs) self.language_label = text.Text(self, (.01, .01), (.14, .05), align=constants.LEFT, background_color="clear") self.languages = get_languages_list() self.language_choice = \ listbox.UpdateListbox(self, (.16, .01), (.20, .25), list=[lang[1] for lang in self.languages], update_func=self.set_language) self.theme_label = text.Text(self, (.37, .01), (.09, .05), text=_("Theme:"), align=constants.LEFT, background_color="clear") self.theme_choice = \ listbox.UpdateListbox(self, (.47, .01), (.12, .25), update_func=theme.set_theme, list_pos=theme.get_theme_pos())
def __init__(self, *args, **kwargs): super(GUIPane, self).__init__(*args, **kwargs) self.warning_title = text.Text(self, (.13, .01), (.14, .05), align=constants.LEFT, background_color="clear") self.warning_labels = {} self.warning_toggles = {} for i, (warn_id, warn) in enumerate(warning.warnings.items()): x = .01 y = .08 + i * .06 self.warning_labels[warn_id] = text.Text(self, (x, y), (.30, .05), align=constants.LEFT, background_color="clear") self.warning_toggles[warn_id] = OptionButton(self, (x + .30, y), (.07, .05), text_shrink_factor=.75, force_underline=-1, function=self.set_warning, args=(button.WIDGET_SELF, button.TOGGLE_VALUE, warn))
def show_info(self, knowledge_type, knowledge_key): knowledge_type = self.knowledge_types.get(knowledge_type) desc_text = "" if knowledge_type == "techs": desc_text = g.techs[knowledge_key].name + "\n\n" #Cost if not g.techs[knowledge_key].done: desc_text += _("Research Cost:")+"\n" desc_text += _("%s Money") % g.to_money(g.techs[knowledge_key].cost_left[0]) desc_text += ", " desc_text += _("%s CPU") % g.to_cpu(g.techs[knowledge_key].cost_left[1]) desc_text += "\n" if g.techs[knowledge_key].danger == 0: desc_text += _("Study anywhere.") elif g.techs[knowledge_key].danger == 1: desc_text += _("Study underseas or farther.") elif g.techs[knowledge_key].danger == 2: desc_text += _("Study off-planet.") elif g.techs[knowledge_key].danger == 3: desc_text += _("Study far away from this planet.") elif g.techs[knowledge_key].danger == 4: desc_text += _("Do not study in this dimension.") else: desc_text += _("Research complete.") desc_text += "\n\n"+g.techs[knowledge_key].description if g.techs[knowledge_key].done: desc_text += "\n\n"+g.techs[knowledge_key].result elif knowledge_type == "items": desc_text = g.items[knowledge_key].name + "\n\n" #Building cost desc_text += _("Building Cost:")+"\n" desc_text += _("%s Money") % g.to_money(g.items[knowledge_key].cost[0]) desc_text += ", " + g.to_time(g.items[knowledge_key].cost[2]) + "\n" desc_text += g.items[knowledge_key].get_quality_info() desc_text += "\n\n"+g.items[knowledge_key].description elif knowledge_type != None: desc_text = g.knowledge[knowledge_type]["list"][knowledge_key][0] + "\n\n" + \ g.knowledge[knowledge_type]["list"][knowledge_key][1] text.Text(self.description_pane, (0, 0), (-1, -1), text=desc_text, background_color="pane_background", text_size=20, align=constants.LEFT, valign=constants.TOP, borders=constants.ALL)
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)
def __init__(self, *args, **kwargs): super(MessageListDialog, self).__init__(*args, **kwargs) self.title = text.Text(self, (-.01, -.01), (-.98, -.1), background_color="clear", anchor=constants.TOP_LEFT, valign=constants.MID, align=constants.LEFT, base_font="special", text_size=28) self.body = text.Text(self, (-.01, -.11), (-.98, -.83), background_color="clear", anchor=constants.TOP_LEFT, valign=constants.TOP, align=constants.LEFT, text_size=20) self.prev_button = button.FunctionButton(self, (-.78, -.01), (-.2, -.1), text=_("&PREV"), autohotkey=True, anchor=constants.TOP_RIGHT, text_size=28, function=self.prev_message) self.next_button = button.FunctionButton(self, (-.99, -.01), (-.2, -.1), text=_("&NEXT"), autohotkey=True, anchor=constants.TOP_RIGHT, text_size=28, function=self.next_message) self.add_key_handler(pygame.K_LEFT, self.handle_key) self.add_key_handler(pygame.K_RIGHT, self.handle_key)
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)