aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/CMakeLists.txt3
-rw-r--r--include/aoapplication.h68
-rw-r--r--include/aolayer.h17
-rw-r--r--include/aolineedit.h26
-rw-r--r--include/aooptionsdialog.h18
-rw-r--r--include/aotextedit.h21
-rw-r--r--include/courtroom.h22
-rw-r--r--include/eventfilters.h36
-rw-r--r--include/lobby.h2
9 files changed, 136 insertions, 77 deletions
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index 18cf23ba..e74a49bf 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -10,13 +10,11 @@ aoevidencebutton.h
aoevidencedisplay.h
aoimage.h
aolayer.h
-aolineedit.h
aomusicplayer.h
aooptionsdialog.h
aopacket.h
aosfxplayer.h
aotextarea.h
-aotextedit.h
bass.h
bassopus.h
chatlogpiece.h
@@ -28,6 +26,7 @@ discord-rpc.h
discord_register.h
discord_rich_presence.h
discord_rpc.h
+eventfilters.h
file_functions.h
hardware_functions.h
lobby.h
diff --git a/include/aoapplication.h b/include/aoapplication.h
index 1cdcbc54..d8d3c9a1 100644
--- a/include/aoapplication.h
+++ b/include/aoapplication.h
@@ -1,8 +1,6 @@
#ifndef AOAPPLICATION_H
#define AOAPPLICATION_H
-#define UNUSED(x) (void)(x)
-
#include "aopacket.h"
#include "datatypes.h"
#include "demoserver.h"
@@ -37,6 +35,25 @@ class NetworkManager;
class Lobby;
class Courtroom;
+class VPath : QString {
+ using QString::QString;
+
+public:
+ explicit VPath(const QString &str) : QString(str) {}
+ inline QString const &toQString() const { return *this; }
+ inline bool operator==(const VPath &str) const {
+ return this->toQString() == str.toQString();
+ }
+ inline VPath operator+(const VPath &str) const {
+ return VPath(this->toQString() + str.toQString());
+ }
+};
+
+inline uint qHash(const VPath &key, uint seed = qGlobalQHashSeed())
+{
+ return qHash(key.toQString(), seed);
+}
+
class AOApplication : public QApplication {
Q_OBJECT
@@ -129,24 +146,26 @@ public:
// implementation in path_functions.cpp
QString get_base_path();
- QString get_data_path();
- QString get_theme_path(QString p_file, QString p_theme="");
- QString get_character_path(QString p_char, QString p_file);
- QString get_misc_path(QString p_misc, QString p_file);
- QString get_sounds_path(QString p_file);
- QString get_music_path(QString p_song);
- QString get_background_path(QString p_file);
- QString get_default_background_path(QString p_file);
- QString get_evidence_path(QString p_file);
- QStringList get_asset_paths(QString p_element, QString p_theme="", QString p_subtheme="", QString p_default_theme="", QString p_misc="", QString p_character="", QString p_placeholder="");
- QString get_asset_path(QStringList pathlist);
- QString get_image_path(QStringList pathlist, bool static_image=false);
- QString get_sfx_path(QStringList pathlist);
+ VPath get_theme_path(QString p_file, QString p_theme="");
+ VPath get_character_path(QString p_char, QString p_file);
+ VPath get_misc_path(QString p_misc, QString p_file);
+ VPath get_sounds_path(QString p_file);
+ VPath get_music_path(QString p_song);
+ VPath get_background_path(QString p_file);
+ VPath get_default_background_path(QString p_file);
+ VPath get_evidence_path(QString p_file);
+ QVector<VPath> get_asset_paths(QString p_element, QString p_theme="", QString p_subtheme="", QString p_default_theme="", QString p_misc="", QString p_character="", QString p_placeholder="");
+ QString get_asset_path(QVector<VPath> pathlist);
+ QString get_image_path(QVector<VPath> pathlist, bool static_image=false);
+ QString get_sfx_path(QVector<VPath> pathlist);
QString get_config_value(QString p_identifier, QString p_config, QString p_theme="", QString p_subtheme="", QString p_default_theme="", QString p_misc="");
QString get_asset(QString p_element, QString p_theme="", QString p_subtheme="", QString p_default_theme="", QString p_misc="", QString p_character="", QString p_placeholder="");
- QString get_image(QString p_element, QString p_theme="", QString p_subtheme="", QString p_default_theme="", QString p_misc="", QString p_character="", QString p_placeholder="");
+ QString get_image(QString p_element, QString p_theme="", QString p_subtheme="", QString p_default_theme="", QString p_misc="", QString p_character="", QString p_placeholder="", bool static_image=false);
QString get_sfx(QString p_sfx, QString p_misc="", QString p_character="");
QString get_case_sensitive_path(QString p_file);
+ QString get_real_path(const VPath &vpath);
+ QString get_real_suffixed_path(const VPath &vpath, const QStringList &suffixes);
+ void invalidate_lookup_cache();
////// Functions for reading and writing files //////
// Implementations file_functions.cpp
@@ -265,6 +284,9 @@ public:
// Returns whether the log should have a timestamp.
bool get_log_timestamp();
+ // Returns the format string for the log timestamp
+ QString get_log_timestamp_format();
+
// Returns whether to log IC actions.
bool get_log_ic_actions();
@@ -284,6 +306,7 @@ public:
QStringList get_call_words();
// returns all of the file's lines in a QStringList
+ QStringList get_list_file(VPath path);
QStringList get_list_file(QString p_file);
// Process a file and return its text as a QString
@@ -307,6 +330,7 @@ public:
QVector<server_type> read_serverlist_txt();
// Returns the value of p_identifier in the design.ini file in p_design_path
+ QString read_design_ini(QString p_identifier, VPath p_design_path);
QString read_design_ini(QString p_identifier, QString p_design_path);
// Returns the coordinates of widget with p_identifier from p_file
@@ -336,18 +360,18 @@ public:
QString get_court_sfx(QString p_identifier, QString p_misc="");
// Figure out if we can opus this or if we should fall back to wav
- QString get_sfx_suffix(QString sound_to_check);
+ QString get_sfx_suffix(VPath sound_to_check);
// Can we use APNG for this? If not, WEBP? If not, GIF? If not, fall back to
// PNG.
- QString get_image_suffix(QString path_to_check, bool static_image=false);
+ QString get_image_suffix(VPath path_to_check, bool static_image=false);
// 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);
// Returns a QStringList of all key=value definitions on a given tag.
- QStringList read_ini_tags(QString p_file, QString target_tag = "");
+ QStringList read_ini_tags(VPath p_file, QString target_tag = "");
// Sets the char.ini p_search_line key under tag target_tag to value.
void set_char_ini(QString p_char, QString value, QString p_search_line,
@@ -491,6 +515,9 @@ public:
// Get the default scaling method
QString get_default_scaling();
+ // Get a list of custom mount paths
+ QStringList get_mount_paths();
+
// Get whether to opt out of player count metrics sent to the master server
bool get_player_count_optout();
@@ -529,6 +556,9 @@ private:
QVector<server_type> server_list;
QVector<server_type> favorite_list;
+ QHash<uint, QString> asset_lookup_cache;
+ QHash<uint, QString> dir_listing_cache;
+ QSet<uint> dir_listing_exist_cache;
public slots:
void server_disconnected();
diff --git a/include/aolayer.h b/include/aolayer.h
index f3ecebfb..b8907152 100644
--- a/include/aolayer.h
+++ b/include/aolayer.h
@@ -7,8 +7,12 @@
#include <QLabel>
#include <QTimer>
#include <QBitmap>
+#include <QtConcurrent/QtConcurrentRun>
+#include <QMutex>
+#include <QWaitCondition>
class AOApplication;
+class VPath;
// "Brief" explanation of what the hell this is:
//
@@ -138,6 +142,18 @@ protected:
// Center the QLabel in the viewport based on the dimensions of f_pixmap
void center_pixmap(QPixmap f_pixmap);
+private:
+ // Populates the frame and delay vectors.
+ void populate_vectors();
+
+ // used in populate_vectors
+ void load_next_frame();
+ bool exit_loop; //awful solution but i'm not fucking using QThread
+ QFuture<void> frame_loader;
+ QMutex mutex;
+ QWaitCondition frameAdded;
+
+
signals:
void done();
@@ -235,4 +251,5 @@ public:
StickerLayer(QWidget *p_parent, AOApplication *p_ao_app);
void load_image(QString p_charname);
};
+
#endif // AOLAYER_H
diff --git a/include/aolineedit.h b/include/aolineedit.h
deleted file mode 100644
index 5dce3aaa..00000000
--- a/include/aolineedit.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef AOLINEEDIT_H
-#define AOLINEEDIT_H
-
-#include <QLineEdit>
-#include <QMouseEvent>
-
-class AOLineEdit : public QLineEdit {
- Q_OBJECT
-
-public:
- AOLineEdit(QWidget *parent);
-
- void preserve_selection(bool toggle) { p_selection = toggle; }
-
-private:
- bool p_selection = false;
-
-protected:
- void mouseDoubleClickEvent(QMouseEvent *e);
- void focusOutEvent(QFocusEvent *ev);
-
-signals:
- void double_clicked();
-};
-
-#endif // AOLINEEDIT_H
diff --git a/include/aooptionsdialog.h b/include/aooptionsdialog.h
index d8ef49f5..84a96484 100644
--- a/include/aooptionsdialog.h
+++ b/include/aooptionsdialog.h
@@ -23,6 +23,7 @@
#include <QtWidgets/QWidget>
#include <QDirIterator>
+#include <QListWidget>
#include <QTextBrowser>
#include <QTextStream>
@@ -62,6 +63,8 @@ private:
QSpinBox *ui_log_margin_spinbox;
QLabel *ui_log_timestamp_lbl;
QCheckBox *ui_log_timestamp_cb;
+ QLabel *ui_log_timestamp_format_lbl;
+ QComboBox *ui_log_timestamp_format_combobox;
QLabel *ui_stay_time_lbl;
QSpinBox *ui_stay_time_spinbox;
QLabel *ui_desync_logs_lbl;
@@ -175,12 +178,25 @@ private:
QLabel *ui_log_lbl;
QCheckBox *ui_log_cb;
+ QWidget *ui_assets_tab;
+ QVBoxLayout *ui_assets_tab_layout;
+ QGridLayout *ui_mount_buttons_layout;
+ QLabel *ui_asset_lbl;
+ QListWidget *ui_mount_list;
+ QPushButton *ui_mount_add;
+ QPushButton *ui_mount_remove;
+ QPushButton *ui_mount_up;
+ QPushButton *ui_mount_down;
+ QPushButton *ui_mount_clear_cache;
+
QWidget *ui_privacy_tab;
QVBoxLayout *ui_privacy_layout;
QCheckBox *ui_privacy_optout_cb;
QFrame *ui_privacy_separator;
QTextBrowser *ui_privacy_policy;
+ bool asset_cache_dirty = false;
+
bool needs_default_audiodev();
void update_values();
@@ -190,6 +206,8 @@ public slots:
void save_pressed();
void discard_pressed();
void button_clicked(QAbstractButton *button);
+ void on_timestamp_format_edited();
+ void timestamp_cb_changed(int state);
void on_reload_theme_clicked();
void theme_changed(int i);
};
diff --git a/include/aotextedit.h b/include/aotextedit.h
deleted file mode 100644
index 8d876f17..00000000
--- a/include/aotextedit.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef AOTEXTEDIT_H
-#define AOTEXTEDIT_H
-
-#include <QPlainTextEdit>
-
-class AOTextEdit : public QPlainTextEdit {
- Q_OBJECT
-public:
- AOTextEdit(QWidget *parent);
-
-protected:
- void mouseDoubleClickEvent(QMouseEvent *e);
-
-signals:
- void double_clicked();
-
-private slots:
- void on_enter_pressed();
-};
-
-#endif // AOTEXTEDIT_H
diff --git a/include/courtroom.h b/include/courtroom.h
index e8145140..4bc86242 100644
--- a/include/courtroom.h
+++ b/include/courtroom.h
@@ -11,13 +11,11 @@
#include "aoevidencedisplay.h"
#include "aoimage.h"
#include "aolayer.h"
-#include "aolineedit.h"
#include "aomusicplayer.h"
#include "aooptionsdialog.h"
#include "aopacket.h"
#include "aosfxplayer.h"
#include "aotextarea.h"
-#include "aotextedit.h"
#include "chatlogpiece.h"
#include "datatypes.h"
#include "debug_functions.h"
@@ -25,6 +23,7 @@
#include "hardware_functions.h"
#include "lobby.h"
#include "scrolltext.h"
+#include "eventfilters.h"
#include <QCheckBox>
#include <QCloseEvent>
@@ -417,6 +416,9 @@ private:
// True, if the log should have a timestamp.
bool log_timestamp = false;
+ // format string for aforementioned log timestamp
+ QString log_timestamp_format;
+
// How long in miliseconds should the objection wait before appearing.
int objection_threshold = 1500;
@@ -648,7 +650,8 @@ private:
QComboBox *ui_pair_order_dropdown;
- AOLineEdit *ui_ic_chat_message;
+ QLineEdit *ui_ic_chat_message;
+ AOLineEditFilter *ui_ic_chat_message_filter;
QLineEdit *ui_ic_chat_name;
QLineEdit *ui_ooc_chat_message;
@@ -730,7 +733,8 @@ private:
AOButton *ui_evidence_button;
AOImage *ui_evidence;
- AOLineEdit *ui_evidence_name;
+ QLineEdit *ui_evidence_name;
+ AOLineEditFilter *ui_evidence_name_filter;
QWidget *ui_evidence_buttons;
QVector<AOEvidenceButton *> ui_evidence_list;
AOButton *ui_evidence_left;
@@ -738,7 +742,8 @@ private:
AOButton *ui_evidence_present;
AOImage *ui_evidence_overlay;
AOButton *ui_evidence_delete;
- AOLineEdit *ui_evidence_image_name;
+ QLineEdit *ui_evidence_image_name;
+ AOLineEditFilter *ui_evidence_image_name_filter;
AOButton *ui_evidence_image_button;
AOButton *ui_evidence_x;
AOButton *ui_evidence_ok;
@@ -746,7 +751,9 @@ private:
AOButton *ui_evidence_transfer;
AOButton *ui_evidence_save;
AOButton *ui_evidence_load;
- AOTextEdit *ui_evidence_description;
+ AOButton *ui_evidence_edit;
+ QPlainTextEdit *ui_evidence_description;
+
AOImage *ui_char_select_background;
@@ -873,6 +880,7 @@ private slots:
void on_evidence_image_button_clicked();
void on_evidence_clicked(int p_id);
void on_evidence_double_clicked(int p_id);
+ void on_evidence_edit_clicked();
void on_evidence_hover(int p_id, bool p_state);
@@ -928,8 +936,6 @@ private slots:
void on_showname_enable_clicked();
- void on_evidence_name_double_clicked();
- void on_evidence_image_name_double_clicked();
void on_evidence_button_clicked();
void on_evidence_delete_clicked();
diff --git a/include/eventfilters.h b/include/eventfilters.h
new file mode 100644
index 00000000..7847608d
--- /dev/null
+++ b/include/eventfilters.h
@@ -0,0 +1,36 @@
+#ifndef EVENTFILTERS_H
+#define EVENTFILTERS_H
+
+#include <QEvent>
+#include <QLineEdit>
+
+class AOLineEditFilter : public QObject
+{
+ Q_OBJECT
+public:
+ bool preserve_selection = false;
+
+protected:
+ bool eventFilter(QObject *obj, QEvent *event) override {
+ QLineEdit *lineEdit = qobject_cast<QLineEdit *>(obj);
+ if (event->type() == QEvent::FocusOut && lineEdit != nullptr && preserve_selection) { // lost focus
+ int start = lineEdit->selectionStart();
+ #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
+ int len = lineEdit->selectionLength();
+ #else
+ int len = lineEdit->selectedText().length();
+ #endif
+ if (start != -1 && len != -1) {
+ lineEdit->setSelection(start, len);\
+ return true;
+ }
+ }
+ return false;
+ }
+signals:
+ void double_clicked();
+};
+
+
+
+#endif // EVENTFILTERS_H
diff --git a/include/lobby.h b/include/lobby.h
index 1d2cbc6c..80832491 100644
--- a/include/lobby.h
+++ b/include/lobby.h
@@ -86,7 +86,7 @@ private:
QProgressBar *ui_progress_bar;
AOButton *ui_cancel;
- int last_index;
+ int last_index = -1;
void set_size_and_pos(QWidget *p_widget, QString p_identifier);