diff --git a/data.json b/data.json index 6c93771..8a9da3f 100644 --- a/data.json +++ b/data.json @@ -8,7 +8,7 @@ "settings": { "music_volume": 0.4577702702702703, "sound_volume": 0.7554835493519442, - "current_theme_image": "lake", + "current_theme_image": "japanese_1", "current_music": "kids_party", "current_theme_colors": "japanese_1" }, diff --git a/screens/__init__.py b/screens/__init__.py index 22c56ca..e78cfda 100644 --- a/screens/__init__.py +++ b/screens/__init__.py @@ -23,3 +23,4 @@ from screens.customization import CustomizationScreen from screens.settings import SettingsScreen from screens.free_mode import FreeModeScreen +from screens.boosters import BoostersScreen diff --git a/screens/boosters.kv b/screens/boosters.kv new file mode 100644 index 0000000..7ff9e5d --- /dev/null +++ b/screens/boosters.kv @@ -0,0 +1,43 @@ +#:kivy 2.2.1 +#:import PATH_IMAGES tools.path.PATH_IMAGES +#:import PATH_BADGES tools.path.PATH_BADGES +#:import PATH_TITLE_FONT tools.path.PATH_TITLE_FONT +#:import TITLE_FONT_SIZE tools.constants.TITLE_FONT_SIZE +#:import TITLE_OUTLINE_WIDTH tools.constants.TITLE_OUTLINE_WIDTH +#:import TITLE_OUTLINE_COLOR tools.constants.TITLE_OUTLINE_COLOR +#:import PATH_TEXT_FONT tools.path.PATH_TEXT_FONT +#:import TEXT_FONT_COLOR tools.constants.TEXT_FONT_COLOR +#:import BOTTOM_BAR_HEIGHT tools.constants.BOTTOM_BAR_HEIGHT + + +: + Label: + text: "Boosters" + font_name: PATH_TITLE_FONT + font_size: TITLE_FONT_SIZE * root.font_ratio + pos_hint: {"center_x":0.5, "center_y":0.9} + outline_width: TITLE_OUTLINE_WIDTH + outline_color: TITLE_OUTLINE_COLOR + color: TEXT_FONT_COLOR + + RoundedButtonImage: + image_path: PATH_IMAGES + "left_arrow.png" + pos_hint: POS_HINT_BACK_ARROW + size_hint: (0.1, None) + height: self.width + colors: root.primary_color + on_release: root.go_backwards() + + BottomBar: + size_hint: (1, BOTTOM_BAR_HEIGHT) + pos_hint: {"bottom":0,"left":0} + selected: "none" + + # Coins counter + CoinsCounter: + size_hint: (0.4, 0.07) + pos_hint: {"center_x":0.5, "center_y":0.81} + font_ratio: root.font_ratio + coins_count: root.coins_count + display_plus: False + disable_button: True diff --git a/screens/boosters.py b/screens/boosters.py new file mode 100644 index 0000000..eb6ad5d --- /dev/null +++ b/screens/boosters.py @@ -0,0 +1,61 @@ +""" +Module to create the profile screen. +""" + +############### +### Imports ### +############### + +### Kivy imports ### + +from kivy.properties import ( + ColorProperty, + NumericProperty, + StringProperty +) + +### Local imports ### + +from tools.path import ( + PATH_BACKGROUNDS +) +from tools.constants import ( + USER_DATA, + THEMES_DICT +) +from tools.kivy_tools import ( + ImprovedScreen +) + + +############# +### Class ### +############# + + +class BoostersScreen(ImprovedScreen): + """ + Class to manage the screen with the coins boosters. + """ + + coins_count = NumericProperty() + primary_color = ColorProperty((0, 0, 0, 1)) + former_screen = StringProperty() + + def __init__(self, **kwargs) -> None: + current_theme_image = USER_DATA.settings["current_theme_image"] + super().__init__( + back_image_path=PATH_BACKGROUNDS + + THEMES_DICT[current_theme_image]["image"], + **kwargs) + + def on_enter(self, *args): + self.coins_count = USER_DATA.user_profile["coins"] + current_theme_image = USER_DATA.settings["current_theme_image"] + self.primary_color = THEMES_DICT[current_theme_image]["primary"] + self.set_back_image_path( + PATH_BACKGROUNDS + THEMES_DICT[current_theme_image]["image"]) + return super().on_enter(*args) + + def go_backwards(self): + self.manager.current = self.former_screen diff --git a/screens/custom_widgets/__init__.py b/screens/custom_widgets/__init__.py index 54f76de..ee5f084 100644 --- a/screens/custom_widgets/__init__.py +++ b/screens/custom_widgets/__init__.py @@ -12,7 +12,7 @@ from screens.custom_widgets.bottom_bar import BottomBar from screens.custom_widgets.act_button import ActButton from screens.custom_widgets.buy_button import BuyButton -from screens.custom_widgets.coins_count import CoinsCounter +from screens.custom_widgets.coins_counter import CoinsCounter from screens.custom_widgets.experience_count import ExperienceCounter from screens.custom_widgets.theme_layout import ThemeLayout from screens.custom_widgets.rounded_button_image import RoundedButtonImage diff --git a/screens/custom_widgets/coins_count.kv b/screens/custom_widgets/coins_counter.kv similarity index 85% rename from screens/custom_widgets/coins_count.kv rename to screens/custom_widgets/coins_counter.kv index 073f351..6c74d01 100644 --- a/screens/custom_widgets/coins_count.kv +++ b/screens/custom_widgets/coins_counter.kv @@ -16,7 +16,7 @@ Label: text: root.coins_count_text font_size: root.font_ratio * root.font_size - pos_hint: {"center_x":0.5, "center_y":0.5} + pos_hint: {"center_x":0.5, "center_y":0.5} if root.display_plus else {"center_x":0.65, "center_y":0.5} size_hint: (1, None) font_name: root.text_font_name line_height: 1 @@ -39,3 +39,4 @@ font_name: root.text_font_name line_height: 1 color: (0,0,0,1) + opacity: 1 if root.display_plus else 0 diff --git a/screens/custom_widgets/coins_count.py b/screens/custom_widgets/coins_counter.py similarity index 82% rename from screens/custom_widgets/coins_count.py rename to screens/custom_widgets/coins_counter.py index c3bb880..dd167d9 100644 --- a/screens/custom_widgets/coins_count.py +++ b/screens/custom_widgets/coins_counter.py @@ -11,7 +11,8 @@ from kivy.uix.behaviors import ButtonBehavior from kivy.properties import ( StringProperty, - NumericProperty + NumericProperty, + BooleanProperty ) ### Local imports ### @@ -39,11 +40,12 @@ class CoinsCounter(ButtonBehavior, RelativeLayout): coins_count = NumericProperty(-1) font_size = NumericProperty() font_ratio = NumericProperty(1) + display_plus = BooleanProperty(True) + disable_button = BooleanProperty(False) def __init__( self, coins_count: int = 0, - button_mode=True, text_font_name=PATH_TEXT_FONT, font_size=COINS_COUNT_FONT_SIZE, release_function=lambda: 1 + 1, @@ -52,22 +54,26 @@ def __init__( if font_ratio is not None: self.font_ratio = font_ratio super().__init__(**kwargs) - self.button_mode = button_mode self.release_function = release_function self.always_release = True self.bind(coins_count=self.update_coins_count) + self.bind(display_plus=self.bind_function) + self.bind(disable_button=self.bind_function) self.coins_count = coins_count self.text_font_name = text_font_name self.font_size = font_size + def bind_function(self, base_widget, value): + pass + def update_coins_count(self, base_widget, value): self.coins_count_text = str(self.coins_count) def on_press(self): - if self.button_mode: + if not self.disable_button: self.opacity = OPACITY_ON_BUTTON_PRESS def on_release(self): - if self.button_mode: + if not self.disable_button: self.release_function() self.opacity = 1 diff --git a/screens/customization.kv b/screens/customization.kv index 2f81fe5..01e08f3 100644 --- a/screens/customization.kv +++ b/screens/customization.kv @@ -39,6 +39,7 @@ pos_hint: {"center_x":0.5, "center_y":0.81} font_ratio: root.font_ratio coins_count: root.coins_count + release_function: root.go_to_boosters # Theme scrollview ScrollView: diff --git a/screens/customization.py b/screens/customization.py index e455eed..854b4fe 100644 --- a/screens/customization.py +++ b/screens/customization.py @@ -58,6 +58,8 @@ def __init__(self, **kwargs) -> None: def on_pre_enter(self, *args): self.coins_count = USER_DATA.user_profile["coins"] + current_theme_image = USER_DATA.settings["current_theme_image"] + self.primary_color = THEMES_DICT[current_theme_image]["primary"] return super().on_pre_enter(*args) def on_resize(self, *args): @@ -69,6 +71,10 @@ def go_backwards(self): # TODO to change self.manager.current = "home" + def go_to_boosters(self): + self.manager.get_screen("boosters").former_screen = "customization" + self.manager.current = "boosters" + def update_coins(self): self.coins_count = USER_DATA.user_profile["coins"] diff --git a/screens/free_mode.py b/screens/free_mode.py index d0582a5..308735c 100644 --- a/screens/free_mode.py +++ b/screens/free_mode.py @@ -50,6 +50,7 @@ def __init__(self, **kwargs) -> None: def on_enter(self, *args): current_theme_image = USER_DATA.settings["current_theme_image"] + self.primary_color = THEMES_DICT[current_theme_image]["primary"] self.set_back_image_path( PATH_BACKGROUNDS + THEMES_DICT[current_theme_image]["image"]) return super().on_enter(*args) diff --git a/screens/opening.py b/screens/opening.py index b7a6284..0e8d8f0 100644 --- a/screens/opening.py +++ b/screens/opening.py @@ -60,7 +60,8 @@ def load_kv_files(self, *_): SettingsScreen, ProfileScreen, CustomizationScreen, - FreeModeScreen + FreeModeScreen, + BoostersScreen ) screen_files = [file for file in os.listdir( @@ -78,6 +79,7 @@ def load_kv_files(self, *_): self.ProfileScreen = ProfileScreen self.CustomizationScreen = CustomizationScreen self.FreeModeScreen = FreeModeScreen + self.BoostersScreen = BoostersScreen Clock.schedule_once(self.load_other_screens) @@ -97,4 +99,6 @@ def load_other_screens(self, *args): self.manager.add_widget(customization_screen) free_mode_screen = self.FreeModeScreen(name="free_mode") self.manager.add_widget(free_mode_screen) + boosters_screen = self.BoostersScreen(name="boosters") + self.manager.add_widget(boosters_screen) Clock.schedule_once(self.switch_to_menu) diff --git a/screens/profile.kv b/screens/profile.kv index 9e65ff3..c25f4aa 100644 --- a/screens/profile.kv +++ b/screens/profile.kv @@ -72,3 +72,4 @@ pos_hint: {"center_x":0.5, "center_y":0.61} font_ratio: root.font_ratio coins_count: root.coins_count + release_function: root.go_to_boosters diff --git a/screens/profile.py b/screens/profile.py index dfb27b2..4157353 100644 --- a/screens/profile.py +++ b/screens/profile.py @@ -58,3 +58,7 @@ def on_enter(self, *args): self.set_back_image_path( PATH_BACKGROUNDS + THEMES_DICT[current_theme_image]["image"]) return super().on_enter(*args) + + def go_to_boosters(self): + self.manager.get_screen("boosters").former_screen = "profile" + self.manager.current = "boosters"