Skip to content
Open
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
12 changes: 10 additions & 2 deletions src/core/animation_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
29 changes: 21 additions & 8 deletions src/core/input_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions src/ui/stats_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
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.
Binary file modified verification/screenshots/stats_progress.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.