Skip to content

Commit

Permalink
design the settings screen
Browse files Browse the repository at this point in the history
  • Loading branch information
LupaDevStudio committed Nov 4, 2023
1 parent 8c398b8 commit b8c2da2
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 165 deletions.
4 changes: 2 additions & 2 deletions screens/achievements.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class AchievementsScreen(ImprovedScreen):
def __init__(self, **kw):
super().__init__(
font_name=PATH_TEXT_FONT,
back_image_path=PATH_IMAGES + "collection_background.png",
back_image_path=PATH_IMAGES + "collection_background.jpg",
**kw)

my_highscore = StringProperty("")
Expand Down Expand Up @@ -79,7 +79,7 @@ def build_scroll_view(self):
path_image = PATH_IMAGES + "ending_unknown.png"
title_ending = "???"
if bool_ending:
path_image = PATH_IMAGES + "ending_" + code_ending + ".png"
path_image = PATH_IMAGES + "ending_" + code_ending + ".jpg"
title_ending = TEXT.ending[code_ending]["title"]

name_label = Button(
Expand Down
6 changes: 3 additions & 3 deletions screens/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class GameScreen(ImprovedScreen):

def __init__(self, **kw):
super().__init__(
back_image_path=PATH_IMAGES + "day_camp.png",
back_image_path=PATH_IMAGES + "day_camp.jpg",
font_name=PATH_TEXT_FONT,
** kw)

Expand Down Expand Up @@ -111,11 +111,11 @@ def preload(self, *_):

# Load the night camp background
self.night_camp_background = Loader.image(
PATH_IMAGES + "night_camp.png")
PATH_IMAGES + "night_camp.jpg")

# Load the day camp background
self.day_camp_background = Loader.image(
PATH_IMAGES + "day_camp.png")
PATH_IMAGES + "day_camp.jpg")

# Load the musics and sounds
new_musics = load_sounds(
Expand Down
2 changes: 1 addition & 1 deletion screens/game_over.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class GameOverScreen(ImprovedScreen):

def __init__(self, **kw):
super().__init__(
back_image_path=PATH_IMAGES + "game_over_background.png",
back_image_path=PATH_IMAGES + "game_over_background.jpg",
font_name=PATH_TEXT_FONT,
**kw)
self.credits_text = TEXT.game_over["credits"]
Expand Down
4 changes: 4 additions & 0 deletions screens/menu.kv
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
font_size: 80*root.font_ratio
font_name: root.font_name
color: TITLE_FONT_COLOR
outline_width: 2
outline_color: (1,1,1,1)

Label:
id: start_label
Expand All @@ -23,6 +25,8 @@
font_size: 50*root.font_ratio
font_name: root.font_name
color: TITLE_FONT_COLOR
outline_width: 2
outline_color: (1,1,1,1)
Button:
size_hint: 1, 0.25
pos_hint: {"center_x": 0.5, "center_y": 0.45}
Expand Down
5 changes: 3 additions & 2 deletions screens/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class MenuScreen(ImprovedScreen):
def __init__(self, **kw):

super().__init__(
back_image_path=PATH_IMAGES + "menu_background.png",
back_image_path=PATH_IMAGES + "menu_background.jpg",
font_name=PATH_TITLE_FONT,
**kw)
self.opacity_state = -1
Expand All @@ -46,7 +46,8 @@ def on_enter(self, *args):

def on_pre_leave(self, *args):
# Stop the title music
music_mixer.stop()
if self.manager.current != "settings":
music_mixer.stop()

# Unschedule the clock update
Clock.unschedule(self.update, 1 / FPS)
Expand Down
194 changes: 63 additions & 131 deletions screens/settings.kv
Original file line number Diff line number Diff line change
@@ -1,140 +1,72 @@
#:kivy 2.1.0
#:import PATH_IMAGES tools.path.PATH_IMAGES
#:import TEXT_FONT_COLOR tools.constants.TEXT_FONT_COLOR
#:import LANGUAGES_LIST tools.constants.LANGUAGES_LIST

<SettingsScreen>:

# Image:
# id: back_image
# source: root.path_back_image
# size_hint: None,None
# width: root.width_back_image
# height: root.height_back_image
# pos_hint: {"center_x":0.5,"center_y":0.5}
# allow_stretch: True
# keep_ratio: True

# Image:
# source: root.path_images + "back_arrow.png"
# size_hint: None, 0.1
# pos_hint: {"x":0.025, "top": 0.975}
# allow_stretch: True
# width: self.height
# Button:
# size_hint: None, 0.1
# width: self.height
# pos_hint: {"x":0.025, "top": 0.975}
# background_color: (0, 0, 0, 0)
# on_release:
# root.manager.init_screen("menu")
ImageWithTextButton:
source: PATH_IMAGES + "back_arrow.png"
size_hint: None, 0.15
pos_hint: {"x":0.025, "top": 1}
allow_stretch: True
width: self.height
release_function: root.go_to_menu

# Label:
# text: root.high_score
# bold: True
# color: root.manager.color_label
# pos_hint: {"right":1, "top":1}
# size_hint: 0.2, 0.1
# font_name: root.font
# font_size: 30*root.font_ratio
Slider:
id: sound_slider
min: 0
max: 1
value: 0.5
pos_hint: {"center_x":0.5, "center_y": 0.6}
size_hint: 0.5, 0.1

Label:
text: "Sound volume"
pos_hint: {"center_x":0.5, "center_y": 0.65}
font_size: 25*root.font_ratio
color: TEXT_FONT_COLOR
outline_width: 2
outline_color: (1,1,1,1)

# # KEYBOARD CONFIGURATION
Slider:
id: music_slider
min: 0
max: 1
value: 0.5
pos_hint: {"center_x":0.5, "center_y": 0.8}
size_hint: 0.5, 0.1

# Button:
# id: top_button
# text: "Move up"
# size_hint: 0.15, 0.1
# pos_hint: {"x":0.45, "y":0.7}
# color: root.manager.gray_color
# font_name: root.font
# font_size: 20*root.font_ratio
# on_release:
# root.select_next_key("top")
# Button:
# id: top_key_input
# text: root.top_key
# size_hint: 0.1, 0.1
# pos_hint: {"x":0.65, "y": 0.7}
# disabled: True
# font_name: root.font
# font_size: 20*root.font_ratio
# color: root.manager.color_label
Label:
text: "Music volume"
pos_hint: {"center_x":0.5, "center_y": 0.85}
font_size: 25*root.font_ratio
color: TEXT_FONT_COLOR
outline_width: 2
outline_color: (1,1,1,1)

# Button:
# id: left_button
# text: "Move left"
# size_hint: 0.15, 0.1
# pos_hint: {"x":0.45, "y":0.55}
# color: root.manager.gray_color
# font_size: 20*root.font_ratio
# font_name: root.font
# on_release:
# root.select_next_key("left")
# Button:
# id: left_key_input
# text: root.left_key
# size_hint: 0.1, 0.1
# pos_hint: {"x":0.65, "y": 0.55}
# disabled: True
# font_name: root.font
# font_size: 20*root.font_ratio
# color: root.manager.color_label

# Button:
# id: bottom_button
# text: "Move down"
# size_hint: 0.15, 0.1
# pos_hint: {"x":0.45, "y":0.4}
# color: root.manager.gray_color
# font_size: 20*root.font_ratio
# font_name: root.font
# on_release:
# root.select_next_key("bottom")
# Button:
# id: bottom_key_input
# text: root.bottom_key
# size_hint: 0.1, 0.1
# pos_hint: {"x":0.65, "y": 0.4}
# disabled: True
# font_name: root.font
# font_size: 20*root.font_ratio
# color: root.manager.color_label


# Button:
# id: right_button
# text: "Move right"
# size_hint: 0.15, 0.1
# pos_hint: {"x":0.45, "y":0.25}
# color: root.manager.gray_color
# font_size: 20*root.font_ratio
# font_name: root.font
# on_release:
# root.select_next_key("right")
# Button:
# id: right_key_input
# text: root.right_key
# size_hint: 0.1, 0.1
# disabled: True
# font_name: root.font
# font_size: 20*root.font_ratio
# pos_hint: {"x":0.65, "y": 0.25}
# color: root.manager.color_label

# Button:
# id: interact_button
# text: "Interact"
# size_hint: 0.15, 0.1
# pos_hint: {"x":0.45, "y":0.1}
# color: root.manager.gray_color
# font_size: 20*root.font_ratio
# font_name: root.font
# on_release:
# root.select_next_key("INTERACT")
# Button:
# id: interact_key_input
# text: root.interact_key
# size_hint: 0.1, 0.1
# disabled: True
# font_name: root.font
# font_size: 20*root.font_ratio
# pos_hint: {"x":0.65, "y": 0.1}
# color: TEXT_FONT_COLOR
Spinner:
id: language_spinner
text: root.current_language
pos_hint: {"center_x":0.5, "center_y": 0.2}
size_hint: 0.3, 0.1
font_size: 20*root.font_ratio
# size_hint: None,None
# size: 100,44
values: root.values_language_list
on_press:
print("The spinner {} has values {}".format(self, self.values))

TextInput:
id: code_input
text: "Enter your code"
pos_hint: {"center_x":0.4, "center_y": 0.4}
size_hint: 0.4, 0.08
font_size: 20*root.font_ratio

Button:
id: enter_code_button
text: "Validate"
pos_hint: {"center_x":0.7, "center_y": 0.4}
size_hint: 0.2, 0.08
font_size: 20*root.font_ratio
59 changes: 33 additions & 26 deletions screens/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,42 @@
# Réglage volume musique bruitage
# Désactiver les pubs


from kivy.uix.screenmanager import Screen
from kivy.properties import StringProperty, ObjectProperty, NumericProperty
from kivy.core.window import Window
from kivy.uix.spinner import Spinner
from kivy.properties import StringProperty, ObjectProperty, NumericProperty, ListProperty
from tools.path import (
PATH_TITLE_FONT,
PATH_IMAGES
PATH_IMAGES,
PATH_TEXT_FONT
)
from tools.kivy_tools import (
ImprovedScreen
)
from tools.constants import (
USER_DATA,
LANGUAGES_LIST,
DICT_LANGUAGE_CORRESPONDANCE
)


class SettingsScreen(ImprovedScreen):

current_language = StringProperty(
DICT_LANGUAGE_CORRESPONDANCE[USER_DATA.language])
values_language_list = ListProperty()

class SettingsScreen(Screen):
def __init__(self, **kw):
super().__init__(**kw)

path_images = PATH_IMAGES
font_name = PATH_TITLE_FONT
high_score = StringProperty("")
top_key = StringProperty()
left_key = StringProperty("")
bottom_key = StringProperty("")
right_key = StringProperty("")
interact_key = StringProperty("")
path_back_image = PATH_IMAGES + "settings_background.png"
font_ratio = NumericProperty(0)
width_back_image = ObjectProperty(Window.size[0])
height_back_image = ObjectProperty(Window.size[0] * 392 / 632)

def init_screen(self):
self.font_ratio = Window.size[0] / 800
self.width_back_image = Window.size[0]
self.height_back_image = Window.size[0] * 392 / 632
pass
super().__init__(
back_image_path=PATH_IMAGES + "settings_background.jpg",
font_name=PATH_TEXT_FONT,
**kw)

def on_enter(self, *args):
print(LANGUAGES_LIST)
self.values_language_list = LANGUAGES_LIST
return super().on_enter(*args)

def go_to_menu(self):
"""
Go back to the main menu.
"""
self.manager.current = "menu"
1 change: 1 addition & 0 deletions tools/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def __init__(self) -> None:
"french": "Français",
"english": "English"
}
LANGUAGES_LIST = tuple(DICT_LANGUAGE_CORRESPONDANCE.values())


class Text():
Expand Down

0 comments on commit b8c2da2

Please sign in to comment.