From 49938eea0f86e13639b072355e1bd97900662e4f Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Tue, 12 Mar 2019 00:26:40 +0100 Subject: makes all the bass stuff optional --- src/aoblipplayer.cpp | 7 ++++++- src/aomusicplayer.cpp | 6 ++++++ src/aooptionsdialog.cpp | 4 +++- src/aosfxplayer.cpp | 6 ++++++ src/courtroom.cpp | 11 +++++++++-- 5 files changed, 30 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/aoblipplayer.cpp b/src/aoblipplayer.cpp index 74757c5..0a8b427 100644 --- a/src/aoblipplayer.cpp +++ b/src/aoblipplayer.cpp @@ -12,9 +12,11 @@ void AOBlipPlayer::set_blips(QString p_sfx) for (int n_stream = 0 ; n_stream < 5 ; ++n_stream) { + #ifdef BASSAUDIO BASS_StreamFree(m_stream_list[n_stream]); m_stream_list[n_stream] = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_UNICODE | BASS_ASYNCFILE); + #endif } set_volume(m_volume); @@ -28,10 +30,11 @@ void AOBlipPlayer::blip_tick() m_cycle = 0; HSTREAM f_stream = m_stream_list[f_cycle]; - + #ifdef BASSAUDIO if (ao_app->get_audio_output_device() != "default") BASS_ChannelSetDevice(f_stream, BASS_GetDevice()); BASS_ChannelPlay(f_stream, false); + #endif } void AOBlipPlayer::set_volume(int p_value) @@ -42,6 +45,8 @@ void AOBlipPlayer::set_volume(int p_value) for (int n_stream = 0 ; n_stream < 5 ; ++n_stream) { + #ifdef BASSAUDIO BASS_ChannelSetAttribute(m_stream_list[n_stream], BASS_ATTRIB_VOL, volume); + #endif } } diff --git a/src/aomusicplayer.cpp b/src/aomusicplayer.cpp index 997d82d..521fae9 100644 --- a/src/aomusicplayer.cpp +++ b/src/aomusicplayer.cpp @@ -8,11 +8,14 @@ AOMusicPlayer::AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app) AOMusicPlayer::~AOMusicPlayer() { + #ifdef BASSAUDIO BASS_ChannelStop(m_stream); + #endif } void AOMusicPlayer::play(QString p_song) { + #ifdef BASSAUDIO BASS_ChannelStop(m_stream); QString f_path = ao_app->get_music_path(p_song); @@ -24,11 +27,14 @@ void AOMusicPlayer::play(QString p_song) if (ao_app->get_audio_output_device() != "default") BASS_ChannelSetDevice(m_stream, BASS_GetDevice()); BASS_ChannelPlay(m_stream, false); +#endif } void AOMusicPlayer::set_volume(int p_value) { m_volume = p_value; float volume = m_volume / 100.0f; + #ifdef BASSAUDIO BASS_ChannelSetAttribute(m_stream, BASS_ATTRIB_VOL, volume); + #endif } diff --git a/src/aooptionsdialog.cpp b/src/aooptionsdialog.cpp index cd69c76..0f6a054 100644 --- a/src/aooptionsdialog.cpp +++ b/src/aooptionsdialog.cpp @@ -199,6 +199,7 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi ui_callwords_layout->addWidget(ui_callwords_explain_lbl); // The audio tab. + #ifdef BASSAUDIO ui_audio_tab = new QWidget(); ui_settings_tabs->addTab(ui_audio_tab, tr("Audio")); @@ -218,7 +219,7 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi ui_audio_device_combobox = new QComboBox(ui_audio_widget); - // Let's fill out the combobox with the available audio devices. + // Let's fill out the combobox with the available audio devices. Or don't if there is no audio int a = 0; BASS_DEVICEINFO info; @@ -311,6 +312,7 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi ui_blank_blips_cb->setChecked(p_ao_app->get_blank_blip()); ui_audio_layout->setWidget(7, QFormLayout::FieldRole, ui_blank_blips_cb); + #endif // The casing tab! ui_casing_tab = new QWidget(); diff --git a/src/aosfxplayer.cpp b/src/aosfxplayer.cpp index 7fe7987..869fa9b 100644 --- a/src/aosfxplayer.cpp +++ b/src/aosfxplayer.cpp @@ -9,6 +9,7 @@ AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app) void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout) { + #ifdef BASSAUDIO BASS_ChannelStop(m_stream); QString misc_path = ""; @@ -36,16 +37,21 @@ void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout) if (ao_app->get_audio_output_device() != "default") BASS_ChannelSetDevice(m_stream, BASS_GetDevice()); BASS_ChannelPlay(m_stream, false); +#endif } void AOSfxPlayer::stop() { + #ifdef BASSAUDIO BASS_ChannelStop(m_stream); + #endif } void AOSfxPlayer::set_volume(int p_value) { m_volume = p_value; float volume = p_value / 100.0f; + #ifdef BASSAUDIO BASS_ChannelSetAttribute(m_stream, BASS_ATTRIB_VOL, volume); + #endif } diff --git a/src/courtroom.cpp b/src/courtroom.cpp index be7629b..6a5379a 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -3,7 +3,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() { ao_app = p_ao_app; - + #ifdef BASSAUDIO // Change the default audio output device to be the one the user has given // in his config.ini file for now. int a = 0; @@ -28,6 +28,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() } } } + #endif keepalive_timer = new QTimer(this); keepalive_timer->start(60000); @@ -3498,23 +3499,29 @@ Courtroom::~Courtroom() delete blip_player; } + #if (defined (_WIN32) || defined (_WIN64)) void Courtroom::load_bass_opus_plugin() { + #ifdef BASSAUDIO BASS_PluginLoad("bassopus.dll", 0); + #endif } #elif (defined (LINUX) || defined (__linux__)) void Courtroom::load_bass_opus_plugin() { + #ifdef BASSAUDIO BASS_PluginLoad("libbassopus.so", 0); + #endif } #elif defined __APPLE__ void Courtroom::load_bass_opus_plugin() { QString libpath = ao_app->get_base_path() + "../../Frameworks/libbassopus.dylib"; QByteArray ba = libpath.toLocal8Bit(); - + #ifdef BASSAUDIO BASS_PluginLoad(ba.data(), 0); + #endif } #else #error This operating system is unsupported for bass plugins. -- cgit From 744c100159ff7b79e01c40ec57e42d37650d139b Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Tue, 12 Mar 2019 00:27:11 +0100 Subject: make discord optional --- src/discord_rich_presence.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/discord_rich_presence.cpp b/src/discord_rich_presence.cpp index 10f5833..0bb7f9f 100644 --- a/src/discord_rich_presence.cpp +++ b/src/discord_rich_presence.cpp @@ -4,6 +4,7 @@ namespace AttorneyOnline { Discord::Discord() { + #ifdef DISCORD DiscordEventHandlers handlers; std::memset(&handlers, 0, sizeof(handlers)); handlers = {}; @@ -18,15 +19,19 @@ Discord::Discord() }; qInfo() << "Initializing Discord RPC"; Discord_Initialize(APPLICATION_ID, &handlers, 1, nullptr); + #endif } Discord::~Discord() { + #ifdef DISCORD Discord_Shutdown(); + #endif } void Discord::state_lobby() { + #ifdef DISCORD DiscordRichPresence presence; std::memset(&presence, 0, sizeof(presence)); presence.largeImageKey = "ao2-logo"; @@ -36,12 +41,13 @@ void Discord::state_lobby() presence.state = "In Lobby"; presence.details = "Idle"; Discord_UpdatePresence(&presence); + #endif } void Discord::state_server(std::string name, std::string server_id) { qDebug() << "Discord RPC: Setting server state"; - + #ifdef DISCORD DiscordRichPresence presence; std::memset(&presence, 0, sizeof(presence)); presence.largeImageKey = "ao2-logo"; @@ -59,6 +65,7 @@ void Discord::state_server(std::string name, std::string server_id) this->server_name = name; this->timestamp = timestamp; Discord_UpdatePresence(&presence); + #endif } void Discord::state_character(std::string name) @@ -67,7 +74,7 @@ void Discord::state_character(std::string name) auto name_friendly = QString(name.c_str()).replace('_', ' ').toStdString(); const std::string playing_as = "Playing as " + name_friendly; qDebug() << "Discord RPC: Setting character state (" << playing_as.c_str() << ")"; - + #ifdef DISCORD DiscordRichPresence presence; std::memset(&presence, 0, sizeof(presence)); presence.largeImageKey = "ao2-logo"; @@ -81,12 +88,13 @@ void Discord::state_character(std::string name) presence.smallImageKey = name_internal.c_str(); // presence.smallImageText = name_internal.c_str(); Discord_UpdatePresence(&presence); + #endif } void Discord::state_spectate() { qDebug() << "Discord RPC: Setting specator state"; - + #ifdef DISCORD DiscordRichPresence presence; std::memset(&presence, 0, sizeof(presence)); presence.largeImageKey = "ao2-logo"; @@ -98,6 +106,7 @@ void Discord::state_spectate() presence.state = "Spectating"; Discord_UpdatePresence(&presence); + #endif } } -- cgit From 92c54ba2ebee12a87360d00f2982a9083f06166d Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Tue, 12 Mar 2019 19:27:13 +0100 Subject: Revert "make discord optional" This reverts commit 744c100159ff7b79e01c40ec57e42d37650d139b. --- src/discord_rich_presence.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/discord_rich_presence.cpp b/src/discord_rich_presence.cpp index 0bb7f9f..10f5833 100644 --- a/src/discord_rich_presence.cpp +++ b/src/discord_rich_presence.cpp @@ -4,7 +4,6 @@ namespace AttorneyOnline { Discord::Discord() { - #ifdef DISCORD DiscordEventHandlers handlers; std::memset(&handlers, 0, sizeof(handlers)); handlers = {}; @@ -19,19 +18,15 @@ Discord::Discord() }; qInfo() << "Initializing Discord RPC"; Discord_Initialize(APPLICATION_ID, &handlers, 1, nullptr); - #endif } Discord::~Discord() { - #ifdef DISCORD Discord_Shutdown(); - #endif } void Discord::state_lobby() { - #ifdef DISCORD DiscordRichPresence presence; std::memset(&presence, 0, sizeof(presence)); presence.largeImageKey = "ao2-logo"; @@ -41,13 +36,12 @@ void Discord::state_lobby() presence.state = "In Lobby"; presence.details = "Idle"; Discord_UpdatePresence(&presence); - #endif } void Discord::state_server(std::string name, std::string server_id) { qDebug() << "Discord RPC: Setting server state"; - #ifdef DISCORD + DiscordRichPresence presence; std::memset(&presence, 0, sizeof(presence)); presence.largeImageKey = "ao2-logo"; @@ -65,7 +59,6 @@ void Discord::state_server(std::string name, std::string server_id) this->server_name = name; this->timestamp = timestamp; Discord_UpdatePresence(&presence); - #endif } void Discord::state_character(std::string name) @@ -74,7 +67,7 @@ void Discord::state_character(std::string name) auto name_friendly = QString(name.c_str()).replace('_', ' ').toStdString(); const std::string playing_as = "Playing as " + name_friendly; qDebug() << "Discord RPC: Setting character state (" << playing_as.c_str() << ")"; - #ifdef DISCORD + DiscordRichPresence presence; std::memset(&presence, 0, sizeof(presence)); presence.largeImageKey = "ao2-logo"; @@ -88,13 +81,12 @@ void Discord::state_character(std::string name) presence.smallImageKey = name_internal.c_str(); // presence.smallImageText = name_internal.c_str(); Discord_UpdatePresence(&presence); - #endif } void Discord::state_spectate() { qDebug() << "Discord RPC: Setting specator state"; - #ifdef DISCORD + DiscordRichPresence presence; std::memset(&presence, 0, sizeof(presence)); presence.largeImageKey = "ao2-logo"; @@ -106,7 +98,6 @@ void Discord::state_spectate() presence.state = "Spectating"; Discord_UpdatePresence(&presence); - #endif } } -- cgit From 6e93d6e1bea8fd539499625f2a980acd83ef424e Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Tue, 12 Mar 2019 19:30:03 +0100 Subject: discord optional v2 --- src/discord_rich_presence.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src') diff --git a/src/discord_rich_presence.cpp b/src/discord_rich_presence.cpp index 10f5833..a310a68 100644 --- a/src/discord_rich_presence.cpp +++ b/src/discord_rich_presence.cpp @@ -2,6 +2,7 @@ namespace AttorneyOnline { +#ifdef DISCORD Discord::Discord() { DiscordEventHandlers handlers; @@ -99,5 +100,36 @@ void Discord::state_spectate() presence.state = "Spectating"; Discord_UpdatePresence(&presence); } +#else +Discord::Discord() +{ + +} + +Discord::~Discord() +{ + +} + +void Discord::state_lobby() +{ + +} +void Discord::state_server(std::string name, std::string server_id) +{ + qDebug() << "Discord RPC: Setting server state"; +} + +void Discord::state_character(std::string name) +{ + qDebug() << "Discord RPC: Setting character state"; +} + +void Discord::state_spectate() +{ + qDebug() << "Discord RPC: Setting specator state"; + +} +#endif } -- cgit From 0b6f376f8f635bfcfd72f621a1077a35efc72342 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Tue, 12 Mar 2019 19:53:06 +0100 Subject: qt can play the blips just fine --- src/aoblipplayer.cpp | 70 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 64 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/aoblipplayer.cpp b/src/aoblipplayer.cpp index 0a8b427..b95f32a 100644 --- a/src/aoblipplayer.cpp +++ b/src/aoblipplayer.cpp @@ -1,5 +1,6 @@ #include "aoblipplayer.h" +#if defined(BASSAUDIO) //Using bass.dll for the blips AOBlipPlayer::AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app) { m_parent = parent; @@ -12,11 +13,9 @@ void AOBlipPlayer::set_blips(QString p_sfx) for (int n_stream = 0 ; n_stream < 5 ; ++n_stream) { - #ifdef BASSAUDIO BASS_StreamFree(m_stream_list[n_stream]); m_stream_list[n_stream] = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_UNICODE | BASS_ASYNCFILE); - #endif } set_volume(m_volume); @@ -30,11 +29,9 @@ void AOBlipPlayer::blip_tick() m_cycle = 0; HSTREAM f_stream = m_stream_list[f_cycle]; - #ifdef BASSAUDIO if (ao_app->get_audio_output_device() != "default") BASS_ChannelSetDevice(f_stream, BASS_GetDevice()); BASS_ChannelPlay(f_stream, false); - #endif } void AOBlipPlayer::set_volume(int p_value) @@ -45,8 +42,69 @@ void AOBlipPlayer::set_volume(int p_value) for (int n_stream = 0 ; n_stream < 5 ; ++n_stream) { - #ifdef BASSAUDIO BASS_ChannelSetAttribute(m_stream_list[n_stream], BASS_ATTRIB_VOL, volume); - #endif } } +#elif defined(QTAUDIO) //Using Qt's QSoundEffect class +AOBlipPlayer::AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app) +{ + m_parent = parent; + ao_app = p_ao_app; +} + +void AOBlipPlayer::set_blips(QString p_sfx) +{ + QString f_path = ao_app->get_sounds_path(p_sfx); + + for (int n_stream = 0 ; n_stream < 5 ; ++n_stream) + { + m_blips.setSource(QUrl::fromLocalFile(f_path)); + } + + set_volume(m_volume); +} + +void AOBlipPlayer::blip_tick() +{ + int f_cycle = m_cycle++; + + if (m_cycle == 5) + m_cycle = 0; + + //HSTREAM f_stream = m_stream_list[f_cycle]; + //if (ao_app->get_audio_output_device() != "default") + //BASS_ChannelSetDevice(f_stream, BASS_GetDevice()); + //BASS_ChannelPlay(f_stream, false); + m_blips.play(); +} + +void AOBlipPlayer::set_volume(int p_value) +{ + m_volume = p_value; + + float volume = p_value / 100.0f; + + m_blips.setVolume(volume); +} +#else //No audio +AOBlipPlayer::AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app) +{ + m_parent = parent; + ao_app = p_ao_app; +} + +void AOBlipPlayer::set_blips(QString p_sfx) +{ + +} + +void AOBlipPlayer::blip_tick() +{ + +} + +void AOBlipPlayer::set_volume(int p_value) +{ + +} +#endif -- cgit From 71da60b5d6f77629b73fd232f97bed2ecaefb4c3 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Tue, 12 Mar 2019 20:14:54 +0100 Subject: sfx tested and works --- src/aosfxplayer.cpp | 76 ++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 70 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/aosfxplayer.cpp b/src/aosfxplayer.cpp index 869fa9b..077767b 100644 --- a/src/aosfxplayer.cpp +++ b/src/aosfxplayer.cpp @@ -1,6 +1,7 @@ #include "aosfxplayer.h" #include "file_functions.h" +#if defined(BASSAUDIO) //Using bass.dll for sfx AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app) { m_parent = parent; @@ -9,7 +10,6 @@ AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app) void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout) { - #ifdef BASSAUDIO BASS_ChannelStop(m_stream); QString misc_path = ""; @@ -37,21 +37,85 @@ void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout) if (ao_app->get_audio_output_device() != "default") BASS_ChannelSetDevice(m_stream, BASS_GetDevice()); BASS_ChannelPlay(m_stream, false); -#endif } void AOSfxPlayer::stop() { - #ifdef BASSAUDIO BASS_ChannelStop(m_stream); - #endif } void AOSfxPlayer::set_volume(int p_value) { m_volume = p_value; float volume = p_value / 100.0f; - #ifdef BASSAUDIO BASS_ChannelSetAttribute(m_stream, BASS_ATTRIB_VOL, volume); - #endif } +#elif defined(QTAUDIO) //Using Qt's QSoundEffect class +AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app) +{ + m_parent = parent; + ao_app = p_ao_app; +} + +void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout) +{ + m_sfx.stop(); + + QString misc_path = ""; + QString char_path = ""; + QString sound_path = ao_app->get_sounds_path(p_sfx); + + if (shout != "") + misc_path = ao_app->get_base_path() + "misc/" + shout + "/" + p_sfx; + if (p_char != "") + char_path = ao_app->get_character_path(p_char, p_sfx); + + QString f_path; + + if (file_exists(char_path)) + f_path = char_path; + else if (file_exists(misc_path)) + f_path = misc_path; + else + f_path = sound_path; + + m_sfx.setSource(QUrl::fromLocalFile(f_path)); + + set_volume(m_volume); + + m_sfx.play(); +} + +void AOSfxPlayer::stop() +{ + m_sfx.stop(); +} + +void AOSfxPlayer::set_volume(int p_value) +{ + m_volume = p_value; + float volume = p_value / 100.0f; + m_sfx.setVolume(volume); +} +#else +AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app) +{ + m_parent = parent; + ao_app = p_ao_app; +} + +void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout) +{ + +} + +void AOSfxPlayer::stop() +{ + +} + +void AOSfxPlayer::set_volume(int p_value) +{ + +} +#endif -- cgit From 1514ffea6ad747fc93f98752abb8f82acc9dc9bd Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Tue, 12 Mar 2019 20:47:47 +0100 Subject: qt music --- src/aomusicplayer.cpp | 59 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 53 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/aomusicplayer.cpp b/src/aomusicplayer.cpp index 521fae9..2791809 100644 --- a/src/aomusicplayer.cpp +++ b/src/aomusicplayer.cpp @@ -1,5 +1,6 @@ #include "aomusicplayer.h" +#if defined(BASSAUDIO) AOMusicPlayer::AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app) { m_parent = parent; @@ -8,14 +9,11 @@ AOMusicPlayer::AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app) AOMusicPlayer::~AOMusicPlayer() { - #ifdef BASSAUDIO BASS_ChannelStop(m_stream); - #endif } void AOMusicPlayer::play(QString p_song) { - #ifdef BASSAUDIO BASS_ChannelStop(m_stream); QString f_path = ao_app->get_music_path(p_song); @@ -27,14 +25,63 @@ void AOMusicPlayer::play(QString p_song) if (ao_app->get_audio_output_device() != "default") BASS_ChannelSetDevice(m_stream, BASS_GetDevice()); BASS_ChannelPlay(m_stream, false); -#endif } void AOMusicPlayer::set_volume(int p_value) { m_volume = p_value; float volume = m_volume / 100.0f; - #ifdef BASSAUDIO BASS_ChannelSetAttribute(m_stream, BASS_ATTRIB_VOL, volume); - #endif } +#elif defined(QTAUDIO) +AOMusicPlayer::AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app) +{ + m_parent = parent; + ao_app = p_ao_app; +} + +AOMusicPlayer::~AOMusicPlayer() +{ + m_player.stop(); +} + +void AOMusicPlayer::play(QString p_song) +{ + m_player.stop(); + + QString f_path = ao_app->get_music_path(p_song); + + m_player.setMedia(QUrl::fromLocalFile(f_path)); + + this->set_volume(m_volume); + + m_player.play(); +} + +void AOMusicPlayer::set_volume(int p_value) +{ + m_volume = p_value; + m_player.setVolume(m_volume); +} +#else +AOMusicPlayer::AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app) +{ + m_parent = parent; + ao_app = p_ao_app; +} + +AOMusicPlayer::~AOMusicPlayer() +{ + +} + +void AOMusicPlayer::play(QString p_song) +{ + +} + +void AOMusicPlayer::set_volume(int p_value) +{ + +} +#endif -- cgit From ece08930e3767def9895dbfa23936ce23ec96c73 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Wed, 13 Mar 2019 13:06:11 +0100 Subject: setVolume doesn't take floats --- src/aoblipplayer.cpp | 5 +---- src/aosfxplayer.cpp | 3 +-- 2 files changed, 2 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/aoblipplayer.cpp b/src/aoblipplayer.cpp index b95f32a..ffeb888 100644 --- a/src/aoblipplayer.cpp +++ b/src/aoblipplayer.cpp @@ -81,10 +81,7 @@ void AOBlipPlayer::blip_tick() void AOBlipPlayer::set_volume(int p_value) { m_volume = p_value; - - float volume = p_value / 100.0f; - - m_blips.setVolume(volume); + m_blips.setVolume(m_volume); } #else //No audio AOBlipPlayer::AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app) diff --git a/src/aosfxplayer.cpp b/src/aosfxplayer.cpp index 077767b..9f47e01 100644 --- a/src/aosfxplayer.cpp +++ b/src/aosfxplayer.cpp @@ -94,8 +94,7 @@ void AOSfxPlayer::stop() void AOSfxPlayer::set_volume(int p_value) { m_volume = p_value; - float volume = p_value / 100.0f; - m_sfx.setVolume(volume); + m_sfx.setVolume(m_volume); } #else AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app) -- cgit From bdde8822f4bb2ce2ef4e95fecb23c17afc0adcac Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Wed, 13 Mar 2019 21:36:12 +0100 Subject: begone, commented code --- src/aoblipplayer.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src') diff --git a/src/aoblipplayer.cpp b/src/aoblipplayer.cpp index ffeb888..4dfb895 100644 --- a/src/aoblipplayer.cpp +++ b/src/aoblipplayer.cpp @@ -71,10 +71,6 @@ void AOBlipPlayer::blip_tick() if (m_cycle == 5) m_cycle = 0; - //HSTREAM f_stream = m_stream_list[f_cycle]; - //if (ao_app->get_audio_output_device() != "default") - //BASS_ChannelSetDevice(f_stream, BASS_GetDevice()); - //BASS_ChannelPlay(f_stream, false); m_blips.play(); } -- cgit From 44d433d941575da0a16d3ad9c905ba71ec20d19c Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Wed, 13 Mar 2019 22:05:24 +0100 Subject: sfx glitch --- src/aosfxplayer.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/aosfxplayer.cpp b/src/aosfxplayer.cpp index 9f47e01..710d7a8 100644 --- a/src/aosfxplayer.cpp +++ b/src/aosfxplayer.cpp @@ -79,11 +79,14 @@ void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout) else f_path = sound_path; + if (file_exists(f_path)) //if its missing, it will glitch out + { m_sfx.setSource(QUrl::fromLocalFile(f_path)); set_volume(m_volume); m_sfx.play(); + } } void AOSfxPlayer::stop() -- cgit From 785168f8d36fc7c075f36cd88f13984c933b903c Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Wed, 13 Mar 2019 22:05:36 +0100 Subject: add a default for this --- src/text_file_functions.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/text_file_functions.cpp b/src/text_file_functions.cpp index 1e920d7..45e2e79 100644 --- a/src/text_file_functions.cpp +++ b/src/text_file_functions.cpp @@ -443,8 +443,9 @@ QString AOApplication::get_chat(QString p_char) QString AOApplication::get_char_shouts(QString p_char) { QString f_result = read_char_ini(p_char, "shouts", "Options"); - - return f_result; + if (f_result == "") + return "default"; + else return f_result; } int AOApplication::get_preanim_duration(QString p_char, QString p_emote) -- cgit From 2e4f0117b067c6d795a7d42fe23162d41260ff74 Mon Sep 17 00:00:00 2001 From: Cerapter Date: Thu, 9 May 2019 23:49:20 +0200 Subject: Text is now advanced based on graphemes, rather than bytes. --- src/courtroom.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index be7629b..c313a98 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -2024,6 +2024,7 @@ void Courtroom::chat_tick() //do not perform heavy operations here QString f_message = m_chatmessage[MESSAGE]; + f_message.remove(0, tick_pos); // Due to our new text speed system, we always need to stop the timer now. chat_tick_timer->stop(); @@ -2038,7 +2039,7 @@ void Courtroom::chat_tick() f_message.remove(0,2); } - if (tick_pos >= f_message.size()) + if (f_message.size() == 0) { text_state = 2; if (anim_state != 4) @@ -2050,7 +2051,16 @@ void Courtroom::chat_tick() else { - QString f_character = f_message.at(tick_pos); + QTextBoundaryFinder tbf(QTextBoundaryFinder::Grapheme, f_message); + QString f_character; + + tbf.toNextBoundary(); + + if (tbf.position() == -1) + f_character = f_message; + else + f_character = f_message.left(tbf.position()); + f_character = f_character.toHtmlEscaped(); if (f_character == " ") @@ -2265,7 +2275,7 @@ void Courtroom::chat_tick() if(blank_blip) qDebug() << "blank_blip found true"; - if (f_message.at(tick_pos) != ' ' || blank_blip) + if (f_character != ' ' || blank_blip) { if (blip_pos % blip_rate == 0 && !formatting_char) @@ -2277,7 +2287,7 @@ void Courtroom::chat_tick() ++blip_pos; } - ++tick_pos; + tick_pos += f_character.length(); // Restart the timer, but according to the newly set speeds, if there were any. // Keep the speed at bay. @@ -2304,6 +2314,7 @@ void Courtroom::chat_tick() } } + void Courtroom::show_testimony() { if (!testimony_in_progress || m_chatmessage[SIDE] != "wit") -- cgit From c8a4f69d144d4be59a1fd07151579d923bcc8a6e Mon Sep 17 00:00:00 2001 From: Cerapter Date: Fri, 10 May 2019 20:49:59 +0200 Subject: Fix escaped HTML characters fucking up the grapheme cluster sizes. --- src/courtroom.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index c313a98..ce82f88 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -2053,6 +2053,7 @@ void Courtroom::chat_tick() { QTextBoundaryFinder tbf(QTextBoundaryFinder::Grapheme, f_message); QString f_character; + int f_char_length; tbf.toNextBoundary(); @@ -2061,8 +2062,10 @@ void Courtroom::chat_tick() else f_character = f_message.left(tbf.position()); + f_char_length = f_character.length(); f_character = f_character.toHtmlEscaped(); + if (f_character == " ") ui_vp_message->insertPlainText(" "); @@ -2155,7 +2158,7 @@ void Courtroom::chat_tick() else { next_character_is_not_special = true; - tick_pos--; + tick_pos -= f_char_length; } } @@ -2176,7 +2179,7 @@ void Courtroom::chat_tick() else { next_character_is_not_special = true; - tick_pos--; + tick_pos -= f_char_length; } } @@ -2287,7 +2290,7 @@ void Courtroom::chat_tick() ++blip_pos; } - tick_pos += f_character.length(); + tick_pos += f_char_length; // Restart the timer, but according to the newly set speeds, if there were any. // Keep the speed at bay. -- cgit From 1f9a1bdd5d17d56fc3bfd4f5a35e3df476e74477 Mon Sep 17 00:00:00 2001 From: cents02 Date: Fri, 31 May 2019 21:47:47 +0000 Subject: Fixed issues #47 on both client and server --- src/courtroom.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index c313a98..c798885 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -2707,6 +2707,7 @@ void Courtroom::on_ooc_return_pressed() } else { + other_charid = -1; append_server_chatmessage("CLIENT", "You are no longer paired with anyone.", "1"); } } @@ -2992,6 +2993,7 @@ void Courtroom::on_pair_list_clicked(QModelIndex p_index) QListWidgetItem *f_item = ui_pair_list->item(p_index.row()); QString f_char = f_item->text(); QString real_char; + int f_cid = -1; if (f_char.endsWith(" [x]")) { @@ -2999,17 +3001,19 @@ void Courtroom::on_pair_list_clicked(QModelIndex p_index) f_item->setText(real_char); } else - real_char = f_char; - - int f_cid = -1; - - for (int n_char = 0 ; n_char < char_list.size() ; n_char++) { + real_char = f_char; + for (int n_char = 0 ; n_char < char_list.size() ; n_char++) + { if (char_list.at(n_char).name == real_char) f_cid = n_char; + } } - if (f_cid < 0 || f_cid >= char_list.size()) + + + + if (f_cid < -2 || f_cid >= char_list.size()) { qDebug() << "W: " << real_char << " not present in char_list"; return; @@ -3028,8 +3032,10 @@ void Courtroom::on_pair_list_clicked(QModelIndex p_index) for (int i = 0; i < ui_pair_list->count(); i++) { ui_pair_list->item(i)->setText(sorted_pair_list.at(i)); } - + if(other_charid != -1) + { f_item->setText(real_char + " [x]"); + } } void Courtroom::on_music_list_double_clicked(QModelIndex p_model) -- cgit From 09d8e9e7a45d8c7d9557253e1fb48f3e9bd9c894 Mon Sep 17 00:00:00 2001 From: cents02 Date: Fri, 31 May 2019 21:52:22 +0000 Subject: Update courtroom.cpp --- src/courtroom.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index c798885..9fd52d8 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -3009,10 +3009,6 @@ void Courtroom::on_pair_list_clicked(QModelIndex p_index) f_cid = n_char; } } - - - - if (f_cid < -2 || f_cid >= char_list.size()) { qDebug() << "W: " << real_char << " not present in char_list"; @@ -3037,7 +3033,6 @@ void Courtroom::on_pair_list_clicked(QModelIndex p_index) f_item->setText(real_char + " [x]"); } } - void Courtroom::on_music_list_double_clicked(QModelIndex p_model) { if (is_muted) -- cgit From ae8552578020dcd515e1fe80f2b95e6be461744c Mon Sep 17 00:00:00 2001 From: cents02 Date: Mon, 3 Jun 2019 09:00:24 +0000 Subject: Resolved requests/issues. --- src/courtroom.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 9fd52d8..020a54c 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -3009,7 +3009,7 @@ void Courtroom::on_pair_list_clicked(QModelIndex p_index) f_cid = n_char; } } - if (f_cid < -2 || f_cid >= char_list.size()) + if (f_cid < -1 || f_cid >= char_list.size()) { qDebug() << "W: " << real_char << " not present in char_list"; return; @@ -3030,7 +3030,7 @@ void Courtroom::on_pair_list_clicked(QModelIndex p_index) } if(other_charid != -1) { - f_item->setText(real_char + " [x]"); + f_item->setText(real_char + " [x]"); } } void Courtroom::on_music_list_double_clicked(QModelIndex p_model) -- cgit From f826ba390bcf11427aab5058728ad7dbd3f699a6 Mon Sep 17 00:00:00 2001 From: cents02 Date: Sun, 30 Jun 2019 21:47:48 +0000 Subject: New feature! /save_case . Takes two parameters, name and cr status. E.g: /save_case case1 lfp . It takes court evidence but leaves the doc and cmdoc options blank to be entered manually(if anybody actually puts anything). --- src/courtroom.cpp | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 020a54c..581ce5a 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -2864,6 +2864,58 @@ void Courtroom::on_ooc_return_pressed() ui_ooc_chat_message->clear(); return; } + else if(ooc_message.startsWith("/save_case")) + { + QStringList command = ooc_message.split(" ", QString::SkipEmptyParts); + + QDir casefolder("base/cases"); + if (!casefolder.exists()) + { + QDir::current().mkdir("base/" + casefolder.dirName()); + append_server_chatmessage("CLIENT", "You don't have a `base/cases/` folder! It was just made for you, but seeing as it WAS just made for you, it's likely that you somehow deleted it.", "1"); + ui_ooc_chat_message->clear(); + return; + } + QStringList caseslist = casefolder.entryList(); + caseslist.removeOne("."); + caseslist.removeOne(".."); + caseslist.replaceInStrings(".ini",""); + + if (command.size() < 2) + { + append_server_chatmessage("CLIENT", "You need to give a filename to save (extension not needed) and the courtroom status!" + caseslist.join(", "), "1"); + ui_ooc_chat_message->clear(); + return; + } + + + if (command.size() > 3) + { + append_server_chatmessage("CLIENT", "Too many arguments to save a case! You only need a filename without extension and the courtroom status!", "1"); + ui_ooc_chat_message->clear(); + return; + } + QSettings casefile("base/cases/" + command[1] + ".ini", QSettings::IniFormat); + casefile.setValue("author",ui_ooc_chat_name->text()); + casefile.setValue("cmdoc",""); + casefile.setValue("doc", ""); + casefile.setValue("status",command[2]); + casefile.sync(); + for(int i = local_evidence_list.size() - 1; i >= 0; i--) + { + casefile.beginGroup(QString::number(i)); + casefile.sync(); + casefile.setValue("name",local_evidence_list[i].name); + casefile.setValue("description",local_evidence_list[i].description); + casefile.setValue("image",local_evidence_list[i].image); + casefile.endGroup(); + } + casefile.sync(); + append_server_chatmessage("CLIENT", "Succesfully saved, edit doc and cmdoc link on the ini!", "1"); + ui_ooc_chat_message->clear(); + return; + + } QStringList packet_contents; packet_contents.append(ui_ooc_chat_name->text()); @@ -3009,7 +3061,11 @@ void Courtroom::on_pair_list_clicked(QModelIndex p_index) f_cid = n_char; } } - if (f_cid < -1 || f_cid >= char_list.size()) + + + + + if (f_cid < -2 || f_cid >= char_list.size()) { qDebug() << "W: " << real_char << " not present in char_list"; return; @@ -3030,9 +3086,10 @@ void Courtroom::on_pair_list_clicked(QModelIndex p_index) } if(other_charid != -1) { - f_item->setText(real_char + " [x]"); + f_item->setText(real_char + " [x]"); } } + void Courtroom::on_music_list_double_clicked(QModelIndex p_model) { if (is_muted) -- cgit From 099fea176c018c4aa6b9e7887e4f154866dc2c7d Mon Sep 17 00:00:00 2001 From: cents02 Date: Sun, 30 Jun 2019 22:09:12 +0000 Subject: Indentation --- src/courtroom.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 581ce5a..da05fe9 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -3086,7 +3086,7 @@ void Courtroom::on_pair_list_clicked(QModelIndex p_index) } if(other_charid != -1) { - f_item->setText(real_char + " [x]"); + f_item->setText(real_char + " [x]"); } } -- cgit From ca3f113377f85296538f42c355ab2308c05ca982 Mon Sep 17 00:00:00 2001 From: cents02 Date: Mon, 1 Jul 2019 18:50:30 +0000 Subject: Fixed evidence not recognizing subfolder issue. Can support 1 folder tho. --- src/evidence.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/evidence.cpp b/src/evidence.cpp index 4e79664..14234d8 100644 --- a/src/evidence.cpp +++ b/src/evidence.cpp @@ -205,8 +205,16 @@ void Courtroom::on_evidence_image_button_clicked() QString filename = filenames.at(0); QStringList split_filename = filename.split("/"); + if(split_filename.at(split_filename.size() - 2) == "evidence") + { + filename = split_filename.at(split_filename.size() - 1); + } + else { + + filename = split_filename.at(split_filename.size() - 2) + "/" + split_filename.at(split_filename.size() - 1); + } + - filename = split_filename.at(split_filename.size() - 1); ui_evidence_image_name->setText(filename); -- cgit From d07dd1d5fe42f0120d4d5ff1050fcd082123b2e9 Mon Sep 17 00:00:00 2001 From: cents02 Date: Wed, 3 Jul 2019 08:48:04 +0000 Subject: Permanent and not temporary solution for evidence. Supports up to infite subfolders. --- src/evidence.cpp | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/evidence.cpp b/src/evidence.cpp index 14234d8..ebef749 100644 --- a/src/evidence.cpp +++ b/src/evidence.cpp @@ -188,11 +188,12 @@ void Courtroom::on_evidence_image_name_edited() void Courtroom::on_evidence_image_button_clicked() { + QDir dir(ao_app->get_base_path() + "evidence"); QFileDialog dialog(this); dialog.setFileMode(QFileDialog::ExistingFile); dialog.setNameFilter(tr("Images (*.png)")); dialog.setViewMode(QFileDialog::List); - dialog.setDirectory(ao_app->get_base_path() + "evidence"); + dialog.setDirectory(dir); QStringList filenames; @@ -203,21 +204,8 @@ void Courtroom::on_evidence_image_button_clicked() return; QString filename = filenames.at(0); - - QStringList split_filename = filename.split("/"); - if(split_filename.at(split_filename.size() - 2) == "evidence") - { - filename = split_filename.at(split_filename.size() - 1); - } - else { - - filename = split_filename.at(split_filename.size() - 2) + "/" + split_filename.at(split_filename.size() - 1); - } - - - + filename = dir.relativeFilePath(filename); ui_evidence_image_name->setText(filename); - on_evidence_image_name_edited(); } -- cgit From 432069844a2073f8d3d5fdfff5c760acacc9a734 Mon Sep 17 00:00:00 2001 From: cents02 Date: Sun, 7 Jul 2019 22:32:57 +0000 Subject: Revert "More bug fixing." This reverts commit ca84ba516fc892deaeafc18b23ad5a06822b29f5 --- src/courtroom.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 2d5cf15..344516a 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -2886,7 +2886,7 @@ void Courtroom::on_ooc_return_pressed() if (command.size() < 2) { - append_server_chatmessage("CLIENT", "You need to give a filename to save (extension not needed) and the courtroom status!" + caseslist.join(", "), "1"); + append_server_chatmessage("CLIENT", "You need to give a filename to save (extension not needed) and the courtroom status!", "1"); ui_ooc_chat_message->clear(); return; } @@ -2906,6 +2906,8 @@ void Courtroom::on_ooc_return_pressed() casefile.sync(); for(int i = local_evidence_list.size() - 1; i >= 0; i--) { + QString clean_evidence_dsc = local_evidence_list[i].description.replace(QRegularExpression("..."), ""); + clean_evidence_dsc = clean_evidence_dsc.replace(clean_evidence_dsc.lastIndexOf(">"), 1, ""); casefile.beginGroup(QString::number(i)); casefile.sync(); casefile.setValue("name",local_evidence_list[i].name); -- cgit From b15c6f15f0b13bce4ef7305efa08c1d257401def Mon Sep 17 00:00:00 2001 From: Windrammer Date: Thu, 11 Jul 2019 09:05:26 -0600 Subject: Fix bug #82 causing a client crash if /save_case was used without providing a courtroom state --- src/courtroom.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 344516a..3d812e0 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -2884,7 +2884,7 @@ void Courtroom::on_ooc_return_pressed() caseslist.removeOne(".."); caseslist.replaceInStrings(".ini",""); - if (command.size() < 2) + if (command.size() < 3) { append_server_chatmessage("CLIENT", "You need to give a filename to save (extension not needed) and the courtroom status!", "1"); ui_ooc_chat_message->clear(); -- cgit From 5eccabcad15a52691228aded1d9c1fd5074fb70e Mon Sep 17 00:00:00 2001 From: David Skoland Date: Fri, 12 Jul 2019 23:00:25 +0000 Subject: Less insane debugging; minor refactoring (!75) --- src/aoapplication.cpp | 14 +++++++------- src/aoevidencebutton.cpp | 2 ++ src/charselect.cpp | 28 ++++++++++++++-------------- src/courtroom.cpp | 10 ++-------- src/discord_rich_presence.cpp | 4 ++-- src/hardware_functions.cpp | 7 +++---- src/networkmanager.cpp | 16 +++++++++------- src/packet_distribution.cpp | 10 ++++++++++ 8 files changed, 49 insertions(+), 42 deletions(-) (limited to 'src') diff --git a/src/aoapplication.cpp b/src/aoapplication.cpp index d7c3e66..4ef1edd 100644 --- a/src/aoapplication.cpp +++ b/src/aoapplication.cpp @@ -37,9 +37,9 @@ void AOApplication::construct_lobby() w_lobby = new Lobby(this); lobby_constructed = true; - QRect screenGeometry = QApplication::desktop()->screenGeometry(); - int x = (screenGeometry.width()-w_lobby->width()) / 2; - int y = (screenGeometry.height()-w_lobby->height()) / 2; + QRect geometry = QGuiApplication::primaryScreen()->geometry(); + int x = (geometry.width()-w_lobby->width()) / 2; + int y = (geometry.height()-w_lobby->height()) / 2; w_lobby->move(x, y); if (is_discord_enabled()) @@ -72,9 +72,9 @@ void AOApplication::construct_courtroom() w_courtroom = new Courtroom(this); courtroom_constructed = true; - QRect screenGeometry = QApplication::desktop()->screenGeometry(); - int x = (screenGeometry.width()-w_courtroom->width()) / 2; - int y = (screenGeometry.height()-w_courtroom->height()) / 2; + QRect geometry = QGuiApplication::primaryScreen()->geometry(); + int x = (geometry.width()-w_courtroom->width()) / 2; + int y = (geometry.height()-w_courtroom->height()) / 2; w_courtroom->move(x, y); } @@ -161,7 +161,7 @@ void AOApplication::ms_connect_finished(bool connected, bool will_retry) { if (lobby_constructed) w_lobby->append_error("Error connecting to master server. Will try again in " - + QString::number(net_manager->ms_reconnect_delay_ms / 1000.f) + " seconds."); + + QString::number(net_manager->ms_reconnect_delay) + " seconds."); } else { diff --git a/src/aoevidencebutton.cpp b/src/aoevidencebutton.cpp index 924aeb8..15b598f 100644 --- a/src/aoevidencebutton.cpp +++ b/src/aoevidencebutton.cpp @@ -86,6 +86,7 @@ void AOEvidenceButton::mouseDoubleClickEvent(QMouseEvent *e) evidence_double_clicked(m_id); } +/* void AOEvidenceButton::dragLeaveEvent(QMouseEvent *e) { //QWidget::dragLeaveEvent(e); @@ -99,6 +100,7 @@ void AOEvidenceButton::dragEnterEvent(QMouseEvent *e) qDebug() << "drag enter event"; } +*/ void AOEvidenceButton::enterEvent(QEvent * e) { diff --git a/src/charselect.cpp b/src/charselect.cpp index 8e1b912..4987cf5 100644 --- a/src/charselect.cpp +++ b/src/charselect.cpp @@ -44,7 +44,6 @@ void Courtroom::construct_char_select() set_size_and_pos(ui_char_buttons, "char_buttons"); - connect (char_button_mapper, SIGNAL(mapped(int)), this, SLOT(char_clicked(int))); connect(ui_back_to_lobby, SIGNAL(clicked()), this, SLOT(on_back_to_lobby_clicked())); connect(ui_char_select_left, SIGNAL(clicked()), this, SLOT(on_char_select_left_clicked())); @@ -52,9 +51,9 @@ void Courtroom::construct_char_select() connect(ui_spectator, SIGNAL(clicked()), this, SLOT(on_spectator_clicked())); - connect(ui_char_search, SIGNAL(textEdited(const QString&)), this, SLOT(on_char_search_changed(const QString&))); - connect(ui_char_passworded, SIGNAL(stateChanged(int)), this, SLOT(on_char_passworded_clicked(int))); - connect(ui_char_taken, SIGNAL(stateChanged(int)), this, SLOT(on_char_taken_clicked(int))); + connect(ui_char_search, SIGNAL(textEdited(const QString&)), this, SLOT(on_char_search_changed())); + connect(ui_char_passworded, SIGNAL(stateChanged(int)), this, SLOT(on_char_passworded_clicked())); + connect(ui_char_taken, SIGNAL(stateChanged(int)), this, SLOT(on_char_taken_clicked())); } void Courtroom::set_char_select() @@ -197,14 +196,15 @@ void Courtroom::character_loading_finished() // Later on, we'll be revealing buttons as we need them. for (int n = 0; n < char_list.size(); n++) { - AOCharButton* character = new AOCharButton(ui_char_buttons, ao_app, 0, 0, char_list.at(n).taken); - character->reset(); - character->hide(); - character->set_image(char_list.at(n).name); - ui_char_button_list.append(character); + AOCharButton* char_button = new AOCharButton(ui_char_buttons, ao_app, 0, 0, char_list.at(n).taken); + char_button->reset(); + char_button->hide(); + char_button->set_image(char_list.at(n).name); + ui_char_button_list.append(char_button); - connect(character, SIGNAL(clicked()), char_button_mapper, SLOT(map())); - char_button_mapper->setMapping(character, ui_char_button_list.size() - 1); + connect(char_button, &AOCharButton::clicked, [this, n](){ + this->char_clicked(n); + }); // This part here serves as a way of showing to the player that the game is still running, it is // just loading the pictures of the characters. @@ -252,17 +252,17 @@ void Courtroom::filter_character_list() set_char_select_page(); } -void Courtroom::on_char_search_changed(const QString& newtext) +void Courtroom::on_char_search_changed() { filter_character_list(); } -void Courtroom::on_char_passworded_clicked(int newstate) +void Courtroom::on_char_passworded_clicked() { filter_character_list(); } -void Courtroom::on_char_taken_clicked(int newstate) +void Courtroom::on_char_taken_clicked() { filter_character_list(); } diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 3d812e0..a8e9739 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -6,7 +6,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() // Change the default audio output device to be the one the user has given // in his config.ini file for now. - int a = 0; + unsigned int a = 0; BASS_DEVICEINFO info; if (ao_app->get_audio_output_device() == "default") @@ -21,7 +21,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() if (ao_app->get_audio_output_device() == info.name) { BASS_SetDevice(a); - BASS_Init(a, 48000, BASS_DEVICE_LATENCY, nullptr, nullptr); + BASS_Init(static_cast(a), 48000, BASS_DEVICE_LATENCY, nullptr, nullptr); load_bass_opus_plugin(); qDebug() << info.name << "was set as the default audio output device."; break; @@ -49,8 +49,6 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() testimony_hide_timer = new QTimer(this); testimony_hide_timer->setSingleShot(true); - char_button_mapper = new QSignalMapper(this); - music_player = new AOMusicPlayer(this, ao_app); music_player->set_volume(0); sfx_player = new AOSfxPlayer(this, ao_app); @@ -2223,11 +2221,7 @@ void Courtroom::chat_tick() case INLINE_GREY: ui_vp_message->insertHtml("" + f_character + ""); break; - default: - ui_vp_message->insertHtml(f_character); - break; } - } else { diff --git a/src/discord_rich_presence.cpp b/src/discord_rich_presence.cpp index 10f5833..ac14bb2 100644 --- a/src/discord_rich_presence.cpp +++ b/src/discord_rich_presence.cpp @@ -11,10 +11,10 @@ Discord::Discord() qInfo() << "Discord RPC ready"; }; handlers.disconnected = [](int errorCode, const char* message) { - qInfo() << "Discord RPC disconnected! " << message; + qInfo() << "Discord RPC disconnected! " << message << errorCode; }; handlers.errored = [](int errorCode, const char* message) { - qWarning() << "Discord RPC errored out! " << message; + qWarning() << "Discord RPC errored out! " << message << errorCode; }; qInfo() << "Initializing Discord RPC"; Discord_Initialize(APPLICATION_ID, &handlers, 1, nullptr); diff --git a/src/hardware_functions.cpp b/src/hardware_functions.cpp index ebba6ab..5d6b6ff 100644 --- a/src/hardware_functions.cpp +++ b/src/hardware_functions.cpp @@ -5,12 +5,12 @@ #if (defined (_WIN32) || defined (_WIN64)) #include -DWORD dwVolSerial; -BOOL bIsRetrieved; +static DWORD dwVolSerial; +static BOOL bIsRetrieved; QString get_hdid() { - bIsRetrieved = GetVolumeInformation(TEXT("C:\\"), NULL, NULL, &dwVolSerial, NULL, NULL, NULL, NULL); + bIsRetrieved = GetVolumeInformation(TEXT("C:\\"), nullptr, 0, &dwVolSerial, nullptr, nullptr, nullptr, 0); if (bIsRetrieved) return QString::number(dwVolSerial, 16); @@ -18,7 +18,6 @@ QString get_hdid() //a totally random string //what could possibly go wrong return "gxsps32sa9fnwic92mfbs0"; - } #elif (defined (LINUX) || defined (__linux__)) diff --git a/src/networkmanager.cpp b/src/networkmanager.cpp index 288a900..5b16db4 100644 --- a/src/networkmanager.cpp +++ b/src/networkmanager.cpp @@ -78,9 +78,9 @@ void NetworkManager::ship_server_packet(QString p_packet) void NetworkManager::handle_ms_packet() { - char buffer[buffer_max_size]; - std::memset(buffer, 0, buffer_max_size); - ms_socket->read(buffer, buffer_max_size); + char buffer[BUFFER_MAX_SIZE]; + std::memset(buffer, 0, BUFFER_MAX_SIZE); + ms_socket->read(buffer, BUFFER_MAX_SIZE); QString in_data = buffer; @@ -137,7 +137,9 @@ void NetworkManager::on_srv_lookup() for (const QDnsServiceRecord &record : srv_records) { +#ifdef DEBUG_NETWORK qDebug() << "Connecting to " << record.target() << ":" << record.port(); +#endif ms_socket->connectToHost(record.target(), record.port()); QTime timer; timer.start(); @@ -206,7 +208,7 @@ void NetworkManager::on_ms_socket_error(QAbstractSocket::SocketError error) emit ms_connect_finished(false, true); - ms_reconnect_timer->start(ms_reconnect_delay_ms); + ms_reconnect_timer->start(ms_reconnect_delay * 1000); } void NetworkManager::retry_ms_connect() @@ -217,9 +219,9 @@ void NetworkManager::retry_ms_connect() void NetworkManager::handle_server_packet() { - char buffer[buffer_max_size]; - std::memset(buffer, 0, buffer_max_size); - server_socket->read(buffer, buffer_max_size); + char buffer[BUFFER_MAX_SIZE]; + std::memset(buffer, 0, BUFFER_MAX_SIZE); + server_socket->read(buffer, BUFFER_MAX_SIZE); QString in_data = buffer; diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index 68d2fb9..942c275 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -14,8 +14,10 @@ void AOApplication::ms_packet_received(AOPacket *p_packet) QString header = p_packet->get_header(); QStringList f_contents = p_packet->get_contents(); +#ifdef DEBUG_NETWORK if (header != "CHECK") qDebug() << "R(ms):" << p_packet->to_string(); +#endif if (header == "ALL") { @@ -127,8 +129,10 @@ void AOApplication::server_packet_received(AOPacket *p_packet) QStringList f_contents = p_packet->get_contents(); QString f_packet = p_packet->to_string(); +#ifdef DEBUG_NETWORK if (header != "checkconnection") qDebug() << "R:" << f_packet; +#endif if (header == "decryptor") { @@ -677,7 +681,9 @@ void AOApplication::send_ms_packet(AOPacket *p_packet) net_manager->ship_ms_packet(f_packet); +#ifdef DEBUG_NETWORK qDebug() << "S(ms):" << f_packet; +#endif delete p_packet; } @@ -691,14 +697,18 @@ void AOApplication::send_server_packet(AOPacket *p_packet, bool encoded) if (encryption_needed) { +#ifdef DEBUG_NETWORK qDebug() << "S(e):" << f_packet; +#endif p_packet->encrypt_header(s_decryptor); f_packet = p_packet->to_string(); } else { +#ifdef DEBUG_NETWORK qDebug() << "S:" << f_packet; +#endif } net_manager->ship_server_packet(f_packet); -- cgit From 82db3e226353183cf8337d993ba89ea265014d3a Mon Sep 17 00:00:00 2001 From: cents02 Date: Sat, 20 Jul 2019 16:33:33 +0000 Subject: Revert "More bug fixing." This reverts commit ca84ba516fc892deaeafc18b23ad5a06822b29f5 --- src/courtroom.cpp | 4 +++- src/text_file_functions.cpp | 12 +++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index a8e9739..237bedc 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -724,7 +724,9 @@ void Courtroom::set_font(QWidget *widget, QString p_identifier) int f_weight = ao_app->get_font_size(p_identifier, design_file); QString class_name = widget->metaObject()->className(); - widget->setFont(QFont("Sans", f_weight)); + QString fontt = ao_app->get_font_name(p_identifier + "_font", design_file); + widget->setFont(QFont(fontt, f_weight)); + QColor f_color = ao_app->get_color(p_identifier + "_color", design_file); diff --git a/src/text_file_functions.cpp b/src/text_file_functions.cpp index 1e920d7..18c43ac 100644 --- a/src/text_file_functions.cpp +++ b/src/text_file_functions.cpp @@ -224,7 +224,17 @@ pos_size_type AOApplication::get_element_dimensions(QString p_identifier, QStrin return return_value; } - +QString AOApplication::get_font_name(QString p_identifier, QString p_file) +{ + QString design_ini_path = get_theme_path(p_file); + QString f_result = read_design_ini(p_identifier, design_ini_path); + QString default_path = get_default_theme_path(p_file); + if(f_result == "") + { + f_result = read_design_ini(p_identifier, default_path); + } + return f_result; +} int AOApplication::get_font_size(QString p_identifier, QString p_file) { QString design_ini_path = get_theme_path(p_file); -- cgit From 2dbd0c148224bfb7bdd7538136df917e7d1f3a6a Mon Sep 17 00:00:00 2001 From: windrammer <31085911+likeawindrammer@users.noreply.github.com> Date: Mon, 22 Jul 2019 18:21:27 -0600 Subject: Remove C style char buffer in favor of QByteArray --- src/networkmanager.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/networkmanager.cpp b/src/networkmanager.cpp index 5b16db4..a9810d4 100644 --- a/src/networkmanager.cpp +++ b/src/networkmanager.cpp @@ -78,11 +78,8 @@ void NetworkManager::ship_server_packet(QString p_packet) void NetworkManager::handle_ms_packet() { - char buffer[BUFFER_MAX_SIZE]; - std::memset(buffer, 0, BUFFER_MAX_SIZE); - ms_socket->read(buffer, BUFFER_MAX_SIZE); - - QString in_data = buffer; + QByteArray buffer = ms_socket->readAll(); + QString in_data = QString::fromUtf8(buffer, buffer.size()); if (!in_data.endsWith("%")) { @@ -219,11 +216,8 @@ void NetworkManager::retry_ms_connect() void NetworkManager::handle_server_packet() { - char buffer[BUFFER_MAX_SIZE]; - std::memset(buffer, 0, BUFFER_MAX_SIZE); - server_socket->read(buffer, BUFFER_MAX_SIZE); - - QString in_data = buffer; + QByteArray buffer = server_socket->readAll(); + QString in_data = QString::fromUtf8(buffer, buffer.size()); if (!in_data.endsWith("%")) { @@ -251,4 +245,3 @@ void NetworkManager::handle_server_packet() ao_app->server_packet_received(f_packet); } } - -- cgit From 71d91e501264659a2c73ccaf57a31fdf3e98d9f9 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Fri, 26 Jul 2019 01:33:29 +0200 Subject: fixed copypasta mistake on objection sfx --- src/courtroom.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 5258120..3f1e578 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -52,10 +52,13 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() music_player = new AOMusicPlayer(this, ao_app); music_player->set_volume(0); + sfx_player = new AOSfxPlayer(this, ao_app); sfx_player->set_volume(0); + objection_player = new AOSfxPlayer(this, ao_app); - sfx_player->set_volume(0); + objection_player->set_volume(0); + blip_player = new AOBlipPlayer(this, ao_app); blip_player->set_volume(0); -- cgit From 98389e7e0357794fb5d3be594e6b71ec5b69e952 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Fri, 26 Jul 2019 01:37:11 +0200 Subject: 1% more readable --- src/courtroom.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 3f1e578..cd01f64 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -181,12 +181,15 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() ui_pre = new QCheckBox(this); ui_pre->setText("Pre"); + ui_flip = new QCheckBox(this); ui_flip->setText("Flip"); ui_flip->hide(); + ui_guard = new QCheckBox(this); ui_guard->setText("Guard"); ui_guard->hide(); + ui_casing = new QCheckBox(this); ui_casing->setChecked(ao_app->get_casing_enabled()); ui_casing->setText(tr("Casing")); @@ -238,6 +241,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() ui_log_limit_spinbox->setValue(ao_app->get_max_log_size()); ui_mute_list = new QListWidget(this); + ui_pair_list = new QListWidget(this); ui_pair_offset_spinbox = new QSpinBox(this); ui_pair_offset_spinbox->setRange(-100,100); -- cgit From 56ddd024ebfdcbb8b7d4e5790cb422e51570248d Mon Sep 17 00:00:00 2001 From: oldmud0 Date: Sat, 27 Jul 2019 21:19:45 -0500 Subject: Fall back to Sans if no font setting found Sigh... --- src/text_file_functions.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/text_file_functions.cpp b/src/text_file_functions.cpp index 7247625..5a34ac8 100644 --- a/src/text_file_functions.cpp +++ b/src/text_file_functions.cpp @@ -226,14 +226,16 @@ pos_size_type AOApplication::get_element_dimensions(QString p_identifier, QStrin } QString AOApplication::get_font_name(QString p_identifier, QString p_file) { - QString design_ini_path = get_theme_path(p_file); - QString f_result = read_design_ini(p_identifier, design_ini_path); - QString default_path = get_default_theme_path(p_file); - if(f_result == "") - { - f_result = read_design_ini(p_identifier, default_path); - } - return f_result; + QString design_ini_path = get_theme_path(p_file); + QString f_result = read_design_ini(p_identifier, design_ini_path); + QString default_path = get_default_theme_path(p_file); + if (f_result == "") + { + f_result = read_design_ini(p_identifier, default_path); + if (f_result == "") + return "Sans"; + } + return f_result; } int AOApplication::get_font_size(QString p_identifier, QString p_file) { -- cgit From 319cb0adee1b8a65d1daf78aa903d6ffd2952c9c Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Sun, 28 Jul 2019 18:43:46 +0200 Subject: translate new features. is i18n dead --- src/courtroom.cpp | 92 +++++++++++++++++++++++++++---------------------------- 1 file changed, 46 insertions(+), 46 deletions(-) (limited to 'src') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index cd01f64..7907b54 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -127,7 +127,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() ui_ooc_chat_name = new QLineEdit(this); ui_ooc_chat_name->setFrame(false); - ui_ooc_chat_name->setPlaceholderText("Name"); + ui_ooc_chat_name->setPlaceholderText(tr("Name")); ui_ooc_chat_name->setMaxLength(30); ui_ooc_chat_name->setText(p_ao_app->get_default_username()); @@ -180,14 +180,14 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() ui_switch_area_music = new AOButton(this, ao_app); ui_pre = new QCheckBox(this); - ui_pre->setText("Pre"); + ui_pre->setText(tr("Pre")); ui_flip = new QCheckBox(this); - ui_flip->setText("Flip"); + ui_flip->setText(tr("Flip")); ui_flip->hide(); ui_guard = new QCheckBox(this); - ui_guard->setText("Guard"); + ui_guard->setText(tr("Guard")); ui_guard->hide(); ui_casing = new QCheckBox(this); @@ -214,15 +214,15 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() ui_prosecution_minus = new AOButton(this, ao_app); ui_text_color = new QComboBox(this); - ui_text_color->addItem("White"); - ui_text_color->addItem("Green"); - ui_text_color->addItem("Red"); - ui_text_color->addItem("Orange"); - ui_text_color->addItem("Blue"); - ui_text_color->addItem("Yellow"); - ui_text_color->addItem("Rainbow"); - ui_text_color->addItem("Pink"); - ui_text_color->addItem("Cyan"); + ui_text_color->addItem(tr("White")); + ui_text_color->addItem(tr("Green")); + ui_text_color->addItem(tr("Red")); + ui_text_color->addItem(tr("Orange")); + ui_text_color->addItem(tr("Blue")); + ui_text_color->addItem(tr("Yellow")); + ui_text_color->addItem(tr("Rainbow")); + ui_text_color->addItem(tr("Pink")); + ui_text_color->addItem(tr("Cyan")); ui_music_slider = new QSlider(Qt::Horizontal, this); ui_music_slider->setRange(0, 100); @@ -689,7 +689,7 @@ void Courtroom::set_widgets() ui_selector->hide(); set_size_and_pos(ui_back_to_lobby, "back_to_lobby"); - ui_back_to_lobby->setText("Back to Lobby"); + ui_back_to_lobby->setText(tr("Back to Lobby")); set_size_and_pos(ui_char_password, "char_password"); @@ -2678,21 +2678,21 @@ void Courtroom::on_ooc_return_pressed() else if (ooc_message.startsWith("/login")) { ui_guard->show(); - append_server_chatmessage("CLIENT", "You were granted the Guard button.", "1"); + append_server_chatmessage("CLIENT", tr("You were granted the Guard button."), "1"); } else if (ooc_message.startsWith("/rainbow") && ao_app->yellow_text_enabled && !rainbow_appended) { //ui_text_color->addItem("Rainbow"); ui_ooc_chat_message->clear(); //rainbow_appended = true; - append_server_chatmessage("CLIENT", "This does nohing, but there you go.", "1"); + append_server_chatmessage("CLIENT", tr("This does nohing, but there you go."), "1"); return; } else if (ooc_message.startsWith("/settings")) { ui_ooc_chat_message->clear(); ao_app->call_settings_menu(); - append_server_chatmessage("CLIENT", "You opened the settings menu.", "1"); + append_server_chatmessage("CLIENT", tr("You opened the settings menu."), "1"); return; } else if (ooc_message.startsWith("/pair")) @@ -2707,20 +2707,20 @@ void Courtroom::on_ooc_return_pressed() if (whom > -1) { other_charid = whom; - QString msg = "You will now pair up with "; + QString msg = tr("You will now pair up with "); msg.append(char_list.at(whom).name); - msg.append(" if they also choose your character in return."); + msg.append(tr(" if they also choose your character in return.")); append_server_chatmessage("CLIENT", msg, "1"); } else { other_charid = -1; - append_server_chatmessage("CLIENT", "You are no longer paired with anyone.", "1"); + append_server_chatmessage("CLIENT", tr("You are no longer paired with anyone."), "1"); } } else { - append_server_chatmessage("CLIENT", "Are you sure you typed that well? The char ID could not be recognised.", "1"); + append_server_chatmessage("CLIENT", tr("Are you sure you typed that well? The char ID could not be recognised."), "1"); } return; } @@ -2736,32 +2736,32 @@ void Courtroom::on_ooc_return_pressed() if (off >= -100 && off <= 100) { offset_with_pair = off; - QString msg = "You have set your offset to "; + QString msg = tr("You have set your offset to "); msg.append(QString::number(off)); msg.append("%."); append_server_chatmessage("CLIENT", msg, "1"); } else { - append_server_chatmessage("CLIENT", "Your offset must be between -100% and 100%!", "1"); + append_server_chatmessage("CLIENT", tr("Your offset must be between -100% and 100%!"), "1"); } } else { - append_server_chatmessage("CLIENT", "That offset does not look like one.", "1"); + append_server_chatmessage("CLIENT", tr("That offset does not look like one."), "1"); } return; } else if (ooc_message.startsWith("/switch_am")) { - append_server_chatmessage("CLIENT", "You switched your music and area list.", "1"); + append_server_chatmessage("CLIENT", tr("You switched your music and area list."), "1"); on_switch_area_music_clicked(); ui_ooc_chat_message->clear(); return; } else if (ooc_message.startsWith("/enable_blocks")) { - append_server_chatmessage("CLIENT", "You have forcefully enabled features that the server may not support. You may not be able to talk IC, or worse, because of this.", "1"); + append_server_chatmessage("CLIENT", tr("You have forcefully enabled features that the server may not support. You may not be able to talk IC, or worse, because of this."), "1"); ao_app->cccc_ic_support_enabled = true; ao_app->arup_enabled = true; ao_app->modcall_reason_enabled = true; @@ -2772,9 +2772,9 @@ void Courtroom::on_ooc_return_pressed() else if (ooc_message.startsWith("/non_int_pre")) { if (ui_pre_non_interrupt->isChecked()) - append_server_chatmessage("CLIENT", "Your pre-animations interrupt again.", "1"); + append_server_chatmessage("CLIENT", tr("Your pre-animations interrupt again."), "1"); else - append_server_chatmessage("CLIENT", "Your pre-animations will not interrupt text.", "1"); + append_server_chatmessage("CLIENT", tr("Your pre-animations will not interrupt text."), "1"); ui_pre_non_interrupt->setChecked(!ui_pre_non_interrupt->isChecked()); ui_ooc_chat_message->clear(); return; @@ -2785,7 +2785,7 @@ void Courtroom::on_ooc_return_pressed() if (!file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) { - append_server_chatmessage("CLIENT", "Couldn't open chatlog.txt to write into.", "1"); + append_server_chatmessage("CLIENT", tr("Couldn't open chatlog.txt to write into."), "1"); ui_ooc_chat_message->clear(); return; } @@ -2798,7 +2798,7 @@ void Courtroom::on_ooc_return_pressed() file.close(); - append_server_chatmessage("CLIENT", "The IC chatlog has been saved.", "1"); + append_server_chatmessage("CLIENT", tr("The IC chatlog has been saved."), "1"); ui_ooc_chat_message->clear(); return; } @@ -2810,7 +2810,7 @@ void Courtroom::on_ooc_return_pressed() if (!casefolder.exists()) { QDir::current().mkdir("base/" + casefolder.dirName()); - append_server_chatmessage("CLIENT", "You don't have a `base/cases/` folder! It was just made for you, but seeing as it WAS just made for you, it's likely the case file you're looking for can't be found in there.", "1"); + append_server_chatmessage("CLIENT", tr("You don't have a `base/cases/` folder! It was just made for you, but seeing as it WAS just made for you, it's likely the case file you're looking for can't be found in there."), "1"); ui_ooc_chat_message->clear(); return; } @@ -2821,7 +2821,7 @@ void Courtroom::on_ooc_return_pressed() if (command.size() < 2) { - append_server_chatmessage("CLIENT", "You need to give a filename to load (extension not needed)! Make sure that it is in the `base/cases/` folder, and that it is a correctly formatted ini.\nCases you can load: " + caseslist.join(", "), "1"); + append_server_chatmessage("CLIENT", tr("You need to give a filename to load (extension not needed)! Make sure that it is in the `base/cases/` folder, and that it is a correctly formatted ini.\nCases you can load: ") + caseslist.join(", "), "1"); ui_ooc_chat_message->clear(); return; } @@ -2829,7 +2829,7 @@ void Courtroom::on_ooc_return_pressed() if (command.size() > 2) { - append_server_chatmessage("CLIENT", "Too many arguments to load a case! You only need one filename, without extension.", "1"); + append_server_chatmessage("CLIENT", tr("Too many arguments to load a case! You only need one filename, without extension."), "1"); ui_ooc_chat_message->clear(); return; } @@ -2842,13 +2842,13 @@ void Courtroom::on_ooc_return_pressed() QString casestatus = casefile.value("status", "").value(); if (!caseauth.isEmpty()) - append_server_chatmessage("CLIENT", "Case made by " + caseauth + ".", "1"); + append_server_chatmessage("CLIENT", tr("Case made by ") + caseauth + ".", "1"); if (!casedoc.isEmpty()) ao_app->send_server_packet(new AOPacket("CT#" + ui_ooc_chat_name->text() + "#/doc " + casedoc + "#%")); if (!casestatus.isEmpty()) ao_app->send_server_packet(new AOPacket("CT#" + ui_ooc_chat_name->text() + "#/status " + casestatus + "#%")); if (!cmdoc.isEmpty()) - append_server_chatmessage("CLIENT", "Navigate to " + cmdoc + " for the CM doc.", "1"); + append_server_chatmessage("CLIENT", tr("Navigate to ") + cmdoc + tr(" for the CM doc."), "1"); for (int i = local_evidence_list.size() - 1; i >= 0; i--) { ao_app->send_server_packet(new AOPacket("DE#" + QString::number(i) + "#%")); @@ -2867,7 +2867,7 @@ void Courtroom::on_ooc_return_pressed() ao_app->send_server_packet(new AOPacket("PE", f_contents)); } - append_server_chatmessage("CLIENT", "Your case \"" + command[1] + "\" was loaded!", "1"); + append_server_chatmessage("CLIENT", tr("Your case \"") + command[1] + tr("\" was loaded!"), "1"); ui_ooc_chat_message->clear(); return; } @@ -2879,7 +2879,7 @@ void Courtroom::on_ooc_return_pressed() if (!casefolder.exists()) { QDir::current().mkdir("base/" + casefolder.dirName()); - append_server_chatmessage("CLIENT", "You don't have a `base/cases/` folder! It was just made for you, but seeing as it WAS just made for you, it's likely that you somehow deleted it.", "1"); + append_server_chatmessage("CLIENT", tr("You don't have a `base/cases/` folder! It was just made for you, but seeing as it WAS just made for you, it's likely that you somehow deleted it."), "1"); ui_ooc_chat_message->clear(); return; } @@ -2890,7 +2890,7 @@ void Courtroom::on_ooc_return_pressed() if (command.size() < 3) { - append_server_chatmessage("CLIENT", "You need to give a filename to save (extension not needed) and the courtroom status!", "1"); + append_server_chatmessage("CLIENT", tr("You need to give a filename to save (extension not needed) and the courtroom status!"), "1"); ui_ooc_chat_message->clear(); return; } @@ -2898,7 +2898,7 @@ void Courtroom::on_ooc_return_pressed() if (command.size() > 3) { - append_server_chatmessage("CLIENT", "Too many arguments to save a case! You only need a filename without extension and the courtroom status!", "1"); + append_server_chatmessage("CLIENT", tr("Too many arguments to save a case! You only need a filename without extension and the courtroom status!"), "1"); ui_ooc_chat_message->clear(); return; } @@ -2920,7 +2920,7 @@ void Courtroom::on_ooc_return_pressed() casefile.endGroup(); } casefile.sync(); - append_server_chatmessage("CLIENT", "Succesfully saved, edit doc and cmdoc link on the ini!", "1"); + append_server_chatmessage("CLIENT", tr("Succesfully saved, edit doc and cmdoc link on the ini!"), "1"); ui_ooc_chat_message->clear(); return; @@ -2948,7 +2948,7 @@ void Courtroom::on_ooc_toggle_clicked() { ui_ms_chatlog->show(); ui_server_chatlog->hide(); - ui_ooc_toggle->setText("Master"); + ui_ooc_toggle->setText(tr("Master")); server_ooc = false; } @@ -2956,7 +2956,7 @@ void Courtroom::on_ooc_toggle_clicked() { ui_ms_chatlog->hide(); ui_server_chatlog->show(); - ui_ooc_toggle->setText("Server"); + ui_ooc_toggle->setText(tr("Server")); server_ooc = true; } @@ -3419,8 +3419,8 @@ void Courtroom::on_call_mod_clicked() QInputDialog input; input.setWindowFlags(Qt::WindowSystemMenuHint); - input.setLabelText("Reason:"); - input.setWindowTitle("Call Moderator"); + input.setLabelText(tr("Reason:")); + input.setWindowTitle(tr("Call Moderator")); auto code = input.exec(); if (code != QDialog::Accepted) @@ -3428,10 +3428,10 @@ void Courtroom::on_call_mod_clicked() QString text = input.textValue(); if (text.isEmpty()) { - errorBox.critical(nullptr, "Error", "You must provide a reason."); + errorBox.critical(nullptr, tr("Error"), tr("You must provide a reason.")); return; } else if (text.length() > 256) { - errorBox.critical(nullptr, "Error", "The message is too long."); + errorBox.critical(nullptr, tr("Error"), tr("The message is too long.")); return; } -- cgit From 762702aff852701c44eb0f07ee02c0fdfd1fd85b Mon Sep 17 00:00:00 2001 From: oldmud0 Date: Tue, 29 May 2018 19:21:49 -0500 Subject: Make all strings translatable --- src/aoapplication.cpp | 6 +++--- src/debug_functions.cpp | 9 ++++++--- src/discord_rich_presence.cpp | 18 +++++++++--------- src/evidence.cpp | 4 ++-- src/lobby.cpp | 10 +++++----- src/main.cpp | 17 +++++++++++++++++ src/packet_distribution.cpp | 25 +++++++++++++------------ 7 files changed, 55 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/aoapplication.cpp b/src/aoapplication.cpp index 4ef1edd..c47f350 100644 --- a/src/aoapplication.cpp +++ b/src/aoapplication.cpp @@ -135,7 +135,7 @@ void AOApplication::server_disconnected() { if (courtroom_constructed) { - call_notice("Disconnected from server."); + call_notice(tr("Disconnected from server.")); construct_lobby(); destruct_courtroom(); } @@ -165,11 +165,11 @@ void AOApplication::ms_connect_finished(bool connected, bool will_retry) } else { - call_error("There was an error connecting to the master server.\n" + call_error(tr("There was an error connecting to the master server.\n" "We deploy multiple master servers to mitigate any possible downtime, " "but the client appears to have exhausted all possible methods of finding " "and connecting to one.\n" - "Please check your Internet connection and firewall, and please try again."); + "Please check your Internet connection and firewall, and please try again.")); } } } diff --git a/src/debug_functions.cpp b/src/debug_functions.cpp index 77f2f35..a790610 100644 --- a/src/debug_functions.cpp +++ b/src/debug_functions.cpp @@ -1,11 +1,14 @@ +#include +#include + #include "debug_functions.h" void call_error(QString p_message) { QMessageBox *msgBox = new QMessageBox; - msgBox->setText("Error: " + p_message); - msgBox->setWindowTitle("Error"); + msgBox->setText(QCoreApplication::translate("debug_functions", "Error: %1").arg(p_message)); + msgBox->setWindowTitle(QCoreApplication::translate("debug_functions", "Error")); //msgBox->setWindowModality(Qt::NonModal); @@ -17,7 +20,7 @@ void call_notice(QString p_message) QMessageBox *msgBox = new QMessageBox; msgBox->setText(p_message); - msgBox->setWindowTitle("Notice"); + msgBox->setWindowTitle(QCoreApplication::translate("debug_functions", "Notice")); //msgBox->setWindowModality(Qt::NonModal); diff --git a/src/discord_rich_presence.cpp b/src/discord_rich_presence.cpp index 95a824a..17a649f 100644 --- a/src/discord_rich_presence.cpp +++ b/src/discord_rich_presence.cpp @@ -31,11 +31,11 @@ void Discord::state_lobby() DiscordRichPresence presence; std::memset(&presence, 0, sizeof(presence)); presence.largeImageKey = "ao2-logo"; - presence.largeImageText = "Objection!"; + presence.largeImageText = tr("Objection!"); presence.instance = 1; - presence.state = "In Lobby"; - presence.details = "Idle"; + presence.state = tr("In Lobby"); + presence.details = tr("Idle"); Discord_UpdatePresence(&presence); } @@ -46,12 +46,12 @@ void Discord::state_server(std::string name, std::string server_id) DiscordRichPresence presence; std::memset(&presence, 0, sizeof(presence)); presence.largeImageKey = "ao2-logo"; - presence.largeImageText = "Objection!"; + presence.largeImageText = tr("Objection!"); presence.instance = 1; auto timestamp = static_cast(std::time(nullptr)); - presence.state = "In a Server"; + presence.state = tr("In a Server"); presence.details = name.c_str(); presence.matchSecret = server_id.c_str(); presence.startTimestamp = this->timestamp; @@ -66,13 +66,13 @@ void Discord::state_character(std::string name) { auto name_internal = QString(name.c_str()).toLower().replace(' ', '_').toStdString(); auto name_friendly = QString(name.c_str()).replace('_', ' ').toStdString(); - const std::string playing_as = "Playing as " + name_friendly; + const std::string playing_as = tr("Playing as %1").arg(name_friendly); qDebug() << "Discord RPC: Setting character state (" << playing_as.c_str() << ")"; DiscordRichPresence presence; std::memset(&presence, 0, sizeof(presence)); presence.largeImageKey = "ao2-logo"; - presence.largeImageText = "Objection!"; + presence.largeImageText = tr("Objection!"); presence.instance = 1; presence.details = this->server_name.c_str(); presence.matchSecret = this->server_id.c_str(); @@ -91,13 +91,13 @@ void Discord::state_spectate() DiscordRichPresence presence; std::memset(&presence, 0, sizeof(presence)); presence.largeImageKey = "ao2-logo"; - presence.largeImageText = "Objection!"; + presence.largeImageText = tr("Objection!"); presence.instance = 1; presence.details = this->server_name.c_str(); presence.matchSecret = this->server_id.c_str(); presence.startTimestamp = this->timestamp; - presence.state = "Spectating"; + presence.state = tr("Spectating"); Discord_UpdatePresence(&presence); } #else diff --git a/src/evidence.cpp b/src/evidence.cpp index ebef749..3ea6a41 100644 --- a/src/evidence.cpp +++ b/src/evidence.cpp @@ -22,7 +22,7 @@ void Courtroom::construct_evidence() ui_evidence_delete = new AOButton(ui_evidence_overlay, ao_app); ui_evidence_image_name = new AOLineEdit(ui_evidence_overlay); ui_evidence_image_button = new AOButton(ui_evidence_overlay, ao_app); - ui_evidence_image_button->setText("Choose.."); + ui_evidence_image_button->setText(tr("Choose..")); ui_evidence_x = new AOButton(ui_evidence_overlay, ao_app); ui_evidence_description = new AOTextEdit(ui_evidence_overlay); @@ -265,7 +265,7 @@ void Courtroom::on_evidence_hover(int p_id, bool p_state) if (p_state) { if (final_id == local_evidence_list.size()) - ui_evidence_name->setText("Add new evidence..."); + ui_evidence_name->setText(tr("Add new evidence...")); else if (final_id < local_evidence_list.size()) ui_evidence_name->setText(local_evidence_list.at(final_id).name); } diff --git a/src/lobby.cpp b/src/lobby.cpp index 4a96e56..776528c 100644 --- a/src/lobby.cpp +++ b/src/lobby.cpp @@ -71,9 +71,9 @@ void Lobby::set_widgets() qDebug() << "W: did not find lobby width or height in " << filename; // Most common symptom of bad config files and missing assets. - call_notice("It doesn't look like your client is set up correctly.\n" + call_notice(tr("It doesn't look like your client is set up correctly.\n" "Did you download all resources correctly from tiny.cc/getao, " - "including the large 'base' folder?"); + "including the large 'base' folder?")); this->resize(517, 666); } @@ -144,11 +144,11 @@ void Lobby::set_widgets() ui_loading_text->setFrameStyle(QFrame::NoFrame); ui_loading_text->setStyleSheet("background-color: rgba(0, 0, 0, 0);" "color: rgba(255, 128, 0, 255);"); - ui_loading_text->append("Loading"); + ui_loading_text->append(tr("Loading")); set_size_and_pos(ui_progress_bar, "progress_bar"); set_size_and_pos(ui_cancel, "cancel"); - ui_cancel->setText("Cancel"); + ui_cancel->setText(tr("Cancel")); ui_loading_background->hide(); @@ -313,7 +313,7 @@ void Lobby::on_server_list_clicked(QModelIndex p_model) ui_description->moveCursor(QTextCursor::Start); ui_description->ensureCursorVisible(); - ui_player_count->setText("Offline"); + ui_player_count->setText(tr("Offline")); ui_connect->setEnabled(false); diff --git a/src/main.cpp b/src/main.cpp index 80ea93b..8b7cb50 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,6 +7,20 @@ #include "courtroom.h" #include #include +#include + +static void install_translators(QtApplication &app) +{ + QTranslator qtTranslator; + qtTranslator.load("qt_" + QLocale::system().name(), + QLibraryInfo::location(QLibraryInfo::TranslationsPath)); + app.installTranslator(&qtTranslator); + + QTranslator appTranslator; + appTranslator.load("ao_" + QLocale::system().name()); + app.installTranslator(&appTranslator); +} + int main(int argc, char *argv[]) { #if QT_VERSION > QT_VERSION_CHECK(5, 6, 0) @@ -17,6 +31,9 @@ int main(int argc, char *argv[]) #endif AOApplication main_app(argc, argv); + + install_translators(&main_app); + main_app.construct_lobby(); main_app.net_manager->connect_to_master(); main_app.w_lobby->show(); diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index 942c275..2bd2693 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -103,15 +103,16 @@ void AOApplication::ms_packet_received(AOPacket *p_packet) } } - call_notice("Outdated version! Your version: " + get_version_string() - + "\nPlease go to aceattorneyonline.com to update."); + call_notice(tr("Outdated version! Your version: %1\n" + "Please go to aceattorneyonline.com to update.") + .arg(get_version_string())); destruct_courtroom(); destruct_lobby(); } else if (header == "DOOM") { - call_notice("You have been exiled from AO." - "Have a nice day."); + call_notice(tr("You have been exiled from AO.\n" + "Have a nice day.")); destruct_courtroom(); destruct_lobby(); } @@ -245,7 +246,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet) courtroom_loaded = false; - QString window_title = "Attorney Online 2"; + QString window_title = tr("Attorney Online 2"); int selected_server = w_lobby->get_selected_server(); QString server_address = "", server_name = ""; @@ -271,7 +272,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet) w_courtroom->set_window_title(window_title); w_lobby->show_loading_overlay(); - w_lobby->set_loading_text("Loading"); + w_lobby->set_loading_text(tr("Loading")); w_lobby->set_loading_value(0); AOPacket *f_packet; @@ -359,7 +360,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet) ++loaded_evidence; - w_lobby->set_loading_text("Loading evidence:\n" + QString::number(loaded_evidence) + "/" + QString::number(evidence_list_size)); + w_lobby->set_loading_text(tr("Loading evidence:\n%1/%2").arg(QString::number(loaded_evidence)).arg(QString::number(evidence_list_size))); w_courtroom->append_evidence(f_evi); @@ -391,7 +392,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet) ++loaded_music; - w_lobby->set_loading_text("Loading music:\n" + QString::number(loaded_music) + "/" + QString::number(music_list_size)); + 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) { @@ -463,7 +464,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet) ++loaded_chars; - w_lobby->set_loading_text("Loading chars:\n" + QString::number(loaded_chars) + "/" + QString::number(char_list_size)); + w_lobby->set_loading_text(tr("Loading chars:\n%1/%2").arg(QString::number(loaded_chars)).arg(QString::number(char_list_size))); w_courtroom->append_char(f_char); @@ -486,7 +487,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet) { ++loaded_music; - w_lobby->set_loading_text("Loading music:\n" + QString::number(loaded_music) + "/" + QString::number(music_list_size)); + 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) { @@ -638,7 +639,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet) { if (courtroom_constructed && f_contents.size() >= 1) { - call_notice("You have been kicked from the server.\nReason: " + f_contents.at(0)); + call_notice(tr("You have been kicked from the server.\nReason: ") + f_contents.at(0)); construct_lobby(); destruct_courtroom(); } @@ -655,7 +656,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet) } else if (header == "BD") { - call_notice("You are banned on this server.\nReason: " + f_contents.at(0)); + call_notice(tr("You are banned on this server.\nReason: ") + f_contents.at(0)); } else if (header == "ZZ") { -- cgit From 69e4da4c43982205d8b94e182a25746ca72340d4 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Sun, 28 Jul 2019 19:17:47 +0200 Subject: it didn't like doing that with a pointer --- src/main.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 8b7cb50..26b97bf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8,18 +8,7 @@ #include #include #include - -static void install_translators(QtApplication &app) -{ - QTranslator qtTranslator; - qtTranslator.load("qt_" + QLocale::system().name(), - QLibraryInfo::location(QLibraryInfo::TranslationsPath)); - app.installTranslator(&qtTranslator); - - QTranslator appTranslator; - appTranslator.load("ao_" + QLocale::system().name()); - app.installTranslator(&appTranslator); -} +#include int main(int argc, char *argv[]) { @@ -32,7 +21,14 @@ int main(int argc, char *argv[]) AOApplication main_app(argc, argv); - install_translators(&main_app); + QTranslator qtTranslator; + qtTranslator.load("qt_" + QLocale::system().name(), + QLibraryInfo::location(QLibraryInfo::TranslationsPath)); + main_app.installTranslator(&qtTranslator); + + QTranslator appTranslator; + appTranslator.load("ao_" + QLocale::system().name()); + main_app.installTranslator(&appTranslator); main_app.construct_lobby(); main_app.net_manager->connect_to_master(); -- cgit From 582417a9020569e2f841bf93bb7358a2ccefa16f Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Sun, 28 Jul 2019 20:19:09 +0200 Subject: german translation --- src/courtroom.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 7907b54..2ba3ba2 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -2685,7 +2685,7 @@ void Courtroom::on_ooc_return_pressed() //ui_text_color->addItem("Rainbow"); ui_ooc_chat_message->clear(); //rainbow_appended = true; - append_server_chatmessage("CLIENT", tr("This does nohing, but there you go."), "1"); + append_server_chatmessage("CLIENT", tr("This does nothing, but there you go."), "1"); return; } else if (ooc_message.startsWith("/settings")) -- cgit From 259422c4af2548c7c0e91df4deb22171c07aa9f6 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Sun, 28 Jul 2019 20:39:36 +0200 Subject: at least the german translation works --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 26b97bf..7bf766f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -27,7 +27,7 @@ int main(int argc, char *argv[]) main_app.installTranslator(&qtTranslator); QTranslator appTranslator; - appTranslator.load("ao_" + QLocale::system().name()); + appTranslator.load("ao_" + QLocale::system().name(),"base/translations/"); main_app.installTranslator(&appTranslator); main_app.construct_lobby(); -- cgit From b7012cec10ce96f4325b2c5749805eb51ee04fd7 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Mon, 29 Jul 2019 21:46:26 +0200 Subject: fixed 2 strings --- src/charselect.cpp | 2 +- src/evidence.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/charselect.cpp b/src/charselect.cpp index 4987cf5..58c990b 100644 --- a/src/charselect.cpp +++ b/src/charselect.cpp @@ -214,7 +214,7 @@ void Courtroom::character_loading_finished() 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(total_loading_size)) * 100); ao_app->w_lobby->set_loading_value(loading_value); - ao_app->w_lobby->set_loading_text("Generating chars:\n" + QString::number(ao_app->generated_chars) + "/" + QString::number(ao_app->char_list_size)); + ao_app->w_lobby->set_loading_text(tr("Generating chars:\n") + QString::number(ao_app->generated_chars) + "/" + QString::number(ao_app->char_list_size)); } } diff --git a/src/evidence.cpp b/src/evidence.cpp index 3ea6a41..341bed0 100644 --- a/src/evidence.cpp +++ b/src/evidence.cpp @@ -22,7 +22,7 @@ void Courtroom::construct_evidence() ui_evidence_delete = new AOButton(ui_evidence_overlay, ao_app); ui_evidence_image_name = new AOLineEdit(ui_evidence_overlay); ui_evidence_image_button = new AOButton(ui_evidence_overlay, ao_app); - ui_evidence_image_button->setText(tr("Choose..")); + ui_evidence_image_button->setText(tr("Choose...")); ui_evidence_x = new AOButton(ui_evidence_overlay, ao_app); ui_evidence_description = new AOTextEdit(ui_evidence_overlay); -- cgit From adf1a973044a2b7ab7b51195bcd2e5b19ec6eeb5 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Mon, 29 Jul 2019 21:54:35 +0200 Subject: adjust translation path in main.cpp --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 7bf766f..7c2daa6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -27,7 +27,7 @@ int main(int argc, char *argv[]) main_app.installTranslator(&qtTranslator); QTranslator appTranslator; - appTranslator.load("ao_" + QLocale::system().name(),"base/translations/"); + appTranslator.load("ao_" + QLocale::system().name(),":/resource/translations/"); main_app.installTranslator(&appTranslator); main_app.construct_lobby(); -- cgit From 460805d072ee391dd50786da1013bd699b435673 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Tue, 30 Jul 2019 19:42:38 +0200 Subject: make discord integration the same for all locales --- src/discord_rich_presence.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/discord_rich_presence.cpp b/src/discord_rich_presence.cpp index 17a649f..95a824a 100644 --- a/src/discord_rich_presence.cpp +++ b/src/discord_rich_presence.cpp @@ -31,11 +31,11 @@ void Discord::state_lobby() DiscordRichPresence presence; std::memset(&presence, 0, sizeof(presence)); presence.largeImageKey = "ao2-logo"; - presence.largeImageText = tr("Objection!"); + presence.largeImageText = "Objection!"; presence.instance = 1; - presence.state = tr("In Lobby"); - presence.details = tr("Idle"); + presence.state = "In Lobby"; + presence.details = "Idle"; Discord_UpdatePresence(&presence); } @@ -46,12 +46,12 @@ void Discord::state_server(std::string name, std::string server_id) DiscordRichPresence presence; std::memset(&presence, 0, sizeof(presence)); presence.largeImageKey = "ao2-logo"; - presence.largeImageText = tr("Objection!"); + presence.largeImageText = "Objection!"; presence.instance = 1; auto timestamp = static_cast(std::time(nullptr)); - presence.state = tr("In a Server"); + presence.state = "In a Server"; presence.details = name.c_str(); presence.matchSecret = server_id.c_str(); presence.startTimestamp = this->timestamp; @@ -66,13 +66,13 @@ void Discord::state_character(std::string name) { auto name_internal = QString(name.c_str()).toLower().replace(' ', '_').toStdString(); auto name_friendly = QString(name.c_str()).replace('_', ' ').toStdString(); - const std::string playing_as = tr("Playing as %1").arg(name_friendly); + const std::string playing_as = "Playing as " + name_friendly; qDebug() << "Discord RPC: Setting character state (" << playing_as.c_str() << ")"; DiscordRichPresence presence; std::memset(&presence, 0, sizeof(presence)); presence.largeImageKey = "ao2-logo"; - presence.largeImageText = tr("Objection!"); + presence.largeImageText = "Objection!"; presence.instance = 1; presence.details = this->server_name.c_str(); presence.matchSecret = this->server_id.c_str(); @@ -91,13 +91,13 @@ void Discord::state_spectate() DiscordRichPresence presence; std::memset(&presence, 0, sizeof(presence)); presence.largeImageKey = "ao2-logo"; - presence.largeImageText = tr("Objection!"); + presence.largeImageText = "Objection!"; presence.instance = 1; presence.details = this->server_name.c_str(); presence.matchSecret = this->server_id.c_str(); presence.startTimestamp = this->timestamp; - presence.state = tr("Spectating"); + presence.state = "Spectating"; Discord_UpdatePresence(&presence); } #else -- cgit From afbbc5476bf5102f421a94006e5f590cb90fd862 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Tue, 30 Jul 2019 20:42:33 +0200 Subject: move #ifdef BASSAUDIO so the audio tab isn't deleted as a whole --- src/aooptionsdialog.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/aooptionsdialog.cpp b/src/aooptionsdialog.cpp index 0f6a054..4bfe9de 100644 --- a/src/aooptionsdialog.cpp +++ b/src/aooptionsdialog.cpp @@ -199,7 +199,6 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi ui_callwords_layout->addWidget(ui_callwords_explain_lbl); // The audio tab. - #ifdef BASSAUDIO ui_audio_tab = new QWidget(); ui_settings_tabs->addTab(ui_audio_tab, tr("Audio")); @@ -221,20 +220,23 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi // Let's fill out the combobox with the available audio devices. Or don't if there is no audio int a = 0; + #ifdef BASSAUDIO BASS_DEVICEINFO info; - + #endif if (needs_default_audiodev()) { + ui_audio_device_combobox->addItem("default"); - } + } + #ifdef BASSAUDIO for (a = 0; BASS_GetDeviceInfo(a, &info); a++) { ui_audio_device_combobox->addItem(info.name); if (p_ao_app->get_audio_output_device() == info.name) ui_audio_device_combobox->setCurrentIndex(ui_audio_device_combobox->count()-1); } - + #endif ui_audio_layout->setWidget(0, QFormLayout::FieldRole, ui_audio_device_combobox); ui_audio_volume_divider = new QFrame(ui_audio_widget); @@ -312,7 +314,6 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi ui_blank_blips_cb->setChecked(p_ao_app->get_blank_blip()); ui_audio_layout->setWidget(7, QFormLayout::FieldRole, ui_blank_blips_cb); - #endif // The casing tab! ui_casing_tab = new QWidget(); -- cgit From 15a48a051c21275662b833d46d44b4e690d535ce Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Mon, 5 Aug 2019 18:53:34 +0200 Subject: make the password field in charselect useful let the server decide what to do with this --- src/charselect.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/charselect.cpp b/src/charselect.cpp index 4987cf5..846daff 100644 --- a/src/charselect.cpp +++ b/src/charselect.cpp @@ -135,7 +135,7 @@ void Courtroom::char_clicked(int n_char) } else { - ao_app->send_server_packet(new AOPacket("CC#" + QString::number(ao_app->s_pv) + "#" + QString::number(n_char) + "#" + get_hdid() + "#%")); + ao_app->send_server_packet(new AOPacket("CC#" + QString::number(ao_app->s_pv) + "#" + QString::number(n_char) + "#" + get_hdid() + "#" + ui_char_password->text() +"#%")); } ui_ic_chat_name->setPlaceholderText(char_list.at(n_char).name); -- cgit From df72671105bb6ae205a9f156de8a49f144bc59f8 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Mon, 5 Aug 2019 21:54:03 +0200 Subject: Revert "make the password field in charselect useful" This reverts commit 15a48a051c21275662b833d46d44b4e690d535ce. --- src/charselect.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/charselect.cpp b/src/charselect.cpp index 846daff..4987cf5 100644 --- a/src/charselect.cpp +++ b/src/charselect.cpp @@ -135,7 +135,7 @@ void Courtroom::char_clicked(int n_char) } else { - ao_app->send_server_packet(new AOPacket("CC#" + QString::number(ao_app->s_pv) + "#" + QString::number(n_char) + "#" + get_hdid() + "#" + ui_char_password->text() +"#%")); + ao_app->send_server_packet(new AOPacket("CC#" + QString::number(ao_app->s_pv) + "#" + QString::number(n_char) + "#" + get_hdid() + "#%")); } ui_ic_chat_name->setPlaceholderText(char_list.at(n_char).name); -- cgit From 223f69d67a888e82fb305b19e51e9d81fffadc59 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Mon, 5 Aug 2019 21:57:17 +0200 Subject: eat shit tsuserver --- src/charselect.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/charselect.cpp b/src/charselect.cpp index 4987cf5..9d579a7 100644 --- a/src/charselect.cpp +++ b/src/charselect.cpp @@ -135,6 +135,7 @@ void Courtroom::char_clicked(int n_char) } else { + ao_app->send_server_packet(new AOPacket("PW#" + ui_char_password->text() + "#%")); ao_app->send_server_packet(new AOPacket("CC#" + QString::number(ao_app->s_pv) + "#" + QString::number(n_char) + "#" + get_hdid() + "#%")); } -- cgit From 230b1a76225def5de5c61efe1eb97e5324512ccf Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Mon, 5 Aug 2019 22:07:39 +0200 Subject: numbered arguments and more strings --- src/charselect.cpp | 2 +- src/courtroom.cpp | 10 +++++----- src/lobby.cpp | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/charselect.cpp b/src/charselect.cpp index 58c990b..7e20c74 100644 --- a/src/charselect.cpp +++ b/src/charselect.cpp @@ -214,7 +214,7 @@ void Courtroom::character_loading_finished() 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(total_loading_size)) * 100); ao_app->w_lobby->set_loading_value(loading_value); - ao_app->w_lobby->set_loading_text(tr("Generating chars:\n") + QString::number(ao_app->generated_chars) + "/" + QString::number(ao_app->char_list_size)); + ao_app->w_lobby->set_loading_text(tr("Generating chars:\n%1/%2").arg(QString::number(ao_app->generated_chars)).arg(QString::number(ao_app->char_list_size))); } } diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 2ba3ba2..dc7f12c 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -245,7 +245,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() ui_pair_list = new QListWidget(this); ui_pair_offset_spinbox = new QSpinBox(this); ui_pair_offset_spinbox->setRange(-100,100); - ui_pair_offset_spinbox->setSuffix("% offset"); + ui_pair_offset_spinbox->setSuffix(tr("% offset")); ui_pair_button = new AOButton(this, ao_app); ui_evidence_button = new AOButton(this, ao_app); @@ -2821,7 +2821,7 @@ void Courtroom::on_ooc_return_pressed() if (command.size() < 2) { - append_server_chatmessage("CLIENT", tr("You need to give a filename to load (extension not needed)! Make sure that it is in the `base/cases/` folder, and that it is a correctly formatted ini.\nCases you can load: ") + caseslist.join(", "), "1"); + append_server_chatmessage("CLIENT", tr("You need to give a filename to load (extension not needed)! Make sure that it is in the `base/cases/` folder, and that it is a correctly formatted ini.\nCases you can load: %1").arg(caseslist.join(", ")), "1"); ui_ooc_chat_message->clear(); return; } @@ -2842,13 +2842,13 @@ void Courtroom::on_ooc_return_pressed() QString casestatus = casefile.value("status", "").value(); if (!caseauth.isEmpty()) - append_server_chatmessage("CLIENT", tr("Case made by ") + caseauth + ".", "1"); + append_server_chatmessage("CLIENT", tr("Case made by %1.").arg(caseauth), "1"); if (!casedoc.isEmpty()) ao_app->send_server_packet(new AOPacket("CT#" + ui_ooc_chat_name->text() + "#/doc " + casedoc + "#%")); if (!casestatus.isEmpty()) ao_app->send_server_packet(new AOPacket("CT#" + ui_ooc_chat_name->text() + "#/status " + casestatus + "#%")); if (!cmdoc.isEmpty()) - append_server_chatmessage("CLIENT", tr("Navigate to ") + cmdoc + tr(" for the CM doc."), "1"); + append_server_chatmessage("CLIENT", tr("Navigate to %1 for the CM doc.").arg(cmdoc), "1"); for (int i = local_evidence_list.size() - 1; i >= 0; i--) { ao_app->send_server_packet(new AOPacket("DE#" + QString::number(i) + "#%")); @@ -2867,7 +2867,7 @@ void Courtroom::on_ooc_return_pressed() ao_app->send_server_packet(new AOPacket("PE", f_contents)); } - append_server_chatmessage("CLIENT", tr("Your case \"") + command[1] + tr("\" was loaded!"), "1"); + append_server_chatmessage("CLIENT", tr("Your case \"%1\" was loaded!").arg(command[1]), "1"); ui_ooc_chat_message->clear(); return; } diff --git a/src/lobby.cpp b/src/lobby.cpp index 776528c..02ed128 100644 --- a/src/lobby.cpp +++ b/src/lobby.cpp @@ -9,7 +9,7 @@ Lobby::Lobby(AOApplication *p_ao_app) : QMainWindow() { ao_app = p_ao_app; - this->setWindowTitle("Attorney Online 2"); + this->setWindowTitle(tr("Attorney Online 2")); this->setWindowIcon(QIcon(":/logo.png")); ui_background = new AOImage(this, ao_app); @@ -26,7 +26,7 @@ Lobby::Lobby(AOApplication *p_ao_app) : QMainWindow() ui_chatbox = new AOTextArea(this); ui_chatbox->setOpenExternalLinks(true); ui_chatname = new QLineEdit(this); - ui_chatname->setPlaceholderText("Name"); + ui_chatname->setPlaceholderText(tr("Name")); ui_chatname->setText(ao_app->get_ooc_name()); ui_chatmessage = new QLineEdit(this); ui_loading_background = new AOImage(this, ao_app); @@ -101,7 +101,7 @@ void Lobby::set_widgets() ui_connect->set_image("connect.png"); set_size_and_pos(ui_version, "version"); - ui_version->setText("Version: " + ao_app->get_version_string()); + ui_version->setText(tr("Version: %1").arg(ao_app->get_version_string())); set_size_and_pos(ui_about, "about"); ui_about->set_image("about.png"); @@ -111,7 +111,7 @@ void Lobby::set_widgets() "font: bold;"); set_size_and_pos(ui_player_count, "player_count"); - ui_player_count->setText("Offline"); + ui_player_count->setText(tr("Offline")); ui_player_count->setStyleSheet("font: bold;" "color: white;" "qproperty-alignment: AlignCenter;"); -- cgit From cab5310029160b3dc2e303d874117b482915ea06 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Mon, 5 Aug 2019 22:20:04 +0200 Subject: missed 2 lobby related ones --- src/aoapplication.cpp | 3 +-- src/lobby.cpp | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/aoapplication.cpp b/src/aoapplication.cpp index c47f350..6213acd 100644 --- a/src/aoapplication.cpp +++ b/src/aoapplication.cpp @@ -160,8 +160,7 @@ void AOApplication::ms_connect_finished(bool connected, bool will_retry) if (will_retry) { if (lobby_constructed) - w_lobby->append_error("Error connecting to master server. Will try again in " - + QString::number(net_manager->ms_reconnect_delay) + " seconds."); + w_lobby->append_error(tr("Error connecting to master server. Will try again in %1 seconds.").arg(QString::number(net_manager->ms_reconnect_delay))); } else { diff --git a/src/lobby.cpp b/src/lobby.cpp index 02ed128..c95fd49 100644 --- a/src/lobby.cpp +++ b/src/lobby.cpp @@ -373,7 +373,7 @@ void Lobby::append_error(QString f_message) void Lobby::set_player_count(int players_online, int max_players) { - QString f_string = "Online: " + QString::number(players_online) + "/" + QString::number(max_players); + QString f_string = tr("Online: %1/%2").arg(QString::number(players_online)).arg(QString::number(max_players)); ui_player_count->setText(f_string); } -- cgit From 078ad79b65692644a1d7230b4cfb9277a16d0310 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Mon, 5 Aug 2019 23:30:00 +0200 Subject: language setting --- src/aooptionsdialog.cpp | 13 +++++++++++++ src/main.cpp | 11 +++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/aooptionsdialog.cpp b/src/aooptionsdialog.cpp index 4bfe9de..d68f6cb 100644 --- a/src/aooptionsdialog.cpp +++ b/src/aooptionsdialog.cpp @@ -167,6 +167,18 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi ui_gameplay_form->setWidget(9, QFormLayout::FieldRole, ui_discord_cb); + ui_language_label = new QLabel(ui_form_layout_widget); + ui_language_label->setText(tr("Language:")); + ui_language_label->setToolTip(tr("Sets the language if you don't want to use your system language.")); + ui_gameplay_form->setWidget(10, QFormLayout::LabelRole, ui_language_label); + + ui_language_combobox = new QComboBox(ui_form_layout_widget); + ui_language_combobox->addItem(" - Default"); + ui_language_combobox->addItem("en - English"); + ui_language_combobox->addItem("de - German"); + ui_language_combobox->addItem("jp - Japanese"); + ui_gameplay_form->setWidget(10, QFormLayout::FieldRole, ui_language_combobox); + // Here we start the callwords tab. ui_callwords_tab = new QWidget(); ui_settings_tabs->addTab(ui_callwords_tab, tr("Callwords")); @@ -466,6 +478,7 @@ void AOOptionsDialog::save_pressed() configini->setValue("show_custom_shownames", ui_showname_cb->isChecked()); configini->setValue("master", ui_ms_textbox->text()); configini->setValue("discord", ui_discord_cb->isChecked()); + configini->setValue("language", ui_language_combobox->currentText().left(2)); QFile* callwordsini = new QFile(ao_app->get_base_path() + "callwords.ini"); diff --git a/src/main.cpp b/src/main.cpp index 7c2daa6..6c15e6f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,13 +21,20 @@ int main(int argc, char *argv[]) AOApplication main_app(argc, argv); + QSettings* configini = main_app.configini; + + QString p_language = configini->value("language",QLocale::system().name()).toString(); + if (p_language==" " || p_language=="") + p_language = QLocale::system().name(); + QTranslator qtTranslator; - qtTranslator.load("qt_" + QLocale::system().name(), + qtTranslator.load("qt_" + p_language, QLibraryInfo::location(QLibraryInfo::TranslationsPath)); main_app.installTranslator(&qtTranslator); QTranslator appTranslator; - appTranslator.load("ao_" + QLocale::system().name(),":/resource/translations/"); + qDebug() << ":/resource/translations/ao_" + p_language; + appTranslator.load("ao_" + p_language,":/resource/translations/"); main_app.installTranslator(&appTranslator); main_app.construct_lobby(); -- cgit From c974ab01ca5f28b00fa88ae3b19abe481aee43a3 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Tue, 6 Aug 2019 20:29:04 +0200 Subject: add es and ru to options and translate a lot more strings from the courtroom --- src/aooptionsdialog.cpp | 2 ++ src/courtroom.cpp | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/aooptionsdialog.cpp b/src/aooptionsdialog.cpp index d68f6cb..539a822 100644 --- a/src/aooptionsdialog.cpp +++ b/src/aooptionsdialog.cpp @@ -176,7 +176,9 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi ui_language_combobox->addItem(" - Default"); ui_language_combobox->addItem("en - English"); ui_language_combobox->addItem("de - German"); + ui_language_combobox->addItem("es - Spanish"); ui_language_combobox->addItem("jp - Japanese"); + ui_language_combobox->addItem("ru - Russian"); ui_gameplay_form->setWidget(10, QFormLayout::FieldRole, ui_language_combobox); // Here we start the callwords tab. diff --git a/src/courtroom.cpp b/src/courtroom.cpp index dc7f12c..54b1b2d 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -563,14 +563,14 @@ void Courtroom::set_widgets() ui_prosecution_bar->set_image("prosecutionbar" + QString::number(prosecution_bar_state) + ".png"); set_size_and_pos(ui_music_label, "music_label"); - ui_music_label->setText("Music"); + ui_music_label->setText(tr("Music")); set_size_and_pos(ui_sfx_label, "sfx_label"); - ui_sfx_label->setText("Sfx"); + ui_sfx_label->setText(tr("Sfx")); set_size_and_pos(ui_blip_label, "blip_label"); - ui_blip_label->setText("Blips"); + ui_blip_label->setText(tr("Blips")); set_size_and_pos(ui_log_limit_label, "log_limit_label"); - ui_log_limit_label->setText("Log limit"); + ui_log_limit_label->setText(tr("Log limit")); set_size_and_pos(ui_hold_it, "hold_it"); ui_hold_it->set_image("holdit.png"); @@ -580,7 +580,7 @@ void Courtroom::set_widgets() ui_take_that->set_image("takethat.png"); set_size_and_pos(ui_ooc_toggle, "ooc_toggle"); - ui_ooc_toggle->setText("Server"); + ui_ooc_toggle->setText(tr("Server")); set_size_and_pos(ui_witness_testimony, "witness_testimony"); ui_witness_testimony->set_image("witnesstestimony.png"); @@ -593,25 +593,25 @@ void Courtroom::set_widgets() ui_not_guilty->set_image("notguilty.png"); set_size_and_pos(ui_change_character, "change_character"); - ui_change_character->setText("Change character"); + ui_change_character->setText(tr("Change character")); set_size_and_pos(ui_reload_theme, "reload_theme"); - ui_reload_theme->setText("Reload theme"); + ui_reload_theme->setText(tr("Reload theme")); set_size_and_pos(ui_call_mod, "call_mod"); - ui_call_mod->setText("Call mod"); + ui_call_mod->setText(tr("Call mod")); set_size_and_pos(ui_settings, "settings"); - ui_settings->setText("Settings"); + ui_settings->setText(tr("Settings")); set_size_and_pos(ui_announce_casing, "casing_button"); - ui_announce_casing->setText("Casing"); + ui_announce_casing->setText(tr("Casing")); set_size_and_pos(ui_switch_area_music, "switch_area_music"); - ui_switch_area_music->setText("A/M"); + ui_switch_area_music->setText(tr("A/M")); set_size_and_pos(ui_pre, "pre"); - ui_pre->setText("Preanim"); + ui_pre->setText(tr("Preanim")); set_size_and_pos(ui_pre_non_interrupt, "pre_no_interrupt"); set_size_and_pos(ui_flip, "flip"); -- cgit From dd325de31e3502e20a5134a5358961d4e0f367f9 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Tue, 6 Aug 2019 21:22:49 +0200 Subject: use languages own name --- src/aooptionsdialog.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/aooptionsdialog.cpp b/src/aooptionsdialog.cpp index 539a822..15a6e35 100644 --- a/src/aooptionsdialog.cpp +++ b/src/aooptionsdialog.cpp @@ -175,10 +175,10 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi ui_language_combobox = new QComboBox(ui_form_layout_widget); ui_language_combobox->addItem(" - Default"); ui_language_combobox->addItem("en - English"); - ui_language_combobox->addItem("de - German"); - ui_language_combobox->addItem("es - Spanish"); - ui_language_combobox->addItem("jp - Japanese"); - ui_language_combobox->addItem("ru - Russian"); + ui_language_combobox->addItem("de - Deutsch"); + ui_language_combobox->addItem("es - Español"); + ui_language_combobox->addItem("jp - 日本語"); + ui_language_combobox->addItem("ru - Русски"); ui_gameplay_form->setWidget(10, QFormLayout::FieldRole, ui_language_combobox); // Here we start the callwords tab. -- cgit From 47eb36789e27440af3b86ebe6cb7f0f74ef53c8c Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Tue, 6 Aug 2019 21:25:33 +0200 Subject: numbered arguments for kick and ban torture --- src/packet_distribution.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index 2bd2693..b79ec30 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -639,7 +639,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet) { if (courtroom_constructed && f_contents.size() >= 1) { - call_notice(tr("You have been kicked from the server.\nReason: ") + f_contents.at(0)); + call_notice(tr("You have been kicked from the server.\nReason: %1").arg(f_contents.at(0))); construct_lobby(); destruct_courtroom(); } @@ -648,7 +648,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet) { if (courtroom_constructed && f_contents.size() >= 1) { - call_notice("You have been banned from the server.\nReason: " + f_contents.at(0)); + call_notice(tr("You have been banned from the server.\nReason: %1").arg(f_contents.at(0))); construct_lobby(); destruct_courtroom(); } @@ -656,7 +656,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet) } else if (header == "BD") { - call_notice(tr("You are banned on this server.\nReason: ") + f_contents.at(0)); + call_notice(tr("You are banned on this server.\nReason: %1").arg(f_contents.at(0))); } else if (header == "ZZ") { -- cgit From c6b949335ac5f4a2ab060e692e8022060a802960 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Tue, 6 Aug 2019 21:27:27 +0200 Subject: +1 on style --- src/main.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 6c15e6f..6c7b151 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,3 @@ - #include "aoapplication.h" #include "datatypes.h" @@ -21,10 +20,10 @@ int main(int argc, char *argv[]) AOApplication main_app(argc, argv); - QSettings* configini = main_app.configini; + QSettings *configini = main_app.configini; - QString p_language = configini->value("language",QLocale::system().name()).toString(); - if (p_language==" " || p_language=="") + QString p_language = configini->value("language", QLocale::system().name()).toString(); + if (p_language == " " || p_language == "") p_language = QLocale::system().name(); QTranslator qtTranslator; @@ -34,7 +33,7 @@ int main(int argc, char *argv[]) QTranslator appTranslator; qDebug() << ":/resource/translations/ao_" + p_language; - appTranslator.load("ao_" + p_language,":/resource/translations/"); + appTranslator.load("ao_" + p_language, ":/resource/translations/"); main_app.installTranslator(&appTranslator); main_app.construct_lobby(); -- cgit From 338dd2003ef2436c307b0e4f28ceabcef6ad404f Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Wed, 7 Aug 2019 14:22:18 +0200 Subject: missed a backwards lowercase N with accent mark --- src/aooptionsdialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/aooptionsdialog.cpp b/src/aooptionsdialog.cpp index 15a6e35..d9e8f89 100644 --- a/src/aooptionsdialog.cpp +++ b/src/aooptionsdialog.cpp @@ -178,7 +178,7 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi ui_language_combobox->addItem("de - Deutsch"); ui_language_combobox->addItem("es - Español"); ui_language_combobox->addItem("jp - 日本語"); - ui_language_combobox->addItem("ru - Русски"); + ui_language_combobox->addItem("ru - Русский"); ui_gameplay_form->setWidget(10, QFormLayout::FieldRole, ui_language_combobox); // Here we start the callwords tab. -- cgit From 0247ca07fe727f61a6a80228547a1b93cc800c34 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Wed, 7 Aug 2019 14:51:21 +0200 Subject: show current setting --- src/aooptionsdialog.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/aooptionsdialog.cpp b/src/aooptionsdialog.cpp index d9e8f89..b5cb46f 100644 --- a/src/aooptionsdialog.cpp +++ b/src/aooptionsdialog.cpp @@ -173,6 +173,7 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi ui_gameplay_form->setWidget(10, QFormLayout::LabelRole, ui_language_label); ui_language_combobox = new QComboBox(ui_form_layout_widget); + ui_language_combobox->addItem(configini->value("language", " ").value() + " - Keep current setting"); ui_language_combobox->addItem(" - Default"); ui_language_combobox->addItem("en - English"); ui_language_combobox->addItem("de - Deutsch"); -- cgit From 047ce046316a96c6183846b40062dd6f72de61fd Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Sun, 11 Aug 2019 23:58:43 +0200 Subject: fix mac content loading it now looks for the content next to the .app bundle and not inside it --- src/path_functions.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/path_functions.cpp b/src/path_functions.cpp index c51cfde..5eb97a3 100644 --- a/src/path_functions.cpp +++ b/src/path_functions.cpp @@ -30,6 +30,8 @@ QString AOApplication::get_base_path() QString external_storage = getenv("EXTERNAL_STORAGE"); base_path = external_storage + "/AO2/"; } +#elif defined __APPLE__ + base_path = applicationDirPath() + "/../../../base/"; #else base_path = applicationDirPath() + "/base/"; #endif -- cgit From 2509cc5e0bf4d9c4bbd6798f71886e34cc8476b2 Mon Sep 17 00:00:00 2001 From: mac builder Date: Tue, 13 Aug 2019 20:01:42 +0200 Subject: get mac serial for hdid --- src/hardware_functions.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/hardware_functions.cpp b/src/hardware_functions.cpp index 5d6b6ff..bd6a6c3 100644 --- a/src/hardware_functions.cpp +++ b/src/hardware_functions.cpp @@ -50,10 +50,31 @@ QString get_hdid() } #elif defined __APPLE__ +#include +#include + QString get_hdid() { - //hdids are broken at this point anyways - return "just a mac passing by"; + CFStringRef serial; + char buffer[64] = {0}; + QString hdid; + io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault, + IOServiceMatching("IOPlatformExpertDevice")); + if (platformExpert) + { + CFTypeRef serialNumberAsCFString = IORegistryEntryCreateCFProperty(platformExpert, + CFSTR(kIOPlatformSerialNumberKey), + kCFAllocatorDefault, 0); + if (serialNumberAsCFString) { + serial = (CFStringRef)serialNumberAsCFString; + } + if (CFStringGetCString(serial, buffer, 64, kCFStringEncodingUTF8)) { + hdid = buffer; + } + + IOObjectRelease(platformExpert); + } + return hdid; } #else -- cgit From 4700902551f80769b54cb452b0fcb794669c553b Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Sat, 17 Aug 2019 20:47:41 +0200 Subject: fix qaudio volume --- src/aoblipplayer.cpp | 30 ++++++++++++++++++++++-------- src/aosfxplayer.cpp | 24 +++++++++++++++++------- 2 files changed, 39 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/aoblipplayer.cpp b/src/aoblipplayer.cpp index 4dfb895..1c668ab 100644 --- a/src/aoblipplayer.cpp +++ b/src/aoblipplayer.cpp @@ -18,7 +18,7 @@ void AOBlipPlayer::set_blips(QString p_sfx) m_stream_list[n_stream] = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_UNICODE | BASS_ASYNCFILE); } - set_volume(m_volume); + set_volume_internal(m_volume); } void AOBlipPlayer::blip_tick() @@ -34,11 +34,15 @@ void AOBlipPlayer::blip_tick() BASS_ChannelPlay(f_stream, false); } -void AOBlipPlayer::set_volume(int p_value) +void AOBlipPlayer::set_volume(qreal p_value) { - m_volume = p_value; + m_volume = p_value / 100; + set_volume_internal(m_volume); +} - float volume = p_value / 100.0f; +void AOBlipPlayer::set_volume_internal(qreal p_value) +{ + float volume = p_value; for (int n_stream = 0 ; n_stream < 5 ; ++n_stream) { @@ -61,7 +65,7 @@ void AOBlipPlayer::set_blips(QString p_sfx) m_blips.setSource(QUrl::fromLocalFile(f_path)); } - set_volume(m_volume); + set_volume_internal(m_volume); } void AOBlipPlayer::blip_tick() @@ -74,9 +78,14 @@ void AOBlipPlayer::blip_tick() m_blips.play(); } -void AOBlipPlayer::set_volume(int p_value) +void AOBlipPlayer::set_volume(qreal p_value) +{ + m_volume = p_value / 100; + set_volume_internal(m_volume); +} + +void AOBlipPlayer::set_volume_internal(qreal p_value) { - m_volume = p_value; m_blips.setVolume(m_volume); } #else //No audio @@ -96,7 +105,12 @@ void AOBlipPlayer::blip_tick() } -void AOBlipPlayer::set_volume(int p_value) +void AOBlipPlayer::set_volume(qreal p_value) +{ + +} + +void AOBlipPlayer::set_volume_internal(qreal p_value) { } diff --git a/src/aosfxplayer.cpp b/src/aosfxplayer.cpp index 710d7a8..3faaad4 100644 --- a/src/aosfxplayer.cpp +++ b/src/aosfxplayer.cpp @@ -44,11 +44,16 @@ void AOSfxPlayer::stop() BASS_ChannelStop(m_stream); } -void AOSfxPlayer::set_volume(int p_value) +void AOSfxPlayer::set_volume(qreal p_value) { - m_volume = p_value; - float volume = p_value / 100.0f; - BASS_ChannelSetAttribute(m_stream, BASS_ATTRIB_VOL, volume); + m_volume = p_value / 100; + set_volume_internal(m_volume); +} + +void AOSfxPlayer::set_volume_internal(qreal p_value) +{ + float volume = p_value; + BASS_ChannelSetAttribute(m_stream, BASS_ATTRIB_VOL, volume); } #elif defined(QTAUDIO) //Using Qt's QSoundEffect class AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app) @@ -83,7 +88,7 @@ void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout) { m_sfx.setSource(QUrl::fromLocalFile(f_path)); - set_volume(m_volume); + set_volume_internal(m_volume); m_sfx.play(); } @@ -94,9 +99,14 @@ void AOSfxPlayer::stop() m_sfx.stop(); } -void AOSfxPlayer::set_volume(int p_value) +void AOSfxPlayer::set_volume(qreal p_value) +{ + m_volume = p_value/100; + set_volume_internal(m_volume); +} + +void AOSfxPlayer::set_volume_internal(qreal p_value) { - m_volume = p_value; m_sfx.setVolume(m_volume); } #else -- cgit From 49be444d74cfdecdaa1090a2a51c19f70ae9b0b1 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Sat, 17 Aug 2019 21:09:13 +0200 Subject: OOP :convenience_store: --- src/aosfxplayer.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/aosfxplayer.cpp b/src/aosfxplayer.cpp index 3faaad4..98dd2cd 100644 --- a/src/aosfxplayer.cpp +++ b/src/aosfxplayer.cpp @@ -126,7 +126,12 @@ void AOSfxPlayer::stop() } -void AOSfxPlayer::set_volume(int p_value) +void AOSfxPlayer::set_volume(qreal p_value) +{ + +} + +void AOSfxPlayer::set_volume_internal(qreal p_value) { } -- cgit From 35f2333403cdd930848fb998739583c6c829f5d3 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Mon, 19 Aug 2019 19:06:41 +0200 Subject: list audio devices (doesn't apply it yet) --- src/aooptionsdialog.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/aooptionsdialog.cpp b/src/aooptionsdialog.cpp index b5cb46f..82507a1 100644 --- a/src/aooptionsdialog.cpp +++ b/src/aooptionsdialog.cpp @@ -1,6 +1,5 @@ #include "aooptionsdialog.h" #include "aoapplication.h" -#include "bass.h" AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDialog(parent) { @@ -235,9 +234,6 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi // Let's fill out the combobox with the available audio devices. Or don't if there is no audio int a = 0; - #ifdef BASSAUDIO - BASS_DEVICEINFO info; - #endif if (needs_default_audiodev()) { @@ -245,12 +241,20 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi } #ifdef BASSAUDIO + BASS_DEVICEINFO info; for (a = 0; BASS_GetDeviceInfo(a, &info); a++) { ui_audio_device_combobox->addItem(info.name); if (p_ao_app->get_audio_output_device() == info.name) ui_audio_device_combobox->setCurrentIndex(ui_audio_device_combobox->count()-1); } + #elif defined QTAUDIO + foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) + { + ui_audio_device_combobox->addItem(deviceInfo.deviceName()); + if (p_ao_app->get_audio_output_device() == deviceInfo.deviceName()) + ui_audio_device_combobox->setCurrentIndex(ui_audio_device_combobox->count()-1); + } #endif ui_audio_layout->setWidget(0, QFormLayout::FieldRole, ui_audio_device_combobox); -- cgit From d94d2fb405a0d3634951cc8fa4b0e22c7979c438 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Mon, 19 Aug 2019 19:38:47 +0200 Subject: read and store qt audio device --- src/courtroom.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 54b1b2d..a171416 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -28,6 +28,20 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() } } } + #elif defined QTAUDIO + + if (ao_app->get_audio_output_device() != "default") + { + foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) + { + if (ao_app->get_audio_output_device() == deviceInfo.deviceName()) + { + ao_app->QtAudioDevice = deviceInfo; + qDebug() << deviceInfo.deviceName() << "was set as the default audio output device."; + break; + } + } + } #endif keepalive_timer = new QTimer(this); -- cgit From 177c56e2b8402cee95ae1ff1e042ddf2eabe52b6 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Tue, 20 Aug 2019 18:28:25 +0200 Subject: move button enabling to ID because not all servers understand FL --- src/packet_distribution.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index b79ec30..40015fd 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -175,6 +175,8 @@ void AOApplication::server_packet_received(AOPacket *p_packet) s_pv = f_contents.at(0).toInt(); server_software = f_contents.at(1); + w_lobby->enable_connect_button(); + send_server_packet(new AOPacket("ID#AO2#" + get_version_string() + "#%")); } else if (header == "CT") @@ -214,8 +216,6 @@ void AOApplication::server_packet_received(AOPacket *p_packet) casing_alerts_enabled = true; if (f_packet.contains("modcall_reason",Qt::CaseInsensitive)) modcall_reason_enabled = true; - - w_lobby->enable_connect_button(); } else if (header == "PN") { -- cgit From 5807410b1dae61ba9307197f7d1ae04b8e55c378 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Tue, 20 Aug 2019 18:35:42 +0200 Subject: doubleclick to join a server --- src/lobby.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') diff --git a/src/lobby.cpp b/src/lobby.cpp index c95fd49..6f257ce 100644 --- a/src/lobby.cpp +++ b/src/lobby.cpp @@ -47,6 +47,7 @@ Lobby::Lobby(AOApplication *p_ao_app) : QMainWindow() connect(ui_connect, SIGNAL(released()), this, SLOT(on_connect_released())); connect(ui_about, SIGNAL(clicked()), this, SLOT(on_about_clicked())); connect(ui_server_list, SIGNAL(clicked(QModelIndex)), this, SLOT(on_server_list_clicked(QModelIndex))); + connect(ui_server_list, SIGNAL(activated(QModelIndex)), this, SLOT(on_server_list_doubleclicked(QModelIndex))); connect(ui_chatmessage, SIGNAL(returnPressed()), this, SLOT(on_chatfield_return_pressed())); connect(ui_cancel, SIGNAL(clicked()), ao_app, SLOT(loading_cancelled())); @@ -282,9 +283,13 @@ void Lobby::on_about_clicked() QMessageBox::about(this, "About", msg); } +//clicked on an item in the serverlist void Lobby::on_server_list_clicked(QModelIndex p_model) { + if (p_model != last_model) + { server_type f_server; + last_model = p_model; int n_server = p_model.row(); if (n_server < 0) @@ -318,6 +323,14 @@ void Lobby::on_server_list_clicked(QModelIndex p_model) ui_connect->setEnabled(false); ao_app->net_manager->connect_to_server(f_server); + } +} + +//doubleclicked on an item in the serverlist so we'll connect right away +void Lobby::on_server_list_doubleclicked(QModelIndex p_model) +{ + on_server_list_clicked(p_model); + on_connect_released(); } void Lobby::on_chatfield_return_pressed() -- cgit From 5520c248698e067c0b6f88ead616bc546eaab80e Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Thu, 22 Aug 2019 21:02:09 +0200 Subject: bass blips were slightly too quiet --- src/aosfxplayer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/aosfxplayer.cpp b/src/aosfxplayer.cpp index 98dd2cd..ad8ced6 100644 --- a/src/aosfxplayer.cpp +++ b/src/aosfxplayer.cpp @@ -32,7 +32,7 @@ void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout) m_stream = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_STREAM_AUTOFREE | BASS_UNICODE | BASS_ASYNCFILE); - set_volume(m_volume); + set_volume_internal(m_volume); if (ao_app->get_audio_output_device() != "default") BASS_ChannelSetDevice(m_stream, BASS_GetDevice()); -- cgit