Пример #1
0
def death_screen():
    left = C.width / 4
    width = C.width / 2
    height = 12
    top = C.height / 2 - height /2
    
    time = game.state.time - (24*60)
    survived = "%i days, %i hours, and %i minutes" % ((time / 60) / 24, (time / 60) % 60, time % 60)

    death_box = draw.draw_box(left, top, width, height,
                                border_color=W.LIGHTRED, border_background_color=W.RED,
                                interior_background_color=W.RED)
    death_box.text.extend([
        draw.Text(W.WHITE, 1, 3, "UNHANDLED EXCEPTION:".center(width - 2)),
        draw.Text(W.LIGHTRED, 1, 4, ("Killed by %s." % game.state.killer).center(width - 2)),
        draw.Text(W.LIGHTRED, 1, 7, ("You lasted %s. " % survived).center(width - 2)),
        draw.Text(W.WHITE, 1, 10, "Press <ENTER> to quit.".center(width - 2)),
        ])
    draw.draw_box_text(death_box)
    while True:
        (chn, chs) = W.getch()
        #figure out if we're done
        if chs == '\r':
            #enter, exit
            raise game.GameShutdown()
Пример #2
0
Файл: hud.py Проект: non/ld21
def draw_node_stats(bar, data, titleText="CURRENT NODE:", highColor=W.YELLOW, lowColor=W.BROWN):
    if not bar.text:
        bar.text.extend(
            [
                draw.Text(lowColor, 2, 2, titleText),
                draw.Text(highColor, 2, 4, "[ name ]"),
                draw.Text(highColor, 2, 5, "ip"),
                draw.Text(lowColor, 3, 7, "PROCESSOR:"),
                draw.Text(lowColor, 3, 8, "STORAGE:"),
                draw.Text(lowColor, 3, 9, "BANDWIDTH:"),
                draw.Text(lowColor, 3, 10, "SECURITY:"),
                draw.Text(lowColor, 3, 11, "EXPOSURE:"),
                draw.Text(highColor, 3, 7, "", right_justify=True),
                draw.Text(highColor, 3, 8, "", right_justify=True),
                draw.Text(highColor, 3, 9, "", right_justify=True),
                draw.Text(highColor, 3, 10, "", right_justify=True),
                draw.Text(highColor, 3, 11, "", right_justify=True),
            ]
        )
    _, nameText, ipText, _, _, _, _, _, processorText, storageText, bandwidthText, securityText, exposureText = bar.text
    nameText.text = data.name.center(bar.width - 4)[: bar.width - 4]
    ipText.text = data.ip_addr.center(bar.width - 4)[: bar.width - 4]

    processorText.text = " %i" % data.processor
    storageText.text = " %i" % data.storage
    bandwidthText.text = " %i" % data.bandwidth
    securityText.text = " %i" % data.security
    exposureText.text = " %i" % data.exposure

    draw.draw_box_text(bar)
Пример #3
0
Файл: hud.py Проект: non/ld21
def topbar_tick():
    bar = boxes.topbar
    if not bar.text:
        bar.text.extend(
            [
                draw.Text(W.WHITE, 5, 0, "Time: "),
                draw.Text(W.WHITE, 44, 0, "Condition: "),
                draw.Text(W.WHITE, 5, 0, "Mission: ", right_justify=True),
            ]
        )
    timeText, conditionText, missionText = bar.text
    timeText.text = "Time: %s" % format_time(game.state.time)
    missionText.text = ""  # "Mission: %i" % (game.state.mission)

    draw.draw_box_text(bar)
    draw_condition_bar(conditionText)
Пример #4
0
Файл: hud.py Проект: non/ld21
def draw_tunnel_list(bar, data, highColor=W.YELLOW, lowColor=W.BROWN):
    draw.draw_box(box=bar)

    def draw_node(idx, node):
        max_width = bar.width - 4
        if idx is not None:
            name = "%i) %s" % (idx, node.name)
        else:
            name = "   %s" % node.name
        name = name[:max_width]
        texts.append(draw.Text(highColor, 2, y, name))
        texts.append(draw.Text(lowColor, 2, y + 1, ("   %s" % node.ip_addr)[:max_width]))

    y = 4
    texts = [draw.Text(lowColor, 2, 2, "TUNNEL PATH:")]
    draw_node(None, game.state.home_node)
    y += 3
    start = max(0, len(data) - 7)
    i = start
    for node in data[start:]:
        i += 1
        draw_node(i, node)
        y += 3
    draw.draw_box_text(bar, text=texts)
Пример #5
0
def show_confirmation(line1=' ', line2=' '):
    line1 = terminal.Line.parse(line1)[0]
    line2 = terminal.Line.parse(line2)[0]
    width = max(14, max(line1.width, line2.width) + 2)
    height = 8
    left = (C.width - width) / 2
    top = (C.height - height) / 2
    previous_buf = W.gettext(left, top, left + width, top + height)
    btn_width = 7
    btn_height = 4
    btn_offset = 3
    try:
        container = draw.draw_box(left, top, width, height,
                                    border_color=W.LIGHTBLUE, border_background_color = W.BLUE)
        W.puttext(left+1, top + 1, left + line1.width, top + 1, line1.buf)
        W.puttext(left+1, top + 2, left + line2.width, top + 2, line2.buf)

        yes_button = draw.draw_box(left + btn_offset, top + height - btn_height, btn_width, btn_height,
                                    border_color=W.LIGHTBLUE, border_background_color = W.BLUE,
                                    corners = {'bl': 'teeup', 'br': 'teeup'})

        no_button = draw.draw_box(left + width - btn_offset - btn_width, top + height - btn_height, btn_width, btn_height,
                                    border_color=W.LIGHTBLUE, border_background_color = W.BLUE,
                                    corners = {'bl': 'teeup', 'br': 'teeup'})

        yes_text = draw.Text(W.DARKGREY, 1, 1, "YES".center(btn_width -2 ))
        no_text = draw.Text(W.WHITE, 1, 1, "NO".center(btn_width -2 ))
        yes_button.text.append(yes_text)
        no_button.text.append(no_text)
        selected_button = no_button

        while True:
            if selected_button == yes_button:
                yes_text.color = W.WHITE
                no_text.color = W.DARKGREY
            else:
                no_text.color = W.WHITE
                yes_text.color = W.DARKGREY
            draw.draw_box_text(yes_button)
            draw.draw_box_text(no_button)
            (chn, chs) = W.getch()
            #figure out if we're done
            if chs == '\r':
                #enter, exit
                break
            if chs == 'y':
                selected_button = yes_button
                break

            if chs == 'n':
                selected_button = no_button
                break

            if chn == 0 or chn == 224:
                #special keys come in two parts
                (chn2, _) = W.getch()
                if chn2 in W.__keydict:
                    name = W.__keydict[chn2]
                    if 'left' in name or 'right' in name:
                        selected_button = (selected_button == yes_button and no_button or yes_button)

        return (selected_button == yes_button and True or False)

    finally:
        #Restore what we scribbled on
        W.puttext(left, top, left + width, top + height, previous_buf)