Skip to content

Commit

Permalink
Added missing UI elements and events
Browse files Browse the repository at this point in the history
  • Loading branch information
leus committed Sep 26, 2020
1 parent 6c9208f commit 0d28d13
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 4 deletions.
61 changes: 61 additions & 0 deletions pes-fmdl/CompatibilityLayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,23 @@ def ExportUVMaps(cls, blenderMaterial, blenderMesh, name, vertexFields):
@classmethod
def TriangulateMesh(cls, modifiedBlenderMesh, scene):
pass

@classmethod
def AppendToImportMenu(cls, newMenuItem):
pass

@classmethod
def AppendToExportMenu(cls, newMenuItem):
pass

@classmethod
def AppendScenePostUpdateEvent(cls, event):
pass

@classmethod
def RemoveSceneUpdatePostEvent(cls, eventHandler):
pass

def __init__(self):
pass

Expand Down Expand Up @@ -242,9 +258,26 @@ def AppendToImportMenu(cls, newMenuItem):
def AppendToExportMenu(cls, newMenuItem):
bpy.types.INFO_MT_file_export.append(newMenuItem)

@classmethod
def AppendScenePostUpdateEvent(cls, eventHandler):
bpy.app.handlers.scene_update_post.append(eventHandler)

@classmethod
def RemoveSceneUpdatePostEvent(cls, eventHandler):
bpy.app.handlers.scene_update_post.remove(eventHandler)

@classmethod
def RemoveFromExportMenu(cls, menuItem):
bpy.types.INFO_MT_file_export.remove(menuItem)

@classmethod
def RemoveFromImportMenu(cls, menuItem):
bpy.types.INFO_MT_file_import.remove(menuItem)

def __init__(self):
super().__init__()


class CompatibilityLayer29(CompatibilityLayerBase):

@classmethod
Expand Down Expand Up @@ -386,6 +419,22 @@ def AppendToImportMenu(cls, newMenuItem):
def AppendToExportMenu(cls, newMenuItem):
bpy.types.TOPBAR_MT_file_export.append(newMenuItem)

@classmethod
def AppendSceneUpdatePostEvent(cls, eventHandler):
bpy.app.handlers.depsgraph_update_post.append(eventHandler)

@classmethod
def RemoveSceneUpdatePostEvent(cls, eventHandler):
bpy.app.handlers.depsgraph_update_post.remove(eventHandler)

@classmethod
def RemoveFromExportMenu(cls, menuItem):
bpy.types.TOPBAR_MT_file_export.remove(menuItem)

@classmethod
def RemoveFromImportMenu(cls, menuItem):
bpy.types.TOPBAR_MT_file_import.remove(menuItem)

def __init__(self):
super().__init__()

Expand Down Expand Up @@ -432,3 +481,15 @@ def AppendToImportMenu(self, newMenuItem):

def AppendToExportMenu(self, newMenuItem):
self.shim.AppendToExportMenu(newMenuItem)

def AppendSceneUpdatePostEvent(self, eventHandler):
self.shim.AppendSceneUpdatePostEvent(eventHandler)

def RemoveSceneUpdatePostEvent(self, eventHandler):
self.shim.RemoveSceneUpdatePostEvent(eventHandler)

def RemoveFromExportMenu(self, menuItem):
self.shim.RemoveFromExportMenu(menuItem)

def RemoveFromImportMenu(self, menuItem):
self.shim.RemoveFromImportMenu(menuItem)
9 changes: 5 additions & 4 deletions pes-fmdl/UI.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,14 +809,15 @@ def register():
shim.AppendToExportMenu(FMDL_Scene_FMDL_Export_MenuItem)
bpy.types.TEXTURE_PT_image.append(FMDL_Texture_Load_Ftex_Button)

bpy.app.handlers.scene_update_post.append(FMDL_Mesh_BoneGroup_TrackVertexGroupUsageUpdates)
shim.AppendSceneUpdatePostEvent(FMDL_Mesh_BoneGroup_TrackVertexGroupUsageUpdates)

def unregister():
bpy.app.handlers.scene_update_post.remove(FMDL_Mesh_BoneGroup_TrackVertexGroupUsageUpdates)
shim = CompatibilityLayer.CompatibilityLayer()
shim.RemoveSceneUpdatePostEvent(FMDL_Mesh_BoneGroup_TrackVertexGroupUsageUpdates)

bpy.types.TEXTURE_PT_image.remove(FMDL_Texture_Load_Ftex_Button)
bpy.types.INFO_MT_file_export.remove(FMDL_Scene_FMDL_Export_MenuItem)
bpy.types.INFO_MT_file_import.remove(FMDL_Scene_FMDL_Import_MenuItem)
shim.RemoveFromExportMenu(FMDL_Scene_FMDL_Export_MenuItem)
shim.RemoveFromImportMenu(FMDL_Scene_FMDL_Import_MenuItem)

for c in classes[::-1]:
bpy.utils.unregister_class(c)

0 comments on commit 0d28d13

Please sign in to comment.