2.10.1 Changes (#888)

* Utilise .ui file to create settings dialog (#858)

* Remove config loading from AOApplications

Removes most, but not all config functions from AOApplication and moves them into their own class.

Not even remotely done here. but holy shit I'm tired.

* First steps towards UI file

* Fixed your UI layout issue

* Leifa bullies me

* Set all the setters

Reminder : Figure out why username and ooc_name exist. Are they the same? Maybe. Maybe not. Gonna have to look at it and migrate the key.

Todo : Cleanup key naming. Most of these are terrible, imprecise or I just don't like them.

* Make layout appear proper

* Minor option dialog update

* Hookup AOOptionsdialogue to Options Getter/setter

Not done yet, but parts of the options interactions work again.

* More settings menu working

* Mostly working settings dialogue

Restore default and cancel still need work

* Fix asset widget

* Tooltips

Also removes the commented out tooltip code

* Finish Tooltips

Move widget implementation to its own folder

* Migrate callwords to config.ini

Also correct sleep deprived code.

* Fix widget translation

* Language dropdown changes

We might want to look into doing this a bit better.

* Remove QSettings from AOApplication

Try cleaning up stray references to said object anymore

* Fix constructor order to prevent runtime crash

* Slightly sort implementation file

* Remove unused label declarations from header

Fix some comments

* Formatting

* Fix buttons

Also fixes restore settings when a restore to default is aborted.

* Raise pair list after courtroom construction (#859)

* Don't reset evidence selection (#860)

They are defaulted in the header. This SHOULD not affect the client negatively.

* Hitting the emergency exit (#861)

Don't change the widget state when the ID exceeds the current widget list due to pages being changed while evidence is being edited.

* add CI and license badge

* add contributors

* Handle config.temp after confirmation

* Deletes config.temp when the user has confirmed they want to keep the current settings.

* Make reset to default destructive

Don't worry, we ask first! :)

* Fix case of self_offset received without a y offset (#864)

caused by typos in #701

it's possible for older clients to send x offsets without a y
offset. if you think this case is annoying you can remove it in
the next version and handle it server-side instead

* Change default settings (#839)

* Make default config enable features for most cases except for Continuous Playback due to it introducing performance issues according to tooltip and confirmed in testing
* Increase log size to 1000
* Default disable animated themes

Co-authored-by: Salanto <62221668+Salanto@users.noreply.github.com>
Co-authored-by: stonedDiscord <Tukz@gmx.de>

* Make it a singleton? Maybe? I dunno? Ask Longbyte

* Commit suggestions

* More suggestions

Also try fixing a memory leak. Not going to well.

* Return to dialog

Otherwise we don't have Exec.

* Cleanup

* Deprecate ooc_name, implement username

* Remove ooc_name key and copy its value to default_showname if its empty.

* Consistent naming in AOOptionsDialog

* Clang format

* Don't write the username to the showname

* Fix theme dropdown being incorrectly set

* Bandaid callword playing every message

* Remove unused or duplicate includes

* More include removals

Removes lobby and courtroom direct includes from the dialog source

* Burn baby, burn!

* Remove reload_theme function

* Remove "Case Alert Supported Message"

All servers I tested on master supported it. The text is redundant in operation.

Co-authored-by: TrickyLeifa <date.epoch@gmail.com>
Co-authored-by: stonedDiscord <Tukz@gmx.de>
Co-authored-by: oldmud0 <oldmud0@users.noreply.github.com>
Co-authored-by: Crystalwarrior <Varsash@Gmail.com>

* Cleanup lobby (#880)

* Remove config loading from AOApplications

Removes most, but not all config functions from AOApplication and moves them into their own class.

Not even remotely done here. but holy shit I'm tired.

* First steps towards UI file

* Fixed your UI layout issue

* Leifa bullies me

* Set all the setters

Reminder : Figure out why username and ooc_name exist. Are they the same? Maybe. Maybe not. Gonna have to look at it and migrate the key.

Todo : Cleanup key naming. Most of these are terrible, imprecise or I just don't like them.

* Make layout appear proper

* Minor option dialog update

* Hookup AOOptionsdialogue to Options Getter/setter

Not done yet, but parts of the options interactions work again.

* More settings menu working

* Mostly working settings dialogue

Restore default and cancel still need work

* Fix asset widget

* Tooltips

Also removes the commented out tooltip code

* Finish Tooltips

Move widget implementation to its own folder

* Migrate callwords to config.ini

Also correct sleep deprived code.

* Fix widget translation

* Language dropdown changes

We might want to look into doing this a bit better.

* Remove QSettings from AOApplication

Try cleaning up stray references to said object anymore

* Fix constructor order to prevent runtime crash

* Slightly sort implementation file

* Remove unused label declarations from header

Fix some comments

* Formatting

* Fix buttons

Also fixes restore settings when a restore to default is aborted.

* Raise pair list after courtroom construction (#859)

* Don't reset evidence selection (#860)

They are defaulted in the header. This SHOULD not affect the client negatively.

* Hitting the emergency exit (#861)

Don't change the widget state when the ID exceeds the current widget list due to pages being changed while evidence is being edited.

* add CI and license badge

* add contributors

* Handle config.temp after confirmation

* Deletes config.temp when the user has confirmed they want to keep the current settings.

* Make reset to default destructive

Don't worry, we ask first! :)

* Fix case of self_offset received without a y offset (#864)

caused by typos in #701

it's possible for older clients to send x offsets without a y
offset. if you think this case is annoying you can remove it in
the next version and handle it server-side instead

* Change default settings (#839)

* Make default config enable features for most cases except for Continuous Playback due to it introducing performance issues according to tooltip and confirmed in testing
* Increase log size to 1000
* Default disable animated themes


Co-authored-by: Salanto <62221668+Salanto@users.noreply.github.com>
Co-authored-by: stonedDiscord <Tukz@gmx.de>

* Make it a singleton? Maybe? I dunno? Ask Longbyte

* Commit suggestions

* More suggestions

Also try fixing a memory leak. Not going to well.

* Return to dialog

Otherwise we don't have Exec.

* Cleanup

* Deprecate ooc_name, implement username

* Remove ooc_name key and copy its value to default_showname if its empty.

* Consistent naming in AOOptionsDialog

* Clang format

* Don't write the username to the showname

* Fix theme dropdown being incorrectly set

* Bandaid callword playing every message

* Remove unused or duplicate includes

* More include removals

Removes lobby and courtroom direct includes from the dialog source

* Burn baby, burn!

* Remove reload_theme function

* Remove "Case Alert Supported Message"

All servers I tested on master supported it. The text is redundant in operation.

* Create preliminary lobby design

Attempts to slightly modernize the aging lobby to a scheme more akin to modern server browsers.

* Fix missing header, add necessary search lineedits

* More UI changes

* Start hooking up new UI elements

* Hookup Serverbrowser to new UI frontend

Still need to fix the favorites AND implement the NEW demolist

* Fixup demo ui and make demoserver functional

* More demoserver cleanup

* Remove jarring ao_app pointer shenigans

Still a bit to do before we can safely remove that pointer, but hey, its something.

* *unholy screeches*

Tried to untangle the tange of dependencies that is connection behaviour

* Rip out loading screen

Some servers are not even sending proper values anymore, like vanilla, so why keep it?

* Optimise includes, format header

Lobby should not even have to know what an AOPacket is, smh

* Formatting fixes

and turn settings menu opening into a signal

* Why does netmanager never emit when the server is connected

* Fixup final parts

About as well implemented as I can do rn. Missing the load screen, but that was more flair than anything else

* Correct start page

* demo qol

Co-authored-by: TrickyLeifa <date.epoch@gmail.com>
Co-authored-by: stonedDiscord <Tukz@gmx.de>
Co-authored-by: oldmud0 <oldmud0@users.noreply.github.com>
Co-authored-by: Crystalwarrior <Varsash@Gmail.com>

* Delete rebase artifact

* only set setting codec on qt5

* fix old regex

* qlocale include was missing

* Add default soundfont value + cleaup stream checks

* Remove Case Announcement

* Add add_server dialog and move logic to options.h

* Add Direction Connection Widget and function

* Visual Fluff, don't show direct connection on demo screen

* Implement ui-file reload and RCC mounting.

* Add edit menu to favorites

* Add Server remains active when no server is selected

* Hack together window title for courtroom

I hate this.

* Fix incorrect subtheme location code

* Cleanup

* Make all charicons appear on first join

This entire system needs a rework, but this will do for now.

Also slightly improves performance by not making it load the character list 4 times, only 2 now :^)
closes #854

* Fix evidence hover selector under Qt5

#closes #890

* Remove options calling itself trough pointer

* Fix Android CI (#891)

* pro gamer move

* remove pregenerated android files

* version

* install old ass android platform

* Revert "remove pregenerated android files"

This reverts commit c81a94c6fd337e187af61e9dd706fac5cd51bcc0.

* switch to 24

* CharButton - Fix enterEvent override in Qt5

Also mark them as override. Also make the preprocessor if a bit less copypastey.

* version bump

* Update embeeded lobby ui color sheme

Shoutout to Dumb Fuck (That is their real discord name).

Co-Authored-By: Crystalwarrior <3470436+Crystalwarrior@users.noreply.github.com>

* Add changelog.md loading logic from main mount path

* Expand tabbar of optional Tabbar widget

* Fix order column being incorrectly sized

* missed a space

* remove fonts

* change margins

* fix minimum sizes

* Allow theme overwrite of settings menu

* Cleanup iterator for subthemes

* Allow reload of settings menu

Might aswell do them all 🤷

* AO base path (#893)

* make get_base_path global

and move parts that use base to use it

* options uses base

* sal moved a bunch of code

* fix creating case folder

---------

Co-authored-by: stonedDiscord <10584181+stonedDiscord@users.noreply.github.com>

* Android 2 10 1 (#894)

* ask for file permissions before trying to load a file

* create armv7 gitignore

* extract all the abis

* don't fail if the dir exists

* Clear options map before reloading the UI

* Fix runtime warning for theme/subtheme combobox

Shouldn't do the job of something that the template can do for me.
Also fix formatting cause it was busted.
Also made the subtheme/theme load code not give me cancer.

* Sort dropdown numerically to match explorer preview

closes #793

* fuck bass

* copy mingw

* copy other dll

* wrong folder

* Account for server subtheme

* Replace incorrect subtheme check

* Settings, not server

* Remove debug

* Add compatibility code, suppress compiler warning (#896)

lobby.cpp:
* Added compatibility code so 2.10.1 can run on Qt versions older than 5.14, such as the version that ships with Ubuntu 20.04

courtroom.cpp:
* Used a Q_UNUSED macro on an unused variable to suppress a compiler warning

* Resolve Qt6(.5.0) compiler errors

* Undo incompetence.

* Force theme reload on theme change

If a user saves a new theme and does not reload the UI it will cause misplacement of widgets inside of courtroom.
This is mitigated by forcing a reload.

* make speedlines stretch by default (in *actually* non-stupid way this time) (#901)

* Rework default volume settings (#903)

* rework volume default settings

* remove default volume settings in options dialog
* make client remember last volume settings instead

* fix options starting tab

* Reworked direct connect (#906)

Resolve issue #905
Works as advertised.

* Set join text when double-click on connected server

Good enough. I would handle this a bit smarter and lock based on the connection state of NetworkManager, but NetworkManager sucks and I refuse to fix it this close before 2.10.1 is done.

* remove unused m_looping

* remove useless underflow check

* do not fall from server to favorites

* Ci android fix (#899)

* pro gamer move

* remove pregenerated android files

* version

* install old ass android platform

* Revert "remove pregenerated android files"

This reverts commit c81a94c6fd337e187af61e9dd706fac5cd51bcc0.

* switch to 24

* use android\src\android\templates instead

* deprecate "chat" deskmod (#910)

* ignore deskmod when zoom speaking

* clean up deskmod a bit

* adds an enum for deskmods
* deprecates the "chat" deskmood
* modifies set_scene since it never rly used the deskmod argument
  meaningfully

* actually use the enums i made lol

* fix typo

* Add credits for lamdacalculus

---------

Co-authored-by: TrickyLeifa <date.epoch@gmail.com>
Co-authored-by: stonedDiscord <Tukz@gmx.de>
Co-authored-by: oldmud0 <oldmud0@users.noreply.github.com>
Co-authored-by: Crystalwarrior <Varsash@Gmail.com>
Co-authored-by: Crystalwarrior <3470436+Crystalwarrior@users.noreply.github.com>
Co-authored-by: stonedDiscord <10584181+stonedDiscord@users.noreply.github.com>
Co-authored-by: segfault <128277930+memsecviolator@users.noreply.github.com>
Co-authored-by: lambdcalculus <64238778+lambdcalculus@users.noreply.github.com>
Co-authored-by: Leifa♥ <26681464+TrickyLeifa@users.noreply.github.com>
This commit is contained in:
Salanto 2023-05-31 20:17:30 +02:00 committed by GitHub
parent 2915f4cc04
commit 7c1fe80d4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
59 changed files with 6207 additions and 5114 deletions

View File

@ -1,3 +1,5 @@
BasedOnStyle: LLVM BasedOnStyle: LLVM
BreakBeforeBraces: Stroustrup BreakBeforeBraces: Stroustrup
AllowShortIfStatementsOnASingleLine: true AllowShortIfStatementsOnASingleLine: true
NamespaceIndentation: All

View File

@ -23,7 +23,7 @@ jobs:
- platform: gcc_64 - platform: gcc_64
os: ubuntu-latest os: ubuntu-latest
- platform: android - platform: android
os: ubuntu-latest os: ubuntu-20.04
- platform: msvc2019 - platform: msvc2019
os: windows-2019 os: windows-2019
- platform: mingw81_32 - platform: mingw81_32
@ -59,6 +59,7 @@ jobs:
ANDROID_NDK_ROOT=${ANDROID_SDK_ROOT}/ndk-bundle ANDROID_NDK_ROOT=${ANDROID_SDK_ROOT}/ndk-bundle
SDKMANAGER=${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager SDKMANAGER=${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager
echo "y" | $SDKMANAGER "ndk;21.4.7075529" echo "y" | $SDKMANAGER "ndk;21.4.7075529"
echo "y" | $SDKMANAGER "platforms;android-24"
ln -sfn $ANDROID_SDK_ROOT/ndk/21.4.7075529 $ANDROID_NDK_ROOT ln -sfn $ANDROID_SDK_ROOT/ndk/21.4.7075529 $ANDROID_NDK_ROOT
- uses: Skycoder42/action-setup-qt@master - uses: Skycoder42/action-setup-qt@master
@ -164,21 +165,23 @@ jobs:
- name: Install Android BASS - name: Install Android BASS
if: matrix.platform == 'android' if: matrix.platform == 'android'
run: | run: |
mkdir ./android/libs/ mkdir -p ./android/libs/armeabi-v7a/
mkdir ./android/libs/armeabi-v7a/
curl http://www.un4seen.com/files/bass24-android.zip -o bass.zip curl http://www.un4seen.com/files/bass24-android.zip -o bass.zip
unzip -d bass -o bass.zip unzip -o bass.zip -d bass
cp ./bass/libs/armeabi-v7a/libbass.so ./lib/ cp ./bass/libs/armeabi-v7a/libbass.so ./lib/
unzip -o bass.zip "libs/*" -d "./android/libs/"
cp ./bass/libs/armeabi-v7a/libbass.so ./android/libs/armeabi-v7a/ cp ./bass/libs/armeabi-v7a/libbass.so ./android/libs/armeabi-v7a/
curl http://www.un4seen.com/files/bassmidi24-android.zip -o bassmidi.zip curl http://www.un4seen.com/files/bassmidi24-android.zip -o bassmidi.zip
unzip -d bass -o bassmidi.zip unzip -d bass -o bassmidi.zip
cp ./bass/libs/armeabi-v7a/libbassmidi.so ./lib/ cp ./bass/libs/armeabi-v7a/libbassmidi.so ./lib/
unzip -o bassmidi.zip "libs/*" -d "./android/libs/"
cp ./bass/libs/armeabi-v7a/libbassmidi.so ./android/libs/armeabi-v7a/ cp ./bass/libs/armeabi-v7a/libbassmidi.so ./android/libs/armeabi-v7a/
curl http://www.un4seen.com/files/bassopus24-android.zip -o bassopus.zip curl http://www.un4seen.com/files/bassopus24-android.zip -o bassopus.zip
unzip -d bass -o bassopus.zip unzip -d bass -o bassopus.zip
cp ./bass/libs/armeabi-v7a/libbassopus.so ./lib/ cp ./bass/libs/armeabi-v7a/libbassopus.so ./lib/
unzip -o bassopus.zip "libs/*" -d "./android/libs/"
cp ./bass/libs/armeabi-v7a/libbassopus.so ./android/libs/armeabi-v7a/ cp ./bass/libs/armeabi-v7a/libbassopus.so ./android/libs/armeabi-v7a/
- name: qmake - name: qmake
@ -214,13 +217,22 @@ jobs:
rm -r bearer rm -r bearer
rm -r styles rm -r styles
- name: Copy MingW DLL
if: matrix.platform == 'mingw81_32'
working-directory: ${{github.workspace}}/bin/
shell: bash
run: |
cp D:/a/AO2-Client/AO2-Client/.cache/qt/Tools/mingw810_32/bin/libgcc_s_dw2-1.dll .
cp D:/a/AO2-Client/AO2-Client/.cache/qt/Tools/mingw810_32/bin/libstdc++-6.dll .
cp D:/a/AO2-Client/AO2-Client/.cache/qt/Tools/mingw810_32/bin/libwinpthread-1.dll .
- name: Deploy Linux - name: Deploy Linux
if: matrix.platform == 'gcc_64' if: matrix.platform == 'gcc_64'
working-directory: ${{github.workspace}}/bin/ working-directory: ${{github.workspace}}/bin/
shell: bash shell: bash
run: | run: |
cp ../scripts/launch.sh . cp ../scripts/launch.sh .
mkdir imageformats mkdir -p imageformats
cp ../QtApng/plugins/imageformats/libqapng.so ./imageformats/libqapng.so cp ../QtApng/plugins/imageformats/libqapng.so ./imageformats/libqapng.so
chmod +x launch.sh chmod +x launch.sh
chmod +x Attorney_Online chmod +x Attorney_Online
@ -251,11 +263,10 @@ jobs:
working-directory: ${{github.workspace}}/ working-directory: ${{github.workspace}}/
shell: bash shell: bash
run: | run: |
mkdir ./build/libs/ mkdir -p ./build/libs/armeabi-v7a/
mkdir ./build/libs/armeabi-v7a/
mv ./bin/*.so ./build/libs/armeabi-v7a/ mv ./bin/*.so ./build/libs/armeabi-v7a/
cp ./QtApng/plugins/imageformats/libplugins_imageformats_qapng_armeabi-v7a.so ./build/libs/armeabi-v7a/ cp ./QtApng/plugins/imageformats/libplugins_imageformats_qapng_armeabi-v7a.so ./build/libs/armeabi-v7a/
androiddeployqt --input android-Attorney_Online-deployment-settings.json --output ./build/ --apk ./bin/AttorneyOnline.apk androiddeployqt --android-platform android-24 --input android-Attorney_Online-deployment-settings.json --output ./build/ --apk ./bin/AttorneyOnline.apk
- name: Upload Artifact - name: Upload Artifact
uses: actions/upload-artifact@master uses: actions/upload-artifact@master

View File

@ -1,17 +1,19 @@
QT += core gui widgets network websockets QT += core gui widgets network websockets uitools
TARGET = Attorney_Online TARGET = Attorney_Online
TEMPLATE = app TEMPLATE = app
VERSION = 2.10.0.0 VERSION = 2.10.1.0
INCLUDEPATH += $$PWD/include INCLUDEPATH += $$PWD/include
DESTDIR = $$PWD/bin DESTDIR = $$PWD/bin
OBJECTS_DIR = $$PWD/build OBJECTS_DIR = $$PWD/build
MOC_DIR = $$PWD/build MOC_DIR = $$PWD/build
SOURCES += $$files($$PWD/src/*.cpp) SOURCES += $$files($$PWD/src/*.cpp, true)
HEADERS += $$files($$PWD/include/*.h) HEADERS += $$files($$PWD/include/*.h, true)
FORMS += $$files($$PWD/resource/ui/*.ui)
LIBS += -L$$PWD/lib LIBS += -L$$PWD/lib
QMAKE_LFLAGS += -Wl,-rpath,"'\$$ORIGIN/lib'" QMAKE_LFLAGS += -Wl,-rpath,"'\$$ORIGIN/lib'"
@ -57,7 +59,8 @@ TRANSLATIONS = resource/translations/ao_en.ts \
resource/translations/ao_es.ts \ resource/translations/ao_es.ts \
resource/translations/ao_pt.ts \ resource/translations/ao_pt.ts \
resource/translations/ao_pl.ts \ resource/translations/ao_pl.ts \
resource/translations/ao_it.ts resource/translations/ao_it.ts \
ressource/ui/
win32:RC_ICONS = resource/logo_ao2.ico win32:RC_ICONS = resource/logo_ao2.ico
macx:ICON = resource/logo_ao2.icns macx:ICON = resource/logo_ao2.icns

View File

@ -1,77 +0,0 @@
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.0'
}
}
repositories {
google()
jcenter()
}
apply plugin: 'com.android.application'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
}
android {
/*******************************************************
* The following variables:
* - androidBuildToolsVersion,
* - androidCompileSdkVersion
* - qt5AndroidDir - holds the path to qt android files
* needed to build any Qt application
* on Android.
*
* are defined in gradle.properties file. This file is
* updated by QtCreator and androiddeployqt tools.
* Changing them manually might break the compilation!
*******************************************************/
compileSdkVersion androidCompileSdkVersion.toInteger()
buildToolsVersion '28.0.3'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java']
aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl']
res.srcDirs = [qt5AndroidDir + '/res', 'res']
resources.srcDirs = ['resources']
renderscript.srcDirs = ['src']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
}
tasks.withType(JavaCompile) {
options.incremental = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
lintOptions {
abortOnError false
}
// Do not compress Qt binary resources file
aaptOptions {
noCompress 'rcc'
}
defaultConfig {
resConfig "en"
minSdkVersion = qtMinSdkVersion
targetSdkVersion = qtTargetSdkVersion
}
}

3
android/libs/armeabi-v7a/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
libbass.so
libbassmidi.so
libbassopus.so

View File

@ -1 +1 @@
target=android-21 target=android-24

View File

@ -1,14 +1,13 @@
#ifndef AOAPPLICATION_H #ifndef AOAPPLICATION_H
#define AOAPPLICATION_H #define AOAPPLICATION_H
#include "widgets/aooptionsdialog.h"
#include "aopacket.h" #include "aopacket.h"
#include "datatypes.h" #include "datatypes.h"
#include "demoserver.h" #include "demoserver.h"
#include "discord_rich_presence.h" #include "discord_rich_presence.h"
#include "bass.h" #include "bass.h"
#include "bassmidi.h"
#include "bassopus.h"
#include <QApplication> #include <QApplication>
#include <QFile> #include <QFile>
@ -34,6 +33,7 @@
class NetworkManager; class NetworkManager;
class Lobby; class Lobby;
class Courtroom; class Courtroom;
class Options;
class VPath : QString { class VPath : QString {
using QString::QString; using QString::QString;
@ -130,10 +130,6 @@ public:
/////////////////////////////////////////// ///////////////////////////////////////////
void load_favorite_list();
void save_favorite_list();
QVector<server_type> &get_favorite_list() { return favorite_list; }
// Adds the server to favorite_servers.ini // Adds the server to favorite_servers.ini
void add_favorite_server(int p_server); void add_favorite_server(int p_server);
void remove_favorite_server(int p_server); void remove_favorite_server(int p_server);
@ -141,14 +137,10 @@ public:
void set_server_list(QVector<server_type> &servers) { server_list = servers; } void set_server_list(QVector<server_type> &servers) { server_list = servers; }
QVector<server_type> &get_server_list() { return server_list; } QVector<server_type> &get_server_list() { return server_list; }
// reads the theme from config.ini and sets it accordingly
void reload_theme();
// Returns the character the player has currently selected // Returns the character the player has currently selected
QString get_current_char(); QString get_current_char();
// implementation in path_functions.cpp // implementation in path_functions.cpp
QString get_base_path();
VPath get_theme_path(QString p_file, QString p_theme=""); VPath get_theme_path(QString p_file, QString p_theme="");
VPath get_character_path(QString p_char, QString p_file); VPath get_character_path(QString p_char, QString p_file);
VPath get_misc_path(QString p_misc, QString p_file); VPath get_misc_path(QString p_misc, QString p_file);
@ -173,147 +165,6 @@ public:
////// Functions for reading and writing files ////// ////// Functions for reading and writing files //////
// Implementations file_functions.cpp // Implementations file_functions.cpp
// Instead of reinventing the wheel, we'll use a QSettings class.
QSettings *configini;
// Reads the theme from config.ini and loads it into the current_theme
// variable
QString read_theme();
// Returns the value of ooc_name in config.ini
QString get_ooc_name();
// Returns the blip rate from config.ini (once per X symbols)
int read_blip_rate();
// Returns true if blank blips is enabled in config.ini and false otherwise
bool get_blank_blip();
// Returns true if looping sound effects are enabled in the config.ini
bool get_looping_sfx();
// Returns true if stop music on objection is enabled in the config.ini
bool objection_stop_music();
// Returns true if streaming is enabled in the config.ini
bool is_streaming_disabled();
// Returns the value of default_music in config.ini
int get_default_music();
// Returns the value of default_sfx in config.ini
int get_default_sfx();
// Returns the value of default_blip in config.ini
int get_default_blip();
// Returns the value of suppress_audio in config.ini
int get_default_suppress_audio();
// Returns the value if objections interrupt and skip the message queue
// from the config.ini.
bool is_instant_objection_enabled();
// returns if log will show messages as-received, while viewport will parse according to the queue (Text Stay Time)
// from the config.ini
bool is_desyncrhonized_logs_enabled();
// Returns the value of whether Discord should be enabled on startup
// from the config.ini.
bool is_discord_enabled();
// Returns the value of whether shaking should be enabled.
// from the config.ini.
bool is_shake_enabled();
// Returns the value of whether effects should be enabled.
// from the config.ini.
bool is_effects_enabled();
// Returns the value of whether frame-specific effects defined in char.ini
// should be sent/received over the network. from the config.ini.
bool is_frame_network_enabled();
// Returns the value of whether colored ic log should be a thing.
// from the config.ini.
bool is_colorlog_enabled();
// Returns the value of whether sticky sounds should be a thing.
// from the config.ini.
bool is_stickysounds_enabled();
// Returns the value of whether sticky effects should be a thing.
// from the config.ini.
bool is_stickyeffects_enabled();
// Returns the value of whether sticky preanims should be a thing.
// from the config.ini.
bool is_stickypres_enabled();
// Returns the value of whether custom chatboxes should be a thing.
// from the config.ini.
// I am increasingly maddened by the lack of dynamic auto-generation system
// for settings.
bool is_customchat_enabled();
// Returns the value of characer sticker (avatar) setting
bool is_sticker_enabled();
// Returns the value of whether continuous playback should be used
// from the config.ini.
bool is_continuous_enabled();
// Returns the value of whether stopping music by double clicking category should be used
// from the config.ini.
bool is_category_stop_enabled();
// Returns the value of the maximum amount of lines the IC chatlog
// may contain, from config.ini.
int get_max_log_size();
// Current wait time between messages for the queue system
int stay_time();
// Returns the letter display speed during text crawl in in-character messages
int get_text_crawl();
// Returns Minimum amount of time (in miliseconds) that must pass before the next Enter key press will send your IC message. (new behaviour)
int get_chat_ratelimit();
// Returns whether the log should go upwards (new behaviour)
// or downwards (vanilla behaviour).
bool get_log_goes_downwards();
// Returns whether the log should separate name from text via newline or :
bool get_log_newline();
// Get spacing between IC log entries.
int get_log_margin();
// Returns whether the log should have a timestamp.
bool get_log_timestamp();
// Returns the format string for the log timestamp
QString get_log_timestamp_format();
// Returns whether to log IC actions.
bool get_log_ic_actions();
// Returns the username the user may have set in config.ini.
QString get_default_username();
// Returns the audio device used for the client.
QString get_audio_output_device();
// Returns whether the user would like to have custom shownames on by default.
bool get_showname_enabled_by_default();
//Returns the showname the user may have set in config.ini.
QString get_default_showname();
// Returns the list of words in callwords.ini
QStringList get_call_words();
// returns all of the file's lines in a QStringList // returns all of the file's lines in a QStringList
QStringList get_list_file(VPath path); QStringList get_list_file(VPath path);
QStringList get_list_file(QString p_file); QStringList get_list_file(QString p_file);
@ -333,23 +184,17 @@ public:
void append_to_demofile(QString packet_string); void append_to_demofile(QString packet_string);
/** /**
* @brief Reads favorite_servers.ini and returns a list of servers. * @brief Reads the clients log folder and locates potential demo files to populate the demoserver list.
* *
* The demo server entry is always present at the top of the list. * @return A seperated list of servernames and demo logfile filenames.
* *
* If the server list returned was to be empty (exluding the demo server entry), * @details This is to remove the need of delimiters or deal with potential
* will return a list of servers from the legacy serverlist.txt file. * harmfully encoding or plattform differences. We always get a combo of servername and filename.
*
* Do note this function assumes all demo files have the .demo extension.
* *
* @return A list of servers.
*/ */
QVector<server_type> read_favorite_servers(); QMultiMap<QString, QString> load_demo_logs_list() const;
/**
* @brief Reads serverlist.txt and returns a list of servers.
*
* @return A list of servers.
*/
QVector<server_type> read_legacy_favorite_servers();
// Returns the value of p_identifier in the design.ini file in p_design_path // Returns the value of p_identifier in the design.ini file in p_design_path
QString read_design_ini(QString p_identifier, VPath p_design_path); QString read_design_ini(QString p_identifier, VPath p_design_path);
@ -505,62 +350,11 @@ public:
// These are all casing-related settings. // These are all casing-related settings.
// ====== // ======
// Returns if the user has casing alerts enabled.
bool get_casing_enabled();
// Returns if the user wants to get alerts for the defence role.
bool get_casing_defence_enabled();
// Same for prosecution.
bool get_casing_prosecution_enabled();
// Same for judge.
bool get_casing_judge_enabled();
// Same for juror.
bool get_casing_juror_enabled();
// Same for steno.
bool get_casing_steno_enabled();
// Same for CM.
bool get_casing_cm_enabled();
// Get the message for the CM for casing alerts.
QString get_casing_can_host_cases();
// Get if text file logging is enabled
bool get_text_logging_enabled();
// Get if demo logging is enabled
bool get_demo_logging_enabled();
// Get the subtheme from settings
QString get_subtheme();
// Get if the theme is animated
bool get_animated_theme();
// Get the default scaling method
QString get_default_scaling();
// Get a list of custom mount paths
QStringList get_mount_paths();
// Get whether to opt out of player count metrics sent to the master server
bool get_player_count_optout();
// Get if sfx can be sent to play on idle
bool get_sfx_on_idle();
// Whether opening evidence requires a single or double click
bool get_evidence_double_click();
// Currently defined subtheme // Currently defined subtheme
QString subtheme; QString subtheme;
QString default_theme = "default"; //Default is always default.
QString current_theme = default_theme; const QString default_theme = "default";
// The file name of the log file in base/logs. // The file name of the log file in base/logs.
QString log_filename; QString log_filename;
@ -587,10 +381,9 @@ public:
private: private:
const int RELEASE = 2; const int RELEASE = 2;
const int MAJOR_VERSION = 10; const int MAJOR_VERSION = 10;
const int MINOR_VERSION = 0; const int MINOR_VERSION = 1;
QVector<server_type> server_list; QVector<server_type> server_list;
QVector<server_type> favorite_list;
QHash<uint, QString> asset_lookup_cache; QHash<uint, QString> asset_lookup_cache;
QHash<uint, QString> dir_listing_cache; QHash<uint, QString> dir_listing_cache;
QSet<uint> dir_listing_exist_cache; QSet<uint> dir_listing_exist_cache;

View File

@ -1,46 +0,0 @@
#ifndef AOCASEANNOUNCERDIALOG_H
#define AOCASEANNOUNCERDIALOG_H
#include "aoapplication.h"
#include "courtroom.h"
#include <QDialogButtonBox>
#include <QtWidgets/QCheckBox>
#include <QtWidgets/QDialog>
#include <QtWidgets/QFormLayout>
#include <QtWidgets/QLabel>
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QVBoxLayout>
class AOCaseAnnouncerDialog : public QDialog {
Q_OBJECT
public:
explicit AOCaseAnnouncerDialog(QWidget *parent = nullptr,
AOApplication *p_ao_app = nullptr,
Courtroom *p_court = nullptr);
private:
AOApplication *ao_app;
Courtroom *court;
QDialogButtonBox *ui_announcer_buttons;
QVBoxLayout *ui_vbox_layout;
QFormLayout *ui_form_layout;
QLabel *ui_case_title_label;
QLineEdit *ui_case_title_textbox;
QCheckBox *ui_defense_needed;
QCheckBox *ui_prosecutor_needed;
QCheckBox *ui_judge_needed;
QCheckBox *ui_juror_needed;
QCheckBox *ui_steno_needed;
public slots:
void ok_pressed();
void cancel_pressed();
};
#endif // AOCASEANNOUNCERDIALOG_H

View File

@ -38,8 +38,12 @@ private:
AOImage *ui_selector; AOImage *ui_selector;
protected: protected:
void enterEvent(QEnterEvent *e); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void leaveEvent(QEvent *e); void enterEvent(QEvent *e) override;
#else
void enterEvent(QEnterEvent *e) override;
#endif
void leaveEvent(QEvent *e) override;
}; };
#endif // AOCHARBUTTON_H #endif // AOCHARBUTTON_H

View File

@ -32,9 +32,13 @@ private:
int m_id = 0; int m_id = 0;
protected: protected:
void enterEvent(QEnterEvent *e); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void leaveEvent(QEvent *e); void enterEvent(QEvent *e) override;
void mouseDoubleClickEvent(QMouseEvent *e); #else
void enterEvent(QEnterEvent *e) override;
#endif
void leaveEvent(QEvent *e) override;
void mouseDoubleClickEvent(QMouseEvent *e) override;
/* /*
void dragLeaveEvent(QMouseEvent *e); void dragLeaveEvent(QMouseEvent *e);
void dragEnterEvent(QMouseEvent *e); void dragEnterEvent(QMouseEvent *e);

View File

@ -1,11 +1,5 @@
#ifndef AOMUSICPLAYER_H #ifndef AOMUSICPLAYER_H
#define AOMUSICPLAYER_H #define AOMUSICPLAYER_H
#include "file_functions.h"
#include "bass.h"
#include "bassmidi.h"
#include "bassopus.h"
#include "aoapplication.h" #include "aoapplication.h"
#include <QDebug> #include <QDebug>
@ -24,17 +18,6 @@ public:
const int m_channelmax = 4; const int m_channelmax = 4;
// These have to be public for the stupid sync thing
/**
* @brief The starting sample of the AB-Loop.
*/
unsigned int loop_start[4] = {0, 0, 0, 0};
/**
* @brief The end sample of the AB-Loop.
*/
unsigned int loop_end[4] = {0, 0, 0, 0};
QFutureWatcher<QString> music_watcher; QFutureWatcher<QString> music_watcher;
public slots: public slots:
@ -46,7 +29,6 @@ private:
QWidget *m_parent; QWidget *m_parent;
AOApplication *ao_app; AOApplication *ao_app;
bool m_looping = false;
bool m_muted = false; bool m_muted = false;
int m_volume[4] = {0, 0, 0, 0}; int m_volume[4] = {0, 0, 0, 0};
@ -56,6 +38,16 @@ private:
// Channel 3 = extra // Channel 3 = extra
HSTREAM m_stream_list[4]; HSTREAM m_stream_list[4];
HSYNC loop_sync[4]; HSYNC loop_sync[4];
/**
* @brief The starting sample of the AB-Loop.
*/
unsigned int loop_start[4] = {0, 0, 0, 0};
/**
* @brief The end sample of the AB-Loop.
*/
unsigned int loop_end[4] = {0, 0, 0, 0};
}; };
#endif // AOMUSICPLAYER_H #endif // AOMUSICPLAYER_H

View File

@ -1,273 +0,0 @@
#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/QPushButton>
#include <QtWidgets/QScrollArea>
#include <QtWidgets/QSpinBox>
#include <QtWidgets/QTabWidget>
#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QWidget>
#include <QDirIterator>
#include <QListWidget>
#include <QTextBrowser>
#include <QTextStream>
class Lobby;
class Courtroom;
class AOOptionsDialog : public QDialog {
Q_OBJECT
public:
explicit AOOptionsDialog(QWidget *parent = nullptr,
AOApplication *p_ao_app = nullptr);
private:
AOApplication *ao_app;
QVBoxLayout *ui_vertical_layout;
QTabWidget *ui_settings_tabs;
QWidget *ui_gameplay_tab;
QWidget *ui_form_layout_widget;
QFormLayout *ui_gameplay_form;
QLabel *ui_theme_label;
QComboBox *ui_theme_combobox;
QLabel *ui_subtheme_label;
QComboBox *ui_subtheme_combobox;
QPushButton *ui_theme_reload_button;
QPushButton *ui_theme_folder_button;
QLabel *ui_evidence_double_click_lbl;
QCheckBox *ui_evidence_double_click_cb;
QLabel *ui_animated_theme_lbl;
QCheckBox *ui_animated_theme_cb;
QFrame *ui_theme_log_divider;
QLabel *ui_stay_time_lbl;
QSpinBox *ui_stay_time_spinbox;
QLabel *ui_instant_objection_lbl;
QCheckBox *ui_instant_objection_cb;
QLabel *ui_text_crawl_lbl;
QSpinBox *ui_text_crawl_spinbox;
QLabel *ui_chat_ratelimit_lbl;
QSpinBox *ui_chat_ratelimit_spinbox;
QFrame *ui_log_names_divider;
QLineEdit *ui_username_textbox;
QLabel *ui_username_lbl;
QLabel *ui_showname_lbl;
QCheckBox *ui_showname_cb;
QLabel *ui_default_showname_lbl;
QLineEdit *ui_default_showname_textbox;
QFrame *ui_net_divider;
QLabel *ui_ms_lbl;
QLineEdit *ui_ms_textbox;
QLabel *ui_discord_lbl;
QCheckBox *ui_discord_cb;
QLabel *ui_language_label;
QComboBox *ui_language_combobox;
QLabel *ui_scaling_label;
QComboBox *ui_scaling_combobox;
QLabel *ui_shake_lbl;
QCheckBox *ui_shake_cb;
QLabel *ui_effects_lbl;
QCheckBox *ui_effects_cb;
QLabel *ui_framenetwork_lbl;
QCheckBox *ui_framenetwork_cb;
QLabel *ui_colorlog_lbl;
QCheckBox *ui_colorlog_cb;
QLabel *ui_stickysounds_lbl;
QCheckBox *ui_stickysounds_cb;
QLabel *ui_stickyeffects_lbl;
QCheckBox *ui_stickyeffects_cb;
QLabel *ui_stickypres_lbl;
QCheckBox *ui_stickypres_cb;
QLabel *ui_customchat_lbl;
QCheckBox *ui_customchat_cb;
QLabel *ui_sticker_lbl;
QCheckBox *ui_sticker_cb;
QLabel *ui_continuous_lbl;
QCheckBox *ui_continuous_cb;
QLabel *ui_category_stop_lbl;
QCheckBox *ui_category_stop_cb;
QLabel *ui_sfx_on_idle_lbl;
QCheckBox *ui_sfx_on_idle_cb;
QWidget *ui_callwords_tab;
QWidget *ui_callwords_widget;
QVBoxLayout *ui_callwords_layout;
QPlainTextEdit *ui_callwords_textbox;
QLabel *ui_callwords_explain_lbl;
QCheckBox *ui_callwords_char_textbox;
QWidget *ui_audio_tab;
QWidget *ui_audio_widget;
QFormLayout *ui_audio_layout;
QLabel *ui_audio_device_lbl;
QComboBox *ui_audio_device_combobox;
QFrame *ui_audio_volume_divider;
QSpinBox *ui_music_volume_spinbox;
QLabel *ui_music_volume_lbl;
QSpinBox *ui_sfx_volume_spinbox;
QSpinBox *ui_blips_volume_spinbox;
QSpinBox *ui_suppress_audio_spinbox;
QLabel *ui_sfx_volume_lbl;
QLabel *ui_blips_volume_lbl;
QLabel *ui_suppress_audio_lbl;
QFrame *ui_volume_blip_divider;
QSpinBox *ui_bliprate_spinbox;
QLabel *ui_bliprate_lbl;
QCheckBox *ui_blank_blips_cb;
QLabel *ui_blank_blips_lbl;
QLabel *ui_loopsfx_lbl;
QCheckBox *ui_loopsfx_cb;
QLabel *ui_objectmusic_lbl;
QCheckBox *ui_objectmusic_cb;
QLabel *ui_disablestreams_lbl;
QCheckBox *ui_disablestreams_cb;
QDialogButtonBox *ui_settings_buttons;
QWidget *ui_casing_tab;
QWidget *ui_casing_widget;
QFormLayout *ui_casing_layout;
QLabel *ui_casing_supported_lbl;
QLabel *ui_casing_enabled_lbl;
QCheckBox *ui_casing_enabled_cb;
QLabel *ui_casing_def_lbl;
QCheckBox *ui_casing_def_cb;
QLabel *ui_casing_pro_lbl;
QCheckBox *ui_casing_pro_cb;
QLabel *ui_casing_jud_lbl;
QCheckBox *ui_casing_jud_cb;
QLabel *ui_casing_jur_lbl;
QCheckBox *ui_casing_jur_cb;
QLabel *ui_casing_steno_lbl;
QCheckBox *ui_casing_steno_cb;
QLabel *ui_casing_cm_lbl;
QCheckBox *ui_casing_cm_cb;
QLabel *ui_casing_cm_cases_lbl;
QLineEdit *ui_casing_cm_cases_textbox;
QWidget *ui_assets_tab;
QVBoxLayout *ui_assets_tab_layout;
QGridLayout *ui_mount_buttons_layout;
QLabel *ui_asset_lbl;
QListWidget *ui_mount_list;
QPushButton *ui_mount_add;
QPushButton *ui_mount_remove;
QPushButton *ui_mount_up;
QPushButton *ui_mount_down;
QPushButton *ui_mount_clear_cache;
QWidget *ui_logging_tab;
QWidget *ui_form_logging_widget;
QFormLayout *ui_logging_form;
/**
* Option for log direction. Supported options are downwards and wrong way.
*/
QLabel *ui_downwards_lbl;
QCheckBox *ui_downwards_cb;
/**
* Option for log length. Controls how many IC-log entries are kept before it autowraps.
*/
QLabel *ui_length_lbl;
QSpinBox *ui_length_spinbox;
/**
* Option for log newline. Controls if the IC-log contains newlines or as one consecutive string.
*/
QLabel *ui_log_newline_lbl;
QCheckBox *ui_log_newline_cb;
/**
* Option for log margin. Controls how many pixels are between each log entry.
*/
QLabel *ui_log_margin_lbl;
QSpinBox *ui_log_margin_spinbox;
/**
* Option for timestamp format. A checkmark to enable the timestamp dropdown.
* Why does this exist? Are we Dorico now?
*/
QLabel *ui_log_timestamp_lbl;
QCheckBox *ui_log_timestamp_cb;
/**
* Option for timestamp format. Dropdown to select the preferred format.
*/
QLabel *ui_log_timestamp_format_lbl;
QComboBox *ui_log_timestamp_format_combobox;
/**
* Option for desynched IC-log and viewport. Controls if entires are appended to the IC-log before displayed in the viewport.
*/
QLabel *ui_desync_logs_lbl;
QCheckBox *ui_desync_logs_cb;
/**
* Option for logging IC-actions. Will add shouts, evidence or music changes to the IC-log.
*/
QLabel *ui_log_ic_actions_lbl;
QCheckBox *ui_log_ic_actions_cb;
/**
* Option to enable logging. If enabled client will save all messages to the log folder.
*/
QLabel *ui_log_text_lbl;
QCheckBox *ui_log_text_cb;
/**
* Option to enable demo logging. If enabled, client will save a demo file for replay trough the demo server.
*/
QLabel *ui_log_demo_lbl;
QCheckBox *ui_log_demo_cb;
QWidget *ui_privacy_tab;
QVBoxLayout *ui_privacy_layout;
QCheckBox *ui_privacy_optout_cb;
QFrame *ui_privacy_separator;
QTextBrowser *ui_privacy_policy;
bool asset_cache_dirty = false;
bool needs_default_audiodev();
void update_values();
signals:
public slots:
void save_pressed();
void discard_pressed();
void button_clicked(QAbstractButton *button);
void on_timestamp_format_edited();
void timestamp_cb_changed(int state);
void on_reload_theme_clicked();
void theme_changed(int i);
};
#endif // AOOPTIONSDIALOG_H

View File

@ -12,7 +12,7 @@
#include "aoimage.h" #include "aoimage.h"
#include "aolayer.h" #include "aolayer.h"
#include "aomusicplayer.h" #include "aomusicplayer.h"
#include "aooptionsdialog.h" #include "widgets/aooptionsdialog.h"
#include "aopacket.h" #include "aopacket.h"
#include "aosfxplayer.h" #include "aosfxplayer.h"
#include "aotextarea.h" #include "aotextarea.h"
@ -191,7 +191,7 @@ public:
void set_pair_list(); void set_pair_list();
// sets desk and bg based on pos in chatmessage // sets desk and bg based on pos in chatmessage
void set_scene(QString f_desk_mod, QString f_side); void set_scene(bool show_desk, QString f_side);
// sets ui_vp_player_char according to SELF_OFFSET, only a function bc it's used with desk_mod 4 and 5 // sets ui_vp_player_char according to SELF_OFFSET, only a function bc it's used with desk_mod 4 and 5
void set_self_offset(const QString& p_list); void set_self_offset(const QString& p_list);
@ -318,9 +318,6 @@ public:
// Toggles the judge buttons, whether they should appear or not. // Toggles the judge buttons, whether they should appear or not.
void show_judge_controls(bool visible); void show_judge_controls(bool visible);
void announce_case(QString title, bool def, bool pro, bool jud, bool jur,
bool steno);
void check_connection_received(); void check_connection_received();
void start_clock(int id); void start_clock(int id);
@ -741,14 +738,12 @@ private:
AOButton *ui_reload_theme; AOButton *ui_reload_theme;
AOButton *ui_call_mod; AOButton *ui_call_mod;
AOButton *ui_settings; AOButton *ui_settings;
AOButton *ui_announce_casing;
AOButton *ui_switch_area_music; AOButton *ui_switch_area_music;
QCheckBox *ui_pre; QCheckBox *ui_pre;
QCheckBox *ui_flip; QCheckBox *ui_flip;
QCheckBox *ui_additive; QCheckBox *ui_additive;
QCheckBox *ui_guard; QCheckBox *ui_guard;
QCheckBox *ui_casing;
QCheckBox *ui_immediate; QCheckBox *ui_immediate;
QCheckBox *ui_showname_enable; QCheckBox *ui_showname_enable;
@ -852,8 +847,6 @@ public slots:
void mod_called(QString p_ip); void mod_called(QString p_ip);
void case_called(QString msg, bool def, bool pro, bool jud, bool jur,
bool steno);
void on_reload_theme_clicked(); void on_reload_theme_clicked();
void update_ui_music_name(); void update_ui_music_name();
@ -975,7 +968,6 @@ private slots:
void on_change_character_clicked(); void on_change_character_clicked();
void on_call_mod_clicked(); void on_call_mod_clicked();
void on_settings_clicked(); void on_settings_clicked();
void on_announce_casing_clicked();
void on_pre_clicked(); void on_pre_clicked();
void on_flip_clicked(); void on_flip_clicked();
@ -1016,8 +1008,6 @@ private slots:
void on_switch_area_music_clicked(); void on_switch_area_music_clicked();
void on_casing_clicked();
void on_application_state_changed(Qt::ApplicationState state); void on_application_state_changed(Qt::ApplicationState state);
void ping_server(); void ping_server();

View File

@ -120,6 +120,17 @@ enum EMOTE_MOD_TYPE {
PREANIM_ZOOM = 6, PREANIM_ZOOM = 6,
}; };
enum DESK_MOD_TYPE {
DESK_HIDE = 0,
DESK_SHOW,
DESK_EMOTE_ONLY,
DESK_PRE_ONLY,
DESK_EMOTE_ONLY_EX,
DESK_PRE_ONLY_EX,
//"EX" for "expanded"
//dumb, i know, but throw the first stone if you have a better idea
};
enum MUSIC_EFFECT { FADE_IN = 1, FADE_OUT = 2, SYNC_POS = 4 }; enum MUSIC_EFFECT { FADE_IN = 1, FADE_OUT = 2, SYNC_POS = 4 };
#endif // DATATYPES_H #endif // DATATYPES_H

View File

@ -22,6 +22,8 @@ public:
int port = 27088; int port = 27088;
int max_wait = -1; int max_wait = -1;
void set_demo_file(QString filepath);
private: private:
void handle_packet(AOPacket *packet); void handle_packet(AOPacket *packet);
void load_demo(QString filename); void load_demo(QString filename);
@ -39,6 +41,7 @@ private:
QString p_path; QString p_path;
QTimer *timer; QTimer *timer;
int elapsed_time = 0; int elapsed_time = 0;
QString filename;
private slots: private slots:
void accept_connection(); void accept_connection();

View File

@ -4,9 +4,11 @@
#include <QDir> #include <QDir>
#include <QFileInfo> #include <QFileInfo>
#include <QString> #include <QString>
#include <QCoreApplication>
bool file_exists(QString file_path); bool file_exists(QString file_path);
bool dir_exists(QString file_path); bool dir_exists(QString file_path);
bool exists(QString p_path); bool exists(QString p_path);
QString get_base_path();
#endif // FILE_FUNCTIONS_H #endif // FILE_FUNCTIONS_H

View File

@ -0,0 +1,21 @@
#include <QDialog>
#pragma once
#ifndef AO_UI_FAVORITESERVERDIALOG
#define AO_UI_FAVORITESRRVERDIALOG
namespace AttorneyOnline {
namespace UI {
class FavoriteServerDialog : public QDialog {
public:
FavoriteServerDialog() = default;
~FavoriteServerDialog() = default;
const QString DEFAULT_UI = "favorite_server_dialog.ui";
const int TCP_INDEX = 0;
private slots:
virtual void onSavePressed() = 0;
virtual void onCancelPressed() = 0;
};
} // namespace UI
} // namespace AttorneyOnline
#endif // AO_UI_FAVORITESERVERDIALOG

View File

@ -1,22 +1,17 @@
#ifndef LOBBY_H #ifndef LOBBY_H
#define LOBBY_H #define LOBBY_H
#include "aobutton.h" class QLabel;
#include "aoimage.h" class QLineEdit;
#include "aopacket.h" class QPushButton;
#include "aotextarea.h" class QTextBrowser;
class QTreeWidget;
class QTreeWidgetItem;
#include <QLabel>
#include <QLineEdit>
#include <QListWidget>
#include <QMainWindow> #include <QMainWindow>
#include <QPlainTextEdit> #include "networkmanager.h"
#include <QProgressBar> #include "file_functions.h"
#include <QTextBrowser>
#include <QTreeWidget>
#include <QDebug>
#include <QScrollBar>
#include <QHeaderView>
#ifdef ANDROID #ifdef ANDROID
#include <QtAndroidExtras/QtAndroid> #include <QtAndroidExtras/QtAndroid>
#endif #endif
@ -25,91 +20,88 @@ class AOApplication;
class Lobby : public QMainWindow { class Lobby : public QMainWindow {
Q_OBJECT Q_OBJECT
public: public:
Lobby(AOApplication *p_ao_app); Lobby(AOApplication *p_ao_app, NetworkManager *p_net_man = nullptr);
void set_widgets();
void list_servers();
void list_favorites();
void get_motd();
void check_for_updates();
void append_chatmessage(QString f_name, QString f_message);
void append_error(QString f_message);
void set_player_count(int players_online, int max_players);
void set_server_description(const QString& server_description);
void set_stylesheet(QWidget *widget);
void set_stylesheets();
void set_fonts();
void set_font(QWidget *widget, QString p_identifier);
void set_loading_text(QString p_text);
void show_loading_overlay() { ui_loading_background->show(); }
void hide_loading_overlay() { ui_loading_background->hide(); }
QString get_chatlog();
int get_selected_server();
void enable_connect_button();
void reset_selection();
void set_loading_value(int p_value);
bool public_servers_selected = true;
bool doubleclicked = false;
~Lobby(); ~Lobby();
void set_player_count(int players_online, int max_players);
void set_server_description(const QString &server_description);
void list_servers();
int get_selected_server();
int pageSelected();
private: private:
AOApplication *ao_app; AOApplication *ao_app;
NetworkManager *net_manager;
AOImage *ui_background; const QString DEFAULT_UI = "lobby.ui";
AOButton *ui_public_servers; void list_favorites();
AOButton *ui_favorites; void list_demos();
void get_motd();
AOButton *ui_refresh; void check_for_updates();
AOButton *ui_add_to_fav; void reset_selection();
AOButton *ui_remove_from_fav;
AOButton *ui_connect;
QLabel *ui_version;
AOButton *ui_about;
AOButton *ui_settings;
QTreeWidget *ui_server_list;
QLineEdit *ui_server_search;
QLabel *ui_player_count;
AOTextArea *ui_description;
AOTextArea *ui_chatbox;
AOImage *ui_loading_background;
QTextEdit *ui_loading_text;
QProgressBar *ui_progress_bar;
AOButton *ui_cancel;
int last_index = -1; int last_index = -1;
void set_size_and_pos(QWidget *p_widget, QString p_identifier); enum TabPage { SERVER, FAVORITES, DEMOS };
// UI-file Lobby
// Top Row
QLabel *ui_game_version_lbl;
QPushButton *ui_settings_button;
QPushButton *ui_about_button;
// Server, Favs and Demo lists
QTabWidget *ui_connections_tabview;
QTreeWidget *ui_serverlist_tree;
QLineEdit *ui_serverlist_search;
QTreeWidget *ui_favorites_tree;
QLineEdit *ui_favorites_search;
QTreeWidget *ui_demo_tree;
QLineEdit *ui_demo_search;
QPushButton *ui_add_to_favorite_button;
QPushButton *ui_add_server_button;
QPushButton *ui_remove_from_favorites_button;
QPushButton *ui_edit_favorite_button;
QPushButton *ui_direct_connect_button;
QPushButton *ui_refresh_button;
// Serverinfo / MOTD Horizontal Row
QTextBrowser *ui_motd_text;
QLabel *ui_server_player_count_lbl;
QTextBrowser *ui_server_description_text;
QPushButton *ui_connect_button;
// Optional Widget
QTextBrowser *ui_game_changelog_text;
void loadUI();
TabPage current_page = SERVER;
private slots: private slots:
void on_public_servers_clicked(); void on_tab_changed(int index);
void on_favorites_clicked();
void on_refresh_pressed();
void on_refresh_released(); void on_refresh_released();
void on_add_to_fav_pressed(); void on_direct_connect_released();
void on_add_to_fav_released(); void on_add_to_fav_released();
void on_remove_from_fav_pressed(); void on_add_server_to_fave_released();
void on_edit_favorite_released();
void on_remove_from_fav_released(); void on_remove_from_fav_released();
void on_connect_pressed();
void on_connect_released();
void on_about_clicked(); void on_about_clicked();
void on_settings_clicked();
void on_server_list_clicked(QTreeWidgetItem *p_item, int column); void on_server_list_clicked(QTreeWidgetItem *p_item, int column);
void on_server_list_doubleclicked(QTreeWidgetItem *p_item, int column); void on_list_doubleclicked(QTreeWidgetItem *p_item, int column);
void on_server_list_context_menu_requested(const QPoint &point); void on_favorite_tree_clicked(QTreeWidgetItem *p_item, int column);
void on_server_search_edited(QString p_text); void on_server_search_edited(QString p_text);
void on_demo_clicked(QTreeWidgetItem *item, int column);
void onReloadThemeRequested(); // Oh boy.
void onSettingsRequested();
}; };
#endif // LOBBY_H #endif // LOBBY_H

View File

@ -51,9 +51,13 @@ public:
void connect_to_server(server_type p_server); void connect_to_server(server_type p_server);
void disconnect_from_server(); void disconnect_from_server();
signals:
void server_connected(bool state);
public slots: public slots:
void get_server_list(const std::function<void()> &cb); void get_server_list(const std::function<void()> &cb);
void ship_server_packet(QString p_packet); void ship_server_packet(QString p_packet);
void join_to_server();
void handle_server_packet(const QString& p_data); void handle_server_packet(const QString& p_data);
void request_document(MSDocumentType document_type, void request_document(MSDocumentType document_type,

290
include/options.h Normal file
View File

@ -0,0 +1,290 @@
#ifndef OPTIONS_H
#define OPTIONS_H
#include <QCoreApplication>
#include <QSettings>
#include <datatypes.h>
class Options {
private:
/**
* @brief QSettings object for config.ini
*/
QSettings config;
/**
* @brief QSettings object for favorite_servers.ini
*/
QSettings favorite;
void migrateCallwords();
/**
* @brief Constructor for options class.
*/
Options();
QString m_server_subtheme;
public:
Options(Options const &) = delete;
void operator=(Options const &) = delete;
static Options &getInstance()
{
static Options instance;
return instance;
}
/**
* @brief Migrates old configuration files to the most recent format.
*/
void migrate();
// Reads the theme from config.ini and loads it into the currenttheme
// variable
QString theme() const;
void setTheme(QString value);
// Returns the value of oocname in config.ini
QString oocName() const;
void setOocName(QString value);
// Returns the blip rate from config.ini (once per X symbols)
int blipRate() const;
void setBlipRate(int value);
// Returns true if blank blips is enabled in config.ini and false otherwise
bool blankBlip() const;
void setBlankBlip(bool value);
// Returns true if looping sound effects are enabled in the config.ini
bool loopingSfx() const;
void setLoopingSfx(bool value);
// Returns true if stop music on objection is enabled in the config.ini
bool objectionStopMusic() const;
void setObjectionStopMusic(bool value);
// Returns true if streaming is enabled in the config.ini
bool streamingEnabled() const;
void setStreamingEnabled(bool value);
// Returns the value of defaultmusic in config.ini
int musicVolume() const;
void setMusicVolume(int value);
// Returns the value of defaultsfx in config.ini
int sfxVolume() const;
void setSfxVolume(int value);
// Returns the value of defaultblip in config.ini
int blipVolume() const;
void setBlipVolume(int value);
// Returns the value of suppressaudio in config.ini
int defaultSuppressAudio() const;
void setDefaultSupressedAudio(int value);
// Returns the value if objections interrupt and skip the message queue
// from the config.ini.
bool objectionSkipQueueEnabled() const;
void setObjectionSkipQueueEnabled(bool value);
// returns if log will show messages as-received, while viewport will parse
// according to the queue (Text Stay Time) from the config.ini
bool desynchronisedLogsEnabled() const;
void setDesynchronisedLogsEnabled(bool value);
// Returns the value of whether Discord should be enabled on startup
// from the config.ini.
bool discordEnabled() const;
void setDiscordEnabled(bool value);
// Returns the value of whether shaking should be enabled.
// from the config.ini.
bool shakeEnabled() const;
void setShakeEnabled(bool value);
// Returns the value of whether effects should be Enabled.
// from the config.ini.
bool effectsEnabled() const;
void setEffectsEnabled(bool value);
// Returns the value of whether frame-specific effects defined in char.ini
// should be sent/received over the network. from the config.ini.
bool networkedFrameSfxEnabled() const;
void setNetworkedFrameSfxEnabled(bool value);
// Returns the value of whether colored ic log should be a thing.
// from the config.ini.
bool colorLogEnabled() const;
void setColorLogEnabled(bool value);
// Returns the value of whether sticky sounds should be a thing.
// from the config.ini.
bool clearSoundsDropdownOnPlayEnabled() const;
void setClearSoundsDropdownOnPlayEnabled(bool value);
// Returns the value of whether sticky effects should be a thing.
// from the config.ini.
bool clearEffectsDropdownOnPlayEnabled() const;
void setClearEffectsDropdownOnPlayEnabled(bool value);
// Returns the value of whether sticky preanims should be a thing.
// from the config.ini.
bool clearPreOnPlayEnabled() const;
void setClearPreOnPlayEnabled(bool value);
// Returns the value of whether custom chatboxes should be a thing.
// from the config.ini.
// I am increasingly maddened by the lack of dynamic auto-generation system
// for settings.
bool customChatboxEnabled() const;
void setCustomChatboxEnabled(bool value);
// Returns the value of characer sticker (avatar) setting
bool characterStickerEnabled() const;
void setCharacterStickerEnabled(bool value);
// Returns the value of whether continuous playback should be used
// from the config.ini.
bool continuousPlaybackEnabled() const;
void setContinuousPlaybackEnabled(bool value);
// Returns the value of whether stopping music by double clicking category
// should be used from the config.ini.
bool stopMusicOnCategoryEnabled() const;
void setStopMusicOnCategoryEnabled(bool value);
// Returns the value of the maximum amount of lines the IC chatlog
// may contain, from config.ini.
int maxLogSize() const;
void setMaxLogSize(int value);
// Current wait time between messages for the queue system
int textStayTime() const;
void setTextStayTime(int value);
// Returns the letter display speed during text crawl in in-character messages
int textCrawlSpeed() const;
void setTextCrawlSpeed(int value);
// Returns Minimum amount of time (in miliseconds) that must pass before the
// next Enter key press will send your IC message. (new behaviour)
int chatRateLimit() const;
void setChatRateLimit(int value);
// Returns whether the log should go upwards (new behaviour)
// or downwards (vanilla behaviour).
bool logDirectionDownwards() const;
void setLogDirectionDownwards(bool value);
// Returns whether the log should separate name from text via newline or :
bool logNewline() const;
void setLogNewline(bool value);
// Get spacing between IC log entries.
int logMargin() const;
void setLogMargin(int value);
// Returns whether the log should have a timestamp.
bool logTimestampEnabled() const;
void setLogTimestampEnabled(bool value);
// Returns the format string for the log timestamp
QString logTimestampFormat() const;
void setLogTimestampFormat(QString value);
// Returns whether to log IC actions.
bool logIcActions() const;
void setLogIcActions(bool value);
// Returns the username the user may have set in config.ini.
QString username() const;
void setUsername(QString value);
// Returns the audio device used for the client.
QString audioOutputDevice() const;
void setAudioOutputDevice(QString value);
// Returns whether the user would like to have custom shownames on by default.
bool customShownameEnabled() const;
void setCustomShownameEnabled(bool value);
// Returns the showname the user may have set in config.ini.
QString shownameOnJoin() const;
void setShownameOnJoin(QString value);
// Get if text file logging is Enabled
bool logToTextFileEnabled() const;
void setLogToTextFileEnabled(bool value);
// Get if demo logging is Enabled
bool logToDemoFileEnabled() const;
void setLogToDemoFileEnabled(bool value);
// Get the subtheme from settings
QString subTheme() const;
QString settingsSubTheme() const;
void setSettingsSubTheme(QString value);
// Returns the server-
QString serverSubTheme() const;
void setServerSubTheme(QString value);
// Get if the theme is animated
bool animatedThemeEnabled() const;
void setAnimatedThemeEnabled(bool value);
// Get the default scaling method
QString defaultScalingMode() const;
void setDefaultScalingMode(QString value);
// Get a list of custom mount paths
QStringList mountPaths() const;
void setMountPaths(QStringList value);
// Get whether to opt out of player count metrics sent to the master server
bool playerCountOptout() const;
void setPlayerCountOptout(bool value);
// Get if sfx can be sent to play on idle
bool playSelectedSFXOnIdle() const;
void setPlaySelectedSFXOnIdle(bool value);
// Whether opening evidence requires a single or double click
bool evidenceDoubleClickEdit() const;
void setEvidenceDoubleClickEdit(bool value);
// Supplies an alternative masterserver URL
QString alternativeMasterserver() const;
void setAlternativeMasterserver(QString value);
// Language the client loads on start.
QString language() const;
void setLanguage(QString value);
// Callwords notify the user when the word/words are used in a game message.
QStringList callwords() const;
void setCallwords(QStringList value);
// Clears the configuration file. Essentially restoring it to default.
void clearConfig();
// Loads the favorite servers
QVector<server_type> favorites();
void setFavorites(QVector<server_type> value);
// Interactions with favorite servers
void removeFavorite(int index);
void addFavorite(server_type server);
void updateFavorite(server_type server, int index);
// Theming Nonesense!
QString getUIAsset(QString f_asset_name);
};
#endif // OPTIONS_H

View File

@ -0,0 +1,44 @@
#pragma once
#ifndef ADD_SERVER_DIALOG_H
#define ADD_SERVER_DIALOG_H
#include "interfaces/server_dialog.h"
class QComboBox;
class QDialogButton;
class QDialogButtonBox;
class QLabel;
class QLineEdit;
class QPlainTextEdit;
class QPushButton;
class QSpinBox;
class AddServerDialog : public AttorneyOnline::UI::FavoriteServerDialog {
Q_OBJECT
public:
AddServerDialog();
~AddServerDialog() = default;
private:
QWidget *ui_widget;
QLineEdit *ui_server_display_name_edit;
QLineEdit *ui_server_hostname_edit;
QSpinBox *ui_server_port_box;
QComboBox *ui_server_protocol_box;
QPlainTextEdit *ui_server_description_edit;
QDialogButtonBox *ui_server_dialog_button;
// Legacy Server UI
QLabel *ui_server_legacy_lbl;
QLineEdit *ui_server_legacy_edit;
QPushButton *ui_server_legacy_load_button;
private slots:
void onSavePressed() override;
void onCancelPressed() override;
void parseLegacyServerEntry();
};
#endif // ADD_SERVER_DIALOG_H

View File

@ -0,0 +1,159 @@
#ifndef AOOPTIONSDIALOG_H
#define AOOPTIONSDIALOG_H
#include "options.h"
#include <QtCore/QVariant>
#include <QtWidgets/QApplication>
class QCheckBox;
class QComboBox;
class QDialogButtonBox;
class QLineEdit;
class QPlainTextEdit;
class QScrollArea;
class QSpinBox;
class QTabWidget;
class QLabel;
class QAbstractButton;
#include <QtWidgets/QDialog>
#include <QDirIterator>
#include <QListWidget>
#include <QTextBrowser>
#include <QTextStream>
class AOApplication;
struct OptionEntry {
std::function<void()> load;
std::function<void()> save;
};
class AOOptionsDialog : public QDialog {
Q_OBJECT
public:
explicit AOOptionsDialog(QDialog *parent = nullptr,
AOApplication *p_ao_app = nullptr);
private:
AOApplication *ao_app;
// Dialog interaction buttons. Save/Discard/Restore Defaults
QDialogButtonBox *ui_settings_buttons;
// The gameplay tab
QWidget *ui_settings_widget;
QComboBox *ui_theme_combobox;
QComboBox *ui_subtheme_combobox;
QPushButton *ui_theme_reload_button;
QPushButton *ui_theme_folder_button;
QCheckBox *ui_evidence_double_click_cb;
QCheckBox *ui_animated_theme_cb;
QSpinBox *ui_stay_time_spinbox;
QCheckBox *ui_instant_objection_cb;
QSpinBox *ui_text_crawl_spinbox;
QSpinBox *ui_chat_ratelimit_spinbox;
QFrame *ui_log_names_divider;
QLineEdit *ui_username_textbox;
QCheckBox *ui_showname_cb;
QLineEdit *ui_default_showname_textbox;
QFrame *ui_net_divider;
QLineEdit *ui_ms_textbox;
QCheckBox *ui_discord_cb;
QLabel *ui_language_label;
QComboBox *ui_language_combobox;
QLabel *ui_scaling_label;
QComboBox *ui_scaling_combobox;
QCheckBox *ui_shake_cb;
QCheckBox *ui_effects_cb;
QCheckBox *ui_framenetwork_cb;
QCheckBox *ui_colorlog_cb;
QCheckBox *ui_stickysounds_cb;
QCheckBox *ui_stickyeffects_cb;
QCheckBox *ui_stickypres_cb;
QCheckBox *ui_customchat_cb;
QCheckBox *ui_sticker_cb;
QCheckBox *ui_continuous_cb;
QCheckBox *ui_category_stop_cb;
QCheckBox *ui_sfx_on_idle_cb;
// The callwords tab
QPlainTextEdit *ui_callwords_textbox;
QCheckBox *ui_callwords_char_textbox;
// The audio tab
QWidget *ui_audio_tab;
QWidget *ui_audio_widget;
QComboBox *ui_audio_device_combobox;
QSpinBox *ui_suppress_audio_spinbox;
QFrame *ui_volume_blip_divider;
QSpinBox *ui_bliprate_spinbox;
QCheckBox *ui_blank_blips_cb;
QCheckBox *ui_loopsfx_cb;
QCheckBox *ui_objectmusic_cb;
QCheckBox *ui_disablestreams_cb;
// The asset tab
QListWidget *ui_mount_list;
QPushButton *ui_mount_add;
QPushButton *ui_mount_remove;
QPushButton *ui_mount_up;
QPushButton *ui_mount_down;
QPushButton *ui_mount_clear_cache;
// The logging tab
QCheckBox *ui_downwards_cb;
QSpinBox *ui_length_spinbox;
QCheckBox *ui_log_newline_cb;
QSpinBox *ui_log_margin_spinbox;
QLabel *ui_log_timestamp_format_lbl;
QCheckBox *ui_log_timestamp_cb;
QComboBox *ui_log_timestamp_format_combobox;
QCheckBox *ui_desync_logs_cb;
QCheckBox *ui_log_ic_actions_cb;
QCheckBox *ui_log_text_cb;
QCheckBox *ui_log_demo_cb;
/**
* Allows the AO2 master server hoster to go broke.
*/
QWidget *ui_privacy_tab;
QCheckBox *ui_privacy_optout_cb;
QFrame *ui_privacy_separator;
QTextBrowser *ui_privacy_policy;
bool asset_cache_dirty = false;
bool needsDefaultAudioDevice();
void populateAudioDevices();
void updateValues();
QVector<OptionEntry> optionEntries;
template <typename T, typename V>
void setWidgetData(T *widget, const V &value);
template <typename T, typename V> V widgetData(T *widget) const;
template <typename T, typename V>
void registerOption(const QString &widgetName, V (Options::*getter)() const,
void (Options::*setter)(V));
signals:
void reloadThemeRequest();
private slots:
void savePressed();
void discardPressed();
void buttonClicked(QAbstractButton *button);
void onTimestampFormatEdited();
void timestampCbChanged(int state);
void onReloadThemeClicked();
void themeChanged(int i);
void setupUI();
};
#endif // AOOPTIONSDIALOG_H

View File

@ -0,0 +1,46 @@
#ifndef DIRECT_CONNECT_DIALOG_H
#define DIRECT_CONNECT_DIALOG_H
#include <QDialog>
#include <QTimer>
#include <QRegularExpression>
class QLabel;
class QSpinBox;
class QLineEdit;
class QPushButton;
class QComboBox;
class QLabel;
class NetworkManager;
class DirectConnectDialog : public QDialog {
Q_OBJECT
public:
DirectConnectDialog(NetworkManager* p_net_manager);
~DirectConnectDialog() = default;
private slots:
void onConnectPressed();
void onServerConnected();
void onConnectTimeout();
private:
NetworkManager* net_manager;
QLineEdit* ui_direct_hostname_edit;
QLabel* ui_direct_connection_status_lbl;
QPushButton* ui_direct_connect_button;
QPushButton* ui_direct_cancel_button;
QWidget* ui_widget;
QTimer connect_timeout;
const int TCP_INDEX = 0;
const QRegularExpression SCHEME_PATTERN{"^\\w+://.+$"};
const int CONNECT_TIMEOUT = 5 * 1000;
const QString DEFAULT_UI = "direct_connect_dialog.ui";;
};
#endif // DIRECT_CONNECT_DIALOG_H

View File

@ -0,0 +1,46 @@
#pragma once
#ifndef EDIT_SERVER_DIALOG_H
#define EDIT_SERVER_DIALOG_H
#include "interfaces/server_dialog.h"
class QPushButton;
class QDialogButton;
class QLabel;
class QLineEdit;
class QComboBox;
class QSpinBox;
class QPlainTextEdit;
class QDialogButtonBox;
class EditServerDialog : public AttorneyOnline::UI::FavoriteServerDialog {
Q_OBJECT
public:
EditServerDialog(int index);
~EditServerDialog() = default;
private:
QWidget *ui_widget;
QLineEdit *ui_server_display_name_edit;
QLineEdit *ui_server_hostname_edit;
QSpinBox *ui_server_port_box;
QComboBox *ui_server_protocol_box;
QPlainTextEdit *ui_server_description_edit;
QDialogButtonBox *ui_server_dialog_button;
// Legacy Server UI
QLabel *ui_server_legacy_lbl;
QLineEdit *ui_server_legacy_edit;
QPushButton *ui_server_legacy_load_button;
int index;
void loadEntry();
private slots:
void onSavePressed() override;
void onCancelPressed() override;
};
#endif // EDIT_SERVER_DIALOG_H

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>direct_connect_dialog</class>
<widget class="QWidget" name="direct_connect_dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>401</width>
<height>77</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="direct_hostname_edit">
<property name="placeholderText">
<string>scheme://hostname.domain:port</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="direct_connection_status_lbl">
<property name="text">
<string>Not Connected</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="direct_connect_button">
<property name="text">
<string>Connect</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="direct_cancel_button">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,141 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>add_server_widget</class>
<widget class="QWidget" name="add_server_widget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>420</width>
<height>420</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>230</width>
<height>260</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<layout class="QHBoxLayout" name="server_legacy_layout">
<item>
<widget class="QLabel" name="server_legacy_lbl">
<property name="text">
<string>Legacy Entry :</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="server_legacy_edit"/>
</item>
<item>
<widget class="QPushButton" name="server_legacy_load_button">
<property name="text">
<string>Convert</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<layout class="QFormLayout" name="server_new_layout">
<item row="0" column="0">
<widget class="QLabel" name="server_display_name_lbl">
<property name="text">
<string>Display Name:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="server_display_name_edit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="server_hostname_lbl">
<property name="text">
<string>Hostname :</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="server_hostname_edit"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="server_port_lbl">
<property name="text">
<string>Port:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="server_port_box">
<property name="maximum">
<number>65535</number>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="server_protocol_lbl">
<property name="text">
<string>Protocol :</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="server_protocol_box">
<item>
<property name="text">
<string>TCP</string>
</property>
</item>
<item>
<property name="text">
<string>WEBSOCKET</string>
</property>
</item>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="server_description_lbl">
<property name="text">
<string>Description:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPlainTextEdit" name="server_description_edit">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="Line" name="server_legacy_bar">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QDialogButtonBox" name="server_dialog_button">
<property name="standardButtons">
<set>QDialogButtonBox::Close|QDialogButtonBox::Save</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

706
resource/ui/lobby.ui Normal file
View File

@ -0,0 +1,706 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>lobby_form</class>
<widget class="QWidget" name="lobby_form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>550</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>300</width>
<height>280</height>
</size>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="windowTitle">
<string/>
</property>
<property name="styleSheet">
<string notr="true">QWidget#lobby_form {
background-color : rgba(102, 102, 102, 255);
}
QLabel {
color: white;
}
QLineEdit {
background-color: rgb(102,102,102);
color: rgb(255, 255, 255);
}
QTreeWidget {
background-color: rgb(102,102,102);
color: white
}
QWidget#demo_tab {
border: 1px solid white
}
QPushButton {
border: 1px solid lightgray;
background-color: rgb(84,33,0);
color: white;
padding: 3;
}
QPushButton:hover {
border: 1px solid white;
background-color: rgb(122,40,0);
}
QPushButton:pressed {
border: 1px solid white;
background-color: rgb(125,41,0);
color: white;
}
QTabBar::tab {
border: 2px solid lightgray;
background-color: rgb(100,41,0);
color: lightgray;
padding: 2;
margin-right: 5px;
margin-left: 5px;
border-bottom: 0;
}
QTabBar::tab:selected, QTabBar::tab:hover {
color: white;
background-color: rgb(122,40,0);
}
QTabBar::tab:selected {
background-color: rgb(122,40,0);
border: 2px solid white;
border-bottom: 0;
}
QTabBar::tab:!selected {
margin-top: 2px; /* make non-selected tabs look smaller */
}
QHeaderView::section {
border: 1px solid white;
background-color: rgb(122,40,0);
margin-right: 2px;
padding: 1;
}
QHeaderView::section:pressed {
background-color: rgb(84,33,0);
}
QHeaderView::up-arrow
{
image: url(&quot;:/resource/ui/lobby_assets/up-arrow.png&quot;);
}
QHeaderView::down-arrow
{
image: url(&quot;:/resource/ui/lobby_assets/down-arrow.png&quot;);
}
QScrollBar:vertical {
background-color: rgba(140,140,140, 255);
color : white
}
QScrollBar:horizontall {
background-color: rgba(140,140,140, 255);
color : white
}</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="lobby_info" native="true">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="lobby_controls" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="game_version_lbl">
<property name="text">
<string>Version: 2.10.1</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="settings_button">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Settings</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="about_button">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>About</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="lobby_title">
<property name="text">
<string>Game Lobby</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="server_interaction" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QWidget" name="serverlist" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>3</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QTabWidget" name="connections_tabview">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<property name="documentMode">
<bool>true</bool>
</property>
<widget class="QWidget" name="serverlist_tab">
<attribute name="title">
<string>Public Servers</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLineEdit" name="serverlist_search">
<property name="placeholderText">
<string>Search</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QTreeWidget" name="serverlist_tree">
<property name="styleSheet">
<string notr="true">background-color: rgba(140, 140, 140, 255);
color: rgb(255, 255, 255);</string>
</property>
<property name="textElideMode">
<enum>Qt::ElideNone</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<column>
<property name="text">
<string>#</string>
</property>
<property name="textAlignment">
<set>AlignTrailing|AlignVCenter</set>
</property>
</column>
<column>
<property name="text">
<string>Name</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="favorites_tab">
<attribute name="title">
<string>Favorites</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QTreeWidget" name="favorites_tree">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgba(140, 140, 140, 255);
color: rgb(255, 255, 255);</string>
</property>
<property name="textElideMode">
<enum>Qt::ElideNone</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<column>
<property name="text">
<string>#</string>
</property>
</column>
<column>
<property name="text">
<string>Name</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="demo_tab">
<attribute name="title">
<string>Demos</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QTreeWidget" name="demo_tree">
<property name="styleSheet">
<string notr="true">background-color: rgba(140, 140, 140, 255);
color: rgb(255, 255, 255);</string>
</property>
<property name="textElideMode">
<enum>Qt::ElideNone</enum>
</property>
<property name="indentation">
<number>0</number>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<column>
<property name="text">
<string>Server</string>
</property>
</column>
<column>
<property name="text">
<string>Name</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="server_controls">
<item>
<widget class="QPushButton" name="add_server_button">
<property name="text">
<string>Add Server</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="remove_from_favorites_button">
<property name="text">
<string>Remove Server</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="edit_favorite_button">
<property name="text">
<string>Edit Server</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="favorite_controls">
<item>
<widget class="QPushButton" name="direct_connect_button">
<property name="text">
<string>Direct Connect</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="add_to_favorite_button">
<property name="text">
<string>Add To Favorites</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="refresh_layout">
<item>
<widget class="QPushButton" name="refresh_button">
<property name="text">
<string>Refresh</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>5</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QWidget" name="info_motd" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="server_info" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>4</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="server_info_lbl">
<property name="styleSheet">
<string notr="true">color: #F8A818;
background-color: #383838;
border: 1px solid white;</string>
</property>
<property name="text">
<string>Server Info</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="server_player_count_lbl">
<property name="styleSheet">
<string notr="true">color: #F8A818;
background-color: #383838;
border: 1px solid white;</string>
</property>
<property name="text">
<string>Offline</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QTextBrowser" name="server_description_text">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgba(140, 140, 140, 255);
color: rgb(255, 255, 255);</string>
</property>
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;meta charset=&quot;utf-8&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
hr { height: 1px; border-width: 0; }
li.unchecked::marker { content: &quot;\2610&quot;; }
li.checked::marker { content: &quot;\2612&quot;; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Segoe UI'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;No description provided.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="connect_button">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Connect</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="motd" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>3</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="motd_lbl">
<property name="styleSheet">
<string notr="true">color: #F8A818;
background-color: #383838;
border: 1px solid white;</string>
</property>
<property name="text">
<string>Message of the Day</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QTextBrowser" name="motd_text">
<property name="styleSheet">
<string notr="true">background-color: rgba(140, 140, 140, 255);
color: rgb(255, 255, 255);</string>
</property>
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;meta charset=&quot;utf-8&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
hr { height: 1px; border-width: 0; }
li.unchecked::marker { content: &quot;\2610&quot;; }
li.checked::marker { content: &quot;\2612&quot;; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Segoe UI'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 B

File diff suppressed because it is too large Load Diff

View File

@ -9,5 +9,11 @@
<file>resource/translations/ao_pl.qm</file> <file>resource/translations/ao_pl.qm</file>
<file>resource/translations/ao_pt.qm</file> <file>resource/translations/ao_pt.qm</file>
<file>resource/translations/ao_ru.qm</file> <file>resource/translations/ao_ru.qm</file>
<file>resource/ui/options_dialog.ui</file>
<file>resource/ui/favorite_server_dialog.ui</file>
<file>resource/ui/direct_connect_dialog.ui</file>
<file>resource/ui/lobby.ui</file>
<file>resource/ui/lobby_assets/down-arrow.png</file>
<file>resource/ui/lobby_assets/up-arrow.png</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -1,12 +1,13 @@
#include "aoapplication.h" #include "aoapplication.h"
#include "bassmidi.h"
#include "courtroom.h" #include "courtroom.h"
#include "debug_functions.h" #include "debug_functions.h"
#include "lobby.h" #include "lobby.h"
#include "networkmanager.h" #include "networkmanager.h"
#include "options.h"
#include "aocaseannouncerdialog.h" #include "widgets/aooptionsdialog.h"
#include "aooptionsdialog.h"
static QtMessageHandler original_message_handler; static QtMessageHandler original_message_handler;
static AOApplication *message_handler_context; static AOApplication *message_handler_context;
@ -19,10 +20,6 @@ void message_handler(QtMsgType type, const QMessageLogContext &context,
AOApplication::AOApplication(int &argc, char **argv) : QApplication(argc, argv) AOApplication::AOApplication(int &argc, char **argv) : QApplication(argc, argv)
{ {
// Create the QSettings class that points to the config.ini.
configini =
new QSettings(get_base_path() + "config.ini", QSettings::IniFormat);
net_manager = new NetworkManager(this); net_manager = new NetworkManager(this);
discord = new AttorneyOnline::Discord(); discord = new AttorneyOnline::Discord();
@ -40,7 +37,6 @@ AOApplication::~AOApplication()
destruct_lobby(); destruct_lobby();
destruct_courtroom(); destruct_courtroom();
delete discord; delete discord;
delete configini;
qInstallMessageHandler(original_message_handler); qInstallMessageHandler(original_message_handler);
} }
@ -51,8 +47,7 @@ void AOApplication::construct_lobby()
return; return;
} }
load_favorite_list(); w_lobby = new Lobby(this, net_manager);
w_lobby = new Lobby(this);
lobby_constructed = true; lobby_constructed = true;
QRect geometry = QGuiApplication::primaryScreen()->geometry(); QRect geometry = QGuiApplication::primaryScreen()->geometry();
@ -60,13 +55,12 @@ void AOApplication::construct_lobby()
int y = (geometry.height() - w_lobby->height()) / 2; int y = (geometry.height() - w_lobby->height()) / 2;
w_lobby->move(x, y); w_lobby->move(x, y);
if (is_discord_enabled()) if (Options::getInstance().discordEnabled())
discord->state_lobby(); discord->state_lobby();
if (demo_server) if (demo_server)
demo_server->deleteLater(); demo_server->deleteLater();
demo_server = new DemoServer(this); demo_server = new DemoServer(this);
w_lobby->show(); w_lobby->show();
} }
@ -124,64 +118,6 @@ QString AOApplication::get_version_string()
QString::number(MINOR_VERSION); QString::number(MINOR_VERSION);
} }
void AOApplication::reload_theme() { current_theme = read_theme(); }
void AOApplication::load_favorite_list()
{
favorite_list = read_favorite_servers();
}
void AOApplication::save_favorite_list()
{
QSettings favorite_servers_ini(get_base_path() + "favorite_servers.ini", QSettings::IniFormat);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
favorite_servers_ini.setIniCodec("UTF-8");
#endif
favorite_servers_ini.clear();
// skip demo server entry, demo server entry is always at index 0
for(int i = 1; i < favorite_list.size(); ++i) {
auto fav_server = favorite_list.at(i);
favorite_servers_ini.beginGroup(QString::number(i));
favorite_servers_ini.setValue("name", fav_server.name);
favorite_servers_ini.setValue("address", fav_server.ip);
favorite_servers_ini.setValue("port", fav_server.port);
favorite_servers_ini.setValue("desc", fav_server.desc);
if (fav_server.socket_type == TCP) {
favorite_servers_ini.setValue("protocol", "tcp");
} else {
favorite_servers_ini.setValue("protocol", "ws");
}
favorite_servers_ini.endGroup();
}
favorite_servers_ini.sync();
}
QString AOApplication::get_current_char()
{
if (courtroom_constructed)
return w_courtroom->get_current_char();
else
return "";
}
void AOApplication::add_favorite_server(int p_server)
{
if (p_server < 0 || p_server >= server_list.size())
return;
favorite_list.append(server_list.at(p_server));
save_favorite_list();
}
void AOApplication::remove_favorite_server(int p_server)
{
if (p_server < 0 || p_server >= favorite_list.size())
return;
favorite_list.removeAt(p_server);
save_favorite_list();
}
void AOApplication::server_disconnected() void AOApplication::server_disconnected()
{ {
if (courtroom_constructed) { if (courtroom_constructed) {
@ -189,25 +125,26 @@ void AOApplication::server_disconnected()
construct_lobby(); construct_lobby();
destruct_courtroom(); destruct_courtroom();
} }
Options::getInstance().setServerSubTheme(QString());
} }
void AOApplication::loading_cancelled() void AOApplication::loading_cancelled()
{ {
destruct_courtroom(); destruct_courtroom();
w_lobby->hide_loading_overlay();
} }
void AOApplication::call_settings_menu() void AOApplication::call_settings_menu()
{ {
AOOptionsDialog settings(nullptr, this); AOOptionsDialog* l_dialog = new AOOptionsDialog(nullptr, this);
settings.exec(); if (courtroom_constructed) {
} connect(l_dialog, &AOOptionsDialog::reloadThemeRequest,
w_courtroom, &Courtroom::on_reload_theme_clicked);
}
void AOApplication::call_announce_menu(Courtroom *court) if(lobby_constructed) {
{ }
AOCaseAnnouncerDialog announcer(nullptr, this, court); l_dialog->exec();
announcer.exec(); delete l_dialog;
} }
// Callback for when BASS device is lost // Callback for when BASS device is lost
@ -238,24 +175,26 @@ void AOApplication::initBASS()
unsigned int a = 0; unsigned int a = 0;
BASS_DEVICEINFO info; BASS_DEVICEINFO info;
if (get_audio_output_device() == "default") { if (Options::getInstance().audioOutputDevice() == "default") {
BASS_Init(-1, 48000, BASS_DEVICE_LATENCY, nullptr, nullptr); BASS_Init(-1, 48000, BASS_DEVICE_LATENCY, nullptr, nullptr);
load_bass_plugins(); load_bass_plugins();
} }
else { else {
for (a = 0; BASS_GetDeviceInfo(a, &info); a++) { for (a = 0; BASS_GetDeviceInfo(a, &info); a++) {
if (get_audio_output_device() == info.name) { if (Options::getInstance().audioOutputDevice() == info.name) {
BASS_SetDevice(a); BASS_SetDevice(a);
BASS_Init(static_cast<int>(a), 48000, BASS_DEVICE_LATENCY, nullptr, BASS_Init(static_cast<int>(a), 48000, BASS_DEVICE_LATENCY, nullptr,
nullptr); nullptr);
load_bass_plugins(); load_bass_plugins();
qInfo() << info.name << "was set as the default audio output device."; qInfo() << info.name << "was set as the default audio output device.";
BASS_SetConfigPtr(BASS_CONFIG_MIDI_DEFFONT, QString(get_base_path() + "soundfont.sf2").toStdString().c_str());
return; return;
} }
} }
BASS_Init(-1, 48000, BASS_DEVICE_LATENCY, nullptr, nullptr); BASS_Init(-1, 48000, BASS_DEVICE_LATENCY, nullptr, nullptr);
load_bass_plugins(); load_bass_plugins();
} }
BASS_SetConfigPtr(BASS_CONFIG_MIDI_DEFFONT, QString(get_base_path() + "soundfont.sf2").toStdString().c_str());
} }
#if (defined(_WIN32) || defined(_WIN64)) #if (defined(_WIN32) || defined(_WIN64))

View File

@ -2,6 +2,7 @@
#include "debug_functions.h" #include "debug_functions.h"
#include "file_functions.h" #include "file_functions.h"
#include "options.h"
AOButton::AOButton(QWidget *parent, AOApplication *p_ao_app) AOButton::AOButton(QWidget *parent, AOApplication *p_ao_app)
: QPushButton(parent) : QPushButton(parent)
@ -20,8 +21,8 @@ void AOButton::set_image(QString p_path, QString p_misc)
{ {
movie->stop(); movie->stop();
QString p_image; QString p_image;
p_image = ao_app->get_image(p_path, ao_app->current_theme, ao_app->get_subtheme(), p_image = ao_app->get_image(p_path, Options::getInstance().theme(), Options::getInstance().subTheme(),
ao_app->default_theme, p_misc, "", "", !ao_app->get_animated_theme()); ao_app->default_theme, p_misc, "", "", !Options::getInstance().animatedThemeEnabled());
if (p_image.isEmpty()) { if (p_image.isEmpty()) {
this->setIcon(QIcon()); this->setIcon(QIcon());
this->setIconSize(this->size()); this->setIconSize(this->size());
@ -33,7 +34,7 @@ void AOButton::set_image(QString p_path, QString p_misc)
movie->setFileName(p_image); movie->setFileName(p_image);
// We double-check if the user wants animated themes, so even if an animated image slipped through, // We double-check if the user wants animated themes, so even if an animated image slipped through,
// we still set it static // we still set it static
if (ao_app->get_animated_theme() && movie->frameCount() > 1) { if (Options::getInstance().animatedThemeEnabled() && movie->frameCount() > 1) {
movie->start(); movie->start();
} }
else { else {

View File

@ -1,85 +0,0 @@
#include "aocaseannouncerdialog.h"
AOCaseAnnouncerDialog::AOCaseAnnouncerDialog(QWidget *parent,
AOApplication *p_ao_app,
Courtroom *p_court)
: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
{
ao_app = p_ao_app;
court = p_court;
setWindowTitle(tr("Case Announcer"));
resize(405, 235);
ui_announcer_buttons = new QDialogButtonBox(this);
QSizePolicy sizepolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
sizepolicy.setHorizontalStretch(0);
sizepolicy.setVerticalStretch(0);
sizepolicy.setHeightForWidth(
ui_announcer_buttons->sizePolicy().hasHeightForWidth());
ui_announcer_buttons->setSizePolicy(sizepolicy);
ui_announcer_buttons->setOrientation(Qt::Horizontal);
ui_announcer_buttons->setStandardButtons(QDialogButtonBox::Ok |
QDialogButtonBox::Cancel);
connect(ui_announcer_buttons, &QDialogButtonBox::accepted, this,
&AOCaseAnnouncerDialog::ok_pressed);
connect(ui_announcer_buttons, &QDialogButtonBox::rejected, this,
&AOCaseAnnouncerDialog::cancel_pressed);
setUpdatesEnabled(false);
ui_vbox_layout = new QVBoxLayout(this);
ui_form_layout = new QFormLayout(this);
ui_form_layout->setLabelAlignment(Qt::AlignLeading | Qt::AlignLeft |
Qt::AlignVCenter);
ui_form_layout->setFormAlignment(Qt::AlignLeading | Qt::AlignLeft |
Qt::AlignTop);
ui_form_layout->setContentsMargins(6, 6, 6, 6);
ui_vbox_layout->addItem(ui_form_layout);
ui_vbox_layout->addWidget(ui_announcer_buttons);
ui_case_title_label = new QLabel(this);
ui_case_title_label->setText(tr("Case title:"));
ui_form_layout->setWidget(0, QFormLayout::LabelRole, ui_case_title_label);
ui_case_title_textbox = new QLineEdit(this);
ui_case_title_textbox->setMaxLength(50);
ui_form_layout->setWidget(0, QFormLayout::FieldRole, ui_case_title_textbox);
ui_defense_needed = new QCheckBox(this);
ui_defense_needed->setText(tr("Defense needed"));
ui_prosecutor_needed = new QCheckBox(this);
ui_prosecutor_needed->setText(tr("Prosecution needed"));
ui_judge_needed = new QCheckBox(this);
ui_judge_needed->setText(tr("Judge needed"));
ui_juror_needed = new QCheckBox(this);
ui_juror_needed->setText(tr("Jurors needed"));
ui_steno_needed = new QCheckBox(this);
ui_steno_needed->setText(tr("Stenographer needed"));
ui_form_layout->setWidget(1, QFormLayout::FieldRole, ui_defense_needed);
ui_form_layout->setWidget(2, QFormLayout::FieldRole, ui_prosecutor_needed);
ui_form_layout->setWidget(3, QFormLayout::FieldRole, ui_judge_needed);
ui_form_layout->setWidget(4, QFormLayout::FieldRole, ui_juror_needed);
ui_form_layout->setWidget(5, QFormLayout::FieldRole, ui_steno_needed);
setUpdatesEnabled(true);
}
void AOCaseAnnouncerDialog::ok_pressed()
{
court->announce_case(
ui_case_title_textbox->text(), ui_defense_needed->isChecked(),
ui_prosecutor_needed->isChecked(), ui_judge_needed->isChecked(),
ui_juror_needed->isChecked(), ui_steno_needed->isChecked());
done(0);
}
void AOCaseAnnouncerDialog::cancel_pressed() { done(0); }

View File

@ -78,7 +78,11 @@ void AOCharButton::set_image(QString p_character)
} }
} }
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void AOCharButton::enterEvent(QEvent *e)
#else
void AOCharButton::enterEvent(QEnterEvent *e) void AOCharButton::enterEvent(QEnterEvent *e)
#endif
{ {
ui_selector->move(this->x() - 1, this->y() - 1); ui_selector->move(this->x() - 1, this->y() - 1);
ui_selector->raise(); ui_selector->raise();

View File

@ -104,7 +104,11 @@ void AOEvidenceButton::dragEnterEvent(QMouseEvent *e)
} }
*/ */
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void AOEvidenceButton::enterEvent(QEvent *e)
#else
void AOEvidenceButton::enterEvent(QEnterEvent *e) void AOEvidenceButton::enterEvent(QEnterEvent *e)
#endif
{ {
ui_selector->show(); ui_selector->show();

View File

@ -1,6 +1,7 @@
#include "file_functions.h" #include "file_functions.h"
#include "aoimage.h" #include "aoimage.h"
#include "options.h"
#include <QBitmap> #include <QBitmap>
@ -28,9 +29,9 @@ AOImage::~AOImage() {}
bool AOImage::set_image(QString p_image, QString p_misc) bool AOImage::set_image(QString p_image, QString p_misc)
{ {
QString p_image_resolved = ao_app->get_image(p_image, ao_app->current_theme, ao_app->get_subtheme(), QString p_image_resolved = ao_app->get_image(p_image, Options::getInstance().theme(), Options::getInstance().subTheme(),
ao_app->default_theme, p_misc, "", "", ao_app->default_theme, p_misc, "", "",
is_static || !ao_app->get_animated_theme()); is_static || !Options::getInstance().animatedThemeEnabled());
if (!file_exists(p_image_resolved)) { if (!file_exists(p_image_resolved)) {
qWarning() << "could not find image" << p_image; qWarning() << "could not find image" << p_image;
@ -41,11 +42,11 @@ bool AOImage::set_image(QString p_image, QString p_misc)
if (!is_static) { if (!is_static) {
movie->stop(); movie->stop();
movie->setFileName(path); movie->setFileName(path);
if (ao_app->get_animated_theme() && movie->frameCount() > 1) { if (Options::getInstance().animatedThemeEnabled() && movie->frameCount() > 1) {
movie->start(); movie->start();
} }
} }
if (is_static || !ao_app->get_animated_theme() || movie->frameCount() <= 1) { if (is_static || !Options::getInstance().animatedThemeEnabled() || movie->frameCount() <= 1) {
QPixmap f_pixmap(path); QPixmap f_pixmap(path);
f_pixmap = f_pixmap =

View File

@ -2,6 +2,8 @@
#include "aoapplication.h" #include "aoapplication.h"
#include "file_functions.h" #include "file_functions.h"
#include "misc_functions.h"
#include "options.h"
static QThreadPool *thread_pool; static QThreadPool *thread_pool;
@ -233,7 +235,7 @@ void SplashLayer::load_image(QString p_filename, QString p_charname,
QString p_miscname) QString p_miscname)
{ {
transform_mode = ao_app->get_misc_scaling(p_miscname); transform_mode = ao_app->get_misc_scaling(p_miscname);
QString final_image = ao_app->get_image(p_filename, ao_app->current_theme, ao_app->get_subtheme(), ao_app->default_theme, p_miscname, p_charname, "placeholder"); QString final_image = ao_app->get_image(p_filename, Options::getInstance().theme(), Options::getInstance().subTheme(), ao_app->default_theme, p_miscname, p_charname, "placeholder");
start_playback(final_image); start_playback(final_image);
play(); play();
} }
@ -256,7 +258,7 @@ void InterfaceLayer::load_image(QString p_filename, QString p_miscname)
{ {
last_path = ""; last_path = "";
stretch = true; stretch = true;
QString final_image = ao_app->get_image(p_filename, ao_app->current_theme, ao_app->get_subtheme(), ao_app->default_theme, p_miscname); QString final_image = ao_app->get_image(p_filename, Options::getInstance().theme(), Options::getInstance().subTheme(), ao_app->default_theme, p_miscname);
start_playback(final_image); start_playback(final_image);
play(); play();
} }
@ -264,10 +266,10 @@ void InterfaceLayer::load_image(QString p_filename, QString p_miscname)
void StickerLayer::load_image(QString p_charname) void StickerLayer::load_image(QString p_charname)
{ {
QString p_miscname; QString p_miscname;
if (ao_app->is_customchat_enabled()) if (Options::getInstance().customChatboxEnabled())
p_miscname = ao_app->get_chat(p_charname); p_miscname = ao_app->get_chat(p_charname);
transform_mode = ao_app->get_misc_scaling(p_miscname); transform_mode = ao_app->get_misc_scaling(p_miscname);
QString final_image = ao_app->get_image("sticker/" + p_charname, ao_app->current_theme, ao_app->get_subtheme(), ao_app->default_theme, p_miscname); QString final_image = ao_app->get_image("sticker/" + p_charname, Options::getInstance().theme(), Options::getInstance().subTheme(), ao_app->default_theme, p_miscname);
start_playback(final_image); start_playback(final_image);
play(); play();
} }
@ -296,7 +298,7 @@ void AOLayer::start_playback(QString p_image)
QMutexLocker locker(&mutex); QMutexLocker locker(&mutex);
this->show(); this->show();
if (!ao_app->is_continuous_enabled()) { if (!Options::getInstance().continuousPlaybackEnabled()) {
continuous = false; continuous = false;
force_continuous = true; force_continuous = true;
} }
@ -335,11 +337,11 @@ void AOLayer::start_playback(QString p_image)
frame = 0; frame = 0;
continuous = false; continuous = false;
} }
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
frame_loader = QtConcurrent::run(thread_pool, this, &AOLayer::populate_vectors); frame_loader = QtConcurrent::run(thread_pool, this, &AOLayer::populate_vectors);
#else #else
frame_loader = QtConcurrent::run(thread_pool, &AOLayer::populate_vectors, this); frame_loader = QtConcurrent::run(thread_pool, &AOLayer::populate_vectors, this);
#endif #endif
last_path = p_image; last_path = p_image;
while (movie_frames.size() <= frame) // if we haven't loaded the frame we need yet while (movie_frames.size() <= frame) // if we haven't loaded the frame we need yet
frameAdded.wait(&mutex); // wait for the frame loader to add another frame, then check again frameAdded.wait(&mutex); // wait for the frame loader to add another frame, then check again

View File

@ -1,4 +1,8 @@
#include "aomusicplayer.h" #include "aomusicplayer.h"
#include "options.h"
#include "bass.h"
#include "file_functions.h"
AOMusicPlayer::AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app) AOMusicPlayer::AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app)
{ {
@ -30,25 +34,15 @@ QString AOMusicPlayer::play(QString p_song, int channel, bool loop,
DWORD newstream; DWORD newstream;
if (f_path.startsWith("http")) { if (f_path.startsWith("http")) {
if (ao_app->is_streaming_disabled()) { if (!Options::getInstance().streamingEnabled()) {
BASS_ChannelStop(m_stream_list[channel]); BASS_ChannelStop(m_stream_list[channel]);
return QObject::tr("[MISSING] Streaming disabled."); return QObject::tr("[MISSING] Streaming disabled.");
} }
newstream = BASS_StreamCreateURL(f_path.toStdString().c_str(), 0, streaming_flags, nullptr, 0);
if (f_path.endsWith(".opus")) }
newstream = BASS_OPUS_StreamCreateURL(f_path.toStdString().c_str(), 0, streaming_flags, nullptr, 0); else {
else if (f_path.endsWith(".mid"))
newstream = BASS_MIDI_StreamCreateURL(f_path.toStdString().c_str(), 0, streaming_flags, nullptr, 0, 1);
else
newstream = BASS_StreamCreateURL(f_path.toStdString().c_str(), 0, streaming_flags, nullptr, 0);
} else {
f_path = ao_app->get_real_path(ao_app->get_music_path(p_song)); f_path = ao_app->get_real_path(ao_app->get_music_path(p_song));
if (f_path.endsWith(".opus")) if (f_path.endsWith(".mo3") || f_path.endsWith(".xm") || f_path.endsWith(".mod") || f_path.endsWith(".s3m") || f_path.endsWith(".it") || f_path.endsWith(".mtm") || f_path.endsWith(".umx") )
newstream = BASS_OPUS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, flags);
else if (f_path.endsWith(".mid"))
newstream = BASS_MIDI_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, flags, 1);
else if (f_path.endsWith(".mo3") || f_path.endsWith(".xm") || f_path.endsWith(".mod") || f_path.endsWith(".s3m") || f_path.endsWith(".it") || f_path.endsWith(".mtm") || f_path.endsWith(".umx") )
newstream = BASS_MusicLoad(FALSE,f_path.utf16(), 0, 0, flags, 1); newstream = BASS_MusicLoad(FALSE,f_path.utf16(), 0, 0, flags, 1);
else else
newstream = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, flags); newstream = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, flags);
@ -56,7 +50,7 @@ QString AOMusicPlayer::play(QString p_song, int channel, bool loop,
int error_code = BASS_ErrorGetCode(); int error_code = BASS_ErrorGetCode();
if (ao_app->get_audio_output_device() != "default") if (Options::getInstance().audioOutputDevice() != "default")
BASS_ChannelSetDevice(m_stream_list[channel], BASS_GetDevice()); BASS_ChannelSetDevice(m_stream_list[channel], BASS_GetDevice());
QString d_path = f_path + ".txt"; QString d_path = f_path + ".txt";
@ -219,20 +213,18 @@ void AOMusicPlayer::set_looping(bool loop_song, int channel)
loop_sync[channel] = 0; loop_sync[channel] = 0;
} }
if (loop_start[channel] >= 0) { if (loop_start[channel] < loop_end[channel])
if (loop_start[channel] < loop_end[channel]) {
{ //Loop when the endpoint is reached.
//Loop when the endpoint is reached. loop_sync[channel] = BASS_ChannelSetSync(
loop_sync[channel] = BASS_ChannelSetSync( m_stream_list[channel], BASS_SYNC_POS | BASS_SYNC_MIXTIME,
m_stream_list[channel], BASS_SYNC_POS | BASS_SYNC_MIXTIME, loop_end[channel], loopProc, &loop_start[channel]);
loop_end[channel], loopProc, &loop_start[channel]); }
} else
else {
{ //Loop when the end of the file is reached.
//Loop when the end of the file is reached. loop_sync[channel] = BASS_ChannelSetSync(
loop_sync[channel] = BASS_ChannelSetSync( m_stream_list[channel], BASS_SYNC_END | BASS_SYNC_MIXTIME,
m_stream_list[channel], BASS_SYNC_END | BASS_SYNC_MIXTIME, 0, loopProc, &loop_start[channel]);
0, loopProc, &loop_start[channel]);
}
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -98,8 +98,14 @@ void Courtroom::set_char_select()
set_size_and_pos(ui_char_taken, "char_taken"); set_size_and_pos(ui_char_taken, "char_taken");
set_size_and_pos(ui_char_buttons, "char_buttons"); set_size_and_pos(ui_char_buttons, "char_buttons");
// Silence emission. This causes the signal to be emitted TWICE during server join!
// Fuck this. Performance Sandwich.
ui_char_taken->blockSignals(true);
ui_char_passworded->blockSignals(true);
ui_char_taken->setChecked(true); ui_char_taken->setChecked(true);
ui_char_passworded->setChecked(true); ui_char_passworded->setChecked(true);
ui_char_taken->blockSignals(false);
ui_char_passworded->blockSignals(false);
truncate_label_text(ui_char_taken, "char_taken"); truncate_label_text(ui_char_taken, "char_taken");
truncate_label_text(ui_char_passworded, "char_passworded"); truncate_label_text(ui_char_passworded, "char_passworded");
@ -142,6 +148,18 @@ void Courtroom::set_char_select_page()
if (current_char_page > 0) if (current_char_page > 0)
ui_char_select_left->show(); ui_char_select_left->show();
QPoint f_spacing =
ao_app->get_button_spacing("char_button_spacing", "courtroom_design.ini");
char_columns =
((ui_char_buttons->width() - button_width) / (f_spacing.x() + button_width)) +
1;
char_rows = ((ui_char_buttons->height() - button_height) /
(f_spacing.y() + button_height)) +
1;
max_chars_on_page = char_columns * char_rows;
put_button_in_place(current_char_page * max_chars_on_page, chars_on_page); put_button_in_place(current_char_page * max_chars_on_page, chars_on_page);
} }
@ -233,25 +251,13 @@ void Courtroom::put_button_in_place(int starting, int chars_on_this_page)
QPoint f_spacing = QPoint f_spacing =
ao_app->get_button_spacing("char_button_spacing", "courtroom_design.ini"); ao_app->get_button_spacing("char_button_spacing", "courtroom_design.ini");
int x_spacing = f_spacing.x();
int x_mod_count = 0; int x_mod_count = 0;
int y_spacing = f_spacing.y();
int y_mod_count = 0; int y_mod_count = 0;
char_columns =
((ui_char_buttons->width() - button_width) / (x_spacing + button_width)) +
1;
char_rows = ((ui_char_buttons->height() - button_height) /
(y_spacing + button_height)) +
1;
max_chars_on_page = char_columns * char_rows;
int startout = starting; int startout = starting;
for (int n = starting; n < startout + chars_on_this_page; ++n) { for (int n = starting; n < startout + chars_on_this_page; ++n) {
int x_pos = (button_width + x_spacing) * x_mod_count; int x_pos = (button_width + f_spacing.x()) * x_mod_count;
int y_pos = (button_height + y_spacing) * y_mod_count; int y_pos = (button_height + f_spacing.y()) * y_mod_count;
ui_char_button_list_filtered.at(n)->move(x_pos, y_pos); ui_char_button_list_filtered.at(n)->move(x_pos, y_pos);
ui_char_button_list_filtered.at(n)->show(); ui_char_button_list_filtered.at(n)->show();
@ -324,19 +330,6 @@ void Courtroom::character_loading_finished()
// still running, it is just loading the pictures of the characters. // still running, it is just loading the pictures of the characters.
if (ao_app->lobby_constructed) { if (ao_app->lobby_constructed) {
ao_app->generated_chars++; ao_app->generated_chars++;
int total_loading_size = ao_app->char_list_size * 2 +
ao_app->evidence_list_size +
ao_app->music_list_size;
int loading_value =
int(((ao_app->loaded_chars + ao_app->generated_chars +
ao_app->loaded_music + ao_app->loaded_evidence) /
static_cast<double>(total_loading_size)) *
100);
ao_app->w_lobby->set_loading_value(loading_value);
ao_app->w_lobby->set_loading_text(
tr("Generating chars:\n%1/%2").arg(
QString::number(ao_app->generated_chars),
QString::number(ao_app->char_list_size)));
} }
} }
ui_char_list->expandAll(); ui_char_list->expandAll();

View File

@ -1,4 +1,5 @@
#include "courtroom.h" #include "courtroom.h"
#include "options.h"
Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
{ {
@ -52,6 +53,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_vp_background->setObjectName("ui_vp_background"); ui_vp_background->setObjectName("ui_vp_background");
ui_vp_speedlines = new SplashLayer(ui_viewport, ao_app); ui_vp_speedlines = new SplashLayer(ui_viewport, ao_app);
ui_vp_speedlines->setObjectName("ui_vp_speedlines"); ui_vp_speedlines->setObjectName("ui_vp_speedlines");
ui_vp_speedlines->stretch = true;
ui_vp_player_char = new CharLayer(ui_viewport, ao_app); ui_vp_player_char = new CharLayer(ui_viewport, ao_app);
ui_vp_player_char->setObjectName("ui_vp_player_char"); ui_vp_player_char->setObjectName("ui_vp_player_char");
ui_vp_player_char->masked = false; ui_vp_player_char->masked = false;
@ -114,15 +116,15 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_ic_chatlog->setReadOnly(true); ui_ic_chatlog->setReadOnly(true);
ui_ic_chatlog->setObjectName("ui_ic_chatlog"); ui_ic_chatlog->setObjectName("ui_ic_chatlog");
log_maximum_blocks = ao_app->get_max_log_size(); log_maximum_blocks = Options::getInstance().maxLogSize();
log_goes_downwards = ao_app->get_log_goes_downwards(); log_goes_downwards = Options::getInstance().logDirectionDownwards();
log_colors = ao_app->is_colorlog_enabled(); log_colors = Options::getInstance().colorLogEnabled();
log_newline = ao_app->get_log_newline(); log_newline = Options::getInstance().logNewline();
log_margin = ao_app->get_log_margin(); log_margin = Options::getInstance().logMargin();
log_timestamp = ao_app->get_log_timestamp(); log_timestamp = Options::getInstance().logTimestampEnabled();
log_timestamp_format = ao_app->get_log_timestamp_format(); log_timestamp_format = Options::getInstance().logTimestampFormat();
ui_debug_log = new AOTextArea(this, ao_app->get_max_log_size()); ui_debug_log = new AOTextArea(this, Options::getInstance().maxLogSize());
ui_debug_log->setReadOnly(true); ui_debug_log->setReadOnly(true);
ui_debug_log->setOpenExternalLinks(true); ui_debug_log->setOpenExternalLinks(true);
ui_debug_log->hide(); ui_debug_log->hide();
@ -176,7 +178,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_ic_chat_name = new QLineEdit(this); ui_ic_chat_name = new QLineEdit(this);
ui_ic_chat_name->setFrame(false); ui_ic_chat_name->setFrame(false);
ui_ic_chat_name->setPlaceholderText(tr("Showname")); ui_ic_chat_name->setPlaceholderText(tr("Showname"));
ui_ic_chat_name->setText(p_ao_app->get_default_showname()); ui_ic_chat_name->setText(Options::getInstance().shownameOnJoin());
ui_ic_chat_name->setObjectName("ui_ic_chat_name"); ui_ic_chat_name->setObjectName("ui_ic_chat_name");
ui_ic_chat_message = new QLineEdit(this); ui_ic_chat_message = new QLineEdit(this);
@ -200,7 +202,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_ooc_chat_name->setFrame(false); ui_ooc_chat_name->setFrame(false);
ui_ooc_chat_name->setPlaceholderText(tr("Name")); ui_ooc_chat_name->setPlaceholderText(tr("Name"));
ui_ooc_chat_name->setMaxLength(30); ui_ooc_chat_name->setMaxLength(30);
ui_ooc_chat_name->setText(p_ao_app->get_default_username()); ui_ooc_chat_name->setText(Options::getInstance().username());
ui_ooc_chat_name->setObjectName("ui_ooc_chat_name"); ui_ooc_chat_name->setObjectName("ui_ooc_chat_name");
// ui_area_password = new QLineEdit(this); // ui_area_password = new QLineEdit(this);
@ -290,9 +292,6 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_settings = new AOButton(this, ao_app); ui_settings = new AOButton(this, ao_app);
ui_settings->setObjectName("ui_settings"); ui_settings->setObjectName("ui_settings");
ui_announce_casing = new AOButton(this, ao_app);
ui_announce_casing->setObjectName("ui_announce_casing");
ui_switch_area_music = new AOButton(this, ao_app); ui_switch_area_music = new AOButton(this, ao_app);
ui_switch_area_music->setObjectName("ui_switch_area_music"); ui_switch_area_music->setObjectName("ui_switch_area_music");
@ -315,14 +314,8 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_additive->hide(); ui_additive->hide();
ui_additive->setObjectName("ui_additive"); ui_additive->setObjectName("ui_additive");
ui_casing = new QCheckBox(this);
ui_casing->setChecked(ao_app->get_casing_enabled());
ui_casing->setText(tr("Casing"));
ui_casing->hide();
ui_casing->setObjectName("ui_casing");
ui_showname_enable = new QCheckBox(this); ui_showname_enable = new QCheckBox(this);
ui_showname_enable->setChecked(ao_app->get_showname_enabled_by_default()); ui_showname_enable->setChecked(Options::getInstance().customShownameEnabled());
ui_showname_enable->setText(tr("Shownames")); ui_showname_enable->setText(tr("Shownames"));
ui_showname_enable->setObjectName("ui_showname_enable"); ui_showname_enable->setObjectName("ui_showname_enable");
@ -365,17 +358,17 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_music_slider = new QSlider(Qt::Horizontal, this); ui_music_slider = new QSlider(Qt::Horizontal, this);
ui_music_slider->setRange(0, 100); ui_music_slider->setRange(0, 100);
ui_music_slider->setValue(ao_app->get_default_music()); ui_music_slider->setValue(Options::getInstance().musicVolume());
ui_music_slider->setObjectName("ui_music_slider"); ui_music_slider->setObjectName("ui_music_slider");
ui_sfx_slider = new QSlider(Qt::Horizontal, this); ui_sfx_slider = new QSlider(Qt::Horizontal, this);
ui_sfx_slider->setRange(0, 100); ui_sfx_slider->setRange(0, 100);
ui_sfx_slider->setValue(ao_app->get_default_sfx()); ui_sfx_slider->setValue(Options::getInstance().sfxVolume());
ui_sfx_slider->setObjectName("ui_sfx_slider"); ui_sfx_slider->setObjectName("ui_sfx_slider");
ui_blip_slider = new QSlider(Qt::Horizontal, this); ui_blip_slider = new QSlider(Qt::Horizontal, this);
ui_blip_slider->setRange(0, 100); ui_blip_slider->setRange(0, 100);
ui_blip_slider->setValue(ao_app->get_default_blip()); ui_blip_slider->setValue(Options::getInstance().blipVolume());
ui_blip_slider->setObjectName("ui_blip_slider"); ui_blip_slider->setObjectName("ui_blip_slider");
ui_mute_list = new QListWidget(this); ui_mute_list = new QListWidget(this);
@ -539,8 +532,6 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
&Courtroom::on_reload_theme_clicked); &Courtroom::on_reload_theme_clicked);
connect(ui_call_mod, &AOButton::clicked, this, &Courtroom::on_call_mod_clicked); connect(ui_call_mod, &AOButton::clicked, this, &Courtroom::on_call_mod_clicked);
connect(ui_settings, &AOButton::clicked, this, &Courtroom::on_settings_clicked); connect(ui_settings, &AOButton::clicked, this, &Courtroom::on_settings_clicked);
connect(ui_announce_casing, &AOButton::clicked, this,
&Courtroom::on_announce_casing_clicked);
connect(ui_switch_area_music, &AOButton::clicked, this, connect(ui_switch_area_music, &AOButton::clicked, this,
&Courtroom::on_switch_area_music_clicked); &Courtroom::on_switch_area_music_clicked);
@ -548,7 +539,6 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
connect(ui_flip, &AOButton::clicked, this, &Courtroom::on_flip_clicked); connect(ui_flip, &AOButton::clicked, this, &Courtroom::on_flip_clicked);
connect(ui_additive, &AOButton::clicked, this, &Courtroom::on_additive_clicked); connect(ui_additive, &AOButton::clicked, this, &Courtroom::on_additive_clicked);
connect(ui_guard, &AOButton::clicked, this, &Courtroom::on_guard_clicked); connect(ui_guard, &AOButton::clicked, this, &Courtroom::on_guard_clicked);
connect(ui_casing, &AOButton::clicked, this, &Courtroom::on_casing_clicked);
connect(ui_showname_enable, &AOButton::clicked, this, connect(ui_showname_enable, &AOButton::clicked, this,
&Courtroom::on_showname_enable_clicked); &Courtroom::on_showname_enable_clicked);
@ -584,7 +574,7 @@ void Courtroom::on_application_state_changed(Qt::ApplicationState state)
suppress_audio = 0; suppress_audio = 0;
if (state != Qt::ApplicationActive) { if (state != Qt::ApplicationActive) {
// Suppressed audio setting // Suppressed audio setting
suppress_audio = ao_app->get_default_suppress_audio(); suppress_audio = Options::getInstance().defaultSuppressAudio();
} }
update_audio_volume(); update_audio_volume();
} }
@ -668,9 +658,6 @@ void Courtroom::set_pair_list()
void Courtroom::set_widgets() void Courtroom::set_widgets()
{ {
QString filename = "courtroom_design.ini"; QString filename = "courtroom_design.ini";
// Update the default theme from the courtroom_design.ini, if it's not defined it will be 'default'.
QSettings settings(ao_app->get_real_path(ao_app->get_theme_path(filename, ao_app->current_theme)), QSettings::IniFormat);
ao_app->default_theme = settings.value("default_theme", "default").toString();
set_fonts(); set_fonts();
set_size_and_pos(ui_viewport, "viewport"); set_size_and_pos(ui_viewport, "viewport");
@ -693,15 +680,6 @@ void Courtroom::set_widgets()
ui_ic_chat_name->setEnabled(false); ui_ic_chat_name->setEnabled(false);
} }
if (ao_app->casing_alerts_supported) {
ui_announce_casing->show();
ui_casing->show();
}
else {
ui_announce_casing->hide();
ui_casing->hide();
}
// We also show the non-server-dependent client additions. // We also show the non-server-dependent client additions.
// Once again, if the theme can't display it, set_move_and_pos will catch // Once again, if the theme can't display it, set_move_and_pos will catch
// them. // them.
@ -748,20 +726,20 @@ void Courtroom::set_widgets()
ui_vp_objection->move_and_center(ui_viewport->x(), ui_viewport->y()); ui_vp_objection->move_and_center(ui_viewport->x(), ui_viewport->y());
ui_vp_objection->combo_resize(ui_viewport->width(), ui_viewport->height()); ui_vp_objection->combo_resize(ui_viewport->width(), ui_viewport->height());
log_maximum_blocks = ao_app->get_max_log_size(); log_maximum_blocks = Options::getInstance().maxLogSize();
bool regenerate = log_goes_downwards != ao_app->get_log_goes_downwards() || bool regenerate = log_goes_downwards != Options::getInstance().logDirectionDownwards() ||
log_colors != ao_app->is_colorlog_enabled() || log_colors != Options::getInstance().colorLogEnabled() ||
log_newline != ao_app->get_log_newline() || log_newline != Options::getInstance().logNewline() ||
log_margin != ao_app->get_log_margin() || log_margin != Options::getInstance().logMargin() ||
log_timestamp != ao_app->get_log_timestamp() || log_timestamp != Options::getInstance().logTimestampEnabled() ||
log_timestamp_format != ao_app->get_log_timestamp_format(); log_timestamp_format != Options::getInstance().logTimestampFormat();
log_goes_downwards = ao_app->get_log_goes_downwards(); log_goes_downwards = Options::getInstance().logDirectionDownwards();
log_colors = ao_app->is_colorlog_enabled(); log_colors = Options::getInstance().colorLogEnabled();
log_newline = ao_app->get_log_newline(); log_newline = Options::getInstance().logNewline();
log_margin = ao_app->get_log_margin(); log_margin = Options::getInstance().logMargin();
log_timestamp = ao_app->get_log_timestamp(); log_timestamp = Options::getInstance().logTimestampEnabled();
log_timestamp_format = ao_app->get_log_timestamp_format(); log_timestamp_format = Options::getInstance().logTimestampFormat();
if (regenerate) { if (regenerate) {
regenerate_ic_chatlog(); regenerate_ic_chatlog();
} }
@ -1014,13 +992,6 @@ void Courtroom::set_widgets()
ui_settings->setToolTip( ui_settings->setToolTip(
tr("Allows you to change various aspects of the client.")); tr("Allows you to change various aspects of the client."));
set_size_and_pos(ui_announce_casing, "casing_button");
ui_announce_casing->setText(tr("Casing"));
ui_announce_casing->set_image("casing_button");
ui_announce_casing->setToolTip(
tr("An interface to help you announce a case (you have to be a CM first "
"to be able to announce cases)"));
set_size_and_pos(ui_switch_area_music, "switch_area_music"); set_size_and_pos(ui_switch_area_music, "switch_area_music");
ui_switch_area_music->setText(tr("A/M")); ui_switch_area_music->setText(tr("A/M"));
ui_switch_area_music->set_image("switch_area_music"); ui_switch_area_music->set_image("switch_area_music");
@ -1061,10 +1032,6 @@ void Courtroom::set_widgets()
tr("Do not listen to mod calls when checked, preventing them from " tr("Do not listen to mod calls when checked, preventing them from "
"playing sounds or focusing attention on the window.")); "playing sounds or focusing attention on the window."));
set_size_and_pos(ui_casing, "casing");
ui_casing->setToolTip(tr("Lets you receive case alerts when enabled.\n"
"(You can set your preferences in the Settings!)"));
set_size_and_pos(ui_showname_enable, "showname_enable"); set_size_and_pos(ui_showname_enable, "showname_enable");
ui_showname_enable->setToolTip( ui_showname_enable->setToolTip(
tr("Display customized shownames for all users when checked.")); tr("Display customized shownames for all users when checked."));
@ -1390,7 +1357,7 @@ void Courtroom::set_background(QString p_background, bool display)
ui_vp_message->hide(); ui_vp_message->hide();
ui_vp_chatbox->setVisible(chatbox_always_show); ui_vp_chatbox->setVisible(chatbox_always_show);
// Show it if chatbox always shows // Show it if chatbox always shows
if (ao_app->is_sticker_enabled() && chatbox_always_show) { if (Options::getInstance().characterStickerEnabled() && chatbox_always_show) {
ui_vp_sticker->load_image(m_chatmessage[CHAR_NAME]); ui_vp_sticker->load_image(m_chatmessage[CHAR_NAME]);
} }
// Hide the face sticker // Hide the face sticker
@ -1412,9 +1379,7 @@ void Courtroom::set_background(QString p_background, bool display)
QString f_side = current_side; QString f_side = current_side;
if (current_side == "") if (current_side == "")
f_side = ao_app->get_char_side(current_char); f_side = ao_app->get_char_side(current_char);
set_scene( set_scene(true, f_side);
QString::number(ao_app->get_desk_mod(current_char, current_emote)),
f_side);
} }
} }
@ -1486,7 +1451,7 @@ void Courtroom::update_character(int p_cid, QString char_name, bool reset_emote)
QString f_char; QString f_char;
if (m_cid == -1) { if (m_cid == -1) {
if (ao_app->is_discord_enabled()) if (Options::getInstance().discordEnabled())
ao_app->discord->state_spectate(); ao_app->discord->state_spectate();
f_char = ""; f_char = "";
} }
@ -1496,7 +1461,7 @@ void Courtroom::update_character(int p_cid, QString char_name, bool reset_emote)
f_char = char_list.at(m_cid).name; f_char = char_list.at(m_cid).name;
} }
if (ao_app->is_discord_enabled()) if (Options::getInstance().discordEnabled())
ao_app->discord->state_character(f_char.toStdString()); ao_app->discord->state_character(f_char.toStdString());
} }
@ -1602,11 +1567,6 @@ void Courtroom::enter_courtroom()
else else
ui_additive->hide(); ui_additive->hide();
if (ao_app->casing_alerts_supported)
ui_casing->show();
else
ui_casing->hide();
list_music(); list_music();
list_areas(); list_areas();
@ -1775,6 +1735,7 @@ void Courtroom::list_areas()
void Courtroom::debug_message_handler(QtMsgType type, const QMessageLogContext &context, void Courtroom::debug_message_handler(QtMsgType type, const QMessageLogContext &context,
const QString &msg) const QString &msg)
{ {
Q_UNUSED(context);
const QMap<QtMsgType, QString> colors = { const QMap<QtMsgType, QString> colors = {
{QtDebugMsg, "debug"}, {QtDebugMsg, "debug"},
{QtInfoMsg, "info"}, {QtInfoMsg, "info"},
@ -1814,7 +1775,7 @@ void Courtroom::append_server_chatmessage(QString p_name, QString p_message,
ui_server_chatlog->append_chatmessage(p_name, p_message, color); ui_server_chatlog->append_chatmessage(p_name, p_message, color);
if (ao_app->get_text_logging_enabled() && !ao_app->log_filename.isEmpty()) { if (Options::getInstance().logToTextFileEnabled() && !ao_app->log_filename.isEmpty()) {
QString full = "[OOC][" + QDateTime::currentDateTimeUtc().toString() + "] " + p_name + ": " + p_message; QString full = "[OOC][" + QDateTime::currentDateTimeUtc().toString() + "] " + p_name + ": " + p_message;
ao_app->append_to_file(full, ao_app->log_filename, true); ao_app->append_to_file(full, ao_app->log_filename, true);
} }
@ -1841,7 +1802,7 @@ void Courtroom::on_chat_return_pressed()
return; return;
ui_ic_chat_message->blockSignals(true); ui_ic_chat_message->blockSignals(true);
QTimer::singleShot(ao_app->get_chat_ratelimit(), this, QTimer::singleShot(Options::getInstance().chatRateLimit(), this,
[this] { ui_ic_chat_message->blockSignals(false); }); [this] { ui_ic_chat_message->blockSignals(false); });
// MS# // MS#
// deskmod# // deskmod#
@ -1875,22 +1836,21 @@ void Courtroom::on_chat_return_pressed()
else else
f_side = current_side; f_side = current_side;
QString f_desk_mod = "chat"; int f_desk_mod = DESK_SHOW;
if (ao_app->desk_mod_supported) { if (ao_app->desk_mod_supported) {
f_desk_mod = f_desk_mod = ao_app->get_desk_mod(current_char, current_emote);
QString::number(ao_app->get_desk_mod(current_char, current_emote));
if (!ao_app->expanded_desk_mods_supported) { if (!ao_app->expanded_desk_mods_supported) {
if (f_desk_mod == "2" || f_desk_mod == "4") if (f_desk_mod == DESK_PRE_ONLY_EX || f_desk_mod == DESK_PRE_ONLY)
f_desk_mod = "0"; f_desk_mod = DESK_HIDE;
else if (f_desk_mod == "3" || f_desk_mod == "5") else if (f_desk_mod == DESK_EMOTE_ONLY_EX || f_desk_mod == DESK_EMOTE_ONLY)
f_desk_mod = "1"; f_desk_mod = DESK_SHOW;
} }
if (f_desk_mod == "-1") if (f_desk_mod == -1)
f_desk_mod = "chat"; f_desk_mod = DESK_SHOW;
} }
packet_contents.append(f_desk_mod); packet_contents.append(QString::number(f_desk_mod));
QString f_pre = ao_app->get_pre_emote(current_char, current_emote); QString f_pre = ao_app->get_pre_emote(current_char, current_emote);
int f_emote_mod = ao_app->get_emote_mod(current_char, current_emote); int f_emote_mod = ao_app->get_emote_mod(current_char, current_emote);
@ -1945,7 +1905,7 @@ void Courtroom::on_chat_return_pressed()
f_sfx = get_char_sfx(); f_sfx = get_char_sfx();
// We have a custom sfx but we're on idle emotes. // We have a custom sfx but we're on idle emotes.
// Turn them into pre so the sound plays if client setting sfx_on_idle is enabled. // Turn them into pre so the sound plays if client setting sfx_on_idle is enabled.
if (ao_app->get_sfx_on_idle() && (f_emote_mod == IDLE || f_emote_mod == ZOOM)) { if (Options::getInstance().playSelectedSFXOnIdle() && (f_emote_mod == IDLE || f_emote_mod == ZOOM)) {
// We turn idle into preanim, but make it not send a pre animation // We turn idle into preanim, but make it not send a pre animation
f_pre = ""; f_pre = "";
// Set sfx delay to 0 so the sfx plays immediately // Set sfx delay to 0 so the sfx plays immediately
@ -1985,7 +1945,7 @@ void Courtroom::on_chat_return_pressed()
f_obj_state = QString::number(objection_state); f_obj_state = QString::number(objection_state);
// We're doing an Objection (custom objections not yet supported) // We're doing an Objection (custom objections not yet supported)
if (objection_state == 2 && ao_app->objection_stop_music()) if (objection_state == 2 && Options::getInstance().objectionStopMusic())
music_stop(true); music_stop(true);
packet_contents.append(f_obj_state); packet_contents.append(f_obj_state);
@ -2078,7 +2038,7 @@ void Courtroom::on_chat_return_pressed()
QString packet; QString packet;
foreach (QString f_emote, emotes_to_check) { foreach (QString f_emote, emotes_to_check) {
packet += f_emote; packet += f_emote;
if (ao_app->is_frame_network_enabled()) { if (Options::getInstance().networkedFrameSfxEnabled()) {
QString sfx_frames = QString sfx_frames =
ao_app ao_app
->read_ini_tags( ->read_ini_tags(
@ -2109,7 +2069,7 @@ void Courtroom::on_chat_return_pressed()
} }
packet_contents.append(effect + "|" + p_effect_folder + "|" + fx_sound); packet_contents.append(effect + "|" + p_effect_folder + "|" + fx_sound);
if (!ao_app->is_stickyeffects_enabled() && !ao_app->get_effect_property(effect, current_char, p_effect_folder, "sticky").startsWith("true")) { if (!Options::getInstance().clearEffectsDropdownOnPlayEnabled() && !ao_app->get_effect_property(effect, current_char, p_effect_folder, "sticky").startsWith("true")) {
ui_effects_dropdown->blockSignals(true); ui_effects_dropdown->blockSignals(true);
ui_effects_dropdown->setCurrentIndex(0); ui_effects_dropdown->setCurrentIndex(0);
ui_effects_dropdown->blockSignals(false); ui_effects_dropdown->blockSignals(false);
@ -2138,14 +2098,14 @@ void Courtroom::reset_ui()
ui_evidence_present->set_image("present"); ui_evidence_present->set_image("present");
// If sticky sounds is disabled and we either have SFX on Idle enabled, or our Preanim checkbox is checked // If sticky sounds is disabled and we either have SFX on Idle enabled, or our Preanim checkbox is checked
if (!ao_app->is_stickysounds_enabled() && (ao_app->get_sfx_on_idle() || ui_pre->isChecked())) { if (!Options::getInstance().clearSoundsDropdownOnPlayEnabled() && (Options::getInstance().playSelectedSFXOnIdle() || ui_pre->isChecked())) {
// Reset the SFX Dropdown to "Default" // Reset the SFX Dropdown to "Default"
ui_sfx_dropdown->setCurrentIndex(0); ui_sfx_dropdown->setCurrentIndex(0);
ui_sfx_remove->hide(); ui_sfx_remove->hide();
custom_sfx = ""; custom_sfx = "";
} }
// If sticky preanims is disabled // If sticky preanims is disabled
if (!ao_app->is_stickypres_enabled()) if (!Options::getInstance().clearPreOnPlayEnabled())
// Turn off our Preanim checkbox // Turn off our Preanim checkbox
ui_pre->setChecked(false); ui_pre->setChecked(false);
} }
@ -2190,17 +2150,17 @@ void Courtroom::chatmessage_enqueue(QStringList p_contents)
reset_ui(); reset_ui();
} }
// If we determine we sent this message, or we have desync enabled // If we determine we sent this message, or we have desync enabled
if (sender || ao_app->is_desyncrhonized_logs_enabled()) { if (sender || Options::getInstance().desynchronisedLogsEnabled()) {
// Initialize operation "message queue ghost" // Initialize operation "message queue ghost"
log_chatmessage(p_contents[MESSAGE], p_contents[CHAR_ID].toInt(), log_chatmessage(p_contents[MESSAGE], p_contents[CHAR_ID].toInt(),
p_contents[SHOWNAME], p_contents[CHAR_NAME], p_contents[SHOWNAME], p_contents[CHAR_NAME],
p_contents[OBJECTION_MOD], p_contents[EVIDENCE_ID].toInt(), p_contents[OBJECTION_MOD], p_contents[EVIDENCE_ID].toInt(),
p_contents[TEXT_COLOR].toInt(), QUEUED, sender || ao_app->is_desyncrhonized_logs_enabled()); p_contents[TEXT_COLOR].toInt(), QUEUED, sender || Options::getInstance().desynchronisedLogsEnabled());
} }
bool is_objection = false; bool is_objection = false;
// If the user wants to clear queue on objection // If the user wants to clear queue on objection
if (ao_app->is_instant_objection_enabled()) if (Options::getInstance().objectionSkipQueueEnabled())
{ {
int objection_mod = p_contents[OBJECTION_MOD].split("&")[0].toInt(); int objection_mod = p_contents[OBJECTION_MOD].split("&")[0].toInt();
is_objection = objection_mod >= 1 && objection_mod <= 5; is_objection = objection_mod >= 1 && objection_mod <= 5;
@ -2217,7 +2177,7 @@ void Courtroom::chatmessage_enqueue(QStringList p_contents)
chatmessage_queue.enqueue(p_contents); chatmessage_queue.enqueue(p_contents);
// Our settings disabled queue, or no message is being parsed right now and we're not waiting on one // Our settings disabled queue, or no message is being parsed right now and we're not waiting on one
bool start_queue = ao_app->stay_time() <= 0 || (text_state >= 2 && !text_queue_timer->isActive()); bool start_queue = Options::getInstance().textStayTime() <= 0 || (text_state >= 2 && !text_queue_timer->isActive());
// Objections also immediately play the message // Objections also immediately play the message
if (start_queue || is_objection) if (start_queue || is_objection)
chatmessage_dequeue(); // Process the message instantly chatmessage_dequeue(); // Process the message instantly
@ -2242,7 +2202,7 @@ void Courtroom::skip_chatmessage_queue()
while (!chatmessage_queue.isEmpty()) { while (!chatmessage_queue.isEmpty()) {
QStringList p_contents = chatmessage_queue.dequeue(); QStringList p_contents = chatmessage_queue.dequeue();
// if the char ID matches our client's char ID (most likely, this is our message coming back to us) // if the char ID matches our client's char ID (most likely, this is our message coming back to us)
bool sender = ao_app->is_desyncrhonized_logs_enabled() || p_contents[CHAR_ID].toInt() == m_cid; bool sender = Options::getInstance().desynchronisedLogsEnabled() || p_contents[CHAR_ID].toInt() == m_cid;
log_chatmessage(p_contents[MESSAGE], p_contents[CHAR_ID].toInt(), p_contents[SHOWNAME], p_contents[CHAR_NAME], p_contents[OBJECTION_MOD], p_contents[EVIDENCE_ID].toInt(), p_contents[TEXT_COLOR].toInt(), DISPLAY_ONLY, sender); log_chatmessage(p_contents[MESSAGE], p_contents[CHAR_ID].toInt(), p_contents[SHOWNAME], p_contents[CHAR_NAME], p_contents[OBJECTION_MOD], p_contents[EVIDENCE_ID].toInt(), p_contents[TEXT_COLOR].toInt(), DISPLAY_ONLY, sender);
} }
} }
@ -2265,7 +2225,7 @@ void Courtroom::unpack_chatmessage(QStringList p_contents)
} }
// if the char ID matches our client's char ID (most likely, this is our message coming back to us) // if the char ID matches our client's char ID (most likely, this is our message coming back to us)
bool sender = ao_app->is_desyncrhonized_logs_enabled() || m_chatmessage[CHAR_ID].toInt() == m_cid; bool sender = Options::getInstance().desynchronisedLogsEnabled() || m_chatmessage[CHAR_ID].toInt() == m_cid;
// We have logs displaying as soon as we reach the message in our queue, which is a less confusing but also less accurate experience for the user. // We have logs displaying as soon as we reach the message in our queue, which is a less confusing but also less accurate experience for the user.
log_chatmessage(m_chatmessage[MESSAGE], m_chatmessage[CHAR_ID].toInt(), m_chatmessage[SHOWNAME], m_chatmessage[CHAR_NAME], m_chatmessage[OBJECTION_MOD], m_chatmessage[EVIDENCE_ID].toInt(), m_chatmessage[TEXT_COLOR].toInt(), DISPLAY_ONLY, sender); log_chatmessage(m_chatmessage[MESSAGE], m_chatmessage[CHAR_ID].toInt(), m_chatmessage[SHOWNAME], m_chatmessage[CHAR_NAME], m_chatmessage[OBJECTION_MOD], m_chatmessage[EVIDENCE_ID].toInt(), m_chatmessage[TEXT_COLOR].toInt(), DISPLAY_ONLY, sender);
@ -2501,19 +2461,17 @@ void Courtroom::display_character()
ui_vp_message->hide(); ui_vp_message->hide();
ui_vp_chatbox->setVisible(chatbox_always_show); ui_vp_chatbox->setVisible(chatbox_always_show);
// Show it if chatbox always shows // Show it if chatbox always shows
if (ao_app->is_sticker_enabled() && chatbox_always_show) { if (Options::getInstance().characterStickerEnabled() && chatbox_always_show) {
ui_vp_sticker->load_image(m_chatmessage[CHAR_NAME]); ui_vp_sticker->load_image(m_chatmessage[CHAR_NAME]);
} }
// Hide the face sticker // Hide the face sticker
else { else {
ui_vp_sticker->stop(); ui_vp_sticker->stop();
} }
// Initialize the correct pos (called SIDE here for some reason) with DESK_MOD to determine if we should hide the desk or not.
set_scene(m_chatmessage[DESK_MOD], m_chatmessage[SIDE]);
// Arrange the netstrings of the frame SFX for the character to know about // Arrange the netstrings of the frame SFX for the character to know about
if (!m_chatmessage[FRAME_SFX].isEmpty() && if (!m_chatmessage[FRAME_SFX].isEmpty() &&
ao_app->is_frame_network_enabled()) { Options::getInstance().networkedFrameSfxEnabled()) {
// ORDER IS IMPORTANT!! // ORDER IS IMPORTANT!!
QStringList netstrings = {m_chatmessage[FRAME_SCREENSHAKE], QStringList netstrings = {m_chatmessage[FRAME_SCREENSHAKE],
m_chatmessage[FRAME_REALIZATION], m_chatmessage[FRAME_REALIZATION],
@ -2672,7 +2630,7 @@ void Courtroom::handle_ic_message()
} }
// if we have instant objections disabled, and queue is not empty, check if next message after this is an objection. // if we have instant objections disabled, and queue is not empty, check if next message after this is an objection.
if (!ao_app->is_instant_objection_enabled() && chatmessage_queue.size() > 0) if (!Options::getInstance().objectionSkipQueueEnabled() && chatmessage_queue.size() > 0)
{ {
QStringList p_contents = chatmessage_queue.head(); QStringList p_contents = chatmessage_queue.head();
int objection_mod = p_contents[OBJECTION_MOD].split("&")[0].toInt(); int objection_mod = p_contents[OBJECTION_MOD].split("&")[0].toInt();
@ -2685,7 +2643,7 @@ void Courtroom::handle_ic_message()
void Courtroom::do_screenshake() void Courtroom::do_screenshake()
{ {
if (!ao_app->is_shake_enabled()) if (!Options::getInstance().shakeEnabled())
return; return;
// This way, the animation is reset in such a way that last played screenshake // This way, the animation is reset in such a way that last played screenshake
@ -2734,7 +2692,7 @@ void Courtroom::do_screenshake()
void Courtroom::do_flash() void Courtroom::do_flash()
{ {
if (!ao_app->is_effects_enabled()) if (!Options::getInstance().effectsEnabled())
return; return;
QString f_char = m_chatmessage[CHAR_NAME]; QString f_char = m_chatmessage[CHAR_NAME];
@ -2758,7 +2716,7 @@ void Courtroom::do_effect(QString fx_path, QString fx_sound, QString p_char,
} }
// Only check if effects are disabled after playing the sound if it exists // Only check if effects are disabled after playing the sound if it exists
if (!ao_app->is_effects_enabled()) { if (!Options::getInstance().effectsEnabled()) {
return; return;
} }
ui_vp_effect->transform_mode = ao_app->get_scaling( ui_vp_effect->transform_mode = ao_app->get_scaling(
@ -2855,7 +2813,7 @@ void Courtroom::initialize_chatbox()
ui_vp_showname->setText(m_chatmessage[SHOWNAME]); ui_vp_showname->setText(m_chatmessage[SHOWNAME]);
} }
QString customchar; QString customchar;
if (ao_app->is_customchat_enabled()) if (Options::getInstance().customChatboxEnabled())
customchar = m_chatmessage[CHAR_NAME]; customchar = m_chatmessage[CHAR_NAME];
QString p_misc = ao_app->get_chat(customchar); QString p_misc = ao_app->get_chat(customchar);
@ -2966,8 +2924,8 @@ void Courtroom::handle_callwords()
{ {
// Quickly check through the message for the word_call (callwords) sfx // Quickly check through the message for the word_call (callwords) sfx
QString f_message = m_chatmessage[MESSAGE]; QString f_message = m_chatmessage[MESSAGE];
// Obtain the current call words (Really? It does File I/O on every single message???) //No more file IO on every message.
QStringList call_words = ao_app->get_call_words(); QStringList call_words = Options::getInstance().callwords();
// Loop through each word in the call words list // Loop through each word in the call words list
for (const QString &word : qAsConst(call_words)) { for (const QString &word : qAsConst(call_words)) {
// If our message contains that specific call word // If our message contains that specific call word
@ -3297,7 +3255,7 @@ void Courtroom::log_ic_text(QString p_name, QString p_showname,
{ {
chatlogpiece log_entry(p_name, p_showname, p_message, p_action, p_color, p_selfname); chatlogpiece log_entry(p_name, p_showname, p_message, p_action, p_color, p_selfname);
ic_chatlog_history.append(log_entry); ic_chatlog_history.append(log_entry);
if (ao_app->get_text_logging_enabled() && !ao_app->log_filename.isEmpty()) if (Options::getInstance().logToTextFileEnabled() && !ao_app->log_filename.isEmpty())
ao_app->append_to_file(log_entry.get_full(), ao_app->log_filename, true); ao_app->append_to_file(log_entry.get_full(), ao_app->log_filename, true);
while (ic_chatlog_history.size() > log_maximum_blocks && while (ic_chatlog_history.size() > log_maximum_blocks &&
@ -3512,20 +3470,20 @@ void Courtroom::play_preanim(bool immediate)
ui_vp_player_char->set_play_once(true); ui_vp_player_char->set_play_once(true);
ui_vp_player_char->load_image(f_preanim, f_char, preanim_duration, true); ui_vp_player_char->load_image(f_preanim, f_char, preanim_duration, true);
switch(m_chatmessage[DESK_MOD].toInt()) { switch (m_chatmessage[DESK_MOD].toInt()) {
case 4: case DESK_EMOTE_ONLY_EX:
ui_vp_sideplayer_char->hide(); ui_vp_sideplayer_char->hide();
ui_vp_player_char->move_and_center(0, 0); ui_vp_player_char->move_and_center(0, 0);
[[fallthrough]]; [[fallthrough]];
case 2: case DESK_EMOTE_ONLY:
set_scene("0", m_chatmessage[SIDE]); case DESK_HIDE:
set_scene(false, m_chatmessage[SIDE]);
break; break;
case 5:
case 3: case DESK_PRE_ONLY_EX:
set_scene("1", m_chatmessage[SIDE]); case DESK_PRE_ONLY:
break; case DESK_SHOW:
default: set_scene(true, m_chatmessage[SIDE]);
set_scene(m_chatmessage[DESK_MOD], m_chatmessage[SIDE]);
break; break;
} }
@ -3563,21 +3521,21 @@ void Courtroom::start_chat_ticking()
// handle expanded desk mods // handle expanded desk mods
switch(m_chatmessage[DESK_MOD].toInt()) { switch(m_chatmessage[DESK_MOD].toInt()) {
case 4: case DESK_EMOTE_ONLY_EX:
set_self_offset(m_chatmessage[SELF_OFFSET]); set_self_offset(m_chatmessage[SELF_OFFSET]);
[[fallthrough]]; [[fallthrough]];
case 2: case DESK_EMOTE_ONLY:
set_scene("1", m_chatmessage[SIDE]); case DESK_SHOW:
set_scene(true, m_chatmessage[SIDE]);
break; break;
case 5:
case DESK_PRE_ONLY_EX:
ui_vp_sideplayer_char->hide(); ui_vp_sideplayer_char->hide();
ui_vp_player_char->move_and_center(0, 0); ui_vp_player_char->move_and_center(0, 0);
[[fallthrough]]; [[fallthrough]];
case 3: case DESK_PRE_ONLY:
set_scene("0", m_chatmessage[SIDE]); case DESK_HIDE:
break; set_scene(false, m_chatmessage[SIDE]);
default:
set_scene(m_chatmessage[DESK_MOD], m_chatmessage[SIDE]);
break; break;
} }
@ -3616,7 +3574,7 @@ void Courtroom::start_chat_ticking()
ui_vp_chatbox->setVisible(chatbox_always_show); ui_vp_chatbox->setVisible(chatbox_always_show);
ui_vp_message->hide(); ui_vp_message->hide();
// Show it if chatbox always shows // Show it if chatbox always shows
if (ao_app->is_sticker_enabled() && chatbox_always_show) if (Options::getInstance().characterStickerEnabled() && chatbox_always_show)
ui_vp_sticker->load_image(m_chatmessage[CHAR_NAME]); ui_vp_sticker->load_image(m_chatmessage[CHAR_NAME]);
// Hide the face sticker // Hide the face sticker
else { else {
@ -3624,7 +3582,7 @@ void Courtroom::start_chat_ticking()
} }
} }
// If we're not already waiting on the next message, start the timer. We could be overriden if there's an objection planned. // If we're not already waiting on the next message, start the timer. We could be overriden if there's an objection planned.
int delay = ao_app->stay_time(); int delay = Options::getInstance().textStayTime();
if (delay > 0 && !text_queue_timer->isActive()) if (delay > 0 && !text_queue_timer->isActive())
text_queue_timer->start(delay); text_queue_timer->start(delay);
return; return;
@ -3633,7 +3591,7 @@ void Courtroom::start_chat_ticking()
ui_vp_chatbox->show(); ui_vp_chatbox->show();
ui_vp_message->show(); ui_vp_message->show();
if (ao_app->is_sticker_enabled()) if (Options::getInstance().characterStickerEnabled())
ui_vp_sticker->load_image(m_chatmessage[CHAR_NAME]); ui_vp_sticker->load_image(m_chatmessage[CHAR_NAME]);
if (m_chatmessage[ADDITIVE] != "1") { if (m_chatmessage[ADDITIVE] != "1") {
@ -3644,9 +3602,9 @@ void Courtroom::start_chat_ticking()
tick_pos = 0; tick_pos = 0;
blip_ticker = 0; blip_ticker = 0;
text_crawl = ao_app->get_text_crawl(); text_crawl = Options::getInstance().textCrawlSpeed();
blip_rate = ao_app->read_blip_rate(); blip_rate = Options::getInstance().blipRate();
blank_blip = ao_app->get_blank_blip(); blank_blip = Options::getInstance().blankBlip();
// At the start of every new message, we set the text speed to the default. // At the start of every new message, we set the text speed to the default.
current_display_speed = 3; current_display_speed = 3;
@ -3707,7 +3665,7 @@ void Courtroom::chat_tick()
anim_state = 3; anim_state = 3;
QString f_char; QString f_char;
QString f_custom_theme; QString f_custom_theme;
if (ao_app->is_customchat_enabled()) { if (Options::getInstance().customChatboxEnabled()) {
f_char = m_chatmessage[CHAR_NAME]; f_char = m_chatmessage[CHAR_NAME];
f_custom_theme = ao_app->get_chat(f_char); f_custom_theme = ao_app->get_chat(f_char);
} }
@ -3723,12 +3681,12 @@ void Courtroom::chat_tick()
// If we're not already waiting on the next message, start the timer. We could be overriden if there's an objection planned. // If we're not already waiting on the next message, start the timer. We could be overriden if there's an objection planned.
int delay = ao_app->stay_time(); int delay = Options::getInstance().textStayTime();
if (delay > 0 && !text_queue_timer->isActive()) if (delay > 0 && !text_queue_timer->isActive())
text_queue_timer->start(delay); text_queue_timer->start(delay);
// if we have instant objections disabled, and queue is not empty, check if next message after this is an objection. // if we have instant objections disabled, and queue is not empty, check if next message after this is an objection.
if (!ao_app->is_instant_objection_enabled() && chatmessage_queue.size() > 0) if (!Options::getInstance().objectionSkipQueueEnabled() && chatmessage_queue.size() > 0)
{ {
QStringList p_contents = chatmessage_queue.head(); QStringList p_contents = chatmessage_queue.head();
int objection_mod = p_contents[OBJECTION_MOD].split("&")[0].toInt(); int objection_mod = p_contents[OBJECTION_MOD].split("&")[0].toInt();
@ -3944,24 +3902,20 @@ void Courtroom::play_sfx()
return; return;
sfx_player->play(sfx_name); sfx_player->play(sfx_name);
if (ao_app->get_looping_sfx()) if (Options::getInstance().loopingSfx())
sfx_player->set_looping( sfx_player->set_looping(
ao_app->get_sfx_looping(current_char, current_emote) == "1"); ao_app->get_sfx_looping(current_char, current_emote) == "1");
} }
void Courtroom::set_scene(const QString f_desk_mod, const QString f_side) void Courtroom::set_scene(bool show_desk, const QString f_side)
{ {
ui_vp_background->load_image(ao_app->get_pos_path(f_side)); ui_vp_background->load_image(ao_app->get_pos_path(f_side));
ui_vp_desk->load_image(ao_app->get_pos_path(f_side, true)); ui_vp_desk->load_image(ao_app->get_pos_path(f_side, true));
if (f_desk_mod == "0" || if (show_desk)
(f_desk_mod != "1" &&
(f_side == "jud" || f_side == "hld" || f_side == "hlp"))) {
ui_vp_desk->hide();
}
else {
ui_vp_desk->show(); ui_vp_desk->show();
} else
ui_vp_desk->hide();
} }
void Courtroom::set_self_offset(const QString& p_list) { void Courtroom::set_self_offset(const QString& p_list) {
@ -4245,21 +4199,6 @@ void Courtroom::mod_called(QString p_ip)
} }
} }
void Courtroom::case_called(QString msg, bool def, bool pro, bool jud, bool jur,
bool steno)
{
Q_UNUSED(def);
Q_UNUSED(pro);
Q_UNUSED(jud);
Q_UNUSED(jur);
Q_UNUSED(steno);
if (ui_casing->isChecked()) {
ui_server_chatlog->append(msg);
modcall_player->play(ao_app->get_court_sfx("case_call"));
ao_app->alert(this);
}
}
void Courtroom::on_ooc_return_pressed() void Courtroom::on_ooc_return_pressed()
{ {
QString ooc_message = ui_ooc_chat_message->text(); QString ooc_message = ui_ooc_chat_message->text();
@ -4281,9 +4220,9 @@ void Courtroom::on_ooc_return_pressed()
#else #else
QStringList command = ooc_message.split(" ", Qt::SkipEmptyParts); QStringList command = ooc_message.split(" ", Qt::SkipEmptyParts);
#endif #endif
QDir casefolder("base/cases"); QDir casefolder(get_base_path()+"/cases");
if (!casefolder.exists()) { if (!casefolder.exists()) {
QDir::current().mkdir("base/" + casefolder.dirName()); QDir::current().mkdir(get_base_path() + casefolder.dirName());
append_server_chatmessage( append_server_chatmessage(
"CLIENT", "CLIENT",
tr("You don't have a `base/cases/` folder! It was just made for you, " tr("You don't have a `base/cases/` folder! It was just made for you, "
@ -4320,7 +4259,7 @@ void Courtroom::on_ooc_return_pressed()
return; return;
} }
QSettings casefile("base/cases/" + command[1] + ".ini", QSettings casefile(get_base_path() + "/cases/" + command[1] + ".ini",
QSettings::IniFormat); QSettings::IniFormat);
QString caseauth = casefile.value("author", "").value<QString>(); QString caseauth = casefile.value("author", "").value<QString>();
@ -4381,9 +4320,9 @@ void Courtroom::on_ooc_return_pressed()
#else #else
QStringList command = ooc_message.split(" ", Qt::SkipEmptyParts); QStringList command = ooc_message.split(" ", Qt::SkipEmptyParts);
#endif #endif
QDir casefolder("base/cases"); QDir casefolder(get_base_path() + "cases");
if (!casefolder.exists()) { if (!casefolder.exists()) {
QDir::current().mkdir("base/" + casefolder.dirName()); QDir(get_base_path()).mkdir(casefolder.dirName());
append_server_chatmessage( append_server_chatmessage(
"CLIENT", "CLIENT",
tr("You don't have a `base/cases/` folder! It was just made for you, " tr("You don't have a `base/cases/` folder! It was just made for you, "
@ -4417,7 +4356,7 @@ void Courtroom::on_ooc_return_pressed()
ui_ooc_chat_message->clear(); ui_ooc_chat_message->clear();
return; return;
} }
QSettings casefile("base/cases/" + command[1] + ".ini", QSettings casefile(get_base_path() + "/cases/" + command[1] + ".ini",
QSettings::IniFormat); QSettings::IniFormat);
casefile.setValue("author", ui_ooc_chat_name->text()); casefile.setValue("author", ui_ooc_chat_name->text());
casefile.setValue("cmdoc", ""); casefile.setValue("cmdoc", "");
@ -4637,7 +4576,7 @@ void Courtroom::on_iniswap_dropdown_changed(int p_index)
} }
QString p_path = ao_app->get_real_path(VPath("iniswaps.ini")); QString p_path = ao_app->get_real_path(VPath("iniswaps.ini"));
if (!file_exists(p_path)) { if (!file_exists(p_path)) {
p_path = ao_app->get_base_path() + "iniswaps.ini"; p_path = get_base_path() + "iniswaps.ini";
} }
ao_app->write_to_file(swaplist.join("\n"), p_path); ao_app->write_to_file(swaplist.join("\n"), p_path);
ui_iniswap_dropdown->blockSignals(true); ui_iniswap_dropdown->blockSignals(true);
@ -4787,7 +4726,7 @@ void Courtroom::on_sfx_context_menu_requested(const QPoint &pos)
menu->addSeparator(); menu->addSeparator();
menu->addAction(QString("Open base sounds folder"), this, menu->addAction(QString("Open base sounds folder"), this,
[=] { [=] {
QString p_path = ao_app->get_base_path() + "sounds/general/"; QString p_path = get_base_path() + "sounds/general/";
if (!dir_exists(p_path)) { if (!dir_exists(p_path)) {
return; return;
} }
@ -4814,7 +4753,7 @@ void Courtroom::on_sfx_edit_requested()
} }
if (!file_exists(p_path)) { if (!file_exists(p_path)) {
p_path = ao_app->get_base_path() + "soundlist.ini"; p_path = get_base_path() + "soundlist.ini";
} }
QDesktopServices::openUrl(QUrl::fromLocalFile(p_path)); QDesktopServices::openUrl(QUrl::fromLocalFile(p_path));
} }
@ -5013,7 +4952,7 @@ void Courtroom::on_music_list_double_clicked(QTreeWidgetItem *p_item,
{ {
if (is_muted) if (is_muted)
return; return;
if (!ao_app->is_category_stop_enabled() && p_item->parent() == nullptr) if (!Options::getInstance().stopMusicOnCategoryEnabled() && p_item->parent() == nullptr)
return; return;
column = 1; // Column 1 is always the metadata (which we want) column = 1; // Column 1 is always the metadata (which we want)
QString p_song = p_item->text(column); QString p_song = p_item->text(column);
@ -5062,7 +5001,7 @@ void Courtroom::on_music_list_context_menu_requested(const QPoint &pos)
menu->addSeparator(); menu->addSeparator();
menu->addAction(QString("Open base music folder"), this, menu->addAction(QString("Open base music folder"), this,
[=] { [=] {
QString p_path = ao_app->get_base_path() + "sounds/music/"; QString p_path = get_base_path() + "sounds/music/";
if (!dir_exists(p_path)) { if (!dir_exists(p_path)) {
return; return;
} }
@ -5388,7 +5327,7 @@ void Courtroom::on_text_color_context_menu_requested(const QPoint &pos)
menu->addAction(QString("Open currently used chat_config.ini"), this, menu->addAction(QString("Open currently used chat_config.ini"), this,
[=] { [=] {
QString p_path = ao_app->get_asset("chat_config.ini", ao_app->current_theme, ao_app->get_subtheme(), ao_app->default_theme, ao_app->get_chat(current_char)); QString p_path = ao_app->get_asset("chat_config.ini", Options::getInstance().theme(), Options::getInstance().subTheme(), ao_app->default_theme, ao_app->get_chat(current_char));
if (!file_exists(p_path)) { if (!file_exists(p_path)) {
return; return;
} }
@ -5578,8 +5517,6 @@ void Courtroom::on_change_character_clicked()
void Courtroom::on_reload_theme_clicked() void Courtroom::on_reload_theme_clicked()
{ {
ao_app->reload_theme();
set_courtroom_size(); set_courtroom_size();
set_widgets(); set_widgets();
update_character(m_cid, ui_iniswap_dropdown->itemText(ui_iniswap_dropdown->currentIndex())); update_character(m_cid, ui_iniswap_dropdown->itemText(ui_iniswap_dropdown->currentIndex()));
@ -5648,11 +5585,6 @@ void Courtroom::on_call_mod_clicked()
void Courtroom::on_settings_clicked() { ao_app->call_settings_menu(); } void Courtroom::on_settings_clicked() { ao_app->call_settings_menu(); }
void Courtroom::on_announce_casing_clicked()
{
ao_app->call_announce_menu(this);
}
void Courtroom::on_pre_clicked() { ui_ic_chat_message->setFocus(); } void Courtroom::on_pre_clicked() { ui_ic_chat_message->setFocus(); }
void Courtroom::on_flip_clicked() { ui_ic_chat_message->setFocus(); } void Courtroom::on_flip_clicked() { ui_ic_chat_message->setFocus(); }
@ -5707,7 +5639,7 @@ void Courtroom::on_evidence_context_menu_requested(const QPoint &pos)
QMenu *menu = new QMenu(this); QMenu *menu = new QMenu(this);
menu->addAction(QString("Open base evidence folder"), this, menu->addAction(QString("Open base evidence folder"), this,
[=] { [=] {
QString p_path = ao_app->get_base_path() + "evidence/"; QString p_path = get_base_path() + "evidence/";
if (!dir_exists(p_path)) { if (!dir_exists(p_path)) {
return; return;
} }
@ -5752,45 +5684,6 @@ qint64 Courtroom::pong()
return ping_timer.elapsed(); return ping_timer.elapsed();
} }
void Courtroom::on_casing_clicked()
{
if (ao_app->casing_alerts_supported) {
if (ui_casing->isChecked()) {
QStringList f_packet;
f_packet.append(ao_app->get_casing_can_host_cases());
f_packet.append(QString::number(ao_app->get_casing_cm_enabled()));
f_packet.append(QString::number(ao_app->get_casing_defence_enabled()));
f_packet.append(
QString::number(ao_app->get_casing_prosecution_enabled()));
f_packet.append(QString::number(ao_app->get_casing_judge_enabled()));
f_packet.append(QString::number(ao_app->get_casing_juror_enabled()));
f_packet.append(QString::number(ao_app->get_casing_steno_enabled()));
ao_app->send_server_packet(new AOPacket("SETCASE", f_packet));
}
else
ao_app->send_server_packet(new AOPacket("SETCASE", {"","0","0","0","0","0","0"}));
}
}
void Courtroom::announce_case(QString title, bool def, bool pro, bool jud,
bool jur, bool steno)
{
if (ao_app->casing_alerts_supported) {
QStringList f_packet;
f_packet.append(title);
f_packet.append(QString::number(def));
f_packet.append(QString::number(pro));
f_packet.append(QString::number(jud));
f_packet.append(QString::number(jur));
f_packet.append(QString::number(steno));
ao_app->send_server_packet(new AOPacket("CASEA", f_packet));
}
}
void Courtroom::start_clock(int id) void Courtroom::start_clock(int id)
{ {
if (id >= 0 && id < max_clocks && ui_clock[id] != nullptr) if (id >= 0 && id < max_clocks && ui_clock[id] != nullptr)
@ -5920,6 +5813,11 @@ void Courtroom::truncate_label_text(QWidget *p_widget, QString p_identifier)
Courtroom::~Courtroom() Courtroom::~Courtroom()
{ {
//save sound settings
Options::getInstance().setMusicVolume(ui_music_slider->value());
Options::getInstance().setSfxVolume(ui_sfx_slider->value());
Options::getInstance().setBlipVolume(ui_blip_slider->value());
delete music_player; delete music_player;
delete sfx_player; delete sfx_player;
delete objection_player; delete objection_player;

View File

@ -12,6 +12,11 @@ DemoServer::DemoServer(QObject *parent) : QObject(parent)
connect(timer, &QTimer::timeout, this, &DemoServer::playback); connect(timer, &QTimer::timeout, this, &DemoServer::playback);
} }
void DemoServer::set_demo_file(QString filepath)
{
filename = filepath;
}
void DemoServer::start_server() void DemoServer::start_server()
{ {
if (server_started) return; if (server_started) return;
@ -35,13 +40,12 @@ void DemoServer::destroy_connection()
void DemoServer::accept_connection() void DemoServer::accept_connection()
{ {
QString path = QFileDialog::getOpenFileName(nullptr, tr("Load Demo"), "logs/", tr("Demo Files (*.demo)")); if (filename.isEmpty())
if (path.isEmpty())
{ {
destroy_connection(); destroy_connection();
return; return;
} }
load_demo(path); load_demo(filename);
if (demo_data.isEmpty()) if (demo_data.isEmpty())
{ {

View File

@ -1,6 +1,7 @@
#include "courtroom.h" #include "courtroom.h"
#include "aoemotebutton.h" #include "aoemotebutton.h"
#include "options.h"
void Courtroom::initialize_emotes() void Courtroom::initialize_emotes()
{ {
@ -200,7 +201,7 @@ void Courtroom::select_emote(int p_id)
if (old_emote == current_emote) { if (old_emote == current_emote) {
ui_pre->setChecked(!ui_pre->isChecked()); ui_pre->setChecked(!ui_pre->isChecked());
} }
else if (!ao_app->is_stickypres_enabled()) { else if (!Options::getInstance().clearPreOnPlayEnabled()) {
if (emote_mod == PREANIM || emote_mod == PREANIM_ZOOM) { if (emote_mod == PREANIM || emote_mod == PREANIM_ZOOM) {
ui_pre->setChecked(true); ui_pre->setChecked(true);
} }

View File

@ -1,4 +1,5 @@
#include "courtroom.h" #include "courtroom.h"
#include "options.h"
void Courtroom::initialize_evidence() void Courtroom::initialize_evidence()
{ {
@ -400,7 +401,7 @@ void Courtroom::on_evidence_image_name_edited()
void Courtroom::on_evidence_image_button_clicked() void Courtroom::on_evidence_image_button_clicked()
{ {
QDir dir("base/evidence/"); QDir dir(get_base_path() + "/evidence/");
QFileDialog dialog(this); QFileDialog dialog(this);
dialog.setFileMode(QFileDialog::ExistingFile); dialog.setFileMode(QFileDialog::ExistingFile);
dialog.setNameFilter(tr("Images (*.png)")); dialog.setNameFilter(tr("Images (*.png)"));
@ -416,8 +417,8 @@ void Courtroom::on_evidence_image_button_clicked()
return; return;
QString filename = filenames.at(0); QString filename = filenames.at(0);
QStringList bases = ao_app->get_mount_paths(); QStringList bases = Options::getInstance().mountPaths();
bases.prepend(ao_app->get_base_path()); bases.prepend(get_base_path());
for (const QString &base : bases) { for (const QString &base : bases) {
QDir baseDir(base); QDir baseDir(base);
if (filename.startsWith(baseDir.absolutePath() + "/")) { if (filename.startsWith(baseDir.absolutePath() + "/")) {
@ -453,7 +454,7 @@ void Courtroom::on_evidence_clicked(int p_id)
else if (f_real_id > local_evidence_list.size()) else if (f_real_id > local_evidence_list.size())
return; return;
if (!ao_app->get_evidence_double_click()){ if (!Options::getInstance().evidenceDoubleClickEdit()){
on_evidence_double_clicked(p_id); on_evidence_double_clicked(p_id);
return; return;
} }

View File

@ -26,3 +26,23 @@ bool exists(QString p_path)
return file.exists(); return file.exists();
} }
QString get_base_path()
{
QString base_path = "";
#ifdef ANDROID
QString sdcard_storage = getenv("SECONDARY_STORAGE");
if (dir_exists(sdcard_storage + "/base/")) {
base_path = sdcard_storage + "/base/";
}
else {
QString external_storage = getenv("EXTERNAL_STORAGE");
base_path = external_storage + "/base/";
}
#elif defined(__APPLE__)
base_path = QCoreApplication::applicationDirPath() + "/../../../base/";
#else
base_path = QCoreApplication::applicationDirPath() + "/base/";
#endif
return base_path;
}

File diff suppressed because it is too large Load Diff

View File

@ -9,6 +9,7 @@
#include <QLibraryInfo> #include <QLibraryInfo>
#include <QPluginLoader> #include <QPluginLoader>
#include <QTranslator> #include <QTranslator>
#include <QResource>
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
@ -16,16 +17,21 @@ int main(int argc, char *argv[])
AOApplication main_app(argc, argv); AOApplication main_app(argc, argv);
#ifdef ANDROID
if(QtAndroid::checkPermission("android.permission.READ_EXTERNAL_STORAGE")==QtAndroid::PermissionResult::Denied) {
QtAndroid::requestPermissionsSync({"android.permission.READ_EXTERNAL_STORAGE","android.permission.WRITE_EXTERNAL_STORAGE"});
}
#endif
AOApplication::addLibraryPath(AOApplication::applicationDirPath() + "/lib"); AOApplication::addLibraryPath(AOApplication::applicationDirPath() + "/lib");
QResource::registerResource(main_app.get_asset("themes/" + Options::getInstance().theme() + ".rcc"));
QFontDatabase fontDatabase; QFontDatabase fontDatabase;
QDirIterator it(main_app.get_base_path() + "fonts", QDirIterator it(get_base_path() + "fonts",
QDirIterator::Subdirectories); QDirIterator::Subdirectories);
while (it.hasNext()) while (it.hasNext())
fontDatabase.addApplicationFont(it.next()); fontDatabase.addApplicationFont(it.next());
QSettings *configini = main_app.configini;
QPluginLoader apngPlugin("qapng"); QPluginLoader apngPlugin("qapng");
if (!apngPlugin.load()) if (!apngPlugin.load())
qCritical() << "QApng plugin could not be loaded"; qCritical() << "QApng plugin could not be loaded";
@ -35,7 +41,7 @@ int main(int argc, char *argv[])
qCritical() << "QWebp plugin could not be loaded"; qCritical() << "QWebp plugin could not be loaded";
QString p_language = QString p_language =
configini->value("language", QLocale::system().name()).toString(); Options::getInstance().language();
if (p_language == " " || p_language == "") if (p_language == " " || p_language == "")
p_language = QLocale::system().name(); p_language = QLocale::system().name();

View File

@ -3,10 +3,12 @@
#include "datatypes.h" #include "datatypes.h"
#include "debug_functions.h" #include "debug_functions.h"
#include "lobby.h" #include "lobby.h"
#include "options.h"
#include <QAbstractSocket> #include <QAbstractSocket>
#include <QJsonArray> #include <QJsonArray>
#include <QJsonDocument> #include <QJsonDocument>
#include <QJsonObject>
#include <QNetworkReply> #include <QNetworkReply>
NetworkManager::NetworkManager(AOApplication *parent) : QObject(parent) NetworkManager::NetworkManager(AOApplication *parent) : QObject(parent)
@ -17,7 +19,7 @@ NetworkManager::NetworkManager(AOApplication *parent) : QObject(parent)
heartbeat_timer = new QTimer(this); heartbeat_timer = new QTimer(this);
QString master_config = QString master_config =
ao_app->configini->value("master", "").value<QString>(); Options::getInstance().alternativeMasterserver();
if (!master_config.isEmpty() && QUrl(master_config).scheme().startsWith("http")) { if (!master_config.isEmpty() && QUrl(master_config).scheme().startsWith("http")) {
qInfo() << "using alternate master server" << master_config; qInfo() << "using alternate master server" << master_config;
ms_baseurl = master_config; ms_baseurl = master_config;
@ -81,7 +83,7 @@ void NetworkManager::send_heartbeat()
// within a 5 minute window, so that the the number of people playing within // within a 5 minute window, so that the the number of people playing within
// that time period can be counted and an accurate player count be displayed. // that time period can be counted and an accurate player count be displayed.
// What do I care about your personal information, I really don't want it. // What do I care about your personal information, I really don't want it.
if (ao_app->get_player_count_optout()) if (Options::getInstance().playerCountOptout())
return; return;
QNetworkRequest req(QUrl(ms_baseurl + "/playing")); QNetworkRequest req(QUrl(ms_baseurl + "/playing"));
@ -105,7 +107,7 @@ void NetworkManager::request_document(MSDocumentType document_type,
req.setRawHeader("User-Agent", get_user_agent().toUtf8()); req.setRawHeader("User-Agent", get_user_agent().toUtf8());
QString language = QString language =
ao_app->configini->value("language").toString(); Options::getInstance().language();
if (language.trimmed().isEmpty()) if (language.trimmed().isEmpty())
language = QLocale::system().name(); language = QLocale::system().name();
@ -192,6 +194,11 @@ void NetworkManager::connect_to_server(server_type p_server)
active_connection_type = p_server.socket_type; active_connection_type = p_server.socket_type;
} }
void NetworkManager::join_to_server()
{
ship_server_packet(AOPacket("askchaa").to_string());
}
void NetworkManager::disconnect_from_server() void NetworkManager::disconnect_from_server()
{ {
if (!connected) if (!connected)

703
src/options.cpp Normal file
View File

@ -0,0 +1,703 @@
#include "options.h"
#include "file_functions.h"
#include <QCoreApplication>
#include <QDebug>
#include <QFile>
#include <QLocale>
#include <QObject>
#include <QRegularExpression>
#include <QSize>
void Options::migrateCallwords()
{
// Bla bla, evil boilerplate.
QStringList l_callwords;
QFile l_file;
l_file.setFileName(get_base_path() + "callwords.ini");
if (!l_file.open(QIODevice::ReadOnly)) {
qWarning() << "Unable to migrate callwords : File not open.";
return;
}
QTextStream in(&l_file);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
in.setCodec("UTF-8");
#endif
while (!in.atEnd()) {
QString line = in.readLine();
l_callwords.append(line);
}
l_file.close();
l_file.remove();
setCallwords(l_callwords);
}
Options::Options()
: config(get_base_path() + "config.ini", QSettings::IniFormat, nullptr),
favorite(get_base_path() + "favorite_servers.ini", QSettings::IniFormat,
nullptr)
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
config.setIniCodec("UTF-8");
#endif
migrate();
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
favorite.setIniCodec("UTF-8");
#endif
}
/*! Migrate old configuration keys/values to a relevant format. */
void Options::migrate()
{
if (config.contains("show_custom_shownames")) {
config.remove("show_custom_shownames");
}
if (QFile::exists(get_base_path() + "callwords.ini")) {
migrateCallwords();
}
if (config.contains("ooc_name")) {
if (username().isEmpty()) {
config.setValue("default_username", config.value("ooc_name"));
}
config.remove("ooc_name");
}
if (config.contains("casing_enabled")) {
config.remove("casing_enabled");
config.remove("casing_defence_enabled");
config.remove("casing_prosecution_enabled");
config.remove("casing_judge_enabled");
config.remove("casing_juror_enabled");
config.remove("casing_steno_enabled");
config.remove("casing_cm_enabled");
config.remove("casing_can_host_cases");
}
}
QString Options::theme() const
{
return config.value("theme", "default").toString();
}
void Options::setTheme(QString value) { config.setValue("theme", value); }
int Options::blipRate() const { return config.value("blip_rate", 2).toInt(); }
void Options::setBlipRate(int value) { config.setValue("blip_rate", value); }
int Options::musicVolume() const
{
return config.value("default_music", 50).toInt();
}
void Options::setMusicVolume(int value)
{
config.setValue("default_music", value);
}
int Options::sfxVolume() const
{
return config.value("default_sfx", 50).toInt();
}
void Options::setSfxVolume(int value) { config.setValue("default_sfx", value); }
int Options::blipVolume() const
{
return config.value("default_blip", 50).toInt();
}
void Options::setBlipVolume(int value)
{
config.setValue("default_blip", value);
}
int Options::defaultSuppressAudio() const
{
return config.value("suppress_audio", 50).toInt();
}
void Options::setDefaultSupressedAudio(int value)
{
config.setValue("suppress_audio", value);
}
int Options::maxLogSize() const
{
return config.value("log_maximum", 200).toInt();
}
void Options::setMaxLogSize(int value)
{
config.setValue("log_maximum", value);
}
int Options::textStayTime() const
{
return config.value("stay_time", 200).toInt();
}
void Options::setTextStayTime(int value)
{
config.setValue("stay_time", value);
}
int Options::textCrawlSpeed() const
{
return config.value("text_crawl", 40).toInt();
}
void Options::setTextCrawlSpeed(int value)
{
config.setValue("text_crawl", value);
}
int Options::chatRateLimit() const
{
return config.value("chat_ratelimit", 300).toInt();
}
void Options::setChatRateLimit(int value)
{
config.setValue("chat_ratelimit", value);
}
bool Options::logDirectionDownwards() const
{
return config.value("log_goes_downwards", true).toBool();
}
void Options::setLogDirectionDownwards(bool value)
{
config.setValue("log_goes_downwards", value);
}
bool Options::logNewline() const
{
return config.value("log_newline", false).toBool();
}
void Options::setLogNewline(bool value)
{
config.setValue("log_newline", value);
}
int Options::logMargin() const { return config.value("log_margin", 0).toInt(); }
void Options::setLogMargin(int value) { config.setValue("log_margin", value); }
bool Options::logTimestampEnabled() const
{
return config.value("log_timestamp", false).toBool();
}
void Options::setLogTimestampEnabled(bool value)
{
config.setValue("log_timestamp", value);
}
QString Options::logTimestampFormat() const
{
return config.value("log_timestamp_format", "h:mm:ss AP").toString();
}
void Options::setLogTimestampFormat(QString value)
{
config.setValue("log_timestamp_format", value);
}
bool Options::logIcActions() const
{
return config.value("log_ic_actions", true).toBool();
}
void Options::setLogIcActions(bool value)
{
config.setValue("log_ic_actions", value);
}
bool Options::customShownameEnabled() const
{
return config.value("show_custom_shownames", true).toBool();
}
void Options::setCustomShownameEnabled(bool value)
{
config.setValue("show_custom_shownames", value);
}
QString Options::username() const
{
return config.value("default_username", "").value<QString>();
}
void Options::setUsername(QString value)
{
config.setValue("default_username", value);
}
QString Options::shownameOnJoin() const
{
return config.value("default_showname", "").toString();
}
void Options::setShownameOnJoin(QString value)
{
config.setValue("default_showname", value);
}
QString Options::audioOutputDevice() const
{
return config.value("default_audio_device", "default").toString();
}
void Options::setAudioOutputDevice(QString value)
{
config.setValue("default_audio_device", value);
}
bool Options::blankBlip() const
{
return config.value("blank_blip", false).toBool();
}
void Options::setBlankBlip(bool value) { config.setValue("blank_blip", value); }
bool Options::loopingSfx() const
{
return config.value("looping_sfx", true).toBool();
}
void Options::setLoopingSfx(bool value)
{
config.setValue("looping_sfx", value);
}
bool Options::objectionStopMusic() const
{
return config.value("objection_stop_music", false).toBool();
}
void Options::setObjectionStopMusic(bool value)
{
config.setValue("objection_stop_music", value);
}
bool Options::streamingEnabled() const
{
return config.value("streaming_enabled", true).toBool();
}
void Options::setStreamingEnabled(bool value)
{
config.setValue("streaming_enabled", value);
}
bool Options::objectionSkipQueueEnabled() const
{
return config.value("instant_objection", true).toBool();
}
void Options::setObjectionSkipQueueEnabled(bool value)
{
config.setValue("instant_objection", value);
}
bool Options::desynchronisedLogsEnabled() const
{
return config.value("desync_logs", false).toBool();
}
void Options::setDesynchronisedLogsEnabled(bool value)
{
config.setValue("desync_logs", value);
}
bool Options::discordEnabled() const
{
return config.value("discord", true).toBool();
}
void Options::setDiscordEnabled(bool value)
{
config.setValue("discord", value);
}
bool Options::shakeEnabled() const
{
return config.value("shake", true).toBool();
}
void Options::setShakeEnabled(bool value) { config.setValue("shake", value); }
bool Options::effectsEnabled() const
{
return config.value("effects", true).toBool();
}
void Options::setEffectsEnabled(bool value)
{
config.setValue("effects", value);
}
bool Options::networkedFrameSfxEnabled() const
{
return config.value("framenetwork", true).toBool();
}
void Options::setNetworkedFrameSfxEnabled(bool value)
{
config.setValue("framenetwork", value);
}
bool Options::colorLogEnabled() const
{
return config.value("colorlog", true).toBool();
}
void Options::setColorLogEnabled(bool value)
{
config.setValue("colorlog", value);
}
bool Options::clearSoundsDropdownOnPlayEnabled() const
{
return config.value("stickysounds", true).toBool();
}
void Options::setClearSoundsDropdownOnPlayEnabled(bool value)
{
config.setValue("stickysounds", value);
}
bool Options::clearEffectsDropdownOnPlayEnabled() const
{
return config.value("stickyeffects", true).toBool();
}
void Options::setClearEffectsDropdownOnPlayEnabled(bool value)
{
config.setValue("stickyeffects", value);
}
bool Options::clearPreOnPlayEnabled() const
{
return config.value("stickypres", true).toBool();
}
void Options::setClearPreOnPlayEnabled(bool value)
{
config.setValue("stickypres", value);
}
bool Options::customChatboxEnabled() const
{
return config.value("customchat", true).toBool();
}
void Options::setCustomChatboxEnabled(bool value)
{
config.setValue("customchat", value);
}
bool Options::characterStickerEnabled() const
{
return config.value("sticker", true).toBool();
}
void Options::setCharacterStickerEnabled(bool value)
{
config.setValue("sticker", value);
}
bool Options::continuousPlaybackEnabled() const
{
return config.value("continuous_playback", true).toBool();
}
void Options::setContinuousPlaybackEnabled(bool value)
{
config.setValue("continuous_playback", value);
}
bool Options::stopMusicOnCategoryEnabled() const
{
return config.value("category_stop", true).toBool();
}
void Options::setStopMusicOnCategoryEnabled(bool value)
{
config.setValue("category_stop", value);
}
bool Options::logToTextFileEnabled() const
{
return config.value("automatic_logging_enabled", true).toBool();
}
void Options::setLogToTextFileEnabled(bool value)
{
config.setValue("automatic_logging_enabled", value);
}
bool Options::logToDemoFileEnabled() const
{
return config.value("demo_logging_enabled", true).toBool();
}
void Options::setLogToDemoFileEnabled(bool value)
{
config.setValue("demo_logging_enabled", value);
}
QString Options::subTheme() const
{
if (settingsSubTheme() == "server" && !m_server_subtheme.isEmpty()) {
return m_server_subtheme;
}
return settingsSubTheme();
}
QString Options::settingsSubTheme() const
{
return config.value("subtheme", "server").toString();
}
void Options::setSettingsSubTheme(QString value)
{
config.setValue("subtheme", value);
}
QString Options::serverSubTheme() const { return m_server_subtheme; }
void Options::setServerSubTheme(QString value) { m_server_subtheme = value; }
bool Options::animatedThemeEnabled() const
{
return config.value("animated_theme", true).toBool();
}
void Options::setAnimatedThemeEnabled(bool value)
{
config.setValue("animated_theme", value);
}
QString Options::defaultScalingMode() const
{
return config.value("default_scaling", "fast").toString();
}
void Options::setDefaultScalingMode(QString value)
{
config.setValue("default_scaling", value);
}
QStringList Options::mountPaths() const
{
return config.value("mount_paths").value<QStringList>();
}
void Options::setMountPaths(QStringList value)
{
config.setValue("mount_paths", value);
}
bool Options::playerCountOptout() const
{
return config.value("player_count_optout", false).toBool();
}
void Options::setPlayerCountOptout(bool value)
{
config.setValue("player_count_optout", value);
}
bool Options::playSelectedSFXOnIdle() const
{
return config.value("sfx_on_idle", false).toBool();
}
void Options::setPlaySelectedSFXOnIdle(bool value)
{
config.setValue("sfx_on_idle", value);
}
bool Options::evidenceDoubleClickEdit() const
{
return config.value("evidence_double_click", true).toBool();
}
void Options::setEvidenceDoubleClickEdit(bool value)
{
config.setValue("evidence_double_click", value);
}
QString Options::alternativeMasterserver() const
{
return config.value("master", "").toString();
}
void Options::setAlternativeMasterserver(QString value)
{
config.setValue("master", value);
}
QString Options::language() const
{
return config.value("language", QLocale::system().name()).toString();
}
void Options::setLanguage(QString value) { config.setValue("language", value); }
QStringList Options::callwords() const
{
QStringList l_callwords =
config.value("callwords", QStringList{}).toStringList();
// Please someone explain to me how tf I am supposed to create an empty
// QStringList using QSetting defaults.
if (l_callwords.size() == 1 && l_callwords.at(0).isEmpty())
l_callwords.clear();
return l_callwords;
}
void Options::setCallwords(QStringList value)
{
config.setValue("callwords", value);
}
void Options::clearConfig() { config.clear(); }
QVector<server_type> Options::favorites()
{
QVector<server_type> serverlist;
auto grouplist = favorite.childGroups();
{ // remove all negative and non-numbers
auto filtered_grouplist = grouplist;
for (const QString &group : qAsConst(grouplist)) {
bool ok = false;
const int l_num = group.toInt(&ok);
if (ok && l_num >= 0) {
continue;
}
filtered_grouplist.append(group);
}
std::sort(filtered_grouplist.begin(), filtered_grouplist.end(),
[](const auto &a, const auto &b) -> bool {
return a.toInt() < b.toInt();
});
grouplist = std::move(filtered_grouplist);
}
for (const QString &group : qAsConst(grouplist)) {
server_type f_server;
favorite.beginGroup(group);
f_server.ip = favorite.value("address", "127.0.0.1").toString();
f_server.port = favorite.value("port", 27016).toInt();
f_server.name = favorite.value("name", "Missing Name").toString();
f_server.desc = favorite.value("desc", "No description").toString();
f_server.socket_type =
to_connection_type.value(favorite.value("protocol", "tcp").toString());
serverlist.append(std::move(f_server));
favorite.endGroup();
}
return serverlist;
}
void Options::setFavorites(QVector<server_type> value)
{
favorite.clear();
for (int i = 0; i < value.size(); ++i) {
auto fav_server = value.at(i);
favorite.beginGroup(QString::number(i));
favorite.setValue("name", fav_server.name);
favorite.setValue("address", fav_server.ip);
favorite.setValue("port", fav_server.port);
favorite.setValue("desc", fav_server.desc);
if (fav_server.socket_type == TCP) {
favorite.setValue("protocol", "tcp");
}
else {
favorite.setValue("protocol", "ws");
}
favorite.endGroup();
}
favorite.sync();
}
void Options::removeFavorite(int index)
{
QVector<server_type> l_favorites = favorites();
l_favorites.remove(index);
setFavorites(l_favorites);
}
void Options::addFavorite(server_type server)
{
int index = favorites().size();
favorite.beginGroup(QString::number(index));
favorite.setValue("name", server.name);
favorite.setValue("address", server.ip);
favorite.setValue("port", server.port);
favorite.setValue("desc", server.desc);
if (server.socket_type == TCP) {
favorite.setValue("protocol", "tcp");
}
else {
favorite.setValue("protocol", "ws");
}
favorite.endGroup();
favorite.sync();
}
void Options::updateFavorite(server_type server, int index)
{
favorite.beginGroup(QString::number(index));
favorite.setValue("name", server.name);
favorite.setValue("address", server.ip);
favorite.setValue("port", server.port);
favorite.setValue("desc", server.desc);
if (server.socket_type == TCP) {
favorite.setValue("protocol", "tcp");
}
else {
favorite.setValue("protocol", "ws");
}
favorite.endGroup();
favorite.sync();
}
QString Options::getUIAsset(QString f_asset_name)
{
QStringList l_paths{":/base/themes/" + Options::getInstance().theme() + "/" +
f_asset_name};
if (subTheme() == "server") {
if (serverSubTheme().isEmpty()) {
l_paths.prepend(":/base/themes/" + theme() + "/" + serverSubTheme() +
"/" + f_asset_name);
}
}
else {
l_paths.prepend(":/base/themes/" + theme() + "/" + subTheme() + "/" +
f_asset_name);
}
for (const QString &l_path : qAsConst(l_paths)) {
if (QFile::exists(l_path)) {
return l_path;
}
}
qWarning() << "Unable to locate ui-asset" << f_asset_name << "in theme"
<< theme() << "Defaulting to embeeded asset.";
return QString(":/resource/ui/" + f_asset_name);
}

View File

@ -5,10 +5,11 @@
#include "hardware_functions.h" #include "hardware_functions.h"
#include "lobby.h" #include "lobby.h"
#include "networkmanager.h" #include "networkmanager.h"
#include "options.h"
void AOApplication::append_to_demofile(QString packet_string) void AOApplication::append_to_demofile(QString packet_string)
{ {
if (get_demo_logging_enabled() && !log_filename.isEmpty()) if (Options::getInstance().logToDemoFileEnabled() && !log_filename.isEmpty())
{ {
QString path = log_filename.left(log_filename.size()).replace(".log", ".demo"); QString path = log_filename.left(log_filename.size()).replace(".log", ".demo");
if (!demo_timer.isValid()) if (!demo_timer.isValid())
@ -71,8 +72,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
client_id = f_contents.at(0).toInt(); client_id = f_contents.at(0).toInt();
server_software = f_contents.at(1); server_software = f_contents.at(1);
if (lobby_constructed) net_manager->server_connected(true);
w_lobby->enable_connect_button();
QStringList f_contents = {"AO2", get_version_string()}; QStringList f_contents = {"AO2", get_version_string()};
send_server_packet(new AOPacket("ID", f_contents)); send_server_packet(new AOPacket("ID", f_contents));
@ -150,10 +150,6 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
w_lobby->set_server_description(f_contents.at(2)); w_lobby->set_server_description(f_contents.at(2));
} }
if (w_lobby->doubleclicked) {
send_server_packet(new AOPacket("askchaa"));
w_lobby->doubleclicked = false;
}
log_to_demo = false; log_to_demo = false;
} }
else if (header == "SI") { else if (header == "SI") {
@ -179,34 +175,39 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
courtroom_loaded = false; courtroom_loaded = false;
int selected_server = w_lobby->get_selected_server(); int selected_server = w_lobby->get_selected_server();
QString server_address = "", server_name = ""; QString server_address = "", server_name = "";
if (w_lobby->public_servers_selected) { switch (w_lobby->pageSelected()) {
if (selected_server >= 0 && selected_server < server_list.size()) { case 0:
auto info = server_list.at(selected_server); if (selected_server >= 0 && selected_server < server_list.size()) {
server_name = info.name; auto info = server_list.at(selected_server);
server_address = server_name = info.name;
QString("%1:%2").arg(info.ip, QString::number(info.port)); server_address =
window_title = server_name; QString("%1:%2").arg(info.ip, QString::number(info.port));
} window_title = server_name;
}
break;
case 1:
{
QVector<server_type> favorite_list = Options::getInstance().favorites();
if (selected_server >= 0 && selected_server < favorite_list.size()) {
auto info = favorite_list.at(selected_server);
server_name = info.name;
server_address =
QString("%1:%2").arg(info.ip, QString::number(info.port));
window_title = server_name;
}
} }
else { break;
if (selected_server >= 0 && selected_server < favorite_list.size()) { case 2:
auto info = favorite_list.at(selected_server); window_title = "Local Demo Recording";
server_name = info.name; break;
server_address = default:
QString("%1:%2").arg(info.ip, QString::number(info.port)); break;
window_title = server_name;
}
} }
if (courtroom_constructed) if (courtroom_constructed)
w_courtroom->set_window_title(window_title); w_courtroom->set_window_title(window_title);
w_lobby->show_loading_overlay();
w_lobby->set_loading_text(tr("Loading"));
w_lobby->set_loading_value(0);
AOPacket *f_packet; AOPacket *f_packet;
f_packet = new AOPacket("RC"); f_packet = new AOPacket("RC");
@ -214,7 +215,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
// Remove any characters not accepted in folder names for the server_name // Remove any characters not accepted in folder names for the server_name
// here // here
if (AOApplication::get_demo_logging_enabled() && server_name != "Demo playback") { if (Options::getInstance().logToDemoFileEnabled() && server_name != "Demo playback") {
this->log_filename = QDateTime::currentDateTime().toUTC().toString( this->log_filename = QDateTime::currentDateTime().toUTC().toString(
"'logs/" + server_name.remove(QRegularExpression("[\\\\/:*?\"<>|\']")) + "'logs/" + server_name.remove(QRegularExpression("[\\\\/:*?\"<>|\']")) +
"/'yyyy-MM-dd hh-mm-ss t'.log'"); "/'yyyy-MM-dd hh-mm-ss t'.log'");
@ -228,7 +229,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
QCryptographicHash hash(QCryptographicHash::Algorithm::Sha256); QCryptographicHash hash(QCryptographicHash::Algorithm::Sha256);
hash.addData(server_address.toUtf8()); hash.addData(server_address.toUtf8());
if (is_discord_enabled()) if (Options::getInstance().discordEnabled())
discord->state_server(server_name.toStdString(), discord->state_server(server_name.toStdString(),
hash.result().toBase64().toStdString()); hash.result().toBase64().toStdString());
log_to_demo = false; log_to_demo = false;
@ -264,21 +265,6 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
f_char.taken = false; f_char.taken = false;
w_courtroom->append_char(f_char); w_courtroom->append_char(f_char);
if (!courtroom_loaded) {
++loaded_chars;
w_lobby->set_loading_text(tr("Loading chars:\n%1/%2")
.arg(QString::number(loaded_chars))
.arg(QString::number(char_list_size)));
int total_loading_size =
char_list_size * 2 + evidence_list_size + music_list_size;
int loading_value = int(
((loaded_chars + generated_chars + loaded_music + loaded_evidence) /
static_cast<double>(total_loading_size)) *
100);
w_lobby->set_loading_value(loading_value);
}
} }
if (!courtroom_loaded) if (!courtroom_loaded)
@ -295,11 +281,6 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
for (int n_element = 0; n_element < f_contents.size(); ++n_element) { for (int n_element = 0; n_element < f_contents.size(); ++n_element) {
++loaded_music; ++loaded_music;
w_lobby->set_loading_text(tr("Loading music:\n%1/%2")
.arg(QString::number(loaded_music))
.arg(QString::number(music_list_size)));
if (musics_time) { if (musics_time) {
w_courtroom->append_music(f_contents.at(n_element)); w_courtroom->append_music(f_contents.at(n_element));
} }
@ -319,14 +300,6 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
areas++; areas++;
} }
} }
int total_loading_size =
char_list_size * 2 + evidence_list_size + music_list_size;
int loading_value = int(
((loaded_chars + generated_chars + loaded_music + loaded_evidence) /
static_cast<double>(total_loading_size)) *
100);
w_lobby->set_loading_value(loading_value);
} }
for (int area_n = 0; area_n < areas; area_n++) { for (int area_n = 0; area_n < areas; area_n++) {
@ -370,10 +343,6 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
if (!courtroom_constructed) if (!courtroom_constructed)
goto end; goto end;
if (lobby_constructed)
w_courtroom->append_server_chatmessage(tr("[Global log]"),
w_lobby->get_chatlog(), "0");
w_courtroom->character_loading_finished(); w_courtroom->character_loading_finished();
w_courtroom->done_received(); w_courtroom->done_received();
@ -534,13 +503,6 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
if (courtroom_constructed && !f_contents.isEmpty()) if (courtroom_constructed && !f_contents.isEmpty())
w_courtroom->mod_called(f_contents.at(0)); w_courtroom->mod_called(f_contents.at(0));
} }
else if (header == "CASEA") {
if (courtroom_constructed && f_contents.size() >= 6)
w_courtroom->case_called(f_contents.at(0), f_contents.at(1) == "1",
f_contents.at(2) == "1", f_contents.at(3) == "1",
f_contents.at(4) == "1",
f_contents.at(5) == "1");
}
else if (header == "TI") { // Timer packet else if (header == "TI") { // Timer packet
if (!courtroom_constructed || f_contents.size() < 2) if (!courtroom_constructed || f_contents.size() < 2)
goto end; goto end;
@ -603,14 +565,15 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
subtheme = f_contents.at(0); subtheme = f_contents.at(0);
// Check if we have subthemes set to "server" // Check if we have subthemes set to "server"
QString p_st = configini->value("subtheme").value<QString>(); if (Options::getInstance().settingsSubTheme().toLower() != "server")
if (p_st.toLower() != "server")
// We don't. Simply acknowledge the subtheme sent by the server, but don't do anything else. // We don't. Simply acknowledge the subtheme sent by the server, but don't do anything else.
return; return;
// Reload theme request // Reload theme request
if (f_contents.size() > 1 && f_contents.at(1) == "1") if (f_contents.size() > 1 && f_contents.at(1) == "1") {
Options::getInstance().setServerSubTheme(subtheme);
w_courtroom->on_reload_theme_clicked(); w_courtroom->on_reload_theme_clicked();
}
} }
// Auth packet // Auth packet
else if (header == "AUTH") { else if (header == "AUTH") {

View File

@ -1,6 +1,7 @@
#include "aoapplication.h" #include "aoapplication.h"
#include "courtroom.h" #include "courtroom.h"
#include "file_functions.h" #include "file_functions.h"
#include "options.h"
#include <QDir> #include <QDir>
#include <QRegularExpression> #include <QRegularExpression>
@ -28,31 +29,10 @@ static bool is_power_2(unsigned int n) {
return r == 1; return r == 1;
} }
QString AOApplication::get_base_path()
{
QString base_path = "";
#ifdef ANDROID
QString sdcard_storage = getenv("SECONDARY_STORAGE");
if (dir_exists(sdcard_storage + "/base/")) {
base_path = sdcard_storage + "/base/";
}
else {
QString external_storage = getenv("EXTERNAL_STORAGE");
base_path = external_storage + "/base/";
}
#elif defined(__APPLE__)
base_path = applicationDirPath() + "/../../../base/";
#else
base_path = applicationDirPath() + "/base/";
#endif
return base_path;
}
VPath AOApplication::get_theme_path(QString p_file, QString p_theme) VPath AOApplication::get_theme_path(QString p_file, QString p_theme)
{ {
if (p_theme == "") if (p_theme == "")
p_theme = current_theme; p_theme = Options::getInstance().theme();
return VPath("themes/" + p_theme + "/" + p_file); return VPath("themes/" + p_theme + "/" + p_file);
} }
@ -280,9 +260,9 @@ QString AOApplication::get_sfx(QString p_sfx, QString p_misc, QString p_characte
{ {
QVector<VPath> pathlist; QVector<VPath> pathlist;
// Sounds subfolder is prioritized for organization sake // Sounds subfolder is prioritized for organization sake
pathlist += get_asset_paths("sounds/" + p_sfx, current_theme, get_subtheme(), default_theme, p_misc, p_character); pathlist += get_asset_paths("sounds/" + p_sfx, Options::getInstance().theme(), Options::getInstance().subTheme(), default_theme, p_misc, p_character);
// If sound subfolder not found, search just for SFX // If sound subfolder not found, search just for SFX
pathlist += get_asset_paths(p_sfx, current_theme, get_subtheme(), default_theme, p_misc, p_character); pathlist += get_asset_paths(p_sfx, Options::getInstance().theme(), Options::getInstance().subTheme(), default_theme, p_misc, p_character);
// If SFX not found, search base/sounds/general/ folder // If SFX not found, search base/sounds/general/ folder
pathlist += get_sounds_path(p_sfx); pathlist += get_sounds_path(p_sfx);
QString ret = get_sfx_path(pathlist); QString ret = get_sfx_path(pathlist);
@ -346,7 +326,7 @@ QString AOApplication::get_real_path(const VPath &vpath,
} }
// Cache miss; try all known mount paths // Cache miss; try all known mount paths
QStringList bases = get_mount_paths(); QStringList bases = Options::getInstance().mountPaths();
bases.prepend(get_base_path()); bases.prepend(get_base_path());
// base // base
// content 1 // content 1

View File

@ -1,147 +1,6 @@
#include "text_file_functions.h" #include "text_file_functions.h"
#include "aoutils.h" #include "aoutils.h"
#include "options.h"
QString AOApplication::read_theme()
{
QString result = configini->value("theme", "default").value<QString>();
return result;
}
int AOApplication::read_blip_rate()
{
int result = configini->value("blip_rate", 2).toInt();
if (result < 0)
return 0;
return result;
}
QString AOApplication::get_ooc_name()
{
QString result = configini->value("ooc_name").value<QString>();
return result;
}
int AOApplication::get_default_music()
{
int result = configini->value("default_music", 50).toInt();
return result;
}
int AOApplication::get_default_sfx()
{
int result = configini->value("default_sfx", 50).toInt();
return result;
}
int AOApplication::get_default_blip()
{
int result = configini->value("default_blip", 50).toInt();
return result;
}
int AOApplication::get_default_suppress_audio()
{
int result = configini->value("suppress_audio", 50).toInt();
return result;
}
int AOApplication::get_max_log_size()
{
int result = configini->value("log_maximum", 1000).toInt();
return result;
}
int AOApplication::stay_time()
{
int result = configini->value("stay_time", 200).toInt();
return result;
}
int AOApplication::get_text_crawl()
{
int result = configini->value("text_crawl", 40).toInt();
return result;
}
int AOApplication::get_chat_ratelimit()
{
int result = configini->value("chat_ratelimit", 300).toInt();
return result;
}
bool AOApplication::get_log_goes_downwards()
{
QString result =
configini->value("log_goes_downwards", "true").value<QString>();
return result.startsWith("true");
}
bool AOApplication::get_log_newline()
{
QString result = configini->value("log_newline", "false").value<QString>();
return result.startsWith("true");
}
int AOApplication::get_log_margin()
{
int result = configini->value("log_margin", 0).toInt();
return result;
}
bool AOApplication::get_log_timestamp()
{
QString result = configini->value("log_timestamp", "false").value<QString>();
return result.startsWith("true");
}
QString AOApplication::get_log_timestamp_format()
{
QString result = configini->value("log_timestamp_format", "h:mm:ss AP").value<QString>();
return result;
}
bool AOApplication::get_log_ic_actions()
{
QString result =
configini->value("log_ic_actions", "true").value<QString>();
return result.startsWith("true");
}
bool AOApplication::get_showname_enabled_by_default()
{
QString result =
configini->value("show_custom_shownames", "true").value<QString>();
return result.startsWith("true");
}
QString AOApplication::get_default_username()
{
QString result = configini->value("default_username", "").value<QString>();
if (result.isEmpty())
return get_ooc_name();
else
return result;
}
QString AOApplication::get_default_showname()
{
QString result = configini->value("default_showname", "").value<QString>();
return result;
}
QString AOApplication::get_audio_output_device()
{
QString result =
configini->value("default_audio_device", "default").value<QString>();
return result;
}
QStringList AOApplication::get_call_words()
{
return get_list_file(get_base_path() + "callwords.ini");
}
QStringList AOApplication::get_list_file(VPath path) QStringList AOApplication::get_list_file(VPath path)
{ {
@ -202,6 +61,7 @@ bool AOApplication::write_to_file(QString p_text, QString p_file, bool make_dir)
if (f_log.open(QIODevice::WriteOnly | QIODevice::Text | if (f_log.open(QIODevice::WriteOnly | QIODevice::Text |
QIODevice::Truncate)) { QIODevice::Truncate)) {
QTextStream out(&f_log); QTextStream out(&f_log);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
out.setCodec("UTF-8"); out.setCodec("UTF-8");
#endif #endif
@ -233,6 +93,7 @@ bool AOApplication::append_to_file(QString p_text, QString p_file,
QFile f_log(p_file); QFile f_log(p_file);
if (f_log.open(QIODevice::WriteOnly | QIODevice::Append)) { if (f_log.open(QIODevice::WriteOnly | QIODevice::Append)) {
QTextStream out(&f_log); QTextStream out(&f_log);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
out.setCodec("UTF-8"); out.setCodec("UTF-8");
#endif #endif
@ -245,101 +106,23 @@ bool AOApplication::append_to_file(QString p_text, QString p_file,
return false; return false;
} }
QVector<server_type> AOApplication::read_favorite_servers() QMultiMap<QString, QString> AOApplication::load_demo_logs_list() const
{ {
QVector<server_type> serverlist; QString l_log_path = applicationDirPath() + "/logs/";
QDir l_log_folder(l_log_path);
l_log_folder.setFilter(QDir::NoDotAndDotDot | QDir::Dirs);
// demo server is always at the top QMultiMap<QString,QString> l_demo_logs;
server_type demo_server; for (const QString &l_demo_folder_name : l_log_folder.entryList()) {
demo_server.ip = "127.0.0.1"; QDir l_demo_folder(l_log_path + l_demo_folder_name);
demo_server.port = 99999; l_demo_folder.setFilter(QDir::Files);
demo_server.name = tr("Demo playback"); l_demo_folder.setNameFilters(QStringList() << "*.demo");
demo_server.desc = tr("Play back demos you have previously recorded");
serverlist.append(demo_server);
QString fav_servers_ini_path(get_base_path() + "favorite_servers.ini"); for (QString l_demo_name : l_demo_folder.entryList()) {
if (!QFile::exists(fav_servers_ini_path)) { l_demo_logs.insert(l_demo_folder_name, l_demo_name);
qWarning() << "failed to locate favorite_servers.ini, falling back to legacy serverlist.txt";
serverlist += read_legacy_favorite_servers();
}
else {
QSettings fav_servers_ini(fav_servers_ini_path, QSettings::IniFormat);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
fav_servers_ini.setIniCodec("UTF-8");
#endif
auto grouplist = fav_servers_ini.childGroups();
{ // remove all negative and non-numbers
auto filtered_grouplist = grouplist;
for (const QString &group : qAsConst(grouplist)) {
bool ok = false;
const int l_num = group.toInt(&ok);
if (ok && l_num >= 0) {
continue;
} }
filtered_grouplist.append(group);
}
std::sort(filtered_grouplist.begin(), filtered_grouplist.end(), [](const auto &a, const auto &b) -> bool {
return a.toInt() < b.toInt();
});
grouplist = std::move(filtered_grouplist);
} }
return l_demo_logs;
for(const QString &group: qAsConst(grouplist)) {
server_type f_server;
fav_servers_ini.beginGroup(group);
f_server.ip = fav_servers_ini.value("address", "127.0.0.1").toString();
f_server.port = fav_servers_ini.value("port", 27016).toInt();
f_server.name = fav_servers_ini.value("name", "Missing Name").toString();
f_server.desc = fav_servers_ini.value("desc", "No description").toString();
f_server.socket_type = to_connection_type.value(fav_servers_ini.value("protocol", "tcp").toString());
serverlist.append(std::move(f_server));
fav_servers_ini.endGroup();
}
}
return serverlist;
}
QVector<server_type> AOApplication::read_legacy_favorite_servers()
{
QVector<server_type> serverlist;
QFile serverlist_txt(get_base_path() + "serverlist.txt");
if (!serverlist_txt.exists()) {
qWarning() << "serverlist.txt does not exist";
} else if (!serverlist_txt.open(QIODevice::ReadOnly)) {
qWarning() << "failed to open serverlist.txt";
} else {
QTextStream stream(&serverlist_txt);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
stream.setCodec("UTF-8");
#endif
while (!stream.atEnd())
{
QStringList contents = stream.readLine().split(":");
int item_count = contents.size();
if (item_count < 3 || item_count > 4) {
continue;
}
server_type server;
server.ip = contents.at(0);
server.port = contents.at(1).toInt();
server.name = contents.at(2);
if (item_count == 4) {
server.socket_type = connection_type(contents.at(3).toInt());
} else {
server.socket_type = TCP;
}
serverlist.append(std::move(server));
}
serverlist_txt.close();
}
return serverlist;
} }
QString AOApplication::read_design_ini(QString p_identifier, QString AOApplication::read_design_ini(QString p_identifier,
@ -368,7 +151,7 @@ QString AOApplication::read_design_ini(QString p_identifier,
Qt::TransformationMode AOApplication::get_scaling(QString p_scaling) Qt::TransformationMode AOApplication::get_scaling(QString p_scaling)
{ {
if (p_scaling.isEmpty()) if (p_scaling.isEmpty())
p_scaling = get_default_scaling(); p_scaling = Options::getInstance().defaultScalingMode();
if (p_scaling == "smooth") if (p_scaling == "smooth")
return Qt::SmoothTransformation; return Qt::SmoothTransformation;
@ -377,7 +160,7 @@ Qt::TransformationMode AOApplication::get_scaling(QString p_scaling)
QPoint AOApplication::get_button_spacing(QString p_identifier, QString p_file) QPoint AOApplication::get_button_spacing(QString p_identifier, QString p_file)
{ {
QString value = get_config_value(p_identifier, p_file, current_theme, get_subtheme(), default_theme); QString value = get_config_value(p_identifier, p_file, Options::getInstance().theme(), Options::getInstance().subTheme(), default_theme);
QPoint return_value; QPoint return_value;
return_value.setX(0); return_value.setX(0);
@ -423,7 +206,7 @@ pos_size_type AOApplication::get_element_dimensions(QString p_identifier,
QString AOApplication::get_design_element(QString p_identifier, QString p_file, QString AOApplication::get_design_element(QString p_identifier, QString p_file,
QString p_misc) QString p_misc)
{ {
QString value = get_config_value(p_identifier, p_file, current_theme, get_subtheme(), default_theme, p_misc); QString value = get_config_value(p_identifier, p_file, Options::getInstance().theme(), Options::getInstance().subTheme(), default_theme, p_misc);
if (!value.isEmpty()) if (!value.isEmpty())
return value; return value;
return ""; return "";
@ -432,7 +215,7 @@ QString AOApplication::get_design_element(QString p_identifier, QString p_file,
// tfw this function is only used for lobby and nowhere else // tfw this function is only used for lobby and nowhere else
int AOApplication::get_font_size(QString p_identifier, QString p_file) int AOApplication::get_font_size(QString p_identifier, QString p_file)
{ {
QString value = get_config_value(p_identifier, p_file, current_theme, get_subtheme(), default_theme); QString value = get_config_value(p_identifier, p_file, Options::getInstance().theme(), Options::getInstance().subTheme(), default_theme);
if (!value.isEmpty()) if (!value.isEmpty())
return value.toInt(); return value.toInt();
return 10; return 10;
@ -440,7 +223,7 @@ int AOApplication::get_font_size(QString p_identifier, QString p_file)
QColor AOApplication::get_color(QString p_identifier, QString p_file) QColor AOApplication::get_color(QString p_identifier, QString p_file)
{ {
QString value = get_config_value(p_identifier, p_file, current_theme, get_subtheme(), default_theme); QString value = get_config_value(p_identifier, p_file, Options::getInstance().theme(), Options::getInstance().subTheme(), default_theme);
QColor return_color(0, 0, 0); QColor return_color(0, 0, 0);
if (value.isEmpty()) if (value.isEmpty())
@ -460,7 +243,7 @@ QColor AOApplication::get_color(QString p_identifier, QString p_file)
QString AOApplication::get_stylesheet(QString p_file) QString AOApplication::get_stylesheet(QString p_file)
{ {
QString path = get_asset(p_file, current_theme, get_subtheme(), default_theme); QString path = get_asset(p_file, Options::getInstance().theme(), Options::getInstance().subTheme(), default_theme);
QFile design_ini; QFile design_ini;
design_ini.setFileName(path); design_ini.setFileName(path);
if (!design_ini.open(QIODevice::ReadOnly)) if (!design_ini.open(QIODevice::ReadOnly))
@ -480,7 +263,7 @@ QString AOApplication::get_stylesheet(QString p_file)
QString AOApplication::get_tagged_stylesheet(QString target_tag, QString p_file) QString AOApplication::get_tagged_stylesheet(QString target_tag, QString p_file)
{ {
QString path = get_asset(p_file, current_theme, get_subtheme(), default_theme); QString path = get_asset(p_file, Options::getInstance().theme(), Options::getInstance().subTheme(), default_theme);
QFile design_ini; QFile design_ini;
design_ini.setFileName(path); design_ini.setFileName(path);
if (!design_ini.open(QIODevice::ReadOnly)) if (!design_ini.open(QIODevice::ReadOnly))
@ -514,7 +297,7 @@ QString AOApplication::get_tagged_stylesheet(QString target_tag, QString p_file)
QString AOApplication::get_chat_markup(QString p_identifier, QString p_chat) QString AOApplication::get_chat_markup(QString p_identifier, QString p_chat)
{ {
// New Chadly method // New Chadly method
QString value = get_config_value(p_identifier, "chat_config.ini", current_theme, get_subtheme(), default_theme, p_chat); QString value = get_config_value(p_identifier, "chat_config.ini", Options::getInstance().theme(), Options::getInstance().subTheme(), default_theme, p_chat);
if (!value.isEmpty()) if (!value.isEmpty())
return value.toUtf8(); return value.toUtf8();
@ -557,14 +340,14 @@ QColor AOApplication::get_chat_color(QString p_identifier, QString p_chat)
QString AOApplication::get_penalty_value(QString p_identifier) QString AOApplication::get_penalty_value(QString p_identifier)
{ {
return get_config_value(p_identifier, "penalty/penalty.ini", current_theme, return get_config_value(p_identifier, "penalty/penalty.ini", Options::getInstance().theme(),
get_subtheme(), default_theme, ""); Options::getInstance().subTheme(), default_theme, "");
} }
QString AOApplication::get_court_sfx(QString p_identifier, QString p_misc) QString AOApplication::get_court_sfx(QString p_identifier, QString p_misc)
{ {
QString value = get_config_value(p_identifier, "courtroom_sounds.ini", current_theme, get_subtheme(), default_theme, p_misc); QString value = get_config_value(p_identifier, "courtroom_sounds.ini", Options::getInstance().theme(), Options::getInstance().subTheme(), default_theme, p_misc);
if (!value.isEmpty()) if (!value.isEmpty())
return value.toUtf8(); return value.toUtf8();
return ""; return "";
@ -615,10 +398,10 @@ QString AOApplication::read_char_ini(QString p_char, QString p_search_line,
{ {
QSettings settings(get_real_path(get_character_path(p_char, "char.ini")), QSettings settings(get_real_path(get_character_path(p_char, "char.ini")),
QSettings::IniFormat); QSettings::IniFormat);
settings.beginGroup(target_tag);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
settings.setIniCodec("UTF-8"); settings.setIniCodec("UTF-8");
#endif #endif
settings.beginGroup(target_tag);
QString value = settings.value(p_search_line).value<QString>(); QString value = settings.value(p_search_line).value<QString>();
settings.endGroup(); settings.endGroup();
return value; return value;
@ -629,6 +412,7 @@ void AOApplication::set_char_ini(QString p_char, QString value,
{ {
QSettings settings(get_real_path(get_character_path(p_char, "char.ini")), QSettings settings(get_real_path(get_character_path(p_char, "char.ini")),
QSettings::IniFormat); QSettings::IniFormat);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
settings.setIniCodec("UTF-8"); settings.setIniCodec("UTF-8");
#endif #endif
@ -927,8 +711,8 @@ int AOApplication::get_text_delay(QString p_char, QString p_emote)
QStringList AOApplication::get_effects(QString p_char) QStringList AOApplication::get_effects(QString p_char)
{ {
const QStringList l_filepath_list{ const QStringList l_filepath_list{
get_asset("effects/effects.ini", current_theme, get_subtheme(), default_theme, ""), get_asset("effects/effects.ini", Options::getInstance().theme(), Options::getInstance().subTheme(), default_theme, ""),
get_asset("effects.ini", current_theme, get_subtheme(), default_theme, read_char_ini(p_char, "effects", "Options")), get_asset("effects.ini", Options::getInstance().theme(), Options::getInstance().subTheme(), default_theme, read_char_ini(p_char, "effects", "Options")),
}; };
QStringList l_effect_name_list; QStringList l_effect_name_list;
@ -943,7 +727,6 @@ QStringList AOApplication::get_effects(QString p_char)
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
l_effects_ini.setIniCodec("UTF-8"); l_effects_ini.setIniCodec("UTF-8");
#endif #endif
// port legacy effects // port legacy effects
if (!l_effects_ini.contains("version/major") || l_effects_ini.value("version/major").toInt() < 2) if (!l_effects_ini.contains("version/major") || l_effects_ini.value("version/major").toInt() < 2)
{ {
@ -998,8 +781,8 @@ QString AOApplication::get_effect(QString effect, QString p_char,
p_folder = read_char_ini(p_char, "effects", "Options"); p_folder = read_char_ini(p_char, "effects", "Options");
QStringList paths { QStringList paths {
get_image("effects/" + effect, current_theme, get_subtheme(), default_theme, ""), get_image("effects/" + effect, Options::getInstance().theme(), Options::getInstance().subTheme(), default_theme, ""),
get_image(effect, current_theme, get_subtheme(), default_theme, p_folder) get_image(effect, Options::getInstance().theme(), Options::getInstance().subTheme(), default_theme, p_folder)
}; };
for (const auto &p : paths) for (const auto &p : paths)
@ -1014,8 +797,8 @@ QString AOApplication::get_effect_property(QString fx_name, QString p_char,
if (p_folder == "") if (p_folder == "")
p_folder = read_char_ini(p_char, "effects", "Options"); p_folder = read_char_ini(p_char, "effects", "Options");
const auto paths = get_asset_paths("effects/effects.ini", current_theme, get_subtheme(), default_theme, ""); const auto paths = get_asset_paths("effects/effects.ini", Options::getInstance().theme(), Options::getInstance().subTheme(), default_theme, "");
const auto misc_paths = get_asset_paths("effects.ini", current_theme, get_subtheme(), default_theme, p_folder); const auto misc_paths = get_asset_paths("effects.ini", Options::getInstance().theme(), Options::getInstance().subTheme(), default_theme, p_folder);
QString path; QString path;
QString f_result; QString f_result;
for (const VPath &p : paths + misc_paths) { for (const VPath &p : paths + misc_paths) {
@ -1060,230 +843,3 @@ bool AOApplication::get_pos_is_judge(const QString &p_pos)
} }
return positions.contains(p_pos.trimmed()); return positions.contains(p_pos.trimmed());
} }
bool AOApplication::get_blank_blip()
{
QString result = configini->value("blank_blip", "false").value<QString>();
return result.startsWith("true");
}
bool AOApplication::get_looping_sfx()
{
QString result = configini->value("looping_sfx", "true").value<QString>();
return result.startsWith("true");
}
bool AOApplication::objection_stop_music()
{
QString result =
configini->value("objection_stop_music", "false").value<QString>();
return result.startsWith("true");
}
bool AOApplication::is_streaming_disabled()
{
return configini->value("streaming_disabled", false).toBool();
}
bool AOApplication::is_instant_objection_enabled()
{
QString result = configini->value("instant_objection", "true").value<QString>();
return result.startsWith("true");
}
bool AOApplication::is_desyncrhonized_logs_enabled()
{
QString result = configini->value("desync_logs", "true").value<QString>();
return result.startsWith("true");
}
bool AOApplication::is_discord_enabled()
{
QString result = configini->value("discord", "true").value<QString>();
return result.startsWith("true");
}
bool AOApplication::is_shake_enabled()
{
QString result = configini->value("shake", "true").value<QString>();
return result.startsWith("true");
}
bool AOApplication::is_effects_enabled()
{
QString result = configini->value("effects", "true").value<QString>();
return result.startsWith("true");
}
bool AOApplication::is_frame_network_enabled()
{
QString result = configini->value("framenetwork", "true").value<QString>();
return result.startsWith("true");
}
bool AOApplication::is_colorlog_enabled()
{
QString result = configini->value("colorlog", "true").value<QString>();
return result.startsWith("true");
}
bool AOApplication::is_stickysounds_enabled()
{
QString result = configini->value("stickysounds", "false").value<QString>();
return result.startsWith("true");
}
bool AOApplication::is_stickyeffects_enabled()
{
QString result = configini->value("stickyeffects", "false").value<QString>();
return result.startsWith("true");
}
bool AOApplication::is_stickypres_enabled()
{
QString result = configini->value("stickypres", "false").value<QString>();
return result.startsWith("true");
}
bool AOApplication::is_customchat_enabled()
{
QString result = configini->value("customchat", "true").value<QString>();
return result.startsWith("true");
}
bool AOApplication::is_sticker_enabled()
{
QString result = configini->value("sticker", "true").value<QString>();
return result.startsWith("true");
}
bool AOApplication::is_continuous_enabled()
{
QString result = configini->value("continuous_playback", "false").value<QString>();
return result.startsWith("true");
}
bool AOApplication::is_category_stop_enabled()
{
QString result = configini->value("category_stop", "false").value<QString>();
return result.startsWith("true");
}
bool AOApplication::get_casing_enabled()
{
QString result = configini->value("casing_enabled", "false").value<QString>();
return result.startsWith("true");
}
bool AOApplication::get_casing_defence_enabled()
{
QString result =
configini->value("casing_defence_enabled", "false").value<QString>();
return result.startsWith("true");
}
bool AOApplication::get_casing_prosecution_enabled()
{
QString result =
configini->value("casing_prosecution_enabled", "false").value<QString>();
return result.startsWith("true");
}
bool AOApplication::get_casing_judge_enabled()
{
QString result =
configini->value("casing_judge_enabled", "false").value<QString>();
return result.startsWith("true");
}
bool AOApplication::get_casing_juror_enabled()
{
QString result =
configini->value("casing_juror_enabled", "false").value<QString>();
return result.startsWith("true");
}
bool AOApplication::get_casing_steno_enabled()
{
QString result =
configini->value("casing_steno_enabled", "false").value<QString>();
return result.startsWith("true");
}
bool AOApplication::get_casing_cm_enabled()
{
QString result =
configini->value("casing_cm_enabled", "false").value<QString>();
return result.startsWith("true");
}
QString AOApplication::get_casing_can_host_cases()
{
QString result =
configini->value("casing_can_host_cases", "Turnabout Check Your Settings")
.value<QString>();
return result;
}
bool AOApplication::get_text_logging_enabled()
{
QString result =
configini->value("automatic_logging_enabled", "true").value<QString>();
return result.startsWith("true");
}
bool AOApplication::get_demo_logging_enabled()
{
QString result =
configini->value("demo_logging_enabled", "true").value<QString>();
return result.startsWith("true");
}
QString AOApplication::get_subtheme()
{
QString result =
configini->value("subtheme", "server").value<QString>();
// Server means we want the server to decide for us
if (result == "server")
// 'subtheme' variable is affected by the server
result = subtheme;
// Default means we don't want any subthemes
else if (result == "default")
result = "";
return result;
}
bool AOApplication::get_animated_theme()
{
QString result =
configini->value("animated_theme", "false").value<QString>();
return result.startsWith("true");
}
QString AOApplication::get_default_scaling()
{
return configini->value("default_scaling", "fast").value<QString>();
}
QStringList AOApplication::get_mount_paths()
{
return configini->value("mount_paths").value<QStringList>();
}
bool AOApplication::get_player_count_optout()
{
return configini->value("player_count_optout", "false").value<QString>()
.startsWith("true");
}
bool AOApplication::get_sfx_on_idle()
{
return configini->value("sfx_on_idle", "true").value<QString>()
.startsWith("true");
}
bool AOApplication::get_evidence_double_click()
{
return configini->value("evidence_double_click", "false").value<QString>()
.startsWith("true");
}

View File

@ -0,0 +1,96 @@
#include "widgets/add_server_dialog.h"
#include "datatypes.h"
#include "options.h"
#include <QComboBox>
#include <QDebug>
#include <QDialogButtonBox>
#include <QFile>
#include <QLineEdit>
#include <QLabel>
#include <QPlainTextEdit>
#include <QPushButton>
#include <QSpinBox>
#include <QUiLoader>
#include <QVBoxLayout>
#define FROM_UI(type, name) \
; \
ui_##name = findChild<type *>(#name);
AddServerDialog::AddServerDialog()
{
QUiLoader l_loader(this);
QFile l_uiFile(Options::getInstance().getUIAsset(DEFAULT_UI));
if (!l_uiFile.open(QFile::ReadOnly)) {
qCritical() << "Unable to open file " << l_uiFile.fileName();
return;
}
ui_widget = l_loader.load(&l_uiFile, this);
auto l_layout = new QVBoxLayout(this);
l_layout->addWidget(ui_widget);
FROM_UI(QLineEdit, server_display_name_edit);
FROM_UI(QLineEdit, server_hostname_edit);
FROM_UI(QSpinBox, server_port_box);
FROM_UI(QComboBox, server_protocol_box);
FROM_UI(QPlainTextEdit, server_description_edit);
FROM_UI(QDialogButtonBox, server_dialog_button);
connect(ui_server_dialog_button, &QDialogButtonBox::accepted, this,
&::AddServerDialog::onSavePressed);
connect(ui_server_dialog_button, &QDialogButtonBox::rejected, this,
&AddServerDialog::onCancelPressed);
FROM_UI(QLabel, server_legacy_lbl);
FROM_UI(QLineEdit, server_legacy_edit);
FROM_UI(QPushButton, server_legacy_load_button);
connect(ui_server_legacy_load_button, &QPushButton::released, this,
&AddServerDialog::parseLegacyServerEntry);
}
void AddServerDialog::onSavePressed()
{
server_type server;
server.name = ui_server_display_name_edit->text();
server.ip = ui_server_hostname_edit->text();
server.port = ui_server_port_box->value();
server.desc = ui_server_description_edit->toPlainText();
server.socket_type =
ui_server_protocol_box->currentIndex() == TCP_INDEX ? TCP : WEBSOCKETS;
Options::getInstance().addFavorite(server);
close();
}
void AddServerDialog::onCancelPressed()
{
close();
deleteLater();
}
void AddServerDialog::parseLegacyServerEntry()
{
QStringList l_legacy_entry = ui_server_legacy_edit->text().split(":");
server_type l_server_entry;
if (l_legacy_entry.isEmpty()) {
qDebug() << "Legacy entry empty.";
return;
}
int l_item_count = l_legacy_entry.size();
if (l_item_count >= 3) {
ui_server_hostname_edit->setText(l_legacy_entry.at(0));
ui_server_port_box->setValue(l_legacy_entry.at(1).toInt());
ui_server_display_name_edit->setText(l_legacy_entry.at(2));
if (l_item_count >= 4) {
if (l_legacy_entry.at(3) == "ws") {
ui_server_protocol_box->setCurrentIndex(1);
}
else {
ui_server_protocol_box->setCurrentIndex(0);
}
}
}
}

View File

@ -0,0 +1,648 @@
#include "widgets/aooptionsdialog.h"
#include "QDesktopServices"
#include "aoapplication.h"
#include "bass.h"
#include "file_functions.h"
#include "networkmanager.h"
#include "options.h"
#include <QCheckBox>
#include <QCollator>
#include <QComboBox>
#include <QDialogButtonBox>
#include <QGroupBox>
#include <QLabel>
#include <QLineEdit>
#include <QPlainTextEdit>
#include <QPushButton>
#include <QResource>
#include <QSpinBox>
#include <QUiLoader>
#include <QVBoxLayout>
#define FROM_UI(type, name) \
; \
ui_##name = findChild<type *>(#name);
AOOptionsDialog::AOOptionsDialog(QDialog *parent, AOApplication *p_ao_app)
: QDialog(parent)
{
ao_app = p_ao_app;
setupUI();
}
void AOOptionsDialog::populateAudioDevices()
{
ui_audio_device_combobox->clear();
if (needsDefaultAudioDevice()) {
ui_audio_device_combobox->addItem("default");
}
BASS_DEVICEINFO info;
for (int a = 0; BASS_GetDeviceInfo(a, &info); a++) {
ui_audio_device_combobox->addItem(info.name);
}
}
template <>
void AOOptionsDialog::setWidgetData(QCheckBox *widget, const bool &value)
{
widget->setChecked(value);
}
template <> bool AOOptionsDialog::widgetData(QCheckBox *widget) const
{
return widget->isChecked();
}
template <>
void AOOptionsDialog::setWidgetData(QLineEdit *widget, const QString &value)
{
widget->setText(value);
}
template <> QString AOOptionsDialog::widgetData(QLineEdit *widget) const
{
return widget->text();
}
template <>
void AOOptionsDialog::setWidgetData(QLineEdit *widget, const uint16_t &value)
{
widget->setText(QString::number(value));
}
template <> uint16_t AOOptionsDialog::widgetData(QLineEdit *widget) const
{
return widget->text().toUShort();
}
template <>
void AOOptionsDialog::setWidgetData(QPlainTextEdit *widget,
const QStringList &value)
{
widget->setPlainText(value.join('\n'));
}
template <>
QStringList AOOptionsDialog::widgetData(QPlainTextEdit *widget) const
{
return widget->toPlainText().trimmed().split('\n');
}
template <>
void AOOptionsDialog::setWidgetData(QSpinBox *widget, const int &value)
{
widget->setValue(value);
}
template <> int AOOptionsDialog::widgetData(QSpinBox *widget) const
{
return widget->value();
}
template <>
void AOOptionsDialog::setWidgetData(QComboBox *widget, const QString &value)
{
for (auto i = 0; i < widget->count(); i++) {
if (widget->itemText(i) == value) {
widget->setCurrentIndex(i);
return;
}
}
qWarning() << "value" << value << "not found for widget"
<< widget->objectName();
}
template <> QString AOOptionsDialog::widgetData(QComboBox *widget) const
{
return widget->currentText();
}
template <>
void AOOptionsDialog::setWidgetData(QGroupBox *widget, const bool &value)
{
widget->setChecked(value);
}
template <> bool AOOptionsDialog::widgetData(QGroupBox *widget) const
{
return widget->isChecked();
}
template <>
void AOOptionsDialog::setWidgetData(QListWidget *widget,
const QStringList &value)
{
widget->addItems(value);
}
template <> QStringList AOOptionsDialog::widgetData(QListWidget *widget) const
{
QStringList paths;
for (auto i = 1; i < widget->count(); i++) {
paths.append(widget->item(i)->text());
}
return paths;
}
template <typename T, typename V>
void AOOptionsDialog::registerOption(const QString &widgetName,
V (Options::*getter)() const,
void (Options::*setter)(V))
{
auto *widget = findChild<T *>(widgetName);
if (!widget) {
qWarning() << "could not find widget" << widgetName;
return;
}
OptionEntry entry;
entry.load = [=] {
setWidgetData<T, V>(widget, (Options::getInstance().*getter)());
};
entry.save = [=] {
(Options::getInstance().*setter)(widgetData<T, V>(widget));
};
optionEntries.append(entry);
}
void AOOptionsDialog::updateValues()
{
QSet<QString> themes;
QStringList bases = Options::getInstance().mountPaths();
bases.push_front(get_base_path());
for (const QString &base : bases) {
QStringList l_themes =
QDir(base + "themes").entryList(QDir::Dirs | QDir::NoDotAndDotDot);
// Resorts list to match numeric sorting found in Windows.
QCollator l_sorting;
l_sorting.setNumericMode(true);
std::sort(l_themes.begin(), l_themes.end(), l_sorting);
for (const QString &l_theme : qAsConst(l_themes)) {
if (!themes.contains(l_theme)) {
ui_theme_combobox->addItem(l_theme);
themes.insert(l_theme);
}
}
}
QStringList l_subthemes =
QDir(ao_app->get_real_path(ao_app->get_theme_path("")))
.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
for (const QString &l_subtheme : qAsConst(l_subthemes)) {
if (l_subtheme.toLower() != "server" && l_subtheme.toLower() != "default" &&
l_subtheme.toLower() != "effects" && l_subtheme.toLower() != "misc") {
ui_subtheme_combobox->addItem(l_subtheme);
}
}
ao_app->net_manager->request_document(
MSDocumentType::PrivacyPolicy, [this](QString document) {
if (document.isEmpty()) {
document = tr("Couldn't get the privacy policy.");
}
ui_privacy_policy->setHtml(document);
});
for (const OptionEntry &entry : qAsConst(optionEntries)) {
entry.load();
}
}
void AOOptionsDialog::savePressed()
{
bool l_reload_theme_required = (ui_theme_combobox->currentText() != Options::getInstance().theme());
for (const OptionEntry &entry : qAsConst(optionEntries)) {
entry.save();
}
if (l_reload_theme_required) {
emit reloadThemeRequest();
}
close();
}
void AOOptionsDialog::discardPressed() { close(); }
void AOOptionsDialog::buttonClicked(QAbstractButton *button)
{
if (ui_settings_buttons->buttonRole(button) == QDialogButtonBox::ResetRole) {
if (QMessageBox::question(
this, "", "Restore default settings?\nThis can't be undone!",
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
// Destructive operation.
Options::getInstance().clearConfig();
updateValues();
}
}
}
void AOOptionsDialog::onReloadThemeClicked()
{
Options::getInstance().setTheme(ui_theme_combobox->currentText());
Options::getInstance().setSettingsSubTheme(ui_subtheme_combobox->currentText());
Options::getInstance().setAnimatedThemeEnabled(
ui_animated_theme_cb->isChecked());
emit reloadThemeRequest();
delete layout();
delete ui_settings_widget;
optionEntries.clear();
setupUI();
}
void AOOptionsDialog::themeChanged(int i)
{
ui_subtheme_combobox->clear();
// Fill the combobox with the names of the themes.
ui_subtheme_combobox->addItem("server");
ui_subtheme_combobox->addItem("default");
QStringList l_subthemes = QDir(ao_app->get_real_path(ao_app->get_theme_path(
"", ui_theme_combobox->itemText(i))))
.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
for (const QString &l_subthemes : qAsConst(l_subthemes)) {
if (l_subthemes.toLower() != "server" &&
l_subthemes.toLower() != "default" &&
l_subthemes.toLower() != "effects" && l_subthemes.toLower() != "misc") {
ui_subtheme_combobox->addItem(l_subthemes);
}
}
QString l_ressource_name = Options::getInstance().theme() + ".rcc";
QString l_resource =
ao_app->get_asset("themes/" + ui_theme_combobox->currentText() + ".rcc");
if (l_resource.isEmpty()) {
QResource::unregisterResource(
ao_app->get_asset("themes/" + l_ressource_name));
qDebug() << "Unable to locate ressource file" << l_ressource_name;
return;
}
QResource::registerResource(l_resource);
}
void AOOptionsDialog::setupUI()
{
QUiLoader l_loader(this);
QFile l_uiFile(Options::getInstance().getUIAsset("options_dialog.ui"));
if (!l_uiFile.open(QFile::ReadOnly)) {
qWarning() << "Unable to open file " << l_uiFile.fileName();
return;
}
ui_settings_widget = l_loader.load(&l_uiFile, this);
auto l_layout = new QVBoxLayout(this);
l_layout->addWidget(ui_settings_widget);
// General dialog element.
FROM_UI(QDialogButtonBox, settings_buttons);
connect(ui_settings_buttons, &QDialogButtonBox::accepted, this,
&AOOptionsDialog::savePressed);
connect(ui_settings_buttons, &QDialogButtonBox::rejected, this,
&AOOptionsDialog::discardPressed);
connect(ui_settings_buttons, &QDialogButtonBox::clicked, this,
&AOOptionsDialog::buttonClicked);
// Gameplay Tab
FROM_UI(QComboBox, theme_combobox)
connect(ui_theme_combobox,
QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&AOOptionsDialog::themeChanged);
registerOption<QComboBox, QString>("theme_combobox", &Options::theme,
&Options::setTheme);
FROM_UI(QComboBox, subtheme_combobox)
registerOption<QComboBox, QString>("subtheme_combobox", &Options::settingsSubTheme,
&Options::setSettingsSubTheme);
FROM_UI(QPushButton, theme_reload_button)
connect(ui_theme_reload_button, &QPushButton::clicked, this,
&::AOOptionsDialog::onReloadThemeClicked);
FROM_UI(QPushButton, theme_folder_button)
connect(ui_theme_folder_button, &QPushButton::clicked, this, [=] {
QString p_path = ao_app->get_real_path(ao_app->get_theme_path(
"", ui_theme_combobox->itemText(ui_theme_combobox->currentIndex())));
if (!dir_exists(p_path)) {
return;
}
QDesktopServices::openUrl(QUrl::fromLocalFile(p_path));
});
FROM_UI(QCheckBox, animated_theme_cb)
FROM_UI(QSpinBox, stay_time_spinbox)
FROM_UI(QCheckBox, instant_objection_cb)
FROM_UI(QSpinBox, text_crawl_spinbox)
FROM_UI(QSpinBox, chat_ratelimit_spinbox)
FROM_UI(QLineEdit, username_textbox)
FROM_UI(QCheckBox, showname_cb)
FROM_UI(QLineEdit, default_showname_textbox)
FROM_UI(QLineEdit, ms_textbox)
FROM_UI(QCheckBox, discord_cb)
FROM_UI(QComboBox, language_combobox)
FROM_UI(QComboBox, scaling_combobox)
FROM_UI(QCheckBox, shake_cb)
FROM_UI(QCheckBox, effects_cb)
FROM_UI(QCheckBox, framenetwork_cb)
FROM_UI(QCheckBox, colorlog_cb)
FROM_UI(QCheckBox, stickysounds_cb)
FROM_UI(QCheckBox, stickyeffects_cb)
FROM_UI(QCheckBox, stickypres_cb)
FROM_UI(QCheckBox, customchat_cb)
FROM_UI(QCheckBox, sticker_cb)
FROM_UI(QCheckBox, continuous_cb)
FROM_UI(QCheckBox, category_stop_cb)
FROM_UI(QCheckBox, sfx_on_idle_cb)
FROM_UI(QCheckBox, evidence_double_click_cb)
registerOption<QCheckBox, bool>("animated_theme_cb",
&Options::animatedThemeEnabled,
&Options::setAnimatedThemeEnabled);
registerOption<QSpinBox, int>("stay_time_spinbox", &Options::textStayTime,
&Options::setTextStayTime);
registerOption<QCheckBox, bool>("instant_objection_cb",
&Options::objectionSkipQueueEnabled,
&Options::setObjectionSkipQueueEnabled);
registerOption<QSpinBox, int>("text_crawl_spinbox", &Options::textCrawlSpeed,
&Options::setTextCrawlSpeed);
registerOption<QSpinBox, int>("chat_ratelimit_spinbox",
&Options::chatRateLimit,
&Options::setChatRateLimit);
registerOption<QLineEdit, QString>("username_textbox", &Options::username,
&Options::setUsername);
registerOption<QCheckBox, bool>("showname_cb",
&Options::customShownameEnabled,
&Options::setCustomShownameEnabled);
registerOption<QLineEdit, QString>("default_showname_textbox",
&Options::shownameOnJoin,
&Options::setShownameOnJoin);
registerOption<QLineEdit, QString>("ms_textbox",
&Options::alternativeMasterserver,
&Options::setAlternativeMasterserver);
registerOption<QCheckBox, bool>("discord_cb", &Options::discordEnabled,
&Options::setDiscordEnabled);
registerOption<QComboBox, QString>("language_combobox", &Options::language,
&Options::setLanguage);
registerOption<QComboBox, QString>("scaling_combobox",
&Options::defaultScalingMode,
&Options::setDefaultScalingMode);
// Populate scaling dropdown. This is necessary as we need the user data
// embeeded into the entry.
ui_scaling_combobox->addItem(tr("Pixel"), "fast");
ui_scaling_combobox->addItem(tr("Smooth"), "smooth");
registerOption<QCheckBox, bool>("shake_cb", &Options::shakeEnabled,
&Options::setShakeEnabled);
registerOption<QCheckBox, bool>("effects_cb", &Options::effectsEnabled,
&Options::setEffectsEnabled);
registerOption<QCheckBox, bool>("framenetwork_cb",
&Options::networkedFrameSfxEnabled,
&Options::setNetworkedFrameSfxEnabled);
registerOption<QCheckBox, bool>("colorlog_cb", &Options::colorLogEnabled,
&Options::setColorLogEnabled);
registerOption<QCheckBox, bool>(
"stickysounds_cb", &Options::clearSoundsDropdownOnPlayEnabled,
&Options::setClearSoundsDropdownOnPlayEnabled);
registerOption<QCheckBox, bool>(
"stickyeffects_cb", &Options::clearEffectsDropdownOnPlayEnabled,
&Options::setClearEffectsDropdownOnPlayEnabled);
registerOption<QCheckBox, bool>("stickypres_cb",
&Options::clearPreOnPlayEnabled,
&Options::setClearPreOnPlayEnabled);
registerOption<QCheckBox, bool>("customchat_cb",
&Options::customChatboxEnabled,
&Options::setCustomChatboxEnabled);
registerOption<QCheckBox, bool>("sticker_cb",
&Options::characterStickerEnabled,
&Options::setCharacterStickerEnabled);
registerOption<QCheckBox, bool>("continuous_cb",
&Options::continuousPlaybackEnabled,
&Options::setContinuousPlaybackEnabled);
registerOption<QCheckBox, bool>("category_stop_cb",
&Options::stopMusicOnCategoryEnabled,
&Options::setStopMusicOnCategoryEnabled);
registerOption<QCheckBox, bool>("sfx_on_idle_cb",
&Options::playSelectedSFXOnIdle,
&Options::setPlaySelectedSFXOnIdle);
registerOption<QCheckBox, bool>("evidence_double_click_cb",
&Options::evidenceDoubleClickEdit,
&Options::setEvidenceDoubleClickEdit);
// Callwords tab. This could just be a QLineEdit, but no, we decided to allow
// people to put a billion entries in.
FROM_UI(QPlainTextEdit, callwords_textbox)
registerOption<QPlainTextEdit, QStringList>(
"callwords_textbox", &Options::callwords, &Options::setCallwords);
// Audio tab.
FROM_UI(QComboBox, audio_device_combobox)
populateAudioDevices();
registerOption<QComboBox, QString>("audio_device_combobox",
&Options::audioOutputDevice,
&Options::setAudioOutputDevice);
FROM_UI(QSpinBox, suppress_audio_spinbox)
FROM_UI(QSpinBox, bliprate_spinbox)
FROM_UI(QCheckBox, blank_blips_cb)
FROM_UI(QCheckBox, loopsfx_cb)
FROM_UI(QCheckBox, objectmusic_cb)
FROM_UI(QCheckBox, disablestreams_cb)
registerOption<QSpinBox, int>("suppress_audio_spinbox",
&::Options::defaultSuppressAudio,
&Options::setDefaultSupressedAudio);
registerOption<QSpinBox, int>("bliprate_spinbox", &::Options::blipRate,
&Options::setBlipRate);
registerOption<QCheckBox, bool>("blank_blips_cb", &Options::blankBlip,
&Options::setBlankBlip);
registerOption<QCheckBox, bool>("loopsfx_cb", &Options::loopingSfx,
&Options::setLoopingSfx);
registerOption<QCheckBox, bool>("objectmusic_cb",
&Options::objectionStopMusic,
&Options::setObjectionStopMusic);
registerOption<QCheckBox, bool>("disablestreams_cb",
&Options::streamingEnabled,
&Options::setStreamingEnabled);
// Asset tab
FROM_UI(QListWidget, mount_list)
auto *defaultMount =
new QListWidgetItem(tr("%1 (default)").arg(get_base_path()));
defaultMount->setFlags(Qt::ItemFlag::NoItemFlags);
ui_mount_list->addItem(defaultMount);
registerOption<QListWidget, QStringList>("mount_list", &Options::mountPaths,
&Options::setMountPaths);
FROM_UI(QPushButton, mount_add)
connect(ui_mount_add, &QPushButton::clicked, this, [this] {
QString path = QFileDialog::getExistingDirectory(
this, tr("Select a base folder"), QApplication::applicationDirPath(),
QFileDialog::ShowDirsOnly);
if (path.isEmpty()) {
return;
}
QDir dir(QApplication::applicationDirPath());
QString relative = dir.relativeFilePath(path);
if (!relative.contains("../")) {
path = relative;
}
QListWidgetItem *dir_item = new QListWidgetItem(path);
ui_mount_list->addItem(dir_item);
ui_mount_list->setCurrentItem(dir_item);
// quick hack to update buttons
emit ui_mount_list->itemSelectionChanged();
});
FROM_UI(QPushButton, mount_remove)
connect(ui_mount_remove, &QPushButton::clicked, this, [this] {
auto selected = ui_mount_list->selectedItems();
if (selected.isEmpty()) return;
delete selected[0];
emit ui_mount_list->itemSelectionChanged();
asset_cache_dirty = true;
});
FROM_UI(QPushButton, mount_up)
connect(ui_mount_up, &QPushButton::clicked, this, [this] {
auto selected = ui_mount_list->selectedItems();
if (selected.isEmpty()) return;
auto *item = selected[0];
int row = ui_mount_list->row(item);
ui_mount_list->takeItem(row);
int new_row = qMax(1, row - 1);
ui_mount_list->insertItem(new_row, item);
ui_mount_list->setCurrentRow(new_row);
asset_cache_dirty = true;
});
FROM_UI(QPushButton, mount_down)
connect(ui_mount_down, &QPushButton::clicked, this, [this] {
auto selected = ui_mount_list->selectedItems();
if (selected.isEmpty()) return;
auto *item = selected[0];
int row = ui_mount_list->row(item);
ui_mount_list->takeItem(row);
int new_row = qMin(ui_mount_list->count() + 1, row + 1);
ui_mount_list->insertItem(new_row, item);
ui_mount_list->setCurrentRow(new_row);
asset_cache_dirty = true;
});
FROM_UI(QPushButton, mount_clear_cache)
connect(ui_mount_clear_cache, &QPushButton::clicked, this, [this] {
asset_cache_dirty = true;
ui_mount_clear_cache->setEnabled(false);
});
connect(ui_mount_list, &QListWidget::itemSelectionChanged, this, [this] {
auto selected_items = ui_mount_list->selectedItems();
bool row_selected = !ui_mount_list->selectedItems().isEmpty();
ui_mount_remove->setEnabled(row_selected);
ui_mount_up->setEnabled(row_selected);
ui_mount_down->setEnabled(row_selected);
if (!row_selected) return;
int row = ui_mount_list->row(selected_items[0]);
if (row <= 1) ui_mount_up->setEnabled(false);
if (row >= ui_mount_list->count() - 1) ui_mount_down->setEnabled(false);
});
// Logging tab
FROM_UI(QCheckBox, downwards_cb)
FROM_UI(QSpinBox, length_spinbox)
FROM_UI(QCheckBox, log_newline_cb)
FROM_UI(QSpinBox, log_margin_spinbox)
FROM_UI(QLabel, log_timestamp_format_lbl)
FROM_UI(QComboBox, log_timestamp_format_combobox)
registerOption<QCheckBox, bool>("downwards_cb",
&Options::logDirectionDownwards,
&Options::setLogDirectionDownwards);
registerOption<QSpinBox, int>("length_spinbox", &Options::maxLogSize,
&Options::setMaxLogSize);
registerOption<QCheckBox, bool>("log_newline_cb", &Options::logNewline,
&Options::setLogNewline);
registerOption<QSpinBox, int>("log_margin_spinbox", &Options::logMargin,
&Options::setLogMargin);
FROM_UI(QCheckBox, log_timestamp_cb)
registerOption<QCheckBox, bool>("log_timestamp_cb",
&Options::logTimestampEnabled,
&Options::setLogTimestampEnabled);
connect(ui_log_timestamp_cb, &QCheckBox::stateChanged, this,
&::AOOptionsDialog::timestampCbChanged);
ui_log_timestamp_format_lbl->setText(
tr("Log timestamp format:\n") +
QDateTime::currentDateTime().toString(
Options::getInstance().logTimestampFormat()));
FROM_UI(QComboBox, log_timestamp_format_combobox)
registerOption<QComboBox, QString>("log_timestamp_format_combobox",
&Options::logTimestampFormat,
&Options::setLogTimestampFormat);
connect(ui_log_timestamp_format_combobox, &QComboBox::currentTextChanged,
this, &::AOOptionsDialog::onTimestampFormatEdited);
QString l_current_format = Options::getInstance().logTimestampFormat();
ui_log_timestamp_format_combobox->setCurrentText(l_current_format);
if (!Options::getInstance().logTimestampEnabled()) {
ui_log_timestamp_format_combobox->setDisabled(true);
}
FROM_UI(QCheckBox, log_ic_actions_cb)
FROM_UI(QCheckBox, desync_logs_cb)
FROM_UI(QCheckBox, log_text_cb)
registerOption<QCheckBox, bool>("log_ic_actions_cb", &Options::logIcActions,
&Options::setLogIcActions);
registerOption<QCheckBox, bool>("desync_logs_cb",
&Options::desynchronisedLogsEnabled,
&Options::setDesynchronisedLogsEnabled);
registerOption<QCheckBox, bool>("log_text_cb", &Options::logToTextFileEnabled,
&Options::setLogToTextFileEnabled);
registerOption<QCheckBox, bool>("log_demo_cb", &Options::logToDemoFileEnabled,
&Options::setLogToDemoFileEnabled);
// DSGVO/Privacy tab
FROM_UI(QTextBrowser, privacy_policy)
ui_privacy_policy->setPlainText(tr("Getting privacy policy..."));
updateValues();
}
void AOOptionsDialog::onTimestampFormatEdited()
{
ui_log_timestamp_format_lbl->setText(
tr("Log timestamp format:\n") +
QDateTime::currentDateTime().toString(
ui_log_timestamp_format_combobox->currentText()));
}
void AOOptionsDialog::timestampCbChanged(int state)
{
ui_log_timestamp_format_combobox->setDisabled(state == 0);
}
#if (defined(_WIN32) || defined(_WIN64))
bool AOOptionsDialog::needsDefaultAudioDevice() { return true; }
#elif (defined(LINUX) || defined(__linux__))
bool AOOptionsDialog::needsDefaultAudioDevice() { return false; }
#elif defined __APPLE__
bool AOOptionsDialog::needsDefaultAudioDevice() { return true; }
#else
#error This operating system is not supported.
#endif

View File

@ -0,0 +1,101 @@
#include "widgets/direct_connect_dialog.h"
#include "networkmanager.h"
#include "options.h"
#include "debug_functions.h"
#include <QComboBox>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QSpinBox>
#include <QUiLoader>
#include <QVBoxLayout>
#include <QRegularExpressionMatch>
#include <QStringBuilder>
#include <QUrl>
#define FROM_UI(type, name) \
; \
ui_##name = findChild<type *>(#name);
DirectConnectDialog::DirectConnectDialog(NetworkManager *p_net_manager) :
net_manager(p_net_manager)
{
QUiLoader l_loader(this);
QFile l_uiFile(Options::getInstance().getUIAsset(DEFAULT_UI));
if (!l_uiFile.open(QFile::ReadOnly)) {
qCritical() << "Unable to open file " << l_uiFile.fileName();
return;
}
ui_widget = l_loader.load(&l_uiFile, this);
auto l_layout = new QVBoxLayout(this);
l_layout->addWidget(ui_widget);
FROM_UI(QLineEdit, direct_hostname_edit)
FROM_UI(QLabel, direct_connection_status_lbl)
FROM_UI(QPushButton, direct_connect_button);
connect(ui_direct_connect_button, &QPushButton::pressed,
this, &DirectConnectDialog::onConnectPressed);
FROM_UI(QPushButton, direct_cancel_button);
connect(ui_direct_cancel_button, &QPushButton::pressed,
this, &DirectConnectDialog::close);
connect(net_manager, &NetworkManager::server_connected,
this, &DirectConnectDialog::onServerConnected);
connect(&connect_timeout, &QTimer::timeout, this,
&DirectConnectDialog::onConnectTimeout);
connect_timeout.setSingleShot(true);
}
void DirectConnectDialog::onConnectPressed()
{
QString l_hostname = ui_direct_hostname_edit->text();
if (!SCHEME_PATTERN.match(l_hostname).hasMatch()) {
l_hostname = "tcp://" % l_hostname;
}
QUrl l_url(l_hostname);
if (!l_url.isValid()) {
call_error(tr("Invalid URL."));
return;
}
if (!to_connection_type.contains(l_url.scheme())) {
call_error(tr("Scheme not recognized. Must be either of the following: ") % QStringList::fromVector(to_connection_type.keys().toVector()).join(", "));
return;
}
if (l_url.port() == -1) {
call_error(tr("Invalid server port."));
return;
}
server_type l_server;
l_server.socket_type = to_connection_type[l_url.scheme()];
l_server.ip = l_url.host();
l_server.port = l_url.port();
l_server.name = "Direct Connection";
net_manager->connect_to_server(l_server);
ui_direct_connect_button->setEnabled(false);
ui_direct_connection_status_lbl->setText("Connecting...");
ui_direct_connection_status_lbl->setStyleSheet("color : rgb(0,64,156)");
connect_timeout.start(CONNECT_TIMEOUT);
}
void DirectConnectDialog::onServerConnected()
{
net_manager->join_to_server();
ui_direct_connection_status_lbl->setText("Connected!");
ui_direct_connection_status_lbl->setStyleSheet("color: rgb(0,128,0)");
close();
}
void DirectConnectDialog::onConnectTimeout()
{
ui_direct_connect_button->setEnabled(true);
ui_direct_connection_status_lbl->setText("Connection Timeout!");
ui_direct_connection_status_lbl->setStyleSheet("color: rgb(255,0,0)");
}

View File

@ -0,0 +1,87 @@
#include "widgets/edit_server_dialog.h"
#include "datatypes.h"
#include "options.h"
#include <QComboBox>
#include <QDebug>
#include <QDialogButtonBox>
#include <QFile>
#include <QLineEdit>
#include <QLabel>
#include <QPlainTextEdit>
#include <QPushButton>
#include <QSpinBox>
#include <QUiLoader>
#include <QVBoxLayout>
#define FROM_UI(type, name) \
; \
ui_##name = findChild<type *>(#name);
EditServerDialog::EditServerDialog(int index) :
index(index) // lol
{
QUiLoader l_loader(this);
QFile l_uiFile(Options::getInstance().getUIAsset(DEFAULT_UI));
if (!l_uiFile.open(QFile::ReadOnly)) {
qCritical() << "Unable to open file " << l_uiFile.fileName();
return;
}
ui_widget = l_loader.load(&l_uiFile, this);
auto l_layout = new QVBoxLayout(this);
l_layout->addWidget(ui_widget);
FROM_UI(QLineEdit, server_display_name_edit);
FROM_UI(QLineEdit, server_hostname_edit);
FROM_UI(QSpinBox, server_port_box);
FROM_UI(QComboBox, server_protocol_box);
FROM_UI(QPlainTextEdit, server_description_edit);
FROM_UI(QDialogButtonBox, server_dialog_button);
connect(ui_server_dialog_button, &QDialogButtonBox::accepted, this,
&::EditServerDialog::onSavePressed);
connect(ui_server_dialog_button, &QDialogButtonBox::rejected, this,
&EditServerDialog::onCancelPressed);
// We don't need you.
FROM_UI(QLabel, server_legacy_lbl);
FROM_UI(QLineEdit, server_legacy_edit);
FROM_UI(QPushButton, server_legacy_load_button);
ui_server_legacy_lbl->setVisible(false);
ui_server_legacy_edit->setVisible(false);
ui_server_legacy_load_button->setVisible(false);
loadEntry();
}
void EditServerDialog::loadEntry()
{
server_type server = Options::getInstance().favorites().at(index);
ui_server_display_name_edit->setText(server.name);
ui_server_hostname_edit->setText(server.ip);
ui_server_port_box->setValue(server.port);
ui_server_description_edit->setPlainText(server.desc);
ui_server_protocol_box->setCurrentIndex(server.socket_type);
}
void EditServerDialog::onSavePressed()
{
server_type server;
server.name = ui_server_display_name_edit->text();
server.ip = ui_server_hostname_edit->text();
server.port = ui_server_port_box->value();
server.desc = ui_server_description_edit->toPlainText();
server.socket_type =
ui_server_protocol_box->currentIndex() == TCP_INDEX ? TCP : WEBSOCKETS;
Options::getInstance().updateFavorite(server, index);
close();
deleteLater();
}
void EditServerDialog::onCancelPressed()
{
close();
deleteLater();
}