UI: Add migration for relative coordinate system
This commit is contained in:
parent
f61d0bb3c2
commit
8251005ad3
5 changed files with 232 additions and 6 deletions
|
|
@ -434,6 +434,97 @@ void OBSBasic::on_actionExportSceneCollection_triggered()
|
|||
}
|
||||
}
|
||||
|
||||
void OBSBasic::on_actionRemigrateSceneCollection_triggered()
|
||||
{
|
||||
if (Active()) {
|
||||
OBSMessageBox::warning(
|
||||
this,
|
||||
QTStr("Basic.Main.RemigrateSceneCollection.Title"),
|
||||
QTStr("Basic.Main.RemigrateSceneCollection.CannotMigrate.Active"));
|
||||
return;
|
||||
}
|
||||
|
||||
OBSDataAutoRelease priv = obs_get_private_data();
|
||||
|
||||
if (!usingAbsoluteCoordinates && !migrationBaseResolution) {
|
||||
OBSMessageBox::warning(
|
||||
this,
|
||||
QTStr("Basic.Main.RemigrateSceneCollection.Title"),
|
||||
QTStr("Basic.Main.RemigrateSceneCollection.CannotMigrate.UnknownBaseResolution"));
|
||||
return;
|
||||
}
|
||||
|
||||
obs_video_info ovi;
|
||||
obs_get_video_info(&ovi);
|
||||
|
||||
if (!usingAbsoluteCoordinates &&
|
||||
migrationBaseResolution->first == ovi.base_width &&
|
||||
migrationBaseResolution->second == ovi.base_height) {
|
||||
OBSMessageBox::warning(
|
||||
this,
|
||||
QTStr("Basic.Main.RemigrateSceneCollection.Title"),
|
||||
QTStr("Basic.Main.RemigrateSceneCollection.CannotMigrate.BaseResolutionMatches"));
|
||||
return;
|
||||
}
|
||||
|
||||
QString name = config_get_string(App()->GlobalConfig(), "Basic",
|
||||
"SceneCollection");
|
||||
QString message = QTStr("Basic.Main.RemigrateSceneCollection.Text")
|
||||
.arg(name)
|
||||
.arg(ovi.base_width)
|
||||
.arg(ovi.base_height);
|
||||
|
||||
auto answer = OBSMessageBox::question(
|
||||
this, QTStr("Basic.Main.RemigrateSceneCollection.Title"),
|
||||
message);
|
||||
|
||||
if (answer == QMessageBox::No)
|
||||
return;
|
||||
|
||||
lastOutputResolution = {ovi.base_width, ovi.base_height};
|
||||
|
||||
if (!usingAbsoluteCoordinates) {
|
||||
/* Temporarily change resolution to migration resolution */
|
||||
ovi.base_width = migrationBaseResolution->first;
|
||||
ovi.base_height = migrationBaseResolution->second;
|
||||
|
||||
if (obs_reset_video(&ovi) != OBS_VIDEO_SUCCESS) {
|
||||
OBSMessageBox::critical(
|
||||
this,
|
||||
QTStr("Basic.Main.RemigrateSceneCollection.Title"),
|
||||
QTStr("Basic.Main.RemigrateSceneCollection.CannotMigrate.FailedVideoReset"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
char path[512];
|
||||
int ret = GetConfigPath(path, 512, "obs-studio/basic/scenes/");
|
||||
if (ret <= 0) {
|
||||
blog(LOG_WARNING, "Failed to get scene collection config path");
|
||||
return;
|
||||
}
|
||||
|
||||
std::string fileName = path;
|
||||
fileName += config_get_string(App()->GlobalConfig(), "Basic",
|
||||
"SceneCollectionFile");
|
||||
fileName += ".json";
|
||||
|
||||
if (api)
|
||||
api->on_event(OBS_FRONTEND_EVENT_SCENE_COLLECTION_CHANGING);
|
||||
|
||||
/* Save and immediately reload to (re-)run migrations. */
|
||||
SaveProjectNow();
|
||||
/* Reset video if we potentially changed to a temporary resolution */
|
||||
if (!usingAbsoluteCoordinates)
|
||||
ResetVideo();
|
||||
|
||||
Load(fileName.c_str(), !usingAbsoluteCoordinates);
|
||||
RefreshSceneCollections();
|
||||
|
||||
if (api)
|
||||
api->on_event(OBS_FRONTEND_EVENT_SCENE_COLLECTION_CHANGED);
|
||||
}
|
||||
|
||||
void OBSBasic::ChangeSceneCollection()
|
||||
{
|
||||
QAction *action = reinterpret_cast<QAction *>(sender());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue