def say(self, text): try: text = str(btText(text)) name = str(btText(self.name)) self.tf.sendText("$%" + str(self.color) + "$%" + name + ":$%" + str(configs.colorof["talk"][0]) + "$% " + text) except: init.quit() print "Unexpected error:", sys.exc_info()[2].tb_next print sys.exc_info()[1] print configs.colorof sys.exit()
def draw(self): w = self.w h = self.h clearLine = " " * (self.w - 12) msg = btText('Messages:') map = btText('Map:') state = btText("State:") self.stdscr.vline(4, self.border, curses.ACS_VLINE, h - 5) self.stdscr.addstr(4, 2, str(msg), curses.A_BOLD) self.stdscr.addstr(4, self.border + 2, str(map), curses.A_BOLD) self.stdscr.addstr(2, 2, str(state), curses.A_BOLD) self.stdscr.addstr(2, 10, clearLine) self.stdscr.addstr(2, 10, self.statusString)
def drawMenu(menuWin, choice): menuWin.erase() menuWin.box() h, w = menuWin.getmaxyx() textout.textOut(menuTitle, (w - len(menuTitle)) / 2, 0, dst=menuWin) for i in range(len(menuList)): if choice == i: textout.textOut(">", 2, i + 2, dst=menuWin) textout.textOut(str(btText(menuList[i][0])), 4, i + 2, dst=menuWin)
def sendText(self, text2): text = btText(text2) while len(text) > self.w: line = text.getRegion(0, self.w) other = text.getRegion(self.w, len(text)) words = line.split(" ") if len(words[0]) < self.w: col = line.getColor(len(text)) text = btText("$%" + col + "$%" + words.pop() + other) self.line.append(btText("$%" + col + "$%" + " ".join(words))) else: self.line.append(btText(words[0])) words.remove(btText(words[0])) text = other self.newLine() self.line.append(text) self.newLine()
def waveWare(x, y, dst): blue = str(curses.color_pair(curses.COLOR_BLUE)) white = str(curses.color_pair(curses.COLOR_WHITE)) ww = textout.btText("$%" + blue + "$%W$%" + white + "$%ave $%" + blue + "$%W$%" + white + "$%are") textout.textOut(ww, x, y, dst)
import sys menuTitle = "/\\\\ Menue //\\" MENU_W = 55 def btExit(): init.quit() sys.exit() def btContinue(): pass menuList = [[str(btText("Continue")), btContinue], [str(btText("Quit")), btExit]] def drawMenu(menuWin, choice): menuWin.erase() menuWin.box() h, w = menuWin.getmaxyx() textout.textOut(menuTitle, (w - len(menuTitle)) / 2, 0, dst=menuWin) for i in range(len(menuList)): if choice == i: textout.textOut(">", 2, i + 2, dst=menuWin) textout.textOut(str(btText(menuList[i][0])), 4, i + 2, dst=menuWin) def start(): dsth, dstw = init.stdscr.getmaxyx()
def sendText(self, text): self.textField.sendText(str(textout.btText(text)))