-
-
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
9a41de1
commit 90c2222
Showing
9 changed files
with
155 additions
and
11 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#:kivy 2.2.1 | ||
#:import PATH_TEXT_FONT tools.path.PATH_TEXT_FONT | ||
#:import LEVEL_ID_FONT_SIZE tools.constants.LEVEL_ID_FONT_SIZE | ||
|
||
<LevelButton>: | ||
|
||
Widget: | ||
opacity: 0.8 | ||
size: root.size | ||
pos: (0,0) | ||
canvas.before: | ||
Color: | ||
rgba: self.parent.primary_color | ||
RoundedRectangle: | ||
pos:(0,0) | ||
size:self.size | ||
radius:[15,] | ||
|
||
Label: | ||
id: level_label | ||
text: root.level_label_text | ||
pos_hint: {"center_x":0.5, "center_y":0.65} | ||
font_size: LEVEL_ID_FONT_SIZE * root.font_ratio | ||
font_name: PATH_TEXT_FONT | ||
|
||
|
||
# Stars | ||
ThreeStars: | ||
id: three_stars | ||
pos_hint: {"center_x":0.5, "center_y":0.25} | ||
size_hint: (0.8,0.45) | ||
nb_stars: root.nb_stars | ||
|
||
# <LevelLeftBranch>: |
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,80 @@ | ||
""" | ||
Module to create the levels tree for the levels screen. | ||
""" | ||
|
||
############### | ||
### Imports ### | ||
############### | ||
|
||
### Kivy imports ### | ||
|
||
from kivy.uix.relativelayout import RelativeLayout | ||
from kivy.uix.behaviors import ButtonBehavior | ||
from kivy.properties import ( | ||
NumericProperty, | ||
BooleanProperty, | ||
ColorProperty, | ||
StringProperty | ||
) | ||
|
||
### Local imports ### | ||
from tools.path import ( | ||
PATH_TEXT_FONT | ||
) | ||
from tools.constants import ( | ||
GAMEPLAY_DICT, | ||
OPACITY_ON_BUTTON_PRESS | ||
) | ||
|
||
|
||
############### | ||
### Classes ### | ||
############### | ||
|
||
class LevelButton(ButtonBehavior, RelativeLayout): | ||
|
||
nb_stars = NumericProperty() | ||
font_ratio = NumericProperty(1) | ||
level_label_text = StringProperty() | ||
primary_color = ColorProperty((0.5, 0.5, 0.5, 1)) | ||
secondary_color = ColorProperty((0.2, 0.2, 0.2, 1)) | ||
is_unlocked = BooleanProperty(False) | ||
disable_button = BooleanProperty(False) | ||
|
||
def __init__( | ||
self, | ||
level_id=0, | ||
release_function=lambda: 1 + 1, | ||
is_unlocked=False, | ||
**kw): | ||
super().__init__(**kw) | ||
self.release_function = release_function | ||
self.always_release = True | ||
self.is_unlocked = is_unlocked | ||
self.level_id = level_id | ||
self.level_label_text = str(level_id) | ||
|
||
def on_press(self): | ||
if not self.disable_button: | ||
self.opacity = OPACITY_ON_BUTTON_PRESS | ||
|
||
def on_release(self): | ||
if not self.disable_button: | ||
self.release_function() | ||
self.opacity = 1 | ||
|
||
|
||
class LevelBranch(RelativeLayout): | ||
def __init__( | ||
self, | ||
act_id, | ||
branch_id, | ||
**kw): | ||
super().__init__(**kw) | ||
self.act_id = act_id | ||
self.branch_id = branch_id | ||
|
||
def build_layout(self): | ||
# Find the number of levels contained in the branch, cannot be greater than 5 | ||
nb_levels = ... | ||
self.local_nb_levels = ... |
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