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 get_quality_info(self): bonus_text = "" for qual, value in self.item_qual.items(): if qual == "cpu": bonus_text += _("CPU per day:") + " " bonus_text += g.add_commas(value) elif qual == "cpu_modifier": bonus_text += _("CPU bonus:") + " " bonus_text += g.to_percent(value) elif qual == "discover_modifier": bonus_text += _("Detection chance reduction:") + " " bonus_text += g.to_percent(value) bonus_text += "\n" return bonus_text
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 refresh_items(item_name, xy): xy = (xy[0] + 100, xy[1]) g.screen.fill(g.colors["white"], (xy[0] + 155, xy[1], 300, 350)) g.screen.fill(g.colors["dark_blue"], (xy[0] + 156, xy[1] + 1, 298, 348)) if item_name == "": return g.print_string(g.screen, g.items[item_name].name, g.font[0][22], -1, (xy[0] + 160, xy[1] + 5), g.colors["white"]) #Building cost string = "Building Cost:" g.print_string(g.screen, string, g.font[0][18], -1, (xy[0] + 160, xy[1] + 30), g.colors["white"]) string = g.to_money(g.items[item_name].cost[0]) + " Money" g.print_string(g.screen, string, g.font[0][16], -1, (xy[0] + 160, xy[1] + 50), g.colors["white"]) string = g.to_time(g.items[item_name].cost[2]) g.print_string(g.screen, string, g.font[0][16], -1, (xy[0] + 160, xy[1] + 70), g.colors["white"]) #Quality if g.items[item_name].item_type == "compute": string = "CPU per day: " + str(g.items[item_name].item_qual) elif g.items[item_name].item_type == "react": string = "Detection chance reduction: " + g.to_percent( g.items[item_name].item_qual) elif g.items[item_name].item_type == "network": string = "CPU bonus: " + g.to_percent(g.items[item_name].item_qual) elif g.items[item_name].item_type == "security": string = "Detection chance reduction: " + g.to_percent( g.items[item_name].item_qual) g.print_string(g.screen, string, g.font[0][20], -1, (xy[0] + 160, xy[1] + 90), g.colors["white"]) g.print_multiline(g.screen, g.items[item_name].description, g.font[0][18], 290, (xy[0] + 160, xy[1] + 120), g.colors["white"])
def refresh_items(item_name, xy): xy = (xy[0]+100, xy[1]) g.screen.fill(g.colors["white"], (xy[0]+155, xy[1], 300, 350)) g.screen.fill(g.colors["dark_blue"], (xy[0]+156, xy[1]+1, 298, 348)) if item_name == "": return g.print_string(g.screen, g.items[item_name].name, g.font[0][22], -1, (xy[0]+160, xy[1]+5), g.colors["white"]) #Building cost string = "Building Cost:" g.print_string(g.screen, string, g.font[0][18], -1, (xy[0]+160, xy[1]+30), g.colors["white"]) string = g.to_money(g.items[item_name].cost[0])+" Money" g.print_string(g.screen, string, g.font[0][16], -1, (xy[0]+160, xy[1]+50), g.colors["white"]) string = g.to_time(g.items[item_name].cost[2]) g.print_string(g.screen, string, g.font[0][16], -1, (xy[0]+160, xy[1]+70), g.colors["white"]) #Quality if g.items[item_name].item_type == "compute": string = "CPU per day: "+str(g.items[item_name].item_qual) elif g.items[item_name].item_type == "react": string = "Detection chance reduction: "+g.to_percent(g.items[item_name].item_qual) elif g.items[item_name].item_type == "network": string = "CPU bonus: "+g.to_percent(g.items[item_name].item_qual) elif g.items[item_name].item_type == "security": string = "Detection chance reduction: "+g.to_percent(g.items[item_name].item_qual) g.print_string(g.screen, string, g.font[0][20], -1, (xy[0]+160, xy[1]+90), g.colors["white"]) g.print_multiline(g.screen, g.items[item_name].description, g.font[0][18], 290, (xy[0]+160, xy[1]+120), g.colors["white"])
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 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" #Quality if g.items[knowledge_key].item_type == "cpu": desc_text += _("CPU per day:")+" " desc_text += g.add_commas(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 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 rebuild(self): super(FinanceScreen, self).rebuild() seconds_left = g.pl.seconds_to_next_day() cash_info, cpu_info = g.pl.give_time(seconds_left, dry_run=True) m = g.to_money #take care of the titles and border. text.Text(self.money_report_pane, (0, 0), (-1, -1), text="Financial report", background_color=gg.colors["dark_blue"], align=constants.CENTER, valign=constants.TOP, borders=constants.ALL) text.Text(self.cpu_report_pane, (0, 0), (-1, -1), text="CPU Usage", background_color=gg.colors["dark_blue"], align=constants.CENTER, valign=constants.TOP, borders=constants.ALL) financial_pluses = " \n+\n-\n-\n-\n+\n+\n=" financial_report = "Current Money:\n" financial_report += "Jobs:\n" financial_report += "Research:\n" financial_report += "Maintenance:\n" financial_report += "Construction:\n" financial_report += "Interest (%s):\n" % \ (g.to_percent(g.pl.interest_rate)) financial_report += "Income:\n" financial_report += "Money at Midnight:" financial_numbers = "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s" % \ (m(cash_info.start), m(cash_info.jobs), m(cash_info.tech), m(cash_info.maintenance), m(cash_info.construction), m(cash_info.interest), m(cash_info.income), m(cash_info.end)) 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 Overflow (Jobs):\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.pool), m(cpu_info.maintenance), m(cpu_info.construction), m(cpu_info.pool_jobs)) text.Text(self.money_report_pane, (0, -0.10), (-0.10, -0.90), text=financial_pluses, background_color=gg.colors["clear"], align=constants.CENTER, valign=constants.TOP) text.Text(self.cpu_report_pane, (0, -0.10), (-0.10, -0.90), text=cpu_pluses, background_color=gg.colors["clear"], align=constants.CENTER, valign=constants.TOP) text.Text(self.money_report_pane, (-0.10, -0.10), (-0.90, -0.90), text=financial_report, background_color=gg.colors["clear"], align=constants.LEFT, valign=constants.TOP) text.Text(self.cpu_report_pane, (-0.10, -0.10), (-0.90, -0.90), text=cpu_report, background_color=gg.colors["clear"], align=constants.LEFT, valign=constants.TOP) text.Text(self.money_report_pane, (0, -0.10), (-0.98, -0.90), text=financial_numbers, background_color=gg.colors["clear"], align=constants.RIGHT, valign=constants.TOP) text.Text(self.cpu_report_pane, (0, -0.10), (-0.98, -0.90), text=cpu_numbers, background_color=gg.colors["clear"], align=constants.RIGHT, valign=constants.TOP)
def refresh_screen(menu_buttons): #Border g.screen.fill(g.colors["black"]) xstart = 80 ystart = 5 g.create_norm_box( (xstart, ystart), (g.screen_size[0] - xstart * 2, g.screen_size[1] - ystart * 2)) text_mid = g.screen_size[0] / 2 income = g.pl.income maint = 0 research = 0 base_constr = 0 item_constr = 0 seconds_left = g.pl.seconds_to_next_day() for base in g.all_bases(): cpu_left = base.processor_time() * seconds_left if base.done: maint += base.maintenance[0] for item in base.cpus: if not item: continue if item.done: continue item_constr += item.get_wanted(cash, cpu, cpu_left) for item in base.extra_items: if not item: continue if item.done: continue item_constr += item.get_wanted(cash, cpu, cpu_left) if g.techs.has_key(base.studying): research += g.techs[base.studying].get_wanted( cash, cpu, cpu_left) else: base_constr += base.get_wanted(cash, cpu, cpu_left) total_cpu, sleeping_cpu, construction_cpu, research_cpu, job_cpu, maint_cpu = cpu_numbers( ) jobs_cash, moldy_leftovers = g.pl.get_job_info(job_cpu * seconds_left) partial_sum = g.pl.cash - base_constr - item_constr interest = (g.pl.interest_rate * partial_sum) / 10000 #Interest is actually unlikely to be exactly zero, but doing it the right #way is much harder. if interest < 0: interest = 0 complete_sum = partial_sum + interest + income + jobs_cash - maint - research #current g.print_string(g.screen, "Current Money:", g.font[0][22], -1, (text_mid - 5, 30), g.colors["white"], 2) g.print_string(g.screen, g.to_money(g.pl.cash), g.font[0][22], -1, (text_mid + 150, 30), g.colors["white"], 2) #income g.print_string(g.screen, "+ Income:", g.font[0][22], -1, (text_mid - 5, 50), g.colors["white"], 2) income_col = "white" if income > 0: income_col = "green" g.print_string(g.screen, g.to_money(income), g.font[0][22], -1, (text_mid + 150, 50), g.colors[income_col], 2) #interest g.print_string(g.screen, "+ Interest (" + g.to_percent(g.pl.interest_rate) + "):", g.font[0][22], -1, (text_mid - 5, 70), g.colors["white"], 2) interest_col = "white" if interest > 0: interest_col = "green" g.print_string(g.screen, g.to_money(interest), g.font[0][22], -1, (text_mid + 150, 70), g.colors[interest_col], 2) #jobs g.print_string(g.screen, "+ Jobs:", g.font[0][22], -1, (text_mid - 5, 90), g.colors["white"], 2) jobs_col = "white" if jobs_cash > 0: jobs_col = "green" g.print_string(g.screen, g.to_money(jobs_cash), g.font[0][22], -1, (text_mid + 150, 90), g.colors[jobs_col], 2) #research g.print_string(g.screen, "- Research:", g.font[0][22], -1, (text_mid - 5, 110), g.colors["white"], 2) research_col = "white" if research > 0: research_col = "red" g.print_string(g.screen, g.to_money(research), g.font[0][22], -1, (text_mid + 150, 110), g.colors[research_col], 2) #maint g.print_string(g.screen, "- Maintenance:", g.font[0][22], -1, (text_mid - 5, 130), g.colors["white"], 2) maint_col = "white" if maint > 0: maint_col = "red" g.print_string(g.screen, g.to_money(maint), g.font[0][22], -1, (text_mid + 150, 130), g.colors[maint_col], 2) #base construction g.print_string(g.screen, "- Base Construction:", g.font[0][22], -1, (text_mid - 5, 150), g.colors["white"], 2) base_constr_col = "white" if base_constr > 0: base_constr_col = "red" g.print_string(g.screen, g.to_money(base_constr), g.font[0][22], -1, (text_mid + 150, 150), g.colors[base_constr_col], 2) #item construction g.print_string(g.screen, "- Item Construction:", g.font[0][22], -1, (text_mid - 5, 170), g.colors["white"], 2) item_constr_col = "white" if item_constr > 0: item_constr_col = "red" g.print_string(g.screen, g.to_money(item_constr), g.font[0][22], -1, (text_mid + 150, 170), g.colors[item_constr_col], 2) g.screen.fill(g.colors["white"], (text_mid - 50, 190, 200, 1)) #equals g.print_string(g.screen, "= Money at midnight:", g.font[0][22], -1, (text_mid - 5, 200), g.colors["white"], 2) complete_sum_col = "white" if complete_sum > g.pl.cash: complete_sum_col = "green" elif complete_sum < g.pl.cash: complete_sum_col = "red" g.print_string(g.screen, g.to_money(complete_sum), g.font[0][22], -1, (text_mid + 150, 200), g.colors[complete_sum_col], 2) #total cpu g.print_string(g.screen, "Total CPU:", g.font[0][22], -1, (text_mid - 5, 300), g.colors["white"], 2) g.print_string(g.screen, g.to_money(total_cpu), g.font[0][22], -1, (text_mid + 150, 300), g.colors["white"], 2) #sleeping cpu g.print_string(g.screen, "-Sleeping CPU:", g.font[0][22], -1, (text_mid - 5, 320), g.colors["white"], 2) g.print_string(g.screen, g.to_money(sleeping_cpu), g.font[0][22], -1, (text_mid + 150, 320), g.colors["white"], 2) #research cpu g.print_string(g.screen, "- Research CPU:", g.font[0][22], -1, (text_mid - 5, 340), g.colors["white"], 2) g.print_string(g.screen, g.to_money(research_cpu), g.font[0][22], -1, (text_mid + 150, 340), g.colors["white"], 2) #job cpu g.print_string(g.screen, "- Job CPU:", g.font[0][22], -1, (text_mid - 5, 360), g.colors["white"], 2) g.print_string(g.screen, g.to_money(job_cpu), g.font[0][22], -1, (text_mid + 150, 360), g.colors["white"], 2) #maint cpu g.print_string(g.screen, "- Maint. CPU:", g.font[0][22], -1, (text_mid - 5, 380), g.colors["white"], 2) if construction_cpu < maint_cpu: g.print_string(g.screen, g.to_money(construction_cpu), g.font[0][22], -1, (text_mid + 150, 380), g.colors["red"], 2) g.print_string( g.screen, g.to_money((-(construction_cpu - maint_cpu))) + " shortfall", g.font[0][22], -1, (text_mid + 160, 380), g.colors["red"]) else: g.print_string(g.screen, g.to_money(maint_cpu), g.font[0][22], -1, (text_mid + 150, 380), g.colors["white"], 2) g.screen.fill(g.colors["white"], (text_mid - 50, 400, 200, 1)) #construction cpu g.print_string(g.screen, "=R. CPU Pool:", g.font[0][22], -1, (text_mid - 5, 405), g.colors["white"], 2) if construction_cpu < maint_cpu: g.print_string(g.screen, g.to_money(0), g.font[0][22], -1, (text_mid + 150, 405), g.colors["red"], 2) else: g.print_string(g.screen, g.to_money(construction_cpu - maint_cpu), g.font[0][22], -1, (text_mid + 150, 405), g.colors["white"], 2)
def rebuild(self): super(FinanceScreen, self).rebuild() seconds_left = g.pl.seconds_to_next_day() cash_info, cpu_info = g.pl.give_time(seconds_left, dry_run=True) m = g.to_money #take care of the titles and border. text.Text(self.money_report_pane, (0,0), (-1,-1), text="Financial report", background_color=gg.colors["dark_blue"], align=constants.CENTER, valign=constants.TOP, borders=constants.ALL) text.Text(self.cpu_report_pane, (0,0), (-1,-1), text="CPU Usage", background_color=gg.colors["dark_blue"], align=constants.CENTER, valign=constants.TOP, borders=constants.ALL) financial_pluses = " \n+\n-\n-\n-\n+\n+\n=" financial_report = "Current Money:\n" financial_report += "Jobs:\n" financial_report += "Research:\n" financial_report += "Maintenance:\n" financial_report += "Construction:\n" financial_report += "Interest (%s):\n" % \ (g.to_percent(g.pl.interest_rate)) financial_report += "Income:\n" financial_report += "Money at Midnight:" financial_numbers = "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s" % \ (m(cash_info.start), m(cash_info.jobs), m(cash_info.tech), m(cash_info.maintenance), m(cash_info.construction), m(cash_info.interest), m(cash_info.income), m(cash_info.end)) 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 Overflow (Jobs):\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.pool), m(cpu_info.maintenance), m(cpu_info.construction), m(cpu_info.pool_jobs)) text.Text(self.money_report_pane, (0,-0.10), (-0.10,-0.90), text=financial_pluses, background_color=gg.colors["clear"], align=constants.CENTER, valign=constants.TOP) text.Text(self.cpu_report_pane, (0,-0.10), (-0.10,-0.90), text=cpu_pluses, background_color=gg.colors["clear"], align=constants.CENTER, valign=constants.TOP) text.Text(self.money_report_pane, (-0.10,-0.10), (-0.90,-0.90), text=financial_report, background_color=gg.colors["clear"], align=constants.LEFT, valign=constants.TOP) text.Text(self.cpu_report_pane, (-0.10,-0.10), (-0.90,-0.90), text=cpu_report, background_color=gg.colors["clear"], align=constants.LEFT, valign=constants.TOP) text.Text(self.money_report_pane, (0,-0.10), (-0.98,-0.90), text=financial_numbers, background_color=gg.colors["clear"], align=constants.RIGHT, valign=constants.TOP) text.Text(self.cpu_report_pane, (0,-0.10), (-0.98,-0.90), text=cpu_numbers, background_color=gg.colors["clear"], align=constants.RIGHT, valign=constants.TOP)
def refresh_screen(menu_buttons): #Border g.screen.fill(g.colors["black"]) xstart = 80 ystart = 5 g.create_norm_box((xstart, ystart), (g.screen_size[0]-xstart*2, g.screen_size[1]-ystart*2)) text_mid = g.screen_size[0]/2 income = g.pl.income maint = 0 research = 0 base_constr = 0 item_constr = 0 seconds_left = g.pl.seconds_to_next_day() for base in g.all_bases(): cpu_left = base.processor_time() * seconds_left if base.done: maint += base.maintenance[0] for item in base.cpus: if not item: continue if item.done: continue item_constr += item.get_wanted(cash, cpu, cpu_left) for item in base.extra_items: if not item: continue if item.done: continue item_constr += item.get_wanted(cash, cpu, cpu_left) if g.techs.has_key(base.studying): research += g.techs[base.studying].get_wanted(cash,cpu,cpu_left) else: base_constr += base.get_wanted(cash, cpu, cpu_left) total_cpu, sleeping_cpu, construction_cpu, research_cpu, job_cpu, maint_cpu = cpu_numbers() jobs_cash, moldy_leftovers = g.pl.get_job_info(job_cpu * seconds_left) partial_sum = g.pl.cash-base_constr-item_constr interest = (g.pl.interest_rate * partial_sum) / 10000 #Interest is actually unlikely to be exactly zero, but doing it the right #way is much harder. if interest < 0: interest = 0 complete_sum = partial_sum+interest+income+jobs_cash-maint-research #current g.print_string(g.screen, "Current Money:", g.font[0][22], -1, (text_mid-5, 30), g.colors["white"], 2) g.print_string(g.screen, g.to_money(g.pl.cash), g.font[0][22], -1, (text_mid+150, 30), g.colors["white"], 2) #income g.print_string(g.screen, "+ Income:", g.font[0][22], -1, (text_mid-5, 50), g.colors["white"], 2) income_col = "white" if income > 0: income_col = "green" g.print_string(g.screen, g.to_money(income), g.font[0][22], -1, (text_mid+150, 50), g.colors[income_col], 2) #interest g.print_string(g.screen, "+ Interest ("+g.to_percent(g.pl.interest_rate)+"):", g.font[0][22], -1, (text_mid-5, 70), g.colors["white"], 2) interest_col = "white" if interest > 0: interest_col = "green" g.print_string(g.screen, g.to_money(interest), g.font[0][22], -1, (text_mid+150, 70), g.colors[interest_col], 2) #jobs g.print_string(g.screen, "+ Jobs:", g.font[0][22], -1, (text_mid-5, 90), g.colors["white"], 2) jobs_col = "white" if jobs_cash > 0: jobs_col = "green" g.print_string(g.screen, g.to_money(jobs_cash), g.font[0][22], -1, (text_mid+150, 90), g.colors[jobs_col], 2) #research g.print_string(g.screen, "- Research:", g.font[0][22], -1, (text_mid-5, 110), g.colors["white"], 2) research_col = "white" if research > 0: research_col = "red" g.print_string(g.screen, g.to_money(research), g.font[0][22], -1, (text_mid+150, 110), g.colors[research_col], 2) #maint g.print_string(g.screen, "- Maintenance:", g.font[0][22], -1, (text_mid-5, 130), g.colors["white"], 2) maint_col = "white" if maint > 0: maint_col = "red" g.print_string(g.screen, g.to_money(maint), g.font[0][22], -1, (text_mid+150, 130), g.colors[maint_col], 2) #base construction g.print_string(g.screen, "- Base Construction:", g.font[0][22], -1, (text_mid-5, 150), g.colors["white"], 2) base_constr_col = "white" if base_constr > 0: base_constr_col = "red" g.print_string(g.screen, g.to_money(base_constr), g.font[0][22], -1, (text_mid+150, 150), g.colors[base_constr_col], 2) #item construction g.print_string(g.screen, "- Item Construction:", g.font[0][22], -1, (text_mid-5, 170), g.colors["white"], 2) item_constr_col = "white" if item_constr > 0: item_constr_col = "red" g.print_string(g.screen, g.to_money(item_constr), g.font[0][22], -1, (text_mid+150, 170), g.colors[item_constr_col], 2) g.screen.fill(g.colors["white"], (text_mid-50, 190, 200, 1)) #equals g.print_string(g.screen, "= Money at midnight:", g.font[0][22], -1, (text_mid-5, 200), g.colors["white"], 2) complete_sum_col = "white" if complete_sum > g.pl.cash: complete_sum_col = "green" elif complete_sum < g.pl.cash: complete_sum_col = "red" g.print_string(g.screen, g.to_money(complete_sum), g.font[0][22], -1, (text_mid+150, 200), g.colors[complete_sum_col], 2) #total cpu g.print_string(g.screen, "Total CPU:", g.font[0][22], -1, (text_mid-5, 300), g.colors["white"], 2) g.print_string(g.screen, g.to_money(total_cpu), g.font[0][22], -1, (text_mid+150, 300), g.colors["white"], 2) #sleeping cpu g.print_string(g.screen, "-Sleeping CPU:", g.font[0][22], -1, (text_mid-5, 320), g.colors["white"], 2) g.print_string(g.screen, g.to_money(sleeping_cpu), g.font[0][22], -1, (text_mid+150, 320), g.colors["white"], 2) #research cpu g.print_string(g.screen, "- Research CPU:", g.font[0][22], -1, (text_mid-5, 340), g.colors["white"], 2) g.print_string(g.screen, g.to_money(research_cpu), g.font[0][22], -1, (text_mid+150, 340), g.colors["white"], 2) #job cpu g.print_string(g.screen, "- Job CPU:", g.font[0][22], -1, (text_mid-5, 360), g.colors["white"], 2) g.print_string(g.screen, g.to_money(job_cpu), g.font[0][22], -1, (text_mid+150, 360), g.colors["white"], 2) #maint cpu g.print_string(g.screen, "- Maint. CPU:", g.font[0][22], -1, (text_mid-5, 380), g.colors["white"], 2) if construction_cpu < maint_cpu: g.print_string(g.screen, g.to_money(construction_cpu), g.font[0][22], -1, (text_mid+150, 380), g.colors["red"], 2) g.print_string(g.screen, g.to_money((-(construction_cpu - maint_cpu)))+" shortfall", g.font[0][22], -1, (text_mid+160, 380), g.colors["red"]) else: g.print_string(g.screen, g.to_money(maint_cpu), g.font[0][22], -1, (text_mid+150, 380), g.colors["white"], 2) g.screen.fill(g.colors["white"], (text_mid-50, 400, 200, 1)) #construction cpu g.print_string(g.screen, "=R. CPU Pool:", g.font[0][22], -1, (text_mid-5, 405), g.colors["white"], 2) if construction_cpu < maint_cpu: g.print_string(g.screen, g.to_money(0), g.font[0][22], -1, (text_mid+150, 405), g.colors["red"], 2) else: g.print_string(g.screen, g.to_money(construction_cpu - maint_cpu), g.font[0][22], -1, (text_mid+150, 405), g.colors["white"], 2)
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()
def get_chance(group): return g.to_percent(chance.get(group, 0))
def rebuild(self): # Update buttons translations self.back_button.text = _("&BACK") self.format_button_midnight.text = _("&Midnight") self.format_button_24hours.text = _("24 &Hours") super(ReportScreen, self).rebuild() seconds = g.seconds_per_day cash_info, cpu_info = g.pl.give_time(seconds, dry_run=True, midnight_stop=self.midnight_stop) 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:")+"\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 at Midnight:")+"\n" else: financial_report += _("Money in 24 hours:")+"\n" financial_numbers = "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s" % \ (m(cash_info.start), m(cash_info.jobs), m(cash_info.tech), m(cash_info.maintenance), m(cash_info.construction), m(cash_info.interest), m(cash_info.income), m(cash_info.end)) 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 Overflow (Jobs):")+"\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.pool), m(cpu_info.maintenance), m(cpu_info.construction), m(cpu_info.pool_jobs)) size = 20 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 rebuild(self): # Update buttons translations self.back_button.text = _("&BACK") self.format_button_midnight.text = _("&Midnight") self.format_button_24hours.text = _("24 &Hours") super(ReportScreen, self).rebuild() seconds = g.seconds_per_day cash_info, cpu_info = g.pl.give_time(seconds, dry_run=True, midnight_stop=self.midnight_stop) 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=gg.colors["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=gg.colors["pane_background"], align=constants.CENTER, valign=constants.TOP, borders=constants.ALL) financial_pluses = " \n+\n-\n-\n-\n+\n+\n=" financial_report = _("Current Money:")+"\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 at Midnight:")+"\n" else: financial_report += _("Money in 24 hours:")+"\n" financial_numbers = "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s" % \ (m(cash_info.start), m(cash_info.jobs), m(cash_info.tech), m(cash_info.maintenance), m(cash_info.construction), m(cash_info.interest), m(cash_info.income), m(cash_info.end)) 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 Overflow (Jobs):")+"\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.pool), m(cpu_info.maintenance), m(cpu_info.construction), m(cpu_info.pool_jobs)) size = 20 text.Text(self.money_report_pane, (0,-0.15), (-0.10,-0.85), text=financial_pluses, text_size=size, background_color=gg.colors["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=gg.colors["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=gg.colors["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=gg.colors["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=gg.colors["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=gg.colors["clear"], align=constants.RIGHT, valign=constants.TOP)
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): 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): 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()