コード例 #1
0
    def drawUsername(self):
        Input = pi.TextInput()
        while self.Username:
            self.window.fill(white)

            events = pygame.event.get()
            for event in events:
                if event.type == pygame.QUIT:
                    pygame.display.quit()
                    quit()
            if (Input.update(events) == 1):
                self.submit()
            self.window.blit(Input.get_surface(), (490, 341))

            self.W.text("Username:"******"User details not found", display_width / 2, 680)
            elif self.createdAccount == 1:
                self.W.text("User created succesfully", display_width / 2, 680)
            elif self.createdAccount == -1:
                self.W.text("Failed to create user", display_width / 2, 680)
            self.W.button("Continue", font, 417, 510, 200, 60,
                          ButtonPrimaryColor, ButtonHighlightColor,
                          self.submit)
            self.W.button("Cancel", font, 663, 510, 200, 60,
                          ButtonPrimaryColor, ButtonHighlightColor,
                          self.quitWindow)
            self.W.button("Don't have an account? Create one", font_24, 417,
                          590, 446, 60, ButtonPrimaryColor,
                          ButtonHighlightColor, self.createAccount)
            pygame.display.update()
            self.clock.tick(60)
        return Input.get_text()
コード例 #2
0
    def drawCreatePassword(self):
        Input = pi.TextInput()
        while self.Password:
            self.window.fill(white)

            events = pygame.event.get()
            for event in events:
                if event.type == pygame.QUIT:
                    exit()
            if (Input.update(events) == 1):
                self.submit()
            self.window.blit(Input.get_surface(), (490, 341))

            self.W.text("Create Password:"******"Create", font, 417, 510, 200, 60,
                          ButtonPrimaryColor, ButtonHighlightColor,
                          self.submit)
            self.W.button("Cancel", font, 663, 510, 200, 60,
                          ButtonPrimaryColor, ButtonHighlightColor,
                          lambda: self.redrawWindow("Login"))
            pygame.display.update()
            self.clock.tick(60)
        return Input.get_text()
コード例 #3
0
    def drawPassword(self):
        Input = pi.TextInput()
        while self.Password:
            self.window.fill(white)

            events = pygame.event.get()
            for event in events:
                if event.type == pygame.QUIT:
                    exit()
            if (Input.update(events) == 1):
                self.submit()
            Input.convertToPassword()
            self.window.blit(Input.get_surface(), (490, 341))

            self.W.text("Password:"******"Login", font, 417, 510, 200, 60, ButtonPrimaryColor,
                          ButtonHighlightColor, self.submit)
            self.W.button("Cancel", font, 663, 510, 200, 60,
                          ButtonPrimaryColor, ButtonHighlightColor,
                          self.quitWindow)
            pygame.display.update()
            self.clock.tick(60)
        return Input.convertToPassword()
コード例 #4
0
def saveNquit(win, currentTable, start, *args):
    if len(args) == 1:
        try:
            playerID = args[0][0][0]
        except:
            playerID = args[0]
        currentTime = format_time(round(time.time() - start))
    else:
        playerID = args[0]
        currentTime = format_time(round(time.time() - start), args[5])
    cellsLeft = countEmptyCells(currentTable)
    table = parseToString(currentTable)
    if cellsLeft == 0:
        done = True
        timeCompleted = currentTime
    else:
        done = False
        timeCompleted = None

    clock = pygame.time.Clock()

    pygame.font.init()
    font = pygame.font.SysFont("comicsans", 40)
    font_small = pygame.font.SysFont("comicsans", 24)
    font_40 = pygame.font.SysFont("robotoregularttf", 40)
    font_32 = pygame.font.SysFont("robotoregularttf", 32)
    font_24 = pygame.font.SysFont("robotoregularttf", 24)
    font_20 = pygame.font.SysFont("robotoregularttf", 20)
    if len(args) != 1:
        Input = pi.TextInput(initial_string=args[2], font_size=24)
    else:
        Input = pi.TextInput(font_size=24)
    save = True
    while save:
        win.fill(white)
        events = pygame.event.get()
        for event in events:
            if event.type == pygame.QUIT:
                save = False
        Input.update(events)
        name = Input.get_text()
        win.blit(Input.get_surface(), (225, 201))

        text(win, "Save & Quit", font_32, (540 - 540 / 2), 84)

        text(win, "Name:", font_24, 186, 215)
        button(win, "", font, 222, 230, 277, 1, black,
               black)  #acts like a line

        text(win, "Time:", font_24, 191, 250)
        text(win, currentTime, font_24, 247, 250)
        button(win, "", font, 222, 265, 277, 1, black,
               black)  #acts like a line

        text(win, "Empty cells left:", font_24, 135, 285)
        if cellsLeft <= 9:
            text(win, str(cellsLeft), font_24, 232, 285)
        else:
            text(win, str(cellsLeft), font_24, 238, 285)
        button(win, "", font, 222, 300, 277, 1, black,
               black)  #acts like a line

        text(win, "Cells completed:", font_24, 130, 320)
        cellsCompleted = 81 - cellsLeft
        text(win, (str(cellsCompleted) + "/81"), font_24, 254, 320)
        button(win, "", font, 222, 335, 277, 1, black,
               black)  #acts like a line

        text(win, "Completed:", font_24, 157, 355)
        if done:
            text(win, "Yes", font_24, 244, 355)
        else:
            text(win, "No", font_24, 241, 355)
        button(win, "", font, 222, 370, 277, 1, black,
               black)  #acts like a line

        if getName(name):
            button(
                win, "Rewrite", font_20, 195, 449, 150, 30, btn, highlight_btn,
                lambda: rewrite(win, name, timeCompleted, currentTime,
                                cellsLeft, done, table, *args))
        button(
            win, "Save", font_20, 195, 484, 150, 30, btn, highlight_btn,
            lambda: upload(win, name, timeCompleted, currentTime, cellsLeft,
                           done, table, playerID, *args))
        button(win, "Cancel", font_20, 195, 519, 150, 30, btn, highlight_btn,
               quitProgram)

        pygame.display.update()
コード例 #5
0
    def drawChooseDifficulty(self):
        chooseDifficulty = True
        print("1")
        Input = pi.TextInput()
        print("2")
        emptycells = None
        difficultyList = [
            "Easy", "Medium", "Difficult", "Extremely difficult", "Custom"
        ]
        print("3")
        while chooseDifficulty:
            print("4")
            self.window.fill(white)
            print("5")
            self.W.small_text(self.username, 1200, 25)
            print("6")
            self.W.button("Log Out", font_24, 1130, 45, 140, 35,
                          ButtonPrimaryColor, ButtonHighlightColor,
                          lambda: self.redrawWindow("Login"))
            print("7")
            self.W.button("Back", font_24, 15, 10, 140, 35, ButtonPrimaryColor,
                          ButtonHighlightColor,
                          lambda: self.redrawWindow("MainMenu"))
            print("8")
            self.W.text("Choose Difficulty", display_width / 2, 115)
            print("9")
            if self.difficulty != "Extremely difficult":
                print("10")
                self.W.button(self.difficulty, font, 490, 165, 300, 60,
                              ButtonPrimaryColor, ButtonHighlightColor,
                              lambda: self.toggleDropDown())
                print("11")
            else:
                self.W.button(self.difficulty, font_32, 490, 165, 300, 60,
                              ButtonPrimaryColor, ButtonHighlightColor,
                              lambda: self.toggleDropDown())
                print("12")
            self.window.blit(arrowDown, (757, 188))
            print("13")

            if self.difficulty == "Custom":
                print("14")
                events = pygame.event.get()
                print("15")
                for event in events:
                    if event.type == pygame.QUIT:
                        pygame.display.quit()
                        quit()
                Input.update(events)
                self.W.button("", font_32, 490, 235, 300, 60,
                              ButtonHighlightColor, ButtonHighlightColor)
                self.W.textAllignLeft("Empty cells:", 524, 284)
                self.window.blit(Input.get_surface(), (608, 246))
                emptycells = int(Input.get_text())

            if self.dropDown:
                print("16")
                for diff in range(5):
                    if diff == self.difficulty:
                        self.W.button(
                            difficultyList[diff], font_32, 490,
                            (235 + 60 * diff), 300, 60, ButtonHighlightColor,
                            ButtonHighlightColor,
                            lambda: self.toggleDropDown(difficultyList[diff]))
                    else:
                        self.W.button(
                            difficultyList[diff], font_32, 490,
                            (235 + 60 * diff), 300, 60, ButtonPrimaryColor,
                            ButtonHighlightColor,
                            lambda: self.toggleDropDown(difficultyList[diff]))
            print("17")
            self.W.button("Play", font, 490, 545, 300, 60, ButtonPrimaryColor,
                          ButtonHighlightColor, self.startGame)
            print("18")
            pygame.display.update()
            print("19")
            self.clock.tick(60)
            print("20")