def __init__(self):
        Scene.__init__(self)
        self.callback = self._default_cb

        self.wait_img = Screen.get_instance().create_image(self.get_name() +
                                                           "_wait")
        if not self.wait_img.is_cached():
            img = Screen.create_button(ResourceManager.get("empty.png"),
                                       Strings.get("Please wait..."),
                                       Config.get("text_color"),
                                       ResourceManager.get(Config.get("font")),
                                       100)
            self.wait_img.load_surface(img)
            self.wait_img.save()

        self.nb_imgs = len(Config.get("photomaton")["placeholders"])
        self.one_more_imgs = []
        for i in xrange(self.nb_imgs):
            self.one_more_imgs.append(
                Screen.get_instance().create_image(self.get_name() +
                                                   "_one_more%d" % i))
            if not self.one_more_imgs[i].is_cached():
                img = Screen.create_button(
                    ResourceManager.get("empty.png"),
                    Strings.get(
                        "Encore une... (%d / %d)" % (i + 1, self.nb_imgs)),
                    Config.get("text_color"),
                    ResourceManager.get(Config.get("font")), 100)
                self.one_more_imgs[i].load_surface(img)
                self.one_more_imgs[i].save()
Exemple #2
0
    def __init__(self, arduino, camera):
        Scene.__init__(self)
        self.arduino = arduino
        self.camera = camera
        self.timer = None
        self.current_step = 0
        self.callback = self._default_cb

        self.cheese_img = Screen.get_instance().create_image(self.get_name() +
                                                             "_cheese")
        if not self.cheese_img.is_cached():
            base_img = Screen.get_instance().create_empty_image(True)
            self.cheese_img.load_surface(base_img.img)
            surf_text = Screen.create_text(
                Strings.get("Cheese"), ResourceManager.get(Config.get("font")),
                100, Config.get("text_color"))
            tw, th = surf_text.get_size()
            bw, bh = self.cheese_img.img.get_size()
            self.cheese_img.img.blit(surf_text, ((bw - tw) / 2, (bh - th) / 2))
            self.cheese_img.save()

        self.wait_img = Screen.get_instance().create_image(self.get_name() +
                                                           "_wait")
        if not self.wait_img.is_cached():
            img = Screen.create_button(ResourceManager.get("empty.png"),
                                       Strings.get("Please wait..."),
                                       Config.get("text_color"),
                                       ResourceManager.get(Config.get("font")),
                                       100)
            self.wait_img.load_surface(img)
            self.wait_img.save()

        self.imgs = []
        wait_before = Config.get("wait_before_snap")
        for i in xrange(wait_before, 0, -1):
            cache_img = Screen.get_instance().create_image(
                "%s_%d" % (self.get_name(), i), True)
            if not cache_img.is_cached():
                base_img = Screen.get_instance().create_empty_image(True)
                cache_img.load_surface(base_img.img)

                img = Screen.create_text(str(i), None, 200, (255, 0, 0))
                iw, ih = img.get_size()
                w, h = base_img.size

                cache_img.img.blit(img, (10, 10))
                cache_img.img.blit(img, (w - iw - 10, 10))
                cache_img.img.blit(img, (10, h - ih - 10))
                cache_img.img.blit(img, (w - iw - 10, h - ih - 10))

                cache_img.save()
            self.imgs.append(cache_img)

        Screen.get_instance().register_callback("on_preview_starts",
                                                self._on_preview_starts)
Exemple #3
0
    def __init__(self, arduino):
        Scene.__init__(self)
        self.arduino = arduino

        self.img = Screen.get_instance().create_image(self.get_name())
        if not self.img.is_cached():
            self.img.load(ResourceManager.get("welcome.png"))
            create_action_button(Arduino.BUTTON_1, Strings.get("Go"),
                                 self.img.get_surface())
            create_action_button(Arduino.BUTTON_2, Strings.get("Settings"),
                                 self.img.get_surface())
            self.img.save()
        self.arduino.register_callback(Arduino.BUTTON_1, self.on_button1)
        self.arduino.register_callback(Arduino.BUTTON_2, self.on_button2)
    def __init__(self, arduino):
        Scene.__init__(self)
        self.arduino = arduino

        self.img = Screen.get_instance().create_image(self.get_name())
        if not self.img.is_cached():
            self.img.load(ResourceManager.get("empty.png"))
            create_action_button(Arduino.BUTTON_1, Strings.get("Ok"), self.img.get_surface())
            create_action_button(Arduino.BUTTON_2, Strings.get("Next"), self.img.get_surface())
            self.img.save()
        arduino.register_callback(Arduino.BUTTON_1, self.on_button1)
        arduino.register_callback(Arduino.BUTTON_2, self.on_button2)

        self.menu = Form(self.img.get_surface().get_size())
        self.menu.add_item(FormButton("mode_simple", self._snap_simple))
        self.menu.add_item(FormButton("mode_photomaton", self._snap_photomaton))
        self.menu.add_item(FormButton("mode_special", self._snap_special))
        self.menu.cache(self.get_name(), self.img)
Exemple #5
0
    def __init__(self, arduino):
        Scene.__init__(self)
        self.arduino = arduino

        self.img = Screen.get_instance().create_image(self.get_name())
        if not self.img.is_cached():
            self.img.load(ResourceManager.get("empty.png"))
            create_action_button(Arduino.BUTTON_1, Strings.get("Ok"), self.img.get_surface())
            create_action_button(Arduino.BUTTON_2, Strings.get("Next"), self.img.get_surface())
            self.img.save()
        arduino.register_callback(Arduino.BUTTON_1, self.on_button1)
        arduino.register_callback(Arduino.BUTTON_2, self.on_button2)

        self.menu = Form(self.img.get_surface().get_size())
        for item in Config.get("special_effects"):
            self.menu.add_item(FormButton(Strings.get(item["string"]), self._effect, item["id"]))

        self.menu.cache(self.get_name(), self.img)
Exemple #6
0
    def __init__(self, arduino):
        Scene.__init__(self)
        self.arduino = arduino

        self.img = Screen.get_instance().create_image(self.get_name())
        if not self.img.is_cached():
            self.img.load(ResourceManager.get("empty.png"))
            create_action_button(Arduino.BUTTON_1, Strings.get("Ok"), self.img.get_surface())
            create_action_button(Arduino.BUTTON_2, Strings.get("Next"), self.img.get_surface())
            self.img.save()
        arduino.register_callback(Arduino.BUTTON_1, self.on_button1)
        arduino.register_callback(Arduino.BUTTON_2, self.on_button2)

        w, h = Screen.get_instance().get_size()
        self.menu = Form((w, h))
        self.menu.add_item(FormButton(Strings.get("Clean Cache"), self._action_clean_cache))
        self.menu.add_item(FormButton(Strings.get("Shutdown"), self._action_shutdown))
        self.menu.add_item(FormButton(Strings.get("Back"), self._action_back))

        self.menu.cache(self.get_name(), self.img)
Exemple #7
0
    def init(self, camera):
        self.camera = camera
        pygame.init()
        pygame.mouse.set_visible(False)
        self._set_display()
        self.w, self.h = self.window.get_size()

        # Write loading
        myfont = pygame.font.SysFont("monospace", 32)
        label = myfont.render(Strings.get("Loading..."), 1, (255, 255, 0))
        lw, lh = label.get_rect().size
        self.window.blit(label, ((self.w - lw) / 2, (self.h - lh) / 2))
        self.update()

        Logger.log_debug("Screen initialized with resolution %dx%d" % (self.w, self.h))
        self.initialized = True
Exemple #8
0
    def show(self):
        Scene.show(self, self.img)
        qr_path = os.path.join("cache/last_qrcode.png")
        if os.path.exists(qr_path):
            qr = pygame.image.load(qr_path)
            iw, ih = qr.get_size()
            w, h = self.img.size
            l = (w - iw) / 2
            t = h - ih - (h / 6)
            Screen.get_instance().get_window().blit(qr, (l, t))

            txt = Screen.create_text(Strings.get("Last picture :"),
                                     ResourceManager.get(Config.get("font")),
                                     Config.get("qrcode")["text_size"],
                                     Config.get("text_color"))
            iw, ih = txt.get_size()
            l = (w - iw) / 2
            t -= ih + 5
            Screen.get_instance().get_window().blit(txt, (l, t))

            Screen.get_instance().update()
        Logger.get_instance().show_msg()
Exemple #9
0
from scenes.SelectModeScene import SelectModeScene
from scenes.SettingsScene import SettingsScene
from scenes.SnapScene import SnapScene
from scenes.SnapPhotomatonScene import SnapPhotomatonScene
from scenes.SnapSpecialScene import SnapSpecialScene
from scenes.SelectEffectScene import SelectEffectScene


def quit():
    Logger.log_info("Quit")
    SceneManager().get_instance().stop()
    return True


if __name__ == "__main__":
    Strings.get_instance().load(ResourceManager.get(
        Config.get("strings_file")))
    camera = Camera()
    arduino = Arduino()
    Screen.get_instance().init(camera)
    try:
        camera.start()
        arduino.start()
        try:
            arduino.register_callback(Arduino.BUTTON_3, quit,
                                      Config.get("halt_delay"))

            sm = SceneManager().get_instance()
            sm.add_scene(WelcomeScene(arduino))
            sm.add_scene(SettingsScene(arduino))
            sm.add_scene(SelectModeScene(arduino))
            sm.add_scene(SnapScene(arduino, camera))