mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-20 08:15:46 -05:00
add support for previous scene on media tab
This commit is contained in:
@@ -90,6 +90,7 @@ SceneSwitcher::SceneSwitcher(QWidget *parent)
|
||||
|
||||
ui->sceneRoundTripScenes2->addItem(PREVIOUS_SCENE_NAME);
|
||||
ui->idleScenes->addItem(PREVIOUS_SCENE_NAME);
|
||||
ui->mediaScenes->addItem(PREVIOUS_SCENE_NAME);
|
||||
|
||||
obs_frontend_source_list *transitions = new obs_frontend_source_list();
|
||||
obs_frontend_get_transitions(transitions);
|
||||
@@ -291,7 +292,9 @@ SceneSwitcher::SceneSwitcher(QWidget *parent)
|
||||
|
||||
for (auto &s : switcher->mediaSwitches) {
|
||||
string sourceName = GetWeakSourceName(s.source);
|
||||
string sceneName = GetWeakSourceName(s.scene);
|
||||
string sceneName = (s.usePreviousScene)
|
||||
? PREVIOUS_SCENE_NAME
|
||||
: GetWeakSourceName(s.scene);
|
||||
string transitionName = GetWeakSourceName(s.transition);
|
||||
QString listText = MakeMediaSwitchName(
|
||||
sourceName.c_str(), sceneName.c_str(),
|
||||
@@ -723,7 +726,8 @@ static void SaveSceneSwitcher(obs_data_t *save_data, bool saving, void *)
|
||||
obs_weak_source_get_source(s.scene);
|
||||
obs_source_t *transition =
|
||||
obs_weak_source_get_source(s.transition);
|
||||
if (source && sceneSource && transition) {
|
||||
if ((s.usePreviousScene || source) && sceneSource &&
|
||||
transition) {
|
||||
const char *sourceName =
|
||||
obs_source_get_name(source);
|
||||
const char *sceneName =
|
||||
@@ -732,8 +736,10 @@ static void SaveSceneSwitcher(obs_data_t *save_data, bool saving, void *)
|
||||
obs_source_get_name(transition);
|
||||
obs_data_set_string(array_obj, "source",
|
||||
sourceName);
|
||||
obs_data_set_string(array_obj, "scene",
|
||||
sceneName);
|
||||
obs_data_set_string(
|
||||
array_obj, "scene",
|
||||
s.usePreviousScene ? PREVIOUS_SCENE_NAME
|
||||
: sceneName);
|
||||
obs_data_set_string(array_obj, "transition",
|
||||
transitionName);
|
||||
obs_data_set_int(array_obj, "state", s.state);
|
||||
@@ -1179,7 +1185,8 @@ static void SaveSceneSwitcher(obs_data_t *save_data, bool saving, void *)
|
||||
GetWeakSourceByName(scene),
|
||||
GetWeakSourceByName(source),
|
||||
GetWeakTransitionByName(transition), state,
|
||||
restriction, time);
|
||||
restriction, time,
|
||||
(strcmp(scene, PREVIOUS_SCENE_NAME) == 0));
|
||||
}
|
||||
|
||||
string autoStopScene =
|
||||
|
||||
@@ -208,16 +208,19 @@ struct MediaSwitch {
|
||||
uint64_t time;
|
||||
time_restriction restriction;
|
||||
bool matched;
|
||||
bool usePreviousScene;
|
||||
|
||||
inline MediaSwitch(OBSWeakSource scene_, OBSWeakSource source_,
|
||||
OBSWeakSource transition_, obs_media_state state_,
|
||||
time_restriction restriction_, uint64_t time_)
|
||||
time_restriction restriction_, uint64_t time_,
|
||||
bool usePreviousScene_)
|
||||
: scene(scene_),
|
||||
source(source_),
|
||||
transition(transition_),
|
||||
state(state_),
|
||||
restriction(restriction_),
|
||||
time(time_)
|
||||
time(time_),
|
||||
usePreviousScene(usePreviousScene_)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
@@ -30,8 +30,9 @@ void SceneSwitcher::on_mediaAdd_clicked()
|
||||
item->setData(Qt::UserRole, v);
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
switcher->mediaSwitches.emplace_back(scene, source, transition, state,
|
||||
restriction, time);
|
||||
switcher->mediaSwitches.emplace_back(
|
||||
scene, source, transition, state, restriction, time,
|
||||
(sceneName == QString(PREVIOUS_SCENE_NAME)));
|
||||
}
|
||||
|
||||
void SceneSwitcher::on_mediaRemove_clicked()
|
||||
@@ -79,7 +80,9 @@ void SwitcherData::checkMediaSwitch(bool &match, OBSWeakSource &scene,
|
||||
duration - time > mediaSwitch.time));
|
||||
if (matched && !mediaSwitch.matched) {
|
||||
match = true;
|
||||
scene = mediaSwitch.scene;
|
||||
scene = (mediaSwitch.usePreviousScene)
|
||||
? previousScene
|
||||
: mediaSwitch.scene;
|
||||
transition = mediaSwitch.transition;
|
||||
}
|
||||
mediaSwitch.matched = matched;
|
||||
|
||||
Reference in New Issue
Block a user