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.
master
derrod 2019-10-10 03:29:09 +02:00 committed by jp9000
parent a03ade631f
commit 3e841b221d
8 changed files with 128 additions and 30 deletions

View File

@ -217,8 +217,16 @@ void TwitchAuth::LoadUI()
cef->add_force_popup_url(moderation_tools_url, chat.data()); cef->add_force_popup_url(moderation_tools_url, chat.data());
script = "localStorage.setItem('twilight.theme', 1);"; 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); browser->setStartupScript(script);
main->addDockWidget(Qt::RightDockWidgetArea, chat.data()); main->addDockWidget(Qt::RightDockWidgetArea, chat.data());
@ -261,8 +269,15 @@ void TwitchAuth::LoadSecondaryUIPanes()
script += name; script += name;
script += "/dashboard/live"; script += "/dashboard/live";
script += referrer_script2; 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;
}
/* ----------------------------------- */ /* ----------------------------------- */

View File

@ -670,6 +670,11 @@ Basic.Settings.Stream.Custom.UseAuthentication="Use authentication"
Basic.Settings.Stream.Custom.Username="Username" Basic.Settings.Stream.Custom.Username="Username"
Basic.Settings.Stream.Custom.Password="Password" Basic.Settings.Stream.Custom.Password="Password"
Basic.Settings.Stream.BandwidthTestMode="Enable Bandwidth Test Mode" 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 mode 'output' settings
Basic.Settings.Output="Output" Basic.Settings.Output="Output"

View File

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

View File

@ -735,6 +735,18 @@ bool OBSApp::InitGlobalConfig()
changed = true; 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", if (config_has_user_value(globalConfig, "BasicWindow",
"MultiviewLayout")) { "MultiviewLayout")) {
const char *layout = config_get_string( const char *layout = config_get_string(

View File

@ -1198,6 +1198,15 @@ bool OBSBasic::InitBasicConfigDefaults()
changed = true; 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) if (changed)

View File

@ -39,6 +39,8 @@ void OBSBasicSettings::InitStreamPage()
ui->connectAccount2->setVisible(false); ui->connectAccount2->setVisible(false);
ui->disconnectAccount->setVisible(false); ui->disconnectAccount->setVisible(false);
ui->bandwidthTestEnable->setVisible(false); ui->bandwidthTestEnable->setVisible(false);
ui->twitchAddonDropdown->setVisible(false);
ui->twitchAddonLabel->setVisible(false);
int vertSpacing = ui->topStreamLayout->verticalSpacing(); int vertSpacing = ui->topStreamLayout->verticalSpacing();
@ -56,6 +58,15 @@ void OBSBasicSettings::InitStreamPage()
LoadServices(false); 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, connect(ui->service, SIGNAL(currentIndexChanged(int)), this,
SLOT(UpdateServerList())); SLOT(UpdateServerList()));
connect(ui->service, SIGNAL(currentIndexChanged(int)), this, connect(ui->service, SIGNAL(currentIndexChanged(int)), this,
@ -98,6 +109,9 @@ void OBSBasicSettings::LoadStream1Settings()
bool bw_test = obs_data_get_bool(settings, "bwtest"); bool bw_test = obs_data_get_bool(settings, "bwtest");
ui->bandwidthTestEnable->setChecked(bw_test); ui->bandwidthTestEnable->setChecked(bw_test);
idx = config_get_int(main->Config(), "Twitch", "AddonChoice");
ui->twitchAddonDropdown->setCurrentIndex(idx);
} }
UpdateServerList(); UpdateServerList();
@ -161,6 +175,21 @@ void OBSBasicSettings::SaveStream1Settings()
obs_data_set_bool(settings, "bwtest", obs_data_set_bool(settings, "bwtest",
ui->bandwidthTestEnable->isChecked()); 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())); obs_data_set_string(settings, "key", QT_TO_UTF8(ui->key->text()));
OBSService newService = obs_service_create( OBSService newService = obs_service_create(
@ -277,6 +306,8 @@ void OBSBasicSettings::on_service_currentIndexChanged(int)
ui->disconnectAccount->setVisible(false); ui->disconnectAccount->setVisible(false);
ui->bandwidthTestEnable->setVisible(false); ui->bandwidthTestEnable->setVisible(false);
ui->twitchAddonDropdown->setVisible(false);
ui->twitchAddonLabel->setVisible(false);
#ifdef BROWSER_AVAILABLE #ifdef BROWSER_AVAILABLE
if (cef) { if (cef) {
@ -430,8 +461,11 @@ void OBSBasicSettings::OnOAuthStreamKeyConnected()
ui->connectAccount2->setVisible(false); ui->connectAccount2->setVisible(false);
ui->disconnectAccount->setVisible(true); ui->disconnectAccount->setVisible(true);
if (strcmp(a->service(), "Twitch") == 0) if (strcmp(a->service(), "Twitch") == 0) {
ui->bandwidthTestEnable->setVisible(true); ui->bandwidthTestEnable->setVisible(true);
ui->twitchAddonLabel->setVisible(true);
ui->twitchAddonDropdown->setVisible(true);
}
} }
ui->streamStackWidget->setCurrentIndex((int)Section::StreamKey); ui->streamStackWidget->setCurrentIndex((int)Section::StreamKey);
@ -494,6 +528,8 @@ void OBSBasicSettings::on_disconnectAccount_clicked()
ui->connectAccount2->setVisible(true); ui->connectAccount2->setVisible(true);
ui->disconnectAccount->setVisible(false); ui->disconnectAccount->setVisible(false);
ui->bandwidthTestEnable->setVisible(false); ui->bandwidthTestEnable->setVisible(false);
ui->twitchAddonDropdown->setVisible(false);
ui->twitchAddonLabel->setVisible(false);
ui->key->setText(""); ui->key->setText("");
} }

View File

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

View File

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