Example #1
0
    def __init__(self):
        super(Footer, self).__init__(clutter.BoxLayout())

        self.set_color(clutter.Color(0, 0, 0, 0))

        layout = self.get_layout_manager()
        layout.set_vertical(True)
        layout.set_spacing(20)

        self.set_width(settings.SCREEN_WIDTH)

        self.now_playing = now_playing()

        self.now_playing_box = clutter.Box(clutter.BoxLayout())
        tmplayout = self.now_playing_box.get_layout_manager()
        tmplayout.set_vertical(False)
        tmplayout.set_spacing(20)
        self.now_playing_box.set_width(settings.SCREEN_WIDTH)
        self.next_song_box = clutter.Box(clutter.BoxLayout())
        tmplayout = self.next_song_box.get_layout_manager()
        tmplayout.set_vertical(False)
        tmplayout.set_spacing(20)
        self.next_song_box.set_width(settings.SCREEN_WIDTH)

        layout.pack(self.now_playing_box, True, False, False,
                    clutter.BOX_ALIGNMENT_CENTER, clutter.BOX_ALIGNMENT_CENTER)
        layout.pack(self.next_song_box, True, False, False,
                    clutter.BOX_ALIGNMENT_CENTER, clutter.BOX_ALIGNMENT_CENTER)
Example #2
0
    def __init__(self, width=DEFAULT_SYMBOL_SIZE):
        super(PlaySymbol, self).__init__(width=width, color='blue')

        self.box = clutter.Box(
            clutter.BinLayout(clutter.BIN_ALIGNMENT_CENTER,
                              clutter.BIN_ALIGNMENT_CENTER))
        self.play = clutter.Text('Router Ultra Bold 25', 'PLAY')
        self.play.set_color(clutter.Color(255, 255, 255, 102))
        self.box.add(self.play)
        self.add(self.box)
Example #3
0
    def __init__(self):
        super(ClutterScope, self).__init__()
        self.graticule = Graticule()
        self.add(self.graticule)
        self.set_reactive(True)

        self.traces = []

        layout = clutter.BoxLayout()
        layout.set_vertical(False)
        layout.set_use_animations(True)
        layout.set_easing_duration(100)
        layout.set_spacing(4)
        label_box = clutter.Box(layout)
        self.add(label_box)
        label_box.set_position(0, 0)
        #label_box.add_constraint(clutter.SnapConstraint(self, clutter.SNAP_EDGE_BOTTOM, clutter.SNAP_EDGE_BOTTOM, 0.))
        label_box.add_constraint(
            clutter.BindConstraint(self, clutter.BIND_WIDTH, 0.))

        # Add some traces (just for looks)
        tr = Trace()
        tr.set_position(0, -50)
        self.graticule.add(tr)
        self.traces += [tr]
        label_box.add(TraceLabel(tr))
        tr.set_name('H1:DMT-STRAIN')

        tr = Trace()
        tr.set_color(clutter.color_from_string('magenta'))
        self.graticule.add(tr)
        self.traces += [tr]
        label_box.add(TraceLabel(tr))
        tr.set_name('L1:DMT-STRAIN')

        tr = Trace()
        tr.set_color(clutter.color_from_string('yellow'))
        tr.set_position(0, 50)
        self.graticule.add(tr)
        self.traces += [tr]
        label_box.add(TraceLabel(tr))
        tr.set_name('A1:DMT-STRAIN')

        # State for event signal handlers
        self.selected_trace = self.traces[0]
        self.__last_scroll_time = 0
        self.__drag_origin = None

        # Hook up event signal handlers
        self.connect_after('button-press-event', self.button_press)
        self.connect_after('button-release-event', self.button_release)
        self.connect_after('motion-event', self.motion)
        self.connect_after('scroll-event', self.scroll)
Example #4
0
 def __init__(self):
     """
     """
     super(PlayerScoreOverlay, self).__init__(
         clutter.BinLayout(clutter.BIN_ALIGNMENT_CENTER,
                           clutter.BIN_ALIGNMENT_CENTER))
     box = clutter.Box(clutter.BoxLayout())
     layout = box.get_layout_manager()
     layout.set_vertical(True)
     self.set_color(config.square_background_color)
     self.name = Text(config.player_overlay_font, '')
     box.add(self.name)
     self.score = Text(config.player_overlay_font, '')
     box.add(self.score)
     self.add(box)
Example #5
0
    def __init__(self):
        super(FrontScreen, self).__init__(
            clutter.BinLayout(clutter.BIN_ALIGNMENT_CENTER,
                              clutter.BIN_ALIGNMENT_CENTER)
            )
        layout = self.get_layout_manager()

        self.credits = Credits()
        layout.add(self.credits,
                   clutter.BIN_ALIGNMENT_START,
                   clutter.BIN_ALIGNMENT_END)

        self.right_arrow = RightArrow()
        layout.add(self.right_arrow,
                   clutter.BIN_ALIGNMENT_END,
                   clutter.BIN_ALIGNMENT_CENTER)

        self.boxed_contents = clutter.Box(clutter.BoxLayout())
        box_layout = self.boxed_contents.get_layout_manager()
        box_layout.set_use_animations(True)
        box_layout.set_vertical(True)
        box_layout.set_spacing(100)

        self.header = LogoLarge()
        box_layout.pack(self.header, True, False, False,
                        clutter.BOX_ALIGNMENT_CENTER,
                        clutter.BOX_ALIGNMENT_CENTER)

        self.labels = (
            clutter.Text(settings.FRONT_SCREEN_FONT, 'songs'),
            clutter.Text(settings.FRONT_SCREEN_FONT, 'artists'),
            )

        self.selected = self.labels[0]

        for label in self.labels:
            label.set_color(FONT_COLOR)
            label.set_opacity(FONT_OPACITY)
            label.set_property('scale-gravity', clutter.GRAVITY_CENTER)
            box_layout.pack(label, True, False, False,
                            clutter.BOX_ALIGNMENT_CENTER,
                            clutter.BOX_ALIGNMENT_CENTER)

        layout.add(self.boxed_contents,
                   clutter.BIN_ALIGNMENT_CENTER,
                   clutter.BIN_ALIGNMENT_START)

        self.highlight(self.selected)
Example #6
0
    def __init__(self, song):
        super(SongDetailScreen, self).__init__(
            clutter.BinLayout(clutter.BIN_ALIGNMENT_CENTER,
                              clutter.BIN_ALIGNMENT_CENTER))
        # Immediately store song information
        self.song = song
        self.set_name('song detail %s' % self.song.title)
        layout = self.get_layout_manager()

        self.header = Header('Song Details')
        self.header.set_width(self.get_width())
        layout.add(self.header, clutter.BIN_ALIGNMENT_CENTER,
                   clutter.BIN_ALIGNMENT_START)

        self.left_arrow = LeftArrow()
        self.play = PlaySymbol()

        self.box = clutter.Box(clutter.BoxLayout())
        box_layout = self.box.get_layout_manager()
        box_layout.set_vertical(True)
        box_layout.set_spacing(20)
        text = clutter.Text(settings.SONG_TITLE_FONT, self.song.title)
        text.set_line_alignment(ALIGN_CENTER)
        text.set_line_wrap(True)
        text.set_color(clutter.Color(230, 230, 230, 0xff))
        self.box.add(text)
        text = clutter.Text(settings.SONG_ARTIST_FONT,
                            "by %s" % self.song.artist.name)
        text.set_line_alignment(ALIGN_CENTER)
        text.set_line_wrap(True)
        text.set_color(clutter.Color(210, 210, 210, 0xff))
        self.box.add(text)
        self.box.set_width(self.get_width() - (self.left_arrow.get_width() +
                                               self.play.get_width()))

        layout.add(
            self.box,
            clutter.BIN_ALIGNMENT_CENTER,
            clutter.BIN_ALIGNMENT_CENTER,
        )

        layout.add(self.left_arrow, clutter.BIN_ALIGNMENT_START,
                   clutter.BIN_ALIGNMENT_CENTER)

        layout.add(self.play, clutter.BIN_ALIGNMENT_END,
                   clutter.BIN_ALIGNMENT_CENTER)
Example #7
0
    def __init__(self):
        """
        """
        self.stage = clutter.stage_get_default()

        if settings.FULLSCREEN:
            logging.info('Setting GUI to fullscreen.')
            self.stage.hide_cursor()
            self.stage.set_fullscreen(True)
            self.stage.set_size(settings.SCREEN_WIDTH, settings.SCREEN_HEIGHT)

        else:
            logging.info('Setting GUI to windowed mode.')
            self.stage.show_cursor()
            self.stage.set_fullscreen(False)
            self.stage.set_user_resizable(True)
            self.stage.set_size(settings.SCREEN_WIDTH * 0.5,
                                settings.SCREEN_HEIGHT * 0.5)

        self.stage.set_color(clutter.Color(0x00, 0x00, 0x00, 0xff))
        self.stage.set_title("AS220 Jukebox")

        self.stage.connect('destroy', clutter.main_quit)
        self.stage.connect('allocation-changed', self.on_allocation_changed)
        self.stage.connect('key-press-event', self.on_press)
        self.stage.connect('key-release-event', self.on_release)

        self.layout = clutter.BinLayout(clutter.BIN_ALIGNMENT_CENTER,
                                        clutter.BIN_ALIGNMENT_CENTER)
        self.container = clutter.Box(self.layout)
        self.stage.add(self.container)

        # Setup screen container
        self.screen_container = ScreenContainer()
        self.container.add(self.screen_container)
        front = FrontScreen()
        self.screen_container.add_screen(front)
        self.screen_container.active_screen = front

        self.transient_message = transient_message
        self.footer = footer
        self.layout.add(self.footer, clutter.BIN_ALIGNMENT_CENTER,
                        clutter.BIN_ALIGNMENT_END)
        self.container.add(transient_message)
Example #8
0
    def __init__(self):
        """
        """
        super(CategoryOverlay, self).__init__(clutter.BoxLayout())
        layout = self.get_layout_manager()
        layout.set_vertical(False)
        self.set_color(config.background_color)

        self.boxes = []
        for category_name in game.get_category_names():
            box = clutter.Box(
                clutter.BinLayout(clutter.BIN_ALIGNMENT_CENTER,
                                  clutter.BIN_ALIGNMENT_CENTER))
            rect = clutter.Rectangle()
            rect.set_color(config.square_background_color)
            box.add(rect)
            text = Text(config.category_overlay_font, category_name)
            box.add(text)
            self.add(box)
Example #9
0
    def __init__(self):
        super(ClueBox,
              self).__init__(clutter.FlowLayout(clutter.FLOW_VERTICAL))
        layout = self.get_layout_manager()
        layout.set_column_spacing(10)
        layout.set_row_spacing(10)
        self.set_color(config.background_color)

        # Add clue answer and question.
        clue_box = clutter.Box(clutter.BoxLayout())
        self.add(clue_box)
        clue_layout = clue_box.get_layout_manager()
        clue_layout.set_vertical(True)

        clue = game.get_selected_clue()
        text = clutter.Text(config.admin_font_header, "CLUE")
        text.set_color('white')
        clue_layout.pack(text, False, False, False,
                         clutter.BOX_ALIGNMENT_START,
                         clutter.BOX_ALIGNMENT_CENTER)
        text = clutter.Text(config.admin_font, "Answer\n%s" % clue.answer)
        text.set_color('green')
        clue_layout.pack(text, False, False, False,
                         clutter.BOX_ALIGNMENT_START,
                         clutter.BOX_ALIGNMENT_CENTER)
        text = clutter.Text(config.admin_font, "Question\n%s" % clue.question)
        text.set_color('red')
        clue_layout.pack(text, False, False, False,
                         clutter.BOX_ALIGNMENT_START,
                         clutter.BOX_ALIGNMENT_CENTER)

        # Add player buzz in information.
        buzz_box = clutter.Box(clutter.BoxLayout())
        self.add(buzz_box)
        buzz_layout = buzz_box.get_layout_manager()
        buzz_layout.set_vertical(True)
        text = clutter.Text(config.admin_font_header, 'PLAYER BUZZES')
        buzz_layout.pack(text, False, False, False,
                         clutter.BOX_ALIGNMENT_START,
                         clutter.BOX_ALIGNMENT_CENTER)
        self.players = []
        for player in game.get_players():
            text = clutter.Text(config.admin_font, "Player %s" % player.name)
            text.set_color('white')
            text.player = player
            self.players.append(text)
            buzz_layout.pack(text, False, False, False,
                             clutter.BOX_ALIGNMENT_START,
                             clutter.BOX_ALIGNMENT_CENTER)

        if game.selected_clue.is_daily_double():
            dd_box = clutter.Box(clutter.BoxLayout())
            self.add(dd_box)
            dd_layout = dd_box.get_layout_manager()
            dd_layout.set_vertical(True)
            for player in game.get_players():
                text = clutter.Text(config.admin_font,
                                    "Player %s" % player.name)
                text.set_color('white')
                text.player = player
                text.set_reactive(True)
                text.connect('button-release-event',
                             lambda actor, event: self.choose_team(actor))
                dd_box.add(text)
            text = clutter.Text(config.admin_font, 'Daily Double Wager:')
            text.set_color('white')
            dd_box.add(text)
            self.wager = clutter.Text(config.admin_font, '0')
            self.wager.set_color('white')
            self.wager.set_reactive(True)
            self.wager.set_editable(True)
            self.wager.connect(
                'text-changed',
                lambda actor: game.set_daily_double_wager(self.get_wager()))
            dd_box.add(self.wager)
            dd_layout.set_fill(self.wager, True, False)
Example #10
0
    def __init__(self):
        super(GUI, self).__init__()

        logging.info('Initializing game gui.')

        self.admin = Admin()

        self.gui_state = self.SHOW_GAME_BOARD

        # Set the stage background to grey.
        self.set_color(config.stage_background_color)

        # Connect callback listeners
        logging.info('Setting up game stage signals.')
        self.connect('destroy', clutter.main_quit)
        self.connect('key-press-event', self.on_press)
        self.connect('button-release-event', self.on_click)
        self.connect('allocation-changed', self.on_allocation_changed)

        self.board_box = clutter.Box(clutter.BoxLayout())
        board_box_layout = self.board_box.get_layout_manager()

        # Instantiate the game board which is the collection of squares to show
        # on screen.
        self.game_board = GameBoard()
        board_box_layout.pack(self.game_board, True, True, True,
                              clutter.BOX_ALIGNMENT_CENTER,
                              clutter.BOX_ALIGNMENT_CENTER)

        # Determine whether or not to display player scores.
        self.player_score_box = None
        if config.display_player_scores:
            self.player_score_box = PlayerScoreBox(game.get_players())
            self.player_score_box.set_width(0.1 * self.get_width())
            if config.player_scores_position == 'east':
                layout = self.player_score_box.get_layout_manager()
                layout.set_vertical(True)
                board_box_layout.pack(self.player_score_box, True, True, True,
                                      clutter.BOX_ALIGNMENT_CENTER,
                                      clutter.BOX_ALIGNMENT_CENTER)
            if config.player_scores_position == 'south':
                layout = self.player_score_box.get_layout_manager()
                layout.set_vertical(False)
                board_box_layout.pack(self.player_score_box, True, True, True,
                                      clutter.BOX_ALIGNMENT_CENTER,
                                      clutter.BOX_ALIGNMENT_CENTER)
            else:
                self.board_box.add(self.player_score_box)

        # Add the box with the board in it to the screen.
        self.add(self.board_box)

        # Overlay box for displaying clue information and answers
        self.clue_overlay = ClueOverlay()
        self.clue_overlay.set_size(self.get_width(), self.get_height())
        self.add(self.clue_overlay)
        self.clue_overlay.set_opacity(0)

        # Overlay box for display category information.
        self.category_overlay = CategoryOverlay()
        self.category_overlay.set_size(self.get_width(), self.get_height())

        # Overlay box for displaying which player buzzed in.
        self.player_buzz_overlay = PlayerBuzzOverlay()
        self.player_buzz_overlay.set_size(self.get_width(), self.get_height())
        self.player_buzz_overlay.set_opacity(0)
        self.add(self.player_buzz_overlay)

        # Overlay box for displaying player score.
        self.player_score_overlay = PlayerScoreOverlay()
        self.player_score_overlay.set_size(self.get_width(), self.get_height())
        self.player_score_overlay.set_opacity(0)
        self.add(self.player_score_overlay)

        # Overlay box for daily double.
        self.daily_double_overlay = DailyDoubleOverlay()
        self.daily_double_overlay.set_size(self.get_width(), self.get_height())
        self.daily_double_overlay.set_opacity(0)
        self.add(self.daily_double_overlay)

        # Overlay box for final round.
        self.final_round_overlay = FinalRoundOverlay()
        self.final_round_overlay.set_size(self.get_width(), self.get_height())
        self.final_round_overlay.set_opacity(0)
        self.add(self.final_round_overlay)

        # Overlay box for displaying all player scores.
        self.all_player_scores_overlay = AllPlayerScoresOverlay()
        self.all_player_scores_overlay.set_size(self.get_width(),
                                                self.get_height())
        self.all_player_scores_overlay.set_opacity(0)
        self.add(self.all_player_scores_overlay)

        self.flashing_scores = False

        # Set a default stage size.
        self.set_fullscreen(False)
        self.set_size(800, 600)
        self.set_user_resizable(True)

        self.show()