aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorCrystalwarrior <varsash@gmail.com>2019-09-20 22:11:37 +0300
committerCrystalwarrior <varsash@gmail.com>2019-09-20 22:11:37 +0300
commit842b829bee8b840149c0042bb7adfc3bda6eec9d (patch)
treec6ce50d4cbeb8d83aaf061c8b252bc6fcb942485 /include
parent497901e8c361326770e88e8a01daa7891b6a16e1 (diff)
Tweak the ambience/crosfade layer to fade in regardless of another sample being there
Fix music not being looped sometimes Prevent channel less than 0 from being passed Set up a new music display element with an attached music name, it displays a scrolling text of the currently playing music Fix music packet processing issues Make SFX slider responsible for all music channels besides 0 (actual music) scrolltext.cpp code recipe was taken from https://stackoverflow.com/questions/10651514/text-scrolling-marquee-in-qlabel - thanks to leemes for that one, I only adapted it for newer C++ version and tweaked some stuff.
Diffstat (limited to 'include')
-rw-r--r--include/aomusicplayer.h12
-rw-r--r--include/courtroom.h4
-rw-r--r--include/scrolltext.h50
3 files changed, 61 insertions, 5 deletions
diff --git a/include/aomusicplayer.h b/include/aomusicplayer.h
index 8ed0771..8e0d239 100644
--- a/include/aomusicplayer.h
+++ b/include/aomusicplayer.h
@@ -19,16 +19,19 @@ class AOMusicPlayer
public:
AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app);
virtual ~AOMusicPlayer();
-
- void play(QString p_song, int channel=0, bool crossfade=false);
- void stop(int channel=0);
- void set_volume(int p_value, int channel=0);
+ void set_volume(int p_value, int channel=-1);
void set_looping(bool toggle, int channel=0);
+ const int m_channelmax = 4;
+
//These have to be public for the stupid sync thing
// QWORD loop_start = 0;
// QWORD loop_end = 0;
+public slots:
+ void play(QString p_song, int channel=0, bool crossfade=false);
+ void stop(int channel=0);
+
private:
QWidget *m_parent;
AOApplication *ao_app;
@@ -36,7 +39,6 @@ private:
bool m_looping = false;
int m_volume = 0;
- const int m_channelmax = 4;
// Channel 0 = music
// Channel 1 = ambience
// Channel 2 = extra
diff --git a/include/courtroom.h b/include/courtroom.h
index d02c756..465b8ce 100644
--- a/include/courtroom.h
+++ b/include/courtroom.h
@@ -26,6 +26,7 @@
#include "datatypes.h"
#include "debug_functions.h"
#include "chatlogpiece.h"
+#include "scrolltext.h"
#include <QMainWindow>
#include <QLineEdit>
@@ -445,6 +446,9 @@ private:
QListWidget *ui_area_list;
QListWidget *ui_music_list;
+ ScrollText *ui_music_name;
+ AOMovie *ui_music_display;
+
AOButton *ui_pair_button;
QListWidget *ui_pair_list;
QSpinBox *ui_pair_offset_spinbox;
diff --git a/include/scrolltext.h b/include/scrolltext.h
new file mode 100644
index 0000000..cf791c0
--- /dev/null
+++ b/include/scrolltext.h
@@ -0,0 +1,50 @@
+#ifndef SCROLLTEXT_H
+#define SCROLLTEXT_H
+
+#include <QWidget>
+#include <QStaticText>
+#include <QTimer>
+#include <QPainter>
+#include <QDebug>
+
+
+class ScrollText : public QWidget
+{
+ Q_OBJECT
+ Q_PROPERTY(QString text READ text WRITE setText)
+ Q_PROPERTY(QString separator READ separator WRITE setSeparator)
+
+public:
+ explicit ScrollText(QWidget *parent = nullptr);
+
+public slots:
+ QString text() const;
+ void setText(QString text);
+
+ QString separator() const;
+ void setSeparator(QString separator);
+
+
+protected:
+ virtual void paintEvent(QPaintEvent *);
+ virtual void resizeEvent(QResizeEvent *);
+
+private:
+ void updateText();
+ QString _text;
+ QString _separator;
+ QStaticText staticText;
+ int singleTextWidth;
+ QSize wholeTextSize;
+ int leftMargin;
+ bool scrollEnabled;
+ int scrollPos;
+ QImage alphaChannel;
+ QImage buffer;
+ QTimer timer;
+
+private slots:
+ virtual void timer_timeout();
+};
+
+#endif // SCROLLTEXT_H