Skip to content

Commit

Permalink
Добавлена возможность менять цвета (есть баги, и выполнено на 80%)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kexi8BiT committed May 2, 2024
1 parent 77f0134 commit 13c9468
Show file tree
Hide file tree
Showing 23 changed files with 189 additions and 65 deletions.
Binary file modified assets/Images/itsme.webp
Binary file not shown.
Binary file modified assets/audio/meow/meow0.mp3
Binary file not shown.
Binary file modified assets/audio/meow/meow1.mp3
Binary file not shown.
Binary file modified assets/audio/meow/meow2.mp3
Binary file not shown.
Binary file modified assets/audio/meow/meow3.mp3
Binary file not shown.
Binary file modified assets/audio/meow/meow4.mp3
Binary file not shown.
Binary file modified assets/audio/meow/meow5.mp3
Binary file not shown.
Binary file modified assets/audio/meow/meow6.mp3
Binary file not shown.
Binary file modified assets/audio/meow/meow7.mp3
Binary file not shown.
Binary file modified assets/audio/meow/meow8.mp3
Binary file not shown.
Binary file modified assets/audio/meow/meow9.mp3
Binary file not shown.
Binary file modified assets/audio/meow/meow9.mp3.sfk
Binary file not shown.
32 changes: 16 additions & 16 deletions expert.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import psutil
from sound_effect import BoopSound
import json
from ui import interface_button
from ui import interface_button, color_1, color_2, color_3, color_text, color_theme_1, button
import shutil
import os
from hashsystem import is_directory
Expand Down Expand Up @@ -95,25 +95,25 @@ def prew_change_disk(e):
catalogs = get_available_drives()
dd = ft.Dropdown(width=380, value=page.client_storage.get("catalog_games"),
options=[ft.dropdown.Option(catalog) for catalog in catalogs],
border_color=ft.colors.with_opacity(0.1, ft.colors.BLACK), border_radius=30,
prefix_icon=ft.icons.STORAGE_ROUNDED, on_change=prew_change_disk)
border_color=ft.colors.with_opacity(0.1, color_1), border_radius=30,
prefix_icon=ft.icons.STORAGE_ROUNDED, on_change=prew_change_disk, color=color_text)

percent_used, gb_free = get_disk_usage(page.client_storage.get("catalog_games"))
progress = ft.ProgressBar(width=295, bgcolor=ft.colors.BLACK12, color=ft.colors.WHITE, value=percent_used)
progress_right = ft.Text(f"{gb_free:.2f} GB")
progress = ft.ProgressBar(width=295, bgcolor=color_2, color=color_text, value=percent_used)
progress_right = ft.Text(f"{gb_free:.2f} GB", color=color_text)

btn = ft.ElevatedButton("Применить", width=380, on_click=lambda _: change_disk(dd.value), disabled=True if gb_free < 1 else False, bgcolor=ft.colors.BLACK12, style=ft.ButtonStyle(bgcolor=ft.colors.TRANSPARENT, shadow_color=ft.colors.TRANSPARENT, overlay_color=ft.colors.TRANSPARENT, surface_tint_color=ft.colors.TRANSPARENT, ),color=ft.colors.WHITE)
btn = ft.ElevatedButton("Применить", width=380, on_click=lambda _: change_disk(dd.value), disabled=True if gb_free < 1 else False, bgcolor=button['bgcolor'], style=ft.ButtonStyle(bgcolor=ft.colors.TRANSPARENT, shadow_color=ft.colors.TRANSPARENT, overlay_color=ft.colors.TRANSPARENT, surface_tint_color=ft.colors.TRANSPARENT, ),color=color_text)
message = ft.Stack(
[ft.Container(
ft.Container(
width=400,
height=200,
bgcolor="#2e2e2e",
bgcolor=color_2,
border_radius=20,
border=ft.border.all(1, ft.colors.BLACK12),
border=ft.border.all(1, color_1),
padding=20,
content=ft.Column([
ft.Text("Выберите каталог", size=20, color=ft.colors.WHITE),
ft.Text("Выберите каталог", size=20, color=color_text),
dd,
ft.Row([progress, progress_right]),
btn
Expand Down Expand Up @@ -168,14 +168,14 @@ def get_game_object(game_id):
ft.Row(
[
ft.Image(height=50, width=50, src=f"assets/games/{game_id}/icon.png", border_radius=10),
ft.Container(ft.Column([ft.Text(config["name"], weight=ft.FontWeight.BOLD), ft.Text(f"{size:.0f} MB", color="#585858")], spacing=2))
ft.Container(ft.Column([ft.Text(config["name"], weight=ft.FontWeight.BOLD, color=color_text), ft.Text(f"{size:.0f} MB", color="#585858")], spacing=2))
]
)
),
ft.Container(ft.Row([
ft.IconButton(ft.icons.RESTART_ALT, tooltip="Проверить файлы", icon_color=ft.colors.WHITE, style=ft.ButtonStyle(bgcolor=ft.colors.GREEN, shape=ft.RoundedRectangleBorder(radius=15))),
ft.IconButton(ft.icons.FOLDER, tooltip="Открыть папку с игрой", 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, tooltip="Удалить игру", 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)))]))
ft.IconButton(ft.icons.RESTART_ALT, tooltip="Проверить файлы", icon_color=color_text, style=ft.ButtonStyle(bgcolor=ft.colors.GREEN, shape=ft.RoundedRectangleBorder(radius=15))),
ft.IconButton(ft.icons.FOLDER, tooltip="Открыть папку с игрой", on_click=lambda _: open_in_explorer(game_id), icon_color=color_text, style=ft.ButtonStyle(bgcolor=ft.colors.AMBER_900, shape=ft.RoundedRectangleBorder(radius=15))),
ft.IconButton(ft.icons.DELETE_FOREVER, tooltip="Удалить игру", on_click=lambda _: remove_game(game_id), icon_color=color_text, style=ft.ButtonStyle(bgcolor=ft.colors.RED_700, shape=ft.RoundedRectangleBorder(radius=15)))]))

], alignment=ft.MainAxisAlignment.SPACE_BETWEEN
)
Expand All @@ -186,7 +186,7 @@ def get_game_object(game_id):
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)
return ft.Container(ft.Text("У вас нет игорь :(", size=15, color=color_text), alignment=ft.alignment.center)
print(files)
return ft.Column([
get_game_object(file) for file in files
Expand All @@ -207,14 +207,14 @@ def close(e):
alignment=ft.alignment.center
)
], alignment=ft.MainAxisAlignment.SPACE_BETWEEN),
bgcolor="#1E1E1E",
bgcolor=color_1,
height=500,
width=900,
border_radius=20,
shadow=ft.BoxShadow(
spread_radius=0,
blur_radius=10,
color='black',
color=color_3,
offset=ft.Offset(0, 10),
blur_style=ft.ShadowBlurStyle.NORMAL,

Expand Down
10 changes: 7 additions & 3 deletions game_run_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,13 @@ def start(self, e):
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}")
try:
process = subprocess.Popen(path)
return_code = process.wait() # Ждем, пока приложение будет закрыто
print(f"Приложение \"{self.id}\" закрыто. Код завершения: {return_code}")
except Exception as e:
print("Ошибка открытия")
return_code = -1
os.chdir(currrect)
self.start_button.disabled = False
self.start_button.update()
Expand Down
1 change: 0 additions & 1 deletion games_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import json
from sound_effect import BoopSound
from game_run_page import GamesPage
import time
import os
class Game_object(ft.UserControl):
id: str = None
Expand Down
19 changes: 11 additions & 8 deletions home_page.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import flet as ft
from ui import interface_button
from ui import interface_button, color_1, color_2, color_3, color_text, color_theme_1, button
from modals import open_link
from internets import get_updates, get_author
md1 = """
Expand All @@ -25,7 +25,8 @@ def open_devs(e):
if dev:
dialog = ft.AlertDialog(
modal=False,
title=ft.Text("Разработчики"),
title=ft.Text("Разработчики", color=color_text),
bgcolor=color_2,
content=ft.Container(
ft.Column(
[
Expand All @@ -35,7 +36,7 @@ def open_devs(e):
horizontal_alignment=ft.CrossAxisAlignment.CENTER),
on_click=lambda e: page.launch_url(dev["link"])),
ft.Container(ft.Text(dev['description'], selectable=True), padding=10,
bgcolor=ft.colors.BLACK12, border_radius=20)
bgcolor=color_text, border_radius=20)
], horizontal_alignment=ft.CrossAxisAlignment.CENTER
),
height=300,
Expand Down Expand Up @@ -67,8 +68,9 @@ def update_history(e):

dialog = ft.AlertDialog(
modal=False,
title=ft.Text("Обновления"),
content=ft.Container(news, width=500, height=400)
title=ft.Text("Обновления", color=color_text),
content=ft.Container(news, width=500, height=400),
bgcolor=color_2
)
page.dialog = dialog
dialog.open = True
Expand All @@ -77,22 +79,23 @@ def update_history(e):
def supp(e):
dialog = ft.AlertDialog(
modal=False,
title=ft.Text("Просто напишите мне в лс и скажите какой я крутой"))
title=ft.Text("Просто напишите мне в лс и скажите какой я крутой", color=color_text),
bgcolor=color_2)
page.dialog = dialog
dialog.open = True
page.update()

content = ft.Container(
ft.Column(
[
ft.Text("Добро пожаловать в SovaLauncher", size=50, weight=ft.FontWeight.BOLD),
ft.Text("Добро пожаловать в SovaLauncher", size=50, weight=ft.FontWeight.BOLD, color=color_text),
ft.Markdown(
md1,
selectable=True,
extension_set=ft.MarkdownExtensionSet.GITHUB_WEB,
on_tap_link=lambda e: page.launch_url(e.data),
),
ft.Row([ft.Text("Да, лаунчер имеет открытый исходный код, репозиторий лежит на "), ft.ElevatedButton(content=ft.Row([ft.Image(src="assets/icons/gitdark.png", height=20), ft.Text("GitHub")]), **interface_button, on_click=lambda e: page.launch_url("https://github.com/Kexi8BiT/SovaLaucher"))], spacing=5),
ft.Row([ft.Text("Да, лаунчер имеет открытый исходный код, репозиторий лежит на ", color=color_text), ft.ElevatedButton(content=ft.Row([ft.Image(src="assets/icons/gitdark.png", height=20), ft.Text("GitHub", color=color_text)]), **interface_button, on_click=lambda e: page.launch_url("https://github.com/Kexi8BiT/SovaLaucher"))], spacing=5),
ft.Container(ft.Row([ft.ElevatedButton("Разработчики", **interface_button, icon=ft.icons.PEOPLE, on_click=open_devs),
ft.ElevatedButton("История обновлений", **interface_button, icon=ft.icons.UPDATE, on_click=update_history),
ft.ElevatedButton("Поддержка", **interface_button, icon=ft.icons.HEART_BROKEN, on_click=supp),
Expand Down
21 changes: 21 additions & 0 deletions huinaothue.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import flet as ft

def go_to_hyen(content, page):
content.content = get_hye_page()
content.update()



def get_hye_page():
hey_pictia = ft.Container(
alignment=ft.alignment.center,
content=ft.Container(
ft.Column([
ft.Text("Рандомная пикча от hyeeeeeeeeeeeeeeeeeeee"),
ft.Row([ft.Image('https://cdn.discordapp.com/attachments/1233063651183689840/1233066242135294052/image.png?ex=662bbded&is=662a6c6d&hm=c2025a674210f46fd448855ea794b7dc9c880ca7f04e23e34fff9c7c883d3562&')], alignment=ft.MainAxisAlignment.CENTER, scroll=ft.ScrollMode.HIDDEN)
], alignment=ft.MainAxisAlignment.CENTER),
height=200,
),
)
return hey_pictia

45 changes: 44 additions & 1 deletion install_game.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
import flet as ft
from ui import interface_button, checkbox
from expert import get_disk_usage, disk_select
Expand All @@ -8,6 +7,11 @@
import json
import hashlib
import requests
import os
import winshell
from win32com.client import Dispatch


def file_hash_(file_path: str) -> str:
"""
Возвращает md5 hash файла по его пути
Expand All @@ -33,6 +37,37 @@ def calculate_percentage(number1, number2):
return pp

filesssss_num_installed = 0


def create_desktop_shortcut(path, name=None, icon=None):
# Получаем путь к рабочему столу пользователя
desktop_path = winshell.desktop()

# Если имя не указано, используем имя исполняемого файла
if not name:
name = os.path.basename(path)

# Создаем путь к ярлыку на рабочем столе
shortcut_path = os.path.join(desktop_path, f"{name}.lnk")

# Создаем объект ярлыка
shell = Dispatch('WScript.Shell')
shortcut = shell.CreateShortCut(shortcut_path)

# Устанавливаем путь к приложению
shortcut.TargetPath = path

# Устанавливаем рабочую директорию
shortcut.WorkingDirectory = os.path.dirname(path)

# Если указана иконка, устанавливаем ее
if icon:
shortcut.IconLocation = icon

# Сохраняем ярлык
shortcut.Save()


def install_game(page: ft.Page, game_id):
global filesssss_num_installed

Expand Down Expand Up @@ -124,6 +159,14 @@ def finish(run, short):
global filesssss_num_installed
filesssss_num_installed = 0
print(run, short)
print(g_s_path)
with open(f"{g_s_path}/config.json", "r") as f:
config = json.load(f)

path_to_game = f"{page.client_storage.get('catalog_games')}:/SovaGames/{game_id}"
path_to_exe = f"{path_to_game}/{config['start-config']['exe_file']}"
if short:
create_desktop_shortcut(path_to_exe, config['name'], f"{g_s_path}/icon.png")
close()

def finished():
Expand Down
11 changes: 5 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
import ctypes
from games_page import go_to_main, get_games_page
from settings_page import go_to_settings, get_settings_page
from ui import interface_button, interface_switch
from ui import interface_button, interface_switch, colors
from game_run_page import GamesPage
from home_page import get_main_page_home
from huinaothue import go_to_hyen
sound = True

launcher_name = "SovaLauncher"
Expand All @@ -17,7 +18,7 @@

def main(page: ft.Page):
page.window_title_bar_hidden = True

page.bgcolor = colors['main_bgcolor']
page.title = launcher_name
height = 700
width = 1100
Expand All @@ -27,28 +28,26 @@ def main(page: ft.Page):
page.padding = 0
page.theme_mode = ft.ThemeMode.DARK
page.spacing = 0
boop = BoopSound(page)
if page.client_storage.get("on_sound") != False:
page.overlay.append(ft.Audio("assets/audio/start.mp3", autoplay=True, volume=0.2))
content = ft.AnimatedSwitcher(
transition=ft.AnimatedSwitcherTransition.FADE,
duration=500,
reverse_duration=500,
)

def go_to_home(e):
content.content = get_main_page_home(page)
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))
content.content = HOME





drag_area, nav_left = get_elements(page, height, lambda e: go_to_home(page), lambda _: go_to_settings(content, page), lambda e: go_to_main(content, page))
drag_area, nav_left = get_elements(page, height, lambda e: go_to_home(page), lambda _: go_to_settings(content, page), lambda e: go_to_main(content, page), lambda e: go_to_hyen(content, page))

page.add(drag_area)
page.add(ft.Row([nav_left, content]))
Expand Down
24 changes: 18 additions & 6 deletions navifation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
from PIL import Image
import io
import base64
from ui import navigation_button
from ui import navigation_button, colors, color_1
from random import randint
launcher_name = "SovaLauncher"


def colorize_image(rgb, image_path):
image = Image.open(image_path).convert('RGB')
colored_image = Image.new('RGB', image.size, rgb)
Expand All @@ -20,23 +20,35 @@ def colorize_image(rgb, image_path):
logo_path = "assets/logo.png"
rgb = (100, -5, -2)

def get_elements(page, height, main, settings, library):
def get_elements(page: ft.Page, height, main, settings, library, hyen):
def close(e):
page.window_minimized = True
page.update()


meows = [ft.Audio(f"assets/audio/meow/meow{i}.mp3", autoplay=False, volume=0.2, balance=0.5) for i in range(9)]

for object in meows:
page.overlay.append(object)

def meow(e):
meows[randint(0, 8)].play()




image_base64 = colorize_image(rgb, logo_path)
navigation = ft.Container(ft.Column([ft.Container(
navigation = ft.Container(ft.Column([ft.Column([ft.Container(
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),
ft.ElevatedButton("Настройки", **navigation_button, on_click=settings),
ft.Divider(),
ft.ElevatedButton("ахах hyee", **navigation_button, on_click=hyen),
ft.Divider(color=color_1),
ft.ElevatedButton("Оффициальный лаунчер", **navigation_button, icon=ft.icons.OPEN_IN_NEW, on_click=lambda _: page.launch_url("https://www.sovagroup.one/sovalaucher"), tooltip="sovagroup:official-launcher"),
], spacing=0,
horizontal_alignment=ft.CrossAxisAlignment.CENTER), bgcolor="#101010", width=250,
horizontal_alignment=ft.CrossAxisAlignment.CENTER), ft.Row([ft.Container(height=100, width=100, image_src="assets/Images/itsme.webp", image_fit=ft.ImageFit.COVER, on_click=meow)], alignment=ft.MainAxisAlignment.CENTER)], alignment=ft.MainAxisAlignment.SPACE_BETWEEN), bgcolor=colors["navigation_bar_bgcolor"], width=250,
height=height)

window_drag = ft.Row(
Expand Down
Binary file modified requirements.txt
Binary file not shown.
Loading

0 comments on commit 13c9468

Please sign in to comment.