Skip to content

Commit

Permalink
Add Timeline Features
Browse files Browse the repository at this point in the history
  • Loading branch information
palindromiq committed Feb 20, 2022
1 parent 4109213 commit 1175fcc
Show file tree
Hide file tree
Showing 32 changed files with 486 additions and 43 deletions.
4 changes: 3 additions & 1 deletion YATE.pro
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CONFIG += c++11 DISCORD_ENABLED
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
VERSION = 1.0.10.0
VERSION = 1.1.0.0
SOURCES += \
analysisviewitem.cpp \
analysisviewmodel.cpp \
Expand All @@ -24,6 +24,7 @@ SOURCES += \
main.cpp \
miniz.cpp \
settingsdialog.cpp \
timelineimagegenerator.cpp \
updater.cpp \
yatewindow.cpp \
zipmanager.cpp
Expand Down Expand Up @@ -60,6 +61,7 @@ HEADERS += \
logevent.h \
miniz.h \
settingsdialog.h \
timelineimagegenerator.h \
updater.h \
yatewindow.h \
zipmanager.h
Expand Down
103 changes: 102 additions & 1 deletion analysiswindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "ui_analysiswindow.h"
#include "analysisviewmodel.h"
#include "huntimagegenerator.h"
#include "timelineimagegenerator.h"
#include "huntinfo.h"
#include <QFileDialog>
#include <QDesktopServices>
Expand All @@ -13,14 +14,15 @@
#include <QImage>
#include <QMimeData>


namespace Yate {
AnalysisWindow::AnalysisWindow(QWidget *parent) :
QMainWindow(parent), ui(new Ui::AnalysisWindow),
model_(nullptr), hunt_(nullptr), selectedNight_(-1)
{
qDebug() << "Initializing analysis window.";
isGenerating_.storeRelaxed(0);
ui->setupUi(this);
isGenerating_.storeRelaxed(0);
unhighlightNight();
qDebug() << "Initialized analysis window.";
}
Expand Down Expand Up @@ -129,10 +131,14 @@ void AnalysisWindow::highlightNight(int night)
if (isGenerating_.loadRelaxed() != 1) {
ui->btnExport->setEnabled(true);
ui->btnCopyImg->setEnabled(true);
ui->btnExportTimeline->setEnabled(true);
ui->btnCopyTimeline->setEnabled(true);
}

ui->btnExport->setToolTip("");
ui->btnCopyImg->setToolTip("");
ui->btnExportTimeline->setToolTip("");
ui->btnCopyTimeline->setToolTip("");
}

void AnalysisWindow::unhighlightNight()
Expand All @@ -142,6 +148,10 @@ void AnalysisWindow::unhighlightNight()
ui->btnExport->setToolTip("Select a night analysis to export.");
ui->btnCopyImg->setEnabled(false);
ui->btnCopyImg->setToolTip("Select a night analysis to copy.");
ui->btnExportTimeline->setEnabled(false);
ui->btnExportTimeline->setToolTip("Select a night analysis to generate timeline.");
ui->btnCopyTimeline->setEnabled(false);
ui->btnCopyTimeline->setToolTip("Select a night analysis to generate timeline.");

}

Expand Down Expand Up @@ -185,6 +195,8 @@ void AnalysisWindow::on_btnExport_clicked()
savePath_ = savePath;
ui->btnExport->setEnabled(false);
ui->btnCopyImg->setEnabled(false);
ui->btnExportTimeline->setEnabled(false);
ui->btnCopyTimeline->setEnabled(false);
isGenerating_.storeRelaxed(1);
HuntImageGenerator *gen = new HuntImageGenerator(savePath, night, night.host(), night.squad());
QThread *genThread = new QThread;
Expand Down Expand Up @@ -235,6 +247,9 @@ void AnalysisWindow::on_btnCopyImg_clicked()
QSettings settings;
NightInfo &night = hunt_->night(selectedNight_);
ui->btnExport->setEnabled(false);
ui->btnCopyImg->setEnabled(false);
ui->btnExportTimeline->setEnabled(false);
ui->btnCopyTimeline->setEnabled(false);
isGenerating_.storeRelaxed(1);
HuntImageGenerator *gen = new HuntImageGenerator("", night, night.host(), night.squad());
QThread *genThread = new QThread;
Expand All @@ -246,4 +261,90 @@ void AnalysisWindow::on_btnCopyImg_clicked()
genThread->start();
}





void AnalysisWindow::on_btnExportTimeline_clicked()
{
if (selectedNight_ == -1 || (selectedNight_ >= hunt_->nightCount())) {
unhighlightNight();
return;
}
qDebug() << "Exporting timeline image.";
QSettings settings;
NightInfo &night = hunt_->night(selectedNight_);
QString defaultSavePath = "";
if (!settings.value(SETTINGS_KEY_LAST_SAVE_DIR).isNull()) {
defaultSavePath = settings.value(SETTINGS_KEY_LAST_SAVE_DIR).toString();
if (!QFileInfo(defaultSavePath).exists() || !QFileInfo(defaultSavePath).isDir()) {
defaultSavePath = "";
settings.remove(SETTINGS_KEY_LAST_SAVE_DIR);
}
}
QString saveFileDir;
if(defaultSavePath.size()) {
saveFileDir = defaultSavePath + QDir::separator() + "Timeline_" + QDateTime::currentDateTime().toString("MM_dd_yy_hh") + ".png";
} else {
saveFileDir = "Hunt_" + QDateTime::currentDateTime().toString("MM_dd_yy_hh") + ".png";
}
QString savePath = QFileDialog::getSaveFileName(this, "Export Hunt Summary", saveFileDir, ".png (PNG)");
if (!savePath.size()) {
return;
}

if (!savePath.endsWith(".png")) {
if (!savePath.endsWith(".")) {
savePath = savePath + ".";
}
savePath = savePath + "png";
}
QString parentSavePath = QFileInfo(savePath).absoluteDir().absolutePath();
settings.setValue(SETTINGS_KEY_LAST_SAVE_DIR, parentSavePath);
savePath_ = savePath;
ui->btnExport->setEnabled(false);
ui->btnCopyImg->setEnabled(false);
ui->btnExportTimeline->setEnabled(false);
ui->btnCopyTimeline->setEnabled(false);
isGenerating_.storeRelaxed(1);
TimelineImageGenerator *gen = new TimelineImageGenerator(savePath, night, night.host(), night.squad());
QThread *genThread = new QThread;
gen->moveToThread(genThread);
connect(genThread, &QThread::finished, genThread, &QThread::deleteLater);
connect(genThread, &QThread::finished, gen, &QThread::deleteLater);
connect(genThread, &QThread::started, gen, &TimelineImageGenerator::exportImage);
connect(gen, &TimelineImageGenerator::exportFinished, this, &AnalysisWindow::exportFinished);
genThread->start();
}


void AnalysisWindow::on_btnCopyTimeline_clicked()
{
if (selectedNight_ == -1 || (selectedNight_ >= hunt_->nightCount())) {
unhighlightNight();
return;
}
qDebug() << "Generating timeline image.";

QSettings settings;
NightInfo &night = hunt_->night(selectedNight_);
ui->btnExport->setEnabled(false);
ui->btnCopyImg->setEnabled(false);
ui->btnExportTimeline->setEnabled(false);
ui->btnCopyTimeline->setEnabled(false);
isGenerating_.storeRelaxed(1);
TimelineImageGenerator *gen = new TimelineImageGenerator("", night, night.host(), night.squad());
QThread *genThread = new QThread;
gen->moveToThread(genThread);
connect(genThread, &QThread::finished, genThread, &QThread::deleteLater);
connect(genThread, &QThread::finished, gen, &QThread::deleteLater);
connect(genThread, &QThread::started, gen, &TimelineImageGenerator::generateAndEmit);
connect(gen, &TimelineImageGenerator::generateFinished, this, &AnalysisWindow::generateFinished);
genThread->start();
}





}
5 changes: 5 additions & 0 deletions analysiswindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <QImage>
#include <QAtomicInt>


namespace Ui {
class AnalysisWindow;
}
Expand Down Expand Up @@ -34,6 +35,10 @@ private slots:
void exportFinished(bool);
void generateFinished(QImage);

void on_btnExportTimeline_clicked();

void on_btnCopyTimeline_clicked();

void on_btnCopyImg_clicked();

private:
Expand Down
39 changes: 26 additions & 13 deletions analysiswindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,31 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QWidget" name="widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<widget class="QPushButton" name="btnCopyTimeline">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Copy Timeline Image</string>
</property>
<property name="icon">
<iconset resource="assets/breeze.qrc">
<normaloff>:/tl.svg</normaloff>:/tl.svg</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnExportTimeline">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Export Timeline Image</string>
</property>
<property name="icon">
<iconset resource="assets/breeze.qrc">
<normaloff>:/tl.svg</normaloff>:/tl.svg</iconset>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QWidget" name="widget_2" native="true"/>
</item>
</layout>
</widget>
</item>
<item>
Expand All @@ -41,7 +54,7 @@
<bool>false</bool>
</property>
<property name="text">
<string>Copy Image</string>
<string>Copy Summary Image</string>
</property>
<property name="icon">
<iconset resource="assets/breeze.qrc">
Expand All @@ -55,7 +68,7 @@
<bool>false</bool>
</property>
<property name="text">
<string>Export Image</string>
<string>Export Summary Image</string>
</property>
<property name="icon">
<iconset resource="assets/breeze.qrc">
Expand Down
17 changes: 17 additions & 0 deletions assets/breeze.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,22 @@
<file>MaterialDark.qss</file>
<file>png.svg</file>
<file>RobotoMonoV.ttf</file>
<file>tl.svg</file>
<file>timeline/DayBegin.png</file>
<file>timeline/EidolonCapture.png</file>
<file>timeline/EidolonDespawn.png</file>
<file>timeline/EidolonKill.png</file>
<file>timeline/EidolonSpawn.png</file>
<file>timeline/HostJoin.png</file>
<file>timeline/HostUnload.png</file>
<file>timeline/Invalid.png</file>
<file>timeline/LimbBreak.png</file>
<file>timeline/LootDrop.png</file>
<file>timeline/NightBegin.png</file>
<file>timeline/ShardInsert.png</file>
<file>timeline/ShardRemove.png</file>
<file>timeline/ShrineDisable.png</file>
<file>timeline/ShrineEnable.png</file>
<file>timeline/SquadJoin.png</file>
</qresource>
</RCC>
Binary file added assets/timeline/DayBegin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/timeline/EidolonCapture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/timeline/EidolonDespawn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/timeline/EidolonKill.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/timeline/EidolonSpawn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/timeline/HostJoin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/timeline/HostUnload.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/timeline/Invalid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/timeline/LimbBreak.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/timeline/LootDrop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/timeline/NightBegin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/timeline/ShardInsert.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/timeline/ShardRemove.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/timeline/ShrineDisable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/timeline/ShrineEnable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/timeline/SquadJoin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions assets/tl.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions eeparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ void EEParser::startLive()
qDebug() << "Live parsing started.";
emit parsingStarted();
QFile logFile(filename());
watcher_ = new FileWatcher(nullptr, filename());
QThread *watcherThread = new QThread;

watcher_ = new FileWatcher(nullptr, filename());
watcher_->moveToThread(watcherThread);

connect( watcherThread, &QThread::started, watcher_, &FileWatcher::start);
Expand Down Expand Up @@ -197,7 +197,7 @@ LogEventType EEParser::msgToEventType(QString msg, int &val, QString &strVal)
{"TeralystAvatarScript.lua: Teralyst Killed", LogEventType::EidolonKill},
{"SnapPickupToGround.lua: Snapping pickup to ground (DefaultArcanePickup)", LogEventType::LootDrop},
{"TeralystEncounter.lua: Shrine enabled", LogEventType::ShrineEnable},
// {"TeralystEncounter.lua: Shrine disabled", LogEventType::ShrineDisable},
{"TeralystEncounter.lua: Shrine disabled", LogEventType::ShrineDisable},
{"EidolonMP.lua: EIDOLONMP: Finalize Eidolon transition", LogEventType::TeralystSpawn},
{"TeralystEncounter.lua: Eidolon spawning SUCCESS", LogEventType::EidolonSpawn},
{"EidolonMP.lua: EIDOLONMP: Level fully destroyed", LogEventType::HostUnload},
Expand Down Expand Up @@ -237,7 +237,7 @@ LogEventType EEParser::msgToEventType(QString msg, int &val, QString &strVal)
val = parts[0].toInt();
return LogEventType::ShardInsert;
} else if (msg.startsWith("TeralystEncounter.lua: A shard has been removed from the Eidolon Shrine.")) {
return LogEventType::Invalid;
return LogEventType::ShardRemove;
} else {
return LogEventType::Invalid;
}
Expand Down
3 changes: 3 additions & 0 deletions globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ class QString;
#define SUMMARY_COLOR_LAST_LIMB "#283D3B"
#define SUMMARY_COLOR_AVERAGE "#283D3B"

#define TIMELINE_COLOR_ELEMENT "#05aeef"





Expand Down
11 changes: 10 additions & 1 deletion huntinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ QString HuntInfo::eidolonName(int eido, bool abbreviate)

QString HuntInfo::timestampToProgressString(float timestamp)
{
if (timestamp == 0.0) {
if (timestamp < 0.0) {
return "N/A";
}
int tsMins = int(timestamp / 60.0);
Expand Down Expand Up @@ -416,6 +416,15 @@ void RunInfo::setStartTimestamp(float newStartTime)
startTimestamp_ = newStartTime;
}

const QVector<LogEvent> &RunInfo::eventLog() const
{
return eventLog_;
}

void RunInfo::addEvent(const LogEvent &evt) {
eventLog_.push_back(evt);
}

CapInfo::CapInfo():valid_(false), shrineTime_(0), lateShardInsertLog_(false)
{
spawnDelay_ = 0;
Expand Down
5 changes: 5 additions & 0 deletions huntinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <QVector>
#include <QSet>
#include "globals.h"
#include "logevent.h"

namespace Yate {
class AnalysisViewItem;
Expand Down Expand Up @@ -140,11 +141,15 @@ class RunInfo {
float startTimestamp() const;
void setStartTimestamp(float newStartTime);

const QVector<LogEvent> &eventLog() const;
void addEvent(const LogEvent &evt);

private:
CapInfo teralystCapInfo_;
CapInfo gantulystCapInfo_;
CapInfo hydrolystCapInfo_;
float startTimestamp_;
QVector<LogEvent> eventLog_;
};

class NightInfo {
Expand Down
Loading

0 comments on commit 1175fcc

Please sign in to comment.