Reimplemented favorite server widget, ...
* Reworked favorite server widget * Renamed `server_type` to `ServerInfo` * Renamed `connection_type` to `ServerConnectionType` * Refactored `AOCharButton` * Reimplemented `AOButton` * Partially reimplemented `AOEmoteButton` * Refactored `AOEvidenceButton`
This commit is contained in:
parent
a0cee58c04
commit
39e4354b1d
@ -66,13 +66,14 @@ add_executable(Attorney_Online
|
|||||||
src/discord_rich_presence.cpp
|
src/discord_rich_presence.cpp
|
||||||
src/discord_rich_presence.h
|
src/discord_rich_presence.h
|
||||||
src/emotes.cpp
|
src/emotes.cpp
|
||||||
|
src/eventfilters.cpp
|
||||||
src/eventfilters.h
|
src/eventfilters.h
|
||||||
src/evidence.cpp
|
src/evidence.cpp
|
||||||
src/file_functions.cpp
|
src/file_functions.cpp
|
||||||
src/file_functions.h
|
src/file_functions.h
|
||||||
|
src/gui_utils.h
|
||||||
src/hardware_functions.cpp
|
src/hardware_functions.cpp
|
||||||
src/hardware_functions.h
|
src/hardware_functions.h
|
||||||
src/interfaces/server_dialog.h
|
|
||||||
src/lobby.cpp
|
src/lobby.cpp
|
||||||
src/lobby.h
|
src/lobby.h
|
||||||
src/main.cpp
|
src/main.cpp
|
||||||
@ -85,17 +86,13 @@ add_executable(Attorney_Online
|
|||||||
src/scrolltext.cpp
|
src/scrolltext.cpp
|
||||||
src/scrolltext.h
|
src/scrolltext.h
|
||||||
src/text_file_functions.cpp
|
src/text_file_functions.cpp
|
||||||
src/gui_utils.h
|
|
||||||
src/widgets/add_server_dialog.cpp
|
|
||||||
src/widgets/add_server_dialog.h
|
|
||||||
src/widgets/aooptionsdialog.cpp
|
src/widgets/aooptionsdialog.cpp
|
||||||
src/widgets/aooptionsdialog.h
|
src/widgets/aooptionsdialog.h
|
||||||
src/widgets/direct_connect_dialog.cpp
|
src/widgets/direct_connect_dialog.cpp
|
||||||
src/widgets/direct_connect_dialog.h
|
src/widgets/direct_connect_dialog.h
|
||||||
src/widgets/edit_server_dialog.cpp
|
src/widgets/server_editor_dialog.cpp
|
||||||
src/widgets/edit_server_dialog.h
|
src/widgets/server_editor_dialog.h
|
||||||
data.qrc
|
data.qrc
|
||||||
src/eventfilters.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set_target_properties(Attorney_Online PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin")
|
set_target_properties(Attorney_Online PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin")
|
||||||
|
@ -23,17 +23,17 @@
|
|||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<layout class="QHBoxLayout" name="server_legacy_layout">
|
<layout class="QHBoxLayout" name="server_legacy_layout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="server_legacy_lbl">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Legacy Entry :</string>
|
<string>Legacy Entry :</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="server_legacy_edit"/>
|
<widget class="QLineEdit" name="legacy_edit"/>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="server_legacy_load_button">
|
<widget class="QPushButton" name="parse_legacy">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Convert</string>
|
<string>Convert</string>
|
||||||
</property>
|
</property>
|
||||||
@ -44,48 +44,48 @@
|
|||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<layout class="QFormLayout" name="server_new_layout">
|
<layout class="QFormLayout" name="server_new_layout">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="server_display_name_lbl">
|
<widget class="QLabel" name="label_3">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Display Name:</string>
|
<string>Name:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QLineEdit" name="server_display_name_edit"/>
|
<widget class="QLineEdit" name="name"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="server_hostname_lbl">
|
<widget class="QLabel" name="label_4">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Hostname :</string>
|
<string>Hostname:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QLineEdit" name="server_hostname_edit"/>
|
<widget class="QLineEdit" name="hostname"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="server_port_lbl">
|
<widget class="QLabel" name="label_5">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Port:</string>
|
<string>Port:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QSpinBox" name="server_port_box">
|
<widget class="QSpinBox" name="port">
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<number>65535</number>
|
<number>65535</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QLabel" name="server_protocol_lbl">
|
<widget class="QLabel" name="label_6">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Protocol :</string>
|
<string>Protocol:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="QComboBox" name="server_protocol_box">
|
<widget class="QComboBox" name="protocol">
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>TCP</string>
|
<string>TCP</string>
|
||||||
@ -99,14 +99,14 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QLabel" name="server_description_lbl">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Description:</string>
|
<string>Description:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="1">
|
<item row="4" column="1">
|
||||||
<widget class="QPlainTextEdit" name="server_description_edit">
|
<widget class="QPlainTextEdit" name="description">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
@ -118,7 +118,7 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="Line" name="server_legacy_bar">
|
<widget class="Line" name="line">
|
||||||
<property name="frameShadow">
|
<property name="frameShadow">
|
||||||
<enum>QFrame::Plain</enum>
|
<enum>QFrame::Plain</enum>
|
||||||
</property>
|
</property>
|
||||||
@ -128,7 +128,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QDialogButtonBox" name="server_dialog_button">
|
<widget class="QDialogButtonBox" name="button_box">
|
||||||
<property name="standardButtons">
|
<property name="standardButtons">
|
||||||
<set>QDialogButtonBox::Close|QDialogButtonBox::Save</set>
|
<set>QDialogButtonBox::Close|QDialogButtonBox::Save</set>
|
||||||
</property>
|
</property>
|
||||||
|
@ -128,8 +128,8 @@ public:
|
|||||||
|
|
||||||
///////////////////////////////////////////
|
///////////////////////////////////////////
|
||||||
|
|
||||||
void set_server_list(QVector<server_type> &servers) { server_list = servers; }
|
void set_server_list(QVector<ServerInfo> &servers) { server_list = servers; }
|
||||||
QVector<server_type> &get_server_list() { return server_list; }
|
QVector<ServerInfo> &get_server_list() { return server_list; }
|
||||||
|
|
||||||
// implementation in path_functions.cpp
|
// implementation in path_functions.cpp
|
||||||
VPath get_theme_path(QString p_file, QString p_theme = QString());
|
VPath get_theme_path(QString p_file, QString p_theme = QString());
|
||||||
@ -359,7 +359,7 @@ private:
|
|||||||
const int MAJOR_VERSION = 11;
|
const int MAJOR_VERSION = 11;
|
||||||
const int MINOR_VERSION = 0;
|
const int MINOR_VERSION = 0;
|
||||||
|
|
||||||
QVector<server_type> server_list;
|
QVector<ServerInfo> server_list;
|
||||||
QHash<uint, QString> asset_lookup_cache;
|
QHash<uint, QString> asset_lookup_cache;
|
||||||
QHash<uint, QString> dir_listing_cache;
|
QHash<uint, QString> dir_listing_cache;
|
||||||
QSet<uint> dir_listing_exist_cache;
|
QSet<uint> dir_listing_exist_cache;
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
#include "aobutton.h"
|
#include "aobutton.h"
|
||||||
|
|
||||||
#include "debug_functions.h"
|
|
||||||
#include "file_functions.h"
|
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
|
||||||
AOButton::AOButton(AOApplication *p_ao_app, QWidget *parent)
|
AOButton::AOButton(AOApplication *ao_app, QWidget *parent)
|
||||||
: QPushButton(parent)
|
: QPushButton(parent)
|
||||||
, ao_app(p_ao_app)
|
, ao_app(ao_app)
|
||||||
{
|
{
|
||||||
m_movie = new QMovie(this);
|
m_movie = new QMovie(this);
|
||||||
|
|
||||||
@ -17,32 +15,61 @@ AOButton::AOButton(AOApplication *p_ao_app, QWidget *parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
AOButton::~AOButton()
|
AOButton::~AOButton()
|
||||||
{}
|
|
||||||
|
|
||||||
void AOButton::set_image(QString p_path, QString p_misc)
|
|
||||||
{
|
{
|
||||||
m_movie->stop();
|
deleteMovie();
|
||||||
QString p_image;
|
}
|
||||||
p_image = ao_app->get_image(p_path, Options::getInstance().theme(), Options::getInstance().subTheme(), ao_app->default_theme, p_misc, "", "", !Options::getInstance().animatedThemeEnabled());
|
|
||||||
if (p_image.isEmpty())
|
void AOButton::setImage(QString image_name)
|
||||||
|
{
|
||||||
|
deleteMovie();
|
||||||
|
|
||||||
|
QString file_path = ao_app->get_image(image_name, Options::getInstance().theme(), Options::getInstance().subTheme(), ao_app->default_theme, QString(), QString(), QString(), !Options::getInstance().animatedThemeEnabled());
|
||||||
|
if (file_path.isEmpty())
|
||||||
{
|
{
|
||||||
this->setIcon(QIcon());
|
setStyleSheet(QString());
|
||||||
this->setIconSize(this->size());
|
setIcon(QIcon());
|
||||||
this->setStyleSheet("");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
this->setText("");
|
else
|
||||||
this->setStyleSheet("QPushButton { background-color: transparent; border: 0px }");
|
|
||||||
m_movie->setFileName(p_image);
|
|
||||||
// We double-check if the user wants animated themes, so even if an animated image slipped through,
|
|
||||||
// we still set it static
|
|
||||||
if (Options::getInstance().animatedThemeEnabled() && m_movie->frameCount() > 1)
|
|
||||||
{
|
{
|
||||||
|
setText(QString());
|
||||||
|
setStyleSheet("QPushButton { background-color: transparent; border: 0px }");
|
||||||
|
|
||||||
|
if (Options::getInstance().animatedThemeEnabled())
|
||||||
|
{
|
||||||
|
m_movie = new QMovie;
|
||||||
|
m_movie->setFileName(file_path);
|
||||||
|
|
||||||
|
connect(m_movie, &QMovie::frameChanged, this, &AOButton::handleNextFrame);
|
||||||
|
|
||||||
m_movie->start();
|
m_movie->start();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->setIcon(QPixmap(p_image).scaled(this->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
updateIcon(QPixmap(file_path));
|
||||||
this->setIconSize(this->size());
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AOButton::deleteMovie()
|
||||||
|
{
|
||||||
|
if (m_movie)
|
||||||
|
{
|
||||||
|
disconnect(m_movie, &QMovie::frameChanged, this, &AOButton::handleNextFrame);
|
||||||
|
|
||||||
|
m_movie->stop();
|
||||||
|
m_movie->deleteLater();
|
||||||
|
m_movie = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AOButton::handleNextFrame()
|
||||||
|
{
|
||||||
|
updateIcon(m_movie->currentPixmap());
|
||||||
|
}
|
||||||
|
|
||||||
|
void AOButton::updateIcon(QPixmap icon)
|
||||||
|
{
|
||||||
|
const QSize current_size = size();
|
||||||
|
setIcon(icon.scaled(current_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
||||||
|
setIconSize(current_size);
|
||||||
|
}
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include "aoapplication.h"
|
#include "aoapplication.h"
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QMovie>
|
#include <QMovie>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
@ -11,12 +10,20 @@ class AOButton : public QPushButton
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AOButton(AOApplication *p_ao_app, QWidget *parent = nullptr);
|
explicit AOButton(AOApplication *ao_app, QWidget *parent = nullptr);
|
||||||
~AOButton();
|
virtual ~AOButton();
|
||||||
|
|
||||||
void set_image(QString p_image, QString p_misc = QString());
|
void setImage(QString image_name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AOApplication *ao_app;
|
AOApplication *ao_app;
|
||||||
QMovie *m_movie;
|
|
||||||
|
QMovie *m_movie = nullptr;
|
||||||
|
|
||||||
|
void deleteMovie();
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void handleNextFrame();
|
||||||
|
|
||||||
|
void updateIcon(QPixmap icon);
|
||||||
};
|
};
|
||||||
|
@ -2,46 +2,31 @@
|
|||||||
|
|
||||||
#include "file_functions.h"
|
#include "file_functions.h"
|
||||||
|
|
||||||
AOCharButton::AOCharButton(AOApplication *p_ao_app, int x_pos, int y_pos, bool is_taken, QWidget *parent)
|
AOCharButton::AOCharButton(AOApplication *ao_app, QWidget *parent)
|
||||||
: QPushButton(parent)
|
: QPushButton(parent)
|
||||||
, ao_app(p_ao_app)
|
, ao_app(ao_app)
|
||||||
, m_taken(is_taken)
|
|
||||||
{
|
{
|
||||||
int size = 60 * Options::getInstance().themeScalingFactor();
|
int size = 60 * Options::getInstance().themeScalingFactor();
|
||||||
int selector_size = 62 * Options::getInstance().themeScalingFactor();
|
int selector_size = 62 * Options::getInstance().themeScalingFactor();
|
||||||
|
|
||||||
this->resize(size, size);
|
resize(size, size);
|
||||||
this->move(x_pos, y_pos);
|
|
||||||
|
|
||||||
ui_taken = new AOImage(ao_app, this);
|
ui_taken = new AOImage(ao_app, this);
|
||||||
ui_taken->resize(size, size);
|
|
||||||
ui_taken->set_image("char_taken");
|
|
||||||
ui_taken->setAttribute(Qt::WA_TransparentForMouseEvents);
|
ui_taken->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||||
|
ui_taken->resize(size, size);
|
||||||
|
ui_taken->setImage("char_taken");
|
||||||
ui_taken->hide();
|
ui_taken->hide();
|
||||||
|
|
||||||
ui_selector = new AOImage(ao_app, parent);
|
ui_selector = new AOImage(ao_app, parent);
|
||||||
ui_selector->resize(selector_size, selector_size);
|
|
||||||
int offset = Options::getInstance().themeScalingFactor();
|
|
||||||
ui_selector->move(x_pos - offset, y_pos - offset);
|
|
||||||
ui_selector->set_image("char_selector");
|
|
||||||
ui_selector->setAttribute(Qt::WA_TransparentForMouseEvents);
|
ui_selector->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||||
|
ui_selector->resize(selector_size, selector_size);
|
||||||
|
ui_selector->setImage("char_selector");
|
||||||
ui_selector->hide();
|
ui_selector->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOCharButton::reset()
|
void AOCharButton::setTaken(bool enabled)
|
||||||
{
|
{
|
||||||
ui_taken->hide();
|
if (enabled)
|
||||||
ui_selector->hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AOCharButton::set_taken(bool is_taken)
|
|
||||||
{
|
|
||||||
m_taken = is_taken;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AOCharButton::apply_taken_image()
|
|
||||||
{
|
|
||||||
if (m_taken)
|
|
||||||
{
|
{
|
||||||
ui_taken->move(0, 0);
|
ui_taken->move(0, 0);
|
||||||
ui_taken->show();
|
ui_taken->show();
|
||||||
@ -52,45 +37,47 @@ void AOCharButton::apply_taken_image()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOCharButton::set_image(QString p_character)
|
void AOCharButton::setCharacter(QString character)
|
||||||
{
|
{
|
||||||
QString image_path = ao_app->get_image_suffix(ao_app->get_character_path(p_character, "char_icon"), true);
|
QString image_path = ao_app->get_image_suffix(ao_app->get_character_path(character, "char_icon"), true);
|
||||||
|
|
||||||
this->setText("");
|
setText(QString());
|
||||||
|
|
||||||
if (file_exists(image_path))
|
if (file_exists(image_path))
|
||||||
{
|
{
|
||||||
this->setStyleSheet("QPushButton { border-image: url(\"" + image_path +
|
setStyleSheet("QPushButton { border-image: url(\"" + image_path +
|
||||||
"\") 0 0 0 0 stretch stretch; }"
|
"\") 0 0 0 0 stretch stretch; }"
|
||||||
"QToolTip { background-image: url(); color: #000000; "
|
"QToolTip { background-image: url(); color: #000000; "
|
||||||
"background-color: #ffffff; border: 0px; }");
|
"background-color: #ffffff; border: 0px; }");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->setStyleSheet("QPushButton { border-image: url(); }"
|
setStyleSheet("QPushButton { border-image: url(); }"
|
||||||
"QToolTip { background-image: url(); color: #000000; "
|
"QToolTip { background-image: url(); color: #000000; "
|
||||||
"background-color: #ffffff; border: 0px; }");
|
"background-color: #ffffff; border: 0px; }");
|
||||||
this->setText(p_character);
|
setText(character);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
void AOCharButton::enterEvent(QEvent *e)
|
void AOCharButton::enterEvent(QEvent *event)
|
||||||
#else
|
#else
|
||||||
void AOCharButton::enterEvent(QEnterEvent *e)
|
void AOCharButton::enterEvent(QEnterEvent *event)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
int offset = Options::getInstance().themeScalingFactor();
|
int offset = Options::getInstance().themeScalingFactor();
|
||||||
ui_selector->move(this->x() - offset, this->y() - offset);
|
ui_selector->move(x() - offset, y() - offset);
|
||||||
ui_selector->raise();
|
ui_selector->raise();
|
||||||
ui_selector->show();
|
ui_selector->show();
|
||||||
|
|
||||||
setFlat(false);
|
setFlat(false);
|
||||||
QPushButton::enterEvent(e);
|
|
||||||
|
QPushButton::enterEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOCharButton::leaveEvent(QEvent *e)
|
void AOCharButton::leaveEvent(QEvent *event)
|
||||||
{
|
{
|
||||||
ui_selector->hide();
|
ui_selector->hide();
|
||||||
QPushButton::leaveEvent(e);
|
|
||||||
|
QPushButton::leaveEvent(event);
|
||||||
}
|
}
|
||||||
|
@ -14,23 +14,19 @@ class AOCharButton : public QPushButton
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AOCharButton(AOApplication *p_ao_app, int x_pos, int y_pos, bool is_taken, QWidget *parent);
|
AOCharButton(AOApplication *ao_app, QWidget *parent);
|
||||||
|
|
||||||
void refresh();
|
void setCharacter(QString character);
|
||||||
void reset();
|
|
||||||
void set_taken(bool is_taken);
|
|
||||||
|
|
||||||
void apply_taken_image();
|
void setTaken(bool enabled);
|
||||||
|
|
||||||
void set_image(QString p_character);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
void enterEvent(QEvent *e) override;
|
void enterEvent(QEvent *event) override;
|
||||||
#else
|
#else
|
||||||
void enterEvent(QEnterEvent *e) override;
|
void enterEvent(QEnterEvent *event) override;
|
||||||
#endif
|
#endif
|
||||||
void leaveEvent(QEvent *e) override;
|
void leaveEvent(QEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AOApplication *ao_app;
|
AOApplication *ao_app;
|
||||||
|
@ -1,22 +1,25 @@
|
|||||||
#include "aoemotebutton.h"
|
#include "aoemotebutton.h"
|
||||||
|
|
||||||
#include "file_functions.h"
|
#include "file_functions.h"
|
||||||
|
|
||||||
AOEmoteButton::AOEmoteButton(AOApplication *p_ao_app, int p_x, int p_y, int p_w, int p_h, QWidget *p_parent)
|
#include <QDebug>
|
||||||
: QPushButton(p_parent)
|
|
||||||
, ao_app(p_ao_app)
|
AOEmoteButton::AOEmoteButton(int id, int width, int height, AOApplication *ao_app, QWidget *parent)
|
||||||
|
: QPushButton(parent)
|
||||||
|
, ao_app(ao_app)
|
||||||
|
, m_id(id)
|
||||||
{
|
{
|
||||||
this->move(p_x, p_y);
|
resize(width, height);
|
||||||
this->resize(p_w, p_h);
|
|
||||||
|
|
||||||
ui_selected = new QLabel(this);
|
ui_selected = new QLabel(this);
|
||||||
ui_selected->resize(size());
|
|
||||||
ui_selected->setAttribute(Qt::WA_TransparentForMouseEvents);
|
ui_selected->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||||
|
ui_selected->resize(width, height);
|
||||||
ui_selected->hide();
|
ui_selected->hide();
|
||||||
|
|
||||||
connect(this, &AOEmoteButton::clicked, this, &AOEmoteButton::on_clicked);
|
connect(this, &AOEmoteButton::clicked, this, [this] { Q_EMIT emoteClicked(m_id); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOEmoteButton::set_selected_image(QString p_image)
|
void AOEmoteButton::setSelectedImage(QString p_image)
|
||||||
{
|
{
|
||||||
if (file_exists(p_image))
|
if (file_exists(p_image))
|
||||||
{
|
{
|
||||||
@ -28,50 +31,24 @@ void AOEmoteButton::set_selected_image(QString p_image)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOEmoteButton::set_id(int p_id)
|
int AOEmoteButton::id()
|
||||||
{
|
|
||||||
m_id = p_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
int AOEmoteButton::get_id()
|
|
||||||
{
|
{
|
||||||
return m_id;
|
return m_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOEmoteButton::set_image(QString p_image, QString p_emote_comment)
|
void AOEmoteButton::setImage(QString character, int emoteId, bool enabled)
|
||||||
{
|
{
|
||||||
if (file_exists(p_image))
|
QString emotion_number = QString::number(emoteId + 1);
|
||||||
{
|
|
||||||
this->setText("");
|
|
||||||
this->setStyleSheet("QPushButton { border: none; }"
|
|
||||||
"QToolTip { color: #000000; background-color: #ffffff; border: 0px; }");
|
|
||||||
this->setIcon(QPixmap(p_image).scaled(this->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
|
||||||
this->setIconSize(this->size());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this->setText(p_emote_comment);
|
|
||||||
this->setStyleSheet("QPushButton { border-image: url(); }"
|
|
||||||
"QToolTip { background-image: url(); color: #000000; "
|
|
||||||
"background-color: #ffffff; border: 0px; }");
|
|
||||||
this->setIcon(QIcon());
|
|
||||||
this->setIconSize(this->size());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AOEmoteButton::set_char_image(QString p_char, int p_emote, bool on)
|
|
||||||
{
|
|
||||||
QString emotion_number = QString::number(p_emote + 1);
|
|
||||||
QStringList suffixes{"_off", "_on"};
|
|
||||||
QStringList suffixedPaths;
|
QStringList suffixedPaths;
|
||||||
for (const QString &suffix : suffixes)
|
static const QStringList SUFFIX_LIST{"_off", "_on"};
|
||||||
|
for (const QString &suffix : SUFFIX_LIST)
|
||||||
{
|
{
|
||||||
suffixedPaths.append(ao_app->get_image_suffix(ao_app->get_character_path(p_char, "emotions/button" + emotion_number + suffix)));
|
suffixedPaths.append(ao_app->get_image_suffix(ao_app->get_character_path(character, "emotions/button" + emotion_number + suffix)));
|
||||||
}
|
}
|
||||||
QString image = suffixedPaths[static_cast<int>(on)];
|
|
||||||
|
|
||||||
QString emoteComment = ao_app->get_emote_comment(p_char, p_emote);
|
QString image = suffixedPaths[static_cast<int>(enabled)];
|
||||||
if (on && !file_exists(suffixedPaths[1]))
|
if (enabled && !file_exists(suffixedPaths[1]))
|
||||||
{
|
{
|
||||||
ui_selected->show();
|
ui_selected->show();
|
||||||
image = suffixedPaths[0];
|
image = suffixedPaths[0];
|
||||||
@ -81,10 +58,22 @@ void AOEmoteButton::set_char_image(QString p_char, int p_emote, bool on)
|
|||||||
ui_selected->hide();
|
ui_selected->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
set_image(image, emoteComment);
|
if (file_exists(image))
|
||||||
}
|
{
|
||||||
|
setText(QString());
|
||||||
void AOEmoteButton::on_clicked()
|
setStyleSheet("QPushButton { border: none; }"
|
||||||
{
|
"QToolTip { color: #000000; background-color: #ffffff; border: 0px; }");
|
||||||
Q_EMIT emote_clicked(m_id);
|
setIcon(QPixmap(image).scaled(size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
||||||
|
setIconSize(size());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QString emote_comment = ao_app->get_emote_comment(character, emoteId);
|
||||||
|
setText(emote_comment);
|
||||||
|
setStyleSheet("QPushButton { border-image: url(); }"
|
||||||
|
"QToolTip { background-image: url(); color: #000000; "
|
||||||
|
"background-color: #ffffff; border: 0px; }");
|
||||||
|
setIcon(QIcon());
|
||||||
|
setIconSize(size());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "aoapplication.h"
|
#include "aoapplication.h"
|
||||||
#include <QDebug>
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPainter>
|
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
class AOEmoteButton : public QPushButton
|
class AOEmoteButton : public QPushButton
|
||||||
@ -11,18 +10,16 @@ class AOEmoteButton : public QPushButton
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AOEmoteButton(AOApplication *p_ao_app, int p_x, int p_y, int p_w, int p_h, QWidget *p_parent);
|
AOEmoteButton(int id, int width, int height, AOApplication *ao_app, QWidget *parent = nullptr);
|
||||||
|
|
||||||
void set_image(QString p_image, QString p_emote_comment);
|
int id();
|
||||||
void set_char_image(QString p_char, int p_emote, bool on);
|
|
||||||
|
|
||||||
void set_selected_image(QString p_image);
|
void setImage(QString character, int emoteId, bool enabled);
|
||||||
|
|
||||||
void set_id(int p_id);
|
void setSelectedImage(QString p_image);
|
||||||
int get_id();
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void emote_clicked(int p_id);
|
void emoteClicked(int p_id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AOApplication *ao_app;
|
AOApplication *ao_app;
|
||||||
@ -30,7 +27,4 @@ private:
|
|||||||
int m_id = 0;
|
int m_id = 0;
|
||||||
|
|
||||||
QLabel *ui_selected = nullptr;
|
QLabel *ui_selected = nullptr;
|
||||||
|
|
||||||
private Q_SLOTS:
|
|
||||||
void on_clicked();
|
|
||||||
};
|
};
|
||||||
|
@ -2,61 +2,58 @@
|
|||||||
|
|
||||||
#include "file_functions.h"
|
#include "file_functions.h"
|
||||||
|
|
||||||
AOEvidenceButton::AOEvidenceButton(AOApplication *p_ao_app, int p_x, int p_y, int p_w, int p_h, QWidget *p_parent)
|
AOEvidenceButton::AOEvidenceButton(int id, int width, int height, AOApplication *ao_app, QWidget *parent)
|
||||||
: QPushButton(p_parent)
|
: QPushButton(parent)
|
||||||
, ao_app(p_ao_app)
|
, ao_app(ao_app)
|
||||||
|
, m_id(id)
|
||||||
{
|
{
|
||||||
|
resize(width, height);
|
||||||
|
|
||||||
ui_selected = new AOImage(ao_app, this);
|
ui_selected = new AOImage(ao_app, this);
|
||||||
ui_selected->resize(p_w, p_h);
|
ui_selected->resize(width, height);
|
||||||
// ui_selected->move(p_x, p_y);
|
ui_selected->setImage("evidence_selected");
|
||||||
ui_selected->set_image("evidence_selected");
|
|
||||||
ui_selected->setAttribute(Qt::WA_TransparentForMouseEvents);
|
ui_selected->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||||
ui_selected->hide();
|
ui_selected->hide();
|
||||||
|
|
||||||
ui_selector = new AOImage(ao_app, this);
|
ui_selector = new AOImage(ao_app, this);
|
||||||
ui_selector->resize(p_w, p_h);
|
ui_selector->resize(width, height);
|
||||||
// ui_selector->move(p_x - 1, p_y - 1);
|
ui_selector->setImage("evidence_selector");
|
||||||
ui_selector->set_image("evidence_selector");
|
|
||||||
ui_selector->setAttribute(Qt::WA_TransparentForMouseEvents);
|
ui_selector->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||||
ui_selector->hide();
|
ui_selector->hide();
|
||||||
|
|
||||||
this->move(p_x, p_y);
|
|
||||||
this->resize(p_w, p_h);
|
|
||||||
// this->setAcceptDrops(true);
|
|
||||||
|
|
||||||
connect(this, &AOEvidenceButton::clicked, this, &AOEvidenceButton::on_clicked);
|
connect(this, &AOEvidenceButton::clicked, this, &AOEvidenceButton::on_clicked);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOEvidenceButton::set_image(QString p_image)
|
void AOEvidenceButton::setImage(QString fileName)
|
||||||
{
|
{
|
||||||
QString image_path = ao_app->get_real_path(ao_app->get_evidence_path(p_image));
|
QString image_path = ao_app->get_real_path(ao_app->get_evidence_path(fileName));
|
||||||
if (file_exists(p_image))
|
if (file_exists(fileName))
|
||||||
{
|
{
|
||||||
this->setText("");
|
setText("");
|
||||||
this->setStyleSheet("QPushButton { border-image: url(\"" + p_image +
|
setStyleSheet("QPushButton { border-image: url(\"" + fileName +
|
||||||
"\") 0 0 0 0 stretch stretch; }"
|
"\") 0 0 0 0 stretch stretch; }"
|
||||||
"QToolTip { color: #000000; background-color: #ffffff; border: 0px; }");
|
"QToolTip { color: #000000; background-color: #ffffff; border: 0px; }");
|
||||||
}
|
}
|
||||||
else if (file_exists(image_path))
|
else if (file_exists(image_path))
|
||||||
{
|
{
|
||||||
this->setText("");
|
setText("");
|
||||||
this->setStyleSheet("QPushButton { border-image: url(\"" + image_path +
|
setStyleSheet("QPushButton { border-image: url(\"" + image_path +
|
||||||
"\") 0 0 0 0 stretch stretch; }"
|
"\") 0 0 0 0 stretch stretch; }"
|
||||||
"QToolTip { color: #000000; background-color: #ffffff; border: 0px; }");
|
"QToolTip { color: #000000; background-color: #ffffff; border: 0px; }");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->setText(p_image);
|
setText(fileName);
|
||||||
this->setStyleSheet("QPushButton { border-image: url(); }"
|
setStyleSheet("QPushButton { border-image: url(); }"
|
||||||
"QToolTip { background-image: url(); color: #000000; "
|
"QToolTip { background-image: url(); color: #000000; "
|
||||||
"background-color: #ffffff; border: 0px; }");
|
"background-color: #ffffff; border: 0px; }");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOEvidenceButton::set_theme_image(QString p_image)
|
void AOEvidenceButton::setThemeImage(QString fileName)
|
||||||
{
|
{
|
||||||
QString theme_image_path = ao_app->get_real_path(ao_app->get_theme_path(p_image));
|
QString theme_image_path = ao_app->get_real_path(ao_app->get_theme_path(fileName));
|
||||||
QString default_image_path = ao_app->get_real_path(ao_app->get_theme_path(p_image, ao_app->default_theme));
|
QString default_image_path = ao_app->get_real_path(ao_app->get_theme_path(fileName, ao_app->default_theme));
|
||||||
|
|
||||||
QString final_image_path;
|
QString final_image_path;
|
||||||
|
|
||||||
@ -69,10 +66,10 @@ void AOEvidenceButton::set_theme_image(QString p_image)
|
|||||||
final_image_path = default_image_path;
|
final_image_path = default_image_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->set_image(final_image_path);
|
setImage(final_image_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOEvidenceButton::set_selected(bool p_selected)
|
void AOEvidenceButton::setSelected(bool p_selected)
|
||||||
{
|
{
|
||||||
if (p_selected)
|
if (p_selected)
|
||||||
{
|
{
|
||||||
@ -86,31 +83,15 @@ void AOEvidenceButton::set_selected(bool p_selected)
|
|||||||
|
|
||||||
void AOEvidenceButton::on_clicked()
|
void AOEvidenceButton::on_clicked()
|
||||||
{
|
{
|
||||||
Q_EMIT evidence_clicked(m_id);
|
Q_EMIT evidenceClicked(m_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOEvidenceButton::mouseDoubleClickEvent(QMouseEvent *e)
|
void AOEvidenceButton::mouseDoubleClickEvent(QMouseEvent *e)
|
||||||
{
|
{
|
||||||
QPushButton::mouseDoubleClickEvent(e);
|
QPushButton::mouseDoubleClickEvent(e);
|
||||||
Q_EMIT evidence_double_clicked(m_id);
|
Q_EMIT evidenceDoubleClicked(m_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
void AOEvidenceButton::dragLeaveEvent(QMouseEvent *e)
|
|
||||||
{
|
|
||||||
//QWidget::dragLeaveEvent(e);
|
|
||||||
|
|
||||||
qDebug() << "drag leave event";
|
|
||||||
}
|
|
||||||
|
|
||||||
void AOEvidenceButton::dragEnterEvent(QMouseEvent *e)
|
|
||||||
{
|
|
||||||
//QWidget::dragEnterEvent(e);
|
|
||||||
|
|
||||||
qDebug() << "drag enter event";
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
void AOEvidenceButton::enterEvent(QEvent *e)
|
void AOEvidenceButton::enterEvent(QEvent *e)
|
||||||
#else
|
#else
|
||||||
@ -119,7 +100,7 @@ void AOEvidenceButton::enterEvent(QEnterEvent *e)
|
|||||||
{
|
{
|
||||||
ui_selector->show();
|
ui_selector->show();
|
||||||
|
|
||||||
Q_EMIT on_hover(m_id, true);
|
Q_EMIT mouseoverUpdated(m_id, true);
|
||||||
|
|
||||||
setFlat(false);
|
setFlat(false);
|
||||||
QPushButton::enterEvent(e);
|
QPushButton::enterEvent(e);
|
||||||
@ -129,6 +110,6 @@ void AOEvidenceButton::leaveEvent(QEvent *e)
|
|||||||
{
|
{
|
||||||
ui_selector->hide();
|
ui_selector->hide();
|
||||||
|
|
||||||
Q_EMIT on_hover(m_id, false);
|
Q_EMIT mouseoverUpdated(m_id, false);
|
||||||
QPushButton::leaveEvent(e);
|
QPushButton::leaveEvent(e);
|
||||||
}
|
}
|
||||||
|
@ -13,18 +13,19 @@ class AOEvidenceButton : public QPushButton
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AOEvidenceButton(AOApplication *p_ao_app, int p_x, int p_y, int p_w, int p_h, QWidget *p_parent = nullptr);
|
AOEvidenceButton(int id, int width, int height, AOApplication *ao_app, QWidget *parent = nullptr);
|
||||||
|
|
||||||
void set_image(QString p_image);
|
void setImage(QString fileName);
|
||||||
void set_theme_image(QString p_image);
|
|
||||||
void set_id(int p_id) { m_id = p_id; }
|
|
||||||
|
|
||||||
void set_selected(bool p_selected);
|
void setThemeImage(QString fileName);
|
||||||
|
|
||||||
|
void setSelected(bool enabled);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void evidence_clicked(int p_id);
|
void evidenceClicked(int id);
|
||||||
void evidence_double_clicked(int p_id);
|
void evidenceDoubleClicked(int id);
|
||||||
void on_hover(int p_id, bool p_state);
|
|
||||||
|
void mouseoverUpdated(int id, bool state);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
@ -33,6 +34,7 @@ protected:
|
|||||||
void enterEvent(QEnterEvent *e) override;
|
void enterEvent(QEnterEvent *e) override;
|
||||||
#endif
|
#endif
|
||||||
void leaveEvent(QEvent *e) override;
|
void leaveEvent(QEvent *e) override;
|
||||||
|
|
||||||
void mouseDoubleClickEvent(QMouseEvent *e) override;
|
void mouseDoubleClickEvent(QMouseEvent *e) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -5,26 +5,23 @@
|
|||||||
|
|
||||||
#include <QBitmap>
|
#include <QBitmap>
|
||||||
|
|
||||||
AOImage::AOImage(AOApplication *p_ao_app, QWidget *parent)
|
AOImage::AOImage(AOApplication *ao_app, QWidget *parent)
|
||||||
: QLabel(parent)
|
: QLabel(parent)
|
||||||
, ao_app(p_ao_app)
|
, ao_app(ao_app)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
AOImage::~AOImage()
|
QString AOImage::image()
|
||||||
{}
|
|
||||||
|
|
||||||
QString AOImage::file_name()
|
|
||||||
{
|
{
|
||||||
return m_file_name;
|
return m_file_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AOImage::set_image(QString p_image, QString p_misc)
|
bool AOImage::setImage(QString fileName, QString miscellaneous)
|
||||||
{
|
{
|
||||||
QString p_image_resolved = ao_app->get_image(p_image, Options::getInstance().theme(), Options::getInstance().subTheme(), ao_app->default_theme, p_misc, "", "", false);
|
QString p_image_resolved = ao_app->get_image(fileName, Options::getInstance().theme(), Options::getInstance().subTheme(), ao_app->default_theme, miscellaneous, "", "", false);
|
||||||
|
|
||||||
if (!file_exists(p_image_resolved))
|
if (!file_exists(p_image_resolved))
|
||||||
{
|
{
|
||||||
qWarning() << "could not find image" << p_image;
|
qWarning() << "could not find image" << fileName;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,3 +32,8 @@ bool AOImage::set_image(QString p_image, QString p_misc)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AOImage::setImage(QString fileName)
|
||||||
|
{
|
||||||
|
return setImage(fileName, QString());
|
||||||
|
}
|
||||||
|
@ -13,12 +13,12 @@ class AOImage : public QLabel
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AOImage(AOApplication *p_ao_app, QWidget *parent = nullptr);
|
AOImage(AOApplication *ao_app, QWidget *parent = nullptr);
|
||||||
AOImage(AOApplication *p_ao_app, bool make_static, QWidget *parent = nullptr);
|
|
||||||
~AOImage();
|
|
||||||
|
|
||||||
QString file_name();
|
QString image();
|
||||||
bool set_image(QString p_image, QString p_misc = QString());
|
|
||||||
|
bool setImage(QString fileName, QString miscellaneous);
|
||||||
|
bool setImage(QString fileName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AOApplication *ao_app;
|
AOApplication *ao_app;
|
||||||
|
@ -19,17 +19,17 @@ AOPacket::AOPacket(QString header, QStringList content)
|
|||||||
, m_content(content)
|
, m_content(content)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
QString AOPacket::get_header()
|
QString AOPacket::header()
|
||||||
{
|
{
|
||||||
return m_header;
|
return m_header;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList &AOPacket::get_content()
|
QStringList &AOPacket::content()
|
||||||
{
|
{
|
||||||
return m_content;
|
return m_content;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AOPacket::to_string(bool ensureEncoded)
|
QString AOPacket::toString(bool ensureEncoded)
|
||||||
{
|
{
|
||||||
QString message = m_header;
|
QString message = m_header;
|
||||||
if (!m_content.isEmpty())
|
if (!m_content.isEmpty())
|
||||||
|
@ -12,9 +12,10 @@ public:
|
|||||||
AOPacket(QString header);
|
AOPacket(QString header);
|
||||||
AOPacket(QString header, QStringList content);
|
AOPacket(QString header, QStringList content);
|
||||||
|
|
||||||
QString get_header();
|
QString header();
|
||||||
QStringList &get_content();
|
QStringList &content();
|
||||||
QString to_string(bool ensureEncoded = false);
|
|
||||||
|
QString toString(bool ensureEncoded = false);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_header;
|
QString m_header;
|
||||||
|
@ -83,7 +83,7 @@ void Courtroom::set_char_select()
|
|||||||
this->setFixedSize(f_charselect.width, f_charselect.height);
|
this->setFixedSize(f_charselect.width, f_charselect.height);
|
||||||
}
|
}
|
||||||
ui_char_select_background->resize(f_charselect.width, f_charselect.height);
|
ui_char_select_background->resize(f_charselect.width, f_charselect.height);
|
||||||
ui_char_select_background->set_image("charselect_background");
|
ui_char_select_background->setImage("charselect_background");
|
||||||
|
|
||||||
ui_char_search->setFocus();
|
ui_char_search->setFocus();
|
||||||
set_size_and_pos(ui_char_search, "char_search");
|
set_size_and_pos(ui_char_search, "char_search");
|
||||||
@ -118,7 +118,6 @@ void Courtroom::set_char_select_page()
|
|||||||
|
|
||||||
for (AOCharButton *i_button : qAsConst(ui_char_button_list))
|
for (AOCharButton *i_button : qAsConst(ui_char_button_list))
|
||||||
{
|
{
|
||||||
i_button->reset();
|
|
||||||
i_button->hide();
|
i_button->hide();
|
||||||
i_button->move(0, 0);
|
i_button->move(0, 0);
|
||||||
}
|
}
|
||||||
@ -265,7 +264,6 @@ void Courtroom::put_button_in_place(int starting, int chars_on_this_page)
|
|||||||
|
|
||||||
ui_char_button_list_filtered.at(n)->move(x_pos, y_pos);
|
ui_char_button_list_filtered.at(n)->move(x_pos, y_pos);
|
||||||
ui_char_button_list_filtered.at(n)->show();
|
ui_char_button_list_filtered.at(n)->show();
|
||||||
ui_char_button_list_filtered.at(n)->apply_taken_image();
|
|
||||||
|
|
||||||
++x_mod_count;
|
++x_mod_count;
|
||||||
|
|
||||||
@ -294,22 +292,24 @@ void Courtroom::character_loading_finished()
|
|||||||
// First, we'll make all the character buttons in the very beginning.
|
// First, we'll make all the character buttons in the very beginning.
|
||||||
// We also hide them all, so they can't be accidentally clicked.
|
// We also hide them all, so they can't be accidentally clicked.
|
||||||
// Later on, we'll be revealing buttons as we need them.
|
// Later on, we'll be revealing buttons as we need them.
|
||||||
for (int n = 0; n < char_list.size(); n++)
|
for (int i = 0; i < char_list.size(); i++)
|
||||||
{
|
{
|
||||||
AOCharButton *char_button = new AOCharButton(ao_app, 0, 0, char_list.at(n).taken, ui_char_buttons);
|
const CharacterSlot &character = char_list.at(i);
|
||||||
|
|
||||||
|
AOCharButton *char_button = new AOCharButton(ao_app, ui_char_buttons);
|
||||||
char_button->setContextMenuPolicy(Qt::CustomContextMenu);
|
char_button->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
char_button->reset();
|
|
||||||
char_button->hide();
|
char_button->hide();
|
||||||
char_button->set_image(char_list.at(n).name);
|
char_button->setCharacter(character.name);
|
||||||
char_button->setToolTip(char_list.at(n).name);
|
char_button->setTaken(character.taken);
|
||||||
|
char_button->setToolTip(character.name);
|
||||||
ui_char_button_list.append(char_button);
|
ui_char_button_list.append(char_button);
|
||||||
QString char_category = ao_app->get_category(char_list.at(n).name);
|
QString char_category = ao_app->get_category(character.name);
|
||||||
QList<QTreeWidgetItem *> matching_list = ui_char_list->findItems(char_category, Qt::MatchFixedString, 0);
|
QList<QTreeWidgetItem *> matching_list = ui_char_list->findItems(char_category, Qt::MatchFixedString, 0);
|
||||||
// create the character tree item
|
// create the character tree item
|
||||||
QTreeWidgetItem *treeItem = new QTreeWidgetItem();
|
QTreeWidgetItem *treeItem = new QTreeWidgetItem();
|
||||||
treeItem->setText(0, char_list.at(n).name);
|
treeItem->setText(0, character.name);
|
||||||
treeItem->setIcon(0, QIcon(ao_app->get_image_suffix(ao_app->get_character_path(char_list.at(n).name, "char_icon"), true)));
|
treeItem->setIcon(0, QIcon(ao_app->get_image_suffix(ao_app->get_character_path(character.name, "char_icon"), true)));
|
||||||
treeItem->setText(1, QString::number(n));
|
treeItem->setText(1, QString::number(i));
|
||||||
// category logic
|
// category logic
|
||||||
QTreeWidgetItem *category;
|
QTreeWidgetItem *category;
|
||||||
if (char_category == "") // no category
|
if (char_category == "") // no category
|
||||||
@ -333,7 +333,7 @@ void Courtroom::character_loading_finished()
|
|||||||
|
|
||||||
ui_char_list->sortItems(0, Qt::AscendingOrder);
|
ui_char_list->sortItems(0, Qt::AscendingOrder);
|
||||||
|
|
||||||
connect(char_button, &AOCharButton::clicked, this, [this, n]() { this->char_clicked(n); });
|
connect(char_button, &AOCharButton::clicked, this, [this, i]() { this->char_clicked(i); });
|
||||||
connect(char_button, &AOCharButton::customContextMenuRequested, this, &Courtroom::on_char_button_context_menu_requested);
|
connect(char_button, &AOCharButton::customContextMenuRequested, this, &Courtroom::on_char_button_context_menu_requested);
|
||||||
|
|
||||||
// This part here serves as a way of showing to the player that the game is
|
// This part here serves as a way of showing to the player that the game is
|
||||||
@ -374,9 +374,8 @@ void Courtroom::filter_character_list()
|
|||||||
// We only really need to update the fact that a character is taken
|
// We only really need to update the fact that a character is taken
|
||||||
// for the buttons that actually appear.
|
// for the buttons that actually appear.
|
||||||
// You'd also update the passwordedness and etc. here later.
|
// You'd also update the passwordedness and etc. here later.
|
||||||
current_char->reset();
|
|
||||||
current_char_list_item->setHidden(false);
|
current_char_list_item->setHidden(false);
|
||||||
current_char->set_taken(char_list.at(i).taken);
|
current_char->setTaken(char_list.at(i).taken);
|
||||||
current_char_list_item->setText(0, char_list.at(i).name);
|
current_char_list_item->setText(0, char_list.at(i).name);
|
||||||
// reset disabled
|
// reset disabled
|
||||||
current_char_list_item->setDisabled(false);
|
current_char_list_item->setDisabled(false);
|
||||||
|
@ -1,60 +1,33 @@
|
|||||||
#include "chatlogpiece.h"
|
#include "chatlogpiece.h"
|
||||||
|
|
||||||
ChatLogPiece::ChatLogPiece()
|
#include <QStringBuilder>
|
||||||
{
|
|
||||||
name = tr("UNKNOWN");
|
|
||||||
showname = tr("UNKNOWN");
|
|
||||||
message = tr("UNKNOWN");
|
|
||||||
color = 0;
|
|
||||||
datetime = QDateTime::currentDateTimeUtc();
|
|
||||||
}
|
|
||||||
|
|
||||||
ChatLogPiece::ChatLogPiece(QString p_name, QString p_showname, QString p_message, QString p_action, int p_color, bool p_selfname)
|
QString ChatLogPiece::toString()
|
||||||
{
|
{
|
||||||
name = p_name;
|
auto maybe_unknown = [](QString str) -> QString {
|
||||||
showname = p_showname;
|
if (str.isEmpty())
|
||||||
message = p_message;
|
|
||||||
action = p_action;
|
|
||||||
color = p_color;
|
|
||||||
selfname = p_selfname;
|
|
||||||
datetime = QDateTime::currentDateTimeUtc();
|
|
||||||
}
|
|
||||||
|
|
||||||
ChatLogPiece::ChatLogPiece(QString p_name, QString p_showname, QString p_message, QString p_action, int p_color, bool p_selfname, QDateTime p_datetime)
|
|
||||||
{
|
|
||||||
name = p_name;
|
|
||||||
showname = p_showname;
|
|
||||||
message = p_message;
|
|
||||||
action = p_action;
|
|
||||||
color = p_color;
|
|
||||||
selfname = p_selfname;
|
|
||||||
datetime = p_datetime.toUTC();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ChatLogPiece::get_datetime_as_string()
|
|
||||||
{
|
|
||||||
return datetime.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ChatLogPiece::get_full()
|
|
||||||
{
|
|
||||||
QString full = "[";
|
|
||||||
|
|
||||||
full.append(get_datetime_as_string());
|
|
||||||
full.append("] ");
|
|
||||||
full.append(showname);
|
|
||||||
if (showname != name)
|
|
||||||
{
|
{
|
||||||
full.append(" (");
|
return tr("UNKNOWN");
|
||||||
full.append(name);
|
|
||||||
full.append(")");
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
QString details = QString("[%1] %2").arg(timestamp.toString(), maybe_unknown(character_name));
|
||||||
|
|
||||||
|
if (character_name != character)
|
||||||
|
{
|
||||||
|
details += " (" % maybe_unknown(character) % ")";
|
||||||
|
}
|
||||||
|
|
||||||
if (!action.isEmpty())
|
if (!action.isEmpty())
|
||||||
{
|
{
|
||||||
full.append(" " + action);
|
details += " " % action;
|
||||||
}
|
}
|
||||||
full.append(": ");
|
|
||||||
full.append(message);
|
|
||||||
|
|
||||||
return full;
|
details += ": " % maybe_unknown(message);
|
||||||
|
|
||||||
|
return details;
|
||||||
}
|
}
|
||||||
|
@ -1,26 +1,21 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QtWidgets/QApplication>
|
|
||||||
|
|
||||||
class ChatLogPiece
|
class ChatLogPiece
|
||||||
{
|
{
|
||||||
Q_DECLARE_TR_FUNCTIONS(chatlogpiece)
|
Q_DECLARE_TR_FUNCTIONS(ChatLogPiece)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ChatLogPiece();
|
QString character;
|
||||||
ChatLogPiece(QString p_name, QString p_showname, QString p_message, QString p_action, int color, bool selfname);
|
QString character_name;
|
||||||
ChatLogPiece(QString p_name, QString p_showname, QString p_message, QString p_action, int color, bool selfname, QDateTime p_datetime);
|
|
||||||
|
|
||||||
QString name;
|
|
||||||
QString showname;
|
|
||||||
QString message;
|
QString message;
|
||||||
QString action;
|
QString action;
|
||||||
bool selfname = false;
|
QDateTime timestamp;
|
||||||
QDateTime datetime;
|
bool local_player = false;
|
||||||
int color = 0;
|
int color = 0;
|
||||||
|
|
||||||
QString get_datetime_as_string();
|
QString toString();
|
||||||
QString get_full();
|
|
||||||
};
|
};
|
||||||
|
@ -563,7 +563,7 @@ void Courtroom::update_audio_volume()
|
|||||||
blip_player->set_volume(ui_blip_slider->value() * remaining_percent);
|
blip_player->set_volume(ui_blip_slider->value() * remaining_percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Courtroom::append_char(char_type p_char)
|
void Courtroom::append_char(CharacterSlot p_char)
|
||||||
{
|
{
|
||||||
char_list.append(p_char);
|
char_list.append(p_char);
|
||||||
}
|
}
|
||||||
@ -671,7 +671,7 @@ void Courtroom::set_courtroom_size()
|
|||||||
}
|
}
|
||||||
ui_background->move(0, 0);
|
ui_background->move(0, 0);
|
||||||
ui_background->resize(m_courtroom_width, m_courtroom_height);
|
ui_background->resize(m_courtroom_width, m_courtroom_height);
|
||||||
ui_background->set_image("courtroombackground");
|
ui_background->setImage("courtroombackground");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Courtroom::set_mute_list()
|
void Courtroom::set_mute_list()
|
||||||
@ -686,7 +686,7 @@ void Courtroom::set_mute_list()
|
|||||||
|
|
||||||
QStringList sorted_mute_list;
|
QStringList sorted_mute_list;
|
||||||
|
|
||||||
for (const char_type &i_char : qAsConst(char_list))
|
for (const CharacterSlot &i_char : qAsConst(char_list))
|
||||||
{
|
{
|
||||||
sorted_mute_list.append(i_char.name);
|
sorted_mute_list.append(i_char.name);
|
||||||
}
|
}
|
||||||
@ -704,7 +704,7 @@ void Courtroom::set_pair_list()
|
|||||||
{
|
{
|
||||||
QStringList sorted_pair_list;
|
QStringList sorted_pair_list;
|
||||||
|
|
||||||
for (const char_type &i_char : qAsConst(char_list))
|
for (const CharacterSlot &i_char : qAsConst(char_list))
|
||||||
{
|
{
|
||||||
sorted_pair_list.append(i_char.name);
|
sorted_pair_list.append(i_char.name);
|
||||||
}
|
}
|
||||||
@ -836,7 +836,7 @@ void Courtroom::set_widgets()
|
|||||||
ui_pair_order_dropdown->setToolTip(tr("Change the order of appearance for your character."));
|
ui_pair_order_dropdown->setToolTip(tr("Change the order of appearance for your character."));
|
||||||
|
|
||||||
set_size_and_pos(ui_pair_button, "pair_button");
|
set_size_and_pos(ui_pair_button, "pair_button");
|
||||||
ui_pair_button->set_image("pair_button");
|
ui_pair_button->setImage("pair_button");
|
||||||
ui_pair_button->setToolTip(tr("Display the list of characters to pair with."));
|
ui_pair_button->setToolTip(tr("Display the list of characters to pair with."));
|
||||||
|
|
||||||
set_size_and_pos(ui_area_list, "music_list");
|
set_size_and_pos(ui_area_list, "music_list");
|
||||||
@ -887,7 +887,7 @@ void Courtroom::set_widgets()
|
|||||||
ui_vp_sticker->combo_resize(ui_viewport->width(), ui_viewport->height());
|
ui_vp_sticker->combo_resize(ui_viewport->width(), ui_viewport->height());
|
||||||
|
|
||||||
ui_muted->resize(ui_ic_chat_message->width(), ui_ic_chat_message->height());
|
ui_muted->resize(ui_ic_chat_message->width(), ui_ic_chat_message->height());
|
||||||
ui_muted->set_image("muted");
|
ui_muted->setImage("muted");
|
||||||
ui_muted->setToolTip(tr("Oops, you're muted!"));
|
ui_muted->setToolTip(tr("Oops, you're muted!"));
|
||||||
|
|
||||||
set_size_and_pos(ui_ooc_chat_message, "ooc_chat_message");
|
set_size_and_pos(ui_ooc_chat_message, "ooc_chat_message");
|
||||||
@ -907,7 +907,7 @@ void Courtroom::set_widgets()
|
|||||||
|
|
||||||
set_size_and_pos(ui_pos_remove, "pos_remove");
|
set_size_and_pos(ui_pos_remove, "pos_remove");
|
||||||
ui_pos_remove->setText("X");
|
ui_pos_remove->setText("X");
|
||||||
ui_pos_remove->set_image("evidencex");
|
ui_pos_remove->setImage("evidencex");
|
||||||
ui_pos_remove->setToolTip(tr("Reset your character's supplementary background to its default."));
|
ui_pos_remove->setToolTip(tr("Reset your character's supplementary background to its default."));
|
||||||
if (current_side == "")
|
if (current_side == "")
|
||||||
{
|
{
|
||||||
@ -928,7 +928,7 @@ void Courtroom::set_widgets()
|
|||||||
|
|
||||||
set_size_and_pos(ui_iniswap_remove, "iniswap_remove");
|
set_size_and_pos(ui_iniswap_remove, "iniswap_remove");
|
||||||
ui_iniswap_remove->setText("X");
|
ui_iniswap_remove->setText("X");
|
||||||
ui_iniswap_remove->set_image("evidencex");
|
ui_iniswap_remove->setImage("evidencex");
|
||||||
ui_iniswap_remove->setToolTip(tr("Remove the currently selected iniswap from the list and return to "
|
ui_iniswap_remove->setToolTip(tr("Remove the currently selected iniswap from the list and return to "
|
||||||
"the original character folder."));
|
"the original character folder."));
|
||||||
ui_iniswap_remove->hide();
|
ui_iniswap_remove->hide();
|
||||||
@ -943,7 +943,7 @@ void Courtroom::set_widgets()
|
|||||||
|
|
||||||
set_size_and_pos(ui_sfx_remove, "sfx_remove");
|
set_size_and_pos(ui_sfx_remove, "sfx_remove");
|
||||||
ui_sfx_remove->setText("X");
|
ui_sfx_remove->setText("X");
|
||||||
ui_sfx_remove->set_image("evidencex");
|
ui_sfx_remove->setImage("evidencex");
|
||||||
ui_sfx_remove->setToolTip(tr("Remove the currently selected sound effect."));
|
ui_sfx_remove->setToolTip(tr("Remove the currently selected sound effect."));
|
||||||
ui_sfx_remove->hide();
|
ui_sfx_remove->hide();
|
||||||
|
|
||||||
@ -964,10 +964,10 @@ void Courtroom::set_widgets()
|
|||||||
ui_effects_dropdown->setIconSize(QSize(p_point.x(), p_point.y()));
|
ui_effects_dropdown->setIconSize(QSize(p_point.x(), p_point.y()));
|
||||||
|
|
||||||
set_size_and_pos(ui_defense_bar, "defense_bar");
|
set_size_and_pos(ui_defense_bar, "defense_bar");
|
||||||
ui_defense_bar->set_image("defensebar" + QString::number(defense_bar_state));
|
ui_defense_bar->setImage("defensebar" + QString::number(defense_bar_state));
|
||||||
|
|
||||||
set_size_and_pos(ui_prosecution_bar, "prosecution_bar");
|
set_size_and_pos(ui_prosecution_bar, "prosecution_bar");
|
||||||
ui_prosecution_bar->set_image("prosecutionbar" + QString::number(prosecution_bar_state));
|
ui_prosecution_bar->setImage("prosecutionbar" + QString::number(prosecution_bar_state));
|
||||||
|
|
||||||
set_size_and_pos(ui_music_label, "music_label");
|
set_size_and_pos(ui_music_label, "music_label");
|
||||||
ui_music_label->setText(tr("Music"));
|
ui_music_label->setText(tr("Music"));
|
||||||
@ -980,70 +980,70 @@ void Courtroom::set_widgets()
|
|||||||
ui_hold_it->setText(tr("Hold It!"));
|
ui_hold_it->setText(tr("Hold It!"));
|
||||||
ui_hold_it->setToolTip(tr("When this is turned on, your next in-character "
|
ui_hold_it->setToolTip(tr("When this is turned on, your next in-character "
|
||||||
"message will be a shout!"));
|
"message will be a shout!"));
|
||||||
ui_hold_it->set_image("holdit");
|
ui_hold_it->setImage("holdit");
|
||||||
|
|
||||||
set_size_and_pos(ui_objection, "objection");
|
set_size_and_pos(ui_objection, "objection");
|
||||||
ui_objection->setText(tr("Objection!"));
|
ui_objection->setText(tr("Objection!"));
|
||||||
ui_objection->setToolTip(tr("When this is turned on, your next in-character "
|
ui_objection->setToolTip(tr("When this is turned on, your next in-character "
|
||||||
"message will be a shout!"));
|
"message will be a shout!"));
|
||||||
ui_objection->set_image("objection");
|
ui_objection->setImage("objection");
|
||||||
|
|
||||||
set_size_and_pos(ui_take_that, "take_that");
|
set_size_and_pos(ui_take_that, "take_that");
|
||||||
ui_take_that->setText(tr("Take That!"));
|
ui_take_that->setText(tr("Take That!"));
|
||||||
ui_take_that->setToolTip(tr("When this is turned on, your next in-character "
|
ui_take_that->setToolTip(tr("When this is turned on, your next in-character "
|
||||||
"message will be a shout!"));
|
"message will be a shout!"));
|
||||||
ui_take_that->set_image("takethat");
|
ui_take_that->setImage("takethat");
|
||||||
|
|
||||||
set_size_and_pos(ui_ooc_toggle, "ooc_toggle");
|
set_size_and_pos(ui_ooc_toggle, "ooc_toggle");
|
||||||
ui_ooc_toggle->setText(tr("Server"));
|
ui_ooc_toggle->setText(tr("Server"));
|
||||||
ui_ooc_toggle->setToolTip(tr("Toggle between server chat and global AO2 chat."));
|
ui_ooc_toggle->setToolTip(tr("Toggle between server chat and global AO2 chat."));
|
||||||
|
|
||||||
set_size_and_pos(ui_witness_testimony, "witness_testimony");
|
set_size_and_pos(ui_witness_testimony, "witness_testimony");
|
||||||
ui_witness_testimony->set_image("witnesstestimony");
|
ui_witness_testimony->setImage("witnesstestimony");
|
||||||
ui_witness_testimony->setToolTip(tr("This will display the animation in the "
|
ui_witness_testimony->setToolTip(tr("This will display the animation in the "
|
||||||
"viewport as soon as it is pressed."));
|
"viewport as soon as it is pressed."));
|
||||||
set_size_and_pos(ui_cross_examination, "cross_examination");
|
set_size_and_pos(ui_cross_examination, "cross_examination");
|
||||||
ui_cross_examination->set_image("crossexamination");
|
ui_cross_examination->setImage("crossexamination");
|
||||||
ui_cross_examination->setToolTip(tr("This will display the animation in the "
|
ui_cross_examination->setToolTip(tr("This will display the animation in the "
|
||||||
"viewport as soon as it is pressed."));
|
"viewport as soon as it is pressed."));
|
||||||
|
|
||||||
set_size_and_pos(ui_guilty, "guilty");
|
set_size_and_pos(ui_guilty, "guilty");
|
||||||
ui_guilty->setText(tr("Guilty!"));
|
ui_guilty->setText(tr("Guilty!"));
|
||||||
ui_guilty->set_image("guilty");
|
ui_guilty->setImage("guilty");
|
||||||
ui_guilty->setToolTip(tr("This will display the animation in the viewport as "
|
ui_guilty->setToolTip(tr("This will display the animation in the viewport as "
|
||||||
"soon as it is pressed."));
|
"soon as it is pressed."));
|
||||||
set_size_and_pos(ui_not_guilty, "not_guilty");
|
set_size_and_pos(ui_not_guilty, "not_guilty");
|
||||||
ui_not_guilty->set_image("notguilty");
|
ui_not_guilty->setImage("notguilty");
|
||||||
ui_not_guilty->setToolTip(tr("This will display the animation in the "
|
ui_not_guilty->setToolTip(tr("This will display the animation in the "
|
||||||
"viewport as soon as it is pressed."));
|
"viewport as soon as it is pressed."));
|
||||||
|
|
||||||
set_size_and_pos(ui_change_character, "change_character");
|
set_size_and_pos(ui_change_character, "change_character");
|
||||||
ui_change_character->setText(tr("Change character"));
|
ui_change_character->setText(tr("Change character"));
|
||||||
ui_change_character->set_image("change_character");
|
ui_change_character->setImage("change_character");
|
||||||
ui_change_character->setToolTip(tr("Bring up the Character Select Screen and change your character."));
|
ui_change_character->setToolTip(tr("Bring up the Character Select Screen and change your character."));
|
||||||
|
|
||||||
set_size_and_pos(ui_reload_theme, "reload_theme");
|
set_size_and_pos(ui_reload_theme, "reload_theme");
|
||||||
ui_reload_theme->setText(tr("Reload theme"));
|
ui_reload_theme->setText(tr("Reload theme"));
|
||||||
ui_reload_theme->set_image("reload_theme");
|
ui_reload_theme->setImage("reload_theme");
|
||||||
ui_reload_theme->setToolTip(tr("Refresh the theme and update all of the ui elements to match."));
|
ui_reload_theme->setToolTip(tr("Refresh the theme and update all of the ui elements to match."));
|
||||||
|
|
||||||
set_size_and_pos(ui_call_mod, "call_mod");
|
set_size_and_pos(ui_call_mod, "call_mod");
|
||||||
ui_call_mod->setText(tr("Call mod"));
|
ui_call_mod->setText(tr("Call mod"));
|
||||||
ui_call_mod->set_image("call_mod");
|
ui_call_mod->setImage("call_mod");
|
||||||
ui_call_mod->setToolTip(tr("Request the attention of the current server's moderator."));
|
ui_call_mod->setToolTip(tr("Request the attention of the current server's moderator."));
|
||||||
|
|
||||||
set_size_and_pos(ui_settings, "settings");
|
set_size_and_pos(ui_settings, "settings");
|
||||||
ui_settings->setText(tr("Settings"));
|
ui_settings->setText(tr("Settings"));
|
||||||
ui_settings->set_image("courtroom_settings");
|
ui_settings->setImage("courtroom_settings");
|
||||||
if (ui_settings->icon().isNull())
|
if (ui_settings->icon().isNull())
|
||||||
{
|
{
|
||||||
ui_settings->set_image("settings"); // pre-2.10 filename
|
ui_settings->setImage("settings"); // pre-2.10 filename
|
||||||
}
|
}
|
||||||
ui_settings->setToolTip(tr("Allows you to change various aspects of the client."));
|
ui_settings->setToolTip(tr("Allows you to change various aspects of the client."));
|
||||||
|
|
||||||
set_size_and_pos(ui_switch_area_music, "switch_area_music");
|
set_size_and_pos(ui_switch_area_music, "switch_area_music");
|
||||||
ui_switch_area_music->setText(tr("A/M"));
|
ui_switch_area_music->setText(tr("A/M"));
|
||||||
ui_switch_area_music->set_image("switch_area_music");
|
ui_switch_area_music->setImage("switch_area_music");
|
||||||
ui_switch_area_music->setToolTip(tr("Switch between Areas and Music lists"));
|
ui_switch_area_music->setToolTip(tr("Switch between Areas and Music lists"));
|
||||||
|
|
||||||
set_size_and_pos(ui_pre, "pre");
|
set_size_and_pos(ui_pre, "pre");
|
||||||
@ -1082,40 +1082,40 @@ void Courtroom::set_widgets()
|
|||||||
|
|
||||||
set_size_and_pos(ui_custom_objection, "custom_objection");
|
set_size_and_pos(ui_custom_objection, "custom_objection");
|
||||||
ui_custom_objection->setText(tr("Custom Shout!"));
|
ui_custom_objection->setText(tr("Custom Shout!"));
|
||||||
ui_custom_objection->set_image("custom");
|
ui_custom_objection->setImage("custom");
|
||||||
ui_custom_objection->setToolTip(tr("This will display the custom character-defined animation in the "
|
ui_custom_objection->setToolTip(tr("This will display the custom character-defined animation in the "
|
||||||
"viewport as soon as it is pressed.\n"
|
"viewport as soon as it is pressed.\n"
|
||||||
"To make one, your character's folder must contain "
|
"To make one, your character's folder must contain "
|
||||||
"custom.[webp/apng/gif/png] and custom.[wav/ogg/opus] sound effect"));
|
"custom.[webp/apng/gif/png] and custom.[wav/ogg/opus] sound effect"));
|
||||||
|
|
||||||
set_size_and_pos(ui_realization, "realization");
|
set_size_and_pos(ui_realization, "realization");
|
||||||
ui_realization->set_image("realization");
|
ui_realization->setImage("realization");
|
||||||
ui_realization->setToolTip(tr("Play realization sound and animation in the viewport on the next "
|
ui_realization->setToolTip(tr("Play realization sound and animation in the viewport on the next "
|
||||||
"spoken message when checked."));
|
"spoken message when checked."));
|
||||||
|
|
||||||
set_size_and_pos(ui_screenshake, "screenshake");
|
set_size_and_pos(ui_screenshake, "screenshake");
|
||||||
ui_screenshake->set_image("screenshake");
|
ui_screenshake->setImage("screenshake");
|
||||||
ui_screenshake->setToolTip(tr("Shake the screen on next spoken message when checked."));
|
ui_screenshake->setToolTip(tr("Shake the screen on next spoken message when checked."));
|
||||||
|
|
||||||
set_size_and_pos(ui_mute, "mute_button");
|
set_size_and_pos(ui_mute, "mute_button");
|
||||||
ui_mute->setText("Mute");
|
ui_mute->setText("Mute");
|
||||||
ui_mute->set_image("mute");
|
ui_mute->setImage("mute");
|
||||||
ui_mute->setToolTip(tr("Display the list of character folders you wish to mute."));
|
ui_mute->setToolTip(tr("Display the list of character folders you wish to mute."));
|
||||||
|
|
||||||
set_size_and_pos(ui_defense_plus, "defense_plus");
|
set_size_and_pos(ui_defense_plus, "defense_plus");
|
||||||
ui_defense_plus->set_image("defplus");
|
ui_defense_plus->setImage("defplus");
|
||||||
ui_defense_plus->setToolTip(tr("Increase the health bar."));
|
ui_defense_plus->setToolTip(tr("Increase the health bar."));
|
||||||
|
|
||||||
set_size_and_pos(ui_defense_minus, "defense_minus");
|
set_size_and_pos(ui_defense_minus, "defense_minus");
|
||||||
ui_defense_minus->set_image("defminus");
|
ui_defense_minus->setImage("defminus");
|
||||||
ui_defense_minus->setToolTip(tr("Decrease the health bar."));
|
ui_defense_minus->setToolTip(tr("Decrease the health bar."));
|
||||||
|
|
||||||
set_size_and_pos(ui_prosecution_plus, "prosecution_plus");
|
set_size_and_pos(ui_prosecution_plus, "prosecution_plus");
|
||||||
ui_prosecution_plus->set_image("proplus");
|
ui_prosecution_plus->setImage("proplus");
|
||||||
ui_prosecution_plus->setToolTip(tr("Increase the health bar."));
|
ui_prosecution_plus->setToolTip(tr("Increase the health bar."));
|
||||||
|
|
||||||
set_size_and_pos(ui_prosecution_minus, "prosecution_minus");
|
set_size_and_pos(ui_prosecution_minus, "prosecution_minus");
|
||||||
ui_prosecution_minus->set_image("prominus");
|
ui_prosecution_minus->setImage("prominus");
|
||||||
ui_prosecution_minus->setToolTip(tr("Decrease the health bar."));
|
ui_prosecution_minus->setToolTip(tr("Decrease the health bar."));
|
||||||
|
|
||||||
set_size_and_pos(ui_text_color, "text_color");
|
set_size_and_pos(ui_text_color, "text_color");
|
||||||
@ -1137,10 +1137,10 @@ void Courtroom::set_widgets()
|
|||||||
set_size_and_pos(ui_char_buttons, "char_buttons");
|
set_size_and_pos(ui_char_buttons, "char_buttons");
|
||||||
|
|
||||||
set_size_and_pos(ui_char_select_left, "char_select_left");
|
set_size_and_pos(ui_char_select_left, "char_select_left");
|
||||||
ui_char_select_left->set_image("arrow_left");
|
ui_char_select_left->setImage("arrow_left");
|
||||||
|
|
||||||
set_size_and_pos(ui_char_select_right, "char_select_right");
|
set_size_and_pos(ui_char_select_right, "char_select_right");
|
||||||
ui_char_select_right->set_image("arrow_right");
|
ui_char_select_right->setImage("arrow_right");
|
||||||
|
|
||||||
set_size_and_pos(ui_spectator, "spectator");
|
set_size_and_pos(ui_spectator, "spectator");
|
||||||
ui_spectator->setToolTip(tr("Become a spectator. You won't be able to "
|
ui_spectator->setToolTip(tr("Become a spectator. You won't be able to "
|
||||||
@ -1334,7 +1334,7 @@ void Courtroom::set_taken(int n_char, bool p_taken)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
char_type f_char;
|
CharacterSlot f_char;
|
||||||
f_char.name = char_list.at(n_char).name;
|
f_char.name = char_list.at(n_char).name;
|
||||||
f_char.description = char_list.at(n_char).description;
|
f_char.description = char_list.at(n_char).description;
|
||||||
f_char.taken = p_taken;
|
f_char.taken = p_taken;
|
||||||
@ -1672,16 +1672,16 @@ void Courtroom::enter_courtroom()
|
|||||||
switch (objection_state) // no need to reset these as it was done in set_widgets()
|
switch (objection_state) // no need to reset these as it was done in set_widgets()
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
ui_hold_it->set_image("holdit_selected");
|
ui_hold_it->setImage("holdit_selected");
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
ui_objection->set_image("objection_selected");
|
ui_objection->setImage("objection_selected");
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
ui_take_that->set_image("takethat_selected");
|
ui_take_that->setImage("takethat_selected");
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
ui_custom_objection->set_image("custom_selected");
|
ui_custom_objection->setImage("custom_selected");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -2292,13 +2292,13 @@ void Courtroom::reset_ui()
|
|||||||
realization_state = 0;
|
realization_state = 0;
|
||||||
screenshake_state = 0;
|
screenshake_state = 0;
|
||||||
is_presenting_evidence = false;
|
is_presenting_evidence = false;
|
||||||
ui_hold_it->set_image("holdit");
|
ui_hold_it->setImage("holdit");
|
||||||
ui_objection->set_image("objection");
|
ui_objection->setImage("objection");
|
||||||
ui_take_that->set_image("takethat");
|
ui_take_that->setImage("takethat");
|
||||||
ui_custom_objection->set_image("custom");
|
ui_custom_objection->setImage("custom");
|
||||||
ui_realization->set_image("realization");
|
ui_realization->setImage("realization");
|
||||||
ui_screenshake->set_image("screenshake");
|
ui_screenshake->setImage("screenshake");
|
||||||
ui_evidence_present->set_image("present");
|
ui_evidence_present->setImage("present");
|
||||||
|
|
||||||
// If sticky sounds is disabled and we either have SFX on Idle enabled, or our Preanim checkbox is checked
|
// If sticky sounds is disabled and we either have SFX on Idle enabled, or our Preanim checkbox is checked
|
||||||
if (!Options::getInstance().clearSoundsDropdownOnPlayEnabled() && (Options::getInstance().playSelectedSFXOnIdle() || ui_pre->isChecked()))
|
if (!Options::getInstance().clearSoundsDropdownOnPlayEnabled() && (Options::getInstance().playSelectedSFXOnIdle() || ui_pre->isChecked()))
|
||||||
@ -3111,14 +3111,14 @@ void Courtroom::initialize_chatbox()
|
|||||||
|
|
||||||
if (ui_vp_showname->text().trimmed().isEmpty()) // Whitespace showname
|
if (ui_vp_showname->text().trimmed().isEmpty()) // Whitespace showname
|
||||||
{
|
{
|
||||||
ui_vp_chatbox->set_image("chatblank", p_misc);
|
ui_vp_chatbox->setImage("chatblank", p_misc);
|
||||||
}
|
}
|
||||||
else // Aw yeah dude do some showname magic
|
else // Aw yeah dude do some showname magic
|
||||||
{
|
{
|
||||||
ui_vp_showname->setVisible(true);
|
ui_vp_showname->setVisible(true);
|
||||||
if (!ui_vp_chatbox->set_image("chat", p_misc))
|
if (!ui_vp_chatbox->setImage("chat", p_misc))
|
||||||
{
|
{
|
||||||
ui_vp_chatbox->set_image("chatbox", p_misc);
|
ui_vp_chatbox->setImage("chatbox", p_misc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remember to set the showname font before the font metrics check.
|
// Remember to set the showname font before the font metrics check.
|
||||||
@ -3153,11 +3153,11 @@ void Courtroom::initialize_chatbox()
|
|||||||
#endif
|
#endif
|
||||||
if (extra_width > 0)
|
if (extra_width > 0)
|
||||||
{
|
{
|
||||||
QString current_path = ui_vp_chatbox->file_name().left(ui_vp_chatbox->file_name().lastIndexOf('.'));
|
QString current_path = ui_vp_chatbox->image().left(ui_vp_chatbox->image().lastIndexOf('.'));
|
||||||
if (fm_width > default_width.width && ui_vp_chatbox->set_image(current_path + "med")) // This text be big. Let's do some shenanigans.
|
if (fm_width > default_width.width && ui_vp_chatbox->setImage(current_path + "med")) // This text be big. Let's do some shenanigans.
|
||||||
{
|
{
|
||||||
ui_vp_showname->resize(default_width.width + extra_width, ui_vp_showname->height());
|
ui_vp_showname->resize(default_width.width + extra_width, ui_vp_showname->height());
|
||||||
if (fm_width > ui_vp_showname->width() && ui_vp_chatbox->set_image(current_path + "big")) // Biggest possible size for us.
|
if (fm_width > ui_vp_showname->width() && ui_vp_chatbox->setImage(current_path + "big")) // Biggest possible size for us.
|
||||||
{
|
{
|
||||||
ui_vp_showname->resize(static_cast<int>(default_width.width + (extra_width * 2)), ui_vp_showname->height());
|
ui_vp_showname->resize(static_cast<int>(default_width.width + (extra_width * 2)), ui_vp_showname->height());
|
||||||
}
|
}
|
||||||
@ -3578,11 +3578,19 @@ QString Courtroom::filter_ic_text(QString p_text, bool html, int target_pos, int
|
|||||||
|
|
||||||
void Courtroom::log_ic_text(QString p_name, QString p_showname, QString p_message, QString p_action, int p_color, bool p_selfname)
|
void Courtroom::log_ic_text(QString p_name, QString p_showname, QString p_message, QString p_action, int p_color, bool p_selfname)
|
||||||
{
|
{
|
||||||
ChatLogPiece log_entry(p_name, p_showname, p_message, p_action, p_color, p_selfname);
|
ChatLogPiece log_entry;
|
||||||
|
log_entry.character = p_name;
|
||||||
|
log_entry.character_name = p_showname;
|
||||||
|
log_entry.local_player = p_selfname;
|
||||||
|
log_entry.message = p_message;
|
||||||
|
log_entry.action = p_action;
|
||||||
|
log_entry.color = p_color;
|
||||||
|
log_entry.timestamp = QDateTime::currentDateTimeUtc();
|
||||||
ic_chatlog_history.append(log_entry);
|
ic_chatlog_history.append(log_entry);
|
||||||
|
|
||||||
if (Options::getInstance().logToTextFileEnabled() && !ao_app->log_filename.isEmpty())
|
if (Options::getInstance().logToTextFileEnabled() && !ao_app->log_filename.isEmpty())
|
||||||
{
|
{
|
||||||
ao_app->append_to_file(log_entry.get_full(), ao_app->log_filename, true);
|
ao_app->append_to_file(log_entry.toString(), ao_app->log_filename, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (ic_chatlog_history.size() > log_maximum_blocks && log_maximum_blocks > 0)
|
while (ic_chatlog_history.size() > log_maximum_blocks && log_maximum_blocks > 0)
|
||||||
@ -3997,7 +4005,8 @@ void Courtroom::start_chat_ticking()
|
|||||||
|
|
||||||
QString f_blips = ao_app->get_blipname(m_chatmessage[CHAR_NAME]);
|
QString f_blips = ao_app->get_blipname(m_chatmessage[CHAR_NAME]);
|
||||||
f_blips = ao_app->get_blips(f_blips);
|
f_blips = ao_app->get_blips(f_blips);
|
||||||
if (ao_app->custom_blips_supported && !m_chatmessage[BLIPNAME].isEmpty()) {
|
if (ao_app->custom_blips_supported && !m_chatmessage[BLIPNAME].isEmpty())
|
||||||
|
{
|
||||||
f_blips = ao_app->get_blips(m_chatmessage[BLIPNAME]);
|
f_blips = ao_app->get_blips(m_chatmessage[BLIPNAME]);
|
||||||
}
|
}
|
||||||
blip_player->set_blips(f_blips);
|
blip_player->set_blips(f_blips);
|
||||||
@ -4389,7 +4398,7 @@ void Courtroom::set_mute(bool p_muted, int p_cid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ui_muted->resize(ui_ic_chat_message->width(), ui_ic_chat_message->height());
|
ui_muted->resize(ui_ic_chat_message->width(), ui_ic_chat_message->height());
|
||||||
ui_muted->set_image("muted");
|
ui_muted->setImage("muted");
|
||||||
|
|
||||||
is_muted = p_muted;
|
is_muted = p_muted;
|
||||||
ui_ic_chat_message->setEnabled(!p_muted);
|
ui_ic_chat_message->setEnabled(!p_muted);
|
||||||
@ -4596,13 +4605,13 @@ void Courtroom::set_hp_bar(int p_bar, int p_state)
|
|||||||
int prev_state = p_state;
|
int prev_state = p_state;
|
||||||
if (p_bar == 1)
|
if (p_bar == 1)
|
||||||
{
|
{
|
||||||
ui_defense_bar->set_image("defensebar" + QString::number(p_state));
|
ui_defense_bar->setImage("defensebar" + QString::number(p_state));
|
||||||
prev_state = defense_bar_state;
|
prev_state = defense_bar_state;
|
||||||
defense_bar_state = p_state;
|
defense_bar_state = p_state;
|
||||||
}
|
}
|
||||||
else if (p_bar == 2)
|
else if (p_bar == 2)
|
||||||
{
|
{
|
||||||
ui_prosecution_bar->set_image("prosecutionbar" + QString::number(p_state));
|
ui_prosecution_bar->setImage("prosecutionbar" + QString::number(p_state));
|
||||||
prev_state = prosecution_bar_state;
|
prev_state = prosecution_bar_state;
|
||||||
prosecution_bar_state = p_state;
|
prosecution_bar_state = p_state;
|
||||||
}
|
}
|
||||||
@ -5483,7 +5492,7 @@ void Courtroom::on_pair_list_clicked(QModelIndex p_index)
|
|||||||
// Redo the character list.
|
// Redo the character list.
|
||||||
QStringList sorted_pair_list;
|
QStringList sorted_pair_list;
|
||||||
|
|
||||||
for (const char_type &i_char : qAsConst(char_list))
|
for (const CharacterSlot &i_char : qAsConst(char_list))
|
||||||
{
|
{
|
||||||
sorted_pair_list.append(i_char.name);
|
sorted_pair_list.append(i_char.name);
|
||||||
}
|
}
|
||||||
@ -5700,16 +5709,16 @@ void Courtroom::on_hold_it_clicked()
|
|||||||
{
|
{
|
||||||
if (objection_state == 1)
|
if (objection_state == 1)
|
||||||
{
|
{
|
||||||
ui_hold_it->set_image("holdit");
|
ui_hold_it->setImage("holdit");
|
||||||
objection_state = 0;
|
objection_state = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui_objection->set_image("objection");
|
ui_objection->setImage("objection");
|
||||||
ui_take_that->set_image("takethat");
|
ui_take_that->setImage("takethat");
|
||||||
ui_custom_objection->set_image("custom");
|
ui_custom_objection->setImage("custom");
|
||||||
|
|
||||||
ui_hold_it->set_image("holdit_selected");
|
ui_hold_it->setImage("holdit_selected");
|
||||||
objection_state = 1;
|
objection_state = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5720,16 +5729,16 @@ void Courtroom::on_objection_clicked()
|
|||||||
{
|
{
|
||||||
if (objection_state == 2)
|
if (objection_state == 2)
|
||||||
{
|
{
|
||||||
ui_objection->set_image("objection");
|
ui_objection->setImage("objection");
|
||||||
objection_state = 0;
|
objection_state = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui_hold_it->set_image("holdit");
|
ui_hold_it->setImage("holdit");
|
||||||
ui_take_that->set_image("takethat");
|
ui_take_that->setImage("takethat");
|
||||||
ui_custom_objection->set_image("custom");
|
ui_custom_objection->setImage("custom");
|
||||||
|
|
||||||
ui_objection->set_image("objection_selected");
|
ui_objection->setImage("objection_selected");
|
||||||
objection_state = 2;
|
objection_state = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5740,16 +5749,16 @@ void Courtroom::on_take_that_clicked()
|
|||||||
{
|
{
|
||||||
if (objection_state == 3)
|
if (objection_state == 3)
|
||||||
{
|
{
|
||||||
ui_take_that->set_image("takethat");
|
ui_take_that->setImage("takethat");
|
||||||
objection_state = 0;
|
objection_state = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui_objection->set_image("objection");
|
ui_objection->setImage("objection");
|
||||||
ui_hold_it->set_image("holdit");
|
ui_hold_it->setImage("holdit");
|
||||||
ui_custom_objection->set_image("custom");
|
ui_custom_objection->setImage("custom");
|
||||||
|
|
||||||
ui_take_that->set_image("takethat_selected");
|
ui_take_that->setImage("takethat_selected");
|
||||||
objection_state = 3;
|
objection_state = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5760,16 +5769,16 @@ void Courtroom::on_custom_objection_clicked()
|
|||||||
{
|
{
|
||||||
if (objection_state == 4)
|
if (objection_state == 4)
|
||||||
{
|
{
|
||||||
ui_custom_objection->set_image("custom");
|
ui_custom_objection->setImage("custom");
|
||||||
objection_state = 0;
|
objection_state = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui_objection->set_image("objection");
|
ui_objection->setImage("objection");
|
||||||
ui_take_that->set_image("takethat");
|
ui_take_that->setImage("takethat");
|
||||||
ui_hold_it->set_image("holdit");
|
ui_hold_it->setImage("holdit");
|
||||||
|
|
||||||
ui_custom_objection->set_image("custom_selected");
|
ui_custom_objection->setImage("custom_selected");
|
||||||
objection_state = 4;
|
objection_state = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5782,10 +5791,10 @@ void Courtroom::show_custom_objection_menu(const QPoint &pos)
|
|||||||
QAction *selecteditem = custom_obj_menu->exec(globalPos);
|
QAction *selecteditem = custom_obj_menu->exec(globalPos);
|
||||||
if (selecteditem)
|
if (selecteditem)
|
||||||
{
|
{
|
||||||
ui_objection->set_image("objection");
|
ui_objection->setImage("objection");
|
||||||
ui_take_that->set_image("takethat");
|
ui_take_that->setImage("takethat");
|
||||||
ui_hold_it->set_image("holdit");
|
ui_hold_it->setImage("holdit");
|
||||||
ui_custom_objection->set_image("custom_selected");
|
ui_custom_objection->setImage("custom_selected");
|
||||||
if (selecteditem->text() == ao_app->read_char_ini(current_char, "custom_name", "Shouts") || selecteditem->text() == "Default")
|
if (selecteditem->text() == ao_app->read_char_ini(current_char, "custom_name", "Shouts") || selecteditem->text() == "Default")
|
||||||
{
|
{
|
||||||
objection_custom = "";
|
objection_custom = "";
|
||||||
@ -5816,14 +5825,14 @@ void Courtroom::on_realization_clicked()
|
|||||||
on_effects_dropdown_changed(ui_effects_dropdown->currentIndex());
|
on_effects_dropdown_changed(ui_effects_dropdown->currentIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
ui_realization->set_image("realization_pressed");
|
ui_realization->setImage("realization_pressed");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
realization_state = 0;
|
realization_state = 0;
|
||||||
ui_effects_dropdown->setCurrentIndex(0);
|
ui_effects_dropdown->setCurrentIndex(0);
|
||||||
on_effects_dropdown_changed(ui_effects_dropdown->currentIndex());
|
on_effects_dropdown_changed(ui_effects_dropdown->currentIndex());
|
||||||
ui_realization->set_image("realization");
|
ui_realization->setImage("realization");
|
||||||
}
|
}
|
||||||
|
|
||||||
ui_ic_chat_message->setFocus();
|
ui_ic_chat_message->setFocus();
|
||||||
@ -5834,12 +5843,12 @@ void Courtroom::on_screenshake_clicked()
|
|||||||
if (screenshake_state == 0)
|
if (screenshake_state == 0)
|
||||||
{
|
{
|
||||||
screenshake_state = 1;
|
screenshake_state = 1;
|
||||||
ui_screenshake->set_image("screenshake_pressed");
|
ui_screenshake->setImage("screenshake_pressed");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
screenshake_state = 0;
|
screenshake_state = 0;
|
||||||
ui_screenshake->set_image("screenshake");
|
ui_screenshake->setImage("screenshake");
|
||||||
}
|
}
|
||||||
|
|
||||||
ui_ic_chat_message->setFocus();
|
ui_ic_chat_message->setFocus();
|
||||||
@ -5854,13 +5863,13 @@ void Courtroom::on_mute_clicked()
|
|||||||
ui_pair_offset_spinbox->hide();
|
ui_pair_offset_spinbox->hide();
|
||||||
ui_pair_vert_offset_spinbox->hide();
|
ui_pair_vert_offset_spinbox->hide();
|
||||||
ui_pair_order_dropdown->hide();
|
ui_pair_order_dropdown->hide();
|
||||||
ui_pair_button->set_image("pair_button");
|
ui_pair_button->setImage("pair_button");
|
||||||
ui_mute->set_image("mute_pressed");
|
ui_mute->setImage("mute_pressed");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui_mute_list->hide();
|
ui_mute_list->hide();
|
||||||
ui_mute->set_image("mute");
|
ui_mute->setImage("mute");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5876,8 +5885,8 @@ void Courtroom::on_pair_clicked()
|
|||||||
}
|
}
|
||||||
ui_pair_order_dropdown->show();
|
ui_pair_order_dropdown->show();
|
||||||
ui_mute_list->hide();
|
ui_mute_list->hide();
|
||||||
ui_mute->set_image("mute");
|
ui_mute->setImage("mute");
|
||||||
ui_pair_button->set_image("pair_button_pressed");
|
ui_pair_button->setImage("pair_button_pressed");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -5885,7 +5894,7 @@ void Courtroom::on_pair_clicked()
|
|||||||
ui_pair_offset_spinbox->hide();
|
ui_pair_offset_spinbox->hide();
|
||||||
ui_pair_vert_offset_spinbox->hide();
|
ui_pair_vert_offset_spinbox->hide();
|
||||||
ui_pair_order_dropdown->hide();
|
ui_pair_order_dropdown->hide();
|
||||||
ui_pair_button->set_image("pair_button");
|
ui_pair_button->setImage("pair_button");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6271,8 +6280,8 @@ void Courtroom::regenerate_ic_chatlog()
|
|||||||
foreach (ChatLogPiece item, ic_chatlog_history)
|
foreach (ChatLogPiece item, ic_chatlog_history)
|
||||||
{
|
{
|
||||||
QString message = item.message;
|
QString message = item.message;
|
||||||
QString name = ui_showname_enable->isChecked() ? item.showname : item.name;
|
QString name = ui_showname_enable->isChecked() ? item.character_name : item.character;
|
||||||
append_ic_text(message, name, item.action, item.color, item.selfname, item.datetime.toLocalTime());
|
append_ic_text(message, name, item.action, item.color, item.local_player, item.timestamp.toLocalTime());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ public:
|
|||||||
|
|
||||||
void update_audio_volume();
|
void update_audio_volume();
|
||||||
|
|
||||||
void append_char(char_type p_char);
|
void append_char(CharacterSlot p_char);
|
||||||
void append_music(QString f_music);
|
void append_music(QString f_music);
|
||||||
void append_area(QString f_area);
|
void append_area(QString f_area);
|
||||||
void clear_chars();
|
void clear_chars();
|
||||||
@ -138,7 +138,7 @@ public:
|
|||||||
void set_pos_dropdown(QStringList pos_dropdowns);
|
void set_pos_dropdown(QStringList pos_dropdowns);
|
||||||
|
|
||||||
// sets the evidence list member variable to argument
|
// sets the evidence list member variable to argument
|
||||||
void set_evidence_list(QVector<evi_type> &p_evi_list);
|
void set_evidence_list(QVector<EvidenceItem> &p_evi_list);
|
||||||
|
|
||||||
// called when a DONE#% from the server was received
|
// called when a DONE#% from the server was received
|
||||||
void done_received();
|
void done_received();
|
||||||
@ -331,8 +331,8 @@ private:
|
|||||||
// 0 = in front, 1 = behind
|
// 0 = in front, 1 = behind
|
||||||
int pair_order = 0;
|
int pair_order = 0;
|
||||||
|
|
||||||
QVector<char_type> char_list;
|
QVector<CharacterSlot> char_list;
|
||||||
QVector<evi_type> evidence_list;
|
QVector<EvidenceItem> evidence_list;
|
||||||
QVector<QString> music_list;
|
QVector<QString> music_list;
|
||||||
QVector<QString> area_list;
|
QVector<QString> area_list;
|
||||||
|
|
||||||
@ -553,9 +553,9 @@ private:
|
|||||||
int emote_rows = 2;
|
int emote_rows = 2;
|
||||||
int max_emotes_on_page = 10;
|
int max_emotes_on_page = 10;
|
||||||
|
|
||||||
QVector<evi_type> local_evidence_list;
|
QVector<EvidenceItem> local_evidence_list;
|
||||||
QVector<evi_type> private_evidence_list;
|
QVector<EvidenceItem> private_evidence_list;
|
||||||
QVector<evi_type> global_evidence_list;
|
QVector<EvidenceItem> global_evidence_list;
|
||||||
|
|
||||||
// false = use private_evidence_list
|
// false = use private_evidence_list
|
||||||
bool current_evidence_global = true;
|
bool current_evidence_global = true;
|
||||||
@ -938,7 +938,7 @@ private Q_SLOTS:
|
|||||||
void on_evidence_load_clicked();
|
void on_evidence_load_clicked();
|
||||||
void evidence_save(QString filename);
|
void evidence_save(QString filename);
|
||||||
void evidence_load(QString filename);
|
void evidence_load(QString filename);
|
||||||
bool compare_evidence_changed(evi_type evi_a, evi_type evi_b);
|
bool compare_evidence_changed(EvidenceItem evi_a, EvidenceItem evi_b);
|
||||||
|
|
||||||
void on_back_to_lobby_clicked();
|
void on_back_to_lobby_clicked();
|
||||||
|
|
||||||
|
@ -3,35 +3,24 @@
|
|||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
enum connection_type
|
enum ServerConnectionType
|
||||||
{
|
{
|
||||||
TCP,
|
TcpServerConnection,
|
||||||
WEBSOCKETS,
|
WebSocketServerConnection,
|
||||||
};
|
};
|
||||||
|
|
||||||
static QMap<QString, connection_type> to_connection_type = {{"tcp", connection_type::TCP}, {"ws", connection_type::WEBSOCKETS}};
|
static const QMap<QString, ServerConnectionType> SERVER_CONNECTION_TYPE_STRING_MAP = {{"tcp", ServerConnectionType::TcpServerConnection}, {"ws", ServerConnectionType::WebSocketServerConnection}};
|
||||||
|
|
||||||
struct server_type
|
struct ServerInfo
|
||||||
{
|
{
|
||||||
QString name;
|
QString name;
|
||||||
QString desc;
|
QString description;
|
||||||
QString ip;
|
QString ip;
|
||||||
int port;
|
int port;
|
||||||
connection_type socket_type;
|
ServerConnectionType socket_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct emote_type
|
struct CharacterSlot
|
||||||
{
|
|
||||||
QString comment;
|
|
||||||
QString preanim;
|
|
||||||
QString anim;
|
|
||||||
int mod;
|
|
||||||
QString sfx_name;
|
|
||||||
int sfx_delay;
|
|
||||||
int sfx_duration;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct char_type
|
|
||||||
{
|
{
|
||||||
QString name;
|
QString name;
|
||||||
QString description;
|
QString description;
|
||||||
@ -39,44 +28,13 @@ struct char_type
|
|||||||
bool taken;
|
bool taken;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct evi_type
|
struct EvidenceItem
|
||||||
{
|
{
|
||||||
QString name;
|
QString name;
|
||||||
QString description;
|
QString description;
|
||||||
QString image;
|
QString image;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct chatmessage_type
|
|
||||||
{
|
|
||||||
QString message;
|
|
||||||
QString character;
|
|
||||||
QString side;
|
|
||||||
QString sfx_name;
|
|
||||||
QString pre_emote;
|
|
||||||
QString emote;
|
|
||||||
int emote_modifier;
|
|
||||||
int objection_modifier;
|
|
||||||
int realization;
|
|
||||||
int text_color;
|
|
||||||
int evidence;
|
|
||||||
int cid;
|
|
||||||
int sfx_delay;
|
|
||||||
int flip;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct area_type
|
|
||||||
{
|
|
||||||
QString name;
|
|
||||||
QString background;
|
|
||||||
bool passworded;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct pos_type
|
|
||||||
{
|
|
||||||
int x;
|
|
||||||
int y;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct pos_size_type
|
struct pos_size_type
|
||||||
{
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
|
@ -66,7 +66,7 @@ void DemoServer::accept_connection()
|
|||||||
{
|
{
|
||||||
sc_packet = demo_data.dequeue();
|
sc_packet = demo_data.dequeue();
|
||||||
AOPacket sc(sc_packet);
|
AOPacket sc(sc_packet);
|
||||||
num_chars = sc.get_content().length();
|
num_chars = sc.content().length();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -94,7 +94,7 @@ void DemoServer::recv_data()
|
|||||||
QString in_data = QString::fromUtf8(client_sock->readAll());
|
QString in_data = QString::fromUtf8(client_sock->readAll());
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
const QStringList packet_list = in_data.split("%", QString::SplitBehavior(QString::SkipEmptyParts));
|
const QStringList packet_list = in_data.split("%", QString::SkipEmptyParts);
|
||||||
#else
|
#else
|
||||||
const QStringList packet_list = in_data.split("%", Qt::SkipEmptyParts);
|
const QStringList packet_list = in_data.split("%", Qt::SkipEmptyParts);
|
||||||
#endif
|
#endif
|
||||||
@ -143,8 +143,8 @@ void DemoServer::handle_packet(AOPacket p_packet)
|
|||||||
// Also, at some point, I will make akashit
|
// Also, at some point, I will make akashit
|
||||||
// into a shared library.
|
// into a shared library.
|
||||||
|
|
||||||
QString header = p_packet.get_header();
|
QString header = p_packet.header();
|
||||||
QStringList contents = p_packet.get_content();
|
QStringList contents = p_packet.content();
|
||||||
|
|
||||||
if (header == "HI")
|
if (header == "HI")
|
||||||
{
|
{
|
||||||
|
@ -44,10 +44,10 @@ void Courtroom::refresh_emotes()
|
|||||||
set_size_and_pos(ui_emotes, "emotes");
|
set_size_and_pos(ui_emotes, "emotes");
|
||||||
|
|
||||||
set_size_and_pos(ui_emote_left, "emote_left");
|
set_size_and_pos(ui_emote_left, "emote_left");
|
||||||
ui_emote_left->set_image("arrow_left");
|
ui_emote_left->setImage("arrow_left");
|
||||||
|
|
||||||
set_size_and_pos(ui_emote_right, "emote_right");
|
set_size_and_pos(ui_emote_right, "emote_right");
|
||||||
ui_emote_right->set_image("arrow_right");
|
ui_emote_right->setImage("arrow_right");
|
||||||
|
|
||||||
QPoint f_spacing = ao_app->get_button_spacing("emote_button_spacing", "courtroom_design.ini");
|
QPoint f_spacing = ao_app->get_button_spacing("emote_button_spacing", "courtroom_design.ini");
|
||||||
QPoint p_point = ao_app->get_button_spacing("emote_button_size", "courtroom_design.ini");
|
QPoint p_point = ao_app->get_button_spacing("emote_button_size", "courtroom_design.ini");
|
||||||
@ -73,20 +73,18 @@ void Courtroom::refresh_emotes()
|
|||||||
|
|
||||||
QString selected_image = ao_app->get_image_suffix(ao_app->get_theme_path("emote_selected", ""), true);
|
QString selected_image = ao_app->get_image_suffix(ao_app->get_theme_path("emote_selected", ""), true);
|
||||||
|
|
||||||
for (int n = 0; n < max_emotes_on_page; ++n)
|
for (int i = 0; i < max_emotes_on_page; ++i)
|
||||||
{
|
{
|
||||||
int x_pos = (button_width + x_spacing) * x_mod_count;
|
int x_pos = (button_width + x_spacing) * x_mod_count;
|
||||||
int y_pos = (button_height + y_spacing) * y_mod_count;
|
int y_pos = (button_height + y_spacing) * y_mod_count;
|
||||||
|
|
||||||
AOEmoteButton *f_emote = new AOEmoteButton(ao_app, x_pos, y_pos, button_width, button_height, ui_emotes);
|
AOEmoteButton *f_emote = new AOEmoteButton(i, button_width, button_height, ao_app, ui_emotes);
|
||||||
f_emote->set_selected_image(selected_image);
|
f_emote->setSelectedImage(selected_image);
|
||||||
|
f_emote->move(x_pos, y_pos);
|
||||||
ui_emote_list.append(f_emote);
|
ui_emote_list.append(f_emote);
|
||||||
|
|
||||||
f_emote->set_id(n);
|
|
||||||
|
|
||||||
f_emote->setContextMenuPolicy(Qt::CustomContextMenu);
|
f_emote->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
connect(f_emote, &AOEmoteButton::emote_clicked, this, &Courtroom::on_emote_clicked);
|
connect(f_emote, &AOEmoteButton::emoteClicked, this, &Courtroom::on_emote_clicked);
|
||||||
|
|
||||||
connect(f_emote, &AOEmoteButton::customContextMenuRequested, this, &Courtroom::show_emote_menu);
|
connect(f_emote, &AOEmoteButton::customContextMenuRequested, this, &Courtroom::show_emote_menu);
|
||||||
|
|
||||||
++x_mod_count;
|
++x_mod_count;
|
||||||
@ -154,11 +152,11 @@ void Courtroom::set_emote_page()
|
|||||||
|
|
||||||
if (n_real_emote == current_emote)
|
if (n_real_emote == current_emote)
|
||||||
{
|
{
|
||||||
f_emote->set_char_image(current_char, n_real_emote, true);
|
f_emote->setImage(current_char, n_real_emote, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
f_emote->set_char_image(current_char, n_real_emote, false);
|
f_emote->setImage(current_char, n_real_emote, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
f_emote->show();
|
f_emote->show();
|
||||||
@ -191,7 +189,7 @@ void Courtroom::select_emote(int p_id)
|
|||||||
|
|
||||||
if (current_emote >= min && current_emote <= max)
|
if (current_emote >= min && current_emote <= max)
|
||||||
{
|
{
|
||||||
ui_emote_list.at(current_emote % max_emotes_on_page)->set_char_image(current_char, current_emote, false);
|
ui_emote_list.at(current_emote % max_emotes_on_page)->setImage(current_char, current_emote, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int old_emote = current_emote;
|
int old_emote = current_emote;
|
||||||
@ -200,7 +198,7 @@ void Courtroom::select_emote(int p_id)
|
|||||||
|
|
||||||
if (current_emote >= min && current_emote <= max)
|
if (current_emote >= min && current_emote <= max)
|
||||||
{
|
{
|
||||||
ui_emote_list.at(current_emote % max_emotes_on_page)->set_char_image(current_char, current_emote, true);
|
ui_emote_list.at(current_emote % max_emotes_on_page)->setImage(current_char, current_emote, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
int emote_mod = ao_app->get_emote_mod(current_char, current_emote);
|
int emote_mod = ao_app->get_emote_mod(current_char, current_emote);
|
||||||
@ -257,11 +255,11 @@ void Courtroom::show_emote_menu(const QPoint &pos)
|
|||||||
if (qobject_cast<AOEmoteButton *>(button))
|
if (qobject_cast<AOEmoteButton *>(button))
|
||||||
{
|
{
|
||||||
AOEmoteButton *emote_button = qobject_cast<AOEmoteButton *>(sender());
|
AOEmoteButton *emote_button = qobject_cast<AOEmoteButton *>(sender());
|
||||||
id = emote_button->get_id();
|
id = emote_button->id();
|
||||||
}
|
}
|
||||||
int emote_num = id + max_emotes_on_page * current_emote_page;
|
int emote_num = id + max_emotes_on_page * current_emote_page;
|
||||||
emote_menu->clear();
|
emote_menu->clear();
|
||||||
emote_menu->setDefaultAction(emote_menu->addAction("Preview Selected", this, [=] {
|
emote_menu->setDefaultAction(emote_menu->addAction("Preview Selected", this, [this] {
|
||||||
emote_preview->show();
|
emote_preview->show();
|
||||||
emote_preview->raise();
|
emote_preview->raise();
|
||||||
emote_preview->set_widgets();
|
emote_preview->set_widgets();
|
||||||
@ -271,19 +269,19 @@ void Courtroom::show_emote_menu(const QPoint &pos)
|
|||||||
QString f_pre = ao_app->get_pre_emote(current_char, emote_num);
|
QString f_pre = ao_app->get_pre_emote(current_char, emote_num);
|
||||||
if (!f_pre.isEmpty() && f_pre != "-")
|
if (!f_pre.isEmpty() && f_pre != "-")
|
||||||
{
|
{
|
||||||
emote_menu->addAction("Preview pre: " + f_pre, this, [=] { preview_emote(f_pre); });
|
emote_menu->addAction("Preview pre: " + f_pre, this, [this, f_pre] { preview_emote(f_pre); });
|
||||||
}
|
}
|
||||||
|
|
||||||
QString f_emote = ao_app->get_emote(current_char, emote_num);
|
QString f_emote = ao_app->get_emote(current_char, emote_num);
|
||||||
if (!f_emote.isEmpty())
|
if (!f_emote.isEmpty())
|
||||||
{
|
{
|
||||||
emote_menu->addAction("Preview idle: " + f_emote, this, [=] { preview_emote("(a)" + f_emote); });
|
emote_menu->addAction("Preview idle: " + f_emote, this, [this, f_emote] { preview_emote("(a)" + f_emote); });
|
||||||
emote_menu->addAction("Preview talk: " + f_emote, this, [=] { preview_emote("(b)" + f_emote); });
|
emote_menu->addAction("Preview talk: " + f_emote, this, [this, f_emote] { preview_emote("(b)" + f_emote); });
|
||||||
QStringList c_paths = {ao_app->get_image_suffix(ao_app->get_character_path(current_char, "(c)" + f_emote)), ao_app->get_image_suffix(ao_app->get_character_path(current_char, "(c)/" + f_emote))};
|
QStringList c_paths = {ao_app->get_image_suffix(ao_app->get_character_path(current_char, "(c)" + f_emote)), ao_app->get_image_suffix(ao_app->get_character_path(current_char, "(c)/" + f_emote))};
|
||||||
// if there is a (c) animation
|
// if there is a (c) animation
|
||||||
if (file_exists(ui_vp_player_char->find_image(c_paths)))
|
if (file_exists(ui_vp_player_char->find_image(c_paths)))
|
||||||
{
|
{
|
||||||
emote_menu->addAction("Preview segway: " + f_emote, this, [=] { preview_emote("(c)" + f_emote); });
|
emote_menu->addAction("Preview segway: " + f_emote, this, [this, f_emote] { preview_emote("(c)" + f_emote); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emote_menu->popup(button->mapToGlobal(pos));
|
emote_menu->popup(button->mapToGlobal(pos));
|
||||||
|
108
src/evidence.cpp
108
src/evidence.cpp
@ -100,17 +100,17 @@ void Courtroom::refresh_evidence()
|
|||||||
ui_evidence_list.clear();
|
ui_evidence_list.clear();
|
||||||
|
|
||||||
set_size_and_pos(ui_evidence_button, "evidence_button");
|
set_size_and_pos(ui_evidence_button, "evidence_button");
|
||||||
ui_evidence_button->set_image("evidence_button");
|
ui_evidence_button->setImage("evidence_button");
|
||||||
ui_evidence_button->setToolTip(tr("Bring up the Evidence screen."));
|
ui_evidence_button->setToolTip(tr("Bring up the Evidence screen."));
|
||||||
|
|
||||||
set_size_and_pos(ui_evidence, "evidence_background");
|
set_size_and_pos(ui_evidence, "evidence_background");
|
||||||
if (current_evidence_global)
|
if (current_evidence_global)
|
||||||
{
|
{
|
||||||
ui_evidence->set_image("evidence_background");
|
ui_evidence->setImage("evidence_background");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui_evidence->set_image("evidence_background_private");
|
ui_evidence->setImage("evidence_background_private");
|
||||||
}
|
}
|
||||||
|
|
||||||
set_size_and_pos(ui_evidence_name, "evidence_name");
|
set_size_and_pos(ui_evidence_name, "evidence_name");
|
||||||
@ -118,63 +118,63 @@ void Courtroom::refresh_evidence()
|
|||||||
set_size_and_pos(ui_evidence_buttons, "evidence_buttons");
|
set_size_and_pos(ui_evidence_buttons, "evidence_buttons");
|
||||||
|
|
||||||
set_size_and_pos(ui_evidence_left, "evidence_left");
|
set_size_and_pos(ui_evidence_left, "evidence_left");
|
||||||
ui_evidence_left->set_image("arrow_left");
|
ui_evidence_left->setImage("arrow_left");
|
||||||
|
|
||||||
set_size_and_pos(ui_evidence_right, "evidence_right");
|
set_size_and_pos(ui_evidence_right, "evidence_right");
|
||||||
ui_evidence_right->set_image("arrow_right");
|
ui_evidence_right->setImage("arrow_right");
|
||||||
|
|
||||||
set_size_and_pos(ui_evidence_present, "evidence_present");
|
set_size_and_pos(ui_evidence_present, "evidence_present");
|
||||||
ui_evidence_present->set_image("present");
|
ui_evidence_present->setImage("present");
|
||||||
|
|
||||||
set_size_and_pos(ui_evidence_overlay, "evidence_overlay");
|
set_size_and_pos(ui_evidence_overlay, "evidence_overlay");
|
||||||
if (current_evidence_global)
|
if (current_evidence_global)
|
||||||
{
|
{
|
||||||
ui_evidence_overlay->set_image("evidence_overlay");
|
ui_evidence_overlay->setImage("evidence_overlay");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui_evidence_overlay->set_image("evidence_overlay_private");
|
ui_evidence_overlay->setImage("evidence_overlay_private");
|
||||||
}
|
}
|
||||||
|
|
||||||
set_size_and_pos(ui_evidence_delete, "evidence_delete");
|
set_size_and_pos(ui_evidence_delete, "evidence_delete");
|
||||||
ui_evidence_delete->set_image("evidence_delete");
|
ui_evidence_delete->setImage("evidence_delete");
|
||||||
|
|
||||||
set_size_and_pos(ui_evidence_image_name, "evidence_image_name");
|
set_size_and_pos(ui_evidence_image_name, "evidence_image_name");
|
||||||
|
|
||||||
set_size_and_pos(ui_evidence_image_button, "evidence_image_button");
|
set_size_and_pos(ui_evidence_image_button, "evidence_image_button");
|
||||||
|
|
||||||
set_size_and_pos(ui_evidence_x, "evidence_x");
|
set_size_and_pos(ui_evidence_x, "evidence_x");
|
||||||
ui_evidence_x->set_image("evidence_x");
|
ui_evidence_x->setImage("evidence_x");
|
||||||
|
|
||||||
set_size_and_pos(ui_evidence_ok, "evidence_ok");
|
set_size_and_pos(ui_evidence_ok, "evidence_ok");
|
||||||
ui_evidence_ok->set_image("evidence_ok");
|
ui_evidence_ok->setImage("evidence_ok");
|
||||||
|
|
||||||
set_size_and_pos(ui_evidence_switch, "evidence_switch");
|
set_size_and_pos(ui_evidence_switch, "evidence_switch");
|
||||||
if (current_evidence_global)
|
if (current_evidence_global)
|
||||||
{
|
{
|
||||||
ui_evidence_switch->set_image("evidence_global");
|
ui_evidence_switch->setImage("evidence_global");
|
||||||
ui_evidence_switch->setToolTip(tr("Switch evidence to private inventory."));
|
ui_evidence_switch->setToolTip(tr("Switch evidence to private inventory."));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui_evidence_switch->set_image("evidence_private");
|
ui_evidence_switch->setImage("evidence_private");
|
||||||
ui_evidence_switch->setToolTip(tr("Switch evidence to global inventory."));
|
ui_evidence_switch->setToolTip(tr("Switch evidence to global inventory."));
|
||||||
}
|
}
|
||||||
|
|
||||||
set_size_and_pos(ui_evidence_transfer, "evidence_transfer");
|
set_size_and_pos(ui_evidence_transfer, "evidence_transfer");
|
||||||
if (current_evidence_global)
|
if (current_evidence_global)
|
||||||
{
|
{
|
||||||
ui_evidence_transfer->set_image("evidence_transfer");
|
ui_evidence_transfer->setImage("evidence_transfer");
|
||||||
ui_evidence_transfer->setToolTip(tr("Transfer evidence to private inventory."));
|
ui_evidence_transfer->setToolTip(tr("Transfer evidence to private inventory."));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui_evidence_transfer->set_image("evidence_transfer_private");
|
ui_evidence_transfer->setImage("evidence_transfer_private");
|
||||||
ui_evidence_transfer->setToolTip(tr("Transfer evidence to global inventory."));
|
ui_evidence_transfer->setToolTip(tr("Transfer evidence to global inventory."));
|
||||||
}
|
}
|
||||||
|
|
||||||
set_size_and_pos(ui_evidence_save, "evidence_save");
|
set_size_and_pos(ui_evidence_save, "evidence_save");
|
||||||
ui_evidence_save->set_image("evidence_save");
|
ui_evidence_save->setImage("evidence_save");
|
||||||
if (current_evidence_global)
|
if (current_evidence_global)
|
||||||
{
|
{
|
||||||
ui_evidence_save->hide();
|
ui_evidence_save->hide();
|
||||||
@ -185,7 +185,7 @@ void Courtroom::refresh_evidence()
|
|||||||
}
|
}
|
||||||
|
|
||||||
set_size_and_pos(ui_evidence_load, "evidence_load");
|
set_size_and_pos(ui_evidence_load, "evidence_load");
|
||||||
ui_evidence_load->set_image("evidence_load");
|
ui_evidence_load->setImage("evidence_load");
|
||||||
if (current_evidence_global)
|
if (current_evidence_global)
|
||||||
{
|
{
|
||||||
ui_evidence_load->hide();
|
ui_evidence_load->hide();
|
||||||
@ -213,20 +213,18 @@ void Courtroom::refresh_evidence()
|
|||||||
|
|
||||||
max_evidence_on_page = evidence_columns * evidence_rows;
|
max_evidence_on_page = evidence_columns * evidence_rows;
|
||||||
|
|
||||||
for (int n = 0; n < max_evidence_on_page; ++n)
|
for (int i = 0; i < max_evidence_on_page; ++i)
|
||||||
{
|
{
|
||||||
int x_pos = (button_width + x_spacing) * x_mod_count;
|
int x_pos = (button_width + x_spacing) * x_mod_count;
|
||||||
int y_pos = (button_height + y_spacing) * y_mod_count;
|
int y_pos = (button_height + y_spacing) * y_mod_count;
|
||||||
|
|
||||||
AOEvidenceButton *f_evidence = new AOEvidenceButton(ao_app, x_pos, y_pos, button_width, button_height, ui_evidence_buttons);
|
AOEvidenceButton *f_evidence = new AOEvidenceButton(i, button_width, button_height, ao_app, ui_evidence_buttons);
|
||||||
|
|
||||||
ui_evidence_list.append(f_evidence);
|
ui_evidence_list.append(f_evidence);
|
||||||
|
f_evidence->move(x_pos, y_pos);
|
||||||
|
|
||||||
f_evidence->set_id(n);
|
connect(f_evidence, &AOEvidenceButton::evidenceClicked, this, &Courtroom::on_evidence_clicked);
|
||||||
|
connect(f_evidence, &AOEvidenceButton::evidenceDoubleClicked, this, &Courtroom::on_evidence_double_clicked);
|
||||||
connect(f_evidence, &AOEvidenceButton::evidence_clicked, this, &Courtroom::on_evidence_clicked);
|
connect(f_evidence, &AOEvidenceButton::mouseoverUpdated, this, &Courtroom::on_evidence_hover);
|
||||||
connect(f_evidence, &AOEvidenceButton::evidence_double_clicked, this, &Courtroom::on_evidence_double_clicked);
|
|
||||||
connect(f_evidence, &AOEvidenceButton::on_hover, this, &Courtroom::on_evidence_hover);
|
|
||||||
|
|
||||||
++x_mod_count;
|
++x_mod_count;
|
||||||
|
|
||||||
@ -238,7 +236,7 @@ void Courtroom::refresh_evidence()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Courtroom::set_evidence_list(QVector<evi_type> &p_evi_list)
|
void Courtroom::set_evidence_list(QVector<EvidenceItem> &p_evi_list)
|
||||||
{
|
{
|
||||||
global_evidence_list = p_evi_list;
|
global_evidence_list = p_evi_list;
|
||||||
if (!current_evidence_global)
|
if (!current_evidence_global)
|
||||||
@ -247,7 +245,7 @@ void Courtroom::set_evidence_list(QVector<evi_type> &p_evi_list)
|
|||||||
// thing
|
// thing
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<evi_type> old_list = local_evidence_list;
|
QVector<EvidenceItem> old_list = local_evidence_list;
|
||||||
local_evidence_list.clear();
|
local_evidence_list.clear();
|
||||||
local_evidence_list = p_evi_list;
|
local_evidence_list = p_evi_list;
|
||||||
|
|
||||||
@ -351,26 +349,26 @@ void Courtroom::set_evidence_page()
|
|||||||
int n_real_evidence = n_evidence_button + current_evidence_page * max_evidence_on_page;
|
int n_real_evidence = n_evidence_button + current_evidence_page * max_evidence_on_page;
|
||||||
AOEvidenceButton *f_evidence_button = ui_evidence_list.at(n_evidence_button);
|
AOEvidenceButton *f_evidence_button = ui_evidence_list.at(n_evidence_button);
|
||||||
|
|
||||||
f_evidence_button->set_selected(false);
|
f_evidence_button->setSelected(false);
|
||||||
f_evidence_button->setToolTip("");
|
f_evidence_button->setToolTip("");
|
||||||
if (n_real_evidence == (total_evidence - 1))
|
if (n_real_evidence == (total_evidence - 1))
|
||||||
{
|
{
|
||||||
f_evidence_button->set_theme_image("addevidence.png");
|
f_evidence_button->setThemeImage("addevidence.png");
|
||||||
}
|
}
|
||||||
else if (n_real_evidence < (total_evidence - 1))
|
else if (n_real_evidence < (total_evidence - 1))
|
||||||
{
|
{
|
||||||
f_evidence_button->set_image(local_evidence_list.at(n_real_evidence).image);
|
f_evidence_button->setImage(local_evidence_list.at(n_real_evidence).image);
|
||||||
|
|
||||||
if (n_real_evidence == current_evidence)
|
if (n_real_evidence == current_evidence)
|
||||||
{
|
{
|
||||||
f_evidence_button->set_selected(true);
|
f_evidence_button->setSelected(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
f_evidence_button->setToolTip(QString::number(n_real_evidence + 1) + ": " + local_evidence_list.at(n_real_evidence).name);
|
f_evidence_button->setToolTip(QString::number(n_real_evidence + 1) + ": " + local_evidence_list.at(n_real_evidence).name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
f_evidence_button->set_image("");
|
f_evidence_button->setImage("");
|
||||||
}
|
}
|
||||||
|
|
||||||
f_evidence_button->show();
|
f_evidence_button->show();
|
||||||
@ -455,7 +453,7 @@ void Courtroom::on_evidence_clicked(int p_id)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
evi_type f_evi;
|
EvidenceItem f_evi;
|
||||||
f_evi.name = "<name>";
|
f_evi.name = "<name>";
|
||||||
f_evi.description = "<description>";
|
f_evi.description = "<description>";
|
||||||
f_evi.image = "empty.png";
|
f_evi.image = "empty.png";
|
||||||
@ -485,10 +483,10 @@ void Courtroom::on_evidence_clicked(int p_id)
|
|||||||
ui_evidence_name->setText(local_evidence_list.at(f_real_id).name);
|
ui_evidence_name->setText(local_evidence_list.at(f_real_id).name);
|
||||||
for (AOEvidenceButton *i_button : qAsConst(ui_evidence_list))
|
for (AOEvidenceButton *i_button : qAsConst(ui_evidence_list))
|
||||||
{
|
{
|
||||||
i_button->set_selected(false);
|
i_button->setSelected(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
ui_evidence_list.at(p_id)->set_selected(true);
|
ui_evidence_list.at(p_id)->setSelected(true);
|
||||||
current_evidence = f_real_id;
|
current_evidence = f_real_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -512,18 +510,18 @@ void Courtroom::on_evidence_double_clicked(int p_id)
|
|||||||
|
|
||||||
for (AOEvidenceButton *i_button : qAsConst(ui_evidence_list))
|
for (AOEvidenceButton *i_button : qAsConst(ui_evidence_list))
|
||||||
{
|
{
|
||||||
i_button->set_selected(false);
|
i_button->setSelected(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have to check if the ID is on the currently displayed page.
|
// We have to check if the ID is on the currently displayed page.
|
||||||
// This is because SOMEONE allowed the switching of pages while evidence is still being edited.
|
// This is because SOMEONE allowed the switching of pages while evidence is still being edited.
|
||||||
if (p_id < ui_evidence_list.count())
|
if (p_id < ui_evidence_list.count())
|
||||||
{
|
{
|
||||||
ui_evidence_list.at(p_id)->set_selected(true);
|
ui_evidence_list.at(p_id)->setSelected(true);
|
||||||
}
|
}
|
||||||
current_evidence = f_real_id;
|
current_evidence = f_real_id;
|
||||||
|
|
||||||
evi_type f_evi = local_evidence_list.at(f_real_id);
|
EvidenceItem f_evi = local_evidence_list.at(f_real_id);
|
||||||
|
|
||||||
ui_evidence_description->clear();
|
ui_evidence_description->clear();
|
||||||
ui_evidence_description->appendPlainText(f_evi.description);
|
ui_evidence_description->appendPlainText(f_evi.description);
|
||||||
@ -599,11 +597,11 @@ void Courtroom::on_evidence_present_clicked()
|
|||||||
}
|
}
|
||||||
if (is_presenting_evidence)
|
if (is_presenting_evidence)
|
||||||
{
|
{
|
||||||
ui_evidence_present->set_image("present");
|
ui_evidence_present->setImage("present");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui_evidence_present->set_image("present_disabled");
|
ui_evidence_present->setImage("present_disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
is_presenting_evidence = !is_presenting_evidence;
|
is_presenting_evidence = !is_presenting_evidence;
|
||||||
@ -672,7 +670,7 @@ void Courtroom::on_evidence_ok_clicked()
|
|||||||
ui_evidence_ok->hide();
|
ui_evidence_ok->hide();
|
||||||
if (current_evidence < local_evidence_list.size())
|
if (current_evidence < local_evidence_list.size())
|
||||||
{
|
{
|
||||||
evi_type f_evi = local_evidence_list.at(current_evidence);
|
EvidenceItem f_evi = local_evidence_list.at(current_evidence);
|
||||||
if (current_evidence_global)
|
if (current_evidence_global)
|
||||||
{
|
{
|
||||||
QStringList f_contents;
|
QStringList f_contents;
|
||||||
@ -717,7 +715,7 @@ void Courtroom::on_evidence_transfer_clicked()
|
|||||||
QString name;
|
QString name;
|
||||||
if (!current_evidence_global) // Transfer private evidence to global
|
if (!current_evidence_global) // Transfer private evidence to global
|
||||||
{
|
{
|
||||||
evi_type f_evi = local_evidence_list.at(current_evidence);
|
EvidenceItem f_evi = local_evidence_list.at(current_evidence);
|
||||||
|
|
||||||
QStringList f_contents;
|
QStringList f_contents;
|
||||||
f_contents.append(f_evi.name);
|
f_contents.append(f_evi.name);
|
||||||
@ -729,7 +727,7 @@ void Courtroom::on_evidence_transfer_clicked()
|
|||||||
}
|
}
|
||||||
else // Transfer global evidence to private
|
else // Transfer global evidence to private
|
||||||
{
|
{
|
||||||
evi_type f_evi = local_evidence_list.at(current_evidence);
|
EvidenceItem f_evi = local_evidence_list.at(current_evidence);
|
||||||
name = f_evi.name;
|
name = f_evi.name;
|
||||||
private_evidence_list.append(f_evi);
|
private_evidence_list.append(f_evi);
|
||||||
|
|
||||||
@ -751,7 +749,7 @@ void Courtroom::on_evidence_edited()
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
evi_type fake_evidence;
|
EvidenceItem fake_evidence;
|
||||||
fake_evidence.name = ui_evidence_name->text();
|
fake_evidence.name = ui_evidence_name->text();
|
||||||
fake_evidence.description = ui_evidence_description->toPlainText();
|
fake_evidence.description = ui_evidence_description->toPlainText();
|
||||||
fake_evidence.image = ui_evidence_image_name->text();
|
fake_evidence.image = ui_evidence_image_name->text();
|
||||||
@ -778,7 +776,7 @@ void Courtroom::evidence_switch(bool global)
|
|||||||
evidence_close();
|
evidence_close();
|
||||||
current_evidence_global = global;
|
current_evidence_global = global;
|
||||||
is_presenting_evidence = false;
|
is_presenting_evidence = false;
|
||||||
ui_evidence_present->set_image("present");
|
ui_evidence_present->setImage("present");
|
||||||
local_evidence_list.clear();
|
local_evidence_list.clear();
|
||||||
if (current_evidence_global)
|
if (current_evidence_global)
|
||||||
{
|
{
|
||||||
@ -786,10 +784,10 @@ void Courtroom::evidence_switch(bool global)
|
|||||||
ui_evidence_present->show();
|
ui_evidence_present->show();
|
||||||
ui_evidence_save->hide();
|
ui_evidence_save->hide();
|
||||||
ui_evidence_load->hide();
|
ui_evidence_load->hide();
|
||||||
ui_evidence_switch->set_image("evidence_global");
|
ui_evidence_switch->setImage("evidence_global");
|
||||||
ui_evidence->set_image("evidence_background");
|
ui_evidence->setImage("evidence_background");
|
||||||
ui_evidence_overlay->set_image("evidence_overlay");
|
ui_evidence_overlay->setImage("evidence_overlay");
|
||||||
ui_evidence_transfer->set_image("evidence_transfer");
|
ui_evidence_transfer->setImage("evidence_transfer");
|
||||||
ui_evidence_transfer->setToolTip(tr("Transfer evidence to private inventory."));
|
ui_evidence_transfer->setToolTip(tr("Transfer evidence to private inventory."));
|
||||||
ui_evidence_switch->setToolTip(tr("Current evidence is global. Click to switch to private."));
|
ui_evidence_switch->setToolTip(tr("Current evidence is global. Click to switch to private."));
|
||||||
}
|
}
|
||||||
@ -799,10 +797,10 @@ void Courtroom::evidence_switch(bool global)
|
|||||||
ui_evidence_present->hide();
|
ui_evidence_present->hide();
|
||||||
ui_evidence_save->show();
|
ui_evidence_save->show();
|
||||||
ui_evidence_load->show();
|
ui_evidence_load->show();
|
||||||
ui_evidence_switch->set_image("evidence_private");
|
ui_evidence_switch->setImage("evidence_private");
|
||||||
ui_evidence->set_image("evidence_background_private");
|
ui_evidence->setImage("evidence_background_private");
|
||||||
ui_evidence_overlay->set_image("evidence_overlay_private");
|
ui_evidence_overlay->setImage("evidence_overlay_private");
|
||||||
ui_evidence_transfer->set_image("evidence_transfer_private");
|
ui_evidence_transfer->setImage("evidence_transfer_private");
|
||||||
ui_evidence_transfer->setToolTip(tr("Transfer evidence to global inventory."));
|
ui_evidence_transfer->setToolTip(tr("Transfer evidence to global inventory."));
|
||||||
ui_evidence_switch->setToolTip(tr("Current evidence is private. Click to switch to global."));
|
ui_evidence_switch->setToolTip(tr("Current evidence is private. Click to switch to global."));
|
||||||
}
|
}
|
||||||
@ -873,7 +871,7 @@ void Courtroom::evidence_load(QString filename)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
evi_type f_evi;
|
EvidenceItem f_evi;
|
||||||
f_evi.name = inventory.value(evi + "/name", "<name>").value<QString>();
|
f_evi.name = inventory.value(evi + "/name", "<name>").value<QString>();
|
||||||
f_evi.description = inventory.value(evi + "/description", "<description>").value<QString>();
|
f_evi.description = inventory.value(evi + "/description", "<description>").value<QString>();
|
||||||
f_evi.image = inventory.value(evi + "/image", "empty.png").value<QString>();
|
f_evi.image = inventory.value(evi + "/image", "empty.png").value<QString>();
|
||||||
@ -906,7 +904,7 @@ void Courtroom::evidence_save(QString filename)
|
|||||||
inventory.sync();
|
inventory.sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Courtroom::compare_evidence_changed(evi_type evi_a, evi_type evi_b)
|
bool Courtroom::compare_evidence_changed(EvidenceItem evi_a, EvidenceItem evi_b)
|
||||||
{
|
{
|
||||||
return evi_a.name != evi_b.name || evi_a.image != evi_b.image || evi_a.description != evi_b.description;
|
return evi_a.name != evi_b.name || evi_a.image != evi_b.image || evi_a.description != evi_b.description;
|
||||||
}
|
}
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
|
|
||||||
namespace AttorneyOnline
|
|
||||||
{
|
|
||||||
namespace UI
|
|
||||||
{
|
|
||||||
class FavoriteServerDialog : public QDialog
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
const QString DEFAULT_UI = "favorite_server_dialog.ui";
|
|
||||||
const int TCP_INDEX = 0;
|
|
||||||
|
|
||||||
private Q_SLOTS:
|
|
||||||
virtual void onSavePressed() = 0;
|
|
||||||
virtual void onCancelPressed() = 0;
|
|
||||||
};
|
|
||||||
} // namespace UI
|
|
||||||
} // namespace AttorneyOnline
|
|
@ -4,9 +4,8 @@
|
|||||||
#include "demoserver.h"
|
#include "demoserver.h"
|
||||||
#include "gui_utils.h"
|
#include "gui_utils.h"
|
||||||
#include "networkmanager.h"
|
#include "networkmanager.h"
|
||||||
#include "widgets/add_server_dialog.h"
|
|
||||||
#include "widgets/direct_connect_dialog.h"
|
#include "widgets/direct_connect_dialog.h"
|
||||||
#include "widgets/edit_server_dialog.h"
|
#include "widgets/server_editor_dialog.h"
|
||||||
|
|
||||||
#include <QImageReader>
|
#include <QImageReader>
|
||||||
#include <QUiLoader>
|
#include <QUiLoader>
|
||||||
@ -234,18 +233,26 @@ void Lobby::on_add_to_fav_released()
|
|||||||
|
|
||||||
void Lobby::on_add_server_to_fave_released()
|
void Lobby::on_add_server_to_fave_released()
|
||||||
{
|
{
|
||||||
AddServerDialog l_dialog;
|
ServerEditorDialog dialog;
|
||||||
l_dialog.exec();
|
if (dialog.exec())
|
||||||
|
{
|
||||||
|
Options::getInstance().addFavorite(dialog.currentServerInfo());
|
||||||
list_favorites();
|
list_favorites();
|
||||||
reset_selection();
|
reset_selection();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lobby::on_edit_favorite_released()
|
void Lobby::on_edit_favorite_released()
|
||||||
{
|
{
|
||||||
EditServerDialog l_dialog(get_selected_server());
|
const int index = get_selected_server();
|
||||||
l_dialog.exec();
|
ServerEditorDialog dialog;
|
||||||
|
dialog.loadServerInfo(Options::getInstance().favorites().at(index));
|
||||||
|
if (dialog.exec())
|
||||||
|
{
|
||||||
|
Options::getInstance().updateFavorite(dialog.currentServerInfo(), index);
|
||||||
list_favorites();
|
list_favorites();
|
||||||
reset_selection();
|
reset_selection();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lobby::on_remove_from_fav_released()
|
void Lobby::on_remove_from_fav_released()
|
||||||
@ -308,7 +315,7 @@ void Lobby::on_about_clicked()
|
|||||||
void Lobby::on_server_list_clicked(QTreeWidgetItem *p_item, int column)
|
void Lobby::on_server_list_clicked(QTreeWidgetItem *p_item, int column)
|
||||||
{
|
{
|
||||||
column = 0;
|
column = 0;
|
||||||
server_type f_server;
|
ServerInfo f_server;
|
||||||
int n_server = p_item->text(column).toInt();
|
int n_server = p_item->text(column).toInt();
|
||||||
|
|
||||||
if (n_server == last_index)
|
if (n_server == last_index)
|
||||||
@ -322,7 +329,7 @@ void Lobby::on_server_list_clicked(QTreeWidgetItem *p_item, int column)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<server_type> f_server_list = ao_app->get_server_list();
|
QVector<ServerInfo> f_server_list = ao_app->get_server_list();
|
||||||
|
|
||||||
if (n_server >= f_server_list.size())
|
if (n_server >= f_server_list.size())
|
||||||
{
|
{
|
||||||
@ -331,7 +338,7 @@ void Lobby::on_server_list_clicked(QTreeWidgetItem *p_item, int column)
|
|||||||
|
|
||||||
f_server = f_server_list.at(n_server);
|
f_server = f_server_list.at(n_server);
|
||||||
|
|
||||||
set_server_description(f_server.desc);
|
set_server_description(f_server.description);
|
||||||
|
|
||||||
ui_server_description_text->moveCursor(QTextCursor::Start);
|
ui_server_description_text->moveCursor(QTextCursor::Start);
|
||||||
ui_server_description_text->ensureCursorVisible();
|
ui_server_description_text->ensureCursorVisible();
|
||||||
@ -354,7 +361,7 @@ void Lobby::on_list_doubleclicked(QTreeWidgetItem *p_item, int column)
|
|||||||
void Lobby::on_favorite_tree_clicked(QTreeWidgetItem *p_item, int column)
|
void Lobby::on_favorite_tree_clicked(QTreeWidgetItem *p_item, int column)
|
||||||
{
|
{
|
||||||
column = 0;
|
column = 0;
|
||||||
server_type f_server;
|
ServerInfo f_server;
|
||||||
int n_server = p_item->text(column).toInt();
|
int n_server = p_item->text(column).toInt();
|
||||||
|
|
||||||
if (n_server == last_index)
|
if (n_server == last_index)
|
||||||
@ -372,7 +379,7 @@ void Lobby::on_favorite_tree_clicked(QTreeWidgetItem *p_item, int column)
|
|||||||
ui_edit_favorite_button->setEnabled(true);
|
ui_edit_favorite_button->setEnabled(true);
|
||||||
ui_remove_from_favorites_button->setEnabled(true);
|
ui_remove_from_favorites_button->setEnabled(true);
|
||||||
|
|
||||||
QVector<server_type> f_server_list = Options::getInstance().favorites();
|
QVector<ServerInfo> f_server_list = Options::getInstance().favorites();
|
||||||
|
|
||||||
if (n_server >= f_server_list.size())
|
if (n_server >= f_server_list.size())
|
||||||
{
|
{
|
||||||
@ -381,7 +388,7 @@ void Lobby::on_favorite_tree_clicked(QTreeWidgetItem *p_item, int column)
|
|||||||
|
|
||||||
f_server = f_server_list.at(n_server);
|
f_server = f_server_list.at(n_server);
|
||||||
|
|
||||||
set_server_description(f_server.desc);
|
set_server_description(f_server.description);
|
||||||
ui_server_description_text->moveCursor(QTextCursor::Start);
|
ui_server_description_text->moveCursor(QTextCursor::Start);
|
||||||
ui_server_description_text->ensureCursorVisible();
|
ui_server_description_text->ensureCursorVisible();
|
||||||
ui_server_player_count_lbl->setText(tr("Connecting..."));
|
ui_server_player_count_lbl->setText(tr("Connecting..."));
|
||||||
@ -427,7 +434,7 @@ void Lobby::on_demo_clicked(QTreeWidgetItem *item, int column)
|
|||||||
|
|
||||||
QString l_filepath = (QApplication::applicationDirPath() + "/logs/%1/%2").arg(item->data(0, Qt::DisplayRole).toString(), item->data(1, Qt::DisplayRole).toString());
|
QString l_filepath = (QApplication::applicationDirPath() + "/logs/%1/%2").arg(item->data(0, Qt::DisplayRole).toString(), item->data(1, Qt::DisplayRole).toString());
|
||||||
ao_app->demo_server->start_server();
|
ao_app->demo_server->start_server();
|
||||||
server_type demo_server;
|
ServerInfo demo_server;
|
||||||
demo_server.ip = "127.0.0.1";
|
demo_server.ip = "127.0.0.1";
|
||||||
demo_server.port = ao_app->demo_server->port();
|
demo_server.port = ao_app->demo_server->port();
|
||||||
ao_app->demo_server->set_demo_file(l_filepath);
|
ao_app->demo_server->set_demo_file(l_filepath);
|
||||||
@ -458,7 +465,7 @@ void Lobby::list_servers()
|
|||||||
ui_serverlist_search->setText("");
|
ui_serverlist_search->setText("");
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (const server_type &i_server : qAsConst(ao_app->get_server_list()))
|
for (const ServerInfo &i_server : qAsConst(ao_app->get_server_list()))
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *treeItem = new QTreeWidgetItem(ui_serverlist_tree);
|
QTreeWidgetItem *treeItem = new QTreeWidgetItem(ui_serverlist_tree);
|
||||||
treeItem->setData(0, Qt::DisplayRole, i);
|
treeItem->setData(0, Qt::DisplayRole, i);
|
||||||
@ -476,7 +483,7 @@ void Lobby::list_favorites()
|
|||||||
ui_favorites_tree->clear();
|
ui_favorites_tree->clear();
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (const server_type &i_server : Options::getInstance().favorites())
|
for (const ServerInfo &i_server : Options::getInstance().favorites())
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *treeItem = new QTreeWidgetItem(ui_favorites_tree);
|
QTreeWidgetItem *treeItem = new QTreeWidgetItem(ui_favorites_tree);
|
||||||
treeItem->setData(0, Qt::DisplayRole, i);
|
treeItem->setData(0, Qt::DisplayRole, i);
|
||||||
|
@ -51,23 +51,23 @@ void NetworkManager::ms_request_finished(QNetworkReply *reply)
|
|||||||
|
|
||||||
qDebug().noquote() << "Got valid response from" << reply->url();
|
qDebug().noquote() << "Got valid response from" << reply->url();
|
||||||
|
|
||||||
QVector<server_type> server_list;
|
QVector<ServerInfo> server_list;
|
||||||
const auto jsonEntries = json.array();
|
const auto jsonEntries = json.array();
|
||||||
for (const auto &entryRef : jsonEntries)
|
for (const auto &entryRef : jsonEntries)
|
||||||
{
|
{
|
||||||
const auto entry = entryRef.toObject();
|
const auto entry = entryRef.toObject();
|
||||||
server_type server;
|
ServerInfo server;
|
||||||
server.ip = entry["ip"].toString();
|
server.ip = entry["ip"].toString();
|
||||||
server.name = entry["name"].toString();
|
server.name = entry["name"].toString();
|
||||||
server.desc = entry["description"].toString(tr("No description provided."));
|
server.description = entry["description"].toString(tr("No description provided."));
|
||||||
if (entry["ws_port"].isDouble())
|
if (entry["ws_port"].isDouble())
|
||||||
{
|
{
|
||||||
server.socket_type = WEBSOCKETS;
|
server.socket_type = WebSocketServerConnection;
|
||||||
server.port = entry["ws_port"].toInt();
|
server.port = entry["ws_port"].toInt();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
server.socket_type = TCP;
|
server.socket_type = TcpServerConnection;
|
||||||
server.port = entry["port"].toInt();
|
server.port = entry["port"].toInt();
|
||||||
}
|
}
|
||||||
if (server.port != 0)
|
if (server.port != 0)
|
||||||
@ -137,7 +137,7 @@ void NetworkManager::request_document(MSDocumentType document_type, const std::f
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkManager::connect_to_server(server_type p_server)
|
void NetworkManager::connect_to_server(ServerInfo p_server)
|
||||||
{
|
{
|
||||||
disconnect_from_server();
|
disconnect_from_server();
|
||||||
|
|
||||||
@ -146,9 +146,10 @@ void NetworkManager::connect_to_server(server_type p_server)
|
|||||||
switch (p_server.socket_type)
|
switch (p_server.socket_type)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
p_server.socket_type = TCP;
|
p_server.socket_type = TcpServerConnection;
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
case TCP:
|
|
||||||
|
case TcpServerConnection:
|
||||||
qInfo() << "using TCP backend";
|
qInfo() << "using TCP backend";
|
||||||
server_socket.tcp = new QTcpSocket(this);
|
server_socket.tcp = new QTcpSocket(this);
|
||||||
|
|
||||||
@ -165,7 +166,8 @@ void NetworkManager::connect_to_server(server_type p_server)
|
|||||||
|
|
||||||
server_socket.tcp->connectToHost(p_server.ip, p_server.port);
|
server_socket.tcp->connectToHost(p_server.ip, p_server.port);
|
||||||
break;
|
break;
|
||||||
case WEBSOCKETS:
|
|
||||||
|
case WebSocketServerConnection:
|
||||||
qInfo() << "using WebSockets backend";
|
qInfo() << "using WebSockets backend";
|
||||||
server_socket.ws = new QWebSocket(QString(), QWebSocketProtocol::VersionLatest, this);
|
server_socket.ws = new QWebSocket(QString(), QWebSocketProtocol::VersionLatest, this);
|
||||||
|
|
||||||
@ -190,7 +192,7 @@ void NetworkManager::connect_to_server(server_type p_server)
|
|||||||
|
|
||||||
void NetworkManager::join_to_server()
|
void NetworkManager::join_to_server()
|
||||||
{
|
{
|
||||||
ship_server_packet(AOPacket("askchaa").to_string());
|
ship_server_packet(AOPacket("askchaa").toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkManager::disconnect_from_server()
|
void NetworkManager::disconnect_from_server()
|
||||||
@ -202,11 +204,11 @@ void NetworkManager::disconnect_from_server()
|
|||||||
|
|
||||||
switch (active_connection_type)
|
switch (active_connection_type)
|
||||||
{
|
{
|
||||||
case TCP:
|
case TcpServerConnection:
|
||||||
server_socket.tcp->close();
|
server_socket.tcp->close();
|
||||||
server_socket.tcp->deleteLater();
|
server_socket.tcp->deleteLater();
|
||||||
break;
|
break;
|
||||||
case WEBSOCKETS:
|
case WebSocketServerConnection:
|
||||||
server_socket.ws->close(QWebSocketProtocol::CloseCodeGoingAway);
|
server_socket.ws->close(QWebSocketProtocol::CloseCodeGoingAway);
|
||||||
server_socket.ws->deleteLater();
|
server_socket.ws->deleteLater();
|
||||||
break;
|
break;
|
||||||
@ -217,14 +219,14 @@ void NetworkManager::disconnect_from_server()
|
|||||||
|
|
||||||
void NetworkManager::ship_server_packet(AOPacket p_packet)
|
void NetworkManager::ship_server_packet(AOPacket p_packet)
|
||||||
{
|
{
|
||||||
QString message = p_packet.to_string(true);
|
QString message = p_packet.toString(true);
|
||||||
switch (active_connection_type)
|
switch (active_connection_type)
|
||||||
{
|
{
|
||||||
case TCP:
|
case TcpServerConnection:
|
||||||
server_socket.tcp->write(message.toUtf8());
|
server_socket.tcp->write(message.toUtf8());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WEBSOCKETS:
|
case WebSocketServerConnection:
|
||||||
server_socket.ws->sendTextMessage(message);
|
server_socket.ws->sendTextMessage(message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,8 @@ class NetworkManager : public QObject
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit NetworkManager(AOApplication *parent);
|
explicit NetworkManager(AOApplication *parent);
|
||||||
~NetworkManager() = default;
|
|
||||||
|
|
||||||
void connect_to_server(server_type p_server);
|
void connect_to_server(ServerInfo p_server);
|
||||||
void disconnect_from_server();
|
void disconnect_from_server();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
@ -53,7 +52,7 @@ private:
|
|||||||
QWebSocket *ws;
|
QWebSocket *ws;
|
||||||
QTcpSocket *tcp;
|
QTcpSocket *tcp;
|
||||||
} server_socket;
|
} server_socket;
|
||||||
connection_type active_connection_type;
|
ServerConnectionType active_connection_type;
|
||||||
bool connected = false;
|
bool connected = false;
|
||||||
|
|
||||||
QTimer *heartbeat_timer;
|
QTimer *heartbeat_timer;
|
||||||
|
@ -633,9 +633,9 @@ void Options::clearConfig()
|
|||||||
config.clear();
|
config.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<server_type> Options::favorites()
|
QVector<ServerInfo> Options::favorites()
|
||||||
{
|
{
|
||||||
QVector<server_type> serverlist;
|
QVector<ServerInfo> serverlist;
|
||||||
|
|
||||||
auto grouplist = favorite.childGroups();
|
auto grouplist = favorite.childGroups();
|
||||||
{ // remove all negative and non-numbers
|
{ // remove all negative and non-numbers
|
||||||
@ -656,13 +656,13 @@ QVector<server_type> Options::favorites()
|
|||||||
|
|
||||||
for (const QString &group : qAsConst(grouplist))
|
for (const QString &group : qAsConst(grouplist))
|
||||||
{
|
{
|
||||||
server_type f_server;
|
ServerInfo f_server;
|
||||||
favorite.beginGroup(group);
|
favorite.beginGroup(group);
|
||||||
f_server.ip = favorite.value("address", "127.0.0.1").toString();
|
f_server.ip = favorite.value("address", "127.0.0.1").toString();
|
||||||
f_server.port = favorite.value("port", 27016).toInt();
|
f_server.port = favorite.value("port", 27016).toInt();
|
||||||
f_server.name = favorite.value("name", "Missing Name").toString();
|
f_server.name = favorite.value("name", "Missing Name").toString();
|
||||||
f_server.desc = favorite.value("desc", "No description").toString();
|
f_server.description = favorite.value("desc", "No description").toString();
|
||||||
f_server.socket_type = to_connection_type.value(favorite.value("protocol", "tcp").toString());
|
f_server.socket_type = SERVER_CONNECTION_TYPE_STRING_MAP.value(favorite.value("protocol", "tcp").toString());
|
||||||
serverlist.append(std::move(f_server));
|
serverlist.append(std::move(f_server));
|
||||||
favorite.endGroup();
|
favorite.endGroup();
|
||||||
}
|
}
|
||||||
@ -670,7 +670,7 @@ QVector<server_type> Options::favorites()
|
|||||||
return serverlist;
|
return serverlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Options::setFavorites(QVector<server_type> value)
|
void Options::setFavorites(QVector<ServerInfo> value)
|
||||||
{
|
{
|
||||||
favorite.clear();
|
favorite.clear();
|
||||||
for (int i = 0; i < value.size(); ++i)
|
for (int i = 0; i < value.size(); ++i)
|
||||||
@ -680,9 +680,9 @@ void Options::setFavorites(QVector<server_type> value)
|
|||||||
favorite.setValue("name", fav_server.name);
|
favorite.setValue("name", fav_server.name);
|
||||||
favorite.setValue("address", fav_server.ip);
|
favorite.setValue("address", fav_server.ip);
|
||||||
favorite.setValue("port", fav_server.port);
|
favorite.setValue("port", fav_server.port);
|
||||||
favorite.setValue("desc", fav_server.desc);
|
favorite.setValue("desc", fav_server.description);
|
||||||
|
|
||||||
if (fav_server.socket_type == TCP)
|
if (fav_server.socket_type == TcpServerConnection)
|
||||||
{
|
{
|
||||||
favorite.setValue("protocol", "tcp");
|
favorite.setValue("protocol", "tcp");
|
||||||
}
|
}
|
||||||
@ -697,20 +697,20 @@ void Options::setFavorites(QVector<server_type> value)
|
|||||||
|
|
||||||
void Options::removeFavorite(int index)
|
void Options::removeFavorite(int index)
|
||||||
{
|
{
|
||||||
QVector<server_type> l_favorites = favorites();
|
QVector<ServerInfo> l_favorites = favorites();
|
||||||
l_favorites.remove(index);
|
l_favorites.remove(index);
|
||||||
setFavorites(l_favorites);
|
setFavorites(l_favorites);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Options::addFavorite(server_type server)
|
void Options::addFavorite(ServerInfo server)
|
||||||
{
|
{
|
||||||
int index = favorites().size();
|
int index = favorites().size();
|
||||||
favorite.beginGroup(QString::number(index));
|
favorite.beginGroup(QString::number(index));
|
||||||
favorite.setValue("name", server.name);
|
favorite.setValue("name", server.name);
|
||||||
favorite.setValue("address", server.ip);
|
favorite.setValue("address", server.ip);
|
||||||
favorite.setValue("port", server.port);
|
favorite.setValue("port", server.port);
|
||||||
favorite.setValue("desc", server.desc);
|
favorite.setValue("desc", server.description);
|
||||||
if (server.socket_type == TCP)
|
if (server.socket_type == TcpServerConnection)
|
||||||
{
|
{
|
||||||
favorite.setValue("protocol", "tcp");
|
favorite.setValue("protocol", "tcp");
|
||||||
}
|
}
|
||||||
@ -722,14 +722,14 @@ void Options::addFavorite(server_type server)
|
|||||||
favorite.sync();
|
favorite.sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Options::updateFavorite(server_type server, int index)
|
void Options::updateFavorite(ServerInfo server, int index)
|
||||||
{
|
{
|
||||||
favorite.beginGroup(QString::number(index));
|
favorite.beginGroup(QString::number(index));
|
||||||
favorite.setValue("name", server.name);
|
favorite.setValue("name", server.name);
|
||||||
favorite.setValue("address", server.ip);
|
favorite.setValue("address", server.ip);
|
||||||
favorite.setValue("port", server.port);
|
favorite.setValue("port", server.port);
|
||||||
favorite.setValue("desc", server.desc);
|
favorite.setValue("desc", server.description);
|
||||||
if (server.socket_type == TCP)
|
if (server.socket_type == TcpServerConnection)
|
||||||
{
|
{
|
||||||
favorite.setValue("protocol", "tcp");
|
favorite.setValue("protocol", "tcp");
|
||||||
}
|
}
|
||||||
|
@ -252,13 +252,13 @@ public:
|
|||||||
void clearConfig();
|
void clearConfig();
|
||||||
|
|
||||||
// Loads the favorite servers
|
// Loads the favorite servers
|
||||||
QVector<server_type> favorites();
|
QVector<ServerInfo> favorites();
|
||||||
void setFavorites(QVector<server_type> value);
|
void setFavorites(QVector<ServerInfo> value);
|
||||||
|
|
||||||
// Interactions with favorite servers
|
// Interactions with favorite servers
|
||||||
void removeFavorite(int index);
|
void removeFavorite(int index);
|
||||||
void addFavorite(server_type server);
|
void addFavorite(ServerInfo server);
|
||||||
void updateFavorite(server_type server, int index);
|
void updateFavorite(ServerInfo server, int index);
|
||||||
|
|
||||||
// Theming Nonesense!
|
// Theming Nonesense!
|
||||||
QString getUIAsset(QString f_asset_name);
|
QString getUIAsset(QString f_asset_name);
|
||||||
|
@ -26,12 +26,12 @@ void AOApplication::append_to_demofile(QString packet_string)
|
|||||||
|
|
||||||
void AOApplication::server_packet_received(AOPacket p_packet)
|
void AOApplication::server_packet_received(AOPacket p_packet)
|
||||||
{
|
{
|
||||||
QStringList f_contents_encoded = p_packet.get_content();
|
QStringList f_contents_encoded = p_packet.content();
|
||||||
QString f_packet_encoded = p_packet.to_string();
|
QString f_packet_encoded = p_packet.toString();
|
||||||
|
|
||||||
QString header = p_packet.get_header();
|
QString header = p_packet.header();
|
||||||
QStringList f_contents = p_packet.get_content();
|
QStringList f_contents = p_packet.content();
|
||||||
QString f_packet = p_packet.to_string();
|
QString f_packet = p_packet.toString();
|
||||||
|
|
||||||
bool log_to_demo = true;
|
bool log_to_demo = true;
|
||||||
|
|
||||||
@ -255,7 +255,7 @@ void AOApplication::server_packet_received(AOPacket p_packet)
|
|||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
QVector<server_type> favorite_list = Options::getInstance().favorites();
|
QVector<ServerInfo> favorite_list = Options::getInstance().favorites();
|
||||||
if (selected_server >= 0 && selected_server < favorite_list.size())
|
if (selected_server >= 0 && selected_server < favorite_list.size())
|
||||||
{
|
{
|
||||||
auto info = favorite_list.at(selected_server);
|
auto info = favorite_list.at(selected_server);
|
||||||
@ -335,7 +335,7 @@ void AOApplication::server_packet_received(AOPacket p_packet)
|
|||||||
sub_element = AOPacket::decode(sub_element);
|
sub_element = AOPacket::decode(sub_element);
|
||||||
}
|
}
|
||||||
|
|
||||||
char_type f_char;
|
CharacterSlot f_char;
|
||||||
f_char.name = sub_elements.at(0);
|
f_char.name = sub_elements.at(0);
|
||||||
if (sub_elements.size() >= 2)
|
if (sub_elements.size() >= 2)
|
||||||
{
|
{
|
||||||
@ -503,14 +503,14 @@ void AOApplication::server_packet_received(AOPacket p_packet)
|
|||||||
{
|
{
|
||||||
if (courtroom_constructed && courtroom_loaded)
|
if (courtroom_constructed && courtroom_loaded)
|
||||||
{
|
{
|
||||||
w_courtroom->chatmessage_enqueue(p_packet.get_content());
|
w_courtroom->chatmessage_enqueue(p_packet.content());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (header == "MC")
|
else if (header == "MC")
|
||||||
{
|
{
|
||||||
if (courtroom_constructed && courtroom_loaded)
|
if (courtroom_constructed && courtroom_loaded)
|
||||||
{
|
{
|
||||||
w_courtroom->handle_song(&p_packet.get_content());
|
w_courtroom->handle_song(&p_packet.content());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (header == "RT")
|
else if (header == "RT")
|
||||||
@ -542,7 +542,7 @@ void AOApplication::server_packet_received(AOPacket p_packet)
|
|||||||
{
|
{
|
||||||
if (courtroom_constructed)
|
if (courtroom_constructed)
|
||||||
{
|
{
|
||||||
QVector<evi_type> f_evi_list;
|
QVector<EvidenceItem> f_evi_list;
|
||||||
|
|
||||||
for (QString f_string : f_contents_encoded)
|
for (QString f_string : f_contents_encoded)
|
||||||
{
|
{
|
||||||
@ -559,7 +559,7 @@ void AOApplication::server_packet_received(AOPacket p_packet)
|
|||||||
data = AOPacket::decode(data);
|
data = AOPacket::decode(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
evi_type f_evi;
|
EvidenceItem f_evi;
|
||||||
f_evi.name = sub_contents.at(0);
|
f_evi.name = sub_contents.at(0);
|
||||||
f_evi.description = sub_contents.at(1);
|
f_evi.description = sub_contents.at(1);
|
||||||
f_evi.image = sub_contents.at(2);
|
f_evi.image = sub_contents.at(2);
|
||||||
@ -805,7 +805,7 @@ void AOApplication::server_packet_received(AOPacket p_packet)
|
|||||||
|
|
||||||
void AOApplication::send_server_packet(AOPacket p_packet)
|
void AOApplication::send_server_packet(AOPacket p_packet)
|
||||||
{
|
{
|
||||||
QString f_packet = p_packet.to_string();
|
QString f_packet = p_packet.toString();
|
||||||
#ifdef DEBUG_NETWORK
|
#ifdef DEBUG_NETWORK
|
||||||
qDebug() << "S:" << p_packet.to_string();
|
qDebug() << "S:" << p_packet.to_string();
|
||||||
#endif
|
#endif
|
||||||
|
@ -17,12 +17,12 @@ ScrollText::ScrollText(QWidget *parent)
|
|||||||
|
|
||||||
QString ScrollText::text() const
|
QString ScrollText::text() const
|
||||||
{
|
{
|
||||||
return _text;
|
return m_text;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScrollText::setText(QString text)
|
void ScrollText::setText(QString text)
|
||||||
{
|
{
|
||||||
_text = text;
|
m_text = text;
|
||||||
updateText();
|
updateText();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
@ -43,7 +43,7 @@ void ScrollText::updateText()
|
|||||||
{
|
{
|
||||||
timer.stop();
|
timer.stop();
|
||||||
#if QT_VERSION > QT_VERSION_CHECK(5, 11, 0)
|
#if QT_VERSION > QT_VERSION_CHECK(5, 11, 0)
|
||||||
singleTextWidth = fontMetrics().horizontalAdvance(_text);
|
singleTextWidth = fontMetrics().horizontalAdvance(m_text);
|
||||||
#else
|
#else
|
||||||
singleTextWidth = fontMetrics().boundingRect(_text).width();
|
singleTextWidth = fontMetrics().boundingRect(_text).width();
|
||||||
#endif
|
#endif
|
||||||
@ -53,12 +53,12 @@ void ScrollText::updateText()
|
|||||||
if (scrollEnabled)
|
if (scrollEnabled)
|
||||||
{
|
{
|
||||||
scrollPos = -64;
|
scrollPos = -64;
|
||||||
staticText.setText(_text + _separator);
|
staticText.setText(m_text + _separator);
|
||||||
timer.start();
|
timer.start();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
staticText.setText(_text);
|
staticText.setText(m_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
staticText.prepare(QTransform(), font());
|
staticText.prepare(QTransform(), font());
|
||||||
|
@ -28,8 +28,7 @@ protected:
|
|||||||
virtual void resizeEvent(QResizeEvent *);
|
virtual void resizeEvent(QResizeEvent *);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateText();
|
QString m_text;
|
||||||
QString _text;
|
|
||||||
QString _separator;
|
QString _separator;
|
||||||
QStaticText staticText;
|
QStaticText staticText;
|
||||||
int singleTextWidth;
|
int singleTextWidth;
|
||||||
@ -41,6 +40,8 @@ private:
|
|||||||
QImage buffer;
|
QImage buffer;
|
||||||
QTimer timer;
|
QTimer timer;
|
||||||
|
|
||||||
|
void updateText();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
virtual void timer_timeout();
|
virtual void timer_timeout();
|
||||||
};
|
};
|
||||||
|
@ -1,96 +0,0 @@
|
|||||||
#include "add_server_dialog.h"
|
|
||||||
|
|
||||||
#include "datatypes.h"
|
|
||||||
#include "options.h"
|
|
||||||
#include "gui_utils.h"
|
|
||||||
|
|
||||||
#include <QComboBox>
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QDialogButtonBox>
|
|
||||||
#include <QFile>
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QLineEdit>
|
|
||||||
#include <QPlainTextEdit>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include <QSpinBox>
|
|
||||||
#include <QUiLoader>
|
|
||||||
#include <QVBoxLayout>
|
|
||||||
|
|
||||||
AddServerDialog::AddServerDialog()
|
|
||||||
{
|
|
||||||
QUiLoader l_loader(this);
|
|
||||||
QFile l_uiFile(Options::getInstance().getUIAsset(DEFAULT_UI));
|
|
||||||
|
|
||||||
if (!l_uiFile.open(QFile::ReadOnly))
|
|
||||||
{
|
|
||||||
qCritical() << "Unable to open file " << l_uiFile.fileName();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ui_widget = l_loader.load(&l_uiFile, this);
|
|
||||||
|
|
||||||
auto l_layout = new QVBoxLayout(this);
|
|
||||||
l_layout->addWidget(ui_widget);
|
|
||||||
|
|
||||||
FROM_UI(QLineEdit, server_display_name_edit);
|
|
||||||
FROM_UI(QLineEdit, server_hostname_edit);
|
|
||||||
FROM_UI(QSpinBox, server_port_box);
|
|
||||||
FROM_UI(QComboBox, server_protocol_box);
|
|
||||||
FROM_UI(QPlainTextEdit, server_description_edit);
|
|
||||||
FROM_UI(QDialogButtonBox, server_dialog_button);
|
|
||||||
connect(ui_server_dialog_button, &QDialogButtonBox::accepted, this, &::AddServerDialog::onSavePressed);
|
|
||||||
connect(ui_server_dialog_button, &QDialogButtonBox::rejected, this, &AddServerDialog::onCancelPressed);
|
|
||||||
|
|
||||||
FROM_UI(QLabel, server_legacy_lbl);
|
|
||||||
FROM_UI(QLineEdit, server_legacy_edit);
|
|
||||||
FROM_UI(QPushButton, server_legacy_load_button);
|
|
||||||
connect(ui_server_legacy_load_button, &QPushButton::released, this, &AddServerDialog::parseLegacyServerEntry);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddServerDialog::onSavePressed()
|
|
||||||
{
|
|
||||||
server_type server;
|
|
||||||
server.name = ui_server_display_name_edit->text();
|
|
||||||
server.ip = ui_server_hostname_edit->text();
|
|
||||||
server.port = ui_server_port_box->value();
|
|
||||||
server.desc = ui_server_description_edit->toPlainText();
|
|
||||||
server.socket_type = ui_server_protocol_box->currentIndex() == TCP_INDEX ? TCP : WEBSOCKETS;
|
|
||||||
Options::getInstance().addFavorite(server);
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddServerDialog::onCancelPressed()
|
|
||||||
{
|
|
||||||
close();
|
|
||||||
deleteLater();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddServerDialog::parseLegacyServerEntry()
|
|
||||||
{
|
|
||||||
QStringList l_legacy_entry = ui_server_legacy_edit->text().split(":");
|
|
||||||
server_type l_server_entry;
|
|
||||||
if (l_legacy_entry.isEmpty())
|
|
||||||
{
|
|
||||||
qDebug() << "Legacy entry empty.";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int l_item_count = l_legacy_entry.size();
|
|
||||||
|
|
||||||
if (l_item_count >= 3)
|
|
||||||
{
|
|
||||||
ui_server_hostname_edit->setText(l_legacy_entry.at(0));
|
|
||||||
ui_server_port_box->setValue(l_legacy_entry.at(1).toInt());
|
|
||||||
ui_server_display_name_edit->setText(l_legacy_entry.at(2));
|
|
||||||
if (l_item_count >= 4)
|
|
||||||
{
|
|
||||||
if (l_legacy_entry.at(3) == "ws")
|
|
||||||
{
|
|
||||||
ui_server_protocol_box->setCurrentIndex(1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ui_server_protocol_box->setCurrentIndex(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "interfaces/server_dialog.h"
|
|
||||||
|
|
||||||
#include <QComboBox>
|
|
||||||
#include <QDialogButtonBox>
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QLineEdit>
|
|
||||||
#include <QPlainTextEdit>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include <QSpinBox>
|
|
||||||
|
|
||||||
class AddServerDialog : public AttorneyOnline::UI::FavoriteServerDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
AddServerDialog();
|
|
||||||
~AddServerDialog() = default;
|
|
||||||
|
|
||||||
private:
|
|
||||||
QWidget *ui_widget;
|
|
||||||
|
|
||||||
QLineEdit *ui_server_display_name_edit;
|
|
||||||
QLineEdit *ui_server_hostname_edit;
|
|
||||||
QSpinBox *ui_server_port_box;
|
|
||||||
QComboBox *ui_server_protocol_box;
|
|
||||||
QPlainTextEdit *ui_server_description_edit;
|
|
||||||
QDialogButtonBox *ui_server_dialog_button;
|
|
||||||
|
|
||||||
// Legacy Server UI
|
|
||||||
QLabel *ui_server_legacy_lbl;
|
|
||||||
QLineEdit *ui_server_legacy_edit;
|
|
||||||
QPushButton *ui_server_legacy_load_button;
|
|
||||||
|
|
||||||
private Q_SLOTS:
|
|
||||||
void onSavePressed() override;
|
|
||||||
void onCancelPressed() override;
|
|
||||||
void parseLegacyServerEntry();
|
|
||||||
};
|
|
@ -9,11 +9,16 @@
|
|||||||
#include <QUiLoader>
|
#include <QUiLoader>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
DirectConnectDialog::DirectConnectDialog(NetworkManager *p_net_manager)
|
const QString DirectConnectDialog::UI_FILE_PATH = "direct_connect_dialog.ui";
|
||||||
: net_manager(p_net_manager)
|
const QRegularExpression DirectConnectDialog::SCHEME_PATTERN{"^\\w+://.+$"};
|
||||||
|
const int DirectConnectDialog::CONNECT_TIMEOUT = 5 * 1000;
|
||||||
|
|
||||||
|
DirectConnectDialog::DirectConnectDialog(NetworkManager *netManager, QWidget *parent)
|
||||||
|
: QDialog(parent)
|
||||||
|
, net_manager(netManager)
|
||||||
{
|
{
|
||||||
QUiLoader l_loader(this);
|
QUiLoader l_loader(this);
|
||||||
QFile l_uiFile(Options::getInstance().getUIAsset(DEFAULT_UI));
|
QFile l_uiFile(Options::getInstance().getUIAsset(UI_FILE_PATH));
|
||||||
|
|
||||||
if (!l_uiFile.open(QFile::ReadOnly))
|
if (!l_uiFile.open(QFile::ReadOnly))
|
||||||
{
|
{
|
||||||
@ -36,8 +41,8 @@ DirectConnectDialog::DirectConnectDialog(NetworkManager *p_net_manager)
|
|||||||
|
|
||||||
connect(net_manager, &NetworkManager::server_connected, this, &DirectConnectDialog::onServerConnected);
|
connect(net_manager, &NetworkManager::server_connected, this, &DirectConnectDialog::onServerConnected);
|
||||||
|
|
||||||
connect(&connect_timeout, &QTimer::timeout, this, &DirectConnectDialog::onConnectTimeout);
|
connect(&m_connect_timeout, &QTimer::timeout, this, &DirectConnectDialog::onConnectTimeout);
|
||||||
connect_timeout.setSingleShot(true);
|
m_connect_timeout.setSingleShot(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DirectConnectDialog::onConnectPressed()
|
void DirectConnectDialog::onConnectPressed()
|
||||||
@ -53,9 +58,9 @@ void DirectConnectDialog::onConnectPressed()
|
|||||||
call_error(tr("Invalid URL."));
|
call_error(tr("Invalid URL."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!to_connection_type.contains(l_url.scheme()))
|
if (!SERVER_CONNECTION_TYPE_STRING_MAP.contains(l_url.scheme()))
|
||||||
{
|
{
|
||||||
call_error(tr("Scheme not recognized. Must be either of the following: ") % QStringList::fromVector(to_connection_type.keys().toVector()).join(", "));
|
call_error(tr("Scheme not recognized. Must be either of the following: ") % QStringList::fromVector(SERVER_CONNECTION_TYPE_STRING_MAP.keys().toVector()).join(", "));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (l_url.port() == -1)
|
if (l_url.port() == -1)
|
||||||
@ -63,8 +68,8 @@ void DirectConnectDialog::onConnectPressed()
|
|||||||
call_error(tr("Invalid server port."));
|
call_error(tr("Invalid server port."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
server_type l_server;
|
ServerInfo l_server;
|
||||||
l_server.socket_type = to_connection_type[l_url.scheme()];
|
l_server.socket_type = SERVER_CONNECTION_TYPE_STRING_MAP[l_url.scheme()];
|
||||||
l_server.ip = l_url.host();
|
l_server.ip = l_url.host();
|
||||||
l_server.port = l_url.port();
|
l_server.port = l_url.port();
|
||||||
l_server.name = "Direct Connection";
|
l_server.name = "Direct Connection";
|
||||||
@ -73,7 +78,7 @@ void DirectConnectDialog::onConnectPressed()
|
|||||||
ui_direct_connect_button->setEnabled(false);
|
ui_direct_connect_button->setEnabled(false);
|
||||||
ui_direct_connection_status_lbl->setText("Connecting...");
|
ui_direct_connection_status_lbl->setText("Connecting...");
|
||||||
ui_direct_connection_status_lbl->setStyleSheet("color : rgb(0,64,156)");
|
ui_direct_connection_status_lbl->setStyleSheet("color : rgb(0,64,156)");
|
||||||
connect_timeout.start(CONNECT_TIMEOUT);
|
m_connect_timeout.start(CONNECT_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DirectConnectDialog::onServerConnected()
|
void DirectConnectDialog::onServerConnected()
|
||||||
|
@ -16,16 +16,17 @@ class DirectConnectDialog : public QDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DirectConnectDialog(NetworkManager *p_net_manager);
|
DirectConnectDialog(NetworkManager *netManager, QWidget *parent = nullptr);
|
||||||
~DirectConnectDialog() = default;
|
|
||||||
|
|
||||||
private Q_SLOTS:
|
|
||||||
void onConnectPressed();
|
|
||||||
void onServerConnected();
|
|
||||||
void onConnectTimeout();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static const QString UI_FILE_PATH;
|
||||||
|
static const QRegularExpression SCHEME_PATTERN;
|
||||||
|
static const int CONNECT_TIMEOUT;
|
||||||
|
|
||||||
NetworkManager *net_manager;
|
NetworkManager *net_manager;
|
||||||
|
QTimer m_connect_timeout;
|
||||||
|
|
||||||
|
QWidget *ui_widget;
|
||||||
|
|
||||||
QLineEdit *ui_direct_hostname_edit;
|
QLineEdit *ui_direct_hostname_edit;
|
||||||
|
|
||||||
@ -33,11 +34,8 @@ private:
|
|||||||
QPushButton *ui_direct_connect_button;
|
QPushButton *ui_direct_connect_button;
|
||||||
QPushButton *ui_direct_cancel_button;
|
QPushButton *ui_direct_cancel_button;
|
||||||
|
|
||||||
QWidget *ui_widget;
|
private Q_SLOTS:
|
||||||
QTimer connect_timeout;
|
void onConnectPressed();
|
||||||
|
void onServerConnected();
|
||||||
const int TCP_INDEX = 0;
|
void onConnectTimeout();
|
||||||
const QRegularExpression SCHEME_PATTERN{"^\\w+://.+$"};
|
|
||||||
const int CONNECT_TIMEOUT = 5 * 1000;
|
|
||||||
const QString DEFAULT_UI = "direct_connect_dialog.ui";
|
|
||||||
};
|
};
|
||||||
|
@ -1,75 +0,0 @@
|
|||||||
#include "edit_server_dialog.h"
|
|
||||||
|
|
||||||
#include "datatypes.h"
|
|
||||||
#include "gui_utils.h"
|
|
||||||
#include "options.h"
|
|
||||||
|
|
||||||
#include <QFile>
|
|
||||||
#include <QUiLoader>
|
|
||||||
#include <QVBoxLayout>
|
|
||||||
|
|
||||||
EditServerDialog::EditServerDialog(int index)
|
|
||||||
: index(index) // lol
|
|
||||||
{
|
|
||||||
QUiLoader l_loader(this);
|
|
||||||
QFile l_uiFile(Options::getInstance().getUIAsset(DEFAULT_UI));
|
|
||||||
|
|
||||||
if (!l_uiFile.open(QFile::ReadOnly))
|
|
||||||
{
|
|
||||||
qCritical() << "Unable to open file " << l_uiFile.fileName();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ui_widget = l_loader.load(&l_uiFile, this);
|
|
||||||
|
|
||||||
auto l_layout = new QVBoxLayout(this);
|
|
||||||
l_layout->addWidget(ui_widget);
|
|
||||||
|
|
||||||
FROM_UI(QLineEdit, server_display_name_edit);
|
|
||||||
FROM_UI(QLineEdit, server_hostname_edit);
|
|
||||||
FROM_UI(QSpinBox, server_port_box);
|
|
||||||
FROM_UI(QComboBox, server_protocol_box);
|
|
||||||
FROM_UI(QPlainTextEdit, server_description_edit);
|
|
||||||
FROM_UI(QDialogButtonBox, server_dialog_button);
|
|
||||||
connect(ui_server_dialog_button, &QDialogButtonBox::accepted, this, &::EditServerDialog::onSavePressed);
|
|
||||||
connect(ui_server_dialog_button, &QDialogButtonBox::rejected, this, &EditServerDialog::onCancelPressed);
|
|
||||||
|
|
||||||
// We don't need you.
|
|
||||||
FROM_UI(QLabel, server_legacy_lbl);
|
|
||||||
FROM_UI(QLineEdit, server_legacy_edit);
|
|
||||||
FROM_UI(QPushButton, server_legacy_load_button);
|
|
||||||
|
|
||||||
ui_server_legacy_lbl->setVisible(false);
|
|
||||||
ui_server_legacy_edit->setVisible(false);
|
|
||||||
ui_server_legacy_load_button->setVisible(false);
|
|
||||||
|
|
||||||
loadEntry();
|
|
||||||
}
|
|
||||||
|
|
||||||
void EditServerDialog::loadEntry()
|
|
||||||
{
|
|
||||||
server_type server = Options::getInstance().favorites().at(index);
|
|
||||||
ui_server_display_name_edit->setText(server.name);
|
|
||||||
ui_server_hostname_edit->setText(server.ip);
|
|
||||||
ui_server_port_box->setValue(server.port);
|
|
||||||
ui_server_description_edit->setPlainText(server.desc);
|
|
||||||
ui_server_protocol_box->setCurrentIndex(server.socket_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EditServerDialog::onSavePressed()
|
|
||||||
{
|
|
||||||
server_type server;
|
|
||||||
server.name = ui_server_display_name_edit->text();
|
|
||||||
server.ip = ui_server_hostname_edit->text();
|
|
||||||
server.port = ui_server_port_box->value();
|
|
||||||
server.desc = ui_server_description_edit->toPlainText();
|
|
||||||
server.socket_type = ui_server_protocol_box->currentIndex() == TCP_INDEX ? TCP : WEBSOCKETS;
|
|
||||||
Options::getInstance().updateFavorite(server, index);
|
|
||||||
close();
|
|
||||||
deleteLater();
|
|
||||||
}
|
|
||||||
|
|
||||||
void EditServerDialog::onCancelPressed()
|
|
||||||
{
|
|
||||||
close();
|
|
||||||
deleteLater();
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "interfaces/server_dialog.h"
|
|
||||||
|
|
||||||
#include <QComboBox>
|
|
||||||
#include <QDialogButtonBox>
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QLineEdit>
|
|
||||||
#include <QPlainTextEdit>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include <QSpinBox>
|
|
||||||
|
|
||||||
class EditServerDialog : public AttorneyOnline::UI::FavoriteServerDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
EditServerDialog(int index);
|
|
||||||
~EditServerDialog() = default;
|
|
||||||
|
|
||||||
private:
|
|
||||||
QWidget *ui_widget;
|
|
||||||
|
|
||||||
QLineEdit *ui_server_display_name_edit;
|
|
||||||
QLineEdit *ui_server_hostname_edit;
|
|
||||||
QSpinBox *ui_server_port_box;
|
|
||||||
QComboBox *ui_server_protocol_box;
|
|
||||||
QPlainTextEdit *ui_server_description_edit;
|
|
||||||
QDialogButtonBox *ui_server_dialog_button;
|
|
||||||
|
|
||||||
// Legacy Server UI
|
|
||||||
QLabel *ui_server_legacy_lbl;
|
|
||||||
QLineEdit *ui_server_legacy_edit;
|
|
||||||
QPushButton *ui_server_legacy_load_button;
|
|
||||||
|
|
||||||
int index;
|
|
||||||
void loadEntry();
|
|
||||||
|
|
||||||
private Q_SLOTS:
|
|
||||||
void onSavePressed() override;
|
|
||||||
void onCancelPressed() override;
|
|
||||||
};
|
|
93
src/widgets/server_editor_dialog.cpp
Normal file
93
src/widgets/server_editor_dialog.cpp
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
#include "server_editor_dialog.h"
|
||||||
|
|
||||||
|
#include "datatypes.h"
|
||||||
|
#include "gui_utils.h"
|
||||||
|
#include "options.h"
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
|
#include <QUiLoader>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
const QString ServerEditorDialog::UI_FILE_PATH = "favorite_server_dialog.ui";
|
||||||
|
|
||||||
|
ServerEditorDialog::ServerEditorDialog(QWidget *parent)
|
||||||
|
: QDialog(parent)
|
||||||
|
{
|
||||||
|
QUiLoader loader(this);
|
||||||
|
QFile file(Options::getInstance().getUIAsset(UI_FILE_PATH));
|
||||||
|
|
||||||
|
if (!file.open(QFile::ReadOnly))
|
||||||
|
{
|
||||||
|
qFatal("Unable to open file %s", qPrintable(file.fileName()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ui_body = loader.load(&file, this);
|
||||||
|
|
||||||
|
auto layout = new QVBoxLayout(this);
|
||||||
|
layout->addWidget(ui_body);
|
||||||
|
|
||||||
|
FROM_UI(QLineEdit, name);
|
||||||
|
FROM_UI(QLineEdit, hostname);
|
||||||
|
FROM_UI(QSpinBox, port);
|
||||||
|
FROM_UI(QComboBox, protocol);
|
||||||
|
FROM_UI(QPlainTextEdit, description);
|
||||||
|
FROM_UI(QDialogButtonBox, button_box);
|
||||||
|
|
||||||
|
FROM_UI(QLineEdit, legacy_edit);
|
||||||
|
FROM_UI(QPushButton, parse_legacy);
|
||||||
|
|
||||||
|
connect(ui_parse_legacy, &QPushButton::released, this, &ServerEditorDialog::parseLegacyEntry);
|
||||||
|
|
||||||
|
connect(ui_button_box, &QDialogButtonBox::accepted, this, &ServerEditorDialog::accept);
|
||||||
|
connect(ui_button_box, &QDialogButtonBox::rejected, this, &ServerEditorDialog::reject);
|
||||||
|
}
|
||||||
|
|
||||||
|
ServerInfo ServerEditorDialog::currentServerInfo() const
|
||||||
|
{
|
||||||
|
ServerInfo server;
|
||||||
|
server.name = ui_name->text();
|
||||||
|
server.ip = ui_hostname->text();
|
||||||
|
server.port = ui_port->value();
|
||||||
|
server.description = ui_description->toPlainText();
|
||||||
|
server.socket_type = ServerConnectionType(ui_protocol->currentIndex());
|
||||||
|
return server;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServerEditorDialog::loadServerInfo(ServerInfo server)
|
||||||
|
{
|
||||||
|
ui_name->setText(server.name);
|
||||||
|
ui_hostname->setText(server.ip);
|
||||||
|
ui_port->setValue(server.port);
|
||||||
|
ui_description->setPlainText(server.description);
|
||||||
|
ui_protocol->setCurrentIndex(server.socket_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServerEditorDialog::parseLegacyEntry()
|
||||||
|
{
|
||||||
|
QStringList entry = ui_legacy_edit->text().split(":");
|
||||||
|
ServerInfo l_server_entry;
|
||||||
|
if (entry.isEmpty())
|
||||||
|
{
|
||||||
|
qDebug() << "Legacy entry empty.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int item_count = entry.size();
|
||||||
|
if (item_count >= 3)
|
||||||
|
{
|
||||||
|
ui_hostname->setText(entry.at(0));
|
||||||
|
ui_port->setValue(entry.at(1).toInt());
|
||||||
|
ui_name->setText(entry.at(2));
|
||||||
|
if (item_count >= 4)
|
||||||
|
{
|
||||||
|
if (entry.at(3) == "ws")
|
||||||
|
{
|
||||||
|
ui_protocol->setCurrentIndex(1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui_protocol->setCurrentIndex(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
43
src/widgets/server_editor_dialog.h
Normal file
43
src/widgets/server_editor_dialog.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "datatypes.h"
|
||||||
|
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QPlainTextEdit>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QSpinBox>
|
||||||
|
|
||||||
|
class ServerEditorDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
ServerEditorDialog(QWidget *parent = nullptr);
|
||||||
|
ServerEditorDialog(const ServerInfo &server, QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
ServerInfo currentServerInfo() const;
|
||||||
|
|
||||||
|
void loadServerInfo(ServerInfo server);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static const QString UI_FILE_PATH;
|
||||||
|
|
||||||
|
QWidget *ui_body;
|
||||||
|
|
||||||
|
QLineEdit *ui_name;
|
||||||
|
QLineEdit *ui_hostname;
|
||||||
|
QSpinBox *ui_port;
|
||||||
|
QComboBox *ui_protocol;
|
||||||
|
QPlainTextEdit *ui_description;
|
||||||
|
QDialogButtonBox *ui_button_box;
|
||||||
|
|
||||||
|
QLineEdit *ui_legacy_edit;
|
||||||
|
QPushButton *ui_parse_legacy;
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void parseLegacyEntry();
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user