added audio implementation and refactored text file functions
This commit is contained in:
parent
a97f223390
commit
c540c1094e
@ -39,7 +39,8 @@ SOURCES += main.cpp\
|
|||||||
aoemotebutton.cpp \
|
aoemotebutton.cpp \
|
||||||
emotes.cpp \
|
emotes.cpp \
|
||||||
aosfxplayer.cpp \
|
aosfxplayer.cpp \
|
||||||
aomusicplayer.cpp
|
aomusicplayer.cpp \
|
||||||
|
aoblipplayer.cpp
|
||||||
|
|
||||||
HEADERS += lobby.h \
|
HEADERS += lobby.h \
|
||||||
aoimage.h \
|
aoimage.h \
|
||||||
@ -62,6 +63,7 @@ HEADERS += lobby.h \
|
|||||||
aoemotebutton.h \
|
aoemotebutton.h \
|
||||||
bass.h \
|
bass.h \
|
||||||
aosfxplayer.h \
|
aosfxplayer.h \
|
||||||
aomusicplayer.h
|
aomusicplayer.h \
|
||||||
|
aoblipplayer.h
|
||||||
|
|
||||||
unix:LIBS += -L/home/omnitroid/Project/Attorney_Online_2/src -lbass
|
unix:LIBS += -L/home/omnitroid/Project/Attorney_Online_2/src -lbass
|
||||||
|
@ -98,6 +98,7 @@ public:
|
|||||||
void write_to_serverlist_txt(QString p_line);
|
void write_to_serverlist_txt(QString p_line);
|
||||||
QVector<server_type> read_serverlist_txt();
|
QVector<server_type> read_serverlist_txt();
|
||||||
pos_size_type get_pos_and_size(QString p_identifier, QString p_design_path);
|
pos_size_type get_pos_and_size(QString p_identifier, QString p_design_path);
|
||||||
|
QString read_char_ini(QString p_char, QString p_search_line, QString target_tag, QString terminator_tag);
|
||||||
QString get_char_side(QString p_char);
|
QString get_char_side(QString p_char);
|
||||||
QString get_showname(QString p_char);
|
QString get_showname(QString p_char);
|
||||||
QString get_chat(QString p_char);
|
QString get_chat(QString p_char);
|
||||||
@ -110,6 +111,7 @@ public:
|
|||||||
QString get_sfx_name(QString p_char, int p_emote);
|
QString get_sfx_name(QString p_char, int p_emote);
|
||||||
int get_sfx_delay(QString p_char, int p_emote);
|
int get_sfx_delay(QString p_char, int p_emote);
|
||||||
int get_emote_mod(QString p_char, int p_emote);
|
int get_emote_mod(QString p_char, int p_emote);
|
||||||
|
QString get_gender(QString p_char);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const int RELEASE = 2;
|
const int RELEASE = 2;
|
||||||
|
47
aoblipplayer.cpp
Normal file
47
aoblipplayer.cpp
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#include "aoblipplayer.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
AOBlipPlayer::AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app)
|
||||||
|
{
|
||||||
|
m_parent = parent;
|
||||||
|
ao_app = p_ao_app;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AOBlipPlayer::set_blips(QString p_sfx, int p_volume)
|
||||||
|
{
|
||||||
|
QString f_path = ao_app->get_sounds_path() + p_sfx;
|
||||||
|
|
||||||
|
for (int n_stream = 0 ; n_stream < 5 ; ++n_stream)
|
||||||
|
{
|
||||||
|
BASS_StreamFree(m_stream_list[n_stream]);
|
||||||
|
|
||||||
|
m_stream_list[n_stream] = BASS_StreamCreateFile(FALSE, f_path.toStdString().c_str(), 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
set_volume(p_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];
|
||||||
|
|
||||||
|
BASS_ChannelPlay(f_stream, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AOBlipPlayer::set_volume(int p_value)
|
||||||
|
{
|
||||||
|
float volume = p_value / 100.0f;
|
||||||
|
|
||||||
|
for (int n_stream = 0 ; n_stream < 5 ; ++n_stream)
|
||||||
|
{
|
||||||
|
BASS_ChannelSetAttribute(m_stream_list[n_stream], BASS_ATTRIB_VOL, volume);
|
||||||
|
}
|
||||||
|
}
|
27
aoblipplayer.h
Normal file
27
aoblipplayer.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#ifndef AOBLIPPLAYER_H
|
||||||
|
#define AOBLIPPLAYER_H
|
||||||
|
|
||||||
|
#include "bass.h"
|
||||||
|
#include "aoapplication.h"
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
class AOBlipPlayer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app);
|
||||||
|
|
||||||
|
void set_blips(QString p_sfx, int p_volume);
|
||||||
|
void blip_tick();
|
||||||
|
void set_volume(int p_volume);
|
||||||
|
|
||||||
|
int m_cycle = 0;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QWidget *m_parent;
|
||||||
|
AOApplication *ao_app;
|
||||||
|
|
||||||
|
HSTREAM m_stream_list[5];
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // AOBLIPPLAYER_H
|
@ -8,45 +8,30 @@ AOMusicPlayer::AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app)
|
|||||||
{
|
{
|
||||||
m_parent = parent;
|
m_parent = parent;
|
||||||
ao_app = p_ao_app;
|
ao_app = p_ao_app;
|
||||||
|
|
||||||
|
|
||||||
BASS_Init(-1, 44100, BASS_DEVICE_LATENCY, 0, NULL);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOMusicPlayer::play(QString p_song)
|
AOMusicPlayer::~AOMusicPlayer()
|
||||||
{
|
{
|
||||||
|
BASS_ChannelStop(m_stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AOMusicPlayer::play(QString p_song, int p_volume)
|
||||||
|
{
|
||||||
BASS_ChannelStop(m_stream);
|
BASS_ChannelStop(m_stream);
|
||||||
|
|
||||||
QString f_path = ao_app->get_music_path(p_song);
|
QString f_path = ao_app->get_music_path(p_song);
|
||||||
|
|
||||||
m_stream = BASS_StreamCreateFile(FALSE, f_path.toStdString().c_str(), 0, 0, BASS_STREAM_PRESCAN);
|
m_stream = BASS_StreamCreateFile(FALSE, f_path.toStdString().c_str(), 0, 0, BASS_STREAM_AUTOFREE);
|
||||||
|
|
||||||
/*
|
this->set_volume(p_volume);
|
||||||
if ((BASS_StreamPutFileData(
|
|
||||||
m_stream,
|
BASS_ChannelPlay(m_stream, false);
|
||||||
p_path.toStdString().c_str(),
|
}
|
||||||
BASS_FILEDATA_END
|
|
||||||
) == -1))
|
void AOMusicPlayer::set_volume(int p_value)
|
||||||
{
|
{
|
||||||
qDebug() << "BASS_StreamPutFileData failllled!";
|
float volume = p_value / 100.0f;
|
||||||
qDebug() << "Error: " << QString::number(BASS_ErrorGetCode());
|
|
||||||
}
|
BASS_ChannelSetAttribute(m_stream, BASS_ATTRIB_VOL, volume);
|
||||||
|
|
||||||
if (m_stream == 0)
|
|
||||||
{
|
|
||||||
qDebug() << "OHSHIT something broke. error code: " << QString::number(BASS_ErrorGetCode());
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
//m_stream = BASS_StreamCreateFileUser(STREAMFILE_BUFFERPUSH, BASS_STREAM_AUTOFREE, nullptr, p_path.toStdString().c_str());
|
|
||||||
|
|
||||||
if (BASS_ChannelPlay(m_stream, true))
|
|
||||||
qDebug() <<"success.";
|
|
||||||
else
|
|
||||||
qDebug() <<"error";
|
|
||||||
|
|
||||||
qDebug() << QString::number(BASS_ErrorGetCode());
|
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,10 @@ class AOMusicPlayer
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app);
|
AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app);
|
||||||
|
~AOMusicPlayer();
|
||||||
|
|
||||||
void play(QString p_song);
|
void play(QString p_song, int p_volume);
|
||||||
|
void set_volume(int p_value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget *m_parent;
|
QWidget *m_parent;
|
||||||
|
@ -8,45 +8,27 @@ AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app)
|
|||||||
{
|
{
|
||||||
m_parent = parent;
|
m_parent = parent;
|
||||||
ao_app = p_ao_app;
|
ao_app = p_ao_app;
|
||||||
|
|
||||||
|
|
||||||
BASS_Init(-1, 44100, BASS_DEVICE_LATENCY, 0, NULL);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOSfxPlayer::play(QString p_path)
|
void AOSfxPlayer::play(QString p_sfx, int p_volume)
|
||||||
{
|
{
|
||||||
|
BASS_ChannelStop(m_stream);
|
||||||
|
|
||||||
BASS_Stop();
|
QString f_path = ao_app->get_sounds_path() + p_sfx;
|
||||||
|
|
||||||
m_stream = BASS_StreamCreateFile(FALSE, p_path.toStdString().c_str(), 0, 0, BASS_STREAM_PRESCAN);
|
qDebug() << "sfx path: " << f_path;
|
||||||
|
|
||||||
/*
|
m_stream = BASS_StreamCreateFile(FALSE, f_path.toStdString().c_str(), 0, 0, BASS_STREAM_AUTOFREE);
|
||||||
if ((BASS_StreamPutFileData(
|
|
||||||
m_stream,
|
|
||||||
p_path.toStdString().c_str(),
|
|
||||||
BASS_FILEDATA_END
|
|
||||||
) == -1))
|
|
||||||
{
|
|
||||||
qDebug() << "BASS_StreamPutFileData failllled!";
|
|
||||||
qDebug() << "Error: " << QString::number(BASS_ErrorGetCode());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_stream == 0)
|
set_volume(p_volume);
|
||||||
{
|
|
||||||
qDebug() << "OHSHIT something broke. error code: " << QString::number(BASS_ErrorGetCode());
|
BASS_ChannelPlay(m_stream, false);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
void AOSfxPlayer::set_volume(int p_value)
|
||||||
|
{
|
||||||
|
float volume = p_value / 100.0f;
|
||||||
|
|
||||||
|
BASS_ChannelSetAttribute(m_stream, BASS_ATTRIB_VOL, volume);
|
||||||
|
|
||||||
//m_stream = BASS_StreamCreateFileUser(STREAMFILE_BUFFERPUSH, BASS_STREAM_AUTOFREE, nullptr, p_path.toStdString().c_str());
|
|
||||||
|
|
||||||
if (BASS_ChannelPlay(m_stream, true))
|
|
||||||
qDebug() <<"success.";
|
|
||||||
else
|
|
||||||
qDebug() <<"error";
|
|
||||||
|
|
||||||
BASS_Start();
|
|
||||||
|
|
||||||
qDebug() << QString::number(BASS_ErrorGetCode());
|
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,8 @@ class AOSfxPlayer
|
|||||||
public:
|
public:
|
||||||
AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app);
|
AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app);
|
||||||
|
|
||||||
void play(QString p_path);
|
void play(QString p_sfx, int p_volume);
|
||||||
|
void set_volume(int p_volume);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget *m_parent;
|
QWidget *m_parent;
|
||||||
|
@ -14,6 +14,9 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
|
|||||||
{
|
{
|
||||||
ao_app = p_ao_app;
|
ao_app = p_ao_app;
|
||||||
|
|
||||||
|
//initializing sound device
|
||||||
|
BASS_Init(-1, 44100, BASS_DEVICE_LATENCY, 0, NULL);
|
||||||
|
|
||||||
keepalive_timer = new QTimer(this);
|
keepalive_timer = new QTimer(this);
|
||||||
keepalive_timer->start(60000);
|
keepalive_timer->start(60000);
|
||||||
|
|
||||||
@ -30,8 +33,9 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
|
|||||||
|
|
||||||
char_button_mapper = new QSignalMapper(this);
|
char_button_mapper = new QSignalMapper(this);
|
||||||
|
|
||||||
sfx_player = new QSoundEffect(this);
|
|
||||||
music_player = new AOMusicPlayer(this, ao_app);
|
music_player = new AOMusicPlayer(this, ao_app);
|
||||||
|
sfx_player = new AOSfxPlayer(this, ao_app);
|
||||||
|
blip_player = new AOBlipPlayer(this, ao_app);
|
||||||
|
|
||||||
ui_background = new AOImage(this, ao_app);
|
ui_background = new AOImage(this, ao_app);
|
||||||
|
|
||||||
@ -232,6 +236,10 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
|
|||||||
|
|
||||||
connect(ui_text_color, SIGNAL(currentIndexChanged(int)), this, SLOT(on_text_color_changed(int)));
|
connect(ui_text_color, SIGNAL(currentIndexChanged(int)), this, SLOT(on_text_color_changed(int)));
|
||||||
|
|
||||||
|
connect(ui_music_slider, SIGNAL(valueChanged(int)), this, SLOT(on_music_slider_moved(int)));
|
||||||
|
connect(ui_sfx_slider, SIGNAL(valueChanged(int)), this, SLOT(on_sfx_slider_moved(int)));
|
||||||
|
connect(ui_blip_slider, SIGNAL(valueChanged(int)), this, SLOT(on_blip_slider_moved(int)));
|
||||||
|
|
||||||
connect(ui_ooc_toggle, SIGNAL(clicked()), this, SLOT(on_ooc_toggle_clicked()));
|
connect(ui_ooc_toggle, SIGNAL(clicked()), this, SLOT(on_ooc_toggle_clicked()));
|
||||||
|
|
||||||
connect(ui_music_search, SIGNAL(textChanged(QString)), this, SLOT(on_music_search_edited(QString)));
|
connect(ui_music_search, SIGNAL(textChanged(QString)), this, SLOT(on_music_search_edited(QString)));
|
||||||
@ -246,6 +254,8 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
|
|||||||
connect(ui_reload_theme, SIGNAL(clicked()), this, SLOT(on_reload_theme_clicked()));
|
connect(ui_reload_theme, SIGNAL(clicked()), this, SLOT(on_reload_theme_clicked()));
|
||||||
connect(ui_call_mod, SIGNAL(clicked()), this, SLOT(on_call_mod_clicked()));
|
connect(ui_call_mod, SIGNAL(clicked()), this, SLOT(on_call_mod_clicked()));
|
||||||
|
|
||||||
|
connect(ui_pre, SIGNAL(clicked()), this, SLOT(on_pre_clicked()));
|
||||||
|
|
||||||
connect(ui_back_to_lobby, SIGNAL(clicked()), this, SLOT(on_back_to_lobby_clicked()));
|
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()));
|
connect(ui_char_select_left, SIGNAL(clicked()), this, SLOT(on_char_select_left_clicked()));
|
||||||
@ -832,9 +842,6 @@ void Courtroom::handle_chatmessage(QStringList *p_contents)
|
|||||||
|
|
||||||
QString f_showname = ao_app->get_showname(m_chatmessage[CHAR_NAME]);
|
QString f_showname = ao_app->get_showname(m_chatmessage[CHAR_NAME]);
|
||||||
|
|
||||||
if (f_showname == "")
|
|
||||||
f_showname = m_chatmessage[CHAR_NAME];
|
|
||||||
|
|
||||||
QString f_message = f_showname + ": " + m_chatmessage[MESSAGE] + '\n';
|
QString f_message = f_showname + ": " + m_chatmessage[MESSAGE] + '\n';
|
||||||
|
|
||||||
if (f_message == previous_ic_message)
|
if (f_message == previous_ic_message)
|
||||||
@ -862,8 +869,6 @@ void Courtroom::handle_chatmessage(QStringList *p_contents)
|
|||||||
|
|
||||||
previous_ic_message = f_message;
|
previous_ic_message = f_message;
|
||||||
|
|
||||||
qDebug() << "objection_mod of received message: " << m_chatmessage[OBJECTION_MOD];
|
|
||||||
|
|
||||||
int objection_mod = m_chatmessage[OBJECTION_MOD].toInt();
|
int objection_mod = m_chatmessage[OBJECTION_MOD].toInt();
|
||||||
|
|
||||||
//if an objection is used
|
//if an objection is used
|
||||||
@ -915,14 +920,9 @@ void Courtroom::handle_chatmessage_2()
|
|||||||
ui_vp_speedlines->stop();
|
ui_vp_speedlines->stop();
|
||||||
ui_vp_player_char->stop();
|
ui_vp_player_char->stop();
|
||||||
|
|
||||||
QString remote_name = m_chatmessage[CHAR_NAME];
|
QString f_showname = ao_app->get_showname(m_chatmessage[CHAR_NAME]);
|
||||||
QString local_showname = ao_app->get_showname(remote_name);
|
|
||||||
|
|
||||||
//empty string means we couldnt find showname in char ini
|
ui_vp_showname->setText(f_showname);
|
||||||
if (local_showname == "")
|
|
||||||
ui_vp_showname->setText(remote_name);
|
|
||||||
else
|
|
||||||
ui_vp_showname->setText(local_showname);
|
|
||||||
|
|
||||||
ui_vp_message->clear();
|
ui_vp_message->clear();
|
||||||
ui_vp_chatbox->hide();
|
ui_vp_chatbox->hide();
|
||||||
@ -1088,6 +1088,10 @@ void Courtroom::start_chat_ticking()
|
|||||||
tick_pos = 0;
|
tick_pos = 0;
|
||||||
chat_tick_timer->start(chat_tick_interval);
|
chat_tick_timer->start(chat_tick_interval);
|
||||||
|
|
||||||
|
QString f_gender = ao_app->get_gender(m_chatmessage[CHAR_NAME]);
|
||||||
|
|
||||||
|
blip_player->set_blips("sfx-blip" + f_gender + ".wav", ui_blip_slider->value());
|
||||||
|
|
||||||
//means text is currently ticking
|
//means text is currently ticking
|
||||||
text_state = 1;
|
text_state = 1;
|
||||||
}
|
}
|
||||||
@ -1119,12 +1123,22 @@ void Courtroom::chat_tick()
|
|||||||
scroll->setValue(scroll->maximum());
|
scroll->setValue(scroll->maximum());
|
||||||
scroll->hide();
|
scroll->hide();
|
||||||
|
|
||||||
|
if (f_message.at(tick_pos) != ' ')
|
||||||
|
blip_player->blip_tick();
|
||||||
|
|
||||||
++tick_pos;
|
++tick_pos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Courtroom::play_sfx()
|
void Courtroom::play_sfx()
|
||||||
{
|
{
|
||||||
|
QString sfx_name = m_chatmessage[SFX_NAME];
|
||||||
|
|
||||||
|
if (sfx_name == "1")
|
||||||
|
return;
|
||||||
|
|
||||||
|
sfx_player->play(sfx_name + ".wav", ui_sfx_slider->value());
|
||||||
|
|
||||||
//T0D0: add audio implementation
|
//T0D0: add audio implementation
|
||||||
//QString sfx_name = m_chatmessage[SFX_NAME];
|
//QString sfx_name = m_chatmessage[SFX_NAME];
|
||||||
}
|
}
|
||||||
@ -1272,7 +1286,7 @@ void Courtroom::handle_song(QStringList *p_contents)
|
|||||||
if (f_contents.size() < 2)
|
if (f_contents.size() < 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
music_player->play(f_contents.at(0));
|
music_player->play(f_contents.at(0), ui_music_slider->value());
|
||||||
|
|
||||||
int n_char = f_contents.at(1).toInt();
|
int n_char = f_contents.at(1).toInt();
|
||||||
|
|
||||||
@ -1285,25 +1299,13 @@ void Courtroom::handle_wtce(QString p_wtce)
|
|||||||
//witness testimony
|
//witness testimony
|
||||||
if (p_wtce == "testimony1")
|
if (p_wtce == "testimony1")
|
||||||
{
|
{
|
||||||
QString wt_path = ao_app->get_sounds_path() + "sfx-testimony2.wav";
|
sfx_player->play("sfx-testimony2.wav", ui_sfx_slider->value());
|
||||||
QUrl wt_sfx(QUrl::fromLocalFile(wt_path));
|
|
||||||
|
|
||||||
sfx_player->stop();
|
|
||||||
sfx_player->setSource(wt_sfx);
|
|
||||||
|
|
||||||
sfx_player->play();
|
|
||||||
ui_vp_wtce->play("witnesstestimony");
|
ui_vp_wtce->play("witnesstestimony");
|
||||||
}
|
}
|
||||||
//cross examination
|
//cross examination
|
||||||
else if (p_wtce == "testimony2")
|
else if (p_wtce == "testimony2")
|
||||||
{
|
{
|
||||||
QString ce_path = ao_app->get_sounds_path() + "sfx-testimony.wav";
|
sfx_player->play("sfx-testimony.wav", ui_sfx_slider->value());
|
||||||
QUrl ce_sfx(QUrl::fromLocalFile(ce_path));
|
|
||||||
|
|
||||||
sfx_player->stop();
|
|
||||||
sfx_player->setSource(ce_sfx);
|
|
||||||
|
|
||||||
sfx_player->play();
|
|
||||||
ui_vp_wtce->play("crossexamination");
|
ui_vp_wtce->play("crossexamination");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1535,6 +1537,21 @@ void Courtroom::on_text_color_changed(int p_color)
|
|||||||
ui_ic_chat_message->setFocus();
|
ui_ic_chat_message->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Courtroom::on_music_slider_moved(int p_value)
|
||||||
|
{
|
||||||
|
music_player->set_volume(p_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Courtroom::on_sfx_slider_moved(int p_value)
|
||||||
|
{
|
||||||
|
sfx_player->set_volume(p_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Courtroom::on_blip_slider_moved(int p_value)
|
||||||
|
{
|
||||||
|
blip_player->set_volume(p_value);
|
||||||
|
}
|
||||||
|
|
||||||
void Courtroom::on_witness_testimony_clicked()
|
void Courtroom::on_witness_testimony_clicked()
|
||||||
{
|
{
|
||||||
if (is_muted)
|
if (is_muted)
|
||||||
@ -1610,6 +1627,11 @@ void Courtroom::on_call_mod_clicked()
|
|||||||
ui_ic_chat_message->setFocus();
|
ui_ic_chat_message->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Courtroom::on_pre_clicked()
|
||||||
|
{
|
||||||
|
ui_ic_chat_message->setFocus();
|
||||||
|
}
|
||||||
|
|
||||||
void Courtroom::char_clicked(int n_char)
|
void Courtroom::char_clicked(int n_char)
|
||||||
{
|
{
|
||||||
int n_real_char = n_char + current_char_page * 90;
|
int n_real_char = n_char + current_char_page * 90;
|
||||||
@ -1636,5 +1658,6 @@ void Courtroom::ping_server()
|
|||||||
|
|
||||||
Courtroom::~Courtroom()
|
Courtroom::~Courtroom()
|
||||||
{
|
{
|
||||||
|
delete music_player;
|
||||||
|
delete sfx_player;
|
||||||
}
|
}
|
||||||
|
11
courtroom.h
11
courtroom.h
@ -10,6 +10,8 @@
|
|||||||
#include "aomovie.h"
|
#include "aomovie.h"
|
||||||
#include "aocharmovie.h"
|
#include "aocharmovie.h"
|
||||||
#include "aomusicplayer.h"
|
#include "aomusicplayer.h"
|
||||||
|
#include "aosfxplayer.h"
|
||||||
|
#include "aoblipplayer.h"
|
||||||
#include "datatypes.h"
|
#include "datatypes.h"
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
@ -160,8 +162,9 @@ private:
|
|||||||
|
|
||||||
QString current_background = "gs4";
|
QString current_background = "gs4";
|
||||||
|
|
||||||
QSoundEffect *sfx_player;
|
|
||||||
AOMusicPlayer *music_player;
|
AOMusicPlayer *music_player;
|
||||||
|
AOSfxPlayer *sfx_player;
|
||||||
|
AOBlipPlayer *blip_player;
|
||||||
|
|
||||||
AOImage *ui_background;
|
AOImage *ui_background;
|
||||||
|
|
||||||
@ -302,6 +305,10 @@ private slots:
|
|||||||
|
|
||||||
void on_text_color_changed(int p_color);
|
void on_text_color_changed(int p_color);
|
||||||
|
|
||||||
|
void on_music_slider_moved(int p_value);
|
||||||
|
void on_sfx_slider_moved(int p_value);
|
||||||
|
void on_blip_slider_moved(int p_value);
|
||||||
|
|
||||||
void on_ooc_toggle_clicked();
|
void on_ooc_toggle_clicked();
|
||||||
|
|
||||||
void on_witness_testimony_clicked();
|
void on_witness_testimony_clicked();
|
||||||
@ -311,6 +318,8 @@ private slots:
|
|||||||
void on_reload_theme_clicked();
|
void on_reload_theme_clicked();
|
||||||
void on_call_mod_clicked();
|
void on_call_mod_clicked();
|
||||||
|
|
||||||
|
void on_pre_clicked();
|
||||||
|
|
||||||
void on_back_to_lobby_clicked();
|
void on_back_to_lobby_clicked();
|
||||||
|
|
||||||
void on_char_select_left_clicked();
|
void on_char_select_left_clicked();
|
||||||
|
11
lobby.cpp
11
lobby.cpp
@ -206,22 +206,13 @@ void Lobby::on_add_to_fav_pressed()
|
|||||||
|
|
||||||
void Lobby::on_add_to_fav_released()
|
void Lobby::on_add_to_fav_released()
|
||||||
{
|
{
|
||||||
AOSfxPlayer *sfx = new AOSfxPlayer(this, ao_app);
|
|
||||||
|
|
||||||
QString path = ao_app->get_music_path("Mystery Skulls - Money.mp3");
|
|
||||||
|
|
||||||
qDebug() << "path: " << path;
|
|
||||||
|
|
||||||
sfx->play(path);
|
|
||||||
|
|
||||||
ui_add_to_fav->set_image("addtofav.png");
|
ui_add_to_fav->set_image("addtofav.png");
|
||||||
/*
|
|
||||||
//you cant add favorites from favorites m8
|
//you cant add favorites from favorites m8
|
||||||
if (!public_servers_selected)
|
if (!public_servers_selected)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ao_app->add_favorite_server(ui_server_list->currentRow());
|
ao_app->add_favorite_server(ui_server_list->currentRow());
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lobby::on_connect_pressed()
|
void Lobby::on_connect_pressed()
|
||||||
|
@ -10,21 +10,3 @@ void delay(int p_milliseconds)
|
|||||||
while(QTime::currentTime() < dieTime)
|
while(QTime::currentTime() < dieTime)
|
||||||
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
|
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
//alternates between true and false every time it is called. useful for certain optimization
|
|
||||||
bool cyclic_function()
|
|
||||||
{
|
|
||||||
static bool cycle = true;
|
|
||||||
|
|
||||||
if (cycle)
|
|
||||||
{
|
|
||||||
cycle = false;
|
|
||||||
return cycle;
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cycle = true;
|
|
||||||
return cycle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -2,6 +2,5 @@
|
|||||||
#define MISC_FUNCTIONS_H
|
#define MISC_FUNCTIONS_H
|
||||||
|
|
||||||
void delay(int p_milliseconds);
|
void delay(int p_milliseconds);
|
||||||
bool cyclic_function();
|
|
||||||
|
|
||||||
#endif // MISC_FUNCTIONS_H
|
#endif // MISC_FUNCTIONS_H
|
||||||
|
@ -139,7 +139,9 @@ pos_size_type AOApplication::get_pos_and_size(QString p_identifier, QString p_de
|
|||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AOApplication::get_char_side(QString p_char)
|
//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
|
||||||
|
QString AOApplication::read_char_ini(QString p_char, QString p_search_line, QString target_tag, QString terminator_tag)
|
||||||
{
|
{
|
||||||
QString char_ini_path = get_character_path(p_char) + "char.ini";
|
QString char_ini_path = get_character_path(p_char) + "char.ini";
|
||||||
|
|
||||||
@ -148,419 +150,186 @@ QString AOApplication::get_char_side(QString p_char)
|
|||||||
char_ini.setFileName(char_ini_path);
|
char_ini.setFileName(char_ini_path);
|
||||||
|
|
||||||
if (!char_ini.open(QIODevice::ReadOnly))
|
if (!char_ini.open(QIODevice::ReadOnly))
|
||||||
{
|
|
||||||
//default to wit and don't make a big deal about it
|
|
||||||
return "wit";
|
|
||||||
}
|
|
||||||
|
|
||||||
QTextStream in(&char_ini);
|
|
||||||
|
|
||||||
while(!in.atEnd())
|
|
||||||
{
|
|
||||||
QString line = in.readLine();
|
|
||||||
|
|
||||||
if (!line.startsWith("side"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
QStringList line_elements = line.split("=");
|
|
||||||
|
|
||||||
if (line_elements.size() < 2)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
//note that we do not validate if this is a valid side or not. that's up to the caller
|
|
||||||
return line_elements.at(1).trimmed().toLower();
|
|
||||||
}
|
|
||||||
|
|
||||||
return "wit";
|
|
||||||
}
|
|
||||||
|
|
||||||
QString AOApplication::get_showname(QString p_char)
|
|
||||||
{
|
|
||||||
QString char_ini_path = get_character_path(p_char) + "char.ini";
|
|
||||||
|
|
||||||
QFile char_ini;
|
|
||||||
|
|
||||||
char_ini.setFileName(char_ini_path);
|
|
||||||
|
|
||||||
if (!char_ini.open(QIODevice::ReadOnly))
|
|
||||||
{
|
|
||||||
//default to empty string
|
|
||||||
return "";
|
return "";
|
||||||
}
|
|
||||||
|
|
||||||
QTextStream in(&char_ini);
|
QTextStream in(&char_ini);
|
||||||
|
|
||||||
|
//because there are char inis that look like [eMoTIonS] for whatever reason
|
||||||
|
target_tag = target_tag.toLower();
|
||||||
|
terminator_tag = terminator_tag.toLower();
|
||||||
|
bool tag_found = false;
|
||||||
|
|
||||||
while(!in.atEnd())
|
while(!in.atEnd())
|
||||||
{
|
{
|
||||||
QString line = in.readLine();
|
QString line = in.readLine();
|
||||||
|
|
||||||
if (!line.startsWith("showname"))
|
if (line.toLower().startsWith(terminator_tag))
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (line.toLower().startsWith(target_tag))
|
||||||
|
{
|
||||||
|
tag_found = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!line.startsWith(p_search_line))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QStringList line_elements = line.split("=");
|
QStringList line_elements = line.split("=");
|
||||||
|
|
||||||
|
if (line_elements.at(0).trimmed() != p_search_line)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (line_elements.size() < 2)
|
if (line_elements.size() < 2)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
return line_elements.at(1).trimmed();
|
if (tag_found)
|
||||||
|
{
|
||||||
|
char_ini.close();
|
||||||
|
return line_elements.at(1).trimmed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char_ini.close();
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AOApplication::get_chat(QString p_char)
|
|
||||||
{
|
|
||||||
QString char_ini_path = get_character_path(p_char) + "char.ini";
|
|
||||||
|
|
||||||
QFile char_ini;
|
|
||||||
|
|
||||||
char_ini.setFileName(char_ini_path);
|
|
||||||
|
|
||||||
if (!char_ini.open(QIODevice::ReadOnly))
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
QTextStream in(&char_ini);
|
|
||||||
|
|
||||||
while(!in.atEnd())
|
|
||||||
{
|
|
||||||
QString line = in.readLine();
|
|
||||||
|
|
||||||
if (!line.startsWith("chat"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
QStringList line_elements = line.split("=");
|
|
||||||
|
|
||||||
if (line_elements.size() < 2)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
return line_elements.at(1).trimmed().toLower() + ".png";
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
int AOApplication::get_preanim_duration(QString p_char, QString p_emote)
|
|
||||||
{
|
|
||||||
QString char_ini_path = get_character_path(p_char) + "char.ini";
|
|
||||||
|
|
||||||
QFile char_ini;
|
|
||||||
|
|
||||||
char_ini.setFileName(char_ini_path);
|
|
||||||
|
|
||||||
if (!char_ini.open(QIODevice::ReadOnly))
|
|
||||||
{
|
|
||||||
//means preanim will finish instantly(i.e. not play)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
QTextStream in(&char_ini);
|
|
||||||
|
|
||||||
while(!in.atEnd())
|
|
||||||
{
|
|
||||||
QString line = in.readLine();
|
|
||||||
|
|
||||||
if (!line.startsWith(p_emote))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
QStringList line_elements = line.split("=");
|
|
||||||
|
|
||||||
if (line_elements.size() < 2)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
return line_elements.at(1).trimmed().toInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int AOApplication::get_text_delay(QString p_char, QString p_emote)
|
|
||||||
{
|
|
||||||
//T0D0: make a sane format for this and implement function
|
|
||||||
p_char.toLower();
|
|
||||||
p_emote.toLower();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString AOApplication::get_char_name(QString p_char)
|
QString AOApplication::get_char_name(QString p_char)
|
||||||
{
|
{
|
||||||
QString char_ini_path = get_character_path(p_char) + "char.ini";
|
QString f_result = read_char_ini(p_char, "name", "[Options]", "[Time]");
|
||||||
|
|
||||||
QFile char_ini;
|
if (f_result == "")
|
||||||
|
return p_char;
|
||||||
|
else return f_result;
|
||||||
|
}
|
||||||
|
|
||||||
char_ini.setFileName(char_ini_path);
|
QString AOApplication::get_showname(QString p_char)
|
||||||
|
{
|
||||||
|
QString f_result = read_char_ini(p_char, "showname", "[Options]", "[Time]");
|
||||||
|
|
||||||
if (!char_ini.open(QIODevice::ReadOnly))
|
if (f_result == "")
|
||||||
{
|
return p_char;
|
||||||
return "";
|
else return f_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextStream in(&char_ini);
|
QString AOApplication::get_char_side(QString p_char)
|
||||||
|
{
|
||||||
|
QString f_result = read_char_ini(p_char, "side", "[Options]", "[Time]");
|
||||||
|
|
||||||
while(!in.atEnd())
|
if (f_result == "")
|
||||||
{
|
return "wit";
|
||||||
QString line = in.readLine();
|
else return f_result;
|
||||||
|
}
|
||||||
|
|
||||||
if (!line.startsWith("name"))
|
QString AOApplication::get_gender(QString p_char)
|
||||||
continue;
|
{
|
||||||
|
QString f_result = read_char_ini(p_char, "gender", "[Options]", "[Time]");
|
||||||
|
|
||||||
QStringList line_elements = line.split("=");
|
if (f_result == "")
|
||||||
|
return "male";
|
||||||
|
else return f_result;
|
||||||
|
}
|
||||||
|
|
||||||
if (line_elements.size() < 2)
|
QString AOApplication::get_chat(QString p_char)
|
||||||
continue;
|
{
|
||||||
|
QString f_result = read_char_ini(p_char, "chat", "[Options]", "[Time]");
|
||||||
|
|
||||||
return line_elements.at(1).trimmed();
|
//handling the correct order of chat is a bit complicated, we let the caller do it
|
||||||
}
|
return f_result;
|
||||||
|
}
|
||||||
|
|
||||||
return "";
|
int AOApplication::get_preanim_duration(QString p_char, QString p_emote)
|
||||||
|
{
|
||||||
|
QString f_result = read_char_ini(p_char, p_emote, "[Time]", "[Emotions]");
|
||||||
|
|
||||||
|
if (f_result == "")
|
||||||
|
return 0;
|
||||||
|
else return f_result.toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
int AOApplication::get_emote_number(QString p_char)
|
int AOApplication::get_emote_number(QString p_char)
|
||||||
{
|
{
|
||||||
QString char_ini_path = get_character_path(p_char) + "char.ini";
|
QString f_result = read_char_ini(p_char, "number", "[Emotions]", "[SoundN]");
|
||||||
QFile char_ini;
|
|
||||||
char_ini.setFileName(char_ini_path);
|
|
||||||
|
|
||||||
if (!char_ini.open(QIODevice::ReadOnly))
|
if (f_result == "")
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
else return f_result.toInt();
|
||||||
|
|
||||||
QTextStream in(&char_ini);
|
|
||||||
bool emotions_found = false;
|
|
||||||
|
|
||||||
while(!in.atEnd())
|
|
||||||
{
|
|
||||||
QString line = in.readLine();
|
|
||||||
|
|
||||||
if (line.startsWith("[SoundN]"))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (line.startsWith("[Emotions]"))
|
|
||||||
emotions_found = true;
|
|
||||||
|
|
||||||
if (!line.startsWith("number"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
QStringList line_elements = line.split("=");
|
|
||||||
|
|
||||||
if (line_elements.size() < 2)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (emotions_found)
|
|
||||||
return line_elements.at(1).trimmed().toInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AOApplication::get_pre_emote(QString p_char, int p_emote)
|
QString AOApplication::get_pre_emote(QString p_char, int p_emote)
|
||||||
{
|
{
|
||||||
QString char_ini_path = get_character_path(p_char) + "char.ini";
|
QString f_result = read_char_ini(p_char, QString::number(p_emote + 1), "[Emotions]", "[SoundN]");
|
||||||
QFile char_ini;
|
|
||||||
char_ini.setFileName(char_ini_path);
|
|
||||||
|
|
||||||
if (!char_ini.open(QIODevice::ReadOnly))
|
qDebug() << "f_result" << f_result;
|
||||||
|
|
||||||
|
QStringList result_contents = f_result.split("#");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (result_contents.size() < 4)
|
||||||
{
|
{
|
||||||
|
qDebug() << "W: misformatted char.ini: " << p_char << ", " << p_emote;
|
||||||
return "normal";
|
return "normal";
|
||||||
}
|
}
|
||||||
|
else return result_contents.at(1);
|
||||||
QTextStream in(&char_ini);
|
|
||||||
bool emotions_found = false;
|
|
||||||
QString search_line = QString::number(p_emote + 1);
|
|
||||||
|
|
||||||
while(!in.atEnd())
|
|
||||||
{
|
|
||||||
QString line = in.readLine();
|
|
||||||
|
|
||||||
if (line.startsWith("[SoundN]"))
|
|
||||||
return "normal";
|
|
||||||
|
|
||||||
if (line.startsWith("[Emotions]"))
|
|
||||||
emotions_found = true;
|
|
||||||
|
|
||||||
if (!line.startsWith(search_line))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
QStringList line_elements = line.split("#");
|
|
||||||
|
|
||||||
if (line_elements.size() < 4)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (emotions_found)
|
|
||||||
return line_elements.at(1).trimmed();
|
|
||||||
}
|
|
||||||
|
|
||||||
return "normal";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AOApplication::get_emote(QString p_char, int p_emote)
|
QString AOApplication::get_emote(QString p_char, int p_emote)
|
||||||
{
|
{
|
||||||
QString char_ini_path = get_character_path(p_char) + "char.ini";
|
QString f_result = read_char_ini(p_char, QString::number(p_emote + 1), "[Emotions]", "[SoundN]");
|
||||||
QFile char_ini;
|
|
||||||
char_ini.setFileName(char_ini_path);
|
|
||||||
|
|
||||||
if (!char_ini.open(QIODevice::ReadOnly))
|
QStringList result_contents = f_result.split("#");
|
||||||
|
|
||||||
|
if (result_contents.size() < 4)
|
||||||
{
|
{
|
||||||
|
qDebug() << "W: misformatted char.ini: " << p_char << ", " << p_emote;
|
||||||
return "normal";
|
return "normal";
|
||||||
}
|
}
|
||||||
|
else return result_contents.at(2);
|
||||||
QTextStream in(&char_ini);
|
|
||||||
bool emotions_found = false;
|
|
||||||
QString search_line = QString::number(p_emote + 1);
|
|
||||||
|
|
||||||
while(!in.atEnd())
|
|
||||||
{
|
|
||||||
QString line = in.readLine();
|
|
||||||
|
|
||||||
if (line.startsWith("[SoundN]"))
|
|
||||||
return "normal";
|
|
||||||
|
|
||||||
if (line.startsWith("[Emotions]"))
|
|
||||||
emotions_found = true;
|
|
||||||
|
|
||||||
if (!line.startsWith(search_line))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
QStringList line_elements = line.split("#");
|
|
||||||
|
|
||||||
if (line_elements.size() < 4)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (emotions_found)
|
|
||||||
return line_elements.at(2).trimmed();
|
|
||||||
}
|
|
||||||
|
|
||||||
return "normal";
|
|
||||||
}
|
|
||||||
|
|
||||||
QString AOApplication::get_sfx_name(QString p_char, int p_emote)
|
|
||||||
{
|
|
||||||
QString char_ini_path = get_character_path(p_char) + "char.ini";
|
|
||||||
QFile char_ini;
|
|
||||||
char_ini.setFileName(char_ini_path);
|
|
||||||
|
|
||||||
if (!char_ini.open(QIODevice::ReadOnly))
|
|
||||||
{
|
|
||||||
return "1";
|
|
||||||
}
|
|
||||||
|
|
||||||
QTextStream in(&char_ini);
|
|
||||||
bool soundn_found = false;
|
|
||||||
QString search_line = QString::number(p_emote + 1);
|
|
||||||
|
|
||||||
while(!in.atEnd())
|
|
||||||
{
|
|
||||||
QString line = in.readLine();
|
|
||||||
|
|
||||||
if (line.startsWith("[SoundT]"))
|
|
||||||
return "1";
|
|
||||||
|
|
||||||
if (line.startsWith("[SoundN]"))
|
|
||||||
soundn_found = true;
|
|
||||||
|
|
||||||
if (!soundn_found)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!line.startsWith(search_line))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
QStringList line_elements = line.split("=");
|
|
||||||
|
|
||||||
if (line_elements.size() < 2)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
|
|
||||||
return line_elements.at(1).trimmed();
|
|
||||||
}
|
|
||||||
|
|
||||||
return "1";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int AOApplication::get_sfx_delay(QString p_char, int p_emote)
|
|
||||||
{
|
|
||||||
QString char_ini_path = get_character_path(p_char) + "char.ini";
|
|
||||||
QFile char_ini;
|
|
||||||
char_ini.setFileName(char_ini_path);
|
|
||||||
|
|
||||||
if (!char_ini.open(QIODevice::ReadOnly))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
QTextStream in(&char_ini);
|
|
||||||
bool soundt_found = false;
|
|
||||||
QString search_line = QString::number(p_emote + 1);
|
|
||||||
|
|
||||||
while(!in.atEnd())
|
|
||||||
{
|
|
||||||
QString line = in.readLine();
|
|
||||||
|
|
||||||
if (line.startsWith("[SoundT]"))
|
|
||||||
soundt_found = true;
|
|
||||||
|
|
||||||
if (!soundt_found)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!line.startsWith(search_line))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
QStringList line_elements = line.split("=");
|
|
||||||
|
|
||||||
if (line_elements.size() < 2)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
return line_elements.at(1).trimmed().toInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int AOApplication::get_emote_mod(QString p_char, int p_emote)
|
int AOApplication::get_emote_mod(QString p_char, int p_emote)
|
||||||
{
|
{
|
||||||
QString char_ini_path = get_character_path(p_char) + "char.ini";
|
QString f_result = read_char_ini(p_char, QString::number(p_emote + 1), "[Emotions]", "[SoundN]");
|
||||||
QFile char_ini;
|
|
||||||
char_ini.setFileName(char_ini_path);
|
|
||||||
|
|
||||||
if (!char_ini.open(QIODevice::ReadOnly))
|
QStringList result_contents = f_result.split("#");
|
||||||
|
|
||||||
|
if (result_contents.size() < 4)
|
||||||
{
|
{
|
||||||
|
qDebug() << "W: misformatted char.ini: " << p_char << ", " << QString::number(p_emote);
|
||||||
return 0;
|
return 0;
|
||||||
qDebug() << "Could not find " << char_ini_path;
|
|
||||||
}
|
}
|
||||||
|
else return result_contents.at(3).toInt();
|
||||||
|
}
|
||||||
|
|
||||||
QTextStream in(&char_ini);
|
QString AOApplication::get_sfx_name(QString p_char, int p_emote)
|
||||||
bool emotions_found = false;
|
{
|
||||||
QString search_line = QString::number(p_emote + 1);
|
QString f_result = read_char_ini(p_char, QString::number(p_emote + 1), "[SoundN]", "[SoundT]");
|
||||||
|
|
||||||
while(!in.atEnd())
|
if (f_result == "")
|
||||||
{
|
return "1";
|
||||||
QString line = in.readLine();
|
else return f_result;
|
||||||
|
}
|
||||||
|
|
||||||
if (line.startsWith("[SoundN]"))
|
int AOApplication::get_sfx_delay(QString p_char, int p_emote)
|
||||||
{
|
{
|
||||||
qDebug() << "get_emote_mod returned early because soundN was found";
|
QString f_result = read_char_ini(p_char, QString::number(p_emote + 1), "[SoundT]", "[TextDelay]");
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (line.startsWith("[Emotions]"))
|
if (f_result == "")
|
||||||
emotions_found = true;
|
return 1;
|
||||||
|
else return f_result.toInt();
|
||||||
|
}
|
||||||
|
|
||||||
if (!line.startsWith(search_line))
|
int AOApplication::get_text_delay(QString p_char, QString p_emote)
|
||||||
continue;
|
{
|
||||||
|
QString f_result = read_char_ini(p_char, p_emote, "[TextDelay]", "END_OF_FILE");
|
||||||
|
|
||||||
QStringList line_elements = line.split("#");
|
if (f_result == "")
|
||||||
|
return -1;
|
||||||
if (line_elements.size() < 4)
|
else return f_result.toInt();
|
||||||
continue;
|
|
||||||
|
|
||||||
if (emotions_found)
|
|
||||||
return line_elements.at(3).trimmed().toInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
qDebug() << "get_emote_mod returned because loop finished";
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user