Ejemplo n.º 1
0
class LcarsButton(LcarsWidget):
    """Button - either rounded or rectangular if rectSize is spcified"""

    def __init__(self, colour, pos, text, handler=None, rectSize=None):
        if rectSize == None:
            image = pygame.image.load("assets/button.png").convert_alpha()
            size = (image.get_rect().width, image.get_rect().height)
        else:
            size = rectSize
            image = pygame.Surface(rectSize).convert_alpha()
            image.fill(colour)

        self.colour = colour
        self.image = image
        font = Font("assets/swiss911.ttf", 19)
        textImage = font.render(text, False, colours.BLACK)
        image.blit(textImage, 
                (image.get_rect().width - textImage.get_rect().width - 10,
                    image.get_rect().height - textImage.get_rect().height - 5))
    
        LcarsWidget.__init__(self, colour, pos, size, handler)
        self.applyColour(colour)
        self.highlighted = False
        self.beep = Sound("assets/audio/panel/202.wav")

    def handleEvent(self, event, clock):
        if (event.type == MOUSEBUTTONDOWN and self.rect.collidepoint(event.pos)):
            self.applyColour(colours.WHITE)
            self.highlighted = True
            self.beep.play()

        if (event.type == MOUSEBUTTONUP and self.highlighted):
            self.applyColour(self.colour)
           
        return LcarsWidget.handleEvent(self, event, clock)
Ejemplo n.º 2
0
class LcarsText(LcarsWidget):
    """Text that can be placed anywhere"""
    def __init__(
        self,
        colour,
        pos,
        message,
        textSize=None,
        background=None,
        handler=None,
        fontFace=None
    ):  #textSize=.75 & fontFace="assets/OpenSansCondensed-Light.ttf"):
        self.colour = colour
        self.currcolour = colour
        self.background = background
        self.togglevalue = False
        if textSize == None and fontFace == None:
            self.font = _defaulttextfont
        else:
            if textSize == None:
                textSize = .75
            if fontFace == None:
                fontFace = "assets/OpenSansCondensed-Light.ttf"
            self.font = Font(fontFace, int(50.0 * textSize))
        self.renderText(message)
        if (pos[1] < 0):
            pos = (pos[0], (config.RESOLUTION[0] / 2) -
                   self.image.get_rect().width / 2)

        LcarsWidget.__init__(self, colour, pos, None, handler)
        self.beep = Sound("assets/audio/panel/202.wav")

    def renderText(self, message):
        if (self.background == None):
            self.image = self.font.render(message, True, self.colour)
        else:
            self.image = self.font.render(message, True, self.colour,
                                          self.background)

    def setText(self, newText):
        self.renderText(newText)

    def changeColour(self, newColour):
        if self.currcolour != newColour:
            self.applyColour(newColour, self.currcolour)
            self.currcolour = newColour

    def handleEvent(self, event, clock):
        if (event.type == MOUSEBUTTONDOWN and self.rect.collidepoint(event.pos)
                and self.visible == True):
            self.beep.play()

        if (event.type == MOUSEBUTTONUP and self.visible == True):
            self.togglevalue = not self.togglevalue

        return LcarsWidget.handleEvent(self, event, clock)
Ejemplo n.º 3
0
class SideButton(GeneralWidget):
    """Button - either rounded or rectangular if rectSize is spcified"""
    def __init__(self,
                 colour,
                 pos,
                 text,
                 handler=None,
                 rectSize=None,
                 icon=None):
        if rectSize == None:
            image = pygame.image.load(
                "assets/button_modern.png").convert_alpha()
            size = (image.get_rect().width, image.get_rect().height)
        else:
            size = rectSize
            image = pygame.Surface(rectSize).convert_alpha()
            image.fill(colours.TRANSPARENT)

        #self.colour = colour
        #self.image = image
        #self.font = Font("assets/swiss911.ttf", 18)
        #textImage = self.font.render(text, False, colours.BLACK)
        #image = image.blit(textImage,
        #        (image.get_rect().width - textImage.get_rect().width - 10,
        #            image.get_rect().height - textImage.get_rect().height - 5))

        self.colour = colours.TRANSPARENT
        self.image = image
        self.font = Font("assets/YukonTech.ttf", 20)
        textImage = self.font.render(text, False, colours.BLUEDARK)
        image = image.blit(
            textImage,
            (image.get_rect().width - textImage.get_rect().width - 4,
             image.get_rect().height - textImage.get_rect().height - 5))

        GeneralWidget.__init__(self, colour, pos, size, handler)
        self.highlighted = False
        self.beep = Sound("assets/audio/panel/202.wav")

    def handleEvent(self, event, clock):
        #image2 = pygame.image.load("assets/reset_small.png")
        if (event.type == MOUSEBUTTONDOWN and self.rect.collidepoint(event.pos)
                and self.visible == True):
            self.applyColour(colours.WHITE)
            self.highlighted = True
            self.beep.play()

        if (event.type == MOUSEBUTTONUP and self.highlighted
                and self.visible == True):
            self.applyColour(self.colour)

        return GeneralWidget.handleEvent(self, event, clock)
Ejemplo n.º 4
0
class PowerButton(PowerWidget):
    """Button - either rounded or rectangular if rectSize is spcified"""
    def __init__(self,
                 colour,
                 pos,
                 text,
                 handler=None,
                 rectSize=None,
                 icon=None):
        if rectSize == None:
            image = pygame.image.load("assets/power_small_cyantest.png")
            size = (image.get_rect().width, image.get_rect().height)
        else:
            size = rectSize
            image = pygame.Surface(rectSize).convert_alpha()
            image.fill(colour)

        self.colour = colour
        self.image = image.convert_alpha()
        #font = Font("assets/swiss911.ttf", 8)
        #textImage = font.render(text, False, colours.BLACK)
        #image.blit(textImage,
        #        (image.get_rect().width - textImage.get_rect().width - 10,
        #            image.get_rect().height - textImage.get_rect().height - 5))
        #if not icon==None:
        #    image.blit(icon, (10,10))

        PowerWidget.__init__(self, colour, pos, size, handler)
        #self.applyColour(colour)
        self.highlighted = False
        self.beep = Sound("assets/audio/panel/202.wav")

    def handleEvent(self, event, clock):
        image2 = pygame.image.load("assets/power_small.png")
        if (event.type == MOUSEBUTTONDOWN and self.rect.collidepoint(event.pos)
                and self.visible == True):
            #self.applyColour(colours.WHITE)
            self.highlighted = True
            self.beep.play()
            self.image = image2.convert_alpha()
            #size = (image.get_rect().width, image.get_rect().height)

        #self.colour = colour

        image = pygame.image.load("assets/power_small_cyantest.png")
        if (event.type == MOUSEBUTTONUP and self.highlighted
                and self.visible == True):
            self.image = image.convert_alpha()

        return PowerWidget.handleEvent(self, event, clock)
Ejemplo n.º 5
0
class ModernButton(LcarsWidget):
    def __init__(self,
                 colour,
                 pos,
                 text,
                 handler=None,
                 rectSize=None,
                 icon=None):
        if rectSize == None:
            image = pygame.image.load(
                "assets/button_modern.png").convert_alpha()
            size = (image.get_rect().width, image.get_rect().height)
        else:
            size = rectSize
            image = pygame.Surface(rectSize)
            image.fill(colour)
            #image=image.convert_alpha()

        self.colour = colours.TRANSPARENT
        self.image = image
        self.font = Font("assets/YukonTech.ttf", 20)
        textImage = self.font.render(text, False, colours.BLUEDARK)
        image = image.blit(
            textImage,
            (image.get_rect().width - textImage.get_rect().width - 4,
             image.get_rect().height - textImage.get_rect().height - 5))

        LcarsWidget.__init__(self, colour, pos, size, handler)
        self.applyColour(colour)
        self.highlighted = False
        self.beep = Sound("assets/audio/panel/202.wav")

    def handleEvent(self, event, clock):
        image2 = pygame.image.load("assets/button_modern_down.png")
        if (event.type == MOUSEBUTTONDOWN and self.rect.collidepoint(event.pos)
                and self.visible == True):
            self.highlighted = True
            self.beep.play()
            self.image = image2.convert_alpha()

        image = pygame.image.load("assets/button_modern.png")
        if (event.type == MOUSEBUTTONUP and self.highlighted
                and self.visible == True):
            self.image = image.convert_alpha()

        return LcarsWidget.handleEvent(self, event, clock)
Ejemplo n.º 6
0
class ResetButton(ResetWidget):
    """Button - either rounded or rectangular if rectSize is spcified"""
    def __init__(self,
                 colour,
                 pos,
                 text,
                 handler=None,
                 rectSize=None,
                 icon=None):
        if rectSize == None:
            image = pygame.image.load(
                "assets/reset_small_cyantest.png").convert_alpha()
            size = (image.get_rect().width, image.get_rect().height)
        else:
            size = rectSize
            image = pygame.Surface(rectSize).convert_alpha()
            image.fill(colour)

        self.colour = colour
        self.image = image

        PowerWidget.__init__(self, colour, pos, size, handler)
        self.highlighted = False
        self.beep = Sound("assets/audio/panel/202.wav")

    def handleEvent(self, event, clock):
        image2 = pygame.image.load("assets/reset_small.png")
        if (event.type == MOUSEBUTTONDOWN and self.rect.collidepoint(event.pos)
                and self.visible == True):
            self.highlighted = True
            self.beep.play()
            self.image = image2.convert_alpha()

        image = pygame.image.load("assets/reset_small_cyantest.png")
        if (event.type == MOUSEBUTTONUP and self.highlighted
                and self.visible == True):
            self.image = image.convert_alpha()

        return PowerWidget.handleEvent(self, event, clock)
Ejemplo n.º 7
0
class ScreenAuthorize(LcarsScreen):

    def setup(self, all_sprites):
        all_sprites.add(LcarsBackgroundImage("assets/lcars_screen_2.png"),
                        layer=0)

        all_sprites.add(LcarsGifImage("assets/gadgets/stlogorotating.gif", (103, 369), 50), 
                        layer=0)        

        all_sprites.add(LcarsText(colours.ORANGE, (270, -1), "AUTHORIZATION REQUIRED", 2),
                        layer=0)

        all_sprites.add(LcarsText(colours.BLUE, (330, -1), "ONLY AUTHORIZED PERSONNEL MAY ACCESS THIS TERMINAL", 1.5),
                        layer=1)

        all_sprites.add(LcarsText(colours.BLUE, (360, -1), "TOUCH TERMINAL TO PROCEED", 1.5),
                        layer=1)
        
        #all_sprites.add(LcarsText(colours.BLUE, (390, -1), "FAILED ATTEMPTS WILL BE REPORTED", 1.5),layer=1)


        all_sprites.add(LcarsButton(colours.GREY_BLUE, (320, 130), "1", self.num_1), layer=2)
        all_sprites.add(LcarsButton(colours.GREY_BLUE, (370, 130), "2", self.num_2), layer=2)
        all_sprites.add(LcarsButton(colours.GREY_BLUE, (320, 270), "3", self.num_3), layer=2)
        all_sprites.add(LcarsButton(colours.GREY_BLUE, (370, 270), "4", self.num_4), layer=2)
        all_sprites.add(LcarsButton(colours.GREY_BLUE, (320, 410), "5", self.num_5), layer=2)
        all_sprites.add(LcarsButton(colours.GREY_BLUE, (370, 410), "6", self.num_6), layer=2)
        all_sprites.add(LcarsButton(colours.GREY_BLUE, (320, 550), "7", self.num_7), layer=2)
        all_sprites.add(LcarsButton(colours.GREY_BLUE, (370, 550), "8", self.num_8), layer=2)

        if config.DEV_MODE:
            all_sprites.add(LcarsButton(colours.GREY_BLUE, (0, 770), "X", self.exitHandler, (30, 30)), layer=2)
        
        self.layer1 = all_sprites.get_sprites_from_layer(1)
        self.layer2 = all_sprites.get_sprites_from_layer(2)

        # sounds
        Sound("assets/audio/panel/215.wav").play()
        self.sound_granted = Sound("assets/audio/accessing.wav")
        self.sound_beep1 = Sound("assets/audio/panel/201.wav")
        self.sound_denied = Sound("assets/audio/access_denied.wav")
        self.sound_deny1 = Sound("assets/audio/deny_1.wav")
        self.sound_deny2 = Sound("assets/audio/deny_2.wav")

        ############
        # SET PIN CODE WITH THIS VARIABLE
        ############
        self.pin = 1234
        ############
        self.reset()

    def reset(self):
        # Variables for PIN code verification
        self.correct = 0
        self.pin_i = 0
        self.granted = False
        for sprite in self.layer1: sprite.visible = True
        for sprite in self.layer2: sprite.visible = False

    def handleEvents(self, event, fpsClock):
        if event.type == pygame.MOUSEBUTTONDOWN:
            # Play sound
            self.sound_beep1.play()

        if event.type == pygame.MOUSEBUTTONUP:
            if (not self.layer2[0].visible):
                for sprite in self.layer1: sprite.visible = False
                for sprite in self.layer2: sprite.visible = True
                Sound("assets/audio/enter_authorization_code.wav").play()
            elif (self.pin_i == len(str(self.pin))):
                # Ran out of button presses
                if (self.correct == 4):
                    self.sound_granted.play()
                    from screens.main import ScreenMain
                    self.loadScreen(ScreenMain())
                else:
                    self.sound_deny2.play()
                    self.sound_denied.play()
                    self.reset()

        return False

    def num_1(self, item, event, clock):
        if str(self.pin)[self.pin_i] == '1':
            self.correct += 1

        self.pin_i += 1

    def num_2(self, item, event, clock):
        if str(self.pin)[self.pin_i] == '2':
            self.correct += 1

        self.pin_i += 1

    def num_3(self, item, event, clock):
        if str(self.pin)[self.pin_i] == '3':
            self.correct += 1

        self.pin_i += 1

    def num_4(self, item, event, clock):
        if str(self.pin)[self.pin_i] == '4':
            self.correct += 1

        self.pin_i += 1

    def num_5(self, item, event, clock):
        if str(self.pin)[self.pin_i] == '5':
            self.correct += 1

        self.pin_i += 1

    def num_6(self, item, event, clock):
        if str(self.pin)[self.pin_i] == '6':
            self.correct += 1

        self.pin_i += 1

    def num_7(self, item, event, clock):
        if str(self.pin)[self.pin_i] == '7':
            self.correct += 1

        self.pin_i += 1

    def num_8(self, item, event, clock):
        if str(self.pin)[self.pin_i] == '8':
            self.correct += 1

        self.pin_i += 1

    def exitHandler(self, item, event, clock):
        sys.exit()
Ejemplo n.º 8
0
class TestScreen(LcarsScreen):

    all_sprites = []

    def convertFloatToPoints(self, x=float, y=float):

        screenWidth = pygame.display.get_surface().get_width()
        screenHeight = pygame.display.get_surface().get_height()

        return (int(x * screenWidth), int(y * screenHeight))

    def yPercToPoints(self, y):

        screenHeight = pygame.display.get_surface().get_height()
        return int(y * screenHeight)

    def xPercToPoints(self, x):

        screenWidth = pygame.display.get_surface().get_width()
        return int(x * screenWidth)

    def convertScreenHeightPointsToFloat(self, y):
        screenHeight = pygame.display.get_surface().get_height()
        return y / screenHeight

    def convertScreenWidthPointsToFloat(self, x):
        screenWidth = pygame.display.get_surface().get_width()
        return x / screenWidth

    def setup(self, all_sprites):

        if config.DEV_MODE:
            all_sprites.add(LcarsButton(colours.GREY_BLUE, (0, 770), "X",
                                        self.exitHandler, (30, 30)),
                            layer=2)

        self.layer1 = all_sprites.get_sprites_from_layer(1)
        self.layer2 = all_sprites.get_sprites_from_layer(2)

        self.all_sprites = all_sprites

        # Uncomment for fullscreen
        #DISPLAYSURF = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)

        # For some reason, coordinates are passed in as y,x

        pad = 5
        hpad = 10

        leftStackWidth = 0.1345
        screenWidth = pygame.display.get_surface().get_width()
        screenHeight = pygame.display.get_surface().get_height()

        # Elbow
        topLeftElbow = LcarsElbow(colours.PEACH, 0, (-40, hpad - 1),
                                  self.convertFloatToPoints(x=0.3,
                                                            y=0.15))  #0.225
        all_sprites.add(topLeftElbow, layer=1)

        # Second elbow
        secondElbow = LcarsElbow(colours.PEACH, 1,
                                 (topLeftElbow.nextObjCoordY(pad), hpad - 1),
                                 self.convertFloatToPoints(x=0.3,
                                                           y=0.15))  #0.225
        all_sprites.add(secondElbow, layer=1)

        # First Horizontal Bar
        h1 = LcarsHStrip(
            colours.PEACH,
            (self.yPercToPoints(0.0595), topLeftElbow.nextObjCoordX(pad)), 60,
            self.yPercToPoints(0.035), "")
        all_sprites.add(h1, layer=1)

        h2 = LcarsHStrip(colours.ORANGE,
                         (self.yPercToPoints(0.0595), h1.nextObjCoordX(pad)),
                         120, self.yPercToPoints(0.035), "")
        all_sprites.add(h2, layer=1)

        h3 = LcarsHStrip(colours.PEACH,
                         (self.yPercToPoints(0.0595), h2.nextObjCoordX(pad)),
                         20, self.yPercToPoints(0.035), "")
        all_sprites.add(h3, layer=1)

        h4 = LcarsHStrip(colours.ORANGE,
                         (self.yPercToPoints(0.0595), h3.nextObjCoordX(pad)),
                         50, self.yPercToPoints(0.035), "")
        all_sprites.add(h4, layer=1)

        h5 = LcarsHStrip(colours.PEACH,
                         (self.yPercToPoints(0.0595), h4.nextObjCoordX(pad)),
                         140, self.yPercToPoints(0.035), "")
        all_sprites.add(h5, layer=1)

        h6 = LcarsHStrip(colours.ORANGE,
                         (self.yPercToPoints(0.0595), h5.nextObjCoordX(pad)),
                         20, self.yPercToPoints(0.035), "")
        all_sprites.add(h6, layer=1)

        remainingWidth = screenWidth - h6.rect.left - h6.rect.width - (hpad *
                                                                       2)
        hlast = LcarsHStrip(
            colours.PEACH, (self.yPercToPoints(0.0595), h6.nextObjCoordX(pad)),
            remainingWidth - pad, self.yPercToPoints(0.035), "")
        all_sprites.add(hlast, layer=1)

        # Second Horizontal Bar
        h7 = LcarsHStrip(
            colours.PEACH,
            (secondElbow.rect.top + 1, secondElbow.nextObjCoordX(0)), 40,
            self.yPercToPoints(0.035), "")
        all_sprites.add(h7, layer=1)

        h8 = LcarsHStrip(colours.ORANGE, (h7.rect.top, h7.nextObjCoordX(pad)),
                         240, self.yPercToPoints(0.035), "")
        all_sprites.add(h8, layer=1)

        h9 = LcarsHStrip(colours.PEACH, (h7.rect.top, h8.nextObjCoordX(pad)),
                         30, self.yPercToPoints(0.035), "")
        all_sprites.add(h9, layer=1)

        h10 = LcarsHStrip(colours.ORANGE, (h7.rect.top, h9.nextObjCoordX(pad)),
                          90, self.yPercToPoints(0.035), "")
        all_sprites.add(h10, layer=1)

        h11 = LcarsHStrip(colours.PEACH, (h7.rect.top, h10.nextObjCoordX(pad)),
                          100, self.yPercToPoints(0.035), "")
        all_sprites.add(h11, layer=1)

        h12 = LcarsHStrip(colours.ORANGE,
                          (h7.rect.top, h11.nextObjCoordX(pad)), 75,
                          self.yPercToPoints(0.035), "")
        all_sprites.add(h12, layer=1)

        secondRemainingWidth = screenWidth - h12.rect.left - h12.rect.width - (
            hpad * 2)
        secondHLast = LcarsHStrip(colours.PEACH,
                                  (h7.rect.top, h12.nextObjCoordX(pad)),
                                  secondRemainingWidth - pad,
                                  self.yPercToPoints(0.035), "")
        all_sprites.add(secondHLast, layer=1)

        # Left Menu Stack
        l1 = LcarsBlockSmall(
            colours.ORANGE, (secondElbow.nextObjCoordY(pad), hpad), "MEDIA",
            self.convertFloatToPoints(x=leftStackWidth, y=0.10))
        l1.handler = self.musicHandler
        all_sprites.add(l1, layer=1)

        l2 = LcarsBlockSmall(
            colours.RED_BROWN, (l1.nextObjCoordY(pad), hpad), "COMMUNICATION",
            self.convertFloatToPoints(x=leftStackWidth, y=0.10))
        all_sprites.add(l2, layer=1)

        l3 = LcarsBlockSmall(
            colours.DARK_BLUE, (l2.nextObjCoordY(pad), hpad), "NAVIGATION",
            self.convertFloatToPoints(x=leftStackWidth, y=0.10))
        all_sprites.add(l3, layer=1)

        l4 = LcarsBlockSmall(
            colours.RED, (l3.nextObjCoordY(pad), hpad), "PERFORMANCE",
            self.convertFloatToPoints(x=leftStackWidth, y=0.075))
        all_sprites.add(l4, layer=1)

        l5 = LcarsBlockSmall(
            colours.BLUE, (l4.nextObjCoordY(pad), hpad), "ENGINEERING",
            self.convertFloatToPoints(x=leftStackWidth, y=0.075))
        all_sprites.add(l5, layer=1)

        # Variable height spacer
        bottomElbowHeight = 0.15
        remainingHeight = screenHeight - l5.rect.top - l5.rect.height - self.yPercToPoints(
            bottomElbowHeight) - (hpad * 2)
        bottomLeftSpacer = LcarsBlockSmall(
            colours.WHITE, (l5.nextObjCoordY(pad), hpad), "",
            self.convertFloatToPoints(
                x=leftStackWidth,
                y=self.convertScreenHeightPointsToFloat(remainingHeight)))
        all_sprites.add(bottomLeftSpacer, layer=1)

        # Bottom Left Elbow
        bottomLeftElbow = LcarsElbow(
            colours.PEACH, 0,
            (bottomLeftSpacer.nextObjCoordY(pad), l5.rect.left),
            self.convertFloatToPoints(x=0.3, y=bottomElbowHeight))  #0.225
        all_sprites.add(bottomLeftElbow, layer=1)

        # Bottom Horizontal Bar
        h13 = LcarsHStrip(
            colours.PEACH,
            (self.yPercToPoints(0.95), bottomLeftElbow.nextObjCoordX(pad)),
            self.yPercToPoints(0.1), self.yPercToPoints(0.035), "")
        all_sprites.add(h13, layer=1)

        # Variable width spacer
        bottomRightElbowWidth = 0.3
        bottomRemainingWidth = screenWidth - h13.rect.left - h13.rect.width - self.xPercToPoints(
            bottomRightElbowWidth) - (hpad * 2)
        bottomRightSpacer = LcarsBlockSmall(
            colours.WHITE, (h13.rect.top, h13.nextObjCoordX(pad)), "",
            self.convertFloatToPoints(
                x=self.convertScreenWidthPointsToFloat(bottomRemainingWidth),
                y=0.035))
        all_sprites.add(bottomRightSpacer, layer=1)

        # Bottom Right Elbow
        bottomRightElbow = LcarsElbow(
            colours.PEACH, 3,
            (bottomRightSpacer.rect.top, bottomRightSpacer.nextObjCoordX(pad)),
            self.convertFloatToPoints(x=bottomRightElbowWidth,
                                      y=bottomElbowHeight))  #0.225
        all_sprites.add(bottomRightElbow, layer=1)

        # weather = LcarsImage("assets/weather.jpg", (l1.rect.y , l1.nextObjCoordX(10)))
        # all_sprites.add(weather, layer=2)

        # b1 = LcarsHStrip(colours.PEACH, (400, hpad), 200, "")
        # all_sprites.add(b1, layer=1)

        # bottomRightElbow = LcarsElbow(colours.PEACH, 2, (250, 250))
        # all_sprites.add(bottomRightElbow, layer=1)

        # l2 = LcarsBlockMedium(colours.GREY_BLUE, (10, 10), "MEDIUM")
        # all_sprites.add(l2, layer=1)
        # l3 = LcarsBlockLarge(colours.PURPLE, (120, 10), "LARGE")
        # all_sprites.add(l3, layer=1)

        # sounds
        Sound("assets/audio/panel/215.wav").play()
        self.sound_granted = Sound("assets/audio/accessing.wav")
        self.sound_beep1 = Sound("assets/audio/panel/201.wav")
        self.sound_denied = Sound("assets/audio/access_denied.wav")
        self.sound_deny1 = Sound("assets/audio/deny_1.wav")
        self.sound_deny2 = Sound("assets/audio/deny_2.wav")

        self.reset()

    def reset(self):
        # Variables for PIN code verification
        self.correct = 0
        self.pin_i = 0
        self.granted = False
        for sprite in self.layer1:
            sprite.visible = True
        for sprite in self.layer2:
            sprite.visible = False

    def musicHandler(self, item, event, clock):
        from screens.main import ScreenMain
        self.loadScreen(ScreenMain())

    def handleEvents(self, event, fpsClock):
        if event.type == pygame.MOUSEBUTTONDOWN:
            # Play sound
            self.sound_beep1.play()

        if event.type == pygame.MOUSEBUTTONUP:
            self.sound_beep1.play()

            # l2 = LcarsBlockSmall(colours.RED_BROWN, (event.pos[1], event.pos[0]), "Hit")
            # self.all_sprites.add(l2, layer=1)

        # if event.type == pygame.MOUSEBUTTONUP:
        #     if (not self.layer2[0].visible):
        #         for sprite in self.layer1: sprite.visible = False
        #         for sprite in self.layer2: sprite.visible = True
        #         Sound("assets/audio/enter_authorization_code.wav").play()
        #     elif (self.pin_i == len(str(config.PIN))):
        #         # Ran out of button presses
        #         if (self.correct == len(config.PIN)):
        #             self.sound_granted.play()
        #             from screens.main import ScreenMain
        #             self.loadScreen(ScreenMain())
        #         else:
        #             self.sound_deny2.play()
        #             self.sound_denied.play()
        #             self.reset()

        return False

    def exitHandler(self, item, event, clock):
        sys.exit()
Ejemplo n.º 9
0
class ScreenAuthorize(LcarsScreen):
    def setup(self, all_sprites):
        all_sprites.add(LcarsBackgroundImage("assets/lcars_screen_3.png"),
                        layer=0)

        all_sprites.add(LcarsGifImage("assets/gadgets/stlogorotating2.gif",
                                      (232, 895), 50),
                        layer=0)

        all_sprites.add(LcarsText(colours.ORANGE, (608, -1),
                                  "AUTHORIZATION REQUIRED", 2),
                        layer=0)

        all_sprites.add(LcarsText(
            colours.BLUE, (743, -1),
            "ONLY AUTHORIZED PERSONNEL MAY ACCESS THIS TERMINAL", 1.5),
                        layer=1)

        all_sprites.add(LcarsText(colours.BLUE, (810, -1),
                                  "TOUCH TERMINAL TO PROCEED", 1.5),
                        layer=1)

        #all_sprites.add(LcarsText(colours.BLUE, (878, -1), "FAILED ATTEMPTS WILL BE REPORTED", 1.5), layer=1)

        all_sprites.add(LcarsButton(colours.GREY_BLUE, (740, 312), "1",
                                    self.num_1),
                        layer=2)
        all_sprites.add(LcarsButton(colours.GREY_BLUE, (843, 312), "2",
                                    self.num_2),
                        layer=2)
        all_sprites.add(LcarsButton(colours.GREY_BLUE, (740, 648), "3",
                                    self.num_3),
                        layer=2)
        all_sprites.add(LcarsButton(colours.GREY_BLUE, (843, 648), "4",
                                    self.num_4),
                        layer=2)
        all_sprites.add(LcarsButton(colours.GREY_BLUE, (740, 984), "5",
                                    self.num_5),
                        layer=2)
        all_sprites.add(LcarsButton(colours.GREY_BLUE, (843, 984), "6",
                                    self.num_6),
                        layer=2)
        all_sprites.add(LcarsButton(colours.GREY_BLUE, (740, 1320), "7",
                                    self.num_7),
                        layer=2)
        all_sprites.add(LcarsButton(colours.GREY_BLUE, (843, 1320), "8",
                                    self.num_8),
                        layer=2)

        if config.DEV_MODE:
            all_sprites.add(LcarsButton(colours.GREY_BLUE, (0, 1848), "X",
                                        self.exitHandler, (68, 72)),
                            layer=2)

        self.layer1 = all_sprites.get_sprites_from_layer(1)
        self.layer2 = all_sprites.get_sprites_from_layer(2)

        # sounds
        Sound("assets/audio/panel/215.wav").play()
        self.sound_granted = Sound("assets/audio/accessing.wav")
        self.sound_beep1 = Sound("assets/audio/panel/201.wav")
        self.sound_denied = Sound("assets/audio/access_denied.wav")
        self.sound_deny1 = Sound("assets/audio/deny_1.wav")
        self.sound_deny2 = Sound("assets/audio/deny_2.wav")

        ############
        # SET PIN CODE WITH THIS VARIABLE
        ############
        self.pin = 1234
        ############
        self.reset()

    def reset(self):
        # Variables for PIN code verification
        self.correct = 0
        self.pin_i = 0
        self.granted = False
        for sprite in self.layer1:
            sprite.visible = True
        for sprite in self.layer2:
            sprite.visible = False

    def handleEvents(self, event, fpsClock):
        if event.type == pygame.MOUSEBUTTONDOWN:
            # Play sound
            self.sound_beep1.play()

        if event.type == pygame.MOUSEBUTTONUP:
            if (not self.layer2[0].visible):
                for sprite in self.layer1:
                    sprite.visible = False
                for sprite in self.layer2:
                    sprite.visible = True
                Sound("assets/audio/enter_authorization_code.wav").play()
            elif (self.pin_i == len(str(self.pin))):
                # Ran out of button presses
                if (self.correct == 4):
                    self.sound_granted.play()
                    from screens.base import ScreenBase
                    self.loadScreen(ScreenBase())
                else:
                    self.sound_deny2.play()
                    self.sound_denied.play()
                    self.reset()

        return False

    def num_1(self, item, event, clock):
        if str(self.pin)[self.pin_i] == '1':
            self.correct += 1

        self.pin_i += 1

    def num_2(self, item, event, clock):
        if str(self.pin)[self.pin_i] == '2':
            self.correct += 1

        self.pin_i += 1

    def num_3(self, item, event, clock):
        if str(self.pin)[self.pin_i] == '3':
            self.correct += 1

        self.pin_i += 1

    def num_4(self, item, event, clock):
        if str(self.pin)[self.pin_i] == '4':
            self.correct += 1

        self.pin_i += 1

    def num_5(self, item, event, clock):
        if str(self.pin)[self.pin_i] == '5':
            self.correct += 1

        self.pin_i += 1

    def num_6(self, item, event, clock):
        if str(self.pin)[self.pin_i] == '6':
            self.correct += 1

        self.pin_i += 1

    def num_7(self, item, event, clock):
        if str(self.pin)[self.pin_i] == '7':
            self.correct += 1

        self.pin_i += 1

    def num_8(self, item, event, clock):
        if str(self.pin)[self.pin_i] == '8':
            self.correct += 1

        self.pin_i += 1

    def exitHandler(self, item, event, clock):
        sys.exit()
Ejemplo n.º 10
0
class ScreenAuthorize(LcarsScreen):

    def setup(self, all_sprites):
        all_sprites.add(LcarsBackgroundImage("assets/lcars_screen_2.png"),
                        layer=0)

        all_sprites.add(LcarsGifImage("assets/gadgets/stlogorotating.gif", (103, 369), 50), 
                        layer=0)        

        all_sprites.add(LcarsText(colours.ORANGE, (270, -1), "AUTHORIZATION REQUIRED", 2),
                        layer=0)

        all_sprites.add(LcarsText(colours.BLUE, (330, -1), "ONLY AUTHORIZED PERSONNEL MAY ACCESS THIS TERMINAL", 1.5),
                        layer=1)

        all_sprites.add(LcarsText(colours.BLUE, (360, -1), "TOUCH TERMINAL TO PROCEED", 1.5),
                        layer=1)
        
        #all_sprites.add(LcarsText(colours.BLUE, (390, -1), "FAILED ATTEMPTS WILL BE REPORTED", 1.5),layer=1)


        all_sprites.add(LcarsButton(colours.GREY_BLUE, (320, 60), "1", self.num_1), layer=2)
        all_sprites.add(LcarsButton(colours.GREY_BLUE, (370, 60), "2", self.num_2), layer=2)
        all_sprites.add(LcarsButton(colours.GREY_BLUE, (320, 200), "3", self.num_3), layer=2)
        all_sprites.add(LcarsButton(colours.GREY_BLUE, (370, 200), "4", self.num_4), layer=2)
        all_sprites.add(LcarsButton(colours.GREY_BLUE, (320, 340), "5", self.num_5), layer=2)
        all_sprites.add(LcarsButton(colours.GREY_BLUE, (370, 340), "6", self.num_6), layer=2)
        all_sprites.add(LcarsButton(colours.GREY_BLUE, (320, 480), "7", self.num_7), layer=2)
        all_sprites.add(LcarsButton(colours.GREY_BLUE, (370, 480), "8", self.num_8), layer=2)
        all_sprites.add(LcarsButton(colours.GREY_BLUE, (320, 610), "9", self.num_9), layer=2)
        all_sprites.add(LcarsButton(colours.GREY_BLUE, (370, 610), "0", self.num_0), layer=2)

        if config.DEV_MODE:
            all_sprites.add(LcarsButton(colours.GREY_BLUE, (0, 770), "X", self.exitHandler, (30, 30)), layer=2)
        
        self.layer1 = all_sprites.get_sprites_from_layer(1)
        self.layer2 = all_sprites.get_sprites_from_layer(2)

        # sounds
        Sound("assets/audio/panel/215.wav").play()
        self.sound_granted = Sound("assets/audio/accessing.wav")
        self.sound_beep1 = Sound("assets/audio/panel/201.wav")
        self.sound_denied = Sound("assets/audio/access_denied.wav")
        self.sound_deny1 = Sound("assets/audio/deny_1.wav")
        self.sound_deny2 = Sound("assets/audio/deny_2.wav")

        self.reset()

    def reset(self):
        # Variables for PIN code verification
        self.correct = 0
        self.pin_i = 0
        self.granted = False
        for sprite in self.layer1: sprite.visible = True
        for sprite in self.layer2: sprite.visible = False

    def update(self, screenSurface, fpsClock):
        if (UserInterface.lastEventTime < datetime.now().timestamp()):
            self.callScreen(ScreenSaver())


    def handleEvents(self, event, fpsClock):
        
        #UserInterface.lastEventTime = datetime.now().timestamp() + config.SCREENSAVER_TIMEOUT_SECONDS
        
        if event.type == pygame.MOUSEBUTTONDOWN:
            # Play sound
            self.sound_beep1.play()

        if event.type == pygame.MOUSEBUTTONUP:
            if (not self.layer2[0].visible):
                for sprite in self.layer1: sprite.visible = False
                for sprite in self.layer2: sprite.visible = True
                Sound("assets/audio/enter_authorization_code.wav").play()
            elif (self.pin_i == len(str(config.PIN))):
                # Ran out of button presses
                if (self.correct == len(config.PIN)):
                    self.sound_granted.play()
                    #from screens.main import ScreenMain
                    #self.loadScreen(ScreenMain())
                    UserInterface.Authorised = True
                    self.returnScreen()
                else:
                    self.sound_deny2.play()
                    self.sound_denied.play()
                    self.reset()

        return False

    def num_1(self, item, event, clock):
        if str(config.PIN)[self.pin_i] == '1':
            self.correct += 1

        self.pin_i += 1

    def num_2(self, item, event, clock):
        if str(config.PIN)[self.pin_i] == '2':
            self.correct += 1

        self.pin_i += 1

    def num_3(self, item, event, clock):
        if str(config.PIN)[self.pin_i] == '3':
            self.correct += 1

        self.pin_i += 1

    def num_4(self, item, event, clock):
        if str(config.PIN)[self.pin_i] == '4':
            self.correct += 1

        self.pin_i += 1

    def num_5(self, item, event, clock):
        if str(config.PIN)[self.pin_i] == '5':
            self.correct += 1

        self.pin_i += 1

    def num_6(self, item, event, clock):
        if str(config.PIN)[self.pin_i] == '6':
            self.correct += 1

        self.pin_i += 1

    def num_7(self, item, event, clock):
        if str(config.PIN)[self.pin_i] == '7':
            self.correct += 1

        self.pin_i += 1

    def num_8(self, item, event, clock):
        if str(config.PIN)[self.pin_i] == '8':
            self.correct += 1

        self.pin_i += 1

    def num_9(self, item, event, clock):
        if str(config.PIN)[self.pin_i] == '9':
            self.correct += 1

        self.pin_i += 1

    def num_0(self, item, event, clock):
        if str(config.PIN)[self.pin_i] == '0':
            self.correct += 1

        self.pin_i += 1

    def exitHandler(self, item, event, clock):
        sys.exit()
Ejemplo n.º 11
0
class LcarsButton(LcarsWidget):
    """Button - either rounded or rectangular if rectSize is spcified"""
    def __init__(self,
                 colour,
                 pos,
                 text,
                 handler=None,
                 rectSize=None,
                 textSize=None,
                 fontFace=None):
        if rectSize == None:
            image = _buttonimage.copy()
            #image = pygame.image.load("assets/button2.png").convert_alpha()
            size = (image.get_rect().width, image.get_rect().height)
        else:
            size = rectSize
            image = pygame.Surface(rectSize).convert_alpha()
            image.fill(colour)
        self.currcolour = colour
        self.colour = colour
        self.image = image
        self.togglevalue = False
        if textSize == None and fontFace == None:
            self.font = _defaultbuttonfont
        else:
            if textSize == None:
                textSize = .75
            if fontFace == None:
                fontFace = "assets/OpenSansCondensed-Bold.ttf"
            self.font = Font(fontFace, int(50.0 * textSize))

        textImage = self.font.render(text, False, colours.BLACK)
        image.blit(textImage,
                   (image.get_rect().width - textImage.get_rect().width - 21,
                    image.get_rect().height - textImage.get_rect().height - 3))

        LcarsWidget.__init__(self, colour, pos, size, handler)
        self.applyColour(colour)
        self.highlighted = False
        self.beep = Sound("assets/audio/panel/202.wav")

    def handleEvent(self, event, clock):
        if (event.type == MOUSEBUTTONDOWN and self.rect.collidepoint(event.pos)
                and self.visible == True):
            if self.currcolour != colours.WHITE:
                self.applyColour(colours.WHITE, self.currcolour)
            self.highlighted = True
            self.beep.play()

        if (event.type == MOUSEBUTTONUP and self.highlighted
                and self.visible == True):
            self.applyColour(self.currcolour, colours.WHITE)
            self.togglevalue = not self.togglevalue

        return LcarsWidget.handleEvent(self, event, clock)

    def changeColour(self, newColour):
        if self.currcolour != newColour:
            self.applyColour(newColour, self.currcolour)
            self.currcolour = newColour

    def get_state(self):
        return self.togglevalue
Ejemplo n.º 12
0
class LcarsTextBlock(LcarsWidget):
    """Text list that can be placed anywhere"""
    def __init__(self,
                 colour,
                 pos,
                 message,
                 textSize=1.0,
                 rectSize=(100, 100),
                 background=(0, 0, 0, 0),
                 handler=None,
                 fontFace="assets/OpenSansCondensed-Light.ttf"):
        self.colour = colour
        self.currcolour = colour
        self.background = background
        self.togglevalue = False
        self.textList = []
        self.place = 0  #
        self.marker = 0  #
        self.line_spacing = 0
        self.rectSize = rectSize
        self.font = Font(fontFace, int(50.0 * textSize))
        self.item_selected = None

        if not isinstance(message, list):
            self.message = message.splitlines()
        else:
            self.message = message

        self.image = pygame.Surface(self.rectSize).convert_alpha()
        self.image.fill(background)

        self.renderText(self.message)

        if (pos[1] < 0):
            pos = (pos[0], (config.RESOLUTION[0] / 2) -
                   self.image.get_rect().width / 2)
        self.pos = pos
        LcarsWidget.__init__(self, colour, pos, rectSize, handler)
        self.beep = Sound("assets/audio/panel/202.wav")

    def renderText(self, message):
        screen_height = self.image.get_height()
        max_file_width = 120
        name_max = 64
        row = 5
        line_buffer = row
        column = 5
        count = 0
        max_count = 10
        for line in message[self.place:]:
            count += 1
            self.place += 1
            self.marker += 1
            if count >= max_count or self.place >= len(message):
                if (self.background == None):
                    ren = self.font.render(line, True, self.colour)
                else:
                    ren = self.font.render(line, True, self.colour,
                                           self.background)
                ren_rect = ren.get_rect()
                ren_rect[0] = column
                ren_rect[1] = row
                self.textList.append((ren_rect, line))
                self.image.blit(ren, ren_rect)
                break
            if (self.background == None):
                ren = self.font.render(line, True, self.colour)
            else:
                ren = self.font.render(line, True, self.colour,
                                       self.background)
            ren_rect = ren.get_rect()
            if count == 1:
                self.line_spacing = ren_rect[3]
                max_count = math.floor(
                    (screen_height - (line_buffer * 2)) / self.line_spacing)
            ren_rect[0] = column
            ren_rect[1] = row
            self.textList.append((ren_rect, line))
            self.image.blit(ren, ren_rect)
            row += self.line_spacing

    def setText(self, newText):
        self.renderText(newText)

    def changeColour(self, newColour):
        if self.currcolour != newColour:
            self.applyColour(newColour, self.currcolour)
            self.currcolour = newColour

    def handleEvent(self, event, clock):
        if (event.type == MOUSEBUTTONDOWN and self.rect.collidepoint(event.pos)
                and self.visible == True):
            cursor = (pygame.mouse.get_pos()[0] - self.pos[1],
                      pygame.mouse.get_pos()[1] - self.pos[0])
            for item in self.textList:
                if item[0].collidepoint(cursor):
                    self.item_selected = item[1]
            self.beep.play()

        if (event.type == MOUSEBUTTONUP and self.visible == True):
            pass

        return LcarsWidget.handleEvent(self, event, clock)

    def get_state(self):
        return self.item_selected
Ejemplo n.º 13
0
class UltimateButton(LcarsWidget):
    """
    
        THE ULTIMATE BUTTON DOES EVERYTHING YOU NEED
        
        ARGUMENTS:
        *Required
            -position | (x coord, y coord)
        *Optional
            -size       | (width, height)                               default is (80, 40) or size of image_set[0]
            -text       | "string"                                      default is None
            -colour_set | [colour, colour_highlighted, colour_pressed]  default is [white, grey/blue, blue]
            -image_set  | [image, image_highlighted, image_pressed]     default is [None, None, None]
            -text_colour| (r, g, b) or from colours file                default is black
            -font       | pygame.Font                                   default is MicroTech
            -handler    | event handler function                        default is None
        
       BUGS:
        -- 3 images (image set) - text disappears when clicking
        
    """

    #DEFAULTS
    imageonly = False

    #init
    def __init__(self,
                 pos,
                 text=None,
                 colour_set=[colours.WHITE, colours.GREY_BLUE, colours.BLUE],
                 image_set=[None, None, None],
                 text_colour=colours.BLACK,
                 font=None,
                 size=(80, 40),
                 handler=None):

        #Set button attributes
        #all buttons
        self.colour = colour_set[0]
        self.colour_highlighted = colour_set[1]
        self.colour_pressed = colour_set[2]
        self.size = size
        self.text_colour = text_colour
        #image buttons only
        if not image_set[0] == None:
            self.image_normal = image_set[0].convert_alpha()
            image = self.image_normal
            self.image = image
            self.size = (image.get_rect().width, image.get_rect().height)
        if not image_set[1] == None:
            self.image_highlighted = image_set[1].convert_alpha()
        if not image_set[2] == None:
            self.image_pressed = image_set[2].convert_alpha()
            self.imageonly = True
        #Create surface for non-image button
        if not self.imageonly:
            if image_set[0] == None:
                image = pygame.Surface(self.size)
                image.fill(self.colour)
                self.image = image
            #apply colour to white button
            else:
                self.image = image
                self.applyColour(self.colour)

        #Create text image if text included
        if not text == None:
            if font == None:
                self.font = Font("assets/MicroTech.ttf", 18)
            else:
                self.font = font
            textImage = self.font.render(text, False, self.text_colour)
            textrect = textImage.get_rect()
            image = image.blit(
                textImage,
                (image.get_rect().width - textImage.get_rect().width - 52,
                 image.get_rect().height - textImage.get_rect().height - 10))

        #Make widget
        LcarsWidget.__init__(self, self.colour, pos, self.size, handler)
        if image_set[2] == None:
            self.applyColour(self.colour)
        else:
            self.imageonly = True
        self.highlighted = False
        self.beep = Sound("assets/audio/panel/202.wav")

    #handle events
    def handleEvent(self, event, clock):
        if (event.type == MOUSEBUTTONDOWN and self.rect.collidepoint(event.pos)
                and self.visible == True):
            if self.imageonly:
                self.image = self.image_pressed
            else:
                self.applyColour(self.colour_pressed)
            self.highlighted = True
            self.beep.play()

        #need to add mouseover highlight functionality here

        if (event.type == MOUSEBUTTONUP and self.highlighted
                and self.visible == True):
            if self.imageonly:
                self.image = self.image_normal
            else:
                self.applyColour(self.colour)

        return LcarsWidget.handleEvent(self, event, clock)
Ejemplo n.º 14
0
class ScreenAuthorize(LcarsScreen):
    def setup(self, all_sprites):
        #self.mainscreen=mainscr
        all_sprites.add(
            LcarsBackgroundImage("assets/lcars_screen_2_modern.png"), layer=0)

        all_sprites.add(LcarsGifImage("assets/gadgets/stlogorotating.gif",
                                      (103, 369), 50),
                        layer=0)

        all_sprites.add(LcarsText(colours.BLUEMID, (270, -1),
                                  "AUTHORIZATION REQUIRED", 2),
                        layer=1)

        all_sprites.add(LcarsText(
            colours.BLUEMID, (330, -1),
            "ONLY AUTHORIZED PERSONNEL MAY ACCESS THIS TERMINAL", 1.5),
                        layer=1)

        all_sprites.add(LcarsText(colours.BLUEMID, (360, -1),
                                  "TOUCH TERMINAL TO PROCEED", 1.5),
                        layer=1)

        #all_sprites.add(LcarsText(colours.BLUE, (390, -1), "FAILED ATTEMPTS WILL BE REPORTED", 1.5),layer=1)
        button_row_1 = 230
        button_row_2 = 270
        button_row_3 = 310
        button_row_4 = 350
        button_col_1 = 210
        button_col_2 = 340
        button_col_3 = 470
        button_image = pygame.image.load("assets/buttonpad.png")
        button_image_down = pygame.image.load("assets/buttonpaddown.png")
        all_sprites.add(UltimateButton(
            (button_row_1, button_col_1),
            text="1",
            handler=self.num_1,
            image_set=[button_image, button_image, button_image_down]),
                        layer=2)
        all_sprites.add(UltimateButton(
            (button_row_1, button_col_2),
            text="2",
            handler=self.num_2,
            image_set=[button_image, button_image, button_image_down]),
                        layer=2)
        all_sprites.add(UltimateButton(
            (button_row_1, button_col_3),
            text="3",
            handler=self.num_3,
            image_set=[button_image, button_image, button_image_down]),
                        layer=2)
        all_sprites.add(UltimateButton(
            (button_row_2, button_col_1),
            text="4",
            handler=self.num_4,
            image_set=[button_image, button_image, button_image_down]),
                        layer=2)
        all_sprites.add(UltimateButton(
            (button_row_2, button_col_2),
            text="5",
            handler=self.num_5,
            image_set=[button_image, button_image, button_image_down]),
                        layer=2)
        all_sprites.add(UltimateButton(
            (button_row_2, button_col_3),
            text="6",
            handler=self.num_6,
            image_set=[button_image, button_image, button_image_down]),
                        layer=2)
        all_sprites.add(UltimateButton(
            (button_row_3, button_col_1),
            text="7",
            handler=self.num_7,
            image_set=[button_image, button_image, button_image_down]),
                        layer=2)
        all_sprites.add(UltimateButton(
            (button_row_3, button_col_2),
            text="8",
            handler=self.num_8,
            image_set=[button_image, button_image, button_image_down]),
                        layer=2)
        all_sprites.add(UltimateButton(
            (button_row_3, button_col_3),
            text="9",
            handler=self.num_3,
            image_set=[button_image, button_image, button_image_down]),
                        layer=2)
        all_sprites.add(UltimateButton(
            (button_row_4, button_col_2),
            text="0",
            handler=self.num_7,
            image_set=[button_image, button_image, button_image_down]),
                        layer=2)

        if config.DEV_MODE:
            all_sprites.add(LcarsButton(colours.GREY_BLUE, (0, 770), "X",
                                        self.exitHandler, (30, 30)),
                            layer=2)

        self.layer1 = all_sprites.get_sprites_from_layer(1)
        self.layer2 = all_sprites.get_sprites_from_layer(2)

        # sounds
        Sound("assets/audio/panel/215.wav").play()
        self.sound_granted = Sound("assets/audio/accessing.wav")
        self.sound_beep1 = Sound("assets/audio/panel/201.wav")
        self.sound_denied = Sound("assets/audio/access_denied.wav")
        self.sound_deny1 = Sound("assets/audio/deny_1.wav")
        self.sound_deny2 = Sound("assets/audio/deny_2.wav")

        ############
        # SET PIN CODE WITH THIS VARIABLE
        ############
        self.pin = 1337
        ############
        self.reset()

    def reset(self):
        # Variables for PIN code verification
        self.correct = 0
        self.pin_i = 0
        self.granted = False
        for sprite in self.layer1:
            sprite.visible = True
        for sprite in self.layer2:
            sprite.visible = False

    def handleEvents(self, event, fpsClock):
        if event.type == pygame.MOUSEBUTTONDOWN:
            # Play sound
            self.sound_beep1.play()

        if event.type == pygame.MOUSEBUTTONUP:
            if (not self.layer2[0].visible):
                for sprite in self.layer1:
                    sprite.visible = False
                for sprite in self.layer2:
                    sprite.visible = True
                Sound("assets/audio/enter_authorization_code.wav").play()
            elif (self.pin_i == len(str(self.pin))):
                # Ran out of button presses
                if (self.correct == len(str(self.pin))):
                    self.sound_granted.play()
                    from screens.main import ScreenMain
                    self.loadScreen(self.params.pop())
                else:
                    self.sound_deny2.play()
                    self.sound_denied.play()
                    self.reset()

        return False

    def num_1(self, item, event, clock):
        if str(self.pin)[self.pin_i] == '1':
            self.correct += 1

        self.pin_i += 1

    def num_2(self, item, event, clock):
        if str(self.pin)[self.pin_i] == '2':
            self.correct += 1

        self.pin_i += 1

    def num_3(self, item, event, clock):
        if str(self.pin)[self.pin_i] == '3':
            self.correct += 1

        self.pin_i += 1

    def num_4(self, item, event, clock):
        if str(self.pin)[self.pin_i] == '4':
            self.correct += 1

        self.pin_i += 1

    def num_5(self, item, event, clock):
        if str(self.pin)[self.pin_i] == '5':
            self.correct += 1

        self.pin_i += 1

    def num_6(self, item, event, clock):
        if str(self.pin)[self.pin_i] == '6':
            self.correct += 1

        self.pin_i += 1

    def num_7(self, item, event, clock):
        if str(self.pin)[self.pin_i] == '7':
            self.correct += 1

        self.pin_i += 1

    def num_8(self, item, event, clock):
        if str(self.pin)[self.pin_i] == '8':
            self.correct += 1

        self.pin_i += 1

    def exitHandler(self, item, event, clock):
        sys.exit()