Example #1
0
    def show(self, ui, *, pan=(0, 0)):
        # show background
        ui.show_div(self.pos, self.size, color=(210, 210, 210), pan=pan)
        ui.show_div(self.pos, self.size, border=1, pan=pan)

        # show text
        ui.show_text(utils.add(self.pos, (50, 30)), self.name, f.cambria(25), pan=pan, align=(0, 1))
        ui.show_text(utils.add(self.pos, (50, 80)), self.ip, f.cambria(15), pan=pan, align=(0, 1))
        ui.show_text(utils.add(self.pos, (150, 80)), str(self.port), f.cambria(15), pan=pan, align=(0, 1))

        # show button
        self.join_btn.show(ui, pan=pan)
Example #2
0
    def show(self, ui):
        self.background.show(ui)
        ui.show_text((self.args.size[0] // 2, 100), f'{self.displayed_room_name}', f.cambria(60), color=(0, 0, 128), align=(1, 1))

        # show ip title
        ui.show_text((self.args.size[0] // 2, 180), 'client ip', f.tnr(30), color=(128, 0, 0), align=(1, 1))
        ui.show_div((self.args.size[0] // 2, 210), (800, 352), color=(191, 220, 187), align=(1, 0))

        # show ip lists
        for i in range(4):
            row = i % 4
            pos = (self.args.size[0] // 2, 254 + 84 * row)
            color = self.player_colors[i]
            if i == self.id and i < len(self.ip_list):
                ui.show_div(pos, (368, 56), color=color, align=(1, 1))
                ui.show_div((pos[0], pos[1] + 28), (368, 12), color=cl.multiply(color, 0.8), align=(1, 0))
                ui.show_text(
                    pos, self.ip_list[i], f.tnr_bold(25),
                    color=cl.white, save='tnr-bold-25-white', align=(1, 1))
            elif i < len(self.ip_list):
                ui.show_div(pos, (368, 56), color=cl.white, align=(1, 1))
                ui.show_div((pos[0], pos[1] + 28), (368, 12), color=color, align=(1, 0))
                ui.show_text(
                    pos, self.ip_list[i], f.tnr_bold(25),
                    save='tnr-bold-25', align=(1, 1))
            else:
                ui.show_div(pos, (368, 56), color=cl.white, align=(1, 1))
                ui.show_div((pos[0], pos[1] + 28), (368, 12), color=cl.white, align=(1, 0))

        for name in self.buttons:
            self.buttons[name].show(ui)
Example #3
0
 def show(self, ui):
     self.background.show(ui)
     # show input box
     ui.show_div((self.args.size[0] // 2, 300), (600, 80),
                 color=(255, 255, 255),
                 align=(1, 1))
     ui.show_div((self.args.size[0] // 2, 300), (600, 80),
                 border=2,
                 color=(0, 0, 0),
                 align=(1, 1))
     if self.server_ip != '':
         ui.show_text((self.args.size[0] // 2, 300),
                      self.server_ip,
                      f.cambria(25),
                      save='cambria-25',
                      align=(1, 1))
     # show buttons
     for name in self.buttons:
         self.buttons[name].show(ui)
     # show error message
     if self.error_msg is not None:
         ui.show_text((self.args.size[0] // 2, 400),
                      self.error_msg,
                      f.tnr(20),
                      color=(128, 0, 0),
                      save='tnr-20-err',
                      align=(1, 1))
Example #4
0
 def show(self, ui):
     self.background.show(ui)
     ui.show_texts((self.args.size[0] // 2, 150),
                   [["PY-", (128, 0, 0)], ["GENERALS", (0, 0, 128)]],
                   font=f.cambria(120),
                   align=(1, 1))
     for name in self.buttons:
         self.buttons[name].show(ui)
Example #5
0
 def show(self, ui):
     self.background.show(ui)
     ui.show_texts(
         (self.args.size[0] // 2, 150),
         [["BATTLE", (255, 0, 0)], [" OF ", (0, 0, 0)], ["SNAKES", (0, 0, 255)]],
         font=f.cambria(100), align=(1, 1))
     for name in self.buttons:
         self.buttons[name].show(ui)
Example #6
0
 def show(self, ui, win, score, *, pan=(0, 0)):
     pos = self.pos[0] + pan[0], self.pos[1] + pan[1]
     # container
     ui.show_div(pos, self.size, color=(255, 204, 204) if win else (204, 204, 255))
     ui.show_div(pos, self.size, border=2)
     # round
     ui.show_text(
         (self.size[0] // 2, 40), f'YOU  {"WIN" if win else "LOSE"}!',
         f.cambria(28), save='cambria-28', align=(1, 0), pan=pos
     )
     ui.show_text(
         (self.size[0] // 2, 80), f'Score: {score}',
         f.cambria(25), save='cambria-25', align=(1, 0), pan=pos
     )
     # buttons
     for name in self.buttons:
         self.buttons[name].show(ui)
Example #7
0
 def show(self, ui):
     self.background.show(ui)
     ui.show_texts((self.args.size[0] // 2, 150),
                   [["PLATFORMER", (0, 0, 0)]],
                   font=f.cambria(120),
                   align=(1, 1))
     for name in self.buttons:
         self.buttons[name].show(ui)
Example #8
0
 def show(self, ui):
     self.background.show(ui)
     ui.show_text((self.args.size[0] // 2, 150),
                  "Game Mode",
                  font=f.cambria(60),
                  save='cambria-60',
                  align=(1, 1))
     for name in self.buttons:
         self.buttons[name].show(ui)
Example #9
0
 def show(self, ui):
     self.background.show(ui)
     ui.show_texts((self.args.size[0] // 2, 150), [["PLATFORMER", (0, 0, 0)]], f.cambria(120), align=(1, 1))
     for name in self.buttons:
         self.buttons[name].show(ui)
     if self.settings_reloaded:
         ui.show_text(
             (self.args.size[0] - 140, self.args.size[1] - 43), "Settings reloaded!",
             f.get_font('courier-prime', 20), color=(64, 64, 255), align=(1, 2)
         )
Example #10
0
 def show(self, ui):
     self.background.show(ui)
     ui.show_text((self.args.size[0] // 2, 100), f'IP: {self.ip}', f.cambria(60), color=(0, 0, 128), align=(1, 1))
     # show connected ips
     ui.show_text((self.args.size[0] // 2, 180), 'client ip', f.tnr(30), color=(128, 0, 0), align=(1, 1))
     for i, client in enumerate(self.clients):
         ui.show_text((self.args.size[0] // 2, 180 + (i + 1) * 60), client['ip'], f.tnr(30), align=(1, 1))
     # show buttons
     for name in self.buttons:
         self.buttons[name].show(ui)
Example #11
0
 def show(self, ui):
     self.background.show(ui)
     ui.show_text((self.args.size[0] // 2, 100),
                  f'IP: {self.server_ip}',
                  f.cambria(60),
                  color=(0, 0, 128),
                  align=(1, 1))
     # TODO: show ip
     for name in self.buttons:
         self.buttons[name].show(ui)
Example #12
0
    def show(self, ui):
        self.background.show(ui)
        ui.show_text((self.args.size[0] // 2, 100),
                     f'IP: {self.ip}',
                     f.cambria(60),
                     color=(0, 0, 128),
                     align=(1, 1))

        # show ip title
        ui.show_text((self.args.size[0] // 2, 180),
                     'client ip',
                     f.tnr(30),
                     color=(128, 0, 0),
                     align=(1, 1))
        ui.show_div((self.args.size[0] // 2, 210), (800, 352),
                    color=(191, 220, 187),
                    align=(1, 0))

        # show ip lists
        ip_list = [self.ip] + [client['ip'] for client in self.clients]
        for i in range(8):
            row, col = i % 4, i // 4
            pos = (self.args.size[0] // 2 - 200 + 400 * col, 254 + 84 * row)
            color = self.player_colors[i]
            if i == 0:
                ui.show_div(pos, (368, 56), color=color, align=(1, 1))
                ui.show_div((pos[0], pos[1] + 28), (368, 12),
                            color=cl.multiply(color, 0.8),
                            align=(1, 0))
                ui.show_text(pos,
                             ip_list[i],
                             f.tnr_bold(25),
                             color=cl.white,
                             save='tnr-bold-25-white',
                             align=(1, 1))
            elif i < len(ip_list):
                ui.show_div(pos, (368, 56), color=cl.white, align=(1, 1))
                ui.show_div((pos[0], pos[1] + 28), (368, 12),
                            color=color,
                            align=(1, 0))
                ui.show_text(pos,
                             ip_list[i],
                             f.tnr_bold(25),
                             save='tnr-bold-25',
                             align=(1, 1))
            else:
                ui.show_div(pos, (368, 56), color=cl.white, align=(1, 1))
                ui.show_div((pos[0], pos[1] + 28), (368, 12),
                            color=cl.white,
                            align=(1, 0))

        # show buttons
        for name in self.buttons:
            self.buttons[name].show(ui)
Example #13
0
 def show(self, ui, *, pan=(0, 0)):
     pos = self.pos[0] + pan[0], self.pos[1] + pan[1]
     # container
     ui.show_div(pos, self.size, color=(192, 192, 192))
     ui.show_div(pos, self.size, border=2)
     # round
     ui.show_text(
         (self.size[0] // 2, 40), f'PAUSED', f.cambria(28), save='cambria-28', align=(1, 0), pan=pos
     )
     # buttons
     for name in self.buttons:
         self.buttons[name].show(ui)
Example #14
0
    def show(self, ui, pos, *, align=(0, 0), pan=(0, 0)):
        pos = utils.top_left(pos, self.size, align=align)

        # show background:
        if self.err:
            color = cl.gray_1
        elif self.winner is None:
            color = cl.white
        else:
            color = self.player_colors[self.winner]
        color_blocks = (182, 192, 189)
        ui.show_div((pos[0], pos[1]), (self.size[0] - 300, self.size[1]), color=color_blocks, pan=pan)
        ui.show_div((pos[0] + 5, pos[1] + 5), (12, self.size[1] - 10), color=color, pan=pan)
        ui.show_div((pos[0] + self.size[0] - 300, pos[1]), (180, self.size[1]), color=cl.add(color_blocks, -10), pan=pan)
        ui.show_div(
            (pos[0] + self.size[0] - 120, pos[1]), (120, self.size[1] // 2), color=cl.add(color_blocks, -20), pan=pan)
        ui.show_div(
            (pos[0] + self.size[0] - 120, pos[1] + self.size[1] // 2),
            (120, self.size[1] // 2), color=(160, 145, 145), pan=pan)

        # show name, num, & turn
        ui.show_text(
            (pos[0] + 40, pos[1] + self.size[1] // 2), self.name,
            f.cambria(22), save='cambria-22', align=(0, 1), pan=pan)
        if not self.err:
            ui.show_text(
                (pos[0] + self.size[0] - 210, pos[1] + self.size[1] // 2 - 18), f'Turn {self.turn}',
                f.cambria(20), save='cambria-20', align=(1, 1), pan=pan)
            ui.show_text(
                (pos[0] + self.size[0] - 210, pos[1] + self.size[1] // 2 + 18),
                f'{self.num} player' + ('' if self.num == 1 else 's'),
                f.cambria(20), save='cambria-20', align=(1, 1), pan=pan)

        # show play and delete images
        ui.show_img_by_path(
            (pos[0] + self.size[0] - 60, pos[1] + self.size[1] // 4), 'play.png', align=(1, 1), pan=pan)
        ui.show_img_by_path(
            (pos[0] + self.size[0] - 60, pos[1] + self.size[1] * 3 // 4), 'delete.png', align=(1, 1), pan=pan)
Example #15
0
 def show(self, ui):
     self.map.show(ui, pan=self.pan)
     for player in self.players:
         player.show(ui, pan=self.pan)
     if self.paused:
         ui.show_div((self.args.size[0] // 2, self.args.size[1] // 2), (400, 100), color=(192, 192, 192), align=(1, 1))
         ui.show_div(
             (self.args.size[0] // 2, self.args.size[1] // 2), (400, 100),
             color=(0, 0, 0), border=2, align=(1, 1)
         )
         ui.show_text(
             (self.args.size[0] // 2, self.args.size[1] // 2), 'SERVER PAUSED',
             font=f.cambria(30), color=(0, 0, 0), align=(1, 1)
         )
Example #16
0
 def show(self, ui):
     self.background.show(ui)
     ui.show_text((self.args.size[0] // 2, 100),
                  "Select A Level",
                  font=f.cambria(60),
                  align=(1, 1))
     for name in self.buttons:
         button = self.buttons[name]
         button.show(ui)
         if name not in ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']:
             continue
         if self.scores[name][0] < 0:
             continue
         b_pos = button.pos[0] + button.size[0] // 2, button.pos[
             1] + button.size[1] // 2
         # show score
         x, y = 35, 50
         pos_list = [[b_pos[0] - x, b_pos[1] + y], [b_pos[0], b_pos[1] + y],
                     [b_pos[0] + x, b_pos[1] + y]]
         for i, pos in enumerate(pos_list):
             ui.show_div(pos, (24, 24),
                         color=(255, 215,
                                0) if self.scores[name][0] > i else
                         (255, 255, 255),
                         align=(1, 1))
             ui.show_div(pos, (24, 24), border=2, align=(1, 1))
         # show time
         if self.scores[name][1] is None:
             continue
         ui.show_div((b_pos[0] + 23, b_pos[1] - 50), (80, 26),
                     color=(255, 255, 255),
                     align=(1, 1))
         ui.show_div((b_pos[0] + 23, b_pos[1] - 50), (80, 26),
                     border=2,
                     align=(1, 1))
         time = utils.to_str_time(self.scores[name][1]).split(':')
         ui.show_text((b_pos[0] + 38, b_pos[1] - 40),
                      f'{time[0]}:{time[1]}',
                      f.get_font('04b_03b', 18),
                      align=(2, 2))
         ui.show_text((b_pos[0] + 41, b_pos[1] - 41),
                      f'{time[2]}',
                      f.get_font('04b_03b', 14),
                      align=(0, 2))
Example #17
0
 def show(self, ui):
     # show map
     self.map.show(ui, pan=self.pan)
     # show player
     for player in reversed(self.players):
         if player != self.my_player:
             player.show(ui, pan=self.pan)
     self.my_player.show(ui, pan=self.pan)
     # show timer
     self.clock.show(ui, time=self.time.split(':'))
     # show score
     self.score_display.show(ui, score=self.score)
     # show pause message
     if self.paused:
         ui.show_div((self.args.size[0] // 2, self.args.size[1] // 2),
                     (400, 100),
                     color=(192, 192, 192),
                     align=(1, 1))
         ui.show_div((self.args.size[0] // 2, self.args.size[1] // 2),
                     (400, 100),
                     color=(0, 0, 0),
                     border=2,
                     align=(1, 1))
         ui.show_text((self.args.size[0] // 2, self.args.size[1] // 2),
                      'SERVER PAUSED',
                      font=f.cambria(30),
                      color=(0, 0, 0),
                      save='cambria-30',
                      align=(1, 1))
     # Show ping
     pdelta_ms = self.pingdelta / 1e6
     rmaxping_ms = self.recent_max_ping() / 1e6
     ping_color = self.__class__.get_ping_color(pdelta_ms)
     ui.show_text(
         (self.args.size[0] - 10, 10),
         "|{: >{:d}s} ".format('#' * round(math.log(pdelta_ms + 1, 2)),
                               round(math.log(rmaxping_ms + 1, 2))) +
         f"Latency{round(pdelta_ms):6d} ms",
         font=f.get_font('courier-prime', 20),
         color=ping_color,
         save='ping-text-' + str(ping_color),
         align=(2, 0))
Example #18
0
 def show(self, ui):
     self.map.show(ui)
     self.player.show(ui)
     self.command.show(ui, self.map)
     self.scoreboard.show(ui)
     self.turn_displayer.show(ui)
     if self.status['paused']:
         ui.show_div(self.args.get_pos(1, 1), (400, 100),
                     color=(192, 192, 192),
                     align=(1, 1))
         ui.show_div(self.args.get_pos(1, 1), (400, 100),
                     color=(0, 0, 0),
                     border=2,
                     align=(1, 1))
         ui.show_text(self.args.get_pos(1, 1),
                      'SERVER PAUSED',
                      font=f.cambria(30),
                      save='cambria-30',
                      color=(0, 0, 0),
                      align=(1, 1))
Example #19
0
 def show(self, ui, *, win=None, pan=(0, 0)):
     pos = self.pos[0] + pan[0], self.pos[1] + pan[1]
     # container
     if win is None:
         color, text = (192, 192, 192), 'PAUSED'
     elif win:
         color, text = (255, 204, 204), 'YOU WIN'
     else:
         color, text = (204, 204, 255), 'YOU LOSE'
     ui.show_div(pos, self.size, color=color)
     ui.show_div(pos, self.size, border=1)
     # msg
     ui.show_text((self.size[0] // 2, 40),
                  text,
                  f.cambria(28),
                  align=(1, 0),
                  pan=pos)
     # buttons
     for name in self.buttons:
         self.buttons[name].show(ui)
Example #20
0
 def show(self, ui):
     self.background.show(ui)
     ui.show_text((self.args.size[0] // 2, 100), "Select A Level", font=f.cambria(60), align=(1, 1))
     for name in self.buttons:
         self.buttons[name].show(ui)