1111// #include "CommonFramework/Globals.h"
1212// #include "CommonFramework/GlobalSettingsPanel.h"
1313#include " DppIntegration/DppClient.h"
14- #include " SleepyDiscordRunner.h"
1514#include " DiscordIntegrationSettings.h"
1615
1716// #include <iostream>
@@ -23,7 +22,6 @@ namespace Integration{
2322
2423
2524DiscordIntegrationSettingsOption::~DiscordIntegrationSettingsOption (){
26- library0.remove_listener (*this );
2725 this ->remove_listener (*this );
2826}
2927DiscordIntegrationSettingsOption::DiscordIntegrationSettingsOption ()
@@ -38,15 +36,6 @@ DiscordIntegrationSettingsOption::DiscordIntegrationSettingsOption()
3836 LockMode::LOCK_WHILE_RUNNING,
3937 false
4038 )
41- , library0(
42- " <b>Discord Integration Library:</b><br>Restart the program for this to take effect." ,
43- {
44- {Library::SleepyDiscord, " sleepy" , " Sleepy Discord (normal commands, deprecated)" },
45- {Library::DPP, " dpp" , " D++ (slash commands and normal commands)" },
46- },
47- LockMode::LOCK_WHILE_RUNNING,
48- Library::DPP
49- )
5039 , command_type(
5140 " <b>Discord Integration Command Type:</b><br>Restart the program for this to take effect." ,
5241 {
@@ -68,11 +57,6 @@ DiscordIntegrationSettingsOption::DiscordIntegrationSettingsOption()
6857 LockMode::LOCK_WHILE_RUNNING,
6958 " ^" , " ^"
7059 )
71- , use_suffix(
72- " <b>Use Suffix (Sleepy):</b><br>Use a suffix instead of a prefix for commands." ,
73- LockMode::LOCK_WHILE_RUNNING,
74- false
75- )
7660 , game_status(
7761 false ,
7862 " <b>Discord Game Status:</b><br>Enter a status message your bot would display." ,
@@ -85,87 +69,39 @@ DiscordIntegrationSettingsOption::DiscordIntegrationSettingsOption()
8569 LockMode::LOCK_WHILE_RUNNING,
8670 " " , " Automation at your service!"
8771 )
88- , sudo(
89- false ,
90- " <b>Discord Sudo (Sleepy):</b><br>Enter user ID(s) to grant sudo access to." ,
91- LockMode::LOCK_WHILE_RUNNING,
92- " " , " 123456789012345678"
93- )
94- , owner(
95- false ,
96- " <b>Discord Owner (Sleepy):</b><br>Enter the bot owner's ID (your own ID)." ,
97- LockMode::LOCK_WHILE_RUNNING,
98- " " , " 123456789012345678"
99- )
10072 , allow_buttons_from_users(
10173 " <b>Allow Buttons from Users:</b><br>Allow other users to issue button presses." ,
10274 LockMode::LOCK_WHILE_RUNNING,
10375 false
10476 )
10577{
10678 PA_ADD_OPTION (run_on_start);
107- PA_ADD_OPTION (library0);
10879 PA_ADD_OPTION (command_type);
10980 PA_ADD_OPTION (token);
11081 PA_ADD_OPTION (command_prefix);
111- PA_ADD_OPTION (use_suffix);
11282 PA_ADD_OPTION (game_status);
11383 PA_ADD_OPTION (hello_message);
114- PA_ADD_OPTION (sudo);
115- PA_ADD_OPTION (owner);
11684 PA_ADD_OPTION (allow_buttons_from_users);
11785 PA_ADD_OPTION (channels);
11886
11987 DiscordIntegrationSettingsOption::on_config_value_changed (this );
12088
12189 this ->add_listener (*this );
122- library0.add_listener (*this );
12390}
12491void DiscordIntegrationSettingsOption::on_config_value_changed ([[maybe_unused]] void * object){
12592// cout << this->enabled() << endl;
126- #if (defined PA_SLEEPY || defined PA_DPP)
127- bool options_enabled = this ->enabled ();
128- switch (library0){
129- #ifdef PA_SLEEPY
130- case Library::SleepyDiscord:{
131- options_enabled &= !SleepyDiscordRunner::is_running ();
132- ConfigOptionState state = options_enabled ? ConfigOptionState::ENABLED : ConfigOptionState::DISABLED;
133-
134- library0.set_visibility (state);
135- command_type.set_visibility (ConfigOptionState::HIDDEN);
136- token.set_visibility (state);
137- game_status.set_visibility (state);
138- hello_message.set_visibility (state);
139-
140- command_prefix.set_visibility (state);
141- use_suffix.set_visibility (state);
142- sudo.set_visibility (state);
143- owner.set_visibility (state);
144- allow_buttons_from_users.set_visibility (ConfigOptionState::HIDDEN);
145- break ;
146- }
147- #endif
14893#ifdef PA_DPP
149- case Library::DPP:{
150- options_enabled &= !DppClient::Client::instance ().is_initialized ();
151- ConfigOptionState state = options_enabled ? ConfigOptionState::ENABLED : ConfigOptionState::DISABLED;
152-
153- library0.set_visibility (state);
154- command_type.set_visibility (state);
155- token.set_visibility (state);
156- game_status.set_visibility (state);
157- hello_message.set_visibility (state);
158- allow_buttons_from_users.set_visibility (state);
159-
160- command_prefix.set_visibility (state);
161- use_suffix.set_visibility (ConfigOptionState::HIDDEN);
162- sudo.set_visibility (ConfigOptionState::HIDDEN);
163- owner.set_visibility (ConfigOptionState::HIDDEN);
164- break ;
165- }
166- #endif
167- default :;
168- }
94+ bool options_enabled = this ->enabled ();
95+ options_enabled &= !DppClient::Client::instance ().is_initialized ();
96+ ConfigOptionState state = options_enabled ? ConfigOptionState::ENABLED : ConfigOptionState::DISABLED;
97+
98+ command_type.set_visibility (state);
99+ token.set_visibility (state);
100+ game_status.set_visibility (state);
101+ hello_message.set_visibility (state);
102+ allow_buttons_from_users.set_visibility (state);
103+
104+ command_prefix.set_visibility (state);
169105#endif
170106}
171107
@@ -181,7 +117,7 @@ ConfigWidget* DiscordIntegrationSettingsOption::make_QtWidget(QWidget& parent){
181117DiscordIntegrationSettingsWidget::DiscordIntegrationSettingsWidget (QWidget& parent, DiscordIntegrationSettingsOption& value)
182118 : GroupWidget(parent, value)
183119{
184- #if (defined PA_SLEEPY || defined PA_DPP)
120+ #ifdef PA_DPP
185121
186122 QWidget* control_buttons = new QWidget (this );
187123 m_options_layout->insertWidget (0 , control_buttons);
@@ -207,38 +143,14 @@ DiscordIntegrationSettingsWidget::DiscordIntegrationSettingsWidget(QWidget& pare
207143 connect (
208144 button_start, &QPushButton::clicked,
209145 this , [this , &value](bool ){
210- switch (value.library0 ){
211- #ifdef PA_SLEEPY
212- case DiscordIntegrationSettingsOption::Library::SleepyDiscord:
213- SleepyDiscordRunner::sleepy_connect ();
214- break ;
215- #endif
216- #ifdef PA_DPP
217- case DiscordIntegrationSettingsOption::Library::DPP:
218- DppClient::Client::instance ().connect ();
219- break ;
220- #endif
221- default :;
222- }
146+ DppClient::Client::instance ().connect ();
223147 value.on_config_value_changed (this );
224148 }
225149 );
226150 connect (
227151 button_stop, &QPushButton::clicked,
228152 this , [this , &value](bool ){
229- switch (value.library0 ){
230- #ifdef PA_SLEEPY
231- case DiscordIntegrationSettingsOption::Library::SleepyDiscord:
232- SleepyDiscordRunner::sleepy_terminate ();
233- break ;
234- #endif
235- #ifdef PA_DPP
236- case DiscordIntegrationSettingsOption::Library::DPP:
237- DppClient::Client::instance ().disconnect ();
238- break ;
239- #endif
240- default :;
241- }
153+ DppClient::Client::instance ().disconnect ();
242154 value.on_config_value_changed (this );
243155 }
244156 );
0 commit comments