aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Skoland <davidskoland@gmail.com>2017-02-14 21:00:02 +0100
committerDavid Skoland <davidskoland@gmail.com>2017-02-14 21:00:02 +0100
commit7c20ad7292066f9fbbf1906495225f78a935d251 (patch)
tree4fde509a8ecb2dd36d96a911412818bb29b431dd
parent267fe47c5fa9902d36ed97b38789081ec4b6da7a (diff)
refactored sound
-rw-r--r--aoblipplayer.cpp6
-rw-r--r--aoblipplayer.h3
-rw-r--r--aoevidencebutton.cpp5
-rw-r--r--aoevidencebutton.h6
-rw-r--r--aomusicplayer.cpp8
-rw-r--r--aomusicplayer.h3
-rw-r--r--aosfxplayer.cpp6
-rw-r--r--aosfxplayer.h3
-rw-r--r--courtroom.cpp26
-rw-r--r--courtroom.h1
-rw-r--r--emotes.cpp2
-rw-r--r--evidence.cpp9
12 files changed, 55 insertions, 23 deletions
diff --git a/aoblipplayer.cpp b/aoblipplayer.cpp
index cddb90c8..27e73a33 100644
--- a/aoblipplayer.cpp
+++ b/aoblipplayer.cpp
@@ -10,7 +10,7 @@ AOBlipPlayer::AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app)
ao_app = p_ao_app;
}
-void AOBlipPlayer::set_blips(QString p_sfx, int p_volume)
+void AOBlipPlayer::set_blips(QString p_sfx)
{
QString f_path = ao_app->get_sounds_path() + p_sfx;
@@ -21,7 +21,7 @@ void AOBlipPlayer::set_blips(QString p_sfx, int p_volume)
m_stream_list[n_stream] = BASS_StreamCreateFile(FALSE, f_path.toStdString().c_str(), 0, 0, 0);
}
- set_volume(p_volume);
+ set_volume(m_volume);
}
void AOBlipPlayer::blip_tick()
@@ -38,6 +38,8 @@ void AOBlipPlayer::blip_tick()
void AOBlipPlayer::set_volume(int p_value)
{
+ m_volume = p_value;
+
float volume = p_value / 100.0f;
for (int n_stream = 0 ; n_stream < 5 ; ++n_stream)
diff --git a/aoblipplayer.h b/aoblipplayer.h
index fdb25508..430f702f 100644
--- a/aoblipplayer.h
+++ b/aoblipplayer.h
@@ -11,7 +11,7 @@ class AOBlipPlayer
public:
AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app);
- void set_blips(QString p_sfx, int p_volume);
+ void set_blips(QString p_sfx);
void blip_tick();
void set_volume(int p_volume);
@@ -21,6 +21,7 @@ private:
QWidget *m_parent;
AOApplication *ao_app;
+ int m_volume;
HSTREAM m_stream_list[5];
};
diff --git a/aoevidencebutton.cpp b/aoevidencebutton.cpp
index f2cd1dd6..993bb4bd 100644
--- a/aoevidencebutton.cpp
+++ b/aoevidencebutton.cpp
@@ -25,3 +25,8 @@ void AOEvidenceButton::set_image(QString p_image)
this->setStyleSheet("");
}
}
+
+void AOEvidenceButton::on_clicked()
+{
+ evidence_clicked(m_id);
+}
diff --git a/aoevidencebutton.h b/aoevidencebutton.h
index 6409a170..b925fced 100644
--- a/aoevidencebutton.h
+++ b/aoevidencebutton.h
@@ -20,6 +20,12 @@ private:
AOApplication *ao_app;
int m_id;
+
+signals:
+ void evidence_clicked(int p_id);
+
+private slots:
+ void on_clicked();
};
#endif // AOEVIDENCEBUTTON_H
diff --git a/aomusicplayer.cpp b/aomusicplayer.cpp
index ca726243..4d0a0931 100644
--- a/aomusicplayer.cpp
+++ b/aomusicplayer.cpp
@@ -15,7 +15,7 @@ AOMusicPlayer::~AOMusicPlayer()
BASS_ChannelStop(m_stream);
}
-void AOMusicPlayer::play(QString p_song, int p_volume)
+void AOMusicPlayer::play(QString p_song)
{
BASS_ChannelStop(m_stream);
@@ -23,14 +23,16 @@ void AOMusicPlayer::play(QString p_song, int p_volume)
m_stream = BASS_StreamCreateFile(FALSE, f_path.toStdString().c_str(), 0, 0, BASS_STREAM_AUTOFREE);
- this->set_volume(p_volume);
+ this->set_volume(m_volume);
BASS_ChannelPlay(m_stream, false);
}
void AOMusicPlayer::set_volume(int p_value)
{
- float volume = p_value / 100.0f;
+ m_volume = p_value;
+
+ float volume = m_volume / 100.0f;
BASS_ChannelSetAttribute(m_stream, BASS_ATTRIB_VOL, volume);
diff --git a/aomusicplayer.h b/aomusicplayer.h
index c0c47210..af8452be 100644
--- a/aomusicplayer.h
+++ b/aomusicplayer.h
@@ -12,13 +12,14 @@ public:
AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app);
~AOMusicPlayer();
- void play(QString p_song, int p_volume);
+ void play(QString p_song);
void set_volume(int p_value);
private:
QWidget *m_parent;
AOApplication *ao_app;
+ int m_volume = 0;
HSTREAM m_stream;
};
diff --git a/aosfxplayer.cpp b/aosfxplayer.cpp
index 3c52b24d..c6a88293 100644
--- a/aosfxplayer.cpp
+++ b/aosfxplayer.cpp
@@ -10,7 +10,7 @@ AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app)
ao_app = p_ao_app;
}
-void AOSfxPlayer::play(QString p_sfx, int p_volume, QString p_char)
+void AOSfxPlayer::play(QString p_sfx, QString p_char)
{
BASS_ChannelStop(m_stream);
@@ -23,13 +23,15 @@ void AOSfxPlayer::play(QString p_sfx, int p_volume, QString p_char)
m_stream = BASS_StreamCreateFile(FALSE, f_path.toStdString().c_str(), 0, 0, BASS_STREAM_AUTOFREE);
- set_volume(p_volume);
+ set_volume(m_volume);
BASS_ChannelPlay(m_stream, false);
}
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);
diff --git a/aosfxplayer.h b/aosfxplayer.h
index bae11008..61280e2e 100644
--- a/aosfxplayer.h
+++ b/aosfxplayer.h
@@ -11,13 +11,14 @@ class AOSfxPlayer
public:
AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app);
- void play(QString p_sfx, int p_volume, QString p_char = "");
+ void play(QString p_sfx, QString p_char = "");
void set_volume(int p_volume);
private:
QWidget *m_parent;
AOApplication *ao_app;
+ int m_volume = 0;
HSTREAM m_stream;
};
diff --git a/courtroom.cpp b/courtroom.cpp
index 5d15d99c..9020901d 100644
--- a/courtroom.cpp
+++ b/courtroom.cpp
@@ -599,6 +599,10 @@ void Courtroom::done_received()
{
m_cid = -1;
+ music_player->set_volume(0);
+ sfx_player->set_volume(0);
+ blip_player->set_volume(0);
+
set_char_select_page();
set_mute_list();
@@ -971,20 +975,20 @@ void Courtroom::handle_chatmessage(QStringList *p_contents)
{
case 1:
ui_vp_objection->play("holdit");
- sfx_player->play("holdit.wav", ui_sfx_slider->value(), m_chatmessage[CHAR_NAME]);
+ sfx_player->play("holdit.wav", m_chatmessage[CHAR_NAME]);
break;
case 2:
ui_vp_objection->play("objection");
- sfx_player->play("objection.wav", ui_sfx_slider->value(), m_chatmessage[CHAR_NAME]);
+ sfx_player->play("objection.wav", m_chatmessage[CHAR_NAME]);
break;
case 3:
ui_vp_objection->play("takethat");
- sfx_player->play("takethat.wav", ui_sfx_slider->value(), m_chatmessage[CHAR_NAME]);
+ sfx_player->play("takethat.wav", m_chatmessage[CHAR_NAME]);
break;
//case 4 is AO2 only
case 4:
ui_vp_objection->play("custom", m_chatmessage[CHAR_NAME]);
- sfx_player->play("custom.wav", ui_sfx_slider->value(), m_chatmessage[CHAR_NAME]);
+ sfx_player->play("custom.wav", m_chatmessage[CHAR_NAME]);
break;
default:
qDebug() << "W: Logic error in objection switch statement!";
@@ -1102,7 +1106,7 @@ void Courtroom::handle_chatmessage_3()
{
realization_timer->start(60);
ui_vp_realization->show();
- sfx_player->play("sfx-realization.wav", ui_sfx_slider->value());
+ sfx_player->play("sfx-realization.wav");
}
}
@@ -1179,7 +1183,7 @@ void Courtroom::start_chat_ticking()
QString f_gender = ao_app->get_gender(m_chatmessage[CHAR_NAME]);
- blip_player->set_blips("sfx-blip" + f_gender + ".wav", ui_blip_slider->value());
+ blip_player->set_blips("sfx-blip" + f_gender + ".wav");
//means text is currently ticking
text_state = 1;
@@ -1246,7 +1250,7 @@ void Courtroom::play_sfx()
if (sfx_name == "1")
return;
- sfx_player->play(sfx_name + ".wav", ui_sfx_slider->value());
+ sfx_player->play(sfx_name + ".wav");
//T0D0: add audio implementation
//QString sfx_name = m_chatmessage[SFX_NAME];
@@ -1399,7 +1403,7 @@ void Courtroom::handle_song(QStringList *p_contents)
if (f_contents.size() < 2)
return;
- music_player->play(f_contents.at(0), ui_music_slider->value());
+ music_player->play(f_contents.at(0));
int n_char = f_contents.at(1).toInt();
@@ -1412,7 +1416,7 @@ void Courtroom::handle_wtce(QString p_wtce)
//witness testimony
if (p_wtce == "testimony1")
{
- sfx_player->play("sfx-testimony2.wav", ui_sfx_slider->value());
+ sfx_player->play("sfx-testimony2.wav");
ui_vp_wtce->play("witnesstestimony");
testimony_in_progress = true;
show_testimony();
@@ -1420,7 +1424,7 @@ void Courtroom::handle_wtce(QString p_wtce)
//cross examination
else if (p_wtce == "testimony2")
{
- sfx_player->play("sfx-testimony.wav", ui_sfx_slider->value());
+ sfx_player->play("sfx-testimony.wav");
ui_vp_wtce->play("crossexamination");
testimony_in_progress = false;
}
@@ -1447,7 +1451,7 @@ void Courtroom::mod_called(QString p_ip)
{
ui_server_chatlog->appendPlainText(p_ip);
if (ui_guard->isChecked())
- modcall_player->play("sfx-gallery.wav", 50);
+ modcall_player->play("sfx-gallery.wav");
}
void Courtroom::on_ooc_return_pressed()
diff --git a/courtroom.h b/courtroom.h
index 5755485d..dee00273 100644
--- a/courtroom.h
+++ b/courtroom.h
@@ -326,6 +326,7 @@ private slots:
void on_music_list_double_clicked(QModelIndex p_model);
void on_emote_clicked(int p_id);
+ void on_evidence_clicked(int p_id);
void on_emote_left_clicked();
void on_emote_right_clicked();
diff --git a/emotes.cpp b/emotes.cpp
index b733822d..8832a1a7 100644
--- a/emotes.cpp
+++ b/emotes.cpp
@@ -37,7 +37,7 @@ void Courtroom::construct_emotes()
++x_mod_count;
//if emote number is divisible by columns with rest columns -1 then the next emote button should start on a new line
- if ((n % emote_columns) == (emote_columns - 1) && (n != 0))
+ if (x_mod_count == emote_columns)
{
++y_mod_count;
x_mod_count = 0;
diff --git a/evidence.cpp b/evidence.cpp
index 256a1c25..59ea7d6f 100644
--- a/evidence.cpp
+++ b/evidence.cpp
@@ -34,7 +34,7 @@ void Courtroom::construct_evidence()
f_evidence->set_id(n);
- //connect(f_evidence, SIGNAL(evidence_clicked(int)), this, SLOT(on_evidence_clicked(int)));
+ connect(f_evidence, SIGNAL(evidence_clicked(int)), this, SLOT(on_evidence_clicked(int)));
++x_mod_count;
@@ -45,3 +45,10 @@ void Courtroom::construct_evidence()
}
}
}
+
+void Courtroom::on_evidence_clicked(int p_id)
+{
+
+}
+
+