diff --git a/main.kv b/main.kv index e13bb3a..a64a9d5 100644 --- a/main.kv +++ b/main.kv @@ -13,3 +13,4 @@ WindowManager: # name: "achievements" # TutorialScreen: # name: "tutorial" + \ No newline at end of file diff --git a/main.py b/main.py index 713d12d..0ccd3e5 100644 --- a/main.py +++ b/main.py @@ -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 ### @@ -43,7 +43,7 @@ FPS, MSAA_LEVEL ) -from screens import OpeningScreen +import screens.opening print("Local packages loaded") @@ -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") @@ -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") diff --git a/resources/images/share_button.png b/resources/images/share_button.png new file mode 100644 index 0000000..13204ce Binary files /dev/null and b/resources/images/share_button.png differ diff --git a/screens/opening.py b/screens/opening.py index ad8cf87..efc7454 100644 --- a/screens/opening.py +++ b/screens/opening.py @@ -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") @@ -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 ### @@ -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) diff --git a/tools/kivy_tools/extended_style.kv b/tools/kivy_tools/extended_style.kv index c0e2222..6160e36 100644 --- a/tools/kivy_tools/extended_style.kv +++ b/tools/kivy_tools/extended_style.kv @@ -107,19 +107,19 @@ color: pink_color allow_stretch: True -: - 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 +# : +# 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 ############### @@ -194,20 +194,20 @@ #################### -: - 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' +# : +# 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' ############## @@ -215,22 +215,22 @@ ############## -: - 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)) +# : +# 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)) ################ @@ -238,50 +238,50 @@ ################ -: - 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)) - -: - 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" +# : +# 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)) + +# : +# 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 ### ############# -: - size: root.size_popup - pos_hint: {"x":0, "y":0} +# : +# 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) ############### @@ -289,12 +289,12 @@ ############### -: - 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 +# : +# 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 diff --git a/tools/kivy_tools/screen.kv b/tools/kivy_tools/screen.kv index 1289d30..849b75c 100644 --- a/tools/kivy_tools/screen.kv +++ b/tools/kivy_tools/screen.kv @@ -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 \ No newline at end of file + keep_ratio: True + anim_delay: 0.0166 \ No newline at end of file