def __draw_game(self, game, overview): color = self.data.config.scoreboard_colors.color("default.background") self.canvas.Fill(color["r"], color["g"], color["b"]) # Draw the pregame renderer if Status.is_pregame(overview.status): scoreboard = Scoreboard(overview) scroll_max_x = self.__max_scroll_x(self.data.config.layout.coords("pregame.scrolling_text")) pregame = Pregame(overview) renderer = PregameRenderer(self.canvas, pregame, scoreboard, self.data, self.scrolling_text_pos) self.__update_scrolling_text_pos(renderer.render()) # Draw the final game renderer elif Status.is_complete(overview.status): scroll_max_x = self.__max_scroll_x(self.data.config.layout.coords("final.scrolling_text")) final = Final(game) scoreboard = Scoreboard(overview) renderer = FinalRenderer(self.canvas, final, scoreboard, self.data, self.scrolling_text_pos) self.__update_scrolling_text_pos(renderer.render()) # Draw the scoreboar renderer elif Status.is_irregular(overview.status): scoreboard = Scoreboard(overview) if scoreboard.get_text_for_reason(): scroll_max_x = self.__max_scroll_x(self.data.config.layout.coords("status.scrolling_text")) renderer = StatusRenderer(self.canvas, scoreboard, self.data, self.scrolling_text_pos) self.__update_scrolling_text_pos(renderer.render()) else: StatusRenderer(self.canvas, scoreboard, self.data).render() else: scoreboard = Scoreboard(overview) ScoreboardRenderer(self.canvas, scoreboard, self.data).render() self.canvas = self.matrix.SwapOnVSync(self.canvas)
def __draw_game(self, game, overview): color = self.data.config.scoreboard_colors.color("default.background") self.canvas.Fill(color["r"], color["g"], color["b"]) # Draw the pregame renderer if Status.is_pregame(overview.status): scoreboard = Scoreboard(overview) scroll_max_x = self.__max_scroll_x(self.data.config.layout.coords("pregame.scrolling_text")) pregame = Pregame(overview) renderer = PregameRenderer(self.canvas, pregame, scoreboard, self.data, self.scrolling_text_pos) self.__update_scrolling_text_pos(renderer.render()) # Draw the final game renderer elif Status.is_complete(overview.status): scroll_max_x = self.__max_scroll_x(self.data.config.layout.coords("final.scrolling_text")) final = Final(game) scoreboard = Scoreboard(overview) renderer = FinalRenderer(self.canvas, final, scoreboard, self.data, self.scrolling_text_pos) self.__update_scrolling_text_pos(renderer.render()) # Draw the scoreboar renderer elif Status.is_irregular(overview.status): scoreboard = Scoreboard(overview) if scoreboard.get_text_for_reason(): scroll_max_x = self.__max_scroll_x(self.data.config.layout.coords("status.scrolling_text")) renderer = StatusRenderer(self.canvas, scoreboard, self.data, self.scrolling_text_pos) self.__update_scrolling_text_pos(renderer.render()) else: StatusRenderer(self.canvas, scoreboard, self.data).render() else: scoreboard = Scoreboard(overview) ScoreboardRenderer(self.canvas, scoreboard, self.data).render() self.canvas = self.matrix.SwapOnVSync(self.canvas)
def render_irregular_status(canvas, layout: Layout, colors: Color, scoreboard: Scoreboard, short_text, text_pos=0): pos = 0 if scoreboard.get_text_for_reason(): pos = __render_scroll_text(canvas, layout, colors, scoreboard, text_pos) __render_game_status(canvas, layout, colors, scoreboard, short_text) return pos
def __draw_game(self): game = self.data.current_game bgcolor = self.data.config.scoreboard_colors.color( "default.background") self.canvas.Fill(bgcolor["r"], bgcolor["g"], bgcolor["b"]) scoreboard = Scoreboard(game) layout = self.data.config.layout colors = self.data.config.scoreboard_colors teams.render_team_banner( self.canvas, layout, self.data.config.team_colors, scoreboard.home_team, scoreboard.away_team, self.data.config.full_team_names, self.data.config.short_team_names_for_runs_hits, ) if status.is_pregame(game.status()): # Draw the pregame information self.__max_scroll_x(layout.coords("pregame.scrolling_text")) pregame = Pregame(game, self.data.config.time_format) pos = pregamerender.render_pregame( self.canvas, layout, colors, pregame, self.scrolling_text_pos, self.data.config.pregame_weather) self.__update_scrolling_text_pos(pos, self.canvas.width) elif status.is_complete(game.status()): # Draw the game summary self.__max_scroll_x(layout.coords("final.scrolling_text")) final = Postgame(game) pos = postgamerender.render_postgame(self.canvas, layout, colors, final, scoreboard, self.scrolling_text_pos) self.__update_scrolling_text_pos(pos, self.canvas.width) elif status.is_irregular(game.status()): # Draw game status short_text = self.data.config.layout.coords( "status.text")["short_text"] if scoreboard.get_text_for_reason(): self.__max_scroll_x(layout.coords("status.scrolling_text")) pos = irregular.render_irregular_status( self.canvas, layout, colors, scoreboard, short_text, self.scrolling_text_pos) self.__update_scrolling_text_pos(pos, self.canvas.width) else: irregular.render_irregular_status(self.canvas, layout, colors, scoreboard, short_text) self.data.scrolling_finished = True else: # draw a live game if scoreboard.homerun() or scoreboard.strikeout(): self.animation_time += 1 else: self.animation_time = 0 loop_point = self.data.config.layout.coords("atbat")["loop"] self.scrolling_text_pos = min(self.scrolling_text_pos, loop_point) pos = gamerender.render_live_game(self.canvas, layout, colors, scoreboard, self.scrolling_text_pos, self.animation_time) self.__update_scrolling_text_pos(pos, loop_point) # Show network issues if self.data.network_issues: network.render_network_error(self.canvas, layout, colors) self.canvas = self.matrix.SwapOnVSync(self.canvas)