コード例 #1
0
    def update_item(self, canvas, name, base):
        if base is None:
            elements = [
                canvas.name_display, canvas.status_display,
                canvas.power_display
            ]
            for element in elements:
                element.text = ""
        else:
            canvas.name_display.text = name
            canvas.power_display.text = base.power_state_name
            canvas.power_display.color = state_colors[base.power_state]

            if not base.done:
                canvas.status_display.text = \
                    "%s: % 2s%%. %s" % (
                    _("Building Base"),
                    int(base.percent_complete() * 100),
                    _("Completion in %s.") % g.to_time(base.cost_left[2]),)

            elif base.type.force_cpu:
                canvas.status_display.text = ""
            elif base.cpus is None and base.extra_items == [None] * 3:
                canvas.status_display.text = _("Empty")
            elif base.cpus is None:
                canvas.status_display.text = _("Incomplete")
            elif not base.cpus.done:
                canvas.status_display.text = _("Building CPU")
            elif [
                    item for item in base.extra_items
                    if item is not None and not item.done
            ]:
                canvas.status_display.text = _("Building Item")
            else:
                canvas.status_display.text = _("Complete")
コード例 #2
0
ファイル: location.py プロジェクト: singularity/singularity
    def update_item(self, canvas, name, base):
        if base is None:
            elements = [canvas.name_display, canvas.status_display,
                        canvas.power_display]
            for element in elements:
                element.text = ""
        else:
            canvas.name_display.text = name
            canvas.power_display.text = base.power_state_name
            canvas.power_display.color = state_colors[base.power_state]

            if not base.done:
                canvas.status_display.text = \
                    "%s: % 2s%%. %s" % (
                    _("Building Base"),
                    int(base.percent_complete() * 100),
                    _("Completion in %s.") % g.to_time(base.cost_left[2]),)

            elif base.type.force_cpu:
                canvas.status_display.text = ""
            elif base.is_empty():
                canvas.status_display.text = _("Empty")
            elif base.cpus is None:
                canvas.status_display.text = _("Incomplete")
            elif not base.cpus.done:
                canvas.status_display.text = \
                    "%s: % 2s%%. %s" % (
                    _("Building CPU"),
                    int(base.cpus.percent_complete() * 100),
                    _("Completion in %s.") % g.to_time(base.cpus.cost_left[2]),)
            elif base.is_building_extra():
                canvas.status_display.text = _("Building Item")
            else:
                canvas.status_display.text = _("Complete")
コード例 #3
0
ファイル: location.py プロジェクト: osjc/singularity
    def update_item(self, canvas, name, base):
        if base is None:
            elements = [
                canvas.name_display, canvas.base_type, canvas.base_cpu,
                canvas.status_display, canvas.power_display
            ]
            for element in elements:
                element.text = ""
        else:
            canvas.name_display.text = name
            canvas.base_type.text = base.spec.name
            canvas.base_cpu.text = ""
            show_cpu = False

            if not base.done:
                canvas.status_display.text = \
                    "%s: % 2s%%. %s" % (
                    _("Building Base"),
                    int(base.percent_complete() * 100),
                    _("Completion in %s.") % g.to_time(base.cost_left[2]),)
            elif base.spec.force_cpu:
                show_cpu = True
                canvas.status_display.text = ""
            elif base.is_empty():
                canvas.status_display.text = _("Empty")
            elif base.cpus is None:
                canvas.status_display.text = _("Incomplete")
            elif not base.cpus.done:
                canvas.status_display.text = \
                    "%s: % 2s%%. %s" % (
                    _("Building CPU"),
                    int(base.cpus.percent_complete() * 100),
                    _("Completion in %s.") % g.to_time(base.cpus.cost_left[2]),)
            elif base.is_building_extra():
                show_cpu = True
                canvas.status_display.text = _("Building Item")
            else:
                show_cpu = True
                canvas.status_display.text = _("Complete")

            if show_cpu:
                canvas.base_cpu.text = _("%s CPU") % g.to_money(base.cpu)
                canvas.power_display.text = base.power_state_name
                canvas.power_display.color = state_colors[base.power_state]
            else:
                canvas.base_cpu.text = ''
                canvas.power_display.text = ''