Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
尘离序散
obs-studio
提交
6b5459fb
O
obs-studio
项目概览
尘离序散
/
obs-studio
与 Fork 源项目一致
从无法访问的项目Fork
通知
30
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
obs-studio
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6b5459fb
编写于
3月 05, 2020
作者:
V
VodBox
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
UI: Fix importing SL collections with repeated names
上级
eba68104
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
41 addition
and
17 deletion
+41
-17
UI/importers/sl.cpp
UI/importers/sl.cpp
+41
-17
未找到文件。
UI/importers/sl.cpp
浏览文件 @
6b5459fb
...
...
@@ -107,20 +107,28 @@ static string translate_hotkey(const Json &hotkey, const string &source)
#undef add_translation
}
static
string
get_source_name_from_id
(
const
Json
&
root
,
const
string
&
id
)
static
bool
source_name_exists
(
const
Json
::
array
&
sources
,
const
string
&
name
)
{
Json
::
array
source_arr
=
root
[
"sources"
][
"items"
].
array_items
();
Json
::
array
scene_arr
=
root
[
"scenes"
][
"items"
].
array_items
();
for
(
size_t
i
=
0
;
i
<
sources
.
size
();
i
++
)
{
Json
item
=
sources
[
i
];
string
source_name
=
item
[
"name"
].
string_value
();
source_arr
.
insert
(
source_arr
.
end
(),
scene_arr
.
begin
(),
scene_arr
.
end
());
if
(
source_name
==
name
)
return
true
;
}
for
(
size_t
i
=
0
;
i
<
source_arr
.
size
();
i
++
)
{
Json
item
=
source_arr
[
i
];
string
source_id
=
item
[
"id"
].
string_value
();
return
false
;
}
if
(
source_id
==
id
)
{
static
string
get_source_name_from_id
(
const
Json
::
array
&
sources
,
const
string
&
id
)
{
for
(
size_t
i
=
0
;
i
<
sources
.
size
();
i
++
)
{
Json
item
=
sources
[
i
];
string
source_id
=
item
[
"sl_id"
].
string_value
();
if
(
source_id
==
id
)
return
item
[
"name"
].
string_value
();
}
}
return
""
;
...
...
@@ -156,7 +164,7 @@ static void get_hotkey_bindings(Json::object &out_hotkeys,
}
}
static
void
get_scene_items
(
const
Json
&
root
,
Json
::
object
&
scene
,
static
void
get_scene_items
(
const
Json
::
array
&
out_sources
,
Json
::
object
&
scene
,
const
Json
::
array
&
in
)
{
int
length
=
0
;
...
...
@@ -169,7 +177,7 @@ static void get_scene_items(const Json &root, Json::object &scene,
Json
in_crop
=
item
[
"crop"
];
string
id
=
item
[
"sourceId"
].
string_value
();
string
name
=
get_source_name_from_id
(
root
,
id
);
string
name
=
get_source_name_from_id
(
out_sources
,
id
);
Json
::
array
hotkey_items
=
item
[
"hotkeys"
][
"items"
].
array_items
();
...
...
@@ -239,15 +247,23 @@ static int attempt_import(const Json &root, const string &name, Json &res)
out_filters
.
push_back
(
filter
);
}
int
copy
=
1
;
string
out_name
=
name
;
while
(
source_name_exists
(
out_sources
,
out_name
))
out_name
=
name
+
"("
+
to_string
(
copy
++
)
+
")"
;
string
sl_id
=
source
[
"id"
].
string_value
();
out_sources
.
push_back
(
Json
::
object
{{
"filters"
,
out_filters
},
{
"hotkeys"
,
out_hotkeys
},
{
"id"
,
source
[
"type"
]},
{
"sl_id"
,
sl_id
},
{
"settings"
,
in_settings
},
{
"sync"
,
sync
},
{
"volume"
,
vol
},
{
"muted"
,
muted
},
{
"name"
,
name
},
{
"name"
,
out_
name
},
{
"monitoring_type"
,
monitoring
}});
}
...
...
@@ -256,9 +272,6 @@ static int attempt_import(const Json &root, const string &name, Json &res)
for
(
size_t
i
=
0
;
i
<
scenes_arr
.
size
();
i
++
)
{
Json
scene
=
scenes_arr
[
i
];
if
(
scene_name
==
""
)
scene_name
=
scene
[
"name"
].
string_value
();
Json
in_hotkeys
=
scene
[
"hotkeys"
];
Json
::
array
hotkey_items
=
in_hotkeys
[
"items"
].
array_items
();
Json
in_filters
=
scene
[
"filters"
];
...
...
@@ -287,22 +300,33 @@ static int attempt_import(const Json &root, const string &name, Json &res)
out_filters
.
push_back
(
filter
);
}
int
copy
=
1
;
string
out_name
=
name
;
while
(
source_name_exists
(
out_sources
,
out_name
))
out_name
=
name
+
"("
+
to_string
(
copy
++
)
+
")"
;
if
(
scene_name
==
""
)
scene_name
=
out_name
;
string
sl_id
=
scene
[
"id"
].
string_value
();
Json
::
object
out
=
Json
::
object
{{
"filters"
,
out_filters
},
{
"hotkeys"
,
out_hotkeys
},
{
"id"
,
"scene"
},
{
"sl_id"
,
sl_id
},
{
"settings"
,
in_settings
},
{
"sync"
,
sync
},
{
"volume"
,
vol
},
{
"muted"
,
muted
},
{
"name"
,
name
},
{
"name"
,
out_
name
},
{
"monitoring_type"
,
monitoring
},
{
"private_settings"
,
Json
::
object
{}}};
Json
in_items
=
scene
[
"sceneItems"
];
Json
::
array
items_arr
=
in_items
[
"items"
].
array_items
();
get_scene_items
(
root
,
out
,
items_arr
);
get_scene_items
(
out_sources
,
out
,
items_arr
);
out_sources
.
push_back
(
out
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录