Skip to content

Commit

Permalink
another failed attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
LupaDevStudio committed Nov 30, 2023
1 parent 76f4253 commit 003b9ca
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 101 deletions.
1 change: 1 addition & 0 deletions main.kv
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ WindowManager:
# name: "achievements"
# TutorialScreen:
# name: "tutorial"

20 changes: 14 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from kivy.uix.screenmanager import ScreenManager, NoTransition, Screen
from kivy.uix.widget import Widget
from kivy.core.window import Window
from kivy.uix.image import Image
from kivy.clock import Clock
print("Kivy packages loaded")

### Module imports ###
Expand All @@ -43,7 +43,7 @@
FPS,
MSAA_LEVEL
)
from screens import OpeningScreen
import screens.opening

print("Local packages loaded")

Expand All @@ -62,9 +62,9 @@ def __init__(self, **kwargs):
super().__init__(**kwargs)
self.transition = NoTransition()
self.list_former_screens = []
opening_screen = OpeningScreen(name="opening")
self.add_widget(opening_screen)
self.current = "opening"
current_screen = Screen(name="temp")
self.add_widget(current_screen)
self.current = "temp"
print("WindowManager initialised")


Expand Down Expand Up @@ -103,8 +103,16 @@ def on_start(self):
if MOBILE_MODE:
Window.update_viewport()

# Open the menu screen
# super().on_start()

# Open the opening screen
# self.root_window.children[0].current = "menu"
opening_screen = screens.opening.OpeningScreen(name="opening")
self.root_window.children[0].add_widget(opening_screen)
self.root_window.children[0].current = "opening"

Clock.schedule_once(
self.root_window.children[0].get_screen("opening").launch_thread, 1)

print("Main app started")

Expand Down
Binary file added resources/images/share_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 10 additions & 5 deletions screens/opening.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ def __init__(self, **kw):
def on_enter(self, *args):
print("enter opening screen")
# Schedule preload of the game screen
thread = Thread(target=self.load_kv_files)
thread.start()

return super().on_enter(*args)

# def switch_to_menu(self, *args):
# self.manager.current = "menu"
def launch_thread(self, *_):
print("launch threads")
thread = Thread(target=self.load_kv_files)
thread.start()

def load_kv_files(self, *_):
print("load the screens")
Expand All @@ -62,6 +63,9 @@ def load_kv_files(self, *_):

Clock.schedule_once(self.load_other_screens)

def switch_to_menu(self, *args):
self.manager.current = "menu"

def load_other_screens(self, *args):

### Load the kv files of the screens ###
Expand All @@ -80,4 +84,5 @@ def load_other_screens(self, *args):
# 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"
# self.manager.current = "menu"
Clock.schedule_once(self.switch_to_menu, 2)
178 changes: 89 additions & 89 deletions tools/kivy_tools/extended_style.kv
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,19 @@
color: pink_color
allow_stretch: True

<ImprovedMDTextField@MDTextField>:
color_mode: "custom"
mode: "rectangle"
line_color_focus: pink_color
line_color_normal: blue_color if not self.disabled else gray_color
normal_color: blue_color
color_active: pink_color
disabled_color: gray_color
text_color_focus: black_color
text_color_normal: blue_color
hint_text_color_normal: pink_color
hint_text_color_focus: blue_color
selection_color: highlight_text_color
# <ImprovedMDTextField@MDTextField>:
# color_mode: "custom"
# mode: "rectangle"
# line_color_focus: pink_color
# line_color_normal: blue_color if not self.disabled else gray_color
# normal_color: blue_color
# color_active: pink_color
# disabled_color: gray_color
# text_color_focus: black_color
# text_color_normal: blue_color
# hint_text_color_normal: pink_color
# hint_text_color_focus: blue_color
# selection_color: highlight_text_color


###############
Expand Down Expand Up @@ -194,107 +194,107 @@
####################


<ProgressBar>:
canvas:
Color:
rgb: 1, 1, 1
BorderImage:
border: (12, 12, 12, 12)
pos: self.x, self.center_y - 12
size: self.width, 24
source: atlas_prefix + 'progressbar_background'
BorderImage:
border: [int(min(self.width * (self.value / float(self.max)) if self.max else 0, 12))] * 4
pos: self.x, self.center_y - 12
size: self.width * (self.value / float(self.max)) if self.max else 0, 24
source: atlas_prefix + 'progressbar'
# <ProgressBar>:
# canvas:
# Color:
# rgb: 1, 1, 1
# BorderImage:
# border: (12, 12, 12, 12)
# pos: self.x, self.center_y - 12
# size: self.width, 24
# source: atlas_prefix + 'progressbar_background'
# BorderImage:
# border: [int(min(self.width * (self.value / float(self.max)) if self.max else 0, 12))] * 4
# pos: self.x, self.center_y - 12
# size: self.width * (self.value / float(self.max)) if self.max else 0, 24
# source: atlas_prefix + 'progressbar'


##############
### Switch ###
##############


<Switch>:
active_norm_pos: max(0., min(1., (int(self.active) + self.touch_distance / sp(41))))
canvas:
Color:
rgb: 1, 1, 1
Rectangle:
source: atlas_prefix + 'switch-background{}'.format('_disabled' if self.disabled else '')
size: sp(83), sp(32)
pos: int(self.center_x - sp(41)), int(self.center_y - sp(16))
canvas.after:
Color:
rgb: 1, 1, 1
Rectangle:
source: atlas_prefix + 'switch-button{}'.format('_disabled' if self.disabled else '')
size: sp(43), sp(32)
pos: int(self.center_x - sp(41) + self.active_norm_pos * sp(41)), int(self.center_y - sp(16))
# <Switch>:
# active_norm_pos: max(0., min(1., (int(self.active) + self.touch_distance / sp(41))))
# canvas:
# Color:
# rgb: 1, 1, 1
# Rectangle:
# source: atlas_prefix + 'switch-background{}'.format('_disabled' if self.disabled else '')
# size: sp(83), sp(32)
# pos: int(self.center_x - sp(41)), int(self.center_y - sp(16))
# canvas.after:
# Color:
# rgb: 1, 1, 1
# Rectangle:
# source: atlas_prefix + 'switch-button{}'.format('_disabled' if self.disabled else '')
# size: sp(43), sp(32)
# pos: int(self.center_x - sp(41) + self.active_norm_pos * sp(41)), int(self.center_y - sp(16))


################
### Checkbox ###
################


<FocusableCheckBox>:
canvas:
Color:
rgba: self.color
Rectangle:
source: ((atlas_prefix + 'checkbox_radio_focus_on' if self.focus else atlas_prefix + 'checkbox_radio_disabled_on' if self.disabled else atlas_prefix + 'checkbox_radio_on') if self.active else (atlas_prefix + 'checkbox_radio_focus_off' if self.focus else atlas_prefix + 'checkbox_radio_disabled_off' if self.disabled else atlas_prefix + 'checkbox_radio_off')) if self.group else ((atlas_prefix + 'checkbox_focus_on' if self.focus else atlas_prefix + 'checkbox_disabled_on' if self.disabled else atlas_prefix + 'checkbox_on') if self.active else (atlas_prefix + 'checkbox_focus_off' if self.focus else atlas_prefix + 'checkbox_disabled_off' if self.disabled else atlas_prefix + 'checkbox_off'))
size: sp(32), sp(32)
pos: int(self.center_x - sp(16)), int(self.center_y - sp(16))

<LabelledCheckBox>:
pos_hint: root.pos_hint
FocusableCheckBox:
id: checkbox
pos_hint: {"x":0, "y":0}
size_hint: root.size_hint_cb
group: root.group
disabled: root.disabled_cb
on_active:
root.function_cb
Label:
text: root.text_label
color: root.color_label
size_hint: root.size_hint_label
pos_hint: {"x":0.1, "y":0}
text_size: self.size
halign: "left"
valign: "center"
# <FocusableCheckBox>:
# canvas:
# Color:
# rgba: self.color
# Rectangle:
# source: ((atlas_prefix + 'checkbox_radio_focus_on' if self.focus else atlas_prefix + 'checkbox_radio_disabled_on' if self.disabled else atlas_prefix + 'checkbox_radio_on') if self.active else (atlas_prefix + 'checkbox_radio_focus_off' if self.focus else atlas_prefix + 'checkbox_radio_disabled_off' if self.disabled else atlas_prefix + 'checkbox_radio_off')) if self.group else ((atlas_prefix + 'checkbox_focus_on' if self.focus else atlas_prefix + 'checkbox_disabled_on' if self.disabled else atlas_prefix + 'checkbox_on') if self.active else (atlas_prefix + 'checkbox_focus_off' if self.focus else atlas_prefix + 'checkbox_disabled_off' if self.disabled else atlas_prefix + 'checkbox_off'))
# size: sp(32), sp(32)
# pos: int(self.center_x - sp(16)), int(self.center_y - sp(16))

# <LabelledCheckBox>:
# pos_hint: root.pos_hint
# FocusableCheckBox:
# id: checkbox
# pos_hint: {"x":0, "y":0}
# size_hint: root.size_hint_cb
# group: root.group
# disabled: root.disabled_cb
# on_active:
# root.function_cb
# Label:
# text: root.text_label
# color: root.color_label
# size_hint: root.size_hint_label
# pos_hint: {"x":0.1, "y":0}
# text_size: self.size
# halign: "left"
# valign: "center"

#############
### Popup ###
#############


<ImprovedPopupLayout>:
size: root.size_popup
pos_hint: {"x":0, "y":0}
# <ImprovedPopupLayout>:
# size: root.size_popup
# pos_hint: {"x":0, "y":0}

Widget:
canvas:
Color:
rgba: root.blue_color
Rectangle:
pos: root.x, root.top
size: self.width, dp(3)
# Widget:
# canvas:
# Color:
# rgba: root.blue_color
# Rectangle:
# pos: root.x, root.top
# size: self.width, dp(3)


###############
### Tooltip ###
###############


<ToolTip>:
size_hint: None, None
size: self.texture_size[0]+5, self.texture_size[1]+5
canvas.before:
Color:
rgb: 0.2, 0.2, 0.2
Rectangle:
size: self.size
pos: self.pos
# <ToolTip>:
# size_hint: None, None
# size: self.texture_size[0]+5, self.texture_size[1]+5
# canvas.before:
# Color:
# rgb: 0.2, 0.2, 0.2
# Rectangle:
# size: self.size
# pos: self.pos
3 changes: 2 additions & 1 deletion tools/kivy_tools/screen.kv
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
opacity: root.back_image_opacity
pos_hint: {"center_x":0.5,"center_y":0.5}
allow_stretch: True
keep_ratio: True
keep_ratio: True
anim_delay: 0.0166

0 comments on commit 003b9ca

Please sign in to comment.