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 = "progress_background_progress" canvas.research_name = text.Text(canvas, (-.01, -.01), (-.70, -.5), align=constants.LEFT, background_color="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="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="normal", function=self.show_help)
def __init__(self, *args, **kwargs): super(GeneralPane, self).__init__(*args, **kwargs) self.language_label = text.Text(self, (.01, .01), (.14, .05), autotranslate=True, text=N_("Language:"), 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, (.46, .01), (.09, .05), autotranslate=True, text=N_("Theme:"), align=constants.LEFT, background_color="clear", ) self.theme_choice = \ listbox.UpdateListbox(self, (.56, .01), (.20, .25), update_func=theme.set_theme, list_pos=theme.get_theme_pos())
def __init__(self, parent, pos, size=(.58, .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), (.45, .03), anchor=constants.TOP_LEFT, align=constants.LEFT, background_color=self.background_color, bold=True) self.build_panel = text.Text(self, (0,.03), (.45, .03), anchor=constants.TOP_LEFT, align=constants.LEFT, background_color=self.background_color, text="", bold=True) self.change_button = button.FunctionButton( self, (.415,.01), (.16, .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(GUIPane, self).__init__(*args, **kwargs) self.warning_title = text.Text(self, (.13, .01), (.14, .05), autotranslate=True, text=N_("WARNING"), 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), autotranslate=True, autohotkey=False, text_shrink_factor=.75, force_underline=-1, function=self.set_warning, args=(button.TOGGLE_VALUE, warn))
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=_("P&REV"), 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, only_on_event_type=pygame.KEYDOWN) self.add_key_handler(pygame.K_RIGHT, self.handle_key, only_on_event_type=pygame.KEYDOWN)
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, 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, *args, **kwargs): super(FilterLogDialog, self).__init__(parent, *args, **kwargs) self.ok_type = "back" self.log_class_labels = {} self.log_class_toggles = {} for i, (log_type, log_class) in enumerate( logmessage.SAVEABLE_LOG_MESSAGES.items()): y = .01 + i * .06 self.log_class_labels[log_type] = text.Text( self, (-.01, y), (-.70, .05), align=constants.LEFT, background_color="clear") self.log_class_toggles[log_type] = FilterButton( self, (-.71, y), (-.28, .05), text_shrink_factor=.75, force_underline=-1, function=self.toggle_log_class, args=(button.WIDGET_SELF, button.TOGGLE_VALUE, log_class)) self.pos = (-.50, 0) self.size = (-.50, (y + .07) / .9) self.anchor = constants.TOP_LEFT
def __init__(self, parent, pos=(0, 0), size = (-1, -1), anchor=constants.TOP_LEFT, *args, **kwargs): kwargs["yes_type"] = N_("&OK") kwargs["no_type"] = N_("&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), autotranslate=True, text=N_("Name"), anchor=constants.BOTTOM_LEFT, borders=(constants.TOP, constants.BOTTOM, constants.LEFT), shrink_factor=.88, background_color="pane_background", ) 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): kwargs["ok_type"] = N_("&BACK") super(FilterLogDialog, self).__init__(parent, *args, **kwargs) self.log_class_labels = {} self.log_class_toggles = {} for i, (log_type, log_class) in enumerate(logmessage.SAVEABLE_LOG_MESSAGES.items()): y = .01 + i * .06 self.log_class_labels[log_type] = text.Text(self, (-.01, y), (-.70, .05), align = constants.LEFT, background_color="clear") self.log_class_toggles[log_type] = FilterButton(self, (-.71, y), (-.28, .05), autotranslate=True, autohotkey=False, on_text=N_('SHOW'), off_text=N_('HIDE'), text_shrink_factor=.75, force_underline=-1, function=self.toggle_log_class, args=(button.TOGGLE_VALUE, log_class)) self.pos = (-.50, 0) self.size = (-.50, (y + .07) / .9) self.anchor = constants.TOP_LEFT
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) self.add_handler(constants.KEY, self._got_key, priority=5)
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), autotranslate=True, text=N_("Number of items"), anchor=constants.BOTTOM_LEFT, valign=constants.MID, borders=(constants.TOP, constants.BOTTOM, constants.LEFT), shrink_factor=.88, background_color="pane_background") self.count_field = text.UpdateEditableText( self, (-.26, -.87), (-.10, -.1), anchor=constants.BOTTOM_LEFT, borders=constants.ALL, update_func=self.on_field_change, allowed_characters=constants.DIGIT_CHARS, 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 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_maint(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 is not None: help_entry = g.knowledge[knowledge_type].help_entries[knowledge_key] desc_text = help_entry.name + "\n\n" + help_entry.description 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 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 __init__(self, *args, **kwargs): super(MainMenu, self).__init__(*args, background_color='main_menu_background', **kwargs) self.map_screen = map.MapScreen(self) self.new_game_button = \ button.FunctionButton(self, (.5, .20), (.25, .08), autotranslate=True, text=N_("&NEW GAME"), anchor=constants.TOP_CENTER, text_size=28, function=self.new_game) self.load_game_button = \ button.FunctionButton(self, (.5, .36), (.25, .08), autotranslate=True, text=N_("&LOAD GAME"), anchor=constants.TOP_CENTER, text_size=28, function=self.load_game) self.options_button = button.DialogButton( self, (.5, .52), (.25, .08), autotranslate=True, text=N_("&OPTIONS"), anchor=constants.TOP_CENTER, text_size=28, dialog=options.OptionsScreen(self)) self.quit_button = button.ExitDialogButton(self, (.5, .68), (.25, .08), autotranslate=True, text=N_("&QUIT"), anchor=constants.TOP_CENTER, text_size=28) self.about_button = button.DialogButton(self, (0, 1), (.13, .04), autotranslate=True, text=N_("&ABOUT"), 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="special", text_size=100, color="singularity_title", background_color="main_menu_background", anchor=constants.TOP_CENTER) self.difficulty_dialog = dialog.SimpleMenuDialog(self) self.load_dialog = savegame.SavegameScreen(self, (.5, .5), (.90, .90), anchor=constants.MID_CENTER)
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) old_item = self.parent.base.items[self.type.id] if item is not None and (old_item is None or old_item.spec != item): g.pl.considered_buyables = [buyable.Buyable(self.item, count=1)] else: g.pl.considered_buyables = [] self.on_description_change()
def __init__(self, parent, *args, **kwargs): super(SavegameScreen, self).__init__(parent, *args, yes_type=N_("&LOAD"), **kwargs) self.yes_button.pos = (-.03, -.99) self.yes_button.size = (-.22, -.1) self.yes_button.function = self.exit_savegame self.yes_button.force_underline = -1 # Work around #224 self.no_button.pos = (-.97, -.99) self.no_button.size = (-.22, -.1) self.no_button.exit_code = None self.no_button.force_underline = -1 # Work around #224 self._all_savegames_sorted = [] self.label = text.Text(self, (-.01, -.01), (-.20, -.08), autotranslate=True, text=N_("Filter: "), 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, background_color="text_entry_background", base_font="normal") self.convert_button = button.FunctionButton( self, (-.27, -.99), (-.22, -.1), autotranslate=True, text=N_("Upgrade"), anchor=constants.BOTTOM_LEFT, function=self.convert_save) self.delete_button = button.FunctionButton( self, (-.51, -.99), (-.22, -.1), autotranslate=True, text=N_("Delete"), anchor=constants.BOTTOM_LEFT, function=self.delete_savegame) self.add_handler(constants.KEY, self._got_key, priority=5)
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) considered_buyables = [] fake_base = base.Base('<Undecided>', base_type) self.parent.location.modify_base(fake_base) considered_buyables.append(fake_base) g.pl.considered_buyables = considered_buyables else: g.pl.considered_buyables = []
def on_change(self, description_pane, event_spec): self.selected_event_spec = event_spec self.trigger_event_button.enabled = True self.expire_event_button.enabled = False event_instance = g.pl.events.get(event_spec.id) triggered_state = _('NO') trigger_duration = g.to_time(event_spec.duration * g.minutes_per_day) \ if event_spec.duration else _('Event never expires') triggered_at_raw = _('N/A; event not triggered') uniqueness = _('YES') if event_spec.unique else _('NO') if event_instance: if event_instance.triggered: self.trigger_event_button.enabled = False self.expire_event_button.enabled = event_instance.decayable_event triggered_state = _('YES') triggered_at_raw = event_instance.triggered_at text_format = _("{DESCRIPTION}\n\n" + "-----------------\n" + "Triggered: {TRIGGER_STATE}\n" + "Trigger chance: {TRIGGER_CHANCE}\n" + "Trigger Duration (full): {TRIGGER_DURATION}\n" + "Triggered at (rawtime): {TRIGGER_TIME_RAW}\n" + "Unique: {UNIQUE}\n" ) desc = text_format.format( DESCRIPTION=event_spec.description, TRIGGER_STATE=triggered_state, TRIGGER_CHANCE=g.to_percent(event_spec.chance), TRIGGER_DURATION=trigger_duration, TRIGGER_TIME_RAW=triggered_at_raw, UNIQUE=uniqueness, ) self.description = text.Text(description_pane, (0, 0), (-1, -1), text=desc, background_color="pane_background", align=constants.LEFT, valign=constants.TOP, borders=constants.ALL)
def on_select(self, description_pane, key): if key in g.pl.techs: description = g.pl.techs[key].get_info() elif key == "cpu_pool": template = "%s\n---\n%s" cpu_pool = task.get_current("cpu_pool") description = template % (cpu_pool.name, cpu_pool.description) elif key == "jobs": template = "%s\n" + _("%s money per CPU per day.") + "\n---\n%s" job = task.get_current("jobs") profit = job.get_profit() description = template % (job.name, profit, job.description) else: description = "" text.Text(self.description_pane, (0, 0), (-1, -1), text=description, background_color="pane_background", text_size=18, align=constants.LEFT, valign=constants.TOP, borders=constants.ALL)
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), autotranslate=True, text=N_("&OPEN BASE"), 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), autotranslate=True, text=N_("&RENAME BASE"), anchor=constants.TOP_CENTER, autohotkey=True, function=self.rename_base) self.power_button = \ button.FunctionButton(self, (-1, -.8), (-.3, -.09), autotranslate=True, text=N_("&POWER STATE"), anchor=constants.TOP_RIGHT, autohotkey=True, function=self.power_state) self.new_button = \ button.FunctionButton(self, (0, -.91), (-.3, -.09), autotranslate=True, text=N_("&NEW BASE"), autohotkey=True, function=self.new_base) self.destroy_button = \ button.FunctionButton(self, (-.50, -.91), (-.3, -.09), autotranslate=True, text=N_("&DESTROY BASE"), anchor=constants.TOP_CENTER, autohotkey=True, function=self.destroy_base) self.back_button = button.ExitDialogButton(self, (-1, -.9), (-.3, -.09), autotranslate=True, text=N_("&BACK"), anchor=constants.TOP_RIGHT, autohotkey=True) self.confirm_destroy = \ dialog.YesNoDialog(self, (-.5, 0), (-.35, -.7), autotranslate=True, text=N_("Are you sure you want to destroy this base?"), shrink_factor=.5) self.cannot_destroy_last_base = \ dialog.MessageDialog(self, autotranslate=True, text=N_("Destroying my last active base would be suicidal. I cannot do that."), 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 rebuild(self): # Update buttons translations self.stats_button.text = _("&STATISTICS") self.back_button.text = _("&BACK") self.format_button_midnight.text = _("&Midnight") self.format_button_24hours.text = _("24 &Hours") super(ReportScreen, self).rebuild() if (self.midnight_stop): seconds = g.seconds_per_day - (g.pl.raw_sec % g.seconds_per_day) else: seconds = g.seconds_per_day cash_info, cpu_info = g.pl.compute_future_resource_flow(seconds) m = g.to_money #take care of the titles and border. text.Text(self.money_report_pane, (0, 0), (-1, -1), text=_("Financial report").replace(" ", u"\xA0"), background_color="pane_background", align=constants.CENTER, valign=constants.TOP, borders=constants.ALL) text.Text(self.cpu_report_pane, (0, 0), (-1, -1), text=_("CPU Usage"), background_color="pane_background", align=constants.CENTER, valign=constants.TOP, borders=constants.ALL) financial_pluses = " \n+\n-\n-\n-\n+\n+\n=" financial_report = _("Current Money flow") + "\n" financial_report += _("Jobs:") + "\n" financial_report += _("Research:") + "\n" financial_report += _("Maintenance:") + "\n" financial_report += _("Construction:") + "\n" financial_report += _("Interest (%s):") % \ (g.to_percent(g.pl.interest_rate))+"\n" financial_report += _("Income:") + "\n" if (self.midnight_stop): financial_report += _("Money flow until Midnight:") + "\n" else: financial_report += _("Money flow for 24 hours:") + "\n" financial_numbers = "\n%s\n%s\n%s\n%s\n%s\n%s\n%s" % \ (m(cash_info.jobs), m(cash_info.tech), m(cash_info.maintenance_needed), m(cash_info.construction_needed), m(cash_info.interest), m(cash_info.income), m(cash_info.difference)) cpu_pluses = " \n-\n-\n-\n=\n \n-\n-\n=" cpu_report = _("Total CPU:") + "\n" cpu_report += _("Sleeping CPU:") + "\n" cpu_report += _("Research CPU:") + "\n" cpu_report += _("Job CPU:") + "\n" cpu_report += _("CPU pool:") + "\n\n" cpu_report += _("Maintenance CPU:") + "\n" cpu_report += _("Construction CPU:") + "\n" cpu_report += _("Pool difference:") + "\n" cpu_numbers = "%s\n%s\n%s\n%s\n%s\n\n%s\n%s\n%s\n" % \ (m(cpu_info.total), m(cpu_info.sleeping), m(cpu_info.tech), m(cpu_info.explicit_jobs), m(cpu_info.effective_pool), m(cpu_info.maintenance_needed), m(cpu_info.construction_needed), m(cpu_info.difference)) size = 'report_content' text.Text(self.money_report_pane, (0, -0.15), (-0.10, -0.85), text=financial_pluses, text_size=size, background_color="clear", align=constants.CENTER, valign=constants.TOP) text.Text(self.cpu_report_pane, (0, -0.15), (-0.10, -0.85), text=cpu_pluses, text_size=size, background_color="clear", align=constants.CENTER, valign=constants.TOP) text.Text(self.money_report_pane, (-0.10, -0.15), (-0.90, -0.85), text=financial_report, text_size=size, background_color="clear", align=constants.LEFT, valign=constants.TOP) text.Text(self.cpu_report_pane, (-0.10, -0.15), (-0.90, -0.85), text=cpu_report, text_size=size, background_color="clear", align=constants.LEFT, valign=constants.TOP) text.Text(self.money_report_pane, (0, -0.15), (-0.98, -0.85), text=financial_numbers, text_size=size, background_color="clear", align=constants.RIGHT, valign=constants.TOP) text.Text(self.cpu_report_pane, (0, -0.15), (-0.98, -0.85), text=cpu_numbers, text_size=size, background_color="clear", align=constants.RIGHT, valign=constants.TOP)
def __init__(self, *args, **kwargs): super(VideoPane, self).__init__(*args, **kwargs) self.resolution_initialized = False self.resolution_label = text.Text(self, (.01, .01), (.14, .05), autotranslate=True, text=N_("Resolution:"), align=constants.LEFT, background_color="clear") self.resolution_choice = \ listbox.UpdateListbox(self, (.16, .01), (.20, .25), update_func=self.update_resolution) self.resolution_custom = button.HotkeyText(self, (.01, .28), (.14, .05), autotranslate=True, text=N_("&Custom:"), align=constants.LEFT, background_color="clear") self.resolution_custom_horiz = \ text.EditableText(self, (.16, .28), (.14, .05), text=str(gg.default_screen_size[0]), allowed_characters=constants.DIGIT_CHARS, borders=constants.ALL) self.resolution_custom_X = text.Text(self, (.30, .28), (.02, .05), text="X", base_font="special", background_color="clear") self.resolution_custom_vert = \ text.EditableText(self, (.32, .28), (.14, .05), text=str(gg.default_screen_size[1]), allowed_characters=constants.DIGIT_CHARS, borders=constants.ALL) self.resolution_custom_ok = button.FunctionButton(self, (.47, .28), (.14, .05), autotranslate=True, autohotkey=False, text=N_("OK"), function=self.set_resolution_custom) self.resolution_custom.hotkey_target = self.resolution_custom_ok self.fullscreen_label = button.HotkeyText(self, (.40, .01), (.30, .05), autotranslate=True, text=N_("&Fullscreen:"), align=constants.LEFT, background_color="clear") self.fullscreen_toggle = OptionButton(self, (.715, .01), (.07, .05), autotranslate=True, autohotkey=False, text_shrink_factor=.75, force_underline=-1, function=self.set_fullscreen, args=(button.TOGGLE_VALUE,)) self.fullscreen_label.hotkey_target = self.fullscreen_toggle self.daynight_label = button.HotkeyText(self, (.40, .08), (.30, .05), autotranslate=True, text=N_("Da&y/night display:"), align=constants.LEFT, background_color="clear") self.daynight_toggle = OptionButton(self, (.715, .08), (.07, .05), autotranslate=True, autohotkey=False, text_shrink_factor=.75, force_underline=-1, function=self.set_daynight, args=(button.TOGGLE_VALUE,)) self.daynight_label.hotkey_target = self.daynight_toggle self.grab_label = button.HotkeyText(self, (.40, .15), (.30, .05), autotranslate=True, text=N_("&Mouse grab:"), align=constants.LEFT, background_color="clear") self.grab_toggle = OptionButton(self, (.715, .15), (.07, .05), autotranslate=True, autohotkey=False, text_shrink_factor=.75, force_underline=-1, function=self.set_grab, args=(button.TOGGLE_VALUE,)) self.grab_label.hotkey_target = self.grab_toggle
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 __init__(self, *args, **kwargs): super(VideoPane, self).__init__(*args, **kwargs) self.resolution_initialized = False self.resolution_label = text.Text(self, (.01, .01), (.14, .05), align=constants.LEFT, background_color="clear") self.resolution_choice = \ listbox.UpdateListbox(self, (.16, .01), (.20, .25), update_func=self.update_resolution) self.resolution_custom = OptionButton( self, (.01, .28), (.14, .05), autohotkey=True, function=self.set_resolution_custom) self.resolution_custom_horiz = \ text.EditableText(self, (.16, .28), (.14, .05), text=str(gg.default_screen_size[0]), borders=constants.ALL, border_color="widget_border", background_color=(0,0,50,255)) self.resolution_custom_X = text.Text(self, (.30, .28), (.02, .05), text="X", base_font="special", background_color="clear") self.resolution_custom_vert = \ text.EditableText(self, (.32, .28), (.14, .05), text=str(gg.default_screen_size[1]), borders=constants.ALL, border_color="widget_border", background_color=(0,0,50,255)) self.fullscreen_label = button.HotkeyText(self, (.40, .01), (.30, .05), autohotkey=True, align=constants.LEFT, background_color="clear") self.fullscreen_toggle = OptionButton(self, (.71, .01), (.07, .05), text_shrink_factor=.75, force_underline=-1, function=self.set_fullscreen, args=(button.TOGGLE_VALUE, )) self.fullscreen_label.hotkey_target = self.fullscreen_toggle self.daynight_label = button.HotkeyText(self, (.40, .08), (.30, .05), autohotkey=True, align=constants.LEFT, background_color="clear") self.daynight_toggle = OptionButton(self, (.71, .08), (.07, .05), text_shrink_factor=.75, force_underline=-1, function=self.set_daynight, args=(button.TOGGLE_VALUE, )) self.daynight_label.hotkey_target = self.daynight_toggle self.grab_label = button.HotkeyText(self, (.40, .15), (.30, .05), autohotkey=True, align=constants.LEFT, background_color="clear") self.grab_toggle = OptionButton(self, (.71, .15), (.07, .05), text_shrink_factor=.75, force_underline=-1, function=self.set_grab, args=(button.TOGGLE_VALUE, )) self.grab_label.hotkey_target = self.grab_toggle
def __init__(self, *args, **kwargs): if len(args) < 3: kwargs.setdefault("size", (.90, .70)) 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), autotranslate=True, text=N_("&BACK"), anchor=constants.BOTTOM_CENTER, ) self.info_frame = text.Text(self, (-1, .09), (.26, .53), 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), (.60, .53), 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), item_type=item_type))