Exemple #1
0
 def __init__(self, app):
     super(Interface, self).__init__(app)
     backdrop = pygame.Surface(app.screenManager.scaledSize)
     backdrop.fill((128, 0, 128))
     i1 = prompt.InputBox(self.app,
                          Area((40, 40), (300, 50)),
                          'Mouse Over',
                          font=Font("KLEPTOCR.TTF", 36))
     i1.onClick.addListener(self.setFocus)
     i2 = prompt.InputBox(self.app,
                          Area((340, 140), (200, 50)),
                          'Mouse Over',
                          font=Font("KLEPTOCR.TTF", 36))
     i2.onClick.addListener(self.setFocus)
     h1 = hint.Hint(self.app, "You absolutely\nRULE!", i1,
                    Font("KLEPTOCR.TTF", 24))
     h2 = hint.Hint(self.app, "Like, amazingly so!! TROSNOTH!@!!@!", i2,
                    Font("KLEPTOCR.TTF", 24))
     h3 = hint.Hint(
         self.app,
         "A secret!\nWell done, you have found a magical land of wonder and amazement!! \nYou win absolutely nothing, but at least you have a good story to tell now.",
         pygame.Rect(500, 400, 100, 50), Font("KLEPTOCR.TTF", 24))
     self.elements = [
         elements.PictureElement(app, backdrop), i1, h1, i2, h2, h3
     ]
Exemple #2
0
    def __init__(self, app):
        Tab.__init__(self, app, 'Sign in')
        framework.TabFriendlyCompoundElement.__init__(self, app)
        font = app.screenManager.fonts.defaultTextBoxFont
        labelColour = app.theme.colours.dialogBoxTextColour
        inputColour = app.theme.colours.grey

        self.usernameField = prompt.InputBox(app,
            Region(topleft=self.Relative(0.1, 0.16),
                bottomright=self.Relative(0.9, 0.32)),
                font=font, colour=inputColour,
                validator=usernameValidator,
                onClick=self.setFocus, onTab=self.tabNext)

        self.passwordField = prompt.PasswordBox(app,
            Region(topleft=self.Relative(0.1, 0.48),
                bottomright=self.Relative(0.9, 0.64)),
                font=font, colour=inputColour,
                onClick=self.setFocus, onTab=self.tabNext)

        self.elements = [
            TextElement(app, 'Username', font,
                Location(self.Relative(0.1, 0.11), 'midleft'),
                labelColour),
            self.usernameField,
            TextElement(app, 'Password', font,
                Location(self.Relative(0.1, 0.43), 'midleft'),
                labelColour),
            self.passwordField,
        ]
        self.tabOrder = [self.usernameField, self.passwordField]
Exemple #3
0
    def __init__(self, app, textBoxText):

        super(FunBox, self).__init__(app, ScaledSize(300, 200), "Dialog!!")
        h = prompt.InputBox(app,
                            Area((10, 10), (280, 50)),
                            textBoxText,
                            font=app.screenManager.fonts.bigMenuFont)
        h.onClick.addListener(self.setFocus)
        font = ScaledFont("KLEPTOCR.TTF", 30)
        b = elements.TextButton(app, (150, 100), "Close", font, (255, 0, 0),
                                (20, 100, 200))
        b.onClick.addListener(lambda sender: self.close())
        self.elements = [h, b]
        self.setColours(titleColour=(255, 0, 0),
                        backgroundColour=(255, 128, 0))
Exemple #4
0
 def __init__(self, app, tabContainer):
     super(NewTab, self).__init__(app, "New Tab")
     h = prompt.InputBox(app, Area(AttachedPoint((10,10), tabContainer._getTabRect), ScaledSize(400,100)), "Press Enter", font = app.screenManager.fonts.bigMenuFont)
     h.onEnter.addListener(lambda sender:self.app.screenManager.setScreenProperties((1024,768), 0, "Testing"))
     h.onClick.addListener(self.setFocus)
     self.elements = [h]
Exemple #5
0
    def __init__(self, app, controller, world):
        super(JoinGameDialog, self).__init__(app, ScaledSize(512, 314),
                                             'Join Game')
        self.result = None
        self.controller = controller
        self.selectedTeam = None

        fonts = self.app.screenManager.fonts
        self.nickBox = prompt.InputBox(
            self.app,
            Area(DialogBoxAttachedPoint(self, ScaledSize(0, 40), 'midtop'),
                 ScaledSize(200, 60), 'midtop'),
            '',
            font=fonts.menuFont,
            maxLength=30,
        )
        self.nickBox.onClick.addListener(self.setFocus)
        self.nickBox.onTab.addListener(lambda sender: self.clearFocus())
        name = app.identitySettings.nick
        if name is not None:
            self.nickBox.setValue(name)

        colours = app.theme.colours
        self.cantJoinYet = elements.TextElement(
            self.app,
            '',
            fonts.ingameMenuFont,
            ScaledLocation(256, 115, 'center'),
            colours.cannotJoinColour,
        )

        teamA = world.teams[0]
        teamB = world.teams[1]

        self.elements = [
            elements.TextElement(
                self.app,
                'Please enter your nick:',
                fonts.smallMenuFont,
                Location(
                    DialogBoxAttachedPoint(self, ScaledSize(0, 10), 'midtop'),
                    'midtop'),
                colours.black,
            ), self.nickBox, self.cantJoinYet,
            elements.TextElement(
                self.app,
                'Select team:',
                fonts.smallMenuFont,
                Location(
                    DialogBoxAttachedPoint(self, ScaledSize(0, 130), 'midtop'),
                    'midtop'),
                colours.black,
            ),
            elements.TextButton(self.app,
                                Location(
                                    DialogBoxAttachedPoint(
                                        self, ScaledSize(-25, 160), 'midtop'),
                                    'topright'),
                                str(teamA),
                                fonts.menuFont,
                                colours.team1msg,
                                colours.white,
                                onClick=lambda obj: self.joinTeam(teamA)),
            elements.TextButton(self.app,
                                Location(
                                    DialogBoxAttachedPoint(
                                        self, ScaledSize(25, 160), 'midtop'),
                                    'topleft'),
                                str(teamB),
                                fonts.menuFont,
                                colours.team2msg,
                                colours.white,
                                onClick=lambda obj: self.joinTeam(teamB)),
            elements.TextButton(self.app,
                                Location(
                                    DialogBoxAttachedPoint(
                                        self, ScaledSize(-25, 210), 'midtop'),
                                    'topright'),
                                'Automatic',
                                fonts.menuFont,
                                colours.inGameButtonColour,
                                colours.white,
                                onClick=lambda obj: self.joinTeam()),
            elements.TextButton(self.app,
                                Location(
                                    DialogBoxAttachedPoint(
                                        self, ScaledSize(25, 210), 'midtop'),
                                    'topleft'),
                                'Spectator',
                                fonts.menuFont,
                                colours.inGameButtonColour,
                                colours.white,
                                onClick=lambda obj: self.spectate()),
            elements.TextButton(self.app,
                                Location(
                                    DialogBoxAttachedPoint(
                                        self, ScaledSize(0, -10), 'midbottom'),
                                    'midbottom'),
                                'Cancel',
                                fonts.menuFont,
                                colours.inGameButtonColour,
                                colours.white,
                                onClick=self.cancel)
        ]
        self.setColours(colours.joinGameBorderColour,
                        colours.joinGameTitleColour,
                        colours.joinGameBackgroundColour)
        self.setFocus(self.nickBox)
Exemple #6
0
    def __init__(self, app, onClose=None):
        super(DisplaySettingsTab, self).__init__(app, 'Display')

        self.onClose = Event()
        if onClose is not None:
            self.onClose.addListener(onClose)

        font = self.app.screenManager.fonts.bigMenuFont
        smallNoteFont = self.app.screenManager.fonts.smallNoteFont

        colour = self.app.theme.colours.headingColour

        def mkText(text, x, y, textFont=font, anchor='topright'):
            return TextElement(self.app, text, textFont,
                               ScaledLocation(x, y, anchor), colour)

        self.text = [
            mkText('X', 640, 280),
            mkText('Screen resolution', 430, 280),
            mkText('Fullscreen mode', 430, 360),
            mkText('Graphics detail', 430, 440),
            mkText('low', 460, 475, textFont=smallNoteFont, anchor='midtop'),
            mkText('high', 845, 475, textFont=smallNoteFont, anchor='midtop'),
            mkText('Show timings', 430, 525),
        ]

        self.invalidInputText = TextElement(self.app, '', font,
                                            ScaledLocation(512, 230, 'midtop'),
                                            (192, 0, 0))

        self.widthInput = prompt.InputBox(self.app,
                                          ScaledArea(460, 265, 150, 60),
                                          initValue=str(
                                              self.app.screenManager.size[0]),
                                          font=font,
                                          maxLength=4,
                                          validator=prompt.intValidator)

        self.widthInput.onEnter.addListener(lambda sender: self.saveSettings())
        self.widthInput.onClick.addListener(self.setFocus)
        self.widthInput.onTab.addListener(self.tabNext)

        self.heightInput = prompt.InputBox(self.app,
                                           ScaledArea(652, 265, 150, 60),
                                           initValue=str(
                                               self.app.screenManager.size[1]),
                                           font=font,
                                           maxLength=4,
                                           validator=prompt.intValidator)

        self.heightInput.onEnter.addListener(
            lambda sender: self.saveSettings())
        self.heightInput.onClick.addListener(self.setFocus)
        self.heightInput.onTab.addListener(self.tabNext)

        self.tabOrder = [self.widthInput, self.heightInput]

        self.fullscreenBox = CheckBox(
            self.app,
            ScaledLocation(460, 365),
            text='',
            font=font,
            colour=(192, 192, 192),
            initValue=self.app.screenManager.isFullScreen(),
        )
        self.fullscreenBox.onValueChanged.addListener(self.fullscreenChanged)

        displaySettings = app.displaySettings

        self.detailSlider = Slider(
            self.app,
            ScaledArea(460, 430, 390, 40),
            bounds=(0, len(displaySettings.DETAIL_LEVELS) - 1),
            snap=True)
        self.detailSlider.setVal(
            displaySettings.DETAIL_LEVELS.index(displaySettings.detailLevel))
        self.detailSlider.onValueChanged.addListener(self.detailChanged)

        self.showTimingsBox = CheckBox(
            self.app,
            ScaledLocation(460, 530),
            text='',
            font=font,
            colour=(192, 192, 192),
            initValue=displaySettings.showTimings,
        )

        self.input = [
            self.widthInput, self.heightInput, self.widthInput,
            self.fullscreenBox, self.detailSlider, self.showTimingsBox
        ]

        self.elements = self.text + self.input + [
            self.invalidInputText,
            button(app,
                   'save',
                   self.saveSettings, (-100, -75),
                   'midbottom',
                   secondColour=app.theme.colours.white),
            button(app,
                   'cancel',
                   self.cancelMenu, (100, -75),
                   'midbottom',
                   secondColour=app.theme.colours.white),
        ]
        self.setFocus(self.widthInput)