8
8
import sys
9
9
import os
10
10
11
- unreal .log ("Loading Shotgun Engine for Unreal from {}" .format (__file__ ))
11
+ unreal .log ("Loading SG Engine for Unreal from {}" .format (__file__ ))
12
+
13
+ # Shotgun integration components were renamed to Shotgrid from UE5
14
+ if hasattr (unreal , "ShotgridEngine" ):
15
+ UESGEngine = unreal .ShotgridEngine
16
+
17
+ else :
18
+ UESGEngine = unreal .ShotgunEngine
12
19
13
20
14
21
@unreal .uclass ()
15
- class ShotgunEngineWrapper (unreal . ShotgunEngine ):
22
+ class ShotgunEngineWrapper (UESGEngine ):
16
23
17
24
def _post_init (self ):
18
25
"""
19
26
Equivalent to __init__ but will also be called from C++
20
27
"""
21
28
config .wrapper_instance = self
22
29
23
- @unreal .ufunction (override = True )
24
- def get_shotgun_menu_items (self ):
25
- """
26
- Returns the list of available menu items to populate the Shotgun menu in Unreal
27
- """
28
- menu_items = []
29
-
30
- engine = sgtk .platform .current_engine ()
31
- menu_items = self .create_menu (engine )
32
-
33
- unreal .log ("get_shotgun_menu_items returned: {0}" .format (menu_items .__str__ ()))
34
-
35
- return menu_items
30
+ # Shotgun integration components were renamed to Shotgrid from UE5
31
+ # these new methods are not available in UE4, we provide backward
32
+ # compatibility so scripts using the old methods don't break in UE5,
33
+ # but also forward compatibility, so users can start using the new
34
+ # names in UE4.
35
+ if hasattr (UESGEngine , "get_shotgrid_menu_items" ):
36
+ @unreal .ufunction (override = True )
37
+ def get_shotgrid_menu_items (self ):
38
+ """
39
+ Returns the list of available menu items to populate the SG menu in Unreal.
40
+ """
41
+ menu_items = []
42
+
43
+ engine = sgtk .platform .current_engine ()
44
+ menu_items = self .create_menu (engine )
45
+
46
+ unreal .log ("get_shotgrid_menu_items returned: {0}" .format (menu_items .__str__ ()))
47
+
48
+ return menu_items
49
+
50
+ def get_shotgun_menu_items (self ):
51
+ """
52
+ Provide backward compatibility.
53
+ """
54
+ unreal .log_warning ("get_shotgun_menu_items is deprecated, get_shotgrid_menu_items should be used instead." )
55
+ return self .get_shotgrid_menu_items ()
56
+ else :
57
+ @unreal .ufunction (override = True )
58
+ def get_shotgun_menu_items (self ):
59
+ """
60
+ Returns the list of available menu items to populate the SG menu in Unreal.
61
+ """
62
+ menu_items = []
63
+
64
+ engine = sgtk .platform .current_engine ()
65
+ menu_items = self .create_menu (engine )
66
+
67
+ unreal .log_warning ("get_shotgun_menu_items is deprecated, get_shotgrid_menu_items should be used instead." )
68
+ unreal .log ("get_shotgun_menu_items returned: {0}" .format (menu_items .__str__ ()))
69
+
70
+ return menu_items
71
+
72
+ def get_shotgrid_menu_items (self ):
73
+ """
74
+ Provide forward compatibility.
75
+ """
76
+ return self .get_shotgun_menu_items ()
77
+
78
+ if hasattr (UESGEngine , "get_shotgrid_work_dir" ):
79
+ def get_shotgun_work_dir (self , * args , ** kwargs ):
80
+ """
81
+ Provide backward compatibility.
82
+ """
83
+ unreal .log_warning ("get_shotgun_work_dir is deprecated, get_shotgrid_work_dir should be used instead." )
84
+ return self .get_shotgrid_work_dir (* args , ** kwargs )
85
+ else :
86
+ def get_shotgrid_work_dir (self , * args , ** kwargs ):
87
+ """
88
+ Provide forward compatibility.
89
+ """
90
+ return self .get_shotgun_work_dir (* args , ** kwargs )
36
91
37
92
@unreal .ufunction (override = True )
38
93
def execute_command (self , command_name ):
39
94
"""
40
- Callback to execute the menu item selected in the Shotgun menu in Unreal
95
+ Callback to execute the menu item selected in the SG menu in Unreal.
41
96
"""
42
97
engine = sgtk .platform .current_engine ()
43
98
@@ -58,9 +113,9 @@ def _get_command_override(self, engine, command_name, default_callback):
58
113
:param command_name: The command name to override
59
114
:param default_callback: The callback to use when there's no override
60
115
"""
61
- # Override the Shotgun Panel command to use the Shotgun Entity context
116
+ # Override the SG Panel command to use the SG Entity context
62
117
# and also reuse the dialog if one already exists
63
- if command_name == "Shotgun Panel..." :
118
+ if command_name in [ "Shotgun Panel..." , "ShotGrid Panel..." ] :
64
119
def show_shotgunpanel_with_context ():
65
120
app = engine .apps ["tk-multi-shotgunpanel" ]
66
121
entity_type , entity_id = self ._get_context (engine )
@@ -75,7 +130,7 @@ def show_shotgunpanel_with_context():
75
130
76
131
def _get_context_url (self , engine ):
77
132
"""
78
- Get the Shotgun entity URL from the metadata of the selected asset, if present
133
+ Get the SG entity URL from the metadata of the selected asset, if present.
79
134
"""
80
135
# By default, use the URL of the project
81
136
url = engine .context .shotgun_url
@@ -110,12 +165,12 @@ def _get_context_url(self, engine):
110
165
111
166
def _get_context (self , engine ):
112
167
"""
113
- Get the Shotgun context (entity type and id) that is associated with the selected menu command
168
+ Get the SG context (entity type and id) that is associated with the selected menu command.
114
169
"""
115
170
entity_type = None
116
171
entity_id = None
117
172
118
- # The context is derived from the Shotgun entity URL
173
+ # The context is derived from the SG entity URL
119
174
url = self ._get_context_url (engine )
120
175
if url :
121
176
# Extract entity type and id from URL, which should follow this pattern:
@@ -173,7 +228,7 @@ def shutdown(self):
173
228
174
229
engine = sgtk .platform .current_engine ()
175
230
if engine is not None :
176
- unreal .log ("Shutting down ShotgunEngineWrapper" )
231
+ unreal .log ("Shutting down %s" % self . __class__ . __name__ )
177
232
178
233
# destroy_engine of tk-unreal will take care of closing all dialogs that are still opened
179
234
engine .destroy ()
@@ -184,12 +239,12 @@ def shutdown(self):
184
239
Menu generation functionality for Unreal (based on the 3ds max Menu Generation implementation)
185
240
186
241
Actual menu creation is done in Unreal
187
- The following functions simply generate a list of available commands that will populate the Shotgun menu in Unreal
242
+ The following functions simply generate a list of available commands that will populate the SG menu in Unreal
188
243
"""
189
244
190
245
def create_menu (self , engine ):
191
246
"""
192
- Populate the Shotgun Menu with the available commands
247
+ Populate the SG Menu with the available commands.
193
248
"""
194
249
menu_items = []
195
250
@@ -257,9 +312,13 @@ def _add_menu_item_from_command(self, menu_items, command):
257
312
258
313
def _add_menu_item (self , menu_items , type , name = "" , title = "" , description = "" ):
259
314
"""
260
- Adds a new Unreal ShotgunMenuItem to the menu items
315
+ Adds a new Unreal SG MenuItem to the menu items.
261
316
"""
262
- menu_item = unreal .ShotgunMenuItem ()
317
+ # Shotgun integration components were renamed to Shotgrid from UE5
318
+ if hasattr (unreal , "ShotgridMenuItem" ):
319
+ menu_item = unreal .ShotgridMenuItem ()
320
+ else :
321
+ menu_item = unreal .ShotgunMenuItem ()
263
322
menu_item .title = title
264
323
menu_item .name = name
265
324
menu_item .type = type
@@ -275,15 +334,23 @@ def _start_contextual_menu(self, engine, menu_items):
275
334
276
335
self ._add_menu_item (menu_items , "context_begin" , ctx_name , ctx_name )
277
336
278
- engine .register_command ("Jump to Shotgun" , self ._jump_to_sg , {"type" : "context_menu" , "short_name" : "jump_to_sg" })
337
+ engine .register_command (
338
+ "Jump to ShotGrid" ,
339
+ self ._jump_to_sg ,
340
+ {"type" : "context_menu" , "short_name" : "jump_to_sg" }
341
+ )
279
342
280
343
# Add the menu item only when there are some file system locations.
281
344
if ctx .filesystem_locations :
282
- engine .register_command ("Jump to File System" , self ._jump_to_fs , {"type" : "context_menu" , "short_name" : "jump_to_fs" })
345
+ engine .register_command (
346
+ "Jump to File System" ,
347
+ self ._jump_to_fs ,
348
+ {"type" : "context_menu" , "short_name" : "jump_to_fs" }
349
+ )
283
350
284
351
def _jump_to_sg (self ):
285
352
"""
286
- Callback to Jump to Shotgun from context
353
+ Callback to Jump to SG from context.
287
354
"""
288
355
from sgtk .platform .qt5 import QtGui , QtCore
289
356
url = self ._get_context_url (sgtk .platform .current_engine ())
0 commit comments