Skip to content

Commit

Permalink
first concept of dps chart
Browse files Browse the repository at this point in the history
  • Loading branch information
maruncz committed Sep 29, 2023
1 parent eabf642 commit 28b888e
Show file tree
Hide file tree
Showing 25 changed files with 1,344 additions and 145 deletions.
97 changes: 57 additions & 40 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,53 +9,68 @@ set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

find_package(Qt6 REQUIRED COMPONENTS Widgets Charts)

option(BUILD_TESTS OFF)



add_library(CombatLog STATIC
CombatLog/LogLine.h CombatLog/LogLine.cpp
CombatLog/defs.h
CombatLog/SubEvents.h CombatLog/SubEvents.cpp
CombatLog/LineParser.h CombatLog/LineParser.cpp
CombatLog/exceptions.h CombatLog/exceptions.cpp
CombatLog/CombatLog.h CombatLog/CombatLog.cpp
)

target_link_libraries(CombatLog PUBLIC Qt6::Core)

add_library(DataModels STATIC
DataModels/healdatamodel.h DataModels/healdatamodel.cpp
DataModels/ObjectListModel.h DataModels/ObjectListModel.cpp
)

target_link_libraries(DataModels
PUBLIC Qt6::Core
PRIVATE CombatLog)

add_library(filters STATIC
filters/SubSampler.h filters/SubSampler.cpp
)

target_link_libraries(filters PUBLIC Qt6::Core)

add_library(forms STATIC
forms/DamagePerSecond.h forms/DamagePerSecond.cpp forms/DamagePerSecond.ui
forms/SourceSelector.h forms/SourceSelector.cpp forms/SourceSelector.ui
)

target_link_libraries(forms PUBLIC Qt6::Widgets Qt6::Charts
PRIVATE DataModels filters)

set(PROJECT_SOURCES
main.cpp
mainwindow.cpp
mainwindow.h
mainwindow.ui
CombatLog/LogLine.h CombatLog/LogLine.cpp
main.cpp
mainwindow.cpp
mainwindow.h
mainwindow.ui
)

if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(WoWCombatAnalyzer
MANUAL_FINALIZATION
${PROJECT_SOURCES}
CombatLog/defs.h
CombatLog/SubEvents.h CombatLog/SubEvents.cpp
CombatLog/LineParser.h CombatLog/LineParser.cpp
CombatLog/exceptions.h CombatLog/exceptions.cpp
CombatLog/CombatLog.h CombatLog/CombatLog.cpp

)
# Define target properties for Android with Qt 6 as:
# set_property(TARGET WoWCombatAnalyzer APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
# ${CMAKE_CURRENT_SOURCE_DIR}/android)
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
else()
if(ANDROID)
add_library(WoWCombatAnalyzer SHARED
${PROJECT_SOURCES}
)
# Define properties for Android with Qt 5 after find_package() calls as:
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
else()
add_executable(WoWCombatAnalyzer
${PROJECT_SOURCES}
)
endif()
endif()

target_link_libraries(WoWCombatAnalyzer PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
qt_add_executable(WoWCombatAnalyzer
MANUAL_FINALIZATION
${PROJECT_SOURCES}
)

target_link_libraries(WoWCombatAnalyzer PRIVATE Qt6::Widgets Qt6::Charts CombatLog DataModels filters forms)

# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# If you are developing for iOS or macOS you should consider setting an
# explicit, fixed bundle identifier manually though.
if(${QT_VERSION} VERSION_LESS 6.1.0)
set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.WoWCombatAnalyzer)
if("${QT_VERSION}" VERSION_LESS 6.1.0)
set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.WoWCombatAnalyzer)
endif()
set_target_properties(WoWCombatAnalyzer PROPERTIES
${BUNDLE_ID_OPTION}
Expand All @@ -72,6 +87,8 @@ install(TARGETS WoWCombatAnalyzer
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(WoWCombatAnalyzer)
qt_finalize_executable(WoWCombatAnalyzer)

if("${BUILD_TESTS}")
add_subdirectory(tests)
endif()
49 changes: 47 additions & 2 deletions CombatLog/CombatLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,54 @@ CombatLog CombatLog::fromFile(QString filename)
throw CombatLogParserException(QString("Line too long: %1").arg(line.size()).toStdString());
}

ret.lines.append(LogLine::fromRawData(line));
ret.append(LogLine::fromRawData(line));
}


ret.finalize();
return ret;
}

const QList<LogLine> &CombatLog::getLines() const
{
return lines;
}

void CombatLog::append(LogLine line)
{
lines.append(line);

{
auto sourceName = line.getSourceObject().name;
if(!sourceNames.contains(sourceName))
{
sourceNames.append(sourceName);
}
}
{
auto targetName = line.getDestObject().name;
if(!targetNames.contains(targetName))
{
targetNames.append(targetName);
}
}
}

void CombatLog::finalize()
{
sourceNames.sort();
targetNames.sort();
}



const QStringList& CombatLog::getTargetNames() const
{
return targetNames;
}



const QStringList& CombatLog::getSourceNames() const
{
return sourceNames;
}
29 changes: 29 additions & 0 deletions CombatLog/CombatLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,45 @@
#define COMBATLOG_H

#include <QList>
#include <QStringList>
#include "LogLine.h"
#include <optional>

class CombatLog
{
public:

[[nodiscard]] static CombatLog fromFile(QString filename);

[[nodiscard]] const QList<LogLine>& getLines() const;

[[nodiscard]] const QStringList& getSourceNames() const;

[[nodiscard]] const QStringList& getTargetNames() const;

template<typename T>
[[nodiscard]] CombatLog filter(const T& filt) const
{
CombatLog ret;
for(const auto &e : lines)
{
if(filt(e))
{
ret.append(e);
}
}
ret.finalize();
return ret;
}

private:
void append(LogLine line);
void finalize();


QList<LogLine> lines;
QStringList sourceNames;
QStringList targetNames;
};

#endif // COMBATLOG_H
43 changes: 43 additions & 0 deletions CombatLog/LogLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,18 @@ SubEvent LogLine::subeventTypeFromString(QString s)
{
return SubEvent::SPELL_PERIODIC_LEECH;
}
else if(s == "SPELL_CREATE")
{
return SubEvent::SPELL_CREATE;
}
else if(s == "RANGE_DAMAGE")
{
return SubEvent::RANGE_DAMAGE;
}
else if(s == "SPELL_INSTAKILL")
{
return SubEvent::SPELL_INSTAKILL;
}


throw CombatLogParserException(QString("unknown subEvent: %1").arg(s).toStdString());
Expand Down Expand Up @@ -214,6 +226,37 @@ variant_t LogLine::subeventValueFromString(SubEvent type, QStringList list)
return {DamageShieldMissed{list}};
case SubEvent::SPELL_PERIODIC_LEECH:
return {SpellPeriodicLeech{list}};
case SubEvent::SPELL_CREATE:
return {SpellCreate{list}};
case SubEvent::RANGE_DAMAGE:
return {RangeDamage{list}};
case SubEvent::SPELL_INSTAKILL:
return {SpellInstakill{list}};
}
throw CombatLogParserException(QString("unhandled subevent: %1").arg(list.at(0)).toStdString());
}

variant_t LogLine::getSubEventValue() const
{
return subEventValue;
}

SubEvent LogLine::getSubeventType() const
{
return subeventType;
}

Object LogLine::getDestObject() const
{
return destObject;
}

Object LogLine::getSourceObject() const
{
return sourceObject;
}

QDateTime LogLine::getTimestamp() const
{
return timestamp;
}
12 changes: 12 additions & 0 deletions CombatLog/LogLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ class LogLine
public:
[[nodiscard]] static LogLine fromRawData(QString s);

[[nodiscard]] bool filter() const;

QDateTime getTimestamp() const;

Object getSourceObject() const;

Object getDestObject() const;

SubEvent getSubeventType() const;

variant_t getSubEventValue() const;

private:
[[nodiscard]] static QStringList parseTokens(QString s);
[[nodiscard]] static QDateTime parseTimestamp(QString s);
Expand Down
4 changes: 2 additions & 2 deletions CombatLog/SubEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

UnitFlags UnitFlags::fromNum(uint32_t n)
{
static constexpr uint32_t unusedBits{Reaction::unused | Type::unused | Special::unused};
static constexpr uint32_t unusedBits{Reaction::unused | Type::unused};
if(n & unusedBits)
{
throw CombatLogParserException(QString("undefined bits set: %1").arg(n & unusedBits, 8,16).toStdString());
throw CombatLogParserException(QString("undefined bits set: 0x%1").arg(n & unusedBits, 8,16).toStdString());
}

UnitFlags ret;
Expand Down
Loading

0 comments on commit 28b888e

Please sign in to comment.