Răsfoiți Sursa

UI: Convert multiview layout string profiles to int

This commit series changes the ini user configuration multiview layout
so that string values were converted to int. In order to prevent past
user saves to break we verify if the ini still have string values and
convert that to int on obs init.

This will make the code easier to maintain in clearer to read the
multiview layout settings, also, makes the addition of new layouts
easier.
Shaolin 7 ani în urmă
părinte
comite
b8a901c870
2 a modificat fișierele cu 41 adăugiri și 0 ștergeri
  1. 39 0
      UI/obs-app.cpp
  2. 2 0
      UI/obs-app.hpp

+ 39 - 0
UI/obs-app.cpp

@@ -591,6 +591,38 @@ static string GetSceneCollectionFileFromName(const char *name)
 	return outputPath;
 }
 
+bool OBSApp::UpdatePre22MultiviewLayout(const char *layout)
+{
+	if (!layout)
+		return false;
+
+	if (astrcmpi(layout, "horizontaltop") == 0) {
+		config_set_int(globalConfig, "BasicWindow", "MultiviewLayout",
+			static_cast<int>(MultiviewLayout::HORIZONTAL_TOP));
+		return true;
+	}
+
+	if (astrcmpi(layout, "horizontalbottom") == 0) {
+		config_set_int(globalConfig, "BasicWindow", "MultiviewLayout",
+			static_cast<int>(MultiviewLayout::HORIZONTAL_BOTTOM));
+		return true;
+	}
+
+	if (astrcmpi(layout, "verticalleft") == 0) {
+		config_set_int(globalConfig, "BasicWindow", "MultiviewLayout",
+			static_cast<int>(MultiviewLayout::VERTICAL_LEFT));
+		return true;
+	}
+
+	if (astrcmpi(layout, "verticalright") == 0) {
+		config_set_int(globalConfig, "BasicWindow", "MultiviewLayout",
+			static_cast<int>(MultiviewLayout::VERTICAL_RIGHT));
+		return true;
+	}
+
+	return false;
+}
+
 bool OBSApp::InitGlobalConfig()
 {
 	char path[512];
@@ -656,6 +688,13 @@ bool OBSApp::InitGlobalConfig()
 		changed = true;
 	}
 
+	if (config_has_user_value(globalConfig, "BasicWindow",
+			"MultiviewLayout")) {
+		const char *layout = config_get_string(globalConfig,
+				"BasicWindow", "MultiviewLayout");
+		changed |= UpdatePre22MultiviewLayout(layout);
+	}
+
 	if (changed)
 		config_save_safe(globalConfig, "tmp", nullptr);
 

+ 2 - 0
UI/obs-app.hpp

@@ -78,6 +78,8 @@ private:
 
 	std::deque<obs_frontend_translate_ui_cb> translatorHooks;
 
+	bool UpdatePre22MultiviewLayout(const char *layout);
+
 	bool InitGlobalConfig();
 	bool InitGlobalConfigDefaults();
 	bool InitLocale();