1
0
Эх сурвалжийг харах

UI: Add setting for Twitch chat add-ons choice

Both BTTV and FFZ are fairly popular however they do occasionally
interfere.  To give users the option to chose whichever one they like
most we add a new setting that allows BTTV, FFZ, both, or neither.

Defaults to "None" for new users.  Existing users will be migrated to
"Both" as that's the previous behavior.
derrod 6 жил өмнө
parent
commit
3e841b221d

+ 19 - 4
UI/auth-twitch.cpp

@@ -217,8 +217,16 @@ void TwitchAuth::LoadUI()
 	cef->add_force_popup_url(moderation_tools_url, chat.data());
 
 	script = "localStorage.setItem('twilight.theme', 1);";
-	script += bttv_script;
-	script += ffz_script;
+
+	const int twAddonChoice =
+		config_get_int(main->Config(), service(), "AddonChoice");
+	if (twAddonChoice) {
+		if (twAddonChoice & 0x1)
+			script += bttv_script;
+		if (twAddonChoice & 0x2)
+			script += ffz_script;
+	}
+
 	browser->setStartupScript(script);
 
 	main->addDockWidget(Qt::RightDockWidgetArea, chat.data());
@@ -261,8 +269,15 @@ void TwitchAuth::LoadSecondaryUIPanes()
 	script += name;
 	script += "/dashboard/live";
 	script += referrer_script2;
-	script += bttv_script;
-	script += ffz_script;
+
+	const int twAddonChoice =
+		config_get_int(main->Config(), service(), "AddonChoice");
+	if (twAddonChoice) {
+		if (twAddonChoice & 0x1)
+			script += bttv_script;
+		if (twAddonChoice & 0x2)
+			script += ffz_script;
+	}
 
 	/* ----------------------------------- */
 

+ 5 - 0
UI/data/locale/en-US.ini

@@ -670,6 +670,11 @@ Basic.Settings.Stream.Custom.UseAuthentication="Use authentication"
 Basic.Settings.Stream.Custom.Username="Username"
 Basic.Settings.Stream.Custom.Password="Password"
 Basic.Settings.Stream.BandwidthTestMode="Enable Bandwidth Test Mode"
+Basic.Settings.Stream.TTVAddon="Twitch Chat Add-Ons"
+Basic.Settings.Stream.TTVAddon.None="None"
+Basic.Settings.Stream.TTVAddon.BTTV="BetterTTV"
+Basic.Settings.Stream.TTVAddon.FFZ="FrankerFaceZ"
+Basic.Settings.Stream.TTVAddon.Both="BetterTTV and FrankerFaceZ"
 
 # basic mode 'output' settings
 Basic.Settings.Output="Output"

+ 38 - 25
UI/forms/OBSBasicSettings.ui

@@ -151,8 +151,8 @@
              <rect>
               <x>0</x>
               <y>0</y>
-              <width>630</width>
-              <height>1035</height>
+              <width>803</width>
+              <height>977</height>
              </rect>
             </property>
             <layout class="QVBoxLayout" name="verticalLayout_19">
@@ -1012,18 +1012,18 @@
                  </widget>
                 </item>
                 <item>
-                <widget class="UrlPushButton" name="getStreamKeyButton">
-                 <property name="toolTip">
-                  <string/>
-                 </property>
-                 <property name="toolTipDuration">
-                  <number>-4</number>
-                 </property>
-                 <property name="text">
-                  <string>Basic.AutoConfig.StreamPage.GetStreamKey</string>
-                 </property>
-                </widget>
-               </item>
+                 <widget class="UrlPushButton" name="getStreamKeyButton">
+                  <property name="toolTip">
+                   <string/>
+                  </property>
+                  <property name="toolTipDuration">
+                   <number>-4</number>
+                  </property>
+                  <property name="text">
+                   <string>Basic.AutoConfig.StreamPage.GetStreamKey</string>
+                  </property>
+                 </widget>
+                </item>
                </layout>
               </widget>
              </item>
@@ -1102,7 +1102,7 @@
                </property>
               </widget>
              </item>
-             <item row="7" column="0">
+             <item row="8" column="0">
               <widget class="QLabel" name="authUsernameLabel">
                <property name="text">
                 <string>Basic.Settings.Stream.Custom.Username</string>
@@ -1112,10 +1112,10 @@
                </property>
               </widget>
              </item>
-             <item row="7" column="1">
+             <item row="8" column="1">
               <widget class="QLineEdit" name="authUsername"/>
              </item>
-             <item row="8" column="0">
+             <item row="9" column="0">
               <widget class="QLabel" name="authPwLabel">
                <property name="text">
                 <string>Basic.Settings.Stream.Custom.Password</string>
@@ -1125,7 +1125,7 @@
                </property>
               </widget>
              </item>
-             <item row="8" column="1">
+             <item row="9" column="1">
               <widget class="QWidget" name="authPwWidget" native="true">
                <layout class="QHBoxLayout" name="horizontalLayout_25">
                 <property name="leftMargin">
@@ -1157,6 +1157,19 @@
                </layout>
               </widget>
              </item>
+             <item row="7" column="1">
+              <widget class="QComboBox" name="twitchAddonDropdown"/>
+             </item>
+             <item row="7" column="0">
+              <widget class="QLabel" name="twitchAddonLabel">
+               <property name="text">
+                <string>Basic.Settings.Stream.TTVAddon</string>
+               </property>
+               <property name="buddy">
+                <cstring>twitchAddonDropdown</cstring>
+               </property>
+              </widget>
+             </item>
             </layout>
            </widget>
           </widget>
@@ -1193,8 +1206,8 @@
              <rect>
               <x>0</x>
               <y>0</y>
-              <width>739</width>
-              <height>793</height>
+              <width>601</width>
+              <height>631</height>
              </rect>
             </property>
             <layout class="QVBoxLayout" name="verticalLayout_21">
@@ -2268,7 +2281,7 @@
                               <property name="currentIndex">
                                <number>0</number>
                               </property>
-                              <widget class="QWidget" name="recTracks" native="true">
+                              <widget class="QWidget" name="recTracks">
                                <layout class="QHBoxLayout" name="horizontalLayout_9">
                                 <property name="leftMargin">
                                  <number>0</number>
@@ -3702,8 +3715,8 @@
              <rect>
               <x>0</x>
               <y>0</y>
-              <width>696</width>
-              <height>601</height>
+              <width>555</width>
+              <height>469</height>
              </rect>
             </property>
             <layout class="QVBoxLayout" name="verticalLayout_50">
@@ -4518,8 +4531,8 @@
              <rect>
               <x>0</x>
               <y>0</y>
-              <width>759</width>
-              <height>930</height>
+              <width>803</width>
+              <height>781</height>
              </rect>
             </property>
             <layout class="QVBoxLayout" name="verticalLayout_23">

+ 12 - 0
UI/obs-app.cpp

@@ -735,6 +735,18 @@ bool OBSApp::InitGlobalConfig()
 		changed = true;
 	}
 
+#define PRE_24_1_DEFS "Pre24.1Defaults"
+	if (!config_has_user_value(globalConfig, "General", PRE_24_1_DEFS)) {
+		bool useOldDefaults = lastVersion &&
+				      lastVersion <
+					      MAKE_SEMANTIC_VERSION(24, 1, 0);
+
+		config_set_bool(globalConfig, "General", PRE_24_1_DEFS,
+				useOldDefaults);
+		changed = true;
+	}
+#undef PRE_24_1_DEFS
+
 	if (config_has_user_value(globalConfig, "BasicWindow",
 				  "MultiviewLayout")) {
 		const char *layout = config_get_string(

+ 9 - 0
UI/window-basic-main.cpp

@@ -1198,6 +1198,15 @@ bool OBSBasic::InitBasicConfigDefaults()
 		changed = true;
 	}
 
+	/* ----------------------------------------------------- */
+	/* set twitch chat extensions to "both" if prev version  */
+	/* is under 24.1                                         */
+	if (config_get_bool(GetGlobalConfig(), "General", "Pre24.1Defaults") &&
+	    !config_has_user_value(basicConfig, "Twitch", "AddonChoice")) {
+		config_set_int(basicConfig, "Twitch", "AddonChoice", 3);
+		changed = true;
+	}
+
 	/* ----------------------------------------------------- */
 
 	if (changed)

+ 37 - 1
UI/window-basic-settings-stream.cpp

@@ -39,6 +39,8 @@ void OBSBasicSettings::InitStreamPage()
 	ui->connectAccount2->setVisible(false);
 	ui->disconnectAccount->setVisible(false);
 	ui->bandwidthTestEnable->setVisible(false);
+	ui->twitchAddonDropdown->setVisible(false);
+	ui->twitchAddonLabel->setVisible(false);
 
 	int vertSpacing = ui->topStreamLayout->verticalSpacing();
 
@@ -56,6 +58,15 @@ void OBSBasicSettings::InitStreamPage()
 
 	LoadServices(false);
 
+	ui->twitchAddonDropdown->addItem(
+		QTStr("Basic.Settings.Stream.TTVAddon.None"));
+	ui->twitchAddonDropdown->addItem(
+		QTStr("Basic.Settings.Stream.TTVAddon.BTTV"));
+	ui->twitchAddonDropdown->addItem(
+		QTStr("Basic.Settings.Stream.TTVAddon.FFZ"));
+	ui->twitchAddonDropdown->addItem(
+		QTStr("Basic.Settings.Stream.TTVAddon.Both"));
+
 	connect(ui->service, SIGNAL(currentIndexChanged(int)), this,
 		SLOT(UpdateServerList()));
 	connect(ui->service, SIGNAL(currentIndexChanged(int)), this,
@@ -98,6 +109,9 @@ void OBSBasicSettings::LoadStream1Settings()
 
 		bool bw_test = obs_data_get_bool(settings, "bwtest");
 		ui->bandwidthTestEnable->setChecked(bw_test);
+
+		idx = config_get_int(main->Config(), "Twitch", "AddonChoice");
+		ui->twitchAddonDropdown->setCurrentIndex(idx);
 	}
 
 	UpdateServerList();
@@ -161,6 +175,21 @@ void OBSBasicSettings::SaveStream1Settings()
 
 	obs_data_set_bool(settings, "bwtest",
 			  ui->bandwidthTestEnable->isChecked());
+
+	if (!!auth && strcmp(auth->service(), "Twitch") == 0) {
+		bool choiceExists = config_has_user_value(
+			main->Config(), "Twitch", "AddonChoice");
+		int currentChoice =
+			config_get_int(main->Config(), "Twitch", "AddonChoice");
+		int newChoice = ui->twitchAddonDropdown->currentIndex();
+
+		config_set_int(main->Config(), "Twitch", "AddonChoice",
+			       newChoice);
+
+		if (choiceExists && currentChoice != newChoice)
+			forceAuthReload = true;
+	}
+
 	obs_data_set_string(settings, "key", QT_TO_UTF8(ui->key->text()));
 
 	OBSService newService = obs_service_create(
@@ -277,6 +306,8 @@ void OBSBasicSettings::on_service_currentIndexChanged(int)
 
 	ui->disconnectAccount->setVisible(false);
 	ui->bandwidthTestEnable->setVisible(false);
+	ui->twitchAddonDropdown->setVisible(false);
+	ui->twitchAddonLabel->setVisible(false);
 
 #ifdef BROWSER_AVAILABLE
 	if (cef) {
@@ -430,8 +461,11 @@ void OBSBasicSettings::OnOAuthStreamKeyConnected()
 		ui->connectAccount2->setVisible(false);
 		ui->disconnectAccount->setVisible(true);
 
-		if (strcmp(a->service(), "Twitch") == 0)
+		if (strcmp(a->service(), "Twitch") == 0) {
 			ui->bandwidthTestEnable->setVisible(true);
+			ui->twitchAddonLabel->setVisible(true);
+			ui->twitchAddonDropdown->setVisible(true);
+		}
 	}
 
 	ui->streamStackWidget->setCurrentIndex((int)Section::StreamKey);
@@ -494,6 +528,8 @@ void OBSBasicSettings::on_disconnectAccount_clicked()
 	ui->connectAccount2->setVisible(true);
 	ui->disconnectAccount->setVisible(false);
 	ui->bandwidthTestEnable->setVisible(false);
+	ui->twitchAddonDropdown->setVisible(false);
+	ui->twitchAddonLabel->setVisible(false);
 	ui->key->setText("");
 }
 

+ 7 - 0
UI/window-basic-settings.cpp

@@ -337,6 +337,7 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent)
 	HookWidget(ui->customServer,         EDIT_CHANGED,   STREAM1_CHANGED);
 	HookWidget(ui->key,                  EDIT_CHANGED,   STREAM1_CHANGED);
 	HookWidget(ui->bandwidthTestEnable,  CHECK_CHANGED,  STREAM1_CHANGED);
+	HookWidget(ui->twitchAddonDropdown,  COMBO_CHANGED,  STREAM1_CHANGED);
 	HookWidget(ui->useAuth,              CHECK_CHANGED,  STREAM1_CHANGED);
 	HookWidget(ui->authUsername,         EDIT_CHANGED,   STREAM1_CHANGED);
 	HookWidget(ui->authPw,               EDIT_CHANGED,   STREAM1_CHANGED);
@@ -3486,6 +3487,12 @@ void OBSBasicSettings::closeEvent(QCloseEvent *event)
 {
 	if (Changed() && !QueryChanges())
 		event->ignore();
+
+	if (forceAuthReload) {
+		main->auth->Save();
+		main->auth->Load();
+		forceAuthReload = false;
+	}
 }
 
 void OBSBasicSettings::on_theme_activated(int idx)

+ 1 - 0
UI/window-basic-settings.hpp

@@ -115,6 +115,7 @@ private:
 	bool advancedChanged = false;
 	int pageIndex = 0;
 	bool loading = true;
+	bool forceAuthReload = false;
 	std::string savedTheme;
 
 	int lastSimpleRecQualityIdx = 0;