Merge pull request #5 from Iamgoofball/patch-1

Fixes opus, adds opus and mp3 support to ini SFX, thanks Longbyte
This commit is contained in:
wewlad1 2018-10-16 03:18:51 -07:00 committed by GitHub
commit 7e20b50b4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 8 deletions

View File

@ -88,7 +88,7 @@ HEADERS += lobby.h \
# in the same way as BASS. Discord RPC uses CMake, which does not play nicely with # in the same way as BASS. Discord RPC uses CMake, which does not play nicely with
# QMake, so this step must be manual. # QMake, so this step must be manual.
unix:LIBS += -L$$PWD -lbass -ldiscord-rpc unix:LIBS += -L$$PWD -lbass -ldiscord-rpc
win32:LIBS += -L$$PWD "$$PWD/bass.dll" -ldiscord-rpc #"$$PWD/discord-rpc.dll" win32:LIBS += -L$$PWD "$$PWD/bass.dll" -L$$PWD "$$PWD/discord-rpc.dll"
android:LIBS += -L$$PWD\android\libs\armeabi-v7a\ -lbass android:LIBS += -L$$PWD\android\libs\armeabi-v7a\ -lbass
CONFIG += c++11 CONFIG += c++11

View File

@ -169,6 +169,9 @@ public:
//Returns the sfx with p_identifier from sounds.ini in the current theme path //Returns the sfx with p_identifier from sounds.ini in the current theme path
QString get_sfx(QString p_identifier); QString get_sfx(QString p_identifier);
//Figure out if we can opus this or if we should fall back to wav
QString get_sfx_suffix(QString sound_to_check);
//Returns the value of p_search_line within target_tag and terminator_tag //Returns the value of p_search_line within target_tag and terminator_tag
QString read_char_ini(QString p_char, QString p_search_line, QString target_tag, QString terminator_tag); QString read_char_ini(QString p_char, QString p_search_line, QString target_tag, QString terminator_tag);
@ -226,7 +229,7 @@ public:
private: private:
const int RELEASE = 2; const int RELEASE = 2;
const int MAJOR_VERSION = 5; const int MAJOR_VERSION = 5;
const int MINOR_VERSION = 1; const int MINOR_VERSION = 2;
QString current_theme = "default"; QString current_theme = "default";

View File

@ -6,7 +6,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
//initializing sound device //initializing sound device
BASS_Init(-1, 48000, BASS_DEVICE_LATENCY, 0, NULL); BASS_Init(-1, 48000, BASS_DEVICE_LATENCY, 0, NULL);
BASS_PluginLoad("bassopus.dll", BASS_UNICODE); BASS_PluginLoad(L"bassopus.dll", BASS_UNICODE);
keepalive_timer = new QTimer(this); keepalive_timer = new QTimer(this);
keepalive_timer->start(60000); keepalive_timer->start(60000);
@ -1377,7 +1377,7 @@ void Courtroom::play_sfx()
if (sfx_name == "1") if (sfx_name == "1")
return; return;
sfx_player->play(sfx_name + ".wav"); sfx_player->play(ao_app->get_sfx_suffix(sfx_name));
} }
void Courtroom::set_scene() void Courtroom::set_scene()
@ -1488,12 +1488,13 @@ void Courtroom::set_text_color()
ui_vp_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);" ui_vp_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);"
"color: yellow"); "color: yellow");
break; break;
default:
qDebug() << "W: undefined text color: " << m_chatmessage[TEXT_COLOR];
case WHITE: case WHITE:
ui_vp_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);" ui_vp_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);"
"color: white"); "color: white");
break;
default:
qDebug() << "W: undefined text color: " << m_chatmessage[TEXT_COLOR];
} }
} }

View File

@ -340,6 +340,26 @@ QString AOApplication::get_sfx(QString p_identifier)
return return_sfx; return return_sfx;
} }
QString AOApplication::get_sfx_suffix(QString sound_to_check)
{
QString wav_check = get_sounds_path() + sound_to_check + ".wav";
QString mp3_check = get_sounds_path() + sound_to_check + ".mp3";
QString opus_check = get_sounds_path() + sound_to_check + ".opus";
if(file_exists(opus_check))
{
return sound_to_check + ".opus";
}
if(file_exists(mp3_check))
{
return sound_to_check + ".mp3";
}
if(file_exists(wav_check))
{
return sound_to_check + ".wav";
}
return sound_to_check + ".wav";
}
//returns whatever is to the right of "search_line =" within target_tag and terminator_tag, trimmed //returns whatever is to the right of "search_line =" within target_tag and terminator_tag, trimmed
//returns the empty string if the search line couldnt be found //returns the empty string if the search line couldnt be found
QString AOApplication::read_char_ini(QString p_char, QString p_search_line, QString target_tag, QString terminator_tag) QString AOApplication::read_char_ini(QString p_char, QString p_search_line, QString target_tag, QString terminator_tag)