-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd78112
commit 3899dc3
Showing
10 changed files
with
138 additions
and
20 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#:kivy 2.2.1 | ||
|
||
<ActButton>: | ||
|
||
# Background | ||
canvas.before: | ||
Color: | ||
rgba: self.background_color | ||
RoundedRectangle: | ||
pos:(0,0) | ||
size:self.size | ||
radius:[40,] | ||
|
||
# Act title | ||
Label: | ||
id: act_title_label | ||
text: root.act_title | ||
pos_hint: {"center_y":0.8, "center_x":0.5} | ||
size: (1,0.5) | ||
font_size: root.parent.font_ratio * root.font_size | ||
font_name: root.text_font_name | ||
halign: "center" | ||
valign: "center" | ||
color: (0,0,0,1) | ||
|
||
# Stars | ||
ThreeStars: | ||
id: three_stars | ||
pos_hint: {"center_x":0.35, "center_y":0.25} | ||
size_hint: (0.5,0.5) | ||
stars_number: root.stars_number | ||
|
||
# Completion | ||
Label: | ||
id: completion_label | ||
text: root.completion_text | ||
pos_hint: {"center_x":0.8, "center_y":0.25} | ||
size_hint: (0.3,0.5) | ||
font_size: root.parent.font_ratio * root.font_size | ||
font_name: root.text_font_name | ||
halign: "center" | ||
valign: "center" | ||
color: (0,0,0,1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
""" | ||
Module to create the act button. | ||
""" | ||
|
||
############### | ||
### Imports ### | ||
############### | ||
|
||
### Kivy imports ### | ||
from kivy.uix.relativelayout import RelativeLayout | ||
from kivy.uix.behaviors import ButtonBehavior | ||
from kivy.properties import ( | ||
StringProperty, | ||
NumericProperty | ||
) | ||
|
||
### Local imports ### | ||
from tools.path import ( | ||
PATH_TEXT_FONT | ||
) | ||
from tools.constants import ( | ||
CUSTOM_BUTTON_BACKGROUND_COLOR, | ||
MAIN_BUTTON_FONT_SIZE, | ||
OPACITY_ON_BUTTON_PRESS | ||
) | ||
|
||
############# | ||
### Class ### | ||
############# | ||
|
||
|
||
class ActButton(ButtonBehavior, RelativeLayout): | ||
""" | ||
A custom button with a white round rectangle background. | ||
""" | ||
|
||
background_color = CUSTOM_BUTTON_BACKGROUND_COLOR | ||
act_title = StringProperty() | ||
completion_text = StringProperty() | ||
font_size = NumericProperty() | ||
nb_levels = NumericProperty() | ||
nb_completed_levels = NumericProperty() | ||
stars_number = NumericProperty() | ||
|
||
def __init__( | ||
self, | ||
text_font_name=PATH_TEXT_FONT, | ||
font_size=MAIN_BUTTON_FONT_SIZE, | ||
release_function=lambda: 1 + 1, | ||
**kwargs): | ||
super().__init__(**kwargs) | ||
self.release_function = release_function | ||
self.always_release = True | ||
self.text_font_name = text_font_name | ||
self.font_size = font_size | ||
self.bind(nb_completed_levels=self.update_nb_completed_levels) | ||
|
||
def update_nb_completed_levels(self, base_widget, value): | ||
self.completion_text = str( | ||
self.nb_completed_levels) + "/" + str(self.nb_levels) | ||
|
||
def on_press(self): | ||
self.opacity = OPACITY_ON_BUTTON_PRESS | ||
|
||
def on_release(self): | ||
self.release_function() | ||
self.opacity = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters