コード例 #1
0
ファイル: foos.py プロジェクト: peteclarkez/foos
sf = 0
frames = 25
for opt, arg in opts:
    if opt == '-f':
        frames = int(arg)
    if opt == '-s':
        sf = float(arg)

root = os.path.abspath(os.path.dirname(__file__))
ui.media_path = root + "/img"

bus = Bus()
gui = ui.Gui(sf,
             frames,
             bus,
             show_leds=config.onscreen_leds_enabled,
             bg_change_interval=config.bg_change_secs)

if is_x11():
    logger.info("Running Keyboard")
    plugins.io_keyboard.Plugin(bus)

# Load plugins
PluginHandler(bus)

# Run main gui main loop
logger.info("Run GUI")
gui.run()
gui.cleanup()
コード例 #2
0
ファイル: ui.py プロジェクト: swehner/foos
    def __setup_sprites(self):
        flat = Shader("uv_flat")
        matflat = Shader("mat_flat")
        if is_x11():
            # load an image as bg
            self.bg_img = pi3d.ImageSprite(load_texture(self.__choose_random_bg()), flat, w=int(self.height * bg_w / bg_h), h=self.height, z=101)
        else:
            self.bg_img = None
            
        if is_pi():
            self.bgr = BGRotater(bg_w, bg_h, -1, img("bg"), self.bg_change_interval) 
            self.bgr.change()

        bg = pi3d.Sprite(w=self.width, h=self.height, z=100)
        bg.set_shader(matflat)
        bg.set_alpha(0)
        self.bg = Flashing(bg)
        
        
        logger.debug("Loading other images")
        logo_d = (80, 80)
        self.logo = pi3d.ImageSprite(load_icon("icons/logo.png", fallback="icons/logo_fallback.png"), flat, w=logo_d[0], h=logo_d[1],
                                     x=self._fright(logo_d[0] / 2 + 40), y=self._fbottom(logo_d[1] / 2 + 40), z=50)
        self.people = Disappear(pi3d.ImageSprite(load_icon("icons/people.png"), flat, w=logo_d[0], h=logo_d[1],
                                x=self._fright(logo_d[0] * 3 / 2 + 40 + 20), y=self._fbottom(logo_d[1] / 2 + 40), z=50),
                                duration=config.md_ev_interval + 1, fade=0.5)

        in_d = (512 * 0.75, 185 * 0.75)
        self.instructions = pi3d.ImageSprite(load_icon("icons/instructions.png"), flat, w=in_d[0], h=in_d[1],
                                             x=self._fleft(in_d[0] / 2 + 40), y=self._fbottom(in_d[1] / 2 + 40), z=50)
        self.instructions = LazyTrigger(Disappear(self.instructions, duration=5))

        logger.debug("Loading font")
        printable_cps = list(itertools.chain(range(ord(' '), ord('~')), range(161, 255), [ord("○"), ord("●"), ord("◌"), ord("◉"), ord('Ω')]))
        fontfile = img("UbuntuMono-B_circle.ttf")
        font = OutlineFont(fontfile, font_size=80, image_size=1024, outline_size=2,
                           codepoints=printable_cps, mipmap=False, filter=GL_LINEAR)
        self.goal_time = ChangingText(flat, font=font, string=self.__get_time_since_last_goal(),
                                      is_3d=False, justify='C', x=0, y=self._fbottom(90), z=50)

        self.game_mode_ui = ChangingText(flat, font=font, string=self.__get_mode_string(None),
                                         is_3d=False, justify='R', x=self._fright(40), y=self._ftop(60), z=50)

        self.feedback = KeysFeedback(flat)

        s = 512
        self.yCounter = Move(Counter(0, flat, config.team_colors['yellow'], w=s, h=s, z=50))
        self.bCounter = Move(Counter(0, flat, config.team_colors['black'], w=s, h=s, z=50))
        playerfont = OutlineFont(fontfile, font_size=50, image_size=768, outline_size=2,
                                 codepoints=printable_cps, mipmap=False, filter=GL_LINEAR)
        self.yPlayers = Multiline(flat, font=playerfont, string=self.getPlayers(left=True),
                                  x=-380, y=-250, z=50, justify='C')
        self.bPlayers = Multiline(flat, font=playerfont, string=self.getPlayers(left=False),
                                  x=380, y=-250, z=50, justify='C')

        menufont = OutlineFont(fontfile, (255, 255, 255, 255), font_size=50, image_size=768,
                               codepoints=printable_cps, mipmap=False, filter=GL_LINEAR)
        arrow = load_icon("icons/arrow.png")
        menu = Menu(menufont, arrow, wchar=60, n=12, z=10)
        self.menu = MenuTree(self.main_menu, menu, rootTitle="Game mode")

        self.ledShapes = {
            "YD": FlatDisk(radius=20, sides=12, x=-100, y=-430, z=0, rx=90),
            "YI": FlatDisk(radius=20, sides=12, x=-100, y=-370, z=0, rx=90),
            "OK": FlatDisk(radius=50, sides=12, x=0, y=-400, z=0, rx=90),
            "BD": FlatDisk(radius=20, sides=12, x=100, y=-430, z=0, rx=90),
            "BI": FlatDisk(radius=20, sides=12, x=100, y=-370, z=0, rx=90),
        }
        red = (1, 0, 0, 0)
        green = (0, 1, 0, 0)
        self.blackColor = (0, 0, 0, 0)
        self.ledColors = {"YD": red, "YI": green, "OK": green, "BD": red, "BI": green}
        self.leds = []

        self.winner = WinnerString(flat)
        # move immediately to position
        self.__move_sprites()
コード例 #3
0
ファイル: ui.py プロジェクト: bartha-adam/foos
    def __setup_sprites(self):
        flat = Shader("uv_flat")
        matflat = Shader("mat_flat")
        if is_x11():
            # load an image as bg
            self.bg_img = pi3d.ImageSprite(load_texture(
                self.__choose_random_bg()),
                                           flat,
                                           w=int(self.height * bg_w / bg_h),
                                           h=self.height,
                                           z=101)
        else:
            self.bg_img = None

        if is_pi():
            self.bgr = BGRotater(bg_w, bg_h, -1, img("bg"),
                                 self.bg_change_interval)
            self.bgr.change()

        bg = pi3d.Sprite(w=self.width, h=self.height, z=100)
        bg.set_shader(matflat)
        bg.set_alpha(0)
        self.bg = Flashing(bg)

        logger.debug("Loading other images")
        logo_d = (80, 80)
        self.logo = pi3d.ImageSprite(load_icon(
            "icons/logo.png", fallback="icons/logo_fallback.png"),
                                     flat,
                                     w=logo_d[0],
                                     h=logo_d[1],
                                     x=self._fright(logo_d[0] / 2 + 40),
                                     y=self._fbottom(logo_d[1] / 2 + 40),
                                     z=50)
        self.people = Disappear(pi3d.ImageSprite(
            load_icon("icons/people.png"),
            flat,
            w=logo_d[0],
            h=logo_d[1],
            x=self._fright(logo_d[0] * 3 / 2 + 40 + 20),
            y=self._fbottom(logo_d[1] / 2 + 40),
            z=50),
                                duration=config.md_ev_interval + 1,
                                fade=0.5)

        in_d = (512 * 0.75, 185 * 0.75)
        self.instructions = pi3d.ImageSprite(
            load_icon("icons/instructions.png"),
            flat,
            w=in_d[0],
            h=in_d[1],
            x=self._fleft(in_d[0] / 2 + 40),
            y=self._fbottom(in_d[1] / 2 + 40),
            z=50)
        self.instructions = LazyTrigger(
            Disappear(self.instructions, duration=5))

        logger.debug("Loading font")
        printable_cps = list(
            itertools.chain(
                range(ord(' '), ord('~')), range(161, 255),
                [ord("○"), ord("●"),
                 ord("◌"), ord("◉"),
                 ord('Ω')]))
        fontfile = img("UbuntuMono-B_circle.ttf")
        font = OutlineFont(fontfile,
                           font_size=80,
                           image_size=1024,
                           outline_size=2,
                           codepoints=printable_cps,
                           mipmap=False,
                           filter=GL_LINEAR)
        self.goal_time = ChangingText(flat,
                                      font=font,
                                      string=self.__get_time_since_last_goal(),
                                      is_3d=False,
                                      justify='C',
                                      x=0,
                                      y=self._fbottom(90),
                                      z=50)

        self.game_mode_ui = ChangingText(flat,
                                         font=font,
                                         string=self.__get_mode_string(None),
                                         is_3d=False,
                                         justify='R',
                                         x=self._fright(40),
                                         y=self._ftop(60),
                                         z=50)

        self.feedback = KeysFeedback(flat)

        s = 512
        self.yCounter = Move(
            Counter(0, flat, config.team_colors['yellow'], w=s, h=s, z=50))
        self.bCounter = Move(
            Counter(0, flat, config.team_colors['black'], w=s, h=s, z=50))
        playerfont = OutlineFont(fontfile,
                                 font_size=50,
                                 image_size=768,
                                 outline_size=2,
                                 codepoints=printable_cps,
                                 mipmap=False,
                                 filter=GL_LINEAR)
        self.yPlayers = Multiline(flat,
                                  font=playerfont,
                                  string=self.getPlayers(left=True),
                                  x=-380,
                                  y=-250,
                                  z=50,
                                  justify='C')
        self.bPlayers = Multiline(flat,
                                  font=playerfont,
                                  string=self.getPlayers(left=False),
                                  x=380,
                                  y=-250,
                                  z=50,
                                  justify='C')

        menufont = OutlineFont(fontfile, (255, 255, 255, 255),
                               font_size=50,
                               image_size=768,
                               codepoints=printable_cps,
                               mipmap=False,
                               filter=GL_LINEAR)
        arrow = load_icon("icons/arrow.png")
        menu = Menu(menufont, arrow, wchar=60, n=12, z=10)
        self.menu = MenuTree(self.main_menu, menu, rootTitle="Game mode")

        self.ledShapes = {
            "YD": FlatDisk(radius=20, sides=12, x=-100, y=-430, z=0, rx=90),
            "YI": FlatDisk(radius=20, sides=12, x=-100, y=-370, z=0, rx=90),
            "OK": FlatDisk(radius=50, sides=12, x=0, y=-400, z=0, rx=90),
            "BD": FlatDisk(radius=20, sides=12, x=100, y=-430, z=0, rx=90),
            "BI": FlatDisk(radius=20, sides=12, x=100, y=-370, z=0, rx=90),
        }
        red = (1, 0, 0, 0)
        green = (0, 1, 0, 0)
        self.blackColor = (0, 0, 0, 0)
        self.ledColors = {
            "YD": red,
            "YI": green,
            "OK": green,
            "BD": red,
            "BI": green
        }
        self.leds = []

        self.winner = WinnerString(flat)
        # move immediately to position
        self.__move_sprites()
コード例 #4
0
ファイル: foos.py プロジェクト: swehner/foos
    print('-s: scale')
    print('-f: framerate (default: 25)')
    sys.exit(2)

sf = 0
frames = 25
for opt, arg in opts:
    if opt == '-f':
        frames = int(arg)
    if opt == '-s':
        sf = float(arg)

root = os.path.abspath(os.path.dirname(__file__))
ui.media_path = root + "/img"

bus = Bus()
gui = ui.Gui(sf, frames, bus, show_leds=config.onscreen_leds_enabled,
             bg_change_interval=config.bg_change_secs)

if is_x11():
    logger.info("Running Keyboard")
    plugins.io_keyboard.Plugin(bus)

# Load plugins
PluginHandler(bus)

# Run main gui main loop
logger.info("Run GUI")
gui.run()
gui.cleanup()