-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpi_errors.py
More file actions
1032 lines (928 loc) · 36.7 KB
/
pi_errors.py
File metadata and controls
1032 lines (928 loc) · 36.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""
Centralized Error and Message Management for TS4 Creator Tools
Provides user-friendly error messages and consistent popup handling across the addon.
"""
import bpy
class ErrorManager:
"""Centralized error and message handling for TS4 Creator Tools"""
# Message categories
SELECTION = "selection"
FILE = "file"
CONTEXT = "context"
VALIDATION = "validation"
PROCESS = "process"
SUCCESS = "success"
# Centralized message definitions with user-friendly content
MESSAGES = {
# === SELECTION ERRORS ===
"no_object_selected": {
"category": SELECTION,
"title": "No Object Selected",
"message": "Please select an object to continue.",
"details": [
"Make sure objects are visible in the viewport",
"Check the Outliner if objects seem missing"
],
"icon": "ERROR"
},
"no_mesh_selected": {
"category": SELECTION,
"title": "No Mesh Selected",
"message": "Please select a mesh object to continue.",
"details": [
"Only mesh objects can be used for this operation",
"Select a mesh from the 3D viewport or Outliner",
"Make sure the selected object is a mesh type"
],
"icon": "ERROR"
},
"wrong_object_type": {
"category": SELECTION,
"title": "Wrong Object Type",
"message": "Selected object is not a mesh.",
"details": [
"This tool only works with mesh objects",
"Select a different object or convert to mesh"
],
"icon": "ERROR"
},
"selected_not_mesh": {
"category": SELECTION,
"title": "Not a Mesh Object",
"message": "Selected object is not a mesh.",
"details": [
"This operation only works with mesh objects",
"Select a mesh object from the viewport or Outliner",
"Ensure the selected object type is MESH"
],
"icon": "ERROR"
},
"no_ash_mesh_found": {
"category": SELECTION,
"title": "No _ASH Mesh Found",
"message": "Could not find a mesh with '_ASH' suffix in the scene.",
"details": [
"Use 'Rename Mesh: Add _ASH' button first",
"Make sure you've renamed your shoe mesh with _ASH suffix",
"Check that the mesh is visible in the scene"
],
"icon": "ERROR"
},
"ash_mesh_hidden": {
"category": SELECTION,
"title": "_ASH Mesh Hidden",
"message": "The _ASH mesh is hidden and cannot be processed.",
"details": [
"Unhide the mesh in the viewport or Outliner",
"Make sure the mesh is visible and selectable",
"Check visibility toggles in the Outliner"
],
"icon": "ERROR"
},
"object_hidden": {
"category": SELECTION,
"title": "Object Hidden",
"message": "The selected object is hidden and cannot be processed.",
"details": [
"Unhide the object in the viewport or Outliner",
"Make sure the object is visible and selectable",
"Check visibility toggles in the Outliner"
],
"icon": "ERROR"
},
# === FILE ERRORS ===
"file_not_found": {
"category": FILE,
"title": "File Not Found",
"message": "The requested file could not be found.",
"details": [
"Check that the file path is correct",
"Verify the file exists in the expected location",
"Try reinstalling the addon if using built-in assets"
],
"icon": "ERROR"
},
"asset_file_missing": {
"category": FILE,
"title": "Asset File Missing",
"message": "The asset file is missing from the addon.",
"details": [
"This usually means the addon installation is incomplete",
"Try reinstalling the TS4 Creator Tools addon",
"Contact support if the problem persists"
],
"icon": "ERROR"
},
"custom_asset_not_found": {
"category": FILE,
"title": "Custom Asset Not Found",
"message": "Could not find the requested custom asset.",
"details": [
"Check that the file exists in your custom assets folder",
"Verify the file name and extension are correct",
"Make sure custom asset paths are set up properly"
],
"icon": "ERROR"
},
"rig_file_not_found": {
"category": FILE,
"title": "Rig File Not Found",
"message": "Rig file not found: {file_path}",
"details": [
"Check that the rig file exists in the expected location",
"Verify the file name and path are correct",
"Make sure the addon assets are properly installed"
],
"icon": "ERROR"
},
"occult_file_not_found": {
"category": FILE,
"title": "Occult File Not Found",
"message": "Occult item file not found: {file_path}",
"details": [
"Searched in: {search_location}",
"Check that the file exists in the addon assets folder",
"Verify the file name is correct"
],
"icon": "ERROR"
},
"cas_file_not_found": {
"category": FILE,
"title": "CAS File Not Found",
"message": "CAS item file not found: {file_path}",
"details": [
"Searched in: {search_location}",
"Check that the file exists in the addon assets folder",
"Verify the file name is correct"
],
"icon": "ERROR"
},
"body_file_not_found": {
"category": FILE,
"title": "Body File Not Found",
"message": "Body base file not found: {file_path}",
"details": [
"Searched in: {search_location}",
"Check that the file exists in the addon assets folder",
"Verify the file name is correct"
],
"icon": "ERROR"
},
"custom_file_not_found": {
"category": FILE,
"title": "Custom File Not Found",
"message": "File not found: {file_path}",
"details": [
"Check that the file exists in your custom assets folder",
"Verify the file path and name are correct",
"Make sure the custom assets are set up properly"
],
"icon": "ERROR"
},
"folder_open_error": {
"category": PROCESS,
"title": "Folder Open Error",
"message": "Could not open folder: {error}",
"details": [
"There was an error opening the assets folder",
"Check that the folder path is valid",
"Try accessing the folder manually"
],
"icon": "ERROR"
},
# === CONTEXT ERRORS ===
"wrong_mode": {
"category": CONTEXT,
"title": "Wrong Mode",
"message": "This operation requires a different mode.",
"details": [
"Switch to the appropriate mode (Object/Edit)",
"Some tools only work in specific modes"
],
"icon": "ERROR"
},
"exit_edit_mode": {
"category": CONTEXT,
"title": "Exit Edit Mode",
"message": "Please exit Edit Mode first.",
"details": [
"Press Tab to switch to Object Mode",
"This operation requires Object Mode"
],
"icon": "ERROR"
},
"wrong_mode_edit_required": {
"category": CONTEXT,
"title": "Edit Mode Required",
"message": "Please enter Edit Mode first.",
"details": [
"Press Tab to switch to Edit Mode",
"This operation requires Edit Mode",
"Select face(s) before calculating Z coordinate"
],
"icon": "ERROR"
},
"no_rig_found": {
"category": CONTEXT,
"title": "No Rig Found",
"message": "Cannot find a rig in your scene.",
"details": [
"Load a rig using the 'Load Rig' button first",
"Make sure the rig is visible and not hidden",
"Check that you have an armature object in your scene"
],
"icon": "ERROR"
},
"rig_not_found": {
"category": CONTEXT,
"title": "No Rig Found",
"message": "No armature containing 'rig' found in scene.",
"details": [
"Import a rig file first using the 'Load Rig' button",
"Make sure your armature has 'rig' in its name",
"Check that the rig object is not hidden"
],
"icon": "ERROR"
},
"rig_target_meshes_not_found": {
"category": CONTEXT,
"title": "Target Meshes Not Found",
"message": "Target mesh objects could not be found.",
"details": [
"This is an internal error with mesh selection",
"Try selecting your meshes again",
"Restart the rig linking process"
],
"icon": "ERROR"
},
"rig_valid_meshes_not_found": {
"category": CONTEXT,
"title": "No Valid Meshes Found",
"message": "No valid target mesh objects found.",
"details": [
"Make sure the selected objects still exist",
"Check that objects haven't been deleted",
"Try reselecting your mesh objects"
],
"icon": "ERROR"
},
"selected_rig_not_found": {
"category": CONTEXT,
"title": "Selected Rig Not Found",
"message": "The selected rig could not be found.",
"details": [
"The rig may have been deleted or renamed",
"Try refreshing the rig list",
"Make sure the rig still exists in the scene"
],
"icon": "ERROR"
},
# === VALIDATION ERRORS ===
"no_weight_groups": {
"category": VALIDATION,
"title": "No Vertex Groups",
"message": "The selected object has no vertex groups for weight transfer.",
"details": [
"The source object needs vertex groups to transfer weights",
"Make sure you selected the right object",
"Check that the object has been properly rigged"
],
"icon": "ERROR"
},
"invalid_mesh_data": {
"category": VALIDATION,
"title": "Invalid Mesh Data",
"message": "The mesh data appears to be corrupt or invalid.",
"details": [
"Try reloading the object or file",
"The mesh may have been corrupted",
"Consider using a backup version"
],
"icon": "ERROR"
},
"topology_mismatch": {
"category": VALIDATION,
"title": "Topology Mismatch",
"message": "The meshes have different topology.",
"details": [
"Both meshes need the same number of vertices and faces",
"Make sure you're using compatible mesh versions",
"Consider using a different transfer method"
],
"icon": "ERROR"
},
"no_marked_vertices": {
"category": VALIDATION,
"title": "No Vertices Marked",
"message": "No vertices have been marked for this operation.",
"details": [
"Enter Edit Mode and select vertices first",
"Use the 'Mark LOD Vertices' button to mark them",
"Make sure you have vertices selected"
],
"icon": "ERROR"
},
"validation_error": {
"category": VALIDATION,
"title": "Validation Error",
"message": "A validation check failed.",
"details": [
"Please check the requirements for this operation",
"Make sure all needed objects and data are present"
],
"icon": "ERROR"
},
# === PROCESS ERRORS ===
"operation_failed": {
"category": PROCESS,
"title": "Operation Failed",
"message": "The operation could not be completed.",
"details": [
"An unexpected error occurred",
"Try the operation again",
"Check that all requirements are met"
],
"icon": "ERROR"
},
"connection_failed": {
"category": PROCESS,
"title": "Connection Failed",
"message": "Could not connect vertices to target objects.",
"details": [
"Make sure target objects are close enough",
"Check that vertices are properly marked",
"Verify that target objects exist and are visible"
],
"icon": "ERROR"
},
"blender_context_error": {
"category": PROCESS,
"title": "Blender Context Error",
"message": "Blender is not in the right state for this operation.",
"details": [
"Try switching modes or refreshing the interface",
"Some operations require specific Blender states",
"Restart Blender if problems persist"
],
"icon": "ERROR"
},
# === SUCCESS MESSAGES ===
"operation_complete": {
"category": SUCCESS,
"title": "Operation Complete",
"message": "The operation completed successfully!",
"details": [],
"icon": "CHECKMARK"
},
"weights_transferred": {
"category": SUCCESS,
"title": "Weights Transferred",
"message": "Vertex weights have been transferred successfully.",
"details": [
"Weights have been transferred to your mesh.",
],
"icon": "CHECKMARK"
},
"mesh_subdivided": {
"category": SUCCESS,
"title": "Mesh Subdivided",
"message": "REF mesh has been subdivided successfully.",
"details": [
"The mesh now has more geometry for detailed work."
],
"icon": "CHECKMARK"
},
"weights_smoothed": {
"category": SUCCESS,
"title": "Weights Smoothed",
"message": "Vertex weights have been smoothed.",
"details": [
"Weight transitions should now be smoother",
],
"icon": "CHECKMARK"
},
"weights_limited": {
"category": SUCCESS,
"title": "Weights Limited",
"message": "Limited the number of weights per vertex.",
"details": [
"Each vertex now influences a maximum number of bones",
],
"icon": "CHECKMARK"
},
"doubles_removed": {
"category": SUCCESS,
"title": "Duplicates Removed",
"message": "Duplicate vertices have been merged.",
"details": [
"Stray vertices have been removed.",
],
"icon": "CHECKMARK"
},
"faces_converted": {
"category": SUCCESS,
"title": "Faces Converted",
"message": "Face topology has been changed successfully.",
"details": [
"Mesh faces have been converted."
],
"icon": "CHECKMARK"
},
"rig_linked": {
"category": SUCCESS,
"title": "Rig Linked",
"message": "Rig has been linked to your meshes.",
"details": [
"Your meshes are now linked to the armature",
],
"icon": "CHECKMARK"
},
"vertex_color_applied": {
"category": SUCCESS,
"title": "Vertex Color Applied",
"message": "Vertex colors have been applied successfully.",
"details": [],
"icon": "CHECKMARK"
},
"uv_setup_complete": {
"category": SUCCESS,
"title": "UV Setup Complete",
"message": "UV maps have been set up correctly.",
"details": [
"Your mesh is now ready for texturing",
"Make sure to unwrap your UVs if needed"
],
"icon": "CHECKMARK"
},
"lod_created": {
"category": SUCCESS,
"title": "LOD Levels Created",
"message": "Level of Detail meshes have been generated.",
"details": [
"All LODs have been placed in the LOD Collection",
],
"icon": "CHECKMARK"
},
"vertices_connected": {
"category": SUCCESS,
"title": "Vertices Connected",
"message": "Vertices have been connected successfully.",
"details": [
"Marked vertices are now positioned properly",
],
"icon": "CHECKMARK"
},
"collection_created": {
"category": SUCCESS,
"title": "Collection Created",
"message": "Baking collection has been created.",
"details": [
"Add your meshes to this collection before baking",
],
"icon": "CHECKMARK"
},
"bake_file_opened": {
"category": SUCCESS,
"title": "Bake File Opened",
"message": "Shadow bake file has been opened in a new window.",
"details": [
"The baking setup is ready to use",
"Your meshes have been imported automatically"
],
"icon": "CHECKMARK"
},
"rig_linked_single": {
"category": SUCCESS,
"title": "Rig Linked",
"message": "Mesh successfully linked to rig.",
"details": [
"Your mesh is now connected to the armature",
"You can now pose and animate your character",
"The armature modifier has been applied"
],
"icon": "CHECKMARK"
},
"rig_linked_multiple": {
"category": SUCCESS,
"title": "Multiple Meshes Linked",
"message": "{count} meshes successfully linked to rig.",
"details": [
"All selected meshes are now connected to the armature",
"You can now pose and animate your character",
"Armature modifiers have been applied to all meshes"
],
"icon": "CHECKMARK"
},
"rig_link_partial_failure": {
"category": PROCESS,
"title": "Partial Rig Link Failure",
"message": "{success} meshes linked successfully, {failed} failed.",
"details": [
"Some meshes could not be linked to the rig",
"This may be due to invalid mesh data or context issues",
"Try linking the failed meshes individually"
],
"icon": "ERROR"
},
"mesh_renamed": {
"category": SUCCESS,
"title": "Mesh Renamed",
"message": "Mesh renamed to: {name}",
"details": [
"The _ASH suffix has been added to the mesh name",
"This mesh can now be used for auto shoe height calculation",
"Use 'Calculate Z' next"
],
"icon": "CHECKMARK"
},
"mesh_already_has_ash": {
"category": SUCCESS,
"title": "Already Has _ASH Suffix",
"message": "This mesh already has the _ASH suffix.",
"details": [
"No changes were made to the mesh name",
"You can proceed with finding the lowest face"
],
"icon": "CHECKMARK"
},
"ash_lowest_found": {
"category": SUCCESS,
"title": "Lowest Face Found",
"message": "Lowest Z coordinate: {z_value}",
"details": [
"The lowest face(s) have been selected in edit mode",
"Copy the Z value from the 'Lowest Z' field",
"Use this value for your shoe height in Sims 4 Studio"
],
"icon": "CHECKMARK"
},
"ash_lowest_updated": {
"category": SUCCESS,
"title": "Z Coordinate Updated",
"message": "Updated Z coordinate: {z_value}",
"details": [
"Z value calculated from currently selected face(s)",
"Copy the Z value from the 'Lowest Z' field",
"Use this value for your shoe height in Sims 4 Studio"
],
"icon": "CHECKMARK"
},
"no_faces_selected": {
"category": SELECTION,
"title": "No Faces Selected",
"message": "Please select at least one face in edit mode.",
"details": [
"Switch to face select mode (press 3)",
"Select the face(s) you want to measure",
"The Z coordinate will be calculated from selected faces"
],
"icon": "ERROR"
},
# === PREFERENCES ERRORS ===
"preferences_access_error": {
"category": PROCESS,
"title": "Preferences Access Error",
"message": "Could not access addon preferences.",
"details": [
"Try restarting Blender",
"Make sure the addon is properly installed",
"Check that addon preferences are accessible"
],
"icon": "ERROR"
},
"settings_reset_complete": {
"category": SUCCESS,
"title": "Settings Reset",
"message": "Bake settings have been reset to defaults.",
"details": [
"Device: Auto Detect",
"Samples: 50",
"Margin: 10",
],
"icon": "CHECKMARK"
},
# === BAKING ERRORS ===
"no_texture_queues": {
"category": VALIDATION,
"title": "No Texture Queues",
"message": "No texture queues found for batch baking.",
"details": [
"Create a queue first using 'Create Queue for Selected'",
"Then add images to the queue",
"Set an output folder for each queue"
],
"icon": "ERROR"
},
"no_valid_queues": {
"category": VALIDATION,
"title": "No Valid Queues",
"message": "No queues with images found.",
"details": [
"Add images to your queues first",
"Use 'Add Image to Queue' to add texture files",
"Make sure output folders are set"
],
"icon": "ERROR"
},
"output_folder_not_set": {
"category": VALIDATION,
"title": "Output Folder Not Set",
"message": "Output folder not set for {mesh_name}.",
"details": [
"Set an output folder for this mesh in the queue",
"Click on the 'Output Folder' field and select a directory",
"This is where baked textures will be saved"
],
"icon": "ERROR"
},
"no_files_added": {
"category": VALIDATION,
"title": "No Files Added",
"message": "No valid image files were added to the queue.",
"details": [
"Check that selected files are valid image formats",
"Supported formats: PNG, JPG, JPEG, TGA, TIFF",
"Make sure file paths are correct"
],
"icon": "ERROR"
},
"batch_baking_cancelled": {
"category": PROCESS,
"title": "Batch Baking Cancelled",
"message": "Batch baking has been cancelled.",
"details": [
"Check output folders for completed bakes"
],
"icon": "INFO"
},
"batch_baking_completed": {
"category": SUCCESS,
"title": "Batch Baking Completed",
"message": "Batch baking completed successfully!",
"details": [
"Check output folders for baked results"
],
"icon": "CHECKMARK"
},
"no_images_processed": {
"category": PROCESS,
"title": "No Images Processed",
"message": "No images were processed during batch baking.",
"details": [
"Check console for error messages",
"Verify that all texture files exist",
"Make sure materials are set up correctly"
],
"icon": "ERROR"
},
"queue_exists": {
"category": VALIDATION,
"title": "Queue Already Exists",
"message": "Queue already exists for {mesh_name}.",
"details": [
"Use the existing queue to add images",
"Or remove the existing queue first",
"Each mesh can only have one queue"
],
"icon": "INFO"
},
"queue_created": {
"category": SUCCESS,
"title": "Queue Created",
"message": "Created queue for {mesh_name}.",
"details": [
"Set output folder and add images",
"Use 'Add Image to Queue' to add texture files",
"Ready for batch baking"
],
"icon": "CHECKMARK"
},
"images_added_to_queue": {
"category": SUCCESS,
"title": "Images Added",
"message": "Added {count} images to {mesh_name} queue.",
"details": [
"Queue now has {total_count} images",
"Set output folder if not already done",
"Ready for batch baking"
],
"icon": "CHECKMARK"
},
"image_removed_from_queue": {
"category": SUCCESS,
"title": "Image Removed",
"message": "Removed image from queue.",
"details": [
"The selected image has been removed",
"Queue has been updated"
],
"icon": "CHECKMARK"
},
"queue_cleared": {
"category": SUCCESS,
"title": "Queue Cleared",
"message": "Cleared queue for {mesh_name}.",
"details": [
"All images have been removed from the queue",
"Queue is now empty"
],
"icon": "CHECKMARK"
},
"mesh_queue_removed": {
"category": SUCCESS,
"title": "Mesh Queue Removed",
"message": "Removed {mesh_name} from queue.",
"details": [
"The selected mesh queue has been deleted",
"All associated images have been removed"
],
"icon": "CHECKMARK"
},
"no_queue_selected": {
"category": SELECTION,
"title": "No Queue Selected",
"message": "No queue selected for this operation.",
"details": [
"Select a mesh queue from the list",
"Click on a queue entry to select it",
"Then try the operation again"
],
"icon": "ERROR"
},
"no_queue_for_mesh": {
"category": VALIDATION,
"title": "No Queue Found",
"message": "No queue found for {mesh_name}.",
"details": [
"Create a queue for this mesh first",
"Use 'Create Queue for Selected' button",
"Then add images to the queue"
],
"icon": "ERROR"
},
"materials_setup_complete": {
"category": SUCCESS,
"title": "Materials Setup Complete",
"message": "Setup materials for {count} objects.",
"details": [
"Added Baking Material",
],
"icon": "CHECKMARK"
},
"uv_setup_complete": {
"category": SUCCESS,
"title": "UV Maps Setup Complete",
"message": "Setup UV maps for {count} objects.",
"details": [
"OG_MAP: original map renamed",
"NEW_MAP: new bake map created",
],
"icon": "CHECKMARK"
},
"objects_duplicated": {
"category": SUCCESS,
"title": "Objects Duplicated",
"message": "Duplicated {count} objects to bake collection.",
"details": [
"Duplicates are now selected and ready for setup",
"Use 'Setup UV Maps' and 'Setup Materials' next",
],
"icon": "CHECKMARK"
},
}
@staticmethod
def show_popup(message_key, **kwargs):
"""
Show a detailed popup message.
Args:
message_key: Key from MESSAGES dictionary
**kwargs: Additional parameters for message formatting
- custom_message: Override the default message
- custom_details: Override the default details list
- count: For messages that show counts
- name: For messages that show object names
- file_path: For file-related messages
"""
if message_key not in ErrorManager.MESSAGES:
# Fallback for unknown message keys
def fallback_popup(self, context):
self.layout.label(text=f"Unknown message: {message_key}")
bpy.context.window_manager.popup_menu(fallback_popup, title="Creator Tools", icon='ERROR')
return
msg_data = ErrorManager.MESSAGES[message_key]
def popup_display(self, context):
layout = self.layout
# Main message
main_message = kwargs.get('custom_message', msg_data['message'])
if 'count' in kwargs and '{count}' in main_message:
main_message = main_message.format(count=kwargs['count'])
if 'name' in kwargs and '{name}' in main_message:
main_message = main_message.format(name=kwargs['name'])
if 'mesh_name' in kwargs and '{mesh_name}' in main_message:
main_message = main_message.format(mesh_name=kwargs['mesh_name'])
if 'total_count' in kwargs and '{total_count}' in main_message:
main_message = main_message.format(total_count=kwargs['total_count'])
if 'processed_count' in kwargs and '{processed_count}' in main_message:
main_message = main_message.format(processed_count=kwargs['processed_count'])
if 'file_path' in kwargs and '{file_path}' in main_message:
main_message = main_message.format(file_path=kwargs['file_path'])
if 'z_value' in kwargs and '{z_value}' in main_message:
main_message = main_message.format(z_value=kwargs['z_value'])
layout.label(text=main_message)
# Details section
details = kwargs.get('custom_details', msg_data.get('details', []))
if details:
layout.separator()
for detail in details:
layout.label(text=f"• {detail}")
# Additional custom info
if 'additional_info' in kwargs:
layout.separator()
for info in kwargs['additional_info']:
layout.label(text=info)
icon = msg_data.get('icon', 'INFO')
title = kwargs.get('title', 'Creator Tools')
bpy.context.window_manager.popup_menu(popup_display, title=title, icon=icon)
@staticmethod
def report(operator, message_key, report_type='INFO', **kwargs):
"""
Use operator.report() for simple messages.
Args:
operator: The calling operator instance
message_key: Key from MESSAGES dictionary
report_type: 'INFO', 'WARNING', 'ERROR'
**kwargs: Additional parameters for message formatting
"""
if message_key not in ErrorManager.MESSAGES:
operator.report({'ERROR'}, f"Unknown message: {message_key}")
return
msg_data = ErrorManager.MESSAGES[message_key]
message = kwargs.get('custom_message', msg_data['message'])
# Format message with provided parameters
if 'count' in kwargs and '{count}' in message:
message = message.format(count=kwargs['count'])
if 'name' in kwargs and '{name}' in message:
message = message.format(name=kwargs['name'])
if 'mesh_name' in kwargs and '{mesh_name}' in message:
message = message.format(mesh_name=kwargs['mesh_name'])
if 'total_count' in kwargs and '{total_count}' in message:
message = message.format(total_count=kwargs['total_count'])
if 'processed_count' in kwargs and '{processed_count}' in message:
message = message.format(processed_count=kwargs['processed_count'])
if 'file_path' in kwargs and '{file_path}' in message:
message = message.format(file_path=kwargs['file_path'])
if 'z_value' in kwargs and '{z_value}' in message:
message = message.format(z_value=kwargs['z_value'])
operator.report({report_type}, message)
@staticmethod
def show_error(error_key, **kwargs):
"""Convenience method for showing error popups"""
ErrorManager.show_popup(error_key, **kwargs)
@staticmethod
def show_success(success_key, **kwargs):
"""Convenience method for showing success popups"""
ErrorManager.show_popup(success_key, **kwargs)
# Convenience functions for common error patterns
def show_no_object_selected():
"""Show 'no object selected' error"""
ErrorManager.show_error('no_object_selected')
def show_no_mesh_selected():
"""Show 'no mesh selected' error"""
ErrorManager.show_error('no_mesh_selected')
def show_wrong_mode():
"""Show 'wrong mode' error"""
ErrorManager.show_error('wrong_mode')
def show_exit_edit_mode():
"""Show 'exit edit mode' error"""
ErrorManager.show_error('exit_edit_mode')
def show_file_not_found(file_path=""):
"""Show 'file not found' error"""
ErrorManager.show_error('file_not_found',
custom_details=[f"File: {file_path}"] if file_path else None)