-
-
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.
- Loading branch information
1 parent
ceb7d93
commit b44764f
Showing
35 changed files
with
2,084 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,13 @@ | ||
# kivy v2.1.0 | ||
#:kivy 2.1.0 | ||
|
||
WindowManager: | ||
MenuScreen: | ||
name: "menu" | ||
GameScreen: | ||
name: "game" | ||
SettingsScreen: | ||
name: "settings" | ||
GameOverScreen: | ||
name: "game_over" | ||
AchievementsScreen: | ||
name: "achievements" |
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 +1,124 @@ | ||
__version__ = "2.0.0" | ||
""" | ||
Main module of the generator of dialogs. | ||
""" | ||
|
||
|
||
############### | ||
### Imports ### | ||
############### | ||
|
||
|
||
### Python imports ### | ||
|
||
import os | ||
|
||
### Kivy imports ### | ||
|
||
from kivy.app import App | ||
from kivy.uix.screenmanager import ScreenManager, NoTransition, Screen | ||
from kivy.lang import Builder | ||
from kivy.uix.widget import Widget | ||
|
||
### Module imports ### | ||
|
||
from tools.tools_constants import ( | ||
PATH_KIVY_FOLDER, | ||
PATH_IMAGES, | ||
MOBILE_MODE | ||
) | ||
from screens import ( | ||
MenuScreen, | ||
GameScreen, | ||
SettingsScreen, | ||
GameOverScreen, | ||
AchievementsScreen | ||
) | ||
from tools.tools_kivy import ( | ||
color_label, | ||
background_color, | ||
Window | ||
) | ||
from tools.tools_sound import ( | ||
music_mixer | ||
) | ||
|
||
|
||
def change_window_size(*args): | ||
global WINDOW_SIZE, SCREEN_RATIO | ||
|
||
# Compute the size of one tile in pixel | ||
WINDOW_SIZE = Window.size | ||
SCREEN_RATIO = WINDOW_SIZE[0] / WINDOW_SIZE[1] | ||
|
||
|
||
Window.bind(on_resize=change_window_size) | ||
change_window_size() | ||
|
||
# Set the fullscreen | ||
if not MOBILE_MODE: | ||
# Window.fullscreen = "auto" | ||
pass | ||
|
||
|
||
############### | ||
### General ### | ||
############### | ||
|
||
|
||
class WindowManager(ScreenManager): | ||
""" | ||
Screen manager, which allows the navigation between the different menus. | ||
""" | ||
|
||
def __init__(self, **kwargs): | ||
super().__init__(**kwargs) | ||
self.gray_color = background_color | ||
self.color_label = color_label | ||
self.transition = NoTransition() | ||
self.add_widget(Screen(name="opening")) | ||
self.current = "opening" | ||
self.list_former_screens = [] | ||
|
||
def init_screen(self, screen_name, *args): | ||
if screen_name == "game": | ||
music_mixer.play("game_music", loop=True) | ||
Window.clearcolor = self.gray_color | ||
self.current = screen_name | ||
self.get_screen(self.current).init_screen(*args) | ||
|
||
|
||
class MainApp(App, Widget): | ||
""" | ||
Main class of the application. | ||
""" | ||
|
||
def build(self): | ||
""" | ||
Build the application. | ||
Parameters | ||
---------- | ||
None | ||
Returns | ||
------- | ||
None | ||
""" | ||
Window.clearcolor = (0, 0, 0, 1) | ||
self.icon = PATH_IMAGES + "logo.png" | ||
|
||
def on_start(self): | ||
if MOBILE_MODE: | ||
Window.update_viewport() | ||
music_mixer.play("title_music", loop=True) | ||
self.root_window.children[0].init_screen("menu") | ||
return super().on_start() | ||
|
||
|
||
# Run the application | ||
if __name__ == "__main__": | ||
for file_name in os.listdir(PATH_KIVY_FOLDER): | ||
if file_name.endswith(".kv"): | ||
Builder.load_file(PATH_KIVY_FOLDER + file_name, encoding="utf-8") | ||
MainApp().run() | ||
|
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,52 @@ | ||
#:kivy 2.1.0 | ||
<CollectionScreen>: | ||
|
||
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") | ||
|
||
Label: | ||
text: root.counter_precious_stones | ||
bold: True | ||
color: root.manager.color_label | ||
pos_hint: {"right":1, "top":1} | ||
size_hint: 0.1, 0.1 | ||
font_name: root.font | ||
font_size: 30*root.font_ratio | ||
|
||
RelativeLayout: | ||
size_hint: 1, 0.9 | ||
pos_hint: {"x":0, "y":0} | ||
ScrollView: | ||
id: scroll_view | ||
do_scroll_x: False | ||
do_scroll_y: True | ||
bar_width: 0 | ||
|
||
MyScrollViewLayout: | ||
id: my_sv_layout | ||
cols: root.number_cols | ||
spacing: root.spacing | ||
padding: root.padding | ||
height: self.minimum_height+root.label_height | ||
pos: root.pos |
Oops, something went wrong.