mirror of
https://github.com/cyberboy666/r_e_c_u_r.git
synced 2025-12-05 16:00:06 +01:00
renamed 'active' to 'enabled' when it comes to plugins
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -6,7 +6,7 @@ json_objects/display_data.json
|
||||
json_objects/shader_bank_data.json
|
||||
json_objects/settings.json
|
||||
json_objects/plugins/*/*.json
|
||||
json_objects/active_plugins.json
|
||||
json_objects/enabled_plugins.json
|
||||
*.patch
|
||||
*.orig
|
||||
*.rej
|
||||
|
||||
@@ -33,7 +33,7 @@ class Data(object):
|
||||
BANK_DATA_JSON = 'display_data.json'
|
||||
SHADER_BANK_DATA_JSON = 'shader_bank_data.json'
|
||||
SETTINGS_JSON = 'settings.json'
|
||||
ACTIVE_PLUGINS_JSON = 'active_plugins.json'
|
||||
ENABLED_PLUGINS_JSON = 'enabled_plugins.json'
|
||||
DEFAULT_SETTINGS_JSON = 'settings_default.json'
|
||||
KEYPAD_MAPPING_JSON = 'keypad_action_mapping.json'
|
||||
OSC_MAPPING_JSON = 'osc_action_mapping.json'
|
||||
@@ -86,9 +86,9 @@ class Data(object):
|
||||
if os.path.isfile(self.PATH_TO_DATA_OBJECTS + self.BANK_DATA_JSON):
|
||||
self.bank_data = self._read_json(self.BANK_DATA_JSON)
|
||||
|
||||
self.active_plugins = {}
|
||||
if os.path.isfile(self.PATH_TO_DATA_OBJECTS + self.ACTIVE_PLUGINS_JSON):
|
||||
self.active_plugins = self._read_json(self.ACTIVE_PLUGINS_JSON)
|
||||
self.enabled_plugins = {}
|
||||
if os.path.isfile(self.PATH_TO_DATA_OBJECTS + self.ENABLED_PLUGINS_JSON):
|
||||
self.enabled_plugins = self._read_json(self.ENABLED_PLUGINS_JSON)
|
||||
|
||||
self.shader_bank_data = [self.create_empty_shader_bank() for i in range(3)]
|
||||
if os.path.isfile(self.PATH_TO_DATA_OBJECTS + self.SHADER_BANK_DATA_JSON):
|
||||
@@ -119,24 +119,24 @@ class Data(object):
|
||||
self.plugins = plugin_collection.PluginCollection("plugins", self.message_handler, self)
|
||||
self.compare_plugins_list()
|
||||
|
||||
def get_active_plugin_class_names(self):
|
||||
return [k for k,v in self.active_plugins.items() if v is True]
|
||||
def get_enabled_plugin_class_names(self):
|
||||
return [k for k,v in self.enabled_plugins.items() if v is True]
|
||||
|
||||
def compare_plugins_list(self):
|
||||
current_plugins = [type(plugin).__name__ for plugin in self.plugins.get_plugins(include_disabled=True)]
|
||||
plugins_to_add = set(current_plugins) - set(self.active_plugins.keys())
|
||||
plugins_to_remove = set(self.active_plugins) - set(current_plugins)
|
||||
plugins_to_add = set(current_plugins) - set(self.enabled_plugins.keys())
|
||||
plugins_to_remove = set(self.enabled_plugins) - set(current_plugins)
|
||||
for k in plugins_to_remove:
|
||||
self.active_plugins.pop(k, None)
|
||||
self.enabled_plugins.pop(k, None)
|
||||
for k in plugins_to_add:
|
||||
self.active_plugins[k] = False
|
||||
self.enabled_plugins[k] = False
|
||||
#switch off all plugins if disabled ...
|
||||
if self.settings['system']['USE_PLUGINS']['value'] == 'disabled':
|
||||
self.active_plugins = {x:False for x in self.active_plugins}
|
||||
self.enabled_plugins = {x:False for x in self.enabled_plugins}
|
||||
|
||||
def update_active_plugins(self, key, value):
|
||||
self.active_plugins[key] = value
|
||||
self._update_json(self.ACTIVE_PLUGINS_JSON, self.active_plugins)
|
||||
def update_enabled_plugins(self, key, value):
|
||||
self.enabled_plugins[key] = value
|
||||
self._update_json(self.ENABLED_PLUGINS_JSON, self.enabled_plugins)
|
||||
|
||||
def load_midi_mapping_for_device(self, device_name):
|
||||
# check if custom config file exists on disk for this device name
|
||||
|
||||
@@ -11,7 +11,7 @@ class Plugin(object):
|
||||
"""
|
||||
@property
|
||||
def disabled(self):
|
||||
return type(self).__name__ not in self.pc.data.get_active_plugin_class_names()
|
||||
return type(self).__name__ not in self.pc.data.get_enabled_plugin_class_names()
|
||||
|
||||
def __init__(self, plugin_collection):
|
||||
self.description = 'UNKNOWN'
|
||||
@@ -477,10 +477,8 @@ class PluginCollection(object):
|
||||
|
||||
|
||||
def get_plugins(self, clazz = None, include_disabled = False):
|
||||
# is_active = self.active_plugins[type(plugin).__name__]
|
||||
if clazz:
|
||||
return [c for c in self.plugins if isinstance(c, clazz) and (include_disabled or not c.disabled)]
|
||||
#and type(c).__name__ in self.data.get_active_plugin_class_names())
|
||||
else:
|
||||
return [c for c in self.plugins if include_disabled or not c.disabled]
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ class Display(object):
|
||||
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("DISPLAY_MODE", 4.18, 4.28)
|
||||
self.display_text.tag_add("COLUMN_NAME", 5.0, 6.0)
|
||||
|
||||
|
||||
@@ -180,10 +180,10 @@ class Display(object):
|
||||
def _load_plugins(self):
|
||||
line_count = 0
|
||||
self.display_text.insert(END, '{} \n'.format(self.body_title))
|
||||
self.display_text.insert(END, '{:<40} {:<5} \n'.format('plugin', 'is_active'))
|
||||
self.display_text.insert(END, '{:<35} {:<8} \n'.format('plugin', 'status'))
|
||||
## showing list of plugins:
|
||||
plugins_list = sorted([
|
||||
(type(plugin).__name__, type(plugin).__name__ in self.data.get_active_plugin_class_names())\
|
||||
(type(plugin).__name__, type(plugin).__name__ in self.data.get_enabled_plugin_class_names())\
|
||||
for plugin in self.data.plugins.get_plugins(include_disabled=True)
|
||||
])
|
||||
self.plugins_menu.menu_list = plugins_list
|
||||
@@ -194,7 +194,7 @@ class Display(object):
|
||||
break
|
||||
if index >= self.plugins_menu.top_menu_index:
|
||||
plugin_line = plugins_list[index]
|
||||
self.display_text.insert(END, '{:<40} {:<5} \n'.format(plugin_line[0], str(plugin_line[1])))
|
||||
self.display_text.insert(END, '{:<35} {:<8} \n'.format(plugin_line[0], 'Enabled' if plugin_line[1] else 'Disabled'))
|
||||
line_count = line_count + 1
|
||||
|
||||
for index in range(self.plugins_menu.top_menu_index + self.plugins_menu.menu_height - number_of_plugins):
|
||||
@@ -209,9 +209,11 @@ class Display(object):
|
||||
|
||||
## showing current shader info:
|
||||
shader = self.shaders.selected_shader_list[self.data.shader_layer]
|
||||
self.display_text.insert(END, '{:<1}lay{:<1}:{:<2} {:<16} '.format \
|
||||
(self.data.shader_layer,self.shaders.selected_status_list[self.data.shader_layer],shader['shad_type'][0], \
|
||||
shader['name'].lstrip()[0:16] ))
|
||||
self.display_text.insert(END, '{:<1}{}{:<1}:{:<2} {:<16} '.format \
|
||||
(self.data.shader_layer,
|
||||
self.get_speed_indicator(self.shaders.selected_speed_list[self.data.shader_layer]),
|
||||
self.shaders.selected_status_list[self.data.shader_layer],shader['shad_type'][0],
|
||||
shader['name'].lstrip()[0:16] ))
|
||||
for i in range(min(4,shader['param_number'])):
|
||||
display_param = self.format_param_value(self.shaders.selected_param_list[self.data.shader_layer][i])
|
||||
if display_param == 100:
|
||||
@@ -243,7 +245,8 @@ class Display(object):
|
||||
self.display_text.insert(END, '{} \n'.format(self.body_title))
|
||||
|
||||
self.display_text.insert(END, '{:>6} {:<11} {:<5} '.format(
|
||||
'{}-layer'.format(self.data.shader_layer), 'name', 'type'))
|
||||
'{} {}'.format(self.data.shader_layer, self.get_speed_indicator(self.shaders.selected_speed_list[self.data.shader_layer])),
|
||||
'name', 'type'))
|
||||
|
||||
shader = self.shaders.selected_shader_list[self.data.shader_layer]
|
||||
|
||||
@@ -274,8 +277,9 @@ class Display(object):
|
||||
self.display_text.insert(END, '{} \n'.format(self.body_title))
|
||||
|
||||
self.display_text.insert(END, '{:>6} {:<11} {:<5} '.format(
|
||||
'{}-layer'.format(self.data.shader_layer), 'name', 'type'))
|
||||
|
||||
'{} {}'.format(self.data.shader_layer, self.get_speed_indicator(self.shaders.selected_speed_list[self.data.shader_layer])),
|
||||
'name', 'type'))
|
||||
|
||||
shader = self.shaders.selected_shader_list[self.data.shader_layer]
|
||||
|
||||
for i in range(min(4,shader['param_number'])):
|
||||
@@ -449,11 +453,61 @@ class Display(object):
|
||||
return capture_status
|
||||
|
||||
def get_bar(self, value, max_value = 1.0):
|
||||
value = value / max_value
|
||||
if value is None:
|
||||
return " "
|
||||
value = abs(value / max_value) # abs() so negative values make some sense
|
||||
bar = u"_\u2581\u2582\u2583\u2584\u2585\u2586\u2587\u2588"
|
||||
g = '%s'%bar[int(value*(len(bar)-1))]
|
||||
return g
|
||||
|
||||
def get_speed_indicator(self, value, convert = True):
|
||||
if convert:
|
||||
value = (value * 2.0) - 1.0 # convert 0 to 1 to -1 to +1
|
||||
output = u""
|
||||
if value==0.0:
|
||||
output+=u"\u23f9" # stopped
|
||||
elif value<=-0.5:
|
||||
output+=u"\u00AB" # fast reverse
|
||||
elif value<0.0:
|
||||
output+=u"\u2039" # reverse
|
||||
elif value>=0.5:
|
||||
output+=u"\u00BB" # fast forward
|
||||
elif value>0.0:
|
||||
output+=u"\u203A" # forward
|
||||
|
||||
#output += " {:03f}".format(value)
|
||||
output += self.get_bar(value)
|
||||
|
||||
return output
|
||||
|
||||
def get_compact_indicators(self, inp):
|
||||
step = 2
|
||||
s = ""
|
||||
for i in range(0,len(inp),step): # number of shader slots per layer
|
||||
selected1 = inp[i]
|
||||
if i+1 > len(inp): # catch if odd number of elements passed to us?
|
||||
selected2 = False
|
||||
else:
|
||||
selected2 = inp[i+1]
|
||||
|
||||
if selected1 and selected2:
|
||||
# full block
|
||||
s += u"\u2588"
|
||||
elif selected1 and not selected2:
|
||||
# left block
|
||||
s += u"\u258C"
|
||||
elif selected2 and not selected1:
|
||||
# right block
|
||||
s += u"\u2590"
|
||||
else:
|
||||
# empty
|
||||
s += "_"
|
||||
|
||||
#s += "#" if selected else "-"
|
||||
return s
|
||||
|
||||
|
||||
|
||||
@staticmethod
|
||||
def create_video_display_banner(start, end, position):
|
||||
banner_list = ['[', '-', '-', '-', '-', '-', '-', '-', '-',
|
||||
|
||||
@@ -206,9 +206,9 @@ class PluginsMenu(Menu):
|
||||
Menu.__init__(self, data, message_handler, menu_height)
|
||||
|
||||
def enter_on_plugins_selection(self):
|
||||
selected_item = sorted(self.data.active_plugins)[self.selected_list_index]
|
||||
state = self.data.active_plugins[selected_item]
|
||||
self.data.update_active_plugins(selected_item, not state)
|
||||
selected_item = sorted(self.data.enabled_plugins)[self.selected_list_index]
|
||||
state = self.data.enabled_plugins[selected_item]
|
||||
self.data.update_enabled_plugins(selected_item, not state)
|
||||
if state:
|
||||
self.data.plugins.stop_plugin_name(selected_item)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user