diff --git a/screens/__init__.py b/screens/__init__.py index 5d492af..be48131 100644 --- a/screens/__init__.py +++ b/screens/__init__.py @@ -6,11 +6,16 @@ ### Imports ### ############### +# Import the custom widgets from screens.custom_widgets import ( BottomBar, - CustomButton + CustomButton, + ThreeStars ) + +# Import the screens from screens.home import HomeScreen from screens.profile import ProfileScreen from screens.customization import CustomizationScreen from screens.settings import SettingsScreen +from screens.free_mode import FreeModeScreen diff --git a/screens/custom_widgets/__init__.py b/screens/custom_widgets/__init__.py index cc814a2..35ccc39 100644 --- a/screens/custom_widgets/__init__.py +++ b/screens/custom_widgets/__init__.py @@ -5,3 +5,4 @@ from screens.custom_widgets.bottom_bar import BottomBar from screens.custom_widgets.custom_buttons import CustomButton +from screens.custom_widgets.three_stars import ThreeStars diff --git a/screens/custom_widgets/bottom_bar.py b/screens/custom_widgets/bottom_bar.py index 7d7aa71..76cbf8b 100644 --- a/screens/custom_widgets/bottom_bar.py +++ b/screens/custom_widgets/bottom_bar.py @@ -48,26 +48,22 @@ def open_home(self): """ Open the home screen. """ - if self.selected != "home": - self.parent.manager.current = "home" + self.parent.manager.current = "home" def open_settings(self): """ Open the settings screen. """ - if self.selected != "settings": - self.parent.manager.current = "settings" + self.parent.manager.current = "settings" def open_customization(self): """ Open the customization screen. """ - if self.selected != "customization": - self.parent.manager.current = "customization" + self.parent.manager.current = "customization" def open_profile(self): """ Open the profile screen. """ - if self.selected != "profile": - self.parent.manager.current = "profile" + self.parent.manager.current = "profile" diff --git a/screens/custom_widgets/three_stars.kv b/screens/custom_widgets/three_stars.kv new file mode 100644 index 0000000..1e95718 --- /dev/null +++ b/screens/custom_widgets/three_stars.kv @@ -0,0 +1,49 @@ +#:kivy 2.2.1 +#:import PATH_IMAGES tools.path.PATH_IMAGES + +: + + # Star one + Image: + id: star_one_contour + pos_hint: {"center_x":0.125,"center_y":0.5} + size_hint: (0.25,1) + source: PATH_IMAGES + "star.png" + fit_mode: "contain" + Image: + id: star_one + pos_hint: {"center_x":0.125,"center_y":0.5} + size_hint: (0.25,1) + source: PATH_IMAGES + "star_full.png" + fit_mode: "contain" + color: root.star_one_color + + # Star two + Image: + id: star_two_contour + pos_hint: {"center_x":0.5,"center_y":0.5} + size_hint: (0.25,1) + source: PATH_IMAGES + "star.png" + fit_mode: "contain" + Image: + id: star_two + pos_hint: {"center_x":0.5,"center_y":0.5} + size_hint: (0.25,1) + source: PATH_IMAGES + "star_full.png" + fit_mode: "contain" + color: root.star_two_color + + # Star three + Image: + id: star_three_contour + pos_hint: {"center_x":0.875,"center_y":0.5} + size_hint: (0.25,1) + source: PATH_IMAGES + "star.png" + fit_mode: "contain" + Image: + id: star_three_contour + pos_hint: {"center_x":0.875,"center_y":0.5} + size_hint: (0.25,1) + source: PATH_IMAGES + "star_full.png" + fit_mode: "contain" + color: root.star_three_color diff --git a/screens/custom_widgets/three_stars.py b/screens/custom_widgets/three_stars.py new file mode 100644 index 0000000..8c2d0c4 --- /dev/null +++ b/screens/custom_widgets/three_stars.py @@ -0,0 +1,63 @@ +""" +Module to create three stars with a certain filling ratio +""" + +############### +### Imports ### +############### + +### Kivy imports ### +from kivy.uix.widget import Widget +from kivy.uix.relativelayout import RelativeLayout +from kivy.properties import ( + NumericProperty, + ListProperty +) + +############# +### Class ### +############# + + +class ThreeStars(RelativeLayout): + + star_one_color = ListProperty([0.5, 0.5, 0.5, 1.]) + star_two_color = ListProperty([0.5, 0.5, 0.5, 1.]) + star_three_color = ListProperty([0.5, 0.5, 0.5, 1.]) + star_color_dict = {1: star_one_color, + 2: star_two_color, + 3: star_three_color} + stars_number = NumericProperty() + primary_color = ListProperty([0.5, 0.5, 0.5, 1.]) + secondary_color = ListProperty([1., 1., 1., 1.]) + + def __init__( + self, + primary_color=[1., 1., 1., 1.], + secondary_color=[0.5, 0.5, 0.5, 1.], + **kwargs): + + self.primary_color = primary_color + self.secondary_color = secondary_color + + self.bind(stars_number=self.change_stars_number) + super().__init__(**kwargs) + + def change_stars_number(self, base_widget, value): + """ + Change the number of stars displayed. + """ + + # self.stars_number = stars_number + if self.stars_number > 0: + self.star_one_color = self.primary_color + else: + self.star_one_color = self.secondary_color + if self.stars_number > 1: + self.star_two_color = self.primary_color + else: + self.star_two_color = self.secondary_color + if self.stars_number > 2: + self.star_three_color = self.primary_color + else: + self.star_three_color = self.secondary_color diff --git a/screens/free_mode.kv b/screens/free_mode.kv index 17af9ee..61de5ae 100644 --- a/screens/free_mode.kv +++ b/screens/free_mode.kv @@ -24,3 +24,7 @@ pos_hint: {"bottom":0,"left":0} selected: "home" + ThreeStars: + size_hint: (0.7,0.15) + pos_hint:{"center_x":0.5,"center_y":0.5} + stars_number: 2 \ No newline at end of file diff --git a/screens/free_mode.py b/screens/free_mode.py index 2e6fa1c..02b7d72 100644 --- a/screens/free_mode.py +++ b/screens/free_mode.py @@ -15,7 +15,6 @@ ) from tools.kivy_tools import ( ImprovedScreen, - ImageButton ) diff --git a/screens/home.kv b/screens/home.kv index fbf573a..2489cf1 100644 --- a/screens/home.kv +++ b/screens/home.kv @@ -28,6 +28,7 @@ size_hint: (0.5,0.1) pos_hint: {"center_x":0.5, "center_y":0.6} text:"Free Mode" + release_function: root.open_free_mode CustomButton: size_hint: (0.5,0.1) diff --git a/screens/home.py b/screens/home.py index d54321b..6f48717 100644 --- a/screens/home.py +++ b/screens/home.py @@ -34,3 +34,9 @@ def __init__(self, **kwargs) -> None: back_image_path=PATH_BACKGROUNDS + THEMES_DICT[current_background_theme]["image"], **kwargs) + + def open_free_mode(self): + """ + Open the free mode screen. + """ + self.manager.current = "free_mode" diff --git a/screens/opening.py b/screens/opening.py index eb07dc1..b7a6284 100644 --- a/screens/opening.py +++ b/screens/opening.py @@ -59,7 +59,8 @@ def load_kv_files(self, *_): HomeScreen, SettingsScreen, ProfileScreen, - CustomizationScreen + CustomizationScreen, + FreeModeScreen ) screen_files = [file for file in os.listdir( @@ -76,6 +77,7 @@ def load_kv_files(self, *_): self.SettingsScreen = SettingsScreen self.ProfileScreen = ProfileScreen self.CustomizationScreen = CustomizationScreen + self.FreeModeScreen = FreeModeScreen Clock.schedule_once(self.load_other_screens) @@ -93,4 +95,6 @@ def load_other_screens(self, *args): self.manager.add_widget(profile_screen) customization_screen = self.CustomizationScreen(name="customization") self.manager.add_widget(customization_screen) + free_mode_screen = self.FreeModeScreen(name="free_mode") + self.manager.add_widget(free_mode_screen) Clock.schedule_once(self.switch_to_menu)