mirror of
https://github.com/cyberboy666/r_e_c_u_r.git
synced 2025-12-12 11:20:15 +01:00
adding plugin menu
This commit is contained in:
15
actions.py
15
actions.py
@@ -102,6 +102,21 @@ class Actions(object):
|
|||||||
def map_on_shaders_selection(self):
|
def map_on_shaders_selection(self):
|
||||||
self.shaders.map_on_shaders_selection()
|
self.shaders.map_on_shaders_selection()
|
||||||
|
|
||||||
|
def move_plugins_selection_down(self):
|
||||||
|
self.display.plugins_menu.navigate_menu_down()
|
||||||
|
|
||||||
|
def move_plugins_selection_up(self):
|
||||||
|
self.display.plugins_menu.navigate_menu_up()
|
||||||
|
|
||||||
|
def move_plugins_selection_page_down(self):
|
||||||
|
self.display.plugins_menu.navigate_menu_page_down()
|
||||||
|
|
||||||
|
def move_plugins_selection_page_up(self):
|
||||||
|
self.display.plugins_menu.navigate_menu_page_up()
|
||||||
|
|
||||||
|
def enter_on_plugins_selection(self):
|
||||||
|
self.display.plugins_menu.enter_on_plugins_selection()
|
||||||
|
|
||||||
def clear_all_slots(self):
|
def clear_all_slots(self):
|
||||||
self.data.clear_all_slots()
|
self.data.clear_all_slots()
|
||||||
self.display.browser_menu.generate_browser_list()
|
self.display.browser_menu.generate_browser_list()
|
||||||
|
|||||||
@@ -28,12 +28,12 @@ class AsyncWrite(threading.Thread):
|
|||||||
data_file.close()
|
data_file.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Data(object):
|
class Data(object):
|
||||||
|
|
||||||
BANK_DATA_JSON = 'display_data.json'
|
BANK_DATA_JSON = 'display_data.json'
|
||||||
SHADER_BANK_DATA_JSON = 'shader_bank_data.json'
|
SHADER_BANK_DATA_JSON = 'shader_bank_data.json'
|
||||||
SETTINGS_JSON = 'settings.json'
|
SETTINGS_JSON = 'settings.json'
|
||||||
|
ACTIVE_PLUGINS = 'active_plugins.json'
|
||||||
DEFAULT_SETTINGS_JSON = 'settings_default.json'
|
DEFAULT_SETTINGS_JSON = 'settings_default.json'
|
||||||
KEYPAD_MAPPING_JSON = 'keypad_action_mapping.json'
|
KEYPAD_MAPPING_JSON = 'keypad_action_mapping.json'
|
||||||
OSC_MAPPING_JSON = 'osc_action_mapping.json'
|
OSC_MAPPING_JSON = 'osc_action_mapping.json'
|
||||||
@@ -85,6 +85,10 @@ class Data(object):
|
|||||||
if os.path.isfile(self.PATH_TO_DATA_OBJECTS + self.BANK_DATA_JSON):
|
if os.path.isfile(self.PATH_TO_DATA_OBJECTS + self.BANK_DATA_JSON):
|
||||||
self.bank_data = self._read_json(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):
|
||||||
|
self.bank_data = self._read_json(self.ACTIVE_PLUGINS)
|
||||||
|
|
||||||
self.shader_bank_data = [self.create_empty_shader_bank() for i in range(3)]
|
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):
|
if os.path.isfile(self.PATH_TO_DATA_OBJECTS + self.SHADER_BANK_DATA_JSON):
|
||||||
self.shader_bank_data = self._read_json(self.SHADER_BANK_DATA_JSON)
|
self.shader_bank_data = self._read_json(self.SHADER_BANK_DATA_JSON)
|
||||||
@@ -111,6 +115,20 @@ class Data(object):
|
|||||||
def initialise_plugins(self):
|
def initialise_plugins(self):
|
||||||
#initialise plugin manager
|
#initialise plugin manager
|
||||||
self.plugins = plugin_collection.PluginCollection("plugins", self.message_handler, self)
|
self.plugins = plugin_collection.PluginCollection("plugins", self.message_handler, self)
|
||||||
|
self.compare_plugins_list()
|
||||||
|
|
||||||
|
def compare_plugins_list(self):
|
||||||
|
current_plugins = [type(plugin).__name__ for plugin in self.plugins.get_plugins(plugin_collection.Plugin)]
|
||||||
|
plugins_to_add = set(current_plugins) - set(self.active_plugins.keys())
|
||||||
|
plugins_to_remove = set(self.active_plugins) - set(current_plugins)
|
||||||
|
for k in plugins_to_remove:
|
||||||
|
self.active_plugins.pop(k, None)
|
||||||
|
for k in plugins_to_add:
|
||||||
|
self.active_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}
|
||||||
|
|
||||||
|
|
||||||
def load_midi_mapping_for_device(self, device_name):
|
def load_midi_mapping_for_device(self, device_name):
|
||||||
# check if custom config file exists on disk for this device name
|
# check if custom config file exists on disk for this device name
|
||||||
@@ -443,11 +461,15 @@ class Data(object):
|
|||||||
display_modes.append(["SHDR_BNK",'PLAY_SHADER'])
|
display_modes.append(["SHDR_BNK",'PLAY_SHADER'])
|
||||||
if self.settings['detour']['TRY_DEMO']['value'] == 'enabled':
|
if self.settings['detour']['TRY_DEMO']['value'] == 'enabled':
|
||||||
display_modes.append(["FRAMES",'NAV_DETOUR'])
|
display_modes.append(["FRAMES",'NAV_DETOUR'])
|
||||||
|
if self.settings['system']['USE_PLUGINS']['value'] == 'enabled':
|
||||||
|
display_modes.append(["PLUGINS",'NAV_PLUGINS'])
|
||||||
|
|
||||||
if hasattr(self, 'plugins') and self.plugins is not None:
|
if hasattr(self, 'plugins') and self.plugins is not None:
|
||||||
from data_centre.plugin_collection import DisplayPlugin
|
from data_centre.plugin_collection import DisplayPlugin
|
||||||
for plugin in self.plugins.get_plugins(DisplayPlugin):
|
for plugin in self.plugins.get_plugins(DisplayPlugin):
|
||||||
display_modes.append(plugin.get_display_modes())
|
is_active = self.active_plugins[type(plugin).__name__]
|
||||||
|
if is_active:
|
||||||
|
display_modes.append(plugin.get_display_modes())
|
||||||
|
|
||||||
if not with_nav_mode:
|
if not with_nav_mode:
|
||||||
return [mode[0] for mode in display_modes]
|
return [mode[0] for mode in display_modes]
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class Display(object):
|
|||||||
self.data = data
|
self.data = data
|
||||||
self.browser_menu = menu.BrowserMenu(self.data, self.message_handler, self.MENU_HEIGHT)
|
self.browser_menu = menu.BrowserMenu(self.data, self.message_handler, self.MENU_HEIGHT)
|
||||||
self.settings_menu = menu.SettingsMenu(self.data, self.message_handler, self.MENU_HEIGHT)
|
self.settings_menu = menu.SettingsMenu(self.data, self.message_handler, self.MENU_HEIGHT)
|
||||||
|
self.plugins_menu = menu.PluginsMenu(self.data, self.message_handler, self.MENU_HEIGHT)
|
||||||
self.shaders_menu = self.shaders.shaders_menu
|
self.shaders_menu = self.shaders.shaders_menu
|
||||||
|
|
||||||
self.body_title = ''
|
self.body_title = ''
|
||||||
@@ -92,6 +93,8 @@ class Display(object):
|
|||||||
self._load_shader_bank()
|
self._load_shader_bank()
|
||||||
elif self.data.display_mode == 'FRAMES':
|
elif self.data.display_mode == 'FRAMES':
|
||||||
self._load_detour()
|
self._load_detour()
|
||||||
|
elif self.data.display_mode == 'PLUGINS':
|
||||||
|
self._load_plugins()
|
||||||
else:
|
else:
|
||||||
from data_centre.plugin_collection import DisplayPlugin
|
from data_centre.plugin_collection import DisplayPlugin
|
||||||
for plugin in self.data.plugins.get_plugins(DisplayPlugin):
|
for plugin in self.data.plugins.get_plugins(DisplayPlugin):
|
||||||
@@ -99,7 +102,8 @@ class Display(object):
|
|||||||
self._load_plugin_page(self.data.display_mode, plugin)
|
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.19, 4.29)
|
||||||
self.display_text.tag_add("COLUMN_NAME", 5.0, 6.0)
|
self.display_text.tag_add("COLUMN_NAME", 5.0, 6.0)
|
||||||
|
|
||||||
|
|
||||||
def _load_plugin_page(self, display_mode, plugin):
|
def _load_plugin_page(self, display_mode, plugin):
|
||||||
plugin.show_plugin(self, display_mode)
|
plugin.show_plugin(self, display_mode)
|
||||||
|
|
||||||
@@ -171,6 +175,29 @@ class Display(object):
|
|||||||
|
|
||||||
self._highlight_this_row(self.settings_menu.selected_list_index - self.settings_menu.top_menu_index)
|
self._highlight_this_row(self.settings_menu.selected_list_index - self.settings_menu.top_menu_index)
|
||||||
|
|
||||||
|
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'))
|
||||||
|
## showing list of plugins:
|
||||||
|
plugins_list = sorted(self.data.active_plugins.items())
|
||||||
|
self.plugins_menu.menu_list = plugins_list
|
||||||
|
|
||||||
|
number_of_plugins = len(plugins_list)
|
||||||
|
for index in range(number_of_plugins):
|
||||||
|
if line_count >= self.MENU_HEIGHT :
|
||||||
|
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])))
|
||||||
|
line_count = line_count + 1
|
||||||
|
|
||||||
|
for index in range(self.plugins_menu.top_menu_index + self.plugins_menu.menu_height - number_of_plugins):
|
||||||
|
self.display_text.insert(END, '\n')
|
||||||
|
|
||||||
|
self._highlight_this_row(self.plugins_menu.selected_list_index - self.plugins_menu.top_menu_index)
|
||||||
|
|
||||||
|
|
||||||
def _load_shaders(self):
|
def _load_shaders(self):
|
||||||
line_count = 0
|
line_count = 0
|
||||||
self.display_text.insert(END, '{} \n'.format(self.body_title))
|
self.display_text.insert(END, '{} \n'.format(self.body_title))
|
||||||
|
|||||||
@@ -199,6 +199,16 @@ class SettingsMenu(Menu):
|
|||||||
ordered_tuple_list.append((other_key, dictionary[other_key]))
|
ordered_tuple_list.append((other_key, dictionary[other_key]))
|
||||||
return ordered_tuple_list
|
return ordered_tuple_list
|
||||||
|
|
||||||
|
|
||||||
|
class PluginsMenu(Menu):
|
||||||
|
def __init__(self, data, message_handler, menu_height):
|
||||||
|
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]
|
||||||
|
self.data.active_plugins[selected_item] = not self.data.active_plugins[selected_item]
|
||||||
|
|
||||||
|
|
||||||
class ShadersMenu(Menu):
|
class ShadersMenu(Menu):
|
||||||
|
|
||||||
def __init__(self, data, message_handler, menu_height):
|
def __init__(self, data, message_handler, menu_height):
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
"DEFAULT": ["seek_back_on_player", "decrease_seek_time"],
|
"DEFAULT": ["seek_back_on_player", "decrease_seek_time"],
|
||||||
"NAV_SETTINGS": ["move_settings_selection_up", "move_settings_selection_page_up"],
|
"NAV_SETTINGS": ["move_settings_selection_up", "move_settings_selection_page_up"],
|
||||||
"NAV_SHADERS": ["move_shaders_selection_up", "move_shaders_selection_page_up"],
|
"NAV_SHADERS": ["move_shaders_selection_up", "move_shaders_selection_page_up"],
|
||||||
|
"NAV_PLUGINS": ["move_plugins_selection_up", "move_plugins_selection_page_up"],
|
||||||
"LENGTH_SET": ["return_to_default_control_mode"],
|
"LENGTH_SET": ["return_to_default_control_mode"],
|
||||||
"CONFIRM": ["return_to_default_control_mode"],
|
"CONFIRM": ["return_to_default_control_mode"],
|
||||||
"SHADER_PARAM": ["decrease_this_param", "decrease_shader_param"],
|
"SHADER_PARAM": ["decrease_this_param", "decrease_shader_param"],
|
||||||
@@ -15,6 +16,7 @@
|
|||||||
"DEFAULT": ["seek_forward_on_player", "increase_seek_time"],
|
"DEFAULT": ["seek_forward_on_player", "increase_seek_time"],
|
||||||
"NAV_SETTINGS": ["move_settings_selection_down", "move_settings_selection_page_down"],
|
"NAV_SETTINGS": ["move_settings_selection_down", "move_settings_selection_page_down"],
|
||||||
"NAV_SHADERS": ["move_shaders_selection_down", "move_shaders_selection_page_down"],
|
"NAV_SHADERS": ["move_shaders_selection_down", "move_shaders_selection_page_down"],
|
||||||
|
"NAV_PLUGINS": ["move_plugins_selection_down", "move_plugins_selection_page_down"],
|
||||||
"LENGTH_SET": ["return_to_default_control_mode"],
|
"LENGTH_SET": ["return_to_default_control_mode"],
|
||||||
"CONFIRM": ["return_to_default_control_mode"],
|
"CONFIRM": ["return_to_default_control_mode"],
|
||||||
"SHADER_PARAM": ["increase_this_param", "increase_shader_param"],
|
"SHADER_PARAM": ["increase_this_param", "increase_shader_param"],
|
||||||
@@ -26,6 +28,7 @@
|
|||||||
"DEFAULT": ["toggle_action_on_player","toggle_show_on_player"],
|
"DEFAULT": ["toggle_action_on_player","toggle_show_on_player"],
|
||||||
"NAV_SETTINGS": ["enter_on_settings_selection"],
|
"NAV_SETTINGS": ["enter_on_settings_selection"],
|
||||||
"NAV_SHADERS": ["enter_on_shaders_selection", "map_on_shaders_selection"],
|
"NAV_SHADERS": ["enter_on_shaders_selection", "map_on_shaders_selection"],
|
||||||
|
"NAV_PLUGINS": ["enter_on_plugins_selection"],
|
||||||
"LENGTH_SET": ["record_fixed_length"],
|
"LENGTH_SET": ["record_fixed_length"],
|
||||||
"SHADER_PARAM": ["return_to_default_control_mode"],
|
"SHADER_PARAM": ["return_to_default_control_mode"],
|
||||||
"CONFIRM": ["perform_confirm_action"],
|
"CONFIRM": ["perform_confirm_action"],
|
||||||
|
|||||||
@@ -164,6 +164,14 @@
|
|||||||
"options": [],
|
"options": [],
|
||||||
"value": null
|
"value": null
|
||||||
},
|
},
|
||||||
|
"USE_PLUGINS": {
|
||||||
|
"action": null,
|
||||||
|
"options": [
|
||||||
|
"enabled",
|
||||||
|
"disabled"
|
||||||
|
],
|
||||||
|
"value": "disabled"
|
||||||
|
},
|
||||||
"CLEAR_MESSAGE_BAR": {
|
"CLEAR_MESSAGE_BAR": {
|
||||||
"action": "clear_message",
|
"action": "clear_message",
|
||||||
"options": [],
|
"options": [],
|
||||||
|
|||||||
Reference in New Issue
Block a user