diff --git a/src/core/animation_manager.py b/src/core/animation_manager.py index 071361f..a5bfad1 100644 --- a/src/core/animation_manager.py +++ b/src/core/animation_manager.py @@ -23,6 +23,7 @@ def __init__(self, label: QLabel, config=None): self.cached_pixmap = None self.last_size = QSize(0, 0) self.main_window = self.label.window() + self._path_cache = {} # Таймер для процедурной SVG анимации self.anim_timer = QTimer() @@ -185,7 +186,15 @@ def play_state(self, state, force=False): for i in range(1, 5): possible_files.append(get_animation_path(self.pet_type, state, i)) - valid_files = [f for f in possible_files if os.path.exists(f)] + valid_files = [] + for f in possible_files: + if f in self._path_cache: + exists = self._path_cache[f] + else: + exists = os.path.exists(f) + self._path_cache[f] = exists + if exists: + valid_files.append(f) if valid_files: path = random.choice(valid_files) @@ -215,4 +224,3 @@ def set_skin(self, skin_name): def set_mouse_pos(self, x, y): self.last_mouse_pos = (x, y) - self.last_mouse_pos_qpoint = QPoint(x, y) diff --git a/src/core/input_manager.py b/src/core/input_manager.py index ac23bb7..87c237f 100644 --- a/src/core/input_manager.py +++ b/src/core/input_manager.py @@ -60,6 +60,8 @@ def __init__(self, pet_window, data_store=None): self.last_mouse_pos = (0, 0) self.last_input_time = time.time() self.last_purr_time = 0 + self.last_pet_time = 0 + self.last_pet_mouse_pos = (0, 0) self.laser_mode = False self.monitor.key_pressed.connect(self.handle_key) @@ -332,14 +334,25 @@ def handle_mouse(self, x, y): # Оптимизация: сравнение квадрата расстояния (порог 60px -> 3600) if dist_sq_pet < 3600: - if self.window.animation_manager.current_state not in ["playing", "hunting", "shaking"]: - self.window.animation_manager.play_state("playing") - self.pending_stats["petting_count"] += 1 - if self.pending_stats["petting_count"] % 5 == 0: - self.check_for_achievements() - if now - self.last_purr_time > 2.0: - self.window.sound_manager.play_sound("purr") - self.last_purr_time = now + # Требуем движения мыши (минимум 30px от прошлого поглаживания) и кулдаун 500мс + dx_move = x - self.last_pet_mouse_pos[0] + dy_move = y - self.last_pet_mouse_pos[1] + move_dist_sq = dx_move * dx_move + dy_move * dy_move + + if move_dist_sq > 900 and (now - self.last_pet_time) > 0.5: + if self.window.animation_manager.current_state not in ["playing", "hunting", "shaking"]: + self.window.animation_manager.play_state("playing") + + self.pending_stats["petting_count"] += 1 + self.last_pet_time = now + self.last_pet_mouse_pos = (x, y) + + if self.pending_stats["petting_count"] % 5 == 0: + self.check_for_achievements() + + if now - self.last_purr_time > 2.0: + self.window.sound_manager.play_sound("purr") + self.last_purr_time = now def toggle_laser_mode(self): self.laser_mode = not self.laser_mode diff --git a/src/ui/stats_dialog.py b/src/ui/stats_dialog.py index 24852a4..b2ba833 100644 --- a/src/ui/stats_dialog.py +++ b/src/ui/stats_dialog.py @@ -45,12 +45,15 @@ def setup_progress_tab(self, widget): # Общие очки и KPS в одной строке stats_row = QHBoxLayout() points_label = QLabel(f"Всего: {points} ❤️") + stats_row.addWidget(points_label) max_kps = self.db.get_stat("max_kps") kps_label = QLabel(f"Рекорд скорости: {max_kps} кл/сек ⚡") - kps_label.setAlignment(Qt.AlignCenter) - kps_label.setStyleSheet("color: #555; font-size: 11px; margin-bottom: 5px;") - layout.addWidget(kps_label) + kps_label.setAlignment(Qt.AlignRight | Qt.AlignVCenter) + kps_label.setStyleSheet("color: #555; font-size: 11px;") + stats_row.addWidget(kps_label) + + layout.addLayout(stats_row) # Прогресс бар if points_for_next_level > 0: diff --git a/verification/screenshots/stats_history.png b/verification/screenshots/stats_history.png index 962895b..472c96d 100644 Binary files a/verification/screenshots/stats_history.png and b/verification/screenshots/stats_history.png differ diff --git a/verification/screenshots/stats_progress.png b/verification/screenshots/stats_progress.png index a048687..6e85081 100644 Binary files a/verification/screenshots/stats_progress.png and b/verification/screenshots/stats_progress.png differ