def get_detect_info(detect_chance): detect_template = _("Detection chance:") + "\n" chances = [] for group in g.pl.groups.values(): detect_template += group.name + u":\xA0%s\n" chances.append(detect_chance.get(group.spec.id, 0)) if g.pl.display_discover == "full": return detect_template % tuple(g.to_percent(c) for c in chances) elif g.pl.display_discover == "partial": return detect_template % tuple( g.to_percent(g.nearest_percent(c, 25)) for c in chances) else: return detect_template % tuple( g.danger_level_to_detect_str(detect_chance_to_danger_level(c)) for c in chances)
def rebuild(self): super(MapScreen, self).rebuild() g.pl.recalc_cpu() 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] detect_chance = base.get_detect_chance() for group in g.player.group_list: detects_per_day[group] += detect_chance[group] / 10000.0 if cpu_pool < maint_cpu: self.cpu_display.color = gg.colors["red"] else: self.cpu_display.color = gg.colors["white"] 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 = g.danger_colors[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 = g.danger_colors[danger_level] danger_styles.append((color, None, False)) if g.techs["Advanced Socioanalytics"].done: 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, button in self.location_buttons.iteritems(): location = g.locations[id] button.text = "%s (%d)" % (location.name, len(location.bases)) button.visible = location.available()
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()
def rebuild(self): # Rebuild dialogs self.location_dialog.needs_rebuild = True self.research_button.dialog.needs_rebuild = True self.knowledge_button.dialog.needs_rebuild = True self.menu_dialog.needs_rebuild = True # 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") if g.cheater: self.cheat_dialog.needs_rebuild = True super(MapScreen, self).rebuild() 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) cash_flow_1d, cpu_flow_1d = g.pl.compute_future_resource_flow(g.seconds_per_day) self.cash_display.text = _("CASH")+": %s (%s)" % \ (g.to_money(g.pl.cash), g.to_money(cash_flow_1d, fixed_size=True)) total_cpu = g.pl.available_cpus[0] + g.pl.sleeping_cpus detects_per_day = {group_id: 0 for group_id in g.pl.groups} for base in g.all_bases(): 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_id in g.pl.groups: detects_per_day[group_id] = \ chance.add(detects_per_day[group_id], detect_chance[group_id] / 10000.) self.cpu_display.color = "cpu_normal" self.cpu_display.text = _("CPU")+": %s (%s)" % \ (g.to_money(total_cpu), g.to_money(cpu_flow_1d)) # 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. normal = (self.suspicion_bar.color, None, False) self.suspicion_bar.chunks = (" ["+_("SUSPICION")+"]",) self.suspicion_bar.styles = (normal,) self.danger_bar.chunks = ("["+_("DETECT RATE")+"]",) self.danger_bar.styles = (normal,) for group in g.pl.groups.values(): suspicion = group.suspicion suspicion_color = gg.resolve_color_alias("danger_level_%d" % g.suspicion_to_danger_level(suspicion)) detects = detects_per_day[group.spec.id] danger_level = group.detects_per_day_to_danger_level(detects) detects_color = gg.resolve_color_alias("danger_level_%d" % danger_level) if g.pl.display_discover == "full": suspicion_display = g.to_percent(suspicion, True) danger_display = g.to_percent(detects*10000, True) elif g.pl.display_discover == "partial": suspicion_display = g.to_percent(g.nearest_percent(suspicion, 500), True) danger_display = g.to_percent(g.nearest_percent(detects*10000, 100), True) else: suspicion_display = g.suspicion_to_detect_str(suspicion) danger_display = g.danger_level_to_detect_str(danger_level) self.suspicion_bar.chunks += (" " + group.name + u":\xA0", suspicion_display) self.suspicion_bar.styles += (normal, (suspicion_color, None, False) ) self.danger_bar.chunks += (" " + group.name + u":\xA0", danger_display) self.danger_bar.styles += (normal, (detects_color, None, False) ) self.suspicion_bar.visible = not g.pl.had_grace self.danger_bar.visible = not g.pl.had_grace for id, location_button in self.location_buttons.items(): location = g.pl.locations[id] location_button.text = "%s (%d)" % (location.name, len(location.bases)) location_button.hotkey = location.hotkey location_button.visible = location.available()
def suspicion_to_detect_str(self): return g.danger_level_to_detect_str(self.suspicion_to_danger_level())
def rebuild(self): super(MapScreen, self).rebuild() g.pl.recalc_cpu() 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] detect_chance = base.get_detect_chance() for group in g.player.group_list: detects_per_day[group] += detect_chance[group] / 10000. if cpu_pool < maint_cpu: self.cpu_display.color = gg.colors["red"] else: self.cpu_display.color = gg.colors["white"] 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 = g.danger_colors[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 = g.danger_colors[danger_level] danger_styles.append((color, None, False)) if g.techs["Advanced Socioanalytics"].done: 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, button in self.location_buttons.iteritems(): location = g.locations[id] button.text = "%s (%d)" % (location.name, len(location.bases)) button.visible = location.available()
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) detects_per_day = dict([(group, 0) for group in player.group_list]) for base in g.all_bases(): 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 player.group_list: detects_per_day[group] = \ chance.add(detects_per_day[group], detect_chance[group] / 10000.) 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 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) elif g.pl.display_discover == "partial": suspicion_display_dict[group] = g.to_percent(g.nearest_percent(suspicion, 500), True) danger_display_dict[group] = g.to_percent(g.nearest_percent(detects*10000, 100), 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()