|
@@ -1692,14 +1692,24 @@ static inline void duplicate_item_data(struct obs_scene_item *dst,
|
|
|
dst->hide_transition_duration = src->hide_transition_duration;
|
|
|
|
|
|
if (duplicate_hotkeys && !dst_scene->source->context.private) {
|
|
|
+ struct dstr show = {0};
|
|
|
+ struct dstr hide = {0};
|
|
|
obs_data_array_t *data0 = NULL;
|
|
|
obs_data_array_t *data1 = NULL;
|
|
|
|
|
|
obs_hotkey_pair_save(src->toggle_visibility, &data0, &data1);
|
|
|
obs_hotkey_pair_load(dst->toggle_visibility, data0, data1);
|
|
|
|
|
|
+ /* Fix scene item ID */
|
|
|
+ dstr_printf(&show, "libobs.show_scene_item.%" PRIi64, dst->id);
|
|
|
+ dstr_printf(&hide, "libobs.hide_scene_item.%" PRIi64, dst->id);
|
|
|
+ obs_hotkey_pair_set_names(dst->toggle_visibility, show.array,
|
|
|
+ hide.array);
|
|
|
+
|
|
|
obs_data_array_release(data0);
|
|
|
obs_data_array_release(data1);
|
|
|
+ dstr_free(&show);
|
|
|
+ dstr_free(&hide);
|
|
|
}
|
|
|
|
|
|
obs_sceneitem_set_crop(dst, &src->crop);
|
|
@@ -2012,21 +2022,34 @@ static bool hotkey_hide_sceneitem(void *data, obs_hotkey_pair_id id,
|
|
|
static void init_hotkeys(obs_scene_t *scene, obs_sceneitem_t *item,
|
|
|
const char *name)
|
|
|
{
|
|
|
+ struct obs_data_array *hotkey_array;
|
|
|
+ obs_data_t *hotkey_data = scene->source->context.hotkey_data;
|
|
|
+
|
|
|
struct dstr show = {0};
|
|
|
struct dstr hide = {0};
|
|
|
+ struct dstr legacy = {0};
|
|
|
struct dstr show_desc = {0};
|
|
|
struct dstr hide_desc = {0};
|
|
|
|
|
|
- dstr_copy(&show, "libobs.show_scene_item.%1");
|
|
|
- dstr_replace(&show, "%1", name);
|
|
|
- dstr_copy(&hide, "libobs.hide_scene_item.%1");
|
|
|
- dstr_replace(&hide, "%1", name);
|
|
|
+ dstr_printf(&show, "libobs.show_scene_item.%" PRIi64, item->id);
|
|
|
+ dstr_printf(&hide, "libobs.hide_scene_item.%" PRIi64, item->id);
|
|
|
|
|
|
dstr_copy(&show_desc, obs->hotkeys.sceneitem_show);
|
|
|
dstr_replace(&show_desc, "%1", name);
|
|
|
dstr_copy(&hide_desc, obs->hotkeys.sceneitem_hide);
|
|
|
dstr_replace(&hide_desc, "%1", name);
|
|
|
|
|
|
+ /* Check if legacy keys exists, migrate if necessary */
|
|
|
+ dstr_printf(&legacy, "libobs.show_scene_item.%s", name);
|
|
|
+ hotkey_array = obs_data_get_array(hotkey_data, legacy.array);
|
|
|
+ if (hotkey_array)
|
|
|
+ obs_data_set_array(hotkey_data, show.array, hotkey_array);
|
|
|
+
|
|
|
+ dstr_printf(&legacy, "libobs.hide_scene_item.%s", name);
|
|
|
+ hotkey_array = obs_data_get_array(hotkey_data, legacy.array);
|
|
|
+ if (hotkey_array)
|
|
|
+ obs_data_set_array(hotkey_data, hide.array, hotkey_array);
|
|
|
+
|
|
|
item->toggle_visibility = obs_hotkey_pair_register_source(
|
|
|
scene->source, show.array, show_desc.array, hide.array,
|
|
|
hide_desc.array, hotkey_show_sceneitem, hotkey_hide_sceneitem,
|
|
@@ -2034,6 +2057,7 @@ static void init_hotkeys(obs_scene_t *scene, obs_sceneitem_t *item,
|
|
|
|
|
|
dstr_free(&show);
|
|
|
dstr_free(&hide);
|
|
|
+ dstr_free(&legacy);
|
|
|
dstr_free(&show_desc);
|
|
|
dstr_free(&hide_desc);
|
|
|
}
|
|
@@ -2041,19 +2065,9 @@ static void init_hotkeys(obs_scene_t *scene, obs_sceneitem_t *item,
|
|
|
static void sceneitem_rename_hotkey(const obs_sceneitem_t *scene_item,
|
|
|
const char *new_name)
|
|
|
{
|
|
|
- struct dstr show = {0};
|
|
|
- struct dstr hide = {0};
|
|
|
struct dstr show_desc = {0};
|
|
|
struct dstr hide_desc = {0};
|
|
|
|
|
|
- dstr_copy(&show, "libobs.show_scene_item.%1");
|
|
|
- dstr_replace(&show, "%1", new_name);
|
|
|
- dstr_copy(&hide, "libobs.hide_scene_item.%1");
|
|
|
- dstr_replace(&hide, "%1", new_name);
|
|
|
-
|
|
|
- obs_hotkey_pair_set_names(scene_item->toggle_visibility, show.array,
|
|
|
- hide.array);
|
|
|
-
|
|
|
dstr_copy(&show_desc, obs->hotkeys.sceneitem_show);
|
|
|
dstr_replace(&show_desc, "%1", new_name);
|
|
|
dstr_copy(&hide_desc, obs->hotkeys.sceneitem_hide);
|
|
@@ -2062,8 +2076,6 @@ static void sceneitem_rename_hotkey(const obs_sceneitem_t *scene_item,
|
|
|
obs_hotkey_pair_set_descriptions(scene_item->toggle_visibility,
|
|
|
show_desc.array, hide_desc.array);
|
|
|
|
|
|
- dstr_free(&show);
|
|
|
- dstr_free(&hide);
|
|
|
dstr_free(&show_desc);
|
|
|
dstr_free(&hide_desc);
|
|
|
}
|