Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/core/animation_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,17 @@ def update_frame(self):
elif self.current_state == "thinking":
# Наклон + покачивание
painter.rotate(10 + 5 * math.sin(self.frame_counter * 0.2))
elif self.current_state == "playing":
# Покачивание и подпрыгивание
angle = 8 * math.sin(self.frame_counter * 0.5)
bounce = abs(10 * math.sin(self.frame_counter * 0.6))
painter.rotate(angle)
painter.translate(0, -bounce)
elif self.current_state == "shaking":
# Сильное встряхивание с динамическим изменением масштаба
scale_var = 1.0 + random.uniform(-0.1, 0.1)
painter.scale(scale_var, scale_var)
painter.translate(random.randint(-6, 6), random.randint(-6, 6))

painter.translate(-size.width() / 2, -size.height() / 2)

Expand Down
3 changes: 3 additions & 0 deletions src/core/input_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def stop(self):
self.keyboard_listener.stop()

class InputManager(QObject):
laser_mode_changed = Signal(bool)

def __init__(self, pet_window, data_store=None):
super().__init__()
self.window = pet_window
Expand Down Expand Up @@ -442,6 +444,7 @@ def handle_mouse(self, x, y):

def toggle_laser_mode(self):
self.laser_mode = not self.laser_mode
self.laser_mode_changed.emit(self.laser_mode)
if self.laser_mode:
self.window.animation_manager.play_state("hunting")
# Создаем красивый светящийся красный лазерный курсор
Expand Down
10 changes: 6 additions & 4 deletions src/ui/tray_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ def setup_menu(self):
self.menu.addSeparator()

# Лазерная указка
laser_action = QAction("Лазерная указка 🔴", self)
laser_action.setCheckable(True)
laser_action.triggered.connect(self.toggle_laser)
self.menu.addAction(laser_action)
self.laser_action = QAction("Лазерная указка 🔴", self)
self.laser_action.setCheckable(True)
self.laser_action.triggered.connect(self.toggle_laser)
if self.window.input_manager:
self.window.input_manager.laser_mode_changed.connect(self.laser_action.setChecked)
self.menu.addAction(self.laser_action)

self.menu.addSeparator()

Expand Down
55 changes: 55 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def test_always_on_top_logic(self):
flags = window.windowFlags()
self.assertFalse(bool(flags & Qt.WindowStaysOnTopHint))
self.assertFalse(config.get("always_on_top"))
window.close()

def test_config_manager(self):
config = ConfigManager(self.config_path)
Expand Down Expand Up @@ -306,6 +307,8 @@ def test_custom_skins_integration(self):
self.assertEqual(anim_mgr.skin, "custom_test_skin")
self.assertTrue(anim_mgr.current_anim_path.endswith("cat_custom_test_skin.svg"))

label.close()

# Очистка
if os.path.exists(test_svg_path):
os.remove(test_svg_path)
Expand Down Expand Up @@ -357,6 +360,7 @@ def test_delete_custom_skin(self):
self.assertEqual(config.get("skin"), "default")
self.assertNotIn("custom_todel_skin", config.get("custom_skins") or {})
finally:
dialog.close()
# Восстанавливаем моки гарантированно
QMessageBox.question = original_question
QMessageBox.information = original_information
Expand Down Expand Up @@ -411,6 +415,7 @@ def test_animation_manager_current_fps(self):
# Тест кастомного FPS
am.current_fps = 15
self.assertEqual(am.current_fps, 15)
label.close()

def test_sound_manager_fallback(self):
from src.utils.sound_manager import SoundManager
Expand Down Expand Up @@ -481,6 +486,55 @@ def test_input_manager_reset_logic(self):

db.close()

def test_procedural_animations_playing_shaking(self):
os.environ["QT_QPA_PLATFORM"] = "offscreen"
from PySide6.QtWidgets import QApplication, QLabel
from PySide6.QtSvg import QSvgRenderer
from src.core.animation_manager import AnimationManager

app = QApplication.instance() or QApplication([])
label = QLabel()
label.resize(100, 100)
config = ConfigManager(self.config_path)
am = AnimationManager(label, config)

# 1. Проверяем обновление кадра для 'playing'
am.current_state = "playing"
am.svg_renderer = MagicMock(spec=QSvgRenderer)
self.assertEqual(am.current_state, "playing")
am.update_frame()
am.svg_renderer.render.assert_called()

# 2. Проверяем обновление кадра для 'shaking'
am.current_state = "shaking"
am.svg_renderer = MagicMock(spec=QSvgRenderer)
self.assertEqual(am.current_state, "shaking")
am.update_frame()
am.svg_renderer.render.assert_called()

label.close()

def test_laser_mode_changed_signal(self):
mock_window = MagicMock()
mock_cursor = MagicMock()
mock_cursor.pos.return_value = QPoint(100, 100)
mock_window.cursor.return_value = mock_cursor

db = DataStore(self.db_path)
im = InputManager(mock_window, db)

signal_received = []
im.laser_mode_changed.connect(lambda val: signal_received.append(val))

# Переключаем режим лазера и проверяем излучение сигнала
im.toggle_laser_mode()
self.assertEqual(signal_received, [True])

im.toggle_laser_mode()
self.assertEqual(signal_received, [True, False])

db.close()

def test_stats_dialog_reset_ui_flow(self):
from src.ui.stats_dialog import StatsDialog
from PySide6.QtWidgets import QMessageBox, QApplication
Expand Down Expand Up @@ -512,6 +566,7 @@ def test_stats_dialog_reset_ui_flow(self):
self.assertEqual(db.get_affection_points(), 0)
QMessageBox.information.assert_called_once()
finally:
dialog.close()
QMessageBox.question = original_question
QMessageBox.information = original_information
db.close()
Expand Down
Binary file modified verification/screenshots/stats_history.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.