Merge pull request #26 from AttorneyOnline/gbp-fixes

Remove BASS dependency
This commit is contained in:
oldmud0 2018-08-29 15:17:08 -05:00 committed by GitHub
commit f726fddb67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 43 additions and 1174 deletions

View File

@ -69,7 +69,6 @@ HEADERS += lobby.h \
misc_functions.h \
aocharmovie.h \
aoemotebutton.h \
bass.h \
aosfxplayer.h \
aomusicplayer.h \
aoblipplayer.h \
@ -81,15 +80,11 @@ HEADERS += lobby.h \
discord_rich_presence.h \
discord-rpc.h
# 1. You need to get BASS and put the x86 bass DLL/headers in the project root folder
# AND the compilation output folder. If you want a static link, you'll probably
# need the .lib file too. MinGW-GCC is really finicky finding BASS, it seems.
# 2. You need to compile the Discord Rich Presence SDK separately and add the lib/headers
# in the same way as BASS. Discord RPC uses CMake, which does not play nicely with
# QMake, so this step must be manual.
unix:LIBS += -L$$PWD -lbass -ldiscord-rpc
win32:LIBS += -L$$PWD "$$PWD/bass.dll" -ldiscord-rpc #"$$PWD/discord-rpc.dll"
android:LIBS += -L$$PWD\android\libs\armeabi-v7a\ -lbass
# You need to compile the Discord Rich Presence SDK separately and add the lib/headers.
# Discord RPC uses CMake, which does not play nicely with QMake, so this step must be manual.
unix:LIBS += -L$$PWD -ldiscord-rpc
win32:LIBS += -L$$PWD -ldiscord-rpc #"$$PWD/discord-rpc.dll"
CONFIG += c++11

View File

@ -2,44 +2,32 @@
AOBlipPlayer::AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app)
{
m_sfxplayer = new QSoundEffect;
m_parent = parent;
ao_app = p_ao_app;
}
AOBlipPlayer::~AOBlipPlayer()
{
m_sfxplayer->stop();
m_sfxplayer->deleteLater();
}
void AOBlipPlayer::set_blips(QString p_sfx)
{
m_sfxplayer->stop();
QString f_path = ao_app->get_sounds_path() + p_sfx.toLower();
for (int n_stream = 0 ; n_stream < BLIP_COUNT ; ++n_stream)
{
BASS_StreamFree(m_stream_list[n_stream]);
m_stream_list[n_stream] = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_UNICODE | BASS_ASYNCFILE);
}
m_sfxplayer->setSource(QUrl::fromLocalFile(f_path));
set_volume(m_volume);
}
void AOBlipPlayer::blip_tick()
{
int f_cycle = m_cycle++;
if (m_cycle == BLIP_COUNT)
m_cycle = 0;
HSTREAM f_stream = m_stream_list[f_cycle];
BASS_ChannelPlay(f_stream, false);
m_sfxplayer->play();
}
void AOBlipPlayer::set_volume(int p_value)
{
m_volume = p_value;
float volume = p_value / 100.0f;
for (int n_stream = 0 ; n_stream < BLIP_COUNT ; ++n_stream)
{
BASS_ChannelSetAttribute(m_stream_list[n_stream], BASS_ATTRIB_VOL, volume);
}
m_sfxplayer->setVolume(p_value / 100.0);
}

View File

@ -1,19 +1,18 @@
#ifndef AOBLIPPLAYER_H
#define AOBLIPPLAYER_H
#include "bass.h"
#include "aoapplication.h"
#include <QWidget>
#include <string.h>
#include <QDebug>
const int BLIP_COUNT = 5;
#include <QSoundEffect>
class AOBlipPlayer
{
public:
AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app);
~AOBlipPlayer();
void set_blips(QString p_sfx);
void blip_tick();
@ -24,9 +23,9 @@ public:
private:
QWidget *m_parent;
AOApplication *ao_app;
QSoundEffect *m_sfxplayer;
int m_volume;
HSTREAM m_stream_list[BLIP_COUNT];
};
#endif // AOBLIPPLAYER_H

View File

@ -4,32 +4,24 @@ AOMusicPlayer::AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app)
{
m_parent = parent;
ao_app = p_ao_app;
m_player = new QMediaPlayer;
}
AOMusicPlayer::~AOMusicPlayer()
{
BASS_ChannelStop(m_stream);
m_player->stop();
m_player->deleteLater();
}
void AOMusicPlayer::play(QString p_song)
{
BASS_ChannelStop(m_stream);
QString f_path = ao_app->get_music_path(p_song);
m_stream = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_STREAM_AUTOFREE | BASS_UNICODE | BASS_ASYNCFILE);
m_player->setMedia(QUrl::fromLocalFile(ao_app->get_music_path(p_song)));
this->set_volume(m_volume);
BASS_ChannelPlay(m_stream, false);
m_player->play();
}
void AOMusicPlayer::set_volume(int p_value)
{
m_volume = p_value;
float volume = m_volume / 100.0f;
BASS_ChannelSetAttribute(m_stream, BASS_ATTRIB_VOL, volume);
m_player->setVolume(p_value);
}

View File

@ -1,12 +1,12 @@
#ifndef AOMUSICPLAYER_H
#define AOMUSICPLAYER_H
#include "bass.h"
#include "aoapplication.h"
#include <QWidget>
#include <string.h>
#include <QDebug>
#include <QMediaPlayer>
class AOMusicPlayer
{
@ -21,8 +21,8 @@ private:
QWidget *m_parent;
AOApplication *ao_app;
QMediaPlayer *m_player;
int m_volume = 0;
HSTREAM m_stream;
};
#endif // AOMUSICPLAYER_H

View File

@ -2,41 +2,40 @@
AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app)
{
m_sfxplayer = new QSoundEffect;
m_parent = parent;
ao_app = p_ao_app;
}
AOSfxPlayer::~AOSfxPlayer()
{
m_sfxplayer->stop();
m_sfxplayer->deleteLater();
}
void AOSfxPlayer::play(QString p_sfx, QString p_char)
{
BASS_ChannelStop(m_stream);
m_sfxplayer->stop();
p_sfx = p_sfx.toLower();
QString f_path;
if (p_char != "")
f_path = ao_app->get_character_path(p_char) + p_sfx;
else
f_path = ao_app->get_sounds_path() + p_sfx;
m_stream = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_STREAM_AUTOFREE | BASS_UNICODE | BASS_ASYNCFILE);
m_sfxplayer->setSource(QUrl::fromLocalFile(f_path));
set_volume(m_volume);
BASS_ChannelPlay(m_stream, false);
m_sfxplayer->play();
}
void AOSfxPlayer::stop()
{
BASS_ChannelStop(m_stream);
m_sfxplayer->stop();
}
void AOSfxPlayer::set_volume(int p_value)
{
m_volume = p_value;
float volume = p_value / 100.0f;
BASS_ChannelSetAttribute(m_stream, BASS_ATTRIB_VOL, volume);
m_sfxplayer->setVolume(p_value / 100.0);
}

View File

@ -1,17 +1,18 @@
#ifndef AOSFXPLAYER_H
#define AOSFXPLAYER_H
#include "bass.h"
#include "aoapplication.h"
#include <QWidget>
#include <string.h>
#include <QDebug>
#include <QSoundEffect>
class AOSfxPlayer
{
public:
AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app);
~AOSfxPlayer();
void play(QString p_sfx, QString p_char = "");
void stop();
@ -20,9 +21,9 @@ public:
private:
QWidget *m_parent;
AOApplication *ao_app;
QSoundEffect *m_sfxplayer;
int m_volume = 0;
HSTREAM m_stream;
};
#endif // AOSFXPLAYER_H

1051
bass.h

File diff suppressed because it is too large Load Diff

View File

@ -4,10 +4,6 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
{
ao_app = p_ao_app;
//initializing sound device
BASS_Init(-1, 48000, BASS_DEVICE_LATENCY, 0, NULL);
BASS_PluginLoad("bassopus.dll", BASS_UNICODE);
keepalive_timer = new QTimer(this);
keepalive_timer->start(60000);

View File

@ -1,56 +1,7 @@
//WELCOME TO THE EXTREMELY GHETTO HEX CONVERSION KLUDGE BECAUSE I COULDNT MAKE ANYTHING ELSE WORK
#include "hex_functions.h"
namespace omni
{
// This might be unused but I don't care to search the entire source code
// So it will remain here (lol)
// The actual int to hex conversion is now done properly
char halfword_to_hex_char(unsigned int input)
{
if (input > 127)
return 'F';
switch (input)
{
case 0:
return '0';
case 1:
return '1';
case 2:
return '2';
case 3:
return '3';
case 4:
return '4';
case 5:
return '5';
case 6:
return '6';
case 7:
return '7';
case 8:
return '8';
case 9:
return '9';
case 10:
return 'A';
case 11:
return 'B';
case 12:
return 'C';
case 13:
return 'D';
case 14:
return 'E';
case 15:
return 'F';
default:
return 'F';
}
}
std::string int_to_hex(unsigned int input)
{
if (input > 255)
@ -64,4 +15,4 @@ namespace omni
return result;
}
} //namespace omni
}

View File

@ -11,7 +11,6 @@
namespace omni
{
char halfword_to_hex_char(unsigned int input);
std::string int_to_hex(unsigned int input);
}