-
-
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.
Add the experience progress bar widget in the profile screen
- Loading branch information
1 parent
d655d1d
commit 17a30c1
Showing
11 changed files
with
168 additions
and
29 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
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,49 @@ | ||
#:kivy 2.2.1 | ||
#:import PATH_IMAGES tools.path.PATH_IMAGES | ||
|
||
<ExperienceCounter>: | ||
|
||
# Background | ||
canvas.before: | ||
Color: | ||
rgba: self.background_color | ||
RoundedRectangle: | ||
pos:(0,0) | ||
size:self.size | ||
radius:[30,] | ||
|
||
# Name | ||
Label: | ||
text: "Exp" | ||
font_size: root.font_ratio * root.font_size | ||
pos_hint: {"x":0.1, "center_y":0.7} | ||
size_hint: (1, None) | ||
font_name: root.text_font_name | ||
line_height: 1 | ||
text_size: self.size | ||
color: (0,0,0,1) | ||
halign: "left" | ||
valign: "middle" | ||
|
||
# Experience left | ||
Label: | ||
text: root.label_experience_left | ||
font_size: root.font_ratio * root.font_size | ||
pos_hint: {"right":0.9, "center_y":0.7} | ||
size_hint: (1, None) | ||
font_name: root.text_font_name | ||
line_height: 1 | ||
text_size: self.size | ||
color: (0,0,0,1) | ||
halign: "right" | ||
valign: "middle" | ||
|
||
# Experience progress bar | ||
CustomProgressBar: | ||
primary_color: (1, 1, 0, 1) | ||
background_color: (0, 0, 0, 1) | ||
value: root.percentage_experience | ||
size_hint: (0.8, 0.3) | ||
pos_hint: {"center_x": 0.5, "center_y":0.3} | ||
primary_color: root.primary_color | ||
secondary_color: root.secondary_color |
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,77 @@ | ||
""" | ||
Module to create coins counter. | ||
""" | ||
|
||
############### | ||
### Imports ### | ||
############### | ||
|
||
### Kivy imports ### | ||
from kivy.uix.relativelayout import RelativeLayout | ||
from kivy.properties import ( | ||
StringProperty, | ||
NumericProperty, | ||
ColorProperty | ||
) | ||
|
||
### Local imports ### | ||
from tools.path import ( | ||
PATH_TEXT_FONT | ||
) | ||
from tools.constants import ( | ||
CUSTOM_BUTTON_BACKGROUND_COLOR, | ||
OPACITY_ON_BUTTON_PRESS, | ||
EXPERIENCE_FONT_SIZE, | ||
THEMES_DICT | ||
) | ||
|
||
############# | ||
### Class ### | ||
############# | ||
|
||
|
||
class ExperienceCounter(RelativeLayout): | ||
""" | ||
A custom layout for the experience counter. | ||
""" | ||
|
||
background_color = CUSTOM_BUTTON_BACKGROUND_COLOR | ||
label_experience_left = StringProperty() | ||
percentage_experience = NumericProperty() | ||
experience_left = NumericProperty() | ||
font_size = NumericProperty() | ||
font_ratio = NumericProperty(1) | ||
theme_colors = StringProperty() | ||
primary_color = ColorProperty() | ||
secondary_color = ColorProperty() | ||
|
||
def __init__( | ||
self, | ||
text_font_name=PATH_TEXT_FONT, | ||
font_size=EXPERIENCE_FONT_SIZE, | ||
font_ratio=None, | ||
**kwargs): | ||
if font_ratio is not None: | ||
self.font_ratio = font_ratio | ||
super().__init__(**kwargs) | ||
self.bind(percentage_experience=self.update_experience) | ||
self.bind(experience_left=self.update_experience) | ||
self.bind(theme_colors=self.update_colors) | ||
self.text_font_name = text_font_name | ||
self.font_size = font_size | ||
|
||
def update_colors(self, base_widget, value): | ||
self.primary_color = THEMES_DICT[self.theme_colors]["primary"] | ||
self.secondary_color = THEMES_DICT[self.theme_colors]["secondary"] | ||
|
||
def update_experience(self, base_widget, value): | ||
self.label_experience_left = "+ " + str(self.experience_left) + " XP" | ||
|
||
def on_press(self): | ||
if self.button_mode: | ||
self.opacity = OPACITY_ON_BUTTON_PRESS | ||
|
||
def on_release(self): | ||
if self.button_mode: | ||
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