@@ -490,7 +490,7 @@ def create_crop_editor_window(
490490 [sg .Frame ("Crop Entries" , crop_frame , expand_x = True )],
491491 [sg .Frame ("Edit Entry" , edit_frame , expand_x = True )],
492492 [
493- sg .Button ("Save Database" , key = "-SAVE_DB-" ),
493+ sg .Button ("Apply Changes to Database" , key = "-SAVE_DB-" ),
494494 sg .Button ("Reload Database" , key = "-RELOAD_DB-" ),
495495 sg .Button ("Close" , key = "-CLOSE-" ),
496496 ],
@@ -558,9 +558,6 @@ def load_entry_to_edit(entry: ArtCropData):
558558 window ["-CARD_RESULTS-" ].update (values = display_results )
559559 else :
560560 window ["-CARD_RESULTS-" ].update (values = [])
561- sg .popup_error (
562- f"No cards found matching '{ search_term } '" , title = "Search"
563- )
564561
565562 if event == "-CARD_RESULTS-" :
566563 # User selected a card from the search results
@@ -575,11 +572,6 @@ def load_entry_to_edit(entry: ArtCropData):
575572 update_crop_table (filtered_crops )
576573 clear_edit_fields ()
577574
578- if not filtered_crops :
579- sg .popup_error (
580- f"No crop entries found for ArtId { art_id } " , title = "No Results"
581- )
582-
583575 if event == "-CROP_TABLE-" :
584576 # User selected a row in the crop table
585577 if values ["-CROP_TABLE-" ]:
@@ -642,27 +634,37 @@ def load_entry_to_edit(entry: ArtCropData):
642634
643635 if event == "-DUPLICATE_PATH-" :
644636 # Create a new entry with the same path but customizable other fields
637+ # Allow creation even if no row is selected, as long as an ArtId is selected
645638 if selected_entry_index is not None and 0 <= selected_entry_index < len (
646639 filtered_crops
647640 ):
648- try :
649- # Get the path from the selected entry
650- selected_entry = filtered_crops [selected_entry_index ]
651- duplicate_path = selected_entry .path
641+ duplicate_path = filtered_crops [selected_entry_index ].path
642+ elif current_art_id :
643+ # Build the path from the current ArtId
644+ art_id_padded = current_art_id .zfill (6 )
645+ folder = art_id_padded [:3 ] + "000"
646+ duplicate_path = f"Assets/Core/CardArt/{ folder } /{ art_id_padded } _AIF"
647+ else :
648+ sg .popup_error (
649+ "Please select a card or a crop entry first" , title = "No Selection"
650+ )
651+ duplicate_path = None
652652
653+ if duplicate_path is not None :
654+ try :
653655 # Create a popup to get the new values
654656 duplicate_layout = [
655657 [
656658 sg .Text (
657- "Creating new entry with same path" ,
659+ "Creating new entry with path" ,
658660 font = ("Arial" , 10 , "bold" ),
659661 )
660662 ],
661663 [sg .Text (f"Path: { duplicate_path } " , text_color = "blue" )],
662664 [sg .HorizontalSeparator ()],
663665 [
664666 sg .Text ("Format:" ),
665- sg .Input ("" , key = "-DUP_FORMAT-" , size = (15 , 1 )),
667+ sg .Input ("Normal " , key = "-DUP_FORMAT-" , size = (15 , 1 )),
666668 ],
667669 [
668670 sg .Text ("X:" ),
@@ -678,7 +680,7 @@ def load_entry_to_edit(entry: ArtCropData):
678680 ],
679681 [
680682 sg .Text ("Generated:" ),
681- sg .Input ("" , key = "-DUP_GENERATED-" , size = (10 , 1 )),
683+ sg .Input ("1 " , key = "-DUP_GENERATED-" , size = (10 , 1 )),
682684 ],
683685 [
684686 sg .Button ("Create" , key = "-DUP_CREATE-" ),
@@ -779,10 +781,6 @@ def load_entry_to_edit(entry: ArtCropData):
779781
780782 except Exception as e :
781783 sg .popup_error (f"Error: { e } " , title = "Error" )
782- else :
783- sg .popup_error (
784- "Please select an entry from the table first" , title = "No Selection"
785- )
786784
787785 if event == "-DELETE_ROW-" :
788786 # Delete the selected entry
0 commit comments