Ejemplo n.º 1
0
 def on_dismiss(self, *args):
     for val in self.score_board:
         if 'new' in val:
             text = self.editable_text.text.strip()
             val['name'] = text and text or DEF_USER
             val.pop('new')
     DB.store_put('%sx%s-%s' % (self.board_h, self.board_v, self.level), self.score_board)
     DB.store_sync()
     super(CustomPopup, self).on_dismiss(*args)
Ejemplo n.º 2
0
    def set_record(self):
        try:
            high_score = DB.store_get('high_score')
        except KeyError:
            high_score = 0

        if high_score < self.score:
            DB.store_put('high_score', self.score)
        DB.store_sync()
Ejemplo n.º 3
0
    def uname_pword_update(self):
        username = self.current_screen.username_input.text.strip()
        password = self.current_screen.password_input.text.strip()

        if username and password:
            DB.store_put('username', username)
            DB.store_put('password', password)
            DB.store_sync()
            self.username = username
            self.password = password
Ejemplo n.º 4
0
 def change_sound(self, *args):
     global SOUND
     button = args[0]
     SOUND = not SOUND
     button.image.source = 'assets/images/sound_%s.png' % (
         SOUND and 'on' or 'off')
     DB.store_put('sound', SOUND)
     DB.store_sync()
     if not SOUND:
         self.sound.stop()
Ejemplo n.º 5
0
 def set_theme(self, theme=None, *args):
     if not theme:
         theme = DB.store_get('theme')
     self.theme = theme
     self.background = THEME.get(theme).get('background')
     self.labels = THEME.get(theme).get('labels')
     self.free_place_notifier = THEME[self.theme]['labels']
     self.change_board_color(self.labels)
     Window.clearcolor = self.background
     DB.store_put('theme', theme)
     DB.store_sync()
Ejemplo n.º 6
0
 def delete_server(self, *args):
     name = self.input_box.name_input.text.strip()
     url = self.input_box.url_input.text.strip()
     repo = self.input_box.repo_input.text.strip()
     cmd = self.input_box.cmd_input.text.strip()
     tmp = {'name': name, 'url': url, 'cmd': cmd, 'repo': repo}
     servers = DB.store_get('servers')
     if filter(lambda x: x == tmp, servers):
         servers.pop(servers.index(tmp))
         DB.store_put('servers', servers)
         DB.store_sync()
         root = findparent(self, Deployment)
         root.load_servers()
         root.servers_correction_screenbased('settings')
Ejemplo n.º 7
0
 def add_server(self, *args):
     name = self.input_box.name_input.text.strip()
     url = self.input_box.url_input.text.strip()
     repo = self.input_box.repo_input.text.strip()
     cmd = self.input_box.cmd_input.text.strip()
     if name and url and cmd and repo:
         servers = DB.store_get('servers')
         servers.append({
             'name': name,
             'url': url,
             'cmd': cmd,
             'repo': repo
         })
         DB.store_put('servers', servers)
         DB.store_sync()
         root = findparent(self, Deployment)
         root.load_servers()
         root.servers_correction_screenbased('settings')
Ejemplo n.º 8
0
    def save_board(self, *args):
        """On exit keep last session"""
        window, = args
        root = window.children[0]
        try:
            board = root.board.children
            board_visual = {}
            if board:
                index = 0
                for label in board:
                    color = get_color(label)
                    if label.filled:
                        board_visual.update({index: color.rgba})
                    index += 1
            DB.store_put('board', board_visual)
            DB.store_put('score', root.score)
            DB.store_sync()
        except AttributeError:
            pass

        try:
            scatters = [root.comingLeft, root.comingMid, root.comingRight]
            shapes = []
            for scatter in scatters:
                layout = scatter.children[0]
                try:
                    shape = layout.children[0]
                    pre_shape = dict(rows=shape.rows,
                                     cols=shape.cols,
                                     array=shape.array,
                                     color=shape.color)
                    shapes.append(pre_shape)
                except IndexError:
                    pass
            DB.store_put('shapes', shapes)
            DB.store_sync()
        except AttributeError:
            pass
Ejemplo n.º 9
0
    def coming_shapes(self):
        shapes = self.get_synced_shapes()
        scatters = [self.comingLeft, self.comingMid, self.comingRight]
        for scatter in scatters:
            scatter.clear_widgets()
            scatter.pos = (0, 0)
            scatter.pre_pos = scatter.pos

        per_shape_width = float(Window.width) / 3
        per_shape_height = float(self.coming.height)

        for scatter in scatters:
            scatter.calculate_shape_size()
            shape = None
            try:
                pre_shape = shapes[scatters.index(scatter)]
                shape = Shape(pre_shape['rows'], pre_shape['cols'],
                              pre_shape['array'], pre_shape['color'])
            except IndexError:
                pass
            if not shape:
                color_set = filter(
                    lambda x: x not in map(
                        lambda x: x.color, self.get_shapes()), COLOR)
                shape = Shape(color_set=color_set)
            width = 0
            height = 0
            index = 0
            for i in shape.array:
                if i == 1:
                    box = Label(
                        size_hint=(None, None),
                        size=(scatter.wh_per, scatter.wh_per))
                    box.curve = self.curve
                    set_color(box, self.background)
                else:
                    box = Image(
                        source='assets/images/trans.png',
                        size_hint=(None, None),
                        size=(scatter.wh_per, scatter.wh_per))
                index += 1
                if index % shape.cols == 0:
                    height += scatter.wh_per + 1

                if index % shape.rows == 0:
                    width += scatter.wh_per + 1
                shape.add_widget(box)
            shape.spacing = (1, 1)
            scatter.size_hint = (None, None)
            scatter.size = (width, height)

            index = scatters.index(scatter)
            scatter_pos_x = (
                per_shape_width * index) + (
                    (per_shape_width - scatter.size[0]) / 2)
            scatter_pos_y = (per_shape_height - scatter.size[1]) / 2
            scatter.pos = (scatter_pos_x, scatter_pos_y)
            scatter.pre_pos = scatter.pos
            self.last_moved = datetime.now()

            scatter.add_widget(shape)
            label_colors = shape.get_colors()
            scatter.do_translation_y = True
            scatter.do_translation_x = True
            for color in label_colors:
                anim = Animation(rgba=shape.color, d=.2, t='in_circ')
                anim.start(color)
        DB.store_put('shapes', [])
        DB.store_sync()
Ejemplo n.º 10
0
 def sync_board(self, board):
     DB.store_put('board', board)
     DB.store_sync()
Ejemplo n.º 11
0
 def sync_score(self, score):
     DB.store_put('score', score)
     DB.store_sync()