Skip to content

Commit

Permalink
Clean the code with go backwards + implement the visit our website + …
Browse files Browse the repository at this point in the history
…change the name of the current act
  • Loading branch information
LupaDevStudio committed Feb 1, 2024
1 parent 9ff8597 commit 3741b8d
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 31 deletions.
3 changes: 0 additions & 3 deletions screens/boosters.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,3 @@ def buy_booster(self, number: int):
None
"""
pass

def go_backwards(self):
self.manager.go_to_previous_screen()
9 changes: 0 additions & 9 deletions screens/classic_mode.kv
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#:import TEXT_FONT_COLOR tools.constants.TEXT_FONT_COLOR
#:import BOTTOM_BAR_HEIGHT tools.constants.BOTTOM_BAR_HEIGHT
#:import GAMEPLAY_DICT tools.constants.GAMEPLAY_DICT
#:import POS_HINT_BACK_ARROW tools.constants.POS_HINT_BACK_ARROW


<ClassicModeScreen>:
Expand All @@ -21,14 +20,6 @@
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}
Expand Down
7 changes: 0 additions & 7 deletions screens/classic_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,11 @@ def on_pre_enter(self, *args):
self.ACT_BUTTON_DICT[act].secondary_color = self.secondary_color
return super().on_pre_enter(*args)

# def on_leave(self, *args):
# self.ids["scrollview_layout"].clear_widgets
# return super().on_leave(*args)

def on_resize(self, *args):
for act in self.ACT_BUTTON_DICT:
self.ACT_BUTTON_DICT[act].font_ratio = self.font_ratio
return super().on_resize(*args)

def go_backwards(self):
self.manager.current = "home"

def fill_scrollview(self):
scrollview_layout = self.ids["scrollview_layout"]
# Load the widgets
Expand Down
4 changes: 0 additions & 4 deletions screens/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,6 @@ def go_to_quests_screen(self):
current_dict_kwargs=dict_kwargs,
next_dict_kwargs=dict_kwargs)

def go_backwards(self):
self.manager.get_screen("levels").current_act_id = self.current_act_id
self.manager.current = "levels"

def go_to_previous_level(self):
print("TODO go to previous level if possible")

Expand Down
20 changes: 19 additions & 1 deletion screens/levels.kv
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<LevelsScreen>:
Label:
text: "Classic Mode"
text: root.current_act_name
font_name: PATH_TITLE_FONT
font_size: TITLE_FONT_SIZE * root.font_ratio
pos_hint: {"center_x":0.5, "center_y":0.9}
Expand All @@ -24,6 +24,24 @@
pos_hint: {"bottom":0,"left":0}
selected: "none"

# Back button
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()

# Button for the quests
RoundedButtonImage:
image_path: PATH_IMAGES + "quests.png"
pos_hint: POS_HINT_RIGHT_TOP_BUTTON
size_hint: (0.1, None)
height: self.width
colors: root.primary_color
on_release: root.go_to_quests_screen()

CustomScrollview:
id: custom_scrollview
pos_hint: {"center_x":0.5, "center_y":0.475}
Expand Down
21 changes: 20 additions & 1 deletion screens/levels.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@

### Kivy imports ###

from kivy.properties import ColorProperty
from kivy.properties import (
ColorProperty,
StringProperty
)

### Local imports ###

Expand Down Expand Up @@ -39,6 +42,7 @@ class LevelsScreen(ImprovedScreen):

primary_color = ColorProperty((0, 0, 0, 1))
secondary_color = ColorProperty((0, 0, 0, 1))
current_act_name = StringProperty()

def __init__(self, **kwargs) -> None:
current_theme_image = USER_DATA.settings["current_theme_image"]
Expand All @@ -57,6 +61,7 @@ def on_pre_enter(self, *args):
self.secondary_color = THEMES_DICT[current_theme_colors]["secondary"]
self.ids.level_layout.act_id = self.current_act_id
self.ids.level_layout.build_layout()
self.current_act_name = "Act " + self.current_act_id.replace("Act", "")
return super().on_pre_enter(*args)

def on_enter(self, *args):
Expand All @@ -66,6 +71,20 @@ def on_leave(self, *args):
self.ids.level_layout.clear_widgets()
return super().on_leave(*args)

def go_to_quests_screen(self):
current_dict_kwargs = {
"current_act_id": self.current_act_id
}
next_dict_kwargs = {
"current_act_id": self.current_act_id,
"current_level_id": None
}
self.manager.go_to_next_screen(
next_screen_name="quests",
current_dict_kwargs=current_dict_kwargs,
next_dict_kwargs=next_dict_kwargs
)

def open_game_screen(self, level_id):
current_dict_kwargs = {
"current_act_id": self.current_act_id
Expand Down
3 changes: 0 additions & 3 deletions screens/quests.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,3 @@ 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_backwards(self):
self.manager.go_to_previous_screen()
1 change: 1 addition & 0 deletions screens/settings.kv
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
text: "Visit our website"
side_image_source: PATH_IMAGES + "lupa_logo.png"
font_ratio: root.font_ratio
release_function: root.open_lupa_website

Label:
text: root.version_text
Expand Down
15 changes: 15 additions & 0 deletions screens/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import os
import random
import webbrowser

### Kivy imports ###

Expand Down Expand Up @@ -97,3 +98,17 @@ def update_music_volume(self, widget, value):
music_volume = value
music_mixer.change_volume(music_volume)
USER_DATA.settings["music_volume"] = music_volume

def open_lupa_website(self):
"""
Open LupaDevStudio website.
Parameters
----------
None
Returns
-------
None
"""
webbrowser.open("https://lupadevstudio.com", 2)
3 changes: 0 additions & 3 deletions screens/themes.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ def on_resize(self, *args):
self.THEME_LAYOUT_DICT[act].font_ratio = self.font_ratio
return super().on_resize(*args)

def go_backwards(self):
self.manager.go_to_previous_screen()

def go_to_boosters(self):
self.manager.go_to_next_screen(
next_screen_name="boosters"
Expand Down
3 changes: 3 additions & 0 deletions tools/kivy_tools/screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,3 +323,6 @@ def change_background_opacity(self, *args):

def reload_kwargs(self, dict_kwargs):
pass

def go_backwards(self):
self.manager.go_to_previous_screen()

0 comments on commit 3741b8d

Please sign in to comment.