Skip to content

Commit

Permalink
UI: Add command line opt to start w/ specific scene
Browse files Browse the repository at this point in the history
  • Loading branch information
jp9000 committed Apr 14, 2016
1 parent 21ea1b1 commit b52c4f9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions obs/obs-app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ static string currentLogFile;
static string lastLogFile;

static bool portable_mode = false;
string opt_starting_scene;

QObject *CreateShortcutFilter()
{
Expand Down Expand Up @@ -1553,6 +1554,9 @@ int main(int argc, char *argv[])
for (int i = 1; i < argc; i++) {
if (arg_is(argv[i], "--portable", "-p")) {
portable_mode = true;

} else if (arg_is(argv[i], "--scene", nullptr)) {
if (++i < argc) opt_starting_scene = argv[i];
}
}

Expand Down
2 changes: 2 additions & 0 deletions obs/obs-app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,5 @@ static inline int GetProfilePath(char *path, size_t size, const char *file)
App()->GetMainWindow());
return window->GetProfilePath(path, size, file);
}

extern std::string opt_starting_scene;
23 changes: 23 additions & 0 deletions obs/window-basic-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,12 @@ void OBSBasic::Load(const char *file)
const char *transitionName = obs_data_get_string(data,
"current_transition");

if (!opt_starting_scene.empty()) {
programSceneName = opt_starting_scene.c_str();
if (!IsPreviewProgramMode())
sceneName = opt_starting_scene.c_str();
}

int newDuration = obs_data_get_int(data, "transition_duration");
if (!newDuration)
newDuration = 300;
Expand Down Expand Up @@ -542,8 +548,22 @@ void OBSBasic::Load(const char *file)
ui->transitionDuration->setValue(newDuration);
SetTransition(curTransition);

retryScene:
curScene = obs_get_source_by_name(sceneName);
curProgramScene = obs_get_source_by_name(programSceneName);

/* if the starting scene command line parameter is bad at all,
* fall back to original settings */
if (!opt_starting_scene.empty() && (!curScene || !curProgramScene)) {
sceneName = obs_data_get_string(data, "current_scene");
programSceneName = obs_data_get_string(data,
"current_program_scene");
obs_source_release(curScene);
obs_source_release(curProgramScene);
opt_starting_scene.clear();
goto retryScene;
}

if (!curProgramScene) {
curProgramScene = curScene;
obs_source_addref(curScene);
Expand Down Expand Up @@ -575,6 +595,9 @@ void OBSBasic::Load(const char *file)

obs_data_release(data);

if (!opt_starting_scene.empty())
opt_starting_scene.clear();

disableSaving--;
}

Expand Down

0 comments on commit b52c4f9

Please sign in to comment.