From 76245b3adce2dbbbcc48851dcceace2eeee0a4a1 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Mon, 8 Sep 2025 20:26:15 +0200 Subject: [PATCH] Fix loading variables quote on quote....... --- croppa/main.py | 56 +++++++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/croppa/main.py b/croppa/main.py index ca7d0af..51dcfe6 100644 --- a/croppa/main.py +++ b/croppa/main.py @@ -215,25 +215,31 @@ class VideoEditor: # Restore state values if 'current_frame' in state: self.current_frame = state['current_frame'] + print(f"Loaded current_frame: {self.current_frame}") if 'crop_rect' in state and state['crop_rect'] is not None: self.crop_rect = tuple(state['crop_rect']) - print(f"DEBUG: Loaded crop_rect: {self.crop_rect}") + print(f"Loaded crop_rect: {self.crop_rect}") if 'zoom_factor' in state: self.zoom_factor = state['zoom_factor'] + print(f"Loaded zoom_factor: {self.zoom_factor}") if 'zoom_center' in state and state['zoom_center'] is not None: self.zoom_center = tuple(state['zoom_center']) + print(f"Loaded zoom_center: {self.zoom_center}") if 'rotation_angle' in state: self.rotation_angle = state['rotation_angle'] + print(f"Loaded rotation_angle: {self.rotation_angle}") if 'brightness' in state: self.brightness = state['brightness'] + print(f"Loaded brightness: {self.brightness}") if 'contrast' in state: self.contrast = state['contrast'] + print(f"Loaded contrast: {self.contrast}") if 'cut_start_frame' in state: self.cut_start_frame = state['cut_start_frame'] - print(f"Restored cut_start_frame: {self.cut_start_frame}") + print(f"Loaded cut_start_frame: {self.cut_start_frame}") if 'cut_end_frame' in state: self.cut_end_frame = state['cut_end_frame'] - print(f"Restored cut_end_frame: {self.cut_end_frame}") + print(f"Loaded cut_end_frame: {self.cut_end_frame}") # Validate cut markers against current video length if self.cut_start_frame is not None and self.cut_start_frame >= self.total_frames: @@ -250,14 +256,19 @@ class VideoEditor: print(f"Markers will be drawn at: Start {start_progress:.4f} ({self.cut_start_frame}/{self.total_frames}), End {end_progress:.4f} ({self.cut_end_frame}/{self.total_frames})") if 'looping_between_markers' in state: self.looping_between_markers = state['looping_between_markers'] + print(f"Loaded looping_between_markers: {self.looping_between_markers}") if 'display_offset' in state: self.display_offset = state['display_offset'] + print(f"Loaded display_offset: {self.display_offset}") if 'playback_speed' in state: self.playback_speed = state['playback_speed'] + print(f"Loaded playback_speed: {self.playback_speed}") if 'seek_multiplier' in state: self.seek_multiplier = state['seek_multiplier'] + print(f"Loaded seek_multiplier: {self.seek_multiplier}") if 'is_playing' in state: self.is_playing = state['is_playing'] + print(f"Loaded is_playing: {self.is_playing}") # Validate and clamp values self.current_frame = max(0, min(self.current_frame, getattr(self, 'total_frames', 1) - 1)) @@ -443,26 +454,7 @@ class VideoEditor: if self.fps > 60: print(" Warning: High framerate video - may impact playback smoothness") - # Reset playback state for new media - self.current_frame = 0 - self.is_playing = False if self.is_image_mode else False # Images start paused - self.playback_speed = 1.0 - self.seek_multiplier = 1.0 - self.current_display_frame = None - - # Reset crop, zoom, rotation, brightness/contrast, and cut settings for new media - self.crop_rect = None - self.crop_history = [] - self.zoom_factor = 1.0 - self.zoom_center = None - self.rotation_angle = 0 - self.brightness = 0 - self.contrast = 1.0 - self.cut_start_frame = None - self.cut_end_frame = None - self.display_offset = [0, 0] - - # Try to load saved state for this media file + # Try to load saved state for this media file first if self.load_state(): print("Loaded saved state for this media file") if self.cut_start_frame is not None: @@ -471,6 +463,24 @@ class VideoEditor: print(f" Cut end frame: {self.cut_end_frame}") else: print("No saved state found for this media file") + # Only reset to defaults if no state was loaded + self.current_frame = 0 + self.is_playing = False if self.is_image_mode else False # Images start paused + self.playback_speed = 1.0 + self.seek_multiplier = 1.0 + self.crop_rect = None + self.crop_history = [] + self.zoom_factor = 1.0 + self.zoom_center = None + self.rotation_angle = 0 + self.brightness = 0 + self.contrast = 1.0 + self.cut_start_frame = None + self.cut_end_frame = None + self.display_offset = [0, 0] + + # Always reset these regardless of state + self.current_display_frame = None def switch_to_video(self, index: int): """Switch to a specific video by index"""