mirror of
https://github.com/cyberboy666/r_e_c_u_r.git
synced 2025-12-11 19:00:04 +01:00
plugins are notified of exiting so they can save config etc
This commit is contained in:
@@ -729,6 +729,7 @@ class Actions(object):
|
||||
|
||||
def quit_the_program(self):
|
||||
self.data._update_json(self.data.SETTINGS_JSON, self.data.settings)
|
||||
self.data.plugins.quit_plugins()
|
||||
self.video_driver.exit_all_players()
|
||||
self.exit_openframeworks()
|
||||
self.exit_osc_server('','')
|
||||
|
||||
@@ -111,7 +111,6 @@ class Data(object):
|
||||
def initialise_plugins(self):
|
||||
#initialise plugin manager
|
||||
self.plugins = plugin_collection.PluginCollection("plugins", self.message_handler, self)
|
||||
self.plugins.apply_all_plugins_on_value(5)
|
||||
|
||||
def load_midi_mapping_for_device(self, device_name):
|
||||
# check if custom config file exists on disk for this device name
|
||||
|
||||
@@ -15,6 +15,9 @@ class Plugin(object):
|
||||
self.description = 'UNKNOWN'
|
||||
self.pc = plugin_collection
|
||||
|
||||
def quit_plugin(self):
|
||||
print("quitting " + type(self).__name__)
|
||||
|
||||
class MidiFeedbackPlugin(Plugin):
|
||||
"""Base class for MIDI feedback plugins
|
||||
"""
|
||||
@@ -476,6 +479,10 @@ class PluginCollection(object):
|
||||
print("Looking for plugins under package %s" % self.plugin_package)
|
||||
self.walk_package(self.plugin_package)
|
||||
|
||||
def quit_plugins(self):
|
||||
# tell each plugin to quit
|
||||
for plugin in self.get_plugins():
|
||||
plugin.quit_plugin()
|
||||
|
||||
def get_plugins(self, clazz = None):
|
||||
if clazz:
|
||||
@@ -483,16 +490,6 @@ class PluginCollection(object):
|
||||
else:
|
||||
return [c for c in self.plugins if not c.disabled]
|
||||
|
||||
def apply_all_plugins_on_value(self, argument):
|
||||
"""Apply all of the plugins on the argument supplied to this function
|
||||
"""
|
||||
print()
|
||||
print('Applying all plugins on value %s:' %argument)
|
||||
for plugin in self.plugins:
|
||||
#print(" Applying %s on value %s yields value %s" % (plugin.description, argument, plugin.perform_operation(argument)))
|
||||
pass
|
||||
|
||||
|
||||
def walk_package(self, package):
|
||||
"""Recursively walk the supplied package to retrieve all plugins
|
||||
"""
|
||||
|
||||
@@ -45,6 +45,11 @@ class ShaderLoopRecordPlugin(ActionsPlugin,SequencePlugin,DisplayPlugin):
|
||||
def save_presets(self):
|
||||
self.pc.update_json(self.PRESET_FILE_NAME, self.frames)
|
||||
|
||||
def quit_plugin(self):
|
||||
super().quit_plugin()
|
||||
self.save_presets()
|
||||
|
||||
# DisplayPlugin methods
|
||||
def get_display_modes(self):
|
||||
return ['LOOPREC','NAV_LPRC']
|
||||
|
||||
|
||||
@@ -25,6 +25,10 @@ class ShaderQuickPresetPlugin(ActionsPlugin): #,SequencePlugin):
|
||||
def save_presets(self):
|
||||
self.pc.update_json(self.PRESET_FILE_NAME, self.presets)
|
||||
|
||||
def quit_plugin(self):
|
||||
super().quit_plugin()
|
||||
self.save_presets()
|
||||
|
||||
@property
|
||||
def parserlist(self):
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user