diff --git a/assets/audio/finish.mp3 b/assets/audio/finish.mp3 index e69de29..141220c 100644 Binary files a/assets/audio/finish.mp3 and b/assets/audio/finish.mp3 differ diff --git a/assets/games/sovadash/config.json b/assets/games/sovadash/config.json index 994bb19..159a78f 100644 --- a/assets/games/sovadash/config.json +++ b/assets/games/sovadash/config.json @@ -1,5 +1,12 @@ { "name": "SovaDash", "color": "#ff4802", - "tags": ["Платфомер", "Популярно", "Онлайн", "2D"] + "tags": ["Платфомер", "Популярно", "Онлайн", "2D"], + "start-config": { + "command_args": "", + "exe_file": "SovaDash.exe", + "other_params": { + "enebled": false + } + } } \ No newline at end of file diff --git a/assets/games/sovadustry/config.json b/assets/games/sovadustry/config.json index 3e79a2d..be919a8 100644 --- a/assets/games/sovadustry/config.json +++ b/assets/games/sovadustry/config.json @@ -1,5 +1,12 @@ { "name": "SovaDustry", "color": "#84bed5", - "tags": ["Платфомер", "Популярно", "Онлайн", "2D", "Мультиплейер"] + "tags": ["Платфомер", "Популярно", "Онлайн", "2D", "Мультиплейер"], + "start-config": { + "command_args": "", + "exe_file": "Mindustry.exe", + "other_params": { + "enebled": false + } + } } \ No newline at end of file diff --git a/assets/games/sovamine/config.json b/assets/games/sovamine/config.json index 206efd5..b68c667 100644 --- a/assets/games/sovamine/config.json +++ b/assets/games/sovamine/config.json @@ -1,5 +1,12 @@ { "name": "SovaMine", "color": "#7c8adb", - "tags": ["Мультиплеер", "MHost", "Онлайн", "3D"] + "tags": ["Мультиплеер", "MHost", "Онлайн", "3D"], + "start-config": { + "command_args": "", + "exe_file": "SovaMine/start.bat", + "other_params": { + "enebled": false + } + } } \ No newline at end of file diff --git a/assets/icons/eaprsmolo.jpeg b/assets/icons/eaprsmolo.jpeg deleted file mode 100644 index fa41abd..0000000 Binary files a/assets/icons/eaprsmolo.jpeg and /dev/null differ diff --git a/assets/icons/internet.png b/assets/icons/internet.png index e69de29..acbd878 100644 Binary files a/assets/icons/internet.png and b/assets/icons/internet.png differ diff --git a/expert.py b/expert.py index 17a4edb..628fba7 100644 --- a/expert.py +++ b/expert.py @@ -5,11 +5,29 @@ from sound_effect import BoopSound import json from ui import interface_button +import shutil +import os +from hashsystem import is_directory + +def copy_all_files_from_directory(from_path, to_path): + items = os.listdir(from_path) + print("Выполняется перенос файлов... [{} -> {}]".format(from_path, to_path)) + for file in items: + print(f"[{from_path}/{file}] -> [{to_path}/{file}]....", end="") + shutil.copytree(f"{from_path}/{file}", f"{to_path}/{file}") + print("OK") + print("Готово!") + def get_available_drives(): return [drive for drive in string.ascii_uppercase if os.path.exists(drive + ':\\')] -def get_disk_usage(drive_letter): +def get_disk_usage(drive_letter) -> (float, float): + """ + + :param drive_letter: + :return: + """ disk_usage = psutil.disk_usage(drive_letter + ':\\') percent_used = disk_usage.percent / 100 gb_free = disk_usage.free / (2**30) # конвертируем байты в гигабайты @@ -28,14 +46,37 @@ def close(e): page.overlay.remove(message) page.update() - def on_bg_click(e): - print("on_bg_click") + def change_disk(disk): + btn.disabled = True + btn.content = ft.ProgressRing(width=20, height=20, color=ft.colors.RED_400, bgcolor=ft.colors.BLACK26) + btn.update() + dd.disabled = True + dd.update() + boop.play() catalog = disk + catalog_to = page.client_storage.get("catalog_games") page.client_storage.set("catalog_games", catalog) + + path_to_new_games = f"{catalog}:/SovaGames" + path_to_games = f"{catalog_to}:/SovaGames" + if path_to_games == path_to_new_games: + close(disk) + return + + if not is_directory(path_to_games): + os.mkdir(path_to_games) + + if not is_directory(path_to_new_games): + os.mkdir(path_to_new_games) + + copy_all_files_from_directory(path_to_games, path_to_new_games) + page.update() + shutil.rmtree(path_to_games) close(disk) + def prew_change_disk(e): boop.play() disk = e.control.value @@ -89,7 +130,22 @@ def prew_change_disk(e): def installed_games(page: ft.Page): + catalog = page.client_storage.get("catalog_games") + path_to_games = f"{catalog}:/SovaGames" boop = BoopSound(page) + + def remove_game(game_id): + boop.play() + shutil.rmtree(f"{path_to_games}/{game_id}") + cccc.content = get_col_games() + cccc.update() + + def open_in_explorer(game_id): + os.startfile(f"{path_to_games}/{game_id}") + + + + def get_game_object(game_id): with open(f"assets/games/{game_id}/config.json", "r", encoding="utf-8") as f: config = json.load(f) @@ -105,14 +161,27 @@ def get_game_object(game_id): ] ) ), - ft.Container(ft.Row([ft.IconButton(icon=ft.icons.RESTART_ALT, icon_color=ft.colors.WHITE, style=ft.ButtonStyle(bgcolor=ft.colors.GREEN, shape=ft.RoundedRectangleBorder(radius=15))), ft.IconButton(ft.icons.FOLDER, icon_color=ft.colors.WHITE, style=ft.ButtonStyle(bgcolor=ft.colors.AMBER_900, shape=ft.RoundedRectangleBorder(radius=15))), ft.IconButton(ft.icons.DELETE_FOREVER, icon_color=ft.colors.WHITE, style=ft.ButtonStyle(bgcolor=ft.colors.RED_700, shape=ft.RoundedRectangleBorder(radius=15)))])) + ft.Container(ft.Row([ + ft.IconButton(ft.icons.RESTART_ALT, icon_color=ft.colors.WHITE, style=ft.ButtonStyle(bgcolor=ft.colors.GREEN, shape=ft.RoundedRectangleBorder(radius=15))), + ft.IconButton(ft.icons.FOLDER, on_click=lambda _: open_in_explorer(game_id), icon_color=ft.colors.WHITE, style=ft.ButtonStyle(bgcolor=ft.colors.AMBER_900, shape=ft.RoundedRectangleBorder(radius=15))), + ft.IconButton(ft.icons.DELETE_FOREVER, on_click=lambda _: remove_game(game_id), icon_color=ft.colors.WHITE, style=ft.ButtonStyle(bgcolor=ft.colors.RED_700, shape=ft.RoundedRectangleBorder(radius=15)))])) ], alignment=ft.MainAxisAlignment.SPACE_BETWEEN ) ) return object - files = os.listdir(f"assets/games") + + def get_col_games(): + files = os.listdir(path_to_games) + if len(files) == 0: + return ft.Container(ft.Text("У вас нет игорь :(", size=15, color="#555555"), alignment=ft.alignment.center) + print(files) + return ft.Column([ + get_game_object(file) for file in files + ], spacing=50, scroll=ft.ScrollMode.HIDDEN) + + cccc = ft.Container(get_col_games(),height=400,border_radius=20) def close(e): boop.play() page.overlay.remove(content) @@ -121,13 +190,7 @@ def close(e): ft.Container( ft.Container( ft.Column([ - ft.Container( - ft.Column([ - get_game_object(file) for file in files - ], spacing=50, scroll=ft.ScrollMode.HIDDEN), - height=400, - border_radius=20 - ), + cccc, ft.Container( ft.ElevatedButton("Назад", on_click=close, **interface_button, width=150), alignment=ft.alignment.center diff --git a/game_run_page.py b/game_run_page.py index e4ec0c5..8856218 100644 --- a/game_run_page.py +++ b/game_run_page.py @@ -4,6 +4,12 @@ from ui import interface_button, interface_switch from internets import get_updates import time +from install_game import install_game +import os +import subprocess +from modals import qwqwqwq + + class GamesPage: def __init__(self, id, web = False, config_start: {} = None, page: ft.Page = None, content_page = None): self.content_page = content_page @@ -13,12 +19,18 @@ def __init__(self, id, web = False, config_start: {} = None, page: ft.Page = Non self.path = f"assets/games/{self.id}" with open(f"{self.path}/description.txt", "r", encoding='utf-8') as f: self.description = f.read() + + self.path_to_game_folder = f"{page.client_storage.get('catalog_games')}:/SovaGames/{self.id}" + if not os.path.exists(self.path_to_game_folder): + self.start_button = ft.ElevatedButton("Установить", **interface_button, on_click=self.install) + else: + self.start_button = ft.ElevatedButton("Запустить", **interface_button, on_click=self.start) self.boop = BoopSound(page) self.page = page self.icon = ft.Image(f"{self.path}/icon.png") self.config = json.load(open(f"{self.path}/config.json", "r", encoding='utf-8')) news = ft.Column([], scroll=ft.ScrollMode.HIDDEN, expand=True) - nes_col = get_updates(game_id=self.id) + nes_col = get_updates(game_id=self.id, base_url=self.page.client_storage.get("cdn_url")) for new in nes_col: content_new = ft.Container( ft.Column([ @@ -73,9 +85,38 @@ def __init__(self, id, web = False, config_start: {} = None, page: ft.Page = Non ft.Container(ft.Text(self.config["name"], size=30, weight=ft.FontWeight.BOLD, color=ft.colors.WHITE)), tags, ], horizontal_alignment=ft.CrossAxisAlignment.CENTER),width=280, height=550), - ft.Container(ft.ElevatedButton("Играть", **interface_button), width=280, margin=ft.margin.only(bottom=10)) + ft.Container(self.start_button, width=280, margin=ft.margin.only(bottom=10)) ], horizontal_alignment=ft.CrossAxisAlignment.CENTER, alignment=ft.MainAxisAlignment.SPACE_BETWEEN), height=630, width=300, bgcolor=ft.colors.BLACK26, border_radius=15, margin=ft.margin.only(top=10)) - ], vertical_alignment=ft.CrossAxisAlignment.START), opacity=0, animate_opacity=ft.Animation(300, ft.AnimationCurve.EASE_IN_OUT),) + ], vertical_alignment=ft.CrossAxisAlignment.START), opacity=0, animate_opacity=ft.Animation(300, ft.AnimationCurve.EASE_IN_OUT)) + + + def install(self, e): + install_game(self.page, self.id) + + + def start(self, e): + self.page.overlay.append(qwqwqwq) + self.page.update() + self.start_button.disabled = True + self.start_button.update() + currrect = os.getcwd() + os.chdir(self.path_to_game_folder) + to_exe = self.config["start-config"]["exe_file"] + path = f"{self.path_to_game_folder}/{to_exe}" + process = subprocess.Popen(path) + return_code = process.wait() # Ждем, пока приложение будет закрыто + print(f"Приложение \"{self.id}\" закрыто. Код завершения: {return_code}") + os.chdir(currrect) + self.start_button.disabled = False + self.start_button.update() + if return_code != 0: + self.error(return_code) + + self.page.overlay.remove(qwqwqwq) + self.page.update() + + def error(self, error): + print("Вывести ошибку") def set_page(self, e): self.content_page.content = self.content self.content_page.update() diff --git a/games_page.py b/games_page.py index 736479a..37c2bd8 100644 --- a/games_page.py +++ b/games_page.py @@ -3,6 +3,7 @@ from sound_effect import BoopSound from game_run_page import GamesPage import time +import os class Game_object(ft.UserControl): id: str = None web_content: bool = True @@ -29,7 +30,7 @@ def __init__(self, id: str, web_content: bool = False, page: ft.Page = None, con self.GAME_PAGE = GamesPage(id, web_content, None, page, content_page=content) def on_object_hover(self, e): - e.control.content.shadow.blur_radius = 10 if e.data == "true" else 50 + e.control.content.scale = 0.98 if e.data == "true" else 1 e.control.update() def go_to_page(self, e): @@ -85,14 +86,14 @@ def build(self): animate_scale=ft.Animation(300, ft.AnimationCurve.EASE_IN_OUT), animate_offset=ft.Animation(200, ft.AnimationCurve.EASE_OUT), animate=ft.Animation(100, ft.AnimationCurve.EASE_IN_OUT), - shadow=ft.BoxShadow( - spread_radius=0, - blur_radius=50, - color=config["color"], - offset=ft.Offset(0, 0), - blur_style=ft.ShadowBlurStyle.NORMAL, - - ) + # shadow=ft.BoxShadow( + # spread_radius=0, + # blur_radius=50, + # color=config["color"], + # offset=ft.Offset(0, 0), + # blur_style=ft.ShadowBlurStyle.NORMAL, + # + # ) ) @@ -122,16 +123,16 @@ def get_games_page(page, content): ft.Container(width=800, height=1, bgcolor="#5c5e60"), ]) ), - Game_object(id="sovacraft", web_content=False, page=page, content=content), - Game_object(id="sovadash", web_content=False, page=page, content=content), - Game_object(id="sovadastry", web_content=False, page=page, content=content), + # Game_object(id="sovamine", web_content=False, page=page, content=content), + # Game_object(id="sovadash", web_content=False, page=page, content=content), + # Game_object(id="sovadustry", web_content=False, page=page, content=content), - ], + ] + [Game_object(id=game, web_content=False, page=page, content=content) for game in os.listdir("assets/games")], alignment=ft.MainAxisAlignment.START, spacing=10, - scroll=ft.ScrollMode.ALWAYS, + scroll=ft.ScrollMode.HIDDEN, ), - height=page.window_height - 120, + height=page.window_height - 100, ) return games \ No newline at end of file diff --git a/home_page.py b/home_page.py index ec7cc71..db3dc7b 100644 --- a/home_page.py +++ b/home_page.py @@ -1,11 +1,8 @@ import flet as ft from ui import interface_button import requests -from internets import get_updates +from internets import get_updates, get_author md1 = """ -# Добро пожаловать в SovaLauncher! - - SovaLauncher - фанатская переделка оригинального SovaLaucher, в отличии от оригинала этот лаунчер имеет множество забавных фич и дополнений @@ -25,10 +22,8 @@ def get_main_page_home(page: ft.Page): base_url = page.client_storage.get("cdn_url") def open_devs(e): - req = requests.get(base_url + "/info/devloper") - if req.status_code == 200: - req = req.json() - dev = req["devloper"] + dev = get_author(page.client_storage.get("cdn_url")) + if dev: dialog = ft.AlertDialog( modal=False, title=ft.Text("Разработчики"), @@ -52,12 +47,10 @@ def open_devs(e): dialog.open = True page.update() - else: - page.error(req.status_code) def update_history(e): news = ft.Column([], scroll=ft.ScrollMode.HIDDEN, expand=True) - nes_col = get_updates(game_id="sovalauncher") + nes_col = get_updates(game_id="sovalauncher", base_url=page.client_storage.get("cdn_url")) for new in nes_col: content_new = ft.Container( ft.Column([ @@ -93,6 +86,7 @@ def supp(e): content = ft.Container( ft.Column( [ + ft.Text("Добро пожаловать в SovaLauncher", size=50, weight=ft.FontWeight.BOLD), ft.Markdown( md1, selectable=True, diff --git a/install_game.py b/install_game.py index e69de29..b5da417 100644 --- a/install_game.py +++ b/install_game.py @@ -0,0 +1,210 @@ +import os +import flet as ft +from ui import interface_button, checkbox +from expert import get_disk_usage, disk_select +from hashsystem import is_directory +from sound_effect import BoopSound, finish_sound +import time +import json +import hashlib +import requests +def file_hash_(file_path: str) -> str: + """ + Возвращает md5 hash файла по его пути + ```python + path = "/path/to/file.txt" + hash_md5 = file_hash(path) + print(hash_md5) + ``` + :param file_path: + :return: + """ + hash_md5 = hashlib.md5() + try: + with open(file_path, "rb") as f: + for chunk in iter(lambda: f.read(4096), b""): + hash_md5.update(chunk) + return hash_md5.hexdigest() + except: + return "404" +def calculate_percentage(number1, number2): + percentage = (number1 / number2) + pp = round(percentage, 2) + return pp + +filesssss_num_installed = 0 +def install_game(page: ft.Page, game_id): + global filesssss_num_installed + + def files_update(path_to_games_dir: str, game_id: str, files_hashs, num) -> None: + global filesssss_num_installed + error_files = [] + file_names = [] + print("Выполняется обновление файлов...") + for file in files_hashs: + filesssss_num_installed += 1 + print(f"- {game_id}/{file['name']}...", end="") + currect_file.color = ft.colors.WHITE + currect_file.bgcolor = ft.colors.TRANSPARENT + currect_file.value = f"Проверка: {game_id}/{file['name']}..." + currect_file.update() + if filesssss_num_installed > 1000: + files_inout.value = filesssss_num_installed + files_inout.update() + + files_inout.value = f"[{filesssss_num_installed}/{num}]" + files_inout.update() + pg.value = calculate_percentage(filesssss_num_installed, num) + pg.update() + + + if file['type'] == "dir": + if not os.path.isdir(f"{path_to_games_dir}/{game_id}/{file['name']}"): + os.mkdir(f"{path_to_games_dir}/{game_id}/{file['name']}") + files_update(path_to_games_dir, f"{game_id}/{file['name']}", file['files'], num) + continue + file_names.append(file['name']) + file_hash = file_hash_(f"{path_to_games_dir}/{game_id}/{file['name']}") + if not file_hash == "404": + if file_hash == file["hash"]: + print("OK", file_hash) + else: + print("FAIL") + currect_file.bgcolor = ft.colors.RED_400 + file['local_hash'] = file_hash + error_files.append(file) + else: + print("404") + currect_file.color = ft.colors.RED_400 + error_files.append(file) + + print("---------------------------") + for file in error_files: + print(f"- {file['name']}...", end="") + try: + currect_file.value = f"Установка: {game_id}/{file['name']}..." + currect_file.update() + with open(f"{path_to_games_dir}/{game_id}/{file['name']}", "wb") as f: + f.write(requests.get(file['url']).content) + print("DONE!") + except: + print("FAIL!") + print("=============================") + + + + + g_s_path = f"assets/games/{game_id}" + boop = BoopSound(page) + # page.client_storage.set("catalog_games", "C") + free_space = get_disk_usage(page.client_storage.get("catalog_games")) + print(free_space[1]) + def change_disk(e): + boop.play() + disk = page.client_storage.get("catalog_games") + disk_select(page) + while page.client_storage.get("catalog_games") == disk: + time.sleep(1) + print("Диск поменян!") + text_master.value = "Мастер установки готов установить игру!" + text_master.color = "white" + text_master.update() + dialog_button.text = "Установить" + dialog_button.on_click = install + dialog_button.update() + + with open(f"{g_s_path}/config.json", "r") as f: + config = json.load(f) + + + def close(): + page.overlay.remove(qweqwewqeqw) + page.update() + + def finish(run, short): + global filesssss_num_installed + filesssss_num_installed = 0 + print(run, short) + close() + + def finished(): + + column.clear() + column.append(top_texts) + column.append(ft.Row([finish_run, finish_icons_short_create])) + column.append(ft.Row([ft.ElevatedButton("Завершить", on_click=lambda e: finish(finish_run.value, finish_icons_short_create.value), **interface_button, width=150)], alignment=ft.MainAxisAlignment.CENTER)) + content.height = 180 + content.update() + content.content.update() + + + def error(error): + column.clear() + column.append(top_texts) + column.append(ft.Container(ft.Column([ft.Text("Ошибка: {}".format(error), color="red"), ft.ElevatedButton("Закрыть", on_click=lambda e: close(), **interface_button, width=150)], alignment=ft.MainAxisAlignment.CENTER, horizontal_alignment=ft.CrossAxisAlignment.CENTER), width=500, height=400)) + content.height = 500 + content.update() + content.content.update() + def install(e): + boop.play() + column.clear() + column.append(top_texts) + column.append(ft.Container(ft.Column([ft.Row([pg, files_inout]), currect_file]), height=50, alignment=ft.alignment.center)) + content.height = 155 + content.update() + content.content.update() + catalog = page.client_storage.get("catalog_games") + path_to_games = f"{catalog}:/SovaGames" + if not is_directory(path_to_games): + os.mkdir(path_to_games) + + files_hashs = requests.get(f"{page.client_storage.get('cdn_url')}/games/{game_id}/hash").json() + if files_hashs["num"] > 1000: + files_inout.size = 10 + files_inout.update() + + + if files_hashs["status"] == "error": + error(files_hashs["message"]) + return + + if not is_directory(f"{path_to_games}/{game_id}"): + os.mkdir(f"{path_to_games}/{game_id}") + + files_update(path_to_games, game_id, files_hashs["hashs"], files_hashs["num"]) + finish_sound(page) + finished() + + def start(): + column.clear() + column.append(top_texts) + column.append(ft.Container(ft.Column([text_master, ft.Row([dialog_button, ft.ElevatedButton("Отмена", on_click=lambda e: close(), **interface_button, width=150)],alignment=ft.MainAxisAlignment.CENTER)], alignment=ft.MainAxisAlignment.CENTER, horizontal_alignment=ft.CrossAxisAlignment.CENTER), width=500, height=400)) + content.height = 500 + content.update() + content.content.update() + + finish_run = ft.Checkbox(label="Запустить", **checkbox) + finish_icons_short_create =ft.Checkbox(label="Создать иконку на рабочем столе", **checkbox) + + # Определяем кнопки и текста + + install_button = ft.ElevatedButton("Установить", on_click=install, **interface_button, width=150) + change_catalog =ft.ElevatedButton("Поменять диск", on_click=change_disk, **interface_button, width=150) + dialog_button = install_button if free_space[1] > 1 else change_catalog + + text_master = ft.Text("Мастер установки готов установить игру!") if free_space[1] > 1 else ft.Text("Недостаточно места на выбранном каталоге", color="red") + + top_texts = ft.Row([ft.Image(src=f"{g_s_path}/icon.png", height=50), ft.Text(config["name"], size=20)]) + + pg = ft.ProgressBar(width=400, height=20, color=ft.colors.RED_400, bgcolor=ft.colors.BLACK26) + files_inout = ft.Text("[0/50]") + currect_file = ft.Text("Installing...") + + + column = [] + + content = ft.Container(height=100, width=500, content=ft.Column(column), bgcolor="#1E1E1E", border_radius=20, padding=20, animate=ft.Animation(400, ft.AnimationCurve.EASE_OUT_SINE)) + qweqwewqeqw = ft.Stack([ft.Container(content=content, bgcolor=ft.colors.with_opacity(0.2, ft.colors.BLACK), blur=ft.Blur(10, 10), alignment=ft.alignment.center)]) + page.overlay.append(qweqwewqeqw) + page.update() + start() diff --git a/internets.py b/internets.py index e84e5a9..3174dce 100644 --- a/internets.py +++ b/internets.py @@ -1,5 +1,5 @@ import requests - +import flet as ft # Функция которая возвращает текущий ip компьютера def get_ip(): return requests.get("https://ipinfo.io/ip").text @@ -7,8 +7,14 @@ def get_ip(): # Эта функция возвращает обнавления указанной игры -def get_updates(only_last:bool = False, game_id = "") -> []: - news = requests.get(f"http://127.0.0.1:8000/updates/{game_id}").json() +def get_updates(only_last:bool = False, game_id = "", base_url = "") -> []: + try: + news = requests.get(f"{base_url}/updates/{game_id}", timeout=0.1).json() + except: + news = [{"name": "Нет соеденения с сервером", + "version": "-", + "text": "Нет соединения с сервером для получения информации, пожалуйста проверьте свое интернет соединение", + "date": "2000.01.01"}] if only_last: return news[0] return news @@ -42,3 +48,18 @@ def check_api(url: str) -> bool: except Exception as e: print(e) return False + +def get_author(base_url): + try: + req = requests.get(base_url + "/info/devloper") + if req.status_code == 200: + req = req.json() + dev = req["devloper"] + return dev + except: + return { + "icon": "assets/icons/internet.png", + "name": "Mirvis", + "link": "http://localhost", + "description": "Сервак не доступен ия не не могу узнать о авторе", + } \ No newline at end of file diff --git a/main.py b/main.py index e97c3d1..7476025 100644 --- a/main.py +++ b/main.py @@ -16,8 +16,6 @@ def main(page: ft.Page): - - page.window_title_bar_hidden = True page.title = launcher_name @@ -42,8 +40,8 @@ def go_to_home(e): content.update() HOME = ft.Container(get_main_page_home(page)) - GAMES = ft.Container(get_games_page(page, content)) - SETTINGS = ft.Container(get_settings_page(page)) + # GAMES = ft.Container(get_games_page(page, content)) + # SETTINGS = ft.Container(get_settings_page(page)) content.content = HOME diff --git a/modals.py b/modals.py index e69de29..28ceed1 100644 --- a/modals.py +++ b/modals.py @@ -0,0 +1,7 @@ +import flet as ft + +modal = ft.Container( + ft.Column([ft.Text("Режим игры...", size=30)], alignment=ft.MainAxisAlignment.CENTER, horizontal_alignment=ft.CrossAxisAlignment.CENTER), + height=100, width=300, bgcolor="#2e2e2e", border_radius=20, padding=10) + +qwqwqwq = ft.Stack([ft.Container(modal, alignment=ft.alignment.center, bgcolor=ft.colors.with_opacity(0.2, ft.colors.BLACK), blur=ft.Blur(10, 10))]) diff --git a/navifation.py b/navifation.py index 6b7f4b4..e67f404 100644 --- a/navifation.py +++ b/navifation.py @@ -17,7 +17,7 @@ def colorize_image(rgb, image_path): return base64_image -logo_path = "assets/logo_.png" +logo_path = "assets/logo.png" rgb = (100, -5, -2) def get_elements(page, height, main, settings, library): @@ -28,7 +28,7 @@ def close(e): image_base64 = colorize_image(rgb, logo_path) navigation = ft.Container(ft.Column([ft.Container( - ft.Image(src_base64=image_base64, width=150, border_radius=30), + ft.Image(src=logo_path, width=150, border_radius=30), margin=ft.margin.only(bottom=40, top=20), on_click=lambda _: page.launch_url("https://www.sovagroup.one"), tooltip="site:https://www.sovagroup.one"), ft.ElevatedButton("Главная", **navigation_button, on_click=main), ft.ElevatedButton("Библиотека", **navigation_button, on_click=library), diff --git a/server/main.py b/server/main.py index cef4b49..20e00c7 100644 --- a/server/main.py +++ b/server/main.py @@ -79,7 +79,7 @@ async def get_updates(game_id): return sovadash if game_id == "sovamine": return sovamine - if game_id == "sovadastry": + if game_id == "sovadustry": return sovadustry return [{"name": "...", "version": "0.0.0.0", diff --git a/settings_page.py b/settings_page.py index ec9cc7b..f85255f 100644 --- a/settings_page.py +++ b/settings_page.py @@ -25,7 +25,7 @@ def edit(e): e.control.update() if check_api(edited_cdn): close(e) - page.client_storage.set("cdn_url", "http://127.0.0.1:8000") + page.client_storage.set("cdn_url", edited_cdn) else: e.control.content = ft.Text("Сохранить") e.control.update() @@ -71,7 +71,7 @@ def on_dnd_change(e): sound_switch.update() page.client_storage.set("on_sound", False) else: - sound_switch.disabled = True + sound_switch.disabled = False sound_switch.value = True sound_switch.update() page.client_storage.set("on_sound", True) @@ -101,17 +101,17 @@ def open_installers(e): ft.Row([ ft.Container(content=ft.Row( [ft.Icon(ft.icons.DO_NOT_DISTURB, color="white", size=20), ft.Text("Не беспокоить"), - ft.Switch(**interface_switch, on_change=on_dnd_change, value=page.client_storage.get("dnd"))]), bgcolor="#1c2024", padding=10, + ft.Switch(**interface_switch, on_change=on_dnd_change, value=page.client_storage.get("dnd"))]), bgcolor="#212224", padding=10, border_radius=10), ft.Container(content=ft.Row( [ft.Icon(ft.icons.AUDIOTRACK_SHARP, color="white", size=20), ft.Text("Звуки"), - sound_switch]), bgcolor="#1c2024", padding=10, + sound_switch]), bgcolor="#212224", padding=10, border_radius=10), ]), ft.Row([ ft.Container(content=ft.Row( [ft.Icon(ft.icons.EXPLORE, color="white", size=20), ft.Text("Публичная сеть"), - ft.Switch(**interface_switch, on_change=boop.play_e)]), bgcolor="#1c2024", padding=10, + ft.Switch(**interface_switch, on_change=boop.play_e)]), bgcolor="#212224", padding=10, border_radius=10), ft.ElevatedButton("Изменить CDN", **interface_button, icon=ft.icons.CLOUD, on_click=edit_cdn) diff --git a/sound_effect.py b/sound_effect.py index 3a1a255..5db826d 100644 --- a/sound_effect.py +++ b/sound_effect.py @@ -14,4 +14,9 @@ def play(self): self.boop.play() def play_e(self, e): - self.play() \ No newline at end of file + self.play() + +def finish_sound(page): + is_sound = page.client_storage.get("on_sound") + if is_sound != False: + page.overlay.append(ft.Audio("assets/audio/finish.mp3", autoplay=True)) \ No newline at end of file diff --git a/ui.py b/ui.py index a7a4997..c4078cc 100644 --- a/ui.py +++ b/ui.py @@ -2,7 +2,7 @@ interface_button = { "color": ft.colors.WHITE, - "style": ft.ButtonStyle(shape=ft.RoundedRectangleBorder(radius=10), bgcolor=ft.colors.WHITE24, overlay_color=ft.colors.with_opacity(0.05, ft.colors.WHITE), padding=20), + "style": ft.ButtonStyle(shape=ft.RoundedRectangleBorder(radius=10), bgcolor=ft.colors.WHITE24, overlay_color=ft.colors.with_opacity(0.05, ft.colors.WHITE), padding=20, shadow_color=ft.colors.TRANSPARENT, surface_tint_color=ft.colors.WHITE12), "icon_color": "white", } @@ -31,4 +31,9 @@ "border_color": ft.colors.WHITE, "border_radius": 15, "focused_border_color": ft.colors.RED_400 +} + +checkbox = { + "check_color": ft.colors.BLACK, + "active_color": ft.colors.RED_400 } \ No newline at end of file