diff --git a/__pycache__/config.cpython-313.pyc b/__pycache__/config.cpython-313.pyc index 27b3c8f..3b44c60 100644 Binary files a/__pycache__/config.cpython-313.pyc and b/__pycache__/config.cpython-313.pyc differ diff --git a/config.py b/config.py index ba3fe0d..b790cde 100644 --- a/config.py +++ b/config.py @@ -26,4 +26,20 @@ SETTINGS_IMG = "assets/settings.png" # Утилиты NOTIFICATION_LEVEL = "info" # Возможные значения: "info", "warning", "error" -USE_DATABASE_LOGS = True \ No newline at end of file +USE_DATABASE_LOGS = True + +# ГЛАВНОЕ МЕНЮ +BACKGROUND_COLOR_USER = "#bcabe5" # Основной фон +TOP_PANEL_COLOR_USER = "#aa9bcd" # Цвет верхней панели +BUTTON_COLOR_PROFILE_USER = "#a2c792" # Цвет кнопок "Профиль", "Магазин", "База знаний" +BUTTON_COLOR_PLAY_USER = "#b4e1a1" # Цвет кнопки "Играть" +BUTTON_COLOR_EXIT_USER = "#a2c792" # Цвет кнопки "Выход" + +# Текст и шрифты +BUTTON_TEXT_COLOR_USER = "white" # Цвет текста на кнопках +FONT_USER = ("Comic Sans MS", 20) # Шрифт для текста кнопок +BIG_FONT_USER = ("Comic Sans MS", 30) # Большой шрифт (например, для заголовков) + +# Размеры кнопок +BUTTON_RADIUS_USER = 50 # Радиус круглой кнопки +EXIT_BUTTON_SIZE_USER = (80, 40) # Размер кнопки "Выход" \ No newline at end of file diff --git a/database/DogAcademy.db b/database/DogAcademy.db index 4e62794..318511e 100644 Binary files a/database/DogAcademy.db and b/database/DogAcademy.db differ diff --git a/logs/logfile.log b/logs/logfile.log index af11b0d..623e4c1 100644 --- a/logs/logfile.log +++ b/logs/logfile.log @@ -1250,3 +1250,96 @@ FROM game_sessions FROM game_sessions 2024-11-25 19:32:52 - [generated in 0.00016s] () 2024-11-25 19:32:52 - ROLLBACK +2024-11-25 20:45:57 - BEGIN (implicit) +2024-11-25 20:45:57 - SELECT count(*) AS count_1 +FROM (SELECT users.user_id AS users_user_id, users.dog_id AS users_dog_id, users.username AS users_username, users.level AS users_level, users.achievement AS users_achievement +FROM users) AS anon_1 +2024-11-25 20:45:57 - [generated in 0.00031s] () +2024-11-25 20:45:57 - SELECT game_sessions.level AS game_sessions_level, count(game_sessions.session_id) AS count_1 +FROM game_sessions GROUP BY game_sessions.level +2024-11-25 20:45:57 - [generated in 0.00021s] () +2024-11-25 20:45:57 - SELECT questions.question_text AS questions_question_text, questions.incorrect_attempts AS questions_incorrect_attempts +FROM questions ORDER BY questions.incorrect_attempts DESC +2024-11-25 20:45:57 - [generated in 0.00024s] () +2024-11-25 20:45:57 - SELECT avg(game_sessions.duration) AS avg_1 +FROM game_sessions +2024-11-25 20:45:57 - [generated in 0.00016s] () +2024-11-25 20:45:57 - ROLLBACK +2024-11-25 20:45:57 - BEGIN (implicit) +2024-11-25 20:45:57 - SELECT game_sessions.start_time AS game_sessions_start_time +FROM game_sessions +2024-11-25 20:45:57 - [generated in 0.00014s] () +2024-11-25 20:45:57 - ROLLBACK +2024-11-25 20:55:11 - BEGIN (implicit) +2024-11-25 20:55:11 - INSERT INTO auth (login, password) VALUES (?, ?) +2024-11-25 20:55:11 - [generated in 0.00024s] ('lubluNikitu', 'meow123') +2024-11-25 20:55:11 - COMMIT +2024-11-25 20:55:36 - BEGIN (implicit) +2024-11-25 20:55:36 - SELECT auth.user_id AS auth_user_id, auth.login AS auth_login, auth.password AS auth_password +FROM auth +WHERE auth.login = ? AND auth.password = ? + LIMIT ? OFFSET ? +2024-11-25 20:55:36 - [generated in 0.00019s] ('lubluNikitu', 'meow123', 1, 0) +2024-11-25 20:55:36 - ROLLBACK +2024-11-25 20:59:37 - BEGIN (implicit) +2024-11-25 20:59:37 - SELECT count(*) AS count_1 +FROM (SELECT users.user_id AS users_user_id, users.dog_id AS users_dog_id, users.username AS users_username, users.level AS users_level, users.achievement AS users_achievement +FROM users) AS anon_1 +2024-11-25 20:59:37 - [generated in 0.00023s] () +2024-11-25 20:59:37 - SELECT game_sessions.level AS game_sessions_level, count(game_sessions.session_id) AS count_1 +FROM game_sessions GROUP BY game_sessions.level +2024-11-25 20:59:37 - [generated in 0.00014s] () +2024-11-25 20:59:37 - SELECT questions.question_text AS questions_question_text, questions.incorrect_attempts AS questions_incorrect_attempts +FROM questions ORDER BY questions.incorrect_attempts DESC +2024-11-25 20:59:37 - [generated in 0.00021s] () +2024-11-25 20:59:37 - SELECT avg(game_sessions.duration) AS avg_1 +FROM game_sessions +2024-11-25 20:59:37 - [generated in 0.00012s] () +2024-11-25 20:59:37 - ROLLBACK +2024-11-25 20:59:37 - BEGIN (implicit) +2024-11-25 20:59:37 - SELECT game_sessions.start_time AS game_sessions_start_time +FROM game_sessions +2024-11-25 20:59:37 - [generated in 0.00014s] () +2024-11-25 20:59:37 - ROLLBACK +2024-11-25 21:00:06 - BEGIN (implicit) +2024-11-25 21:00:06 - SELECT auth.user_id AS auth_user_id, auth.login AS auth_login, auth.password AS auth_password +FROM auth +WHERE auth.login = ? AND auth.password = ? + LIMIT ? OFFSET ? +2024-11-25 21:00:06 - [generated in 0.00024s] ('lubluNikitu', 'meow123', 1, 0) +2024-11-25 21:00:06 - ROLLBACK +2024-11-25 21:07:39 - BEGIN (implicit) +2024-11-25 21:07:39 - SELECT auth.user_id AS auth_user_id, auth.login AS auth_login, auth.password AS auth_password +FROM auth +WHERE auth.login = ? AND auth.password = ? + LIMIT ? OFFSET ? +2024-11-25 21:07:39 - [generated in 0.00032s] ('lubluNikitu', 'meow123', 1, 0) +2024-11-25 21:07:39 - ROLLBACK +2024-11-25 22:18:38 - BEGIN (implicit) +2024-11-25 22:18:38 - SELECT auth.user_id AS auth_user_id, auth.login AS auth_login, auth.password AS auth_password +FROM auth +WHERE auth.login = ? AND auth.password = ? + LIMIT ? OFFSET ? +2024-11-25 22:18:38 - [generated in 0.00021s] ('lubluNikitu', 'meow123', 1, 0) +2024-11-25 22:18:38 - ROLLBACK +2024-11-25 22:29:25 - BEGIN (implicit) +2024-11-25 22:29:25 - SELECT auth.user_id AS auth_user_id, auth.login AS auth_login, auth.password AS auth_password +FROM auth +WHERE auth.login = ? AND auth.password = ? + LIMIT ? OFFSET ? +2024-11-25 22:29:25 - [generated in 0.00026s] ('lubluNikitu', 'meow123', 1, 0) +2024-11-25 22:29:25 - ROLLBACK +2024-11-25 22:31:57 - BEGIN (implicit) +2024-11-25 22:31:57 - SELECT auth.user_id AS auth_user_id, auth.login AS auth_login, auth.password AS auth_password +FROM auth +WHERE auth.login = ? AND auth.password = ? + LIMIT ? OFFSET ? +2024-11-25 22:31:57 - [generated in 0.00027s] ('lubluNikitu', 'meow123', 1, 0) +2024-11-25 22:31:57 - ROLLBACK +2024-11-25 22:36:09 - BEGIN (implicit) +2024-11-25 22:36:09 - SELECT auth.user_id AS auth_user_id, auth.login AS auth_login, auth.password AS auth_password +FROM auth +WHERE auth.login = ? AND auth.password = ? + LIMIT ? OFFSET ? +2024-11-25 22:36:09 - [generated in 0.00045s] ('lubluNikitu', 'meow123', 1, 0) +2024-11-25 22:36:09 - ROLLBACK diff --git a/src/__pycache__/utils.cpython-313.pyc b/src/__pycache__/utils.cpython-313.pyc index 38aeaa4..40b1f47 100644 Binary files a/src/__pycache__/utils.cpython-313.pyc and b/src/__pycache__/utils.cpython-313.pyc differ diff --git a/src/ui/__pycache__/auth_ui.cpython-313.pyc b/src/ui/__pycache__/auth_ui.cpython-313.pyc index 833dcab..742395b 100644 Binary files a/src/ui/__pycache__/auth_ui.cpython-313.pyc and b/src/ui/__pycache__/auth_ui.cpython-313.pyc differ diff --git a/src/ui/__pycache__/user_ui.cpython-313.pyc b/src/ui/__pycache__/user_ui.cpython-313.pyc deleted file mode 100644 index 4b3c551..0000000 Binary files a/src/ui/__pycache__/user_ui.cpython-313.pyc and /dev/null differ diff --git a/src/ui/auth_ui.py b/src/ui/auth_ui.py index 88e76b7..7bfa52f 100644 --- a/src/ui/auth_ui.py +++ b/src/ui/auth_ui.py @@ -3,7 +3,7 @@ from tkinter import messagebox from config import BACKGROUND_COLOR, PRIMARY_COLOR, BUTTON_COLOR, BUTTON_TEXT_COLOR, FONT, BIG_FONT, ADMIN_LOGIN, ADMIN_PASSWORD from src.ui.admin_ui import AdminApp # Импорт интерфейса администратора from database.db_events import create_user, check_user -from src.ui.user_ui import UserApp +from src.ui.user_ui.main_menu import UserApp class DogAcademyApp: def __init__(self, root): @@ -217,5 +217,6 @@ class DogAcademyApp: messagebox.showerror("Ошибка", "Пожалуйста, заполните все поля.") def show_user_dashboard(self): + self.clear_frame() """Перейти к главному меню пользователя после авторизации.""" UserApp(self.root, self) diff --git a/src/ui/user_ui.py b/src/ui/user_ui.py deleted file mode 100644 index 703daba..0000000 --- a/src/ui/user_ui.py +++ /dev/null @@ -1,56 +0,0 @@ -import tkinter as tk -from config import BACKGROUND_COLOR, PRIMARY_COLOR, BUTTON_COLOR, BUTTON_TEXT_COLOR, FONT - -class UserApp: - def __init__(self, root, dog_academy_app): - self.root = root - self.dog_academy_app = dog_academy_app # Сохраняем ссылку на DogAcademyApp - self.show_user_dashboard() - - def show_user_dashboard(self): - """Показать интерфейс пользователя.""" - self.clear_frame() - self.current_frame = tk.Frame(self.root, bg=BACKGROUND_COLOR) - self.current_frame.pack(expand=True) - - # Заголовок - title = tk.Label( - self.current_frame, - text="Главное меню", - bg=BACKGROUND_COLOR, - fg=PRIMARY_COLOR, - font=FONT, - ) - title.pack(pady=50) - - # Кнопка "Играть" - play_button = tk.Button( - self.current_frame, - text="Играть", - bg=BUTTON_COLOR, - fg=BUTTON_TEXT_COLOR, - font=FONT, - command=self.play_game, - ) - play_button.pack(pady=20) - - # Кнопка "Выход" - logout_button = tk.Button( - self.current_frame, - text="Выход", - bg=BUTTON_COLOR, - fg=BUTTON_TEXT_COLOR, - font=FONT, - command=self.dog_academy_app.show_main_menu, # Вызываем метод из DogAcademyApp - ) - logout_button.pack(pady=20) - - def play_game(self): - """Запуск игры.""" - # TODO: Логика игры - pass - - def clear_frame(self): - """Очистить текущий фрейм.""" - if hasattr(self, 'current_frame') and self.current_frame: - self.current_frame.destroy() diff --git a/src/ui/user_ui/__pycache__/main_menu.cpython-313.pyc b/src/ui/user_ui/__pycache__/main_menu.cpython-313.pyc new file mode 100644 index 0000000..ff6afd0 Binary files /dev/null and b/src/ui/user_ui/__pycache__/main_menu.cpython-313.pyc differ diff --git a/src/ui/user_ui/common_ui.py b/src/ui/user_ui/common_ui.py new file mode 100644 index 0000000..e69de29 diff --git a/src/ui/user_ui/game_ui.py b/src/ui/user_ui/game_ui.py new file mode 100644 index 0000000..e69de29 diff --git a/src/ui/user_ui/knowledge_ui.py b/src/ui/user_ui/knowledge_ui.py new file mode 100644 index 0000000..e69de29 diff --git a/src/ui/user_ui/main_menu.py b/src/ui/user_ui/main_menu.py new file mode 100644 index 0000000..5c0e8d2 --- /dev/null +++ b/src/ui/user_ui/main_menu.py @@ -0,0 +1,93 @@ +import tkinter as tk +from config import ( + BACKGROUND_COLOR_USER, + TOP_PANEL_COLOR_USER, + BUTTON_COLOR_PROFILE_USER, + BUTTON_COLOR_PLAY_USER, + BUTTON_COLOR_EXIT_USER, + BUTTON_TEXT_COLOR_USER, + FONT_USER, + BIG_FONT_USER, + BUTTON_RADIUS_USER, + EXIT_BUTTON_SIZE_USER, +) + + +class UserApp: + def __init__(self, root, auth_ui): + self.root = root + self.auth_ui = auth_ui + self.root.configure(bg=BACKGROUND_COLOR_USER) + self.root.geometry("1920x1080") # Разрешение окна + self.root.title("Собачья академия") + print("Главное меню активно") # Лог при открытии меню + self.show_user_dashboard() + + def show_user_dashboard(self): + """Показать интерфейс пользователя.""" + # Верхняя панель + top_panel = tk.Frame(self.root, bg=TOP_PANEL_COLOR_USER, height=100) + top_panel.pack(fill=tk.X, side=tk.TOP) + + # Кнопки на верхней панели + for text, command in [("Профиль", self.show_profile), ("Магазин", self.show_shop), ("База знаний", self.show_knowledge)]: + button = tk.Button( + top_panel, + text=text, + bg=BUTTON_COLOR_PROFILE_USER, + fg=BUTTON_TEXT_COLOR_USER, + font=FONT_USER, + relief=tk.FLAT, + padx=20, + pady=10, + command=command, + ) + button.pack(side=tk.LEFT, padx=20) + + # Кнопка "Играть" в центре + play_button = tk.Button( + self.root, + text="Играть", + bg=BUTTON_COLOR_PLAY_USER, + fg=BUTTON_TEXT_COLOR_USER, + font=BIG_FONT_USER, + relief=tk.FLAT, + height=2, + width=10, + command=self.play_game, + ) + play_button.place(relx=0.5, rely=0.5, anchor=tk.CENTER) + + # Кнопка "Выход" в правом нижнем углу + exit_button = tk.Button( + self.root, + text="Выход", + bg=BUTTON_COLOR_EXIT_USER, + fg=BUTTON_TEXT_COLOR_USER, + font=FONT_USER, + width=EXIT_BUTTON_SIZE_USER[0] // 10, + height=EXIT_BUTTON_SIZE_USER[1] // 10, + command=self.exit_app, + ) + exit_button.place(relx=1.0, rely=1.0, x=-20, y=-20, anchor=tk.SE) + + def play_game(self): + """Заглушка для игры.""" + print("Запуск игры...") + + def exit_app(self): + """Заглушка для выхода.""" + print("Приложение закрыто") + self.root.quit() + + def show_profile(self): + """Заглушка для профиля.""" + print("Переход в профиль...") + + def show_shop(self): + """Заглушка для магазина.""" + print("Переход в магазин...") + + def show_knowledge(self): + """Заглушка для базы знаний.""" + print("Переход в базу знаний...") diff --git a/src/ui/user_ui/profile_ui.py b/src/ui/user_ui/profile_ui.py new file mode 100644 index 0000000..e69de29 diff --git a/src/ui/user_ui/shop_ui.py b/src/ui/user_ui/shop_ui.py new file mode 100644 index 0000000..e69de29 diff --git a/src/user_functions/__pycache__/menu_functions.cpython-313.pyc b/src/user_functions/__pycache__/menu_functions.cpython-313.pyc new file mode 100644 index 0000000..cce9cff Binary files /dev/null and b/src/user_functions/__pycache__/menu_functions.cpython-313.pyc differ diff --git a/src/user_functions/game_functions.py b/src/user_functions/game_functions.py new file mode 100644 index 0000000..e69de29 diff --git a/src/user_functions/knowledge_functions.py b/src/user_functions/knowledge_functions.py new file mode 100644 index 0000000..e69de29 diff --git a/src/user_functions/menu_functions.py b/src/user_functions/menu_functions.py new file mode 100644 index 0000000..e69de29 diff --git a/src/user_functions/profile_functions.py b/src/user_functions/profile_functions.py new file mode 100644 index 0000000..e69de29 diff --git a/src/user_functions/shop_functions.py b/src/user_functions/shop_functions.py new file mode 100644 index 0000000..e69de29 diff --git a/src/utils.py b/src/utils.py index f6c0b15..b73ac70 100644 --- a/src/utils.py +++ b/src/utils.py @@ -16,7 +16,6 @@ def feature_in_development(frame): font=("Comic Sans MS", 16) ).pack(expand=True) - def create_tooltip(widget, text): """Создание подсказки для виджета.""" tooltip = tk.Toplevel() @@ -29,4 +28,4 @@ def create_tooltip(widget, text): tooltip.destroy() widget.bind("", lambda event: tooltip.deiconify()) - widget.bind("", hide_tooltip) \ No newline at end of file + widget.bind("", hide_tooltip)