From 2d7b586318bddcaf6c35f4023d554a9e6d88847c Mon Sep 17 00:00:00 2001 From: magnoborgo Date: Tue, 28 Sep 2021 16:33:21 -0400 Subject: [PATCH] added script load options on preferences --- kmfx_alphaOverlayColor.py | 16 +++++++++------- kmfx_changepaintOpacity.py | 4 +++- kmfx_cloneShapeinPlace.py | 6 ++++-- kmfx_cloneinteractivemodeToggle.py | 4 +++- kmfx_copyShapeKeyframe.py | 9 +++++---- kmfx_cyclePaintPresets.py | 4 +++- kmfx_cycleRGB.py | 4 +++- kmfx_hard_alpha.py | 4 +++- kmfx_keyframeVisibility.py | 4 +++- kmfx_nudgeShapes.py | 4 +++- kmfx_paintpresets.py | 5 +++-- kmfx_pasteShapeKeyframe.py | 6 ++++-- kmfx_resetcloneoverride.py | 7 +++---- kmfx_reshapeOverride.py | 5 +++-- kmfx_selectallpoints.py | 4 +++- kmfx_timeOffset.py | 4 +++- 16 files changed, 58 insertions(+), 32 deletions(-) diff --git a/kmfx_alphaOverlayColor.py b/kmfx_alphaOverlayColor.py index 351c35a..6fbd9c0 100644 --- a/kmfx_alphaOverlayColor.py +++ b/kmfx_alphaOverlayColor.py @@ -4,21 +4,23 @@ from PySide2.QtCore import * from PySide2.QtWidgets import QLabel import sys -# import shiboken2 from fx import * fx.prefs.add("KMFX.Alpha Overlay Color UI", True) +fx.prefs.add("KMFX_Load.Alpha Overlay Color UI", True) + class KMFXalphaOverlayColor(Action): """allows to change the alpha overlay color with UI item and shortcuts""" def __init__(self,): - Action.__init__(self, "KMFX|Alpha Overlay Color") - if fx.prefs["KMFX.Alpha Overlay Color UI"]: - self.AObtn = self.get_widgets() - AOcolor = self.fxcolor_to_qcolor(fx.prefs["viewer.alphaColor"]) - self.AObtn.setStyleSheet( - "background-color: {}".format(AOcolor.name())) + if fx.prefs["KMFX_Load.Alpha Overlay Color UI"] is True: + Action.__init__(self, "KMFX|Alpha Overlay Color") + if fx.prefs["KMFX.Alpha Overlay Color UI"]: + self.AObtn = self.get_widgets() + AOcolor = self.fxcolor_to_qcolor(fx.prefs["viewer.alphaColor"]) + self.AObtn.setStyleSheet( + "background-color: {}".format(AOcolor.name())) def available(self): pass diff --git a/kmfx_changepaintOpacity.py b/kmfx_changepaintOpacity.py index e6c2d67..6d1a4e3 100644 --- a/kmfx_changepaintOpacity.py +++ b/kmfx_changepaintOpacity.py @@ -1,5 +1,6 @@ import fx from fx import * +fx.prefs.add("KMFX_Load.Change Paint Opacity", True) class KMFXchangepaintOpacity(Action): @@ -7,7 +8,8 @@ class KMFXchangepaintOpacity(Action): """shortcuts to increase/decrease opacity when using paint node""" def __init__(self): - Action.__init__(self, "KMFX|Change Paint Opacity") + if fx.prefs["KMFX_Load.Change Paint Opacity"] is True: + Action.__init__(self, "KMFX|Change Paint Opacity") def available(self): node = fx.activeNode() diff --git a/kmfx_cloneShapeinPlace.py b/kmfx_cloneShapeinPlace.py index 1a0b11c..814d522 100644 --- a/kmfx_cloneShapeinPlace.py +++ b/kmfx_cloneShapeinPlace.py @@ -2,6 +2,8 @@ from fx import * from tools.objectIterator import getObjects from tools.objectIterator import ObjectFinder +fx.prefs.add("KMFX_Load.Clone Shapes in Place", True) + def remove_keys(shape,propertiesList): for prop in propertiesList: @@ -13,14 +15,14 @@ def remove_keys(shape,propertiesList): editor.deleteKey(t) editor.execute() propertie.constant = True - class KMFXcloneShapeinPlace(Action): """Copy shapes to an Active Layer on a given frame,removing all keyframes.""" def __init__(self): - Action.__init__(self, "KMFX|Clone Shapes in Place") + if fx.prefs["KMFX_Load.Clone Shapes in Place"] is True: + Action.__init__(self, "KMFX|Clone Shapes in Place") def available(self): shapes = getObjects(selection(), types=[Shape]) diff --git a/kmfx_cloneinteractivemodeToggle.py b/kmfx_cloneinteractivemodeToggle.py index 19be932..8f005dc 100644 --- a/kmfx_cloneinteractivemodeToggle.py +++ b/kmfx_cloneinteractivemodeToggle.py @@ -1,13 +1,15 @@ import fx from fx import * clonemode = None +fx.prefs.add("KMFX_Load.Clone Interactive Toggle", True) class KMFXcloneinteractivemodeToggle(Action): """shortcut to enable interactive mode if onion skin is active""" def __init__(self,): - Action.__init__(self, "KMFX|Clone Interactive Toggle On/Off") + if fx.prefs["KMFX_Load.Clone Interactive Toggle"] is True: + Action.__init__(self, "KMFX|Clone Interactive Toggle On/Off") def available(self): assert fx.viewer.toolName == "Clone", "Clone tool only" diff --git a/kmfx_copyShapeKeyframe.py b/kmfx_copyShapeKeyframe.py index 2db0e18..4bf31da 100644 --- a/kmfx_copyShapeKeyframe.py +++ b/kmfx_copyShapeKeyframe.py @@ -1,16 +1,17 @@ import fx from fx import * from tools.objectIterator import getObjects +fx.prefs.add("KMFX_Load.Shape Keyframe Copy", True) class KMFXcopyShapeKeyframe(Action): """copy paste path keyframes""" def __init__(self): - Action.__init__(self, "KMFX|Shape Keyframe Copy") - self.savedkeys = {} - self.from_action_menu = "copy" - + if fx.prefs["KMFX_Load.Shape Keyframe Copy"] is True: + Action.__init__(self, "KMFX|Shape Keyframe Copy") + self.savedkeys = {} + self.from_action_menu = "copy" def available(self): shapes = getObjects(selection(), types=[Shape]) diff --git a/kmfx_cyclePaintPresets.py b/kmfx_cyclePaintPresets.py index c1d4788..3b97656 100644 --- a/kmfx_cyclePaintPresets.py +++ b/kmfx_cyclePaintPresets.py @@ -3,13 +3,15 @@ from fx import * fx.prefs.add("KMFX.Paint Presets maximum cycle", 4, min=2, max=10) +fx.prefs.add("KMFX_Load.Cycle Paint Presets", True) class KMFXcyclePaintPresets(Action): """You can cycle your paint presets with a keybind""" def __init__(self,): - Action.__init__(self, "KMFX|Cycle Paint Presets") + if fx.prefs["KMFX_Load.Cycle Paint Presets"] is True: + Action.__init__(self, "KMFX|Cycle Paint Presets") def available(self): node = fx.activeNode() diff --git a/kmfx_cycleRGB.py b/kmfx_cycleRGB.py index 1fe2218..f8cb917 100644 --- a/kmfx_cycleRGB.py +++ b/kmfx_cycleRGB.py @@ -2,13 +2,15 @@ from fx import * cycleRGB = None previousRGB = None +fx.prefs.add("KMFX_Load.Cycle RGB channels", True) class KMFXcycleRGBchannels(Action): """Overrides shortcuts to cycle rgb modes using a single key shortcut""" def __init__(self,): - Action.__init__(self, "KMFX|Cycle RGB channels") + if fx.prefs["KMFX_Load.Cycle RGB channels"] is True: + Action.__init__(self, "KMFX|Cycle RGB channels") def available(self): pass diff --git a/kmfx_hard_alpha.py b/kmfx_hard_alpha.py index 5b54a23..14694aa 100644 --- a/kmfx_hard_alpha.py +++ b/kmfx_hard_alpha.py @@ -1,12 +1,14 @@ import fx from fx import * +fx.prefs.add("KMFX_Load.Paint Hard Alpha setup", True) class KMFX_hard_Alpha(Action): """creates a combo of nodes to setup a hard alpha""" def __init__(self,): - Action.__init__(self, "KMFX|Paint Hard Alpha setup") + if fx.prefs["KMFX_Load.Paint Hard Alpha setup"] is True: + Action.__init__(self, "KMFX|Paint Hard Alpha setup") def available(self): assert fx.selection() != [], "Select some nodes" diff --git a/kmfx_keyframeVisibility.py b/kmfx_keyframeVisibility.py index c112ec7..6855780 100644 --- a/kmfx_keyframeVisibility.py +++ b/kmfx_keyframeVisibility.py @@ -1,13 +1,15 @@ import fx from fx import * from tools.objectIterator import getObjects +fx.prefs.add("KMFX_Load.Keyframe Visibility", True) class KMFXkeyframeVisibility(Action): """Creates keyframes without clicking on the visibility icon""" def __init__(self): - Action.__init__(self, "KMFX|Keyframe Visibility") + if fx.prefs["KMFX_Load.Keyframe Visibility"] is True: + Action.__init__(self, "KMFX|Keyframe Visibility") def available(self): shapes = getObjects(selection(), types=[Shape]) diff --git a/kmfx_nudgeShapes.py b/kmfx_nudgeShapes.py index a951afe..bf11f54 100644 --- a/kmfx_nudgeShapes.py +++ b/kmfx_nudgeShapes.py @@ -1,13 +1,15 @@ import fx from fx import * from tools.objectIterator import getObjects +fx.prefs.add("KMFX_Load.Nudge Shape Shortcuts", True) class KMFXnudgeShapes(Action): """move shapes with keyboard shortcuts """ def __init__(self,): - Action.__init__(self, "KMFX|Nudge Shape Shortcuts") + if fx.prefs["KMFX_Load.Nudge Shape Shortcuts"] is True: + Action.__init__(self, "KMFX|Nudge Shape Shortcuts") def available(self): shapes = getObjects(selection(), types=[Shape]) diff --git a/kmfx_paintpresets.py b/kmfx_paintpresets.py index c2f7b92..cab221c 100755 --- a/kmfx_paintpresets.py +++ b/kmfx_paintpresets.py @@ -4,7 +4,7 @@ import glob import os from fx import * - +fx.prefs.add("KMFX_Load.Paint Presets", True) fx.prefs.add("KMFX.Paint Presets Path", "") fx.prefs.add("KMFX.Paint Presets Save Warning", True) @@ -89,7 +89,8 @@ class KMFXpaintPresets(Action): """this will save/load the actual state of the paint node to/from disk""" def __init__(self,): - Action.__init__(self, "KMFX|Paint Presets") + if fx.prefs["KMFX_Load.Paint Presets"] is True: + Action.__init__(self, "KMFX|Paint Presets") def available(self): pass # verification on execution diff --git a/kmfx_pasteShapeKeyframe.py b/kmfx_pasteShapeKeyframe.py index 4c5f055..a4f9573 100644 --- a/kmfx_pasteShapeKeyframe.py +++ b/kmfx_pasteShapeKeyframe.py @@ -1,13 +1,15 @@ import fx from fx import * from tools.objectIterator import getObjects +fx.prefs.add("KMFX_Load.Shape Keyframe Paste", True) + class KMFXpasteShapeKeyframe(Action): """paste path keyframes, this is just a wrapper so we have this on the Actions menu""" def __init__(self): - Action.__init__(self, "KMFX|Shape Keyframe Paste") - + if fx.prefs["KMFX_Load.Shape Keyframe Paste"] is True: + Action.__init__(self, "KMFX|Shape Keyframe Paste") def available(self): shapes = getObjects(selection(), types=[Shape]) diff --git a/kmfx_resetcloneoverride.py b/kmfx_resetcloneoverride.py index 1d1e92d..ffac5ff 100644 --- a/kmfx_resetcloneoverride.py +++ b/kmfx_resetcloneoverride.py @@ -1,16 +1,15 @@ import fx from fx import * - - fx.prefs.add("KMFX.Reset Clone also resets opacity", True) - +fx.prefs.add("KMFX_Load.Clone Reset transforms and frame", True) class KMFXresetCloneOverride(Action): """replicates the behavior the clone tool "reset button",resets clone frame as well""" def __init__(self,): - Action.__init__(self, "KMFX|Clone Reset transforms and frame") + if fx.prefs["KMFX_Load.Clone Reset transforms and frame"] is True: + Action.__init__(self, "KMFX|Clone Reset transforms and frame") def available(self): assert fx.viewer.toolName == "Clone", "Clone tool only" diff --git a/kmfx_reshapeOverride.py b/kmfx_reshapeOverride.py index bcb17ef..737c5e3 100644 --- a/kmfx_reshapeOverride.py +++ b/kmfx_reshapeOverride.py @@ -1,13 +1,14 @@ import fx from fx import * reshapeOverridestore = True - +fx.prefs.add("KMFX_Load.Reshape Tool Override", True) class KMFXreshapeOverride(Action): """Overrides the reshape tool binding to avoid the magnet reshape tool""" def __init__(self,): - Action.__init__(self, "KMFX|Reshape Tool Override") + if fx.prefs["KMFX_Load.Reshape Tool Override"] is True: + Action.__init__(self, "KMFX|Reshape Tool Override") def available(self): pass diff --git a/kmfx_selectallpoints.py b/kmfx_selectallpoints.py index 9190a3a..69144ef 100644 --- a/kmfx_selectallpoints.py +++ b/kmfx_selectallpoints.py @@ -1,13 +1,15 @@ import fx from fx import * from tools.objectIterator import getObjects +fx.prefs.add("KMFX_Load.Select All Points rebind", True) class KMFXselectAllPointRebind(Action): """shortcut to Selects all points when in reshape mode """ def __init__(self,): - Action.__init__(self, "KMFX|Select All Points rebind") + if fx.prefs["KMFX_Load.Select All Points rebind"] is True: + Action.__init__(self, "KMFX|Select All Points rebind") def available(self): pass diff --git a/kmfx_timeOffset.py b/kmfx_timeOffset.py index bcae476..ed20001 100755 --- a/kmfx_timeOffset.py +++ b/kmfx_timeOffset.py @@ -1,13 +1,15 @@ import fx from fx import * from tools.objectIterator import getObjects +fx.prefs.add("KMFX_Load.Node Time Offset", True) class KMFXtimeOffset(Action): """Offsets keyframes on selected nodes""" def __init__(self,): - Action.__init__(self, "KMFX|Node Time Offset") + if fx.prefs["KMFX_Load.Node Time Offset"] is True: + Action.__init__(self, "KMFX|Node Time Offset") def available(self): assert fx.selection() != [], "Select some nodes"