Added a settings menu.
- Cannot be called yet ingame. - Allows the setting of all `config.ini` variables. - Allows the setting of callwords.
This commit is contained in:
		
							parent
							
								
									c85244e38c
								
							
						
					
					
						commit
						913939835a
					
				@ -48,7 +48,8 @@ SOURCES += main.cpp\
 | 
				
			|||||||
    aolineedit.cpp \
 | 
					    aolineedit.cpp \
 | 
				
			||||||
    aotextedit.cpp \
 | 
					    aotextedit.cpp \
 | 
				
			||||||
    aoevidencedisplay.cpp \
 | 
					    aoevidencedisplay.cpp \
 | 
				
			||||||
    discord_rich_presence.cpp
 | 
					    discord_rich_presence.cpp \
 | 
				
			||||||
 | 
					    aooptionsdialog.cpp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
HEADERS  += lobby.h \
 | 
					HEADERS  += lobby.h \
 | 
				
			||||||
    aoimage.h \
 | 
					    aoimage.h \
 | 
				
			||||||
@ -79,7 +80,8 @@ HEADERS  += lobby.h \
 | 
				
			|||||||
    aotextedit.h \
 | 
					    aotextedit.h \
 | 
				
			||||||
    aoevidencedisplay.h \
 | 
					    aoevidencedisplay.h \
 | 
				
			||||||
    discord_rich_presence.h \
 | 
					    discord_rich_presence.h \
 | 
				
			||||||
    discord-rpc.h
 | 
					    discord-rpc.h \
 | 
				
			||||||
 | 
					    aooptionsdialog.h
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# 1. You need to get BASS and put the x86 bass DLL/headers in the project root folder
 | 
					# 1. You need to get BASS and put the x86 bass DLL/headers in the project root folder
 | 
				
			||||||
#    AND the compilation output folder. If you want a static link, you'll probably
 | 
					#    AND the compilation output folder. If you want a static link, you'll probably
 | 
				
			||||||
 | 
				
			|||||||
@ -5,6 +5,8 @@
 | 
				
			|||||||
#include "networkmanager.h"
 | 
					#include "networkmanager.h"
 | 
				
			||||||
#include "debug_functions.h"
 | 
					#include "debug_functions.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "aooptionsdialog.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QDebug>
 | 
					#include <QDebug>
 | 
				
			||||||
#include <QRect>
 | 
					#include <QRect>
 | 
				
			||||||
#include <QDesktopWidget>
 | 
					#include <QDesktopWidget>
 | 
				
			||||||
@ -52,7 +54,7 @@ void AOApplication::construct_lobby()
 | 
				
			|||||||
  int a = 0;
 | 
					  int a = 0;
 | 
				
			||||||
  BASS_DEVICEINFO info;
 | 
					  BASS_DEVICEINFO info;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for (a = 1; BASS_GetDeviceInfo(a, &info); a++)
 | 
					  for (a = 0; BASS_GetDeviceInfo(a, &info); a++)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
      if (get_audio_output_device() == info.name)
 | 
					      if (get_audio_output_device() == info.name)
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
@ -60,11 +62,7 @@ void AOApplication::construct_lobby()
 | 
				
			|||||||
          qDebug() << info.name << "was set as the default audio output device.";
 | 
					          qDebug() << info.name << "was set as the default audio output device.";
 | 
				
			||||||
          break;
 | 
					          break;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      qDebug() << info.name;
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					 | 
				
			||||||
  //AOOptionsDialog* test = new AOOptionsDialog(nullptr, this);
 | 
					 | 
				
			||||||
  //test->exec();
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void AOApplication::destruct_lobby()
 | 
					void AOApplication::destruct_lobby()
 | 
				
			||||||
@ -127,6 +125,20 @@ QString AOApplication::get_cccc_version_string()
 | 
				
			|||||||
void AOApplication::reload_theme()
 | 
					void AOApplication::reload_theme()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  current_theme = read_theme();
 | 
					  current_theme = read_theme();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // This may not be the best place for it, but let's read the audio output device just in case.
 | 
				
			||||||
 | 
					  int a = 0;
 | 
				
			||||||
 | 
					  BASS_DEVICEINFO info;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  for (a = 0; BASS_GetDeviceInfo(a, &info); a++)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					      if (get_audio_output_device() == info.name)
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					          BASS_SetDevice(a);
 | 
				
			||||||
 | 
					          qDebug() << info.name << "was set as the default audio output device.";
 | 
				
			||||||
 | 
					          break;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void AOApplication::set_favorite_list()
 | 
					void AOApplication::set_favorite_list()
 | 
				
			||||||
@ -197,3 +209,10 @@ void AOApplication::ms_connect_finished(bool connected, bool will_retry)
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void AOApplication::call_settings_menu()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    AOOptionsDialog* settings = new AOOptionsDialog(nullptr, this);
 | 
				
			||||||
 | 
					    settings->exec();
 | 
				
			||||||
 | 
					    delete settings;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -42,6 +42,8 @@ public:
 | 
				
			|||||||
  void send_ms_packet(AOPacket *p_packet);
 | 
					  void send_ms_packet(AOPacket *p_packet);
 | 
				
			||||||
  void send_server_packet(AOPacket *p_packet, bool encoded = true);
 | 
					  void send_server_packet(AOPacket *p_packet, bool encoded = true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void call_settings_menu();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /////////////////server metadata//////////////////
 | 
					  /////////////////server metadata//////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  unsigned int s_decryptor = 5;
 | 
					  unsigned int s_decryptor = 5;
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										328
									
								
								aooptionsdialog.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										328
									
								
								aooptionsdialog.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,328 @@
 | 
				
			|||||||
 | 
					#include "aooptionsdialog.h"
 | 
				
			||||||
 | 
					#include "aoapplication.h"
 | 
				
			||||||
 | 
					#include "bass.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <QtCore/QVariant>
 | 
				
			||||||
 | 
					#include <QtWidgets/QApplication>
 | 
				
			||||||
 | 
					#include <QtWidgets/QCheckBox>
 | 
				
			||||||
 | 
					#include <QtWidgets/QComboBox>
 | 
				
			||||||
 | 
					#include <QtWidgets/QDialog>
 | 
				
			||||||
 | 
					#include <QtWidgets/QDialogButtonBox>
 | 
				
			||||||
 | 
					#include <QtWidgets/QFormLayout>
 | 
				
			||||||
 | 
					#include <QtWidgets/QFrame>
 | 
				
			||||||
 | 
					#include <QtWidgets/QLabel>
 | 
				
			||||||
 | 
					#include <QtWidgets/QLineEdit>
 | 
				
			||||||
 | 
					#include <QtWidgets/QPlainTextEdit>
 | 
				
			||||||
 | 
					#include <QtWidgets/QSpinBox>
 | 
				
			||||||
 | 
					#include <QtWidgets/QTabWidget>
 | 
				
			||||||
 | 
					#include <QtWidgets/QVBoxLayout>
 | 
				
			||||||
 | 
					#include <QtWidgets/QWidget>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <QDirIterator>
 | 
				
			||||||
 | 
					#include <QTextStream>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDialog(parent)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    ao_app = p_ao_app;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Setting up the basics.
 | 
				
			||||||
 | 
					    // setAttribute(Qt::WA_DeleteOnClose);
 | 
				
			||||||
 | 
					    setWindowTitle("Settings");
 | 
				
			||||||
 | 
					    resize(398, 320);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SettingsButtons = new QDialogButtonBox(this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    QSizePolicy sizePolicy1(QSizePolicy::Expanding, QSizePolicy::Fixed);
 | 
				
			||||||
 | 
					    sizePolicy1.setHorizontalStretch(0);
 | 
				
			||||||
 | 
					    sizePolicy1.setVerticalStretch(0);
 | 
				
			||||||
 | 
					    sizePolicy1.setHeightForWidth(SettingsButtons->sizePolicy().hasHeightForWidth());
 | 
				
			||||||
 | 
					    SettingsButtons->setSizePolicy(sizePolicy1);
 | 
				
			||||||
 | 
					    SettingsButtons->setOrientation(Qt::Horizontal);
 | 
				
			||||||
 | 
					    SettingsButtons->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Save);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    QObject::connect(SettingsButtons, SIGNAL(accepted()), this, SLOT(save_pressed()));
 | 
				
			||||||
 | 
					    QObject::connect(SettingsButtons, SIGNAL(rejected()), this, SLOT(discard_pressed()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // We'll stop updates so that the window won't flicker while it's being made.
 | 
				
			||||||
 | 
					    setUpdatesEnabled(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // First of all, we want a tabbed dialog, so let's add some layout.
 | 
				
			||||||
 | 
					    verticalLayout = new QVBoxLayout(this);
 | 
				
			||||||
 | 
					    SettingsTabs = new QTabWidget(this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    verticalLayout->addWidget(SettingsTabs);
 | 
				
			||||||
 | 
					    verticalLayout->addWidget(SettingsButtons);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Let's add the tabs one by one.
 | 
				
			||||||
 | 
					    // First, we'll start with 'Gameplay'.
 | 
				
			||||||
 | 
					    GameplayTab = new QWidget();
 | 
				
			||||||
 | 
					    SettingsTabs->addTab(GameplayTab, "Gameplay");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    formLayoutWidget = new QWidget(GameplayTab);
 | 
				
			||||||
 | 
					    formLayoutWidget->setGeometry(QRect(10, 10, 361, 211));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    GameplayForm = new QFormLayout(formLayoutWidget);
 | 
				
			||||||
 | 
					    GameplayForm->setLabelAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter);
 | 
				
			||||||
 | 
					    GameplayForm->setFormAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop);
 | 
				
			||||||
 | 
					    GameplayForm->setContentsMargins(0, 0, 0, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ThemeLabel = new QLabel(formLayoutWidget);
 | 
				
			||||||
 | 
					    ThemeLabel->setText("Theme:");
 | 
				
			||||||
 | 
					    ThemeLabel->setToolTip("Allows you to set the theme used ingame. If your theme changes the lobby's look, too, you'll obviously need to reload the lobby somehow for it take effect. Joining a server and leaving it should work.");
 | 
				
			||||||
 | 
					    GameplayForm->setWidget(0, QFormLayout::LabelRole, ThemeLabel);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ThemeCombobox = new QComboBox(formLayoutWidget);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Fill the combobox with the names of the themes.
 | 
				
			||||||
 | 
					    QDirIterator it(p_ao_app->get_base_path() + "themes", QDir::Dirs, QDirIterator::NoIteratorFlags);
 | 
				
			||||||
 | 
					    while (it.hasNext())
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        QString actualname = QDir(it.next()).dirName();
 | 
				
			||||||
 | 
					        if (actualname != "." && actualname != "..")
 | 
				
			||||||
 | 
					            ThemeCombobox->addItem(actualname);
 | 
				
			||||||
 | 
					        if (actualname == p_ao_app->read_theme())
 | 
				
			||||||
 | 
					            ThemeCombobox->setCurrentIndex(ThemeCombobox->count()-1);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    GameplayForm->setWidget(0, QFormLayout::FieldRole, ThemeCombobox);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ThemeLogDivider = new QFrame(formLayoutWidget);
 | 
				
			||||||
 | 
					    ThemeLogDivider->setMidLineWidth(0);
 | 
				
			||||||
 | 
					    ThemeLogDivider->setFrameShape(QFrame::HLine);
 | 
				
			||||||
 | 
					    ThemeLogDivider->setFrameShadow(QFrame::Sunken);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    GameplayForm->setWidget(1, QFormLayout::FieldRole, ThemeLogDivider);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    DownwardsLabel = new QLabel(formLayoutWidget);
 | 
				
			||||||
 | 
					    DownwardsLabel->setText("Log goes downwards:");
 | 
				
			||||||
 | 
					    DownwardsLabel->setToolTip("If ticked, the IC chatlog will go downwards, in the sense that new messages will appear at the bottom (like the OOC chatlog). The Vanilla behaviour is equivalent to this being unticked.");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    GameplayForm->setWidget(2, QFormLayout::LabelRole, DownwardsLabel);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    DownwardCheckbox = new QCheckBox(formLayoutWidget);
 | 
				
			||||||
 | 
					    DownwardCheckbox->setChecked(p_ao_app->get_log_goes_downwards());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    GameplayForm->setWidget(2, QFormLayout::FieldRole, DownwardCheckbox);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    LengthLabel = new QLabel(formLayoutWidget);
 | 
				
			||||||
 | 
					    LengthLabel->setText("Log length:");
 | 
				
			||||||
 | 
					    LengthLabel->setToolTip("The amount of messages the IC chatlog will keep before getting rid of older messages. A value of 0 or below counts as 'infinite'.");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    GameplayForm->setWidget(3, QFormLayout::LabelRole, LengthLabel);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    LengthSpinbox = new QSpinBox(formLayoutWidget);
 | 
				
			||||||
 | 
					    LengthSpinbox->setMaximum(10000);
 | 
				
			||||||
 | 
					    LengthSpinbox->setValue(p_ao_app->get_max_log_size());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    GameplayForm->setWidget(3, QFormLayout::FieldRole, LengthSpinbox);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    LogNamesDivider = new QFrame(formLayoutWidget);
 | 
				
			||||||
 | 
					    LogNamesDivider->setFrameShape(QFrame::HLine);
 | 
				
			||||||
 | 
					    LogNamesDivider->setFrameShadow(QFrame::Sunken);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    GameplayForm->setWidget(4, QFormLayout::FieldRole, LogNamesDivider);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    UsernameLabel = new QLabel(formLayoutWidget);
 | 
				
			||||||
 | 
					    UsernameLabel->setText("Default username:");
 | 
				
			||||||
 | 
					    UsernameLabel->setToolTip("Your OOC name will be filled in with this string when you join a server.");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    GameplayForm->setWidget(5, QFormLayout::LabelRole, UsernameLabel);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    UsernameLineEdit = new QLineEdit(formLayoutWidget);
 | 
				
			||||||
 | 
					    UsernameLineEdit->setMaxLength(30);
 | 
				
			||||||
 | 
					    UsernameLineEdit->setText(p_ao_app->get_default_username());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    GameplayForm->setWidget(5, QFormLayout::FieldRole, UsernameLineEdit);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ShownameLabel = new QLabel(formLayoutWidget);
 | 
				
			||||||
 | 
					    ShownameLabel->setText("Custom shownames:");
 | 
				
			||||||
 | 
					    ShownameLabel->setToolTip("Gives the default value for the ingame 'Custom shownames' tickbox, which in turn determines whether your client should display custom shownames or not.");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    GameplayForm->setWidget(6, QFormLayout::LabelRole, ShownameLabel);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ShownameCheckbox = new QCheckBox(formLayoutWidget);
 | 
				
			||||||
 | 
					    ShownameCheckbox->setChecked(p_ao_app->get_showname_enabled_by_default());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    GameplayForm->setWidget(6, QFormLayout::FieldRole, ShownameCheckbox);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Here we start the callwords tab.
 | 
				
			||||||
 | 
					    CallwordsTab = new QWidget();
 | 
				
			||||||
 | 
					    SettingsTabs->addTab(CallwordsTab, "Callwords");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    verticalLayoutWidget = new QWidget(CallwordsTab);
 | 
				
			||||||
 | 
					    verticalLayoutWidget->setGeometry(QRect(10, 10, 361, 211));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    CallwordsLayout = new QVBoxLayout(verticalLayoutWidget);
 | 
				
			||||||
 | 
					    CallwordsLayout->setContentsMargins(0,0,0,0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    CallwordsTextEdit = new QPlainTextEdit(verticalLayoutWidget);
 | 
				
			||||||
 | 
					    QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
 | 
				
			||||||
 | 
					    sizePolicy.setHorizontalStretch(0);
 | 
				
			||||||
 | 
					    sizePolicy.setVerticalStretch(0);
 | 
				
			||||||
 | 
					    sizePolicy.setHeightForWidth(CallwordsTextEdit->sizePolicy().hasHeightForWidth());
 | 
				
			||||||
 | 
					    CallwordsTextEdit->setSizePolicy(sizePolicy);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Let's fill the callwords text edit with the already present callwords.
 | 
				
			||||||
 | 
					    CallwordsTextEdit->document()->clear();
 | 
				
			||||||
 | 
					    foreach (QString callword, p_ao_app->get_call_words()) {
 | 
				
			||||||
 | 
					        CallwordsTextEdit->appendPlainText(callword);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    CallwordsLayout->addWidget(CallwordsTextEdit);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    CallwordsExplainLabel = new QLabel(verticalLayoutWidget);
 | 
				
			||||||
 | 
					    CallwordsExplainLabel->setWordWrap(true);
 | 
				
			||||||
 | 
					    CallwordsExplainLabel->setText("<html><head/><body>Enter as many callwords as you would like. These are case insensitive. Make sure to leave every callword in its own line!<br>Do not leave a line with a space at the end -- you will be alerted everytime someone uses a space in their messages.</body></html>");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    CallwordsLayout->addWidget(CallwordsExplainLabel);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // And finally, the Audio tab.
 | 
				
			||||||
 | 
					    AudioTab = new QWidget();
 | 
				
			||||||
 | 
					    SettingsTabs->addTab(AudioTab, "Audio");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    formLayoutWidget_2 = new QWidget(AudioTab);
 | 
				
			||||||
 | 
					    formLayoutWidget_2->setGeometry(QRect(10, 10, 361, 211));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    AudioForm = new QFormLayout(formLayoutWidget_2);
 | 
				
			||||||
 | 
					    AudioForm->setObjectName(QStringLiteral("AudioForm"));
 | 
				
			||||||
 | 
					    AudioForm->setLabelAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter);
 | 
				
			||||||
 | 
					    AudioForm->setFormAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop);
 | 
				
			||||||
 | 
					    AudioForm->setContentsMargins(0, 0, 0, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    AudioDevideLabel = new QLabel(formLayoutWidget_2);
 | 
				
			||||||
 | 
					    AudioDevideLabel->setText("Audio device:");
 | 
				
			||||||
 | 
					    AudioDevideLabel->setToolTip("Allows you to set the theme used ingame. If your theme changes the lobby's look, too, you'll obviously need to reload the lobby somehow for it take effect. Joining a server and leaving it should work.");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    AudioForm->setWidget(0, QFormLayout::LabelRole, AudioDevideLabel);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    AudioDeviceCombobox = new QComboBox(formLayoutWidget_2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Let's fill out the combobox with the available audio devices.
 | 
				
			||||||
 | 
					    int a = 0;
 | 
				
			||||||
 | 
					    BASS_DEVICEINFO info;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (a = 0; BASS_GetDeviceInfo(a, &info); a++)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        AudioDeviceCombobox->addItem(info.name);
 | 
				
			||||||
 | 
					        if (p_ao_app->get_audio_output_device() == info.name)
 | 
				
			||||||
 | 
					            AudioDeviceCombobox->setCurrentIndex(AudioDeviceCombobox->count()-1);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    AudioForm->setWidget(0, QFormLayout::FieldRole, AudioDeviceCombobox);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    DeviceVolumeDivider = new QFrame(formLayoutWidget_2);
 | 
				
			||||||
 | 
					    DeviceVolumeDivider->setFrameShape(QFrame::HLine);
 | 
				
			||||||
 | 
					    DeviceVolumeDivider->setFrameShadow(QFrame::Sunken);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    AudioForm->setWidget(1, QFormLayout::FieldRole, DeviceVolumeDivider);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    MusicVolumeLabel = new QLabel(formLayoutWidget_2);
 | 
				
			||||||
 | 
					    MusicVolumeLabel->setText("Music:");
 | 
				
			||||||
 | 
					    MusicVolumeLabel->setToolTip("Sets the music's default volume.");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    AudioForm->setWidget(2, QFormLayout::LabelRole, MusicVolumeLabel);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    MusicVolumeSpinbox = new QSpinBox(formLayoutWidget_2);
 | 
				
			||||||
 | 
					    MusicVolumeSpinbox->setValue(p_ao_app->get_default_music());
 | 
				
			||||||
 | 
					    MusicVolumeSpinbox->setMaximum(100);
 | 
				
			||||||
 | 
					    MusicVolumeSpinbox->setSuffix("%");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    AudioForm->setWidget(2, QFormLayout::FieldRole, MusicVolumeSpinbox);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SFXVolumeLabel = new QLabel(formLayoutWidget_2);
 | 
				
			||||||
 | 
					    SFXVolumeLabel->setText("SFX:");
 | 
				
			||||||
 | 
					    SFXVolumeLabel->setToolTip("Sets the SFX's default volume. Interjections and actual sound effects count as 'SFX'.");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    AudioForm->setWidget(3, QFormLayout::LabelRole, SFXVolumeLabel);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SFXVolumeSpinbox = new QSpinBox(formLayoutWidget_2);
 | 
				
			||||||
 | 
					    SFXVolumeSpinbox->setValue(p_ao_app->get_default_sfx());
 | 
				
			||||||
 | 
					    SFXVolumeSpinbox->setMaximum(100);
 | 
				
			||||||
 | 
					    SFXVolumeSpinbox->setSuffix("%");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    AudioForm->setWidget(3, QFormLayout::FieldRole, SFXVolumeSpinbox);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    BlipsVolumeLabel = new QLabel(formLayoutWidget_2);
 | 
				
			||||||
 | 
					    BlipsVolumeLabel->setText("Blips:");
 | 
				
			||||||
 | 
					    BlipsVolumeLabel->setToolTip("Sets the volume of the blips, the talking sound effects.");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    AudioForm->setWidget(4, QFormLayout::LabelRole, BlipsVolumeLabel);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    BlipsVolumeSpinbox = new QSpinBox(formLayoutWidget_2);
 | 
				
			||||||
 | 
					    BlipsVolumeSpinbox->setValue(p_ao_app->get_default_blip());
 | 
				
			||||||
 | 
					    BlipsVolumeSpinbox->setMaximum(100);
 | 
				
			||||||
 | 
					    BlipsVolumeSpinbox->setSuffix("%");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    AudioForm->setWidget(4, QFormLayout::FieldRole, BlipsVolumeSpinbox);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    VolumeBlipDivider = new QFrame(formLayoutWidget_2);
 | 
				
			||||||
 | 
					    VolumeBlipDivider->setFrameShape(QFrame::HLine);
 | 
				
			||||||
 | 
					    VolumeBlipDivider->setFrameShadow(QFrame::Sunken);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    AudioForm->setWidget(5, QFormLayout::FieldRole, VolumeBlipDivider);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    BlipRateLabel = new QLabel(formLayoutWidget_2);
 | 
				
			||||||
 | 
					    BlipRateLabel->setText("Blip rate:");
 | 
				
			||||||
 | 
					    BlipRateLabel->setToolTip("Sets the delay between playing the blip sounds.");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    AudioForm->setWidget(6, QFormLayout::LabelRole, BlipRateLabel);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    BlipRateSpinbox = new QSpinBox(formLayoutWidget_2);
 | 
				
			||||||
 | 
					    BlipRateSpinbox->setValue(p_ao_app->read_blip_rate());
 | 
				
			||||||
 | 
					    BlipRateSpinbox->setMinimum(1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    AudioForm->setWidget(6, QFormLayout::FieldRole, BlipRateSpinbox);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    BlankBlipsLabel = new QLabel(formLayoutWidget_2);
 | 
				
			||||||
 | 
					    BlankBlipsLabel->setText("Blank blips:");
 | 
				
			||||||
 | 
					    BlankBlipsLabel->setToolTip("If true, the game will play a blip sound even when a space is 'being said'.");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    AudioForm->setWidget(7, QFormLayout::LabelRole, BlankBlipsLabel);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    BlankBlipsCheckbox = new QCheckBox(formLayoutWidget_2);
 | 
				
			||||||
 | 
					    BlankBlipsCheckbox->setChecked(p_ao_app->get_blank_blip());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    AudioForm->setWidget(7, QFormLayout::FieldRole, BlankBlipsCheckbox);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // When we're done, we should continue the updates!
 | 
				
			||||||
 | 
					    setUpdatesEnabled(true);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void AOOptionsDialog::save_pressed()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // Save everything into the config.ini.
 | 
				
			||||||
 | 
					    QSettings* configini = ao_app->configini;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    configini->setValue("theme", ThemeCombobox->currentText());
 | 
				
			||||||
 | 
					    configini->setValue("log_goes_downwards", DownwardCheckbox->isChecked());
 | 
				
			||||||
 | 
					    configini->setValue("log_maximum", LengthSpinbox->value());
 | 
				
			||||||
 | 
					    configini->setValue("default_username", UsernameLineEdit->text());
 | 
				
			||||||
 | 
					    configini->setValue("show_custom_shownames", ShownameCheckbox->isChecked());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    QFile* callwordsini = new QFile(ao_app->get_base_path() + "callwords.ini");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (!callwordsini->open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text))
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // Nevermind!
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        QTextStream out(callwordsini);
 | 
				
			||||||
 | 
					        out << CallwordsTextEdit->toPlainText();
 | 
				
			||||||
 | 
					        callwordsini->close();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    configini->setValue("default_audio_device", AudioDeviceCombobox->currentText());
 | 
				
			||||||
 | 
					    configini->setValue("default_music", MusicVolumeSpinbox->value());
 | 
				
			||||||
 | 
					    configini->setValue("default_sfx", SFXVolumeSpinbox->value());
 | 
				
			||||||
 | 
					    configini->setValue("default_blip", BlipsVolumeSpinbox->value());
 | 
				
			||||||
 | 
					    configini->setValue("blip_rate", BlipRateSpinbox->value());
 | 
				
			||||||
 | 
					    configini->setValue("blank_blip", BlankBlipsCheckbox->isChecked());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    done(0);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void AOOptionsDialog::discard_pressed()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    done(0);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										81
									
								
								aooptionsdialog.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										81
									
								
								aooptionsdialog.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,81 @@
 | 
				
			|||||||
 | 
					#ifndef AOOPTIONSDIALOG_H
 | 
				
			||||||
 | 
					#define AOOPTIONSDIALOG_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "aoapplication.h"
 | 
				
			||||||
 | 
					#include "bass.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <QtCore/QVariant>
 | 
				
			||||||
 | 
					#include <QtWidgets/QApplication>
 | 
				
			||||||
 | 
					#include <QtWidgets/QCheckBox>
 | 
				
			||||||
 | 
					#include <QtWidgets/QComboBox>
 | 
				
			||||||
 | 
					#include <QtWidgets/QDialog>
 | 
				
			||||||
 | 
					#include <QtWidgets/QDialogButtonBox>
 | 
				
			||||||
 | 
					#include <QtWidgets/QFormLayout>
 | 
				
			||||||
 | 
					#include <QtWidgets/QFrame>
 | 
				
			||||||
 | 
					#include <QtWidgets/QLabel>
 | 
				
			||||||
 | 
					#include <QtWidgets/QLineEdit>
 | 
				
			||||||
 | 
					#include <QtWidgets/QPlainTextEdit>
 | 
				
			||||||
 | 
					#include <QtWidgets/QSpinBox>
 | 
				
			||||||
 | 
					#include <QtWidgets/QTabWidget>
 | 
				
			||||||
 | 
					#include <QtWidgets/QVBoxLayout>
 | 
				
			||||||
 | 
					#include <QtWidgets/QWidget>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class AOOptionsDialog: public QDialog
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    Q_OBJECT
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					    explicit AOOptionsDialog(QWidget *parent = nullptr, AOApplication *p_ao_app = nullptr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					    AOApplication *ao_app;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    QVBoxLayout *verticalLayout;
 | 
				
			||||||
 | 
					    QTabWidget *SettingsTabs;
 | 
				
			||||||
 | 
					    QWidget *GameplayTab;
 | 
				
			||||||
 | 
					    QWidget *formLayoutWidget;
 | 
				
			||||||
 | 
					    QFormLayout *GameplayForm;
 | 
				
			||||||
 | 
					    QLabel *ThemeLabel;
 | 
				
			||||||
 | 
					    QComboBox *ThemeCombobox;
 | 
				
			||||||
 | 
					    QFrame *ThemeLogDivider;
 | 
				
			||||||
 | 
					    QLabel *DownwardsLabel;
 | 
				
			||||||
 | 
					    QCheckBox *DownwardCheckbox;
 | 
				
			||||||
 | 
					    QLabel *LengthLabel;
 | 
				
			||||||
 | 
					    QSpinBox *LengthSpinbox;
 | 
				
			||||||
 | 
					    QFrame *LogNamesDivider;
 | 
				
			||||||
 | 
					    QLineEdit *UsernameLineEdit;
 | 
				
			||||||
 | 
					    QLabel *UsernameLabel;
 | 
				
			||||||
 | 
					    QLabel *ShownameLabel;
 | 
				
			||||||
 | 
					    QCheckBox *ShownameCheckbox;
 | 
				
			||||||
 | 
					    QWidget *CallwordsTab;
 | 
				
			||||||
 | 
					    QWidget *verticalLayoutWidget;
 | 
				
			||||||
 | 
					    QVBoxLayout *CallwordsLayout;
 | 
				
			||||||
 | 
					    QPlainTextEdit *CallwordsTextEdit;
 | 
				
			||||||
 | 
					    QLabel *CallwordsExplainLabel;
 | 
				
			||||||
 | 
					    QCheckBox *CharacterCallwordsCheckbox;
 | 
				
			||||||
 | 
					    QWidget *AudioTab;
 | 
				
			||||||
 | 
					    QWidget *formLayoutWidget_2;
 | 
				
			||||||
 | 
					    QFormLayout *AudioForm;
 | 
				
			||||||
 | 
					    QLabel *AudioDevideLabel;
 | 
				
			||||||
 | 
					    QComboBox *AudioDeviceCombobox;
 | 
				
			||||||
 | 
					    QFrame *DeviceVolumeDivider;
 | 
				
			||||||
 | 
					    QSpinBox *MusicVolumeSpinbox;
 | 
				
			||||||
 | 
					    QLabel *MusicVolumeLabel;
 | 
				
			||||||
 | 
					    QSpinBox *SFXVolumeSpinbox;
 | 
				
			||||||
 | 
					    QSpinBox *BlipsVolumeSpinbox;
 | 
				
			||||||
 | 
					    QLabel *SFXVolumeLabel;
 | 
				
			||||||
 | 
					    QLabel *BlipsVolumeLabel;
 | 
				
			||||||
 | 
					    QFrame *VolumeBlipDivider;
 | 
				
			||||||
 | 
					    QSpinBox *BlipRateSpinbox;
 | 
				
			||||||
 | 
					    QLabel *BlipRateLabel;
 | 
				
			||||||
 | 
					    QCheckBox *BlankBlipsCheckbox;
 | 
				
			||||||
 | 
					    QLabel *BlankBlipsLabel;
 | 
				
			||||||
 | 
					    QDialogButtonBox *SettingsButtons;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					signals:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public slots:
 | 
				
			||||||
 | 
					    void save_pressed();
 | 
				
			||||||
 | 
					    void discard_pressed();
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // AOOPTIONSDIALOG_H
 | 
				
			||||||
@ -102,7 +102,7 @@ QString AOApplication::get_default_username()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
QString AOApplication::get_audio_output_device()
 | 
					QString AOApplication::get_audio_output_device()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  QString result = configini->value("default_username", "default").value<QString>();
 | 
					  QString result = configini->value("default_audio_device", "default").value<QString>();
 | 
				
			||||||
  return result;
 | 
					  return result;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user