Skip to content

Commit

Permalink
implement the other screens
Browse files Browse the repository at this point in the history
  • Loading branch information
LupaDevStudio committed Dec 14, 2023
1 parent 6a5366b commit 3a1b57d
Show file tree
Hide file tree
Showing 10 changed files with 229 additions and 21 deletions.
3 changes: 3 additions & 0 deletions screens/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
###############

from screens.home import HomeScreen
from screens.profile import ProfileScreen
from screens.customization import CustomizationScreen
from screens.settings import SettingsScreen
8 changes: 4 additions & 4 deletions screens/custom_widgets/bottom_bar.kv
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,28 @@
source: PATH_IMAGES + "home.png"
size_hint: root.button_width, root.button_height
pos_hint: {"center_x":0.125, "center_y":0.5}
# release_function: root.manager.current = "home"
release_function: root.open_home

# Customization button
ImageButton:
id: customization_button
source: PATH_IMAGES + "customization.png"
size_hint: root.button_width, root.button_height
pos_hint: {"center_x":0.375, "center_y":0.5}
# release_function: root.manager.current = "customization"
release_function: root.open_customization

# Profile button
ImageButton:
id: profile_button
source: PATH_IMAGES + "profile.png"
size_hint: root.button_width, root.button_height
pos_hint: {"center_x":0.625, "center_y":0.5}
# release_function: root.manager.current = "customization"
release_function: root.open_profile

# Settings button
ImageButton:
id: settings_button
source: PATH_IMAGES + "settings.png"
size_hint: root.button_width, root.button_height
pos_hint: {"center_x":0.875, "center_y":0.5}
# release_function: root.manager.current = "customization"
release_function: root.open_settings
16 changes: 16 additions & 0 deletions screens/custom_widgets/bottom_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,19 @@ def on_kv_post(self, base_widget):
(self.ids[self.selected + "_button"].size_hint[0] * 1.2,
self.ids[self.selected + "_button"].size_hint[1] * 1.2)
return super().on_kv_post(base_widget)

def open_home(self):
if self.selected != "home":
self.parent.manager.current = "home"

def open_settings(self):
if self.selected != "settings":
self.parent.manager.current = "settings"

def open_customization(self):
if self.selected != "customization":
self.parent.manager.current = "customization"

def open_profile(self):
if self.selected != "profile":
self.parent.manager.current = "profile"
26 changes: 26 additions & 0 deletions screens/customization.kv
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#:kivy 2.2.1
#:import PATH_IMAGES tools.path.PATH_IMAGES
#: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


<CustomizationScreen>:
Label:
text: "TO DO"
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

BottomBar:
size_hint: (1, BOTTOM_BAR_HEIGHT)
pos_hint: {"bottom":0,"left":0}
selected: "customization"

38 changes: 38 additions & 0 deletions screens/customization.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""
Module to create the customization screen.
"""

###############
### Imports ###
###############

from tools.path import (
PATH_BACKGROUNDS
)
from tools.constants import (
USER_DATA,
THEMES_DICT
)
from screens.custom_widgets import (
BottomBar,
CustomButton
)
from tools.kivy_tools import (
ImprovedScreen,
ImageButton
)


#############
### Class ###
#############


class CustomizationScreen(ImprovedScreen):

def __init__(self, **kwargs) -> None:
current_background_theme = USER_DATA.settings["current_background_theme"]
super().__init__(
back_image_path=PATH_BACKGROUNDS +
THEMES_DICT[current_background_theme]["image"],
**kwargs)
31 changes: 14 additions & 17 deletions screens/opening.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ def launch_thread(self, *_):

def load_kv_files(self, *_):
from screens import (
HomeScreen)
HomeScreen,
SettingsScreen,
ProfileScreen,
CustomizationScreen
)

screen_files = [file for file in os.listdir(
"screens") if file.endswith(".kv")]
Expand All @@ -69,6 +73,9 @@ def load_kv_files(self, *_):
f"screens/custom_widgets/{file}", encoding="utf-8")

self.HomeScreen = HomeScreen
self.SettingsScreen = SettingsScreen
self.ProfileScreen = ProfileScreen
self.CustomizationScreen = CustomizationScreen

Clock.schedule_once(self.load_other_screens)

Expand All @@ -80,20 +87,10 @@ def load_other_screens(self, *args):
### Load the kv files of the screens ###
home_screen = self.HomeScreen(name="home")
self.manager.add_widget(home_screen)
# game_screen = self.GameScreen(name="game")
# self.manager.add_widget(game_screen)
# settings_screen = self.SettingsScreen(name="settings")
# self.manager.add_widget(settings_screen)
# game_over_screen = self.GameOverScreen(name="game_over")
# self.manager.add_widget(game_over_screen)
# achievements_screen = self.AchievementsScreen(name="achievements")
# self.manager.add_widget(achievements_screen)
# tutorial_screen = self.TutorialScreen(name="tutorial")
# self.manager.add_widget(tutorial_screen)
# help_screen = self.HelpScreen(name="help")
# self.manager.add_widget(help_screen)
# Preload screens
# Clock.schedule_once(self.manager.get_screen("game").preload)
# Clock.schedule_once(self.manager.get_screen("game_over").preload)
# self.manager.current = "menu"
settings_screen = self.SettingsScreen(name="settings")
self.manager.add_widget(settings_screen)
profile_screen = self.ProfileScreen(name="profile")
self.manager.add_widget(profile_screen)
customization_screen = self.CustomizationScreen(name="customization")
self.manager.add_widget(customization_screen)
Clock.schedule_once(self.switch_to_menu)
26 changes: 26 additions & 0 deletions screens/profile.kv
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#:kivy 2.2.1
#:import PATH_IMAGES tools.path.PATH_IMAGES
#: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


<ProfileScreen>:
Label:
text: "TO DO"
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

BottomBar:
size_hint: (1, BOTTOM_BAR_HEIGHT)
pos_hint: {"bottom":0,"left":0}
selected: "profile"

38 changes: 38 additions & 0 deletions screens/profile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""
Module to create the profile screen.
"""

###############
### Imports ###
###############

from tools.path import (
PATH_BACKGROUNDS
)
from tools.constants import (
USER_DATA,
THEMES_DICT
)
from screens.custom_widgets import (
BottomBar,
CustomButton
)
from tools.kivy_tools import (
ImprovedScreen,
ImageButton
)


#############
### Class ###
#############


class ProfileScreen(ImprovedScreen):

def __init__(self, **kwargs) -> None:
current_background_theme = USER_DATA.settings["current_background_theme"]
super().__init__(
back_image_path=PATH_BACKGROUNDS +
THEMES_DICT[current_background_theme]["image"],
**kwargs)
26 changes: 26 additions & 0 deletions screens/settings.kv
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#:kivy 2.2.1
#:import PATH_IMAGES tools.path.PATH_IMAGES
#: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


<SettingsScreen>:
Label:
text: "TO DO"
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

BottomBar:
size_hint: (1, BOTTOM_BAR_HEIGHT)
pos_hint: {"bottom":0,"left":0}
selected: "settings"

38 changes: 38 additions & 0 deletions screens/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""
Module to create the settings screen.
"""

###############
### Imports ###
###############

from tools.path import (
PATH_BACKGROUNDS
)
from tools.constants import (
USER_DATA,
THEMES_DICT
)
from screens.custom_widgets import (
BottomBar,
CustomButton
)
from tools.kivy_tools import (
ImprovedScreen,
ImageButton
)


#############
### Class ###
#############


class SettingsScreen(ImprovedScreen):

def __init__(self, **kwargs) -> None:
current_background_theme = USER_DATA.settings["current_background_theme"]
super().__init__(
back_image_path=PATH_BACKGROUNDS +
THEMES_DICT[current_background_theme]["image"],
**kwargs)

0 comments on commit 3a1b57d

Please sign in to comment.