Esempio n. 1
0
 def handle_game1(self, args):
     self.layout = FrescoClientLayout()
     self.fresco = self.layout.fresco
     self.container.clear_widgets()
     self.container.add_widget(self.layout)
Esempio n. 2
0
 def handle_game1(self, args):
     self.layout = FrescoClientLayout()
     self.fresco = self.layout.fresco
     self.container.clear_widgets()
     self.container.add_widget(self.layout)
Esempio n. 3
0
class FrescoClient(KalScenarioClient):
    def __init__(self, *largs):
        super(FrescoClient, self).__init__(*largs)
        self.count = 0
        self.timeout = 0
        self.layout = None
        self.logo = ""
        Clock.schedule_interval(self.update_graphics_timer, 1 / 10.0)

    def handle_clear(self, args):
        pass

    def handle_waitready(self, args):
        pass

    def handle_time(self, args):
        self.timedelta, self.timeout = map(int, args.split())
        print "time is", time(), self.timedelta
        self.timedelta = time() - self.timedelta
        print "calculated timedelta", self.timedelta
        # apply that delta to timeout
        self.timeout += self.timedelta
        self.timelimit = self.timeout - time()
        print "time limit is", self.timelimit

    def handle_color(self, args):
        self.layout.color = map(lambda x: int(x) / 255.0, args.split())

    def handle_logo(self, args):
        self.layout.logo = args

    def handle_game1(self, args):
        self.layout = FrescoClientLayout()
        self.fresco = self.layout.fresco
        self.container.clear_widgets()
        self.container.add_widget(self.layout)

    def handle_game2(self, args):
        self.layout.hide_places()

    def handle_give(self, args):
        # create thumbnail in the gridlayout
        self.count += 1
        index = int(args)
        item = self.layout.create_and_add_item(index)
        item.bind(date=self.send_date)

    def handle_thnotvalid(self, args):
        index = int(args)
        thumb = self.layout.get_thumb_from_index(index)
        if not thumb:
            return
        thumb.auto_color = True
        thumb.update_color()

    def handle_thvalid(self, args):
        index = int(args)
        thumb = self.layout.get_thumb_from_index(index)
        if not thumb:
            return
        self.fresco.set_pos_by_date(thumb, thumb.item["date"], True)
        thumb.auto_color = True
        thumb.update_color()
        thumb.do_translation = False

    def send_date(self, instance, value):
        if value is None:
            value = -1
        self.send("POS %d %f" % (instance.index, value))

    def update_graphics_timer(self, dt):
        if not self.layout:
            return
        t = self.timeout - time()
        if t < 0:
            t = 0
        self.layout.time = t
        self.layout.timelimit = self.timelimit
Esempio n. 4
0
class FrescoClient(KalScenarioClient):
    def __init__(self, *largs):
        super(FrescoClient, self).__init__(*largs)
        self.count = 0
        self.timeout = 0
        self.layout = None
        self.logo = ''
        Clock.schedule_interval(self.update_graphics_timer, 1 / 10.)

    def handle_clear(self, args):
        pass

    def handle_waitready(self, args):
        pass

    def handle_time(self, args):
        self.timedelta, self.timeout = map(int, args.split())
        self.timedelta = time() - self.timedelta
        # apply that delta to timeout
        self.timeout += self.timedelta
        self.timelimit = self.timeout - time() 

    def handle_color(self, args):
        self.layout.color = map(lambda x: int(x) / 255., args.split())

    def handle_logo(self, args):
        self.layout.logo = args

    def handle_game1(self, args):
        self.layout = FrescoClientLayout()
        self.fresco = self.layout.fresco
        self.container.clear_widgets()
        self.container.add_widget(self.layout)

    def handle_game2(self, args):
        self.layout.hide_places()

    def handle_give(self, args):
        # create thumbnail in the gridlayout
        self.count += 1
        index = int(args)
        item = self.layout.create_and_add_item(index)
        item.bind(date=self.send_date)

    def handle_thnotvalid(self, args):
        index = int(args)
        thumb = self.layout.get_thumb_from_index(index)
        if not thumb:
            return
        thumb.auto_color = True
        thumb.update_color()

    def handle_thvalid(self, args):
        index = int(args)
        thumb = self.layout.get_thumb_from_index(index)
        if not thumb:
            return
        self.fresco.set_pos_by_date(thumb, thumb.item['date'])
        thumb.auto_color = True
        thumb.update_color()
        thumb.do_translation = False


    def send_date(self, instance, value):
        if value is None:
            value = -1
        self.send('POS %d %.04f' % (instance.index, value))

    def update_graphics_timer(self, dt):
        if not self.layout:
            return
        t = self.timeout - time()
        if t < 0:
            t = 0
        self.layout.time = t
        self.layout.timelimit = self.timelimit