-
-
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.
start creating the home screen with the bottom bar
- Loading branch information
1 parent
8ba676e
commit c57115a
Showing
25 changed files
with
305 additions
and
22 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,3 @@ | ||
#:kivy 2.2.1 | ||
|
||
WindowManager: |
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
File renamed without changes
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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
{ | ||
"theme_1": { | ||
"japanese_1": { | ||
"primary": "", | ||
"secondary": "", | ||
"image": "" | ||
"image": "pagode.jpg", | ||
"price": 0, | ||
"name": "" | ||
} | ||
} |
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,9 @@ | ||
""" | ||
Package to manage the screens of the application | ||
""" | ||
|
||
############### | ||
### Imports ### | ||
############### | ||
|
||
from screens.home import HomeScreen |
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,6 @@ | ||
""" | ||
Package to manage the custom widgets included in the screens. | ||
""" | ||
|
||
|
||
from screens.custom_widgets.bottom_bar import BottomBar |
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,47 @@ | ||
#:kivy 2.2.1 | ||
#:import PATH_IMAGES tools.path.PATH_IMAGES | ||
|
||
<BottomBar>: | ||
|
||
canvas.before: | ||
# Background | ||
Color: | ||
rgba: self.background_color | ||
Rectangle: | ||
pos: self.pos | ||
size: self.size | ||
|
||
# Separation bar | ||
Color: | ||
rgba: self.separation_color | ||
Rectangle: | ||
pos: (0,self.height) | ||
size: (self.width, self.separation_height) | ||
|
||
# Home button | ||
ImageButton: | ||
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" | ||
|
||
# Customization button | ||
ImageButton: | ||
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" | ||
|
||
# Profile button | ||
ImageButton: | ||
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" | ||
|
||
# Settings button | ||
ImageButton: | ||
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" |
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,22 @@ | ||
""" | ||
Module to create the bottom bar with the buttons. | ||
""" | ||
|
||
############### | ||
### Imports ### | ||
############### | ||
|
||
from kivy.uix.relativelayout import RelativeLayout | ||
from tools.kivy_tools import ImageButton | ||
|
||
############# | ||
### Class ### | ||
############# | ||
|
||
|
||
class BottomBar(RelativeLayout): | ||
background_color = (0, 0, 0, 0.5) | ||
separation_color = (1, 1, 1, 1) | ||
separation_height = 3 | ||
button_width = 0.15 | ||
button_height = 0.7 |
Empty file.
Empty file.
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,24 @@ | ||
#: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 | ||
|
||
|
||
<HomeScreen>: | ||
Label: | ||
text: "Linconym" | ||
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} |
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,32 @@ | ||
""" | ||
Module to create the home screen. | ||
""" | ||
|
||
############### | ||
### Imports ### | ||
############### | ||
|
||
from tools.path import ( | ||
PATH_BACKGROUNDS | ||
) | ||
from tools.constants import ( | ||
USER_DATA, | ||
THEMES_DICT | ||
) | ||
from screens.custom_widgets import BottomBar | ||
from tools.kivy_tools import ImprovedScreen, ImageButton | ||
|
||
|
||
############# | ||
### Class ### | ||
############# | ||
|
||
|
||
class HomeScreen(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) |
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,99 @@ | ||
""" | ||
Module for the opening screen. | ||
""" | ||
|
||
############### | ||
### Imports ### | ||
############### | ||
|
||
import os | ||
from threading import Thread | ||
from tools.kivy_tools import ImprovedScreen | ||
from tools.path import ( | ||
PATH_IMAGES | ||
) | ||
from kivy.clock import Clock | ||
from kivy.lang import Builder | ||
from kivy.uix.label import Label | ||
|
||
|
||
class OpeningScreen(ImprovedScreen): | ||
""" | ||
Screen of Opening. | ||
""" | ||
|
||
def __init__(self, **kw): | ||
super().__init__( | ||
back_image_path=PATH_IMAGES + "opening.jpg", | ||
**kw) | ||
self.opacity_state = -1 | ||
self.opacity_rate = 0.03 | ||
self.label = Label(text="", pos_hint={ | ||
"bottom": 1, "left": 1}) | ||
self.add_widget(self.label) | ||
|
||
def update(self, *args): | ||
self.label.opacity += self.opacity_state * self.opacity_rate | ||
if self.label.opacity < 0 or self.label.opacity > 1: | ||
self.opacity_state = -self.opacity_state | ||
|
||
def on_enter(self, *args): | ||
print("enter opening screen") | ||
# Schedule the update for the text opacity effect | ||
Clock.schedule_interval(self.update, 1 / 60) | ||
|
||
return super().on_enter(*args) | ||
|
||
def on_pre_leave(self, *args): | ||
# Unschedule the clock update | ||
Clock.unschedule(self.update, 1 / 60) | ||
|
||
return super().on_leave(*args) | ||
|
||
def launch_thread(self, *_): | ||
thread = Thread(target=self.load_kv_files) | ||
thread.start() | ||
|
||
def load_kv_files(self, *_): | ||
from screens import ( | ||
HomeScreen) | ||
|
||
screen_files = [file for file in os.listdir( | ||
"screens") if file.endswith(".kv")] | ||
for file in screen_files: | ||
Builder.load_file(f"screens/{file}", encoding="utf-8") | ||
widget_files = [file for file in os.listdir( | ||
"screens/custom_widgets") if file.endswith(".kv")] | ||
for file in widget_files: | ||
Builder.load_file( | ||
f"screens/custom_widgets/{file}", encoding="utf-8") | ||
|
||
self.HomeScreen = HomeScreen | ||
|
||
Clock.schedule_once(self.load_other_screens) | ||
|
||
def switch_to_menu(self, *args): | ||
self.manager.current = "home" | ||
|
||
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" | ||
Clock.schedule_once(self.switch_to_menu) |
Empty file.
Empty file.
Empty file.
Empty file.
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
Oops, something went wrong.