@@ -346,6 +346,16 @@ class MayaUnrealTurntablePublishPlugin(HookBaseClass):
346
346
347
347
# NOTE: The plugin icon and name are defined by the base file plugin.
348
348
349
+ # List of settings to save and their save code
350
+ _save_settings = (
351
+ ("Unreal Engine Version" , "publish2.unreal_engine_version" ),
352
+ ("Unreal Engine Path" , "publish2.unreal_engine_path" ),
353
+ ("Unreal Project Path" , "publish2.turntable.unreal_project_path" ),
354
+ ("Turntable Map Path" , "publish2.turntable.map_path" ),
355
+ ("Sequence Path" , "publish2.turntable.sequence_path" ),
356
+ ("Turntable Assets Path" , "publish2.turntable.assets_path" ),
357
+ )
358
+
349
359
@property
350
360
def description (self ):
351
361
"""
@@ -563,13 +573,60 @@ def set_ui_settings(self, widget, settings):
563
573
unreal_versions ,
564
574
cur_settings ["Unreal Engine Version" ],
565
575
)
576
+ widget .unreal_setup_widget .unreal_engine_widget .set_path (
577
+ cur_settings ["Unreal Engine Path" ]
578
+ )
566
579
widget .unreal_setup_widget .set_unreal_project_path_template (
567
580
cur_settings ["Unreal Project Path Template" ]
568
581
)
582
+ widget .unreal_setup_widget .unreal_project_widget .set_path (
583
+ cur_settings ["Unreal Project Path" ]
584
+ )
569
585
widget .unreal_turntable_map_widget .setText (cur_settings ["Turntable Map Path" ])
570
586
widget .unreal_sequence_widget .setText (cur_settings ["Sequence Path" ])
571
587
widget .unreal_turntable_asset_widget .setText (cur_settings ["Turntable Assets Path" ])
572
588
589
+ def load_saved_ui_settings (self , settings ):
590
+ """
591
+ Load saved settings and update the given settings dictionary with them.
592
+
593
+ :param settings: A dictionary where keys are settings names and
594
+ values Settings instances.
595
+ """
596
+ # Retrieve SG utils framework settings module and instantiate a manager
597
+ fw = self .load_framework ("tk-framework-shotgunutils_v5.x.x" )
598
+ module = fw .import_module ("settings" )
599
+ settings_manager = module .UserSettings (self .parent )
600
+
601
+ # Retrieve saved settings
602
+ for name , saved_name in self ._save_settings :
603
+ settings [name ].value = settings_manager .retrieve (
604
+ saved_name ,
605
+ settings [name ].value ,
606
+ settings_manager .SCOPE_PROJECT ,
607
+ )
608
+ self .logger .debug ("Loaded settings %s" % settings [name ])
609
+
610
+ def save_ui_settings (self , settings ):
611
+ """
612
+ Save UI settings.
613
+
614
+ :param settings: A dictionary of Settings instances.
615
+ """
616
+ # Retrieve SG utils framework settings module and instantiate a manager
617
+ fw = self .load_framework ("tk-framework-shotgunutils_v5.x.x" )
618
+ module = fw .import_module ("settings" )
619
+ settings_manager = module .UserSettings (self .parent )
620
+
621
+ # Save settings
622
+ for name , saved_name in self ._save_settings :
623
+ value = settings [name ].value
624
+ settings_manager .store (
625
+ saved_name ,
626
+ value ,
627
+ settings_manager .SCOPE_PROJECT
628
+ )
629
+
573
630
def accept (self , settings , item ):
574
631
"""
575
632
Method called by the publisher to determine if an item is of any
@@ -619,6 +676,8 @@ def accept(self, settings, item):
619
676
item .context_change_allowed = False
620
677
if accepted :
621
678
self .logger .info ("Accepting item %s" % item )
679
+ self .load_saved_ui_settings (settings )
680
+
622
681
return {
623
682
"accepted" : accepted ,
624
683
"checked" : True
@@ -755,6 +814,7 @@ def validate(self, settings, item):
755
814
return False
756
815
item .properties ["turntable_assets_path" ] = turntable_assets_path
757
816
817
+ self .save_ui_settings (settings )
758
818
return True
759
819
760
820
def get_unreal_exec_property (self , settings , item ):
0 commit comments