mirror of
https://github.com/cyberboy666/r_e_c_u_r.git
synced 2025-12-12 19:30:11 +01:00
Merge branch 'feature_plugins' into feature_plugins_shader_gadgets
This commit is contained in:
@@ -426,6 +426,12 @@ class Data(object):
|
||||
display_modes.append(["SHDR_BNK",'PLAY_SHADER'])
|
||||
if self.settings['detour']['TRY_DEMO']['value'] == 'enabled':
|
||||
display_modes.append(["FRAMES",'NAV_DETOUR'])
|
||||
|
||||
if hasattr(self, 'plugins') and self.plugins is not None:
|
||||
from data_centre.plugin_collection import DisplayPlugin
|
||||
for plugin in self.plugins.get_plugins(DisplayPlugin):
|
||||
display_modes.append(plugin.get_display_modes())
|
||||
|
||||
if not with_nav_mode:
|
||||
return [mode[0] for mode in display_modes]
|
||||
return display_modes
|
||||
|
||||
@@ -194,6 +194,22 @@ class ActionsPlugin(Plugin):
|
||||
|
||||
return (found_method, args)
|
||||
|
||||
class DisplayPlugin(Plugin):
|
||||
def __init__(self, plugin_collection):
|
||||
super().__init__(plugin_collection)
|
||||
|
||||
def is_handled(self, name):
|
||||
raise NotImplementedError
|
||||
|
||||
def get_display_modes(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def show_plugin(self, display):
|
||||
from tkinter import Text, END
|
||||
#display_text.insert(END, 'test from DisplayPlugin')
|
||||
display.display_text.insert(END, '{} \n'.format(display.body_title))
|
||||
|
||||
|
||||
# adapted from https://github.com/gdiepen/python_plugin_example
|
||||
class PluginCollection(object):
|
||||
"""Upon creation, this class will read the plugins package for modules
|
||||
@@ -267,7 +283,7 @@ class PluginCollection(object):
|
||||
for (_, c) in clsmembers:
|
||||
# Only add classes that are a sub class of Plugin, but NOT Plugin itself
|
||||
# or one of the base classes
|
||||
ignore_list = [ Plugin, ActionsPlugin, SequencePlugin, MidiFeedbackPlugin ]
|
||||
ignore_list = [ Plugin, ActionsPlugin, SequencePlugin, MidiFeedbackPlugin, DisplayPlugin ]
|
||||
if issubclass(c, Plugin) & (c not in ignore_list):
|
||||
print(' Found plugin class: %s.%s' % (c.__module__,c.__name__))
|
||||
self.plugins.append(c(self))
|
||||
|
||||
@@ -92,9 +92,16 @@ class Display(object):
|
||||
self._load_shader_bank()
|
||||
elif self.data.display_mode == 'FRAMES':
|
||||
self._load_detour()
|
||||
else:
|
||||
from data_centre.plugin_collection import DisplayPlugin
|
||||
for plugin in self.data.plugins.get_plugins(DisplayPlugin):
|
||||
if plugin.is_handled(self.data.display_mode):
|
||||
self._load_plugin_page(self.data.display_mode, plugin)
|
||||
self.display_text.tag_add("DISPLAY_MODE", 4.19, 4.29)
|
||||
self.display_text.tag_add("COLUMN_NAME", 5.0, 6.0)
|
||||
|
||||
def _load_plugin_page(self, display_mode, plugin):
|
||||
plugin.show_plugin(self, display_mode)
|
||||
|
||||
def _load_sampler(self):
|
||||
bank_data = self.data.bank_data[self.data.bank_number]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import data_centre.plugin_collection
|
||||
from data_centre.plugin_collection import ActionsPlugin#, SequencePlugin
|
||||
from data_centre.plugin_collection import ActionsPlugin, DisplayPlugin#, SequencePlugin
|
||||
#import math
|
||||
from math import sin, cos, tan, log, exp, pi
|
||||
|
||||
@@ -41,7 +41,7 @@ TODO: >> ?? invert|set_the_shader_param_0_layer_>>print_arguments>>set_variab
|
||||
|
||||
"""
|
||||
|
||||
class ManipulatePlugin(ActionsPlugin):
|
||||
class ManipulatePlugin(ActionsPlugin,DisplayPlugin):
|
||||
disabled = False
|
||||
|
||||
def __init__(self, plugin_collection):
|
||||
@@ -55,9 +55,23 @@ class ManipulatePlugin(ActionsPlugin):
|
||||
( r"^f:(.*):\|(.*)$", self.formula ), # formula eg ```f:sin(x):|```
|
||||
( r"^set_variable_([a-zA-Z0-9]+)$", self.set_variable ),
|
||||
( r"^([A-Z0-9]+)>(.*)$", self.recall_variable ), # recall variable and pipe into righthand side eg ```VAR1>invert|set_the_shader_.....```
|
||||
( r"^(.*)>\&(.*)$", self.run_multi ) # pick up piped commands that duplicate a chain of values last
|
||||
( r"^(.*)>\&(.*)$", self.run_multi ), # pick up piped commands that duplicate a chain of values last
|
||||
( "MANIPULA", None )
|
||||
]
|
||||
|
||||
def show_plugin(self, display, display_mode):
|
||||
from tkinter import Text, END
|
||||
#super(DisplayPlugin).show_plugin(display, display_mode)
|
||||
display.display_text.insert(END, '{} \n'.format(display.body_title))
|
||||
display.display_text.insert(END, "test from ManipulatePlugin!\n")
|
||||
|
||||
for key,value in self.variables.items():
|
||||
display.display_text.insert(END, "\t" + key + "\t{:03.2f}\n".format(value))
|
||||
|
||||
|
||||
def get_display_modes(self):
|
||||
return ["MANIPULA",None] #"NAV_MANIPULATE"]
|
||||
|
||||
def run_multi(self, action1, action2, value):
|
||||
print("multi running %s and %s with value %s" % (action1, action2, value))
|
||||
self.pc.actions.call_method_name(action1, value)
|
||||
|
||||
Reference in New Issue
Block a user