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()
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)
def draw(self, surface): position = glm.vec3(self.xPos, self.yPos, 0) white = sdl2.ext.Color(255, 255, 255) draw.draw_box(surface, position, self.width, self.length, white)
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)
def draw_hud(): log.debug("draw_hud") for box in (boxes.topbar, boxes.current_node, boxes.home_node, boxes.tunnel_list): draw.draw_box(box=box)
def draw(self, surface): length = 548.64 width = 140.97 draw.draw_box(surface, glm.vec3(self.xStart, self.yStart, 0), length, width, self.color)