Beispiel #1
0
    def __init__(self, match):
        self.match = match
        
        w, h = g_cfg.screen_dimensions
        Menu.__init__(self, w, h)

        self.ingame = Ingame(match.match_team1, match.match_team2)
        self.ingame.register(self)
        
        self.team_panels = []
        
        SPACING = 10
        TEAM_PANELS_H = 230
        
        COMMAND_PANEL_H = 50
        
        team_panel = TeamPanel(match.match_team1, (w - 3 * SPACING) / 2,
                               TEAM_PANELS_H) 
        self.add_widget(team_panel, (SPACING, SPACING))
        self.team_panels.append(team_panel)
        
        team_panel = TeamPanel(match.match_team2, (w - 3 * SPACING) / 2,
                               TEAM_PANELS_H) 
        self.add_widget(team_panel, (SPACING, self.team_panels[0].bottom + SPACING))
        self.team_panels.append(team_panel)
        
        self.match_panel = MatchPanel(self.ingame, w - 2 * SPACING,
                                      h - 2 * TEAM_PANELS_H - 5 * SPACING - COMMAND_PANEL_H)
        self.add_widget(self.match_panel, (SPACING, 2 * TEAM_PANELS_H + 3 * SPACING))
        
        self.command_panel = CommandPanel(w - 2 * SPACING, COMMAND_PANEL_H)
        self.add_widget(self.command_panel, (SPACING, h - SPACING, LEFT, DOWN))
        
        self.chalkboard_panel = ChalkboardPanel(self.ingame,
                                                (w - 3 * SPACING) / 2,
                                                2 * TEAM_PANELS_H + SPACING)
        self.add_widget(self.chalkboard_panel, (w - SPACING, SPACING, RIGHT, UP))
        
        cursor = Cursor(DefaultCursorTheme(border=1, horizontal_offset=0,
                                           vertical_offset=0))
        cursor.bind(self)
        
        self.speed = None
        self.command_panel.speed_labels[2].activate()
Beispiel #2
0
class MatchMenu(Menu, Listener):
    
    def __init__(self, match):
        self.match = match
        
        w, h = g_cfg.screen_dimensions
        Menu.__init__(self, w, h)

        self.ingame = Ingame(match.match_team1, match.match_team2)
        self.ingame.register(self)
        
        self.team_panels = []
        
        SPACING = 10
        TEAM_PANELS_H = 230
        
        COMMAND_PANEL_H = 50
        
        team_panel = TeamPanel(match.match_team1, (w - 3 * SPACING) / 2,
                               TEAM_PANELS_H) 
        self.add_widget(team_panel, (SPACING, SPACING))
        self.team_panels.append(team_panel)
        
        team_panel = TeamPanel(match.match_team2, (w - 3 * SPACING) / 2,
                               TEAM_PANELS_H) 
        self.add_widget(team_panel, (SPACING, self.team_panels[0].bottom + SPACING))
        self.team_panels.append(team_panel)
        
        self.match_panel = MatchPanel(self.ingame, w - 2 * SPACING,
                                      h - 2 * TEAM_PANELS_H - 5 * SPACING - COMMAND_PANEL_H)
        self.add_widget(self.match_panel, (SPACING, 2 * TEAM_PANELS_H + 3 * SPACING))
        
        self.command_panel = CommandPanel(w - 2 * SPACING, COMMAND_PANEL_H)
        self.add_widget(self.command_panel, (SPACING, h - SPACING, LEFT, DOWN))
        
        self.chalkboard_panel = ChalkboardPanel(self.ingame,
                                                (w - 3 * SPACING) / 2,
                                                2 * TEAM_PANELS_H + SPACING)
        self.add_widget(self.chalkboard_panel, (w - SPACING, SPACING, RIGHT, UP))
        
        cursor = Cursor(DefaultCursorTheme(border=1, horizontal_offset=0,
                                           vertical_offset=0))
        cursor.bind(self)
        
        self.speed = None
        self.command_panel.speed_labels[2].activate()

    def listen(self, ig, event):
        if event.type == 'end_of_game':
            self.match.set_result(ig.match_teams[0].score,
                                  ig.match_teams[1].score)
            self.command_panel.enable_exit()
            self.change_speed(0)
        else:
            self.match_panel.event_area.add(event)
        for team_panel in self.team_panels:
            team_panel.refresh()

    def update(self):
        for _ in xrange(self.speed):
            ig = self.ingame
            ig.update()
    
            for team_panel in self.team_panels:
                team_panel.update()
            self.match_panel.update()

    def change_speed(self, new_speed):
        for l in self.command_panel.speed_labels:
            l.color = YELLOW if l.speed == new_speed else WHITE
        self.speed = new_speed