Exemple #1
0
def joinGame():
    terminal.clear()
    terminal.printf(4, 3, "Enter Password:"******"", 22)
    addr = conn[1].split(":")
    terminal.clear()
    terminal.printf(4, 3, "Enter Nickname:")
    name = terminal.read_str(4, 4, "", 10)
    client = Client(addr[0], int(addr[1]), name[1])
    while client.isConnected == False:
        client.Loop()
    client.Send({'action': 'wantMap', 'wantMap': 0})
    mpGameLoop(client)
Exemple #2
0
    def update(self):
        if self.owner:
            layer = self.owner.layer
            x = self.owner.pos.x
            y = self.owner.pos.y
        else:
            layer = terminal.state(terminal.TK_LAYER)
            x = 0
            y = 0

        if mouse.clicked_rect(self.x + x, self.y + y, self.length, 1):
            terminal.layer(layer)
            terminal.color('white')
            terminal.puts(self.x + 1 + x, self.y + y,
                          self.skin['BACKGROUND'] * self.length)
            terminal.color('black')
            terminal.refresh()
            result, text = terminal.read_str(self.x + x + 1, self.y + y,
                                             self.text, self.length)
            terminal.refresh()
            self.text = text
            self.updated = True

            self.active = True
            self.dirty = True
Exemple #3
0
    def update(self):
        if self.owner:
            layer = self.owner.layer
            x = self.owner.pos.x
            y = self.owner.pos.y
        else:
            layer = terminal.state(terminal.TK_LAYER)
            x = 0
            y = 0

        if mouse.clicked_rect(self.x + x, self.y + y, self.length, 1):
            terminal.layer(layer)
            terminal.color('white')
            terminal.puts(self.x + 1 + x, self.y + y,
                          self.skin['BACKGROUND'] * self.length)
            terminal.color('black')
            terminal.refresh()
            result, text = terminal.read_str(self.x + x + 1, self.y + y,
                                             self.text, self.length)
            terminal.refresh()
            if text.isnumeric() and (self.min_val <= int(text) <=
                                     self.max_val):
                self.text = str(text)
                self.error = None
                self.updated = True
            else:
                self.error = 'Text must be numeric and between ' + str(
                    self.min_val) + ' and ' + str(self.max_val) + '.'

            self.active = True
            self.dirty = True
Exemple #4
0
def test_text_input():
    blt.set("window.title='Omni: text input'")
    blt.composition(False)

    max_chars = 32
    text = ""
    character = ' '
    result = 0
    char_result = 0

    while True:
        blt.clear()
        blt.color("white")

        blt.puts(2, 1, "Select different input tests by pressing corresponding number:")

        blt.puts(2, 3, "[color=orange]1.[/color] read_str")
        draw_frame(5, 4, max_chars + 2, 3)
        blt.puts(6, 5, "%s" % text)
        blt.puts(5 + max_chars + 2 + 1, 5, "[color=gray] %s" % ("OK" if result >= 0 else "Cancelled"))

        blt.puts(2, 8, "[color=orange]2.[/color] read_char")
        draw_frame(5, 9, 5, 3)
        blt.put(7, 10, character)
        blt.puts(11, 10, "[color=gray]%s" % key_names.get(char_result, str(char_result)))

        blt.refresh()

        key = blt.read()
        if key in (blt.TK_CLOSE, blt.TK_ESCAPE):
            break

        elif key == blt.TK_1:
            blt.color("orange")
            draw_frame(5, 4, max_chars + 2, 3)
            result, text = blt.read_str(6, 5, text, max_chars)

        elif key == blt.TK_2:
            blt.color("orange")
            draw_frame(5, 9, 5, 3)

            while True:
                blt.put(7, 10, character)  
                blt.clear_area(11, 10, 16, 1)
                blt.puts(11, 10, "[color=gray]%s" % key_names.get(char_result, str(char_result)))
                blt.refresh()

                character = ' '
                key = blt.read()
                if key in (blt.TK_ESCAPE, blt.TK_CLOSE, blt.TK_RETURN):
                    break
                elif blt.check(blt.TK_WCHAR):
                    character = blt.state(blt.TK_WCHAR)
                    char_result = key
                elif key < blt.TK_KEY_RELEASED:
                    char_result = key
Exemple #5
0
 def read_str(self, *args):
     if isinstance(args[0], Point):
         return _terminal.read_str(args[0].x, args[0].y, *args[1:])
     else:
         return _terminal.read_str(*args)