def generate_score_label(self, *args): label = Label( text=str(self.get_record()), color=get_color_from_hex('5BBEE5'), font_size=30) label.curve = 25 return label
def generate_medal_label(self, *args): label = Label( color=get_color_from_hex('5BBEE5'), font_size=30, size_hint=(.7, 1)) label.curve = 25 label.image.source = 'assets/images/medal.png' return label
def refresh_board(self): self.board.clear_widgets() pre_board = self.get_synced_board() wh = min((330 * Window.width / 520), (330 * Window.height / 600)) for i in range(0, 100): label = Label( color=(0, 0, 0, 1), size_hint=(None, None), size=(wh / 11, wh / 11)) label.curve = self.curve color = pre_board.get(str(99 - i), self.labels) set_color(label, color) if color != self.labels: label.filled = True self.board.add_widget(label)
def create_on_end_popup(self): self.remove_pause_but() label = Label( text='No Moves Left', color=get_color_from_hex('5BBEE5'), size_hint=(1, .3)) label.curve = 25 gridlayout = GridLayout( cols=1, rows=2, spacing=(0, 3)) score_gridlayout = GridLayout( cols=2, rows=1, spacing=(-20, -10), padding=(0, 0, 0, 0)) button = self.generate_play_button() button.bind(on_press=self.go) button.size_hint = (1, .5) score_label = self.generate_score_label() medal_label = self.generate_medal_label() score_gridlayout.add_widget(medal_label) score_gridlayout.add_widget(score_label) gridlayout.add_widget(label) gridlayout.add_widget(score_gridlayout) theme = self.generate_theme_button() theme.bind(on_press=self.change_theme) sound_theme_box = GridLayout(cols=2, rows=1, spacing=(10, 0), size_hint=(1, .5)) sound = self.generate_sound_button() sound_theme_box.add_widget(theme) sound_theme_box.add_widget(sound) layout = GridLayout( cols=1, rows=3, spacing=(10, 10), padding=(3, 6, 3, 6)) layout.add_widget(gridlayout) layout.add_widget(button) layout.add_widget(sound_theme_box) self.popup = Popup( content=layout, size_hint=(None, None), size=(200, 350), auto_dismiss=False, border=(0, 0, 0, 0), separator_height=0) title = self.popup.children[0].children[2] self.popup.children[0].remove_widget(title) self.popup.open() self.sync_score(0) self.sync_board({})
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()