char/char-rtc-obs

git clone https://git.t4t.associates/char/char-rtc-obs

videogame hackerAdd UI in Tools menu for setup35e5e7d

main
2.1 KiB69 linesraw
1#include <obs-module.h>
2#include <obs-frontend-api.h>
3
4#include <QAction>
5#include <QInputDialog>
6#include <QMessageBox>
7
8static void whip_setup_service(const char *key)
9{
10	obs_service_t *current_service = obs_frontend_get_streaming_service();
11	obs_data_t *data = obs_data_create();
12
13	obs_data_set_string(data, "server",
14			    "https://live.umm.gay/api/wish-server/whip");
15	obs_data_set_string(data, "bearer_token", key);
16
17	obs_data_t *hotkey_data = obs_hotkeys_save_service(current_service);
18
19	obs_service_t *new_service = obs_service_create(
20		"whip_custom", "live.umm.gay", data, hotkey_data);
21
22	obs_frontend_set_streaming_service(new_service);
23}
24
25extern "C" void whip_register_setup_item()
26{
27	QAction *menuAction = (QAction *)obs_frontend_add_tools_menu_qaction(
28		"Use live.umm.gay");
29	QObject::connect(menuAction, &QAction::triggered, [] {
30		QInputDialog *dlg = new QInputDialog(nullptr);
31		dlg->setWindowFlag(Qt::WindowStaysOnTopHint, true);
32		dlg->setWindowFlag(Qt::WindowContextHelpButtonHint, false);
33
34		dlg->setWindowTitle("live.umm.gay: Enter Stream Key");
35		dlg->setTextEchoMode(QLineEdit::Password);
36		dlg->setLabelText("Enter your stream key for live.umm.gay:");
37		if (QLineEdit *edit = dlg->findChild<QLineEdit *>()) {
38			edit->setPlaceholderText("channel:stream-key");
39			edit->setStyleSheet("QLineEdit { color: #7f7f7f; }");
40
41			QObject::connect(edit, &QLineEdit::textChanged, [edit] {
42				if (edit->text().isEmpty()) {
43					edit->setStyleSheet(
44						"QLineEdit { color: #7f7f7f; }");
45				} else {
46					edit->setStyleSheet(nullptr);
47				}
48			});
49		}
50
51		QObject::connect(dlg, &QInputDialog::finished, [dlg](int result) {
52			if (result == QDialog::Accepted) {
53				whip_setup_service(
54					dlg->textValue().toUtf8().constData());
55
56				QMessageBox mb(
57					QMessageBox::Information,
58					"live.umm.gay: Success",
59					"Your stream details have been successfully applied.",
60					QMessageBox::NoButton,
61					(QWidget *)
62						obs_frontend_get_main_window());
63				mb.addButton("OK", QMessageBox::AcceptRole);
64				mb.exec();
65			}
66		});
67		dlg->open();
68	});
69}