Пример #1
0
    def __init__(self, app):
        size = Canvas(384, 150)
        DialogBox.__init__(self, app, size, 'Host game?')
        self._deferred = None

        font = app.screenManager.fonts.defaultTextBoxFont
        btnColour = app.theme.colours.dialogButtonColour
        highlightColour = app.theme.colours.black
        labelColour = app.theme.colours.dialogBoxTextColour
        btnFont = app.screenManager.fonts.bigMenuFont

        self.elements = [
            TextElement(app, 'No games found. Host a game?', font,
                        Location(self.Relative(0.5, 0.4), 'center'),
                        labelColour),
            TextButton(app,
                       Location(self.Relative(0.3, 0.85), 'center'),
                       'Yes',
                       btnFont,
                       btnColour,
                       highlightColour,
                       onClick=self.yesClicked),
            TextButton(app,
                       Location(self.Relative(0.7, 0.85), 'center'),
                       'No',
                       btnFont,
                       btnColour,
                       highlightColour,
                       onClick=self.noClicked),
        ]
Пример #2
0
    def __init__(self, app):
        size = Canvas(512, 384)
        DialogBox.__init__(self, app, size, 'Please authenticate')
        self._deferred = None
        self._host = None

        font = app.screenManager.fonts.defaultTextBoxFont
        btnColour = app.theme.colours.dialogButtonColour
        highlightColour = app.theme.colours.black
        errorTextColour = app.theme.colours.errorColour

        self.tabContainer = TabContainer(app,
                Region(topleft=self.Relative(0, 0),
                size=self.Relative(1, 0.75)), font,
                app.theme.colours.tabContainerColour)
        self.tabContainer.addTab(LoginTab(app))
        self.tabContainer.addTab(CreateAccountTab(app))

        self.errorText = TextElement(app, '', font,
            Location(self.Relative(0.5, 0.8), 'center'), errorTextColour)

        font = app.screenManager.fonts.bigMenuFont
        self.elements = [
            self.tabContainer,
            self.errorText,
            TextButton(app,
                Location(self.Relative(0.3, 0.9), 'center'),
                'Ok', font, btnColour, highlightColour,
                onClick=self.okClicked),
            TextButton(app,
                Location(self.Relative(0.7, 0.9), 'center'),
                'Cancel', font, btnColour, highlightColour,
                onClick=self.cancelClicked),
        ]
        self.cancelled = False
Пример #3
0
    def __init__(self, app, nick, head):
        title = 'Player settings'
        DialogBox.__init__(self, app, Canvas(400, 290), title)

        labelFont = app.screenManager.fonts.bigMenuFont
        labelColour = app.theme.colours.dialogBoxTextColour
        btnFont = app.screenManager.fonts.bigMenuFont
        btnColour = app.theme.colours.dialogButtonColour
        highlightColour = app.theme.colours.black
        inputFont = app.screenManager.fonts.defaultTextBoxFont
        inputColour = app.theme.colours.grey

        self.inputBox = InputBox(
            app,
            Region(topleft=self.Relative(0.1, 0.25),
                   bottomright=self.Relative(0.9, 0.45)),
            nick,
            font=inputFont,
            colour=inputColour,
            onClick=self.setFocus,
            onEnter=self.ok_clicked,
            onEsc=self.cancel_clicked,
        )

        self.heads = HeadSelector(
            app,
            Region(topleft=self.Relative(0.1, 0.5),
                   bottomright=self.Relative(0.9, 0.8)))
        self.heads.selected(head)

        self.elements = [
            TextElement(app, 'Nickname:', labelFont,
                        Location(self.Relative(0.1, 0.15), 'midleft'),
                        labelColour),
            self.inputBox,
            self.heads,
            TextButton(app,
                       Location(self.Relative(0.3, 0.9), 'center'),
                       'Ok',
                       btnFont,
                       btnColour,
                       highlightColour,
                       onClick=self.ok_clicked),
            TextButton(app,
                       Location(self.Relative(0.7, 0.9), 'center'),
                       'Cancel',
                       btnFont,
                       btnColour,
                       highlightColour,
                       onClick=self.cancel_clicked),
        ]

        self.setFocus(self.inputBox)
Пример #4
0
 def processEvent(self, event):
     if event.type == pygame.KEYDOWN and event.key in (pygame.K_KP_ENTER,
                                                       pygame.K_RETURN):
         self.okClicked()
         return None
     else:
         return DialogBox.processEvent(self, event)
Пример #5
0
    def __init__(self, app):
        size = Canvas(512, 384)
        DialogBox.__init__(self, app, size, 'Select arena')
        self._deferred = None
        self._games = None

        font = app.screenManager.fonts.defaultTextBoxFont
        btnColour = app.theme.colours.dialogButtonColour
        highlightColour = app.theme.colours.black
        labelColour = app.theme.colours.dialogBoxTextColour
        btnFont = app.screenManager.fonts.bigMenuFont
        listboxFont = app.screenManager.fonts.serverListFont
        listboxColour = app.theme.colours.mainMenuColour
        listboxHighlight = app.theme.colours.mainMenuHighlight

        self.gameList = ListBox(
            self.app,
            Region(topleft=self.Relative(0.05, 0.15),
                   size=self.Relative(0.9, 0.65)),
            [],
            listboxFont,
            listboxColour,
            listboxHighlight,
        )

        self.elements = [
            TextElement(app, 'Please select:', font,
                        Location(self.Relative(0.05, 0.05), 'topleft'),
                        labelColour),
            self.gameList,
            TextButton(app,
                       Location(self.Relative(0.3, 0.9), 'center'),
                       'Ok',
                       btnFont,
                       btnColour,
                       highlightColour,
                       onClick=self.okClicked),
            TextButton(app,
                       Location(self.Relative(0.7, 0.9), 'center'),
                       'Cancel',
                       btnFont,
                       btnColour,
                       highlightColour,
                       onClick=self.cancelClicked),
        ]
Пример #6
0
    def __init__(self, app, title, label, validator=None):
        DialogBox.__init__(self, app, Canvas(400, 230), title)

        labelFont = app.screenManager.fonts.bigMenuFont
        labelColour = app.theme.colours.dialogBoxTextColour
        btnFont = app.screenManager.fonts.bigMenuFont
        btnColour = app.theme.colours.dialogButtonColour
        highlightColour = app.theme.colours.black
        inputFont = app.screenManager.fonts.defaultTextBoxFont
        inputColour = app.theme.colours.grey

        self.inputBox = InputBox(app,
                                 Region(topleft=self.Relative(0.1, 0.4),
                                        bottomright=self.Relative(0.9, 0.6)),
                                 font=inputFont,
                                 colour=inputColour,
                                 onClick=self.setFocus,
                                 onEnter=self.okClicked,
                                 onEsc=self.cancelClicked,
                                 validator=validator)

        self.elements = [
            TextElement(app, label, labelFont,
                        Location(self.Relative(0.1, 0.2), 'midleft'),
                        labelColour),
            self.inputBox,
            TextButton(app,
                       Location(self.Relative(0.3, 0.9), 'center'),
                       'Ok',
                       btnFont,
                       btnColour,
                       highlightColour,
                       onClick=self.okClicked),
            TextButton(app,
                       Location(self.Relative(0.7, 0.9), 'center'),
                       'Cancel',
                       btnFont,
                       btnColour,
                       highlightColour,
                       onClick=self.cancelClicked),
        ]

        self.setFocus(self.inputBox)
Пример #7
0
 def processEvent(self, event):
     if event.type == pygame.KEYDOWN:
         if event.key in (pygame.K_KP_ENTER, pygame.K_RETURN):
             self.yesClicked()
             return None
         elif event.key == pygame.K_ESCAPE:
             self.noClicked()
             return None
     else:
         return DialogBox.processEvent(self, event)
Пример #8
0
 def show(self, nick):
     self.text.setText('Joining as %s...' % (nick, ))
     DialogBox.show(self)