1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-05 10:32:28 +01:00

Move steam enums into util

This makes it easier in general to work with
This commit is contained in:
Elias Steurer 2023-12-01 16:40:59 +01:00
parent 9a583efbd9
commit 0a046cec9f
22 changed files with 2341 additions and 2239 deletions

View File

@ -314,7 +314,6 @@ target_link_libraries(
ScreenPlayUtilplugin
QArchive
Plausibleplugin
SteamSDKQtEnums
Threads::Threads
Qt6::Quick
Qt6::Gui

View File

@ -6,8 +6,8 @@
#endif
#include "ScreenPlay/CMakeVariables.h"
#include "ScreenPlayUtil/steamenumsgenerated.h"
#include "app.h"
#include "steam/steam_qt_enums_generated.h"
#include <QGuiApplication>
#include <QProcessEnvironment>
#include <QQuickStyle>
@ -75,15 +75,6 @@ void App::init()
qWarning() << "Unable to load font from: " << fontsPath;
}
// TODO: This is a workaround because I don't know how to
// init this in the ScreenPlayWorkshop plugin.
// Move to workshop plugin.
qmlRegisterUncreatableMetaObject(ScreenPlayWorkshopSteamEnums::staticMetaObject,
"WorkshopEnums",
1, 0,
"SteamEnums",
"Error: only enums");
using std::make_shared, std::make_unique;
m_globalVariables = make_shared<GlobalVariables>();

View File

@ -21,9 +21,6 @@ Wizards::Wizards(const std::shared_ptr<GlobalVariables>& globalVariables, QObjec
: QObject(parent)
, m_globalVariables(globalVariables)
{
qRegisterMetaType<Wizards::WizardResult>("Wizards::WizardResult");
qmlRegisterUncreatableType<Wizards>("ScreenPlay.Wizards", 1, 0, "WizardResult", "Error only for enums");
qmlRegisterType<Wizards>("ScreenPlay.Wizards", 1, 0, "Wizards");
}
/*!

View File

@ -47,12 +47,14 @@ set(SOURCES
src/logginghandler.cpp
src/projectfile.cpp
src/exitcodes.cpp
src/steamenumsgenerated.cpp
src/util.cpp
src/archive.cpp)
set(HEADER
# cmake-format: sort
inc/public/ScreenPlayUtil/contenttypes.h
inc/public/ScreenPlayUtil/steamenumsgenerated.h
inc/public/ScreenPlayUtil/exitcodes.h
inc/public/ScreenPlayUtil/httpfileserver.h
inc/public/ScreenPlayUtil/logginghandler.h

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
#include "ScreenPlayUtil/steamenumsgenerated.h"
namespace ScreenPlay {
Steam::Steam()
{
}
}

View File

@ -100,8 +100,7 @@ target_link_libraries(
Qt6::Quick
${STEAM_LIB}
ScreenPlayUtil
SteamSDK
SteamSDKQtEnums)
SteamSDK)
qt_add_qml_module(
${PROJECT_NAME}
@ -137,8 +136,7 @@ if(${SCREENPLAY_STEAM})
Qt6::QuickControls2
${PROJECT_NAME}plugin
ScreenPlayUtilplugin
SteamSDK
SteamSDKQtEnums)
SteamSDK)
if(APPLE)
set_target_properties(tst_ScreenPlayWorkshop PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/")

View File

@ -4,7 +4,7 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOMOC ON)
find_package(Qt6 COMPONENTS Core)
find_package(Qt6 COMPONENTS Core Quick)
set(HEADER
public/steam/isteamapplist.h
@ -54,11 +54,5 @@ set(HEADER
if(${SCREENPLAY_STEAM})
qt_add_library(${PROJECT_NAME} STATIC ${HEADER})
target_include_directories(${PROJECT_NAME} PUBLIC public/)
target_link_libraries(${PROJECT_NAME})
target_link_libraries(${PROJECT_NAME} PUBLIC ScreenPlayUtil)
endif()
# We allaways need the generated enums as a workaround to register these enums in app.cpp. Registering in the ScreenPlayWorkshop plugin does
# not work for some reason.
qt_add_library(SteamSDKQtEnums STATIC public/steam/steam_qt_enums_generated.h)
target_include_directories(SteamSDKQtEnums PUBLIC public/)
target_link_libraries(SteamSDKQtEnums PRIVATE Qt6::Core)

View File

@ -16,7 +16,7 @@ def createEnum(name,valueList):
enum_string += "\n{"
enum_string += "\t"+ enum_string_values
enum_string += " };"
enum_string += "\nQ_ENUM_NS(" + name +")"
enum_string += "\nQ_ENUM(" + name +")"
enum_string += "\n\n"
return enum_string
@ -33,15 +33,23 @@ if __name__ == '__main__':
#pragma once
#include <QObject>
#include <QQmlEngine>
namespace ScreenPlayWorkshopSteamEnums {
namespace ScreenPlay {
Q_NAMESPACE
class Steam : public QObject {
Q_OBJECT
QML_ELEMENT
QML_UNCREATABLE("")
Q_CLASSINFO("RegisterEnumClassesUnscoped", "false")
public:
explicit Steam();
"""
file_end = """
};
}
"""
@ -58,7 +66,7 @@ namespace ScreenPlayWorkshopSteamEnums {
file_complete += file_content
file_complete += file_end
with open('public/steam/steam_qt_enums_generated.h', 'w') as outfile:
with open('steamenumsgenerated.h', 'w') as outfile:
outfile.write(file_complete)
print("Update write")

View File

@ -4,7 +4,7 @@ import QtQuick.Controls.Material
import Qt5Compat.GraphicalEffects
import QtQuick.Layouts
import ScreenPlayWorkshop
import WorkshopEnums
import ScreenPlayUtil
import "upload/"
Item {

View File

@ -4,7 +4,7 @@ import QtQuick.Controls.Material
import Qt5Compat.GraphicalEffects
import QtQuick.Layouts
import ScreenPlayWorkshop
import WorkshopEnums
import ScreenPlayUtil as Util
import "upload/"
Item {

View File

@ -5,7 +5,7 @@ import QtQuick.Controls.Material
import QtQuick.Layouts
import QtQuick.Controls.Material.impl
import ScreenPlayWorkshop
import WorkshopEnums
import ScreenPlayUtil
Page {
id: root

View File

@ -1,5 +1,5 @@
// SPDX-License-Identifier: LicenseRef-EliasSteurerTachiom OR AGPL-3.0-only
#include "steam/steam_qt_enums_generated.h"
#include "ScreenPlayUtil/steamenumsgenerated.h"
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQuickStyle>
@ -11,15 +11,6 @@ int main(int argc, char* argv[])
{
QGuiApplication app(argc, argv);
// TODO: This is a workaround because I don't know how to
// init this in the ScreenPlayWorkshop plugin.
// Move to workshop plugin.
qmlRegisterUncreatableMetaObject(ScreenPlayWorkshopSteamEnums::staticMetaObject,
"WorkshopEnums",
1, 0,
"SteamEnums",
"Error: only enums");
// Must be set so we can access the global ScreenPlay settings like install path.
QGuiApplication::setOrganizationName("ScreenPlay");
QGuiApplication::setOrganizationDomain("screen-play.app");

View File

@ -10,7 +10,7 @@
#include "steam/steamtypes.h"
#include "steamapiwrapper.h"
namespace SteamApiWrapper {
namespace ScreenPlay {
bool setItemTags(const QVariant& updateHandle, const QStringList& tags)
{
auto pTags = std::make_unique<SteamParamStringArray_t>();

View File

@ -3,23 +3,23 @@
#include <QStringList>
#include <QVariant>
#include "steam/steam_qt_enums_generated.h"
#include "ScreenPlayUtil/steamenumsgenerated.h"
#include "steam/steamtypes.h"
namespace SteamApiWrapper {
namespace ScreenPlay {
struct ItemUpdateData {
QString m_title;
QString m_description;
QString m_updateLanguage;
QString m_metadata;
ScreenPlayWorkshopSteamEnums::ERemoteStoragePublishedFileVisibility visibility;
ScreenPlay::Steam::ERemoteStoragePublishedFileVisibility visibility;
QStringList m_tags;
QString m_content; // update item content from this local folder
QString m_preview;
QMap<QString, QString> m_keyValueTag; // add new key-value tags for the item. Note that there can be multiple values for a tag.
QString m_changeNote;
QPair<QString, ScreenPlayWorkshopSteamEnums::EItemPreviewType> m_previewFile;
QPair<QString, ScreenPlayWorkshopSteamEnums::EItemPreviewType> m_previewVideo;
QPair<QString, ScreenPlay::Steam::EItemPreviewType> m_previewFile;
QPair<QString, ScreenPlay::Steam::EItemPreviewType> m_previewVideo;
const char* title() const { return m_title.toUtf8().data(); }
const char* description() const { return m_description.toUtf8().data(); }

View File

@ -208,7 +208,7 @@ void SteamWorkshop::subscribeItem(const QVariant publishedFileID)
m_steamAccount->loadAmountSubscribedItems();
}
bool SteamWorkshop::searchWorkshop(const ScreenPlayWorkshopSteamEnums::EUGCQuery enumEUGCQuery)
bool SteamWorkshop::searchWorkshop(const ScreenPlay::Steam::EUGCQuery enumEUGCQuery)
{
qInfo() << "searchWorkshop";
@ -339,7 +339,7 @@ bool SteamWorkshop::queryWorkshopItemFromHandle(SteamWorkshopListModel* listMode
return true;
}
void SteamWorkshop::searchWorkshopByText(const QString text, const ScreenPlayWorkshopSteamEnums::EUGCQuery rankedBy)
void SteamWorkshop::searchWorkshopByText(const QString text, const ScreenPlay::Steam::EUGCQuery rankedBy)
{
qInfo() << "searchWorkshopByText" << text;

View File

@ -18,7 +18,7 @@
// Steam
#include "steam/steam_api.h"
#include "steam/steam_qt_enums_generated.h"
#include "ScreenPlayUtil/steamenumsgenerated.h"
#include "steamaccount.h"
#include "steamworkshoplistmodel.h"
@ -87,9 +87,9 @@ public slots:
void requestWorkshopItemDetails(const QVariant publishedFileID);
void vote(const QVariant publishedFileID, const bool voteUp);
void subscribeItem(const QVariant publishedFileID);
bool searchWorkshop(const ScreenPlayWorkshopSteamEnums::EUGCQuery enumEUGCQuery);
bool searchWorkshop(const ScreenPlay::Steam::EUGCQuery enumEUGCQuery);
void searchWorkshopByText(const QString text,
const ScreenPlayWorkshopSteamEnums::EUGCQuery rankedBy = ScreenPlayWorkshopSteamEnums::EUGCQuery::K_EUGCQuery_RankedByTrend);
const ScreenPlay::Steam::EUGCQuery rankedBy = ScreenPlay::Steam::EUGCQuery::K_EUGCQuery_RankedByTrend);
bool checkAndSetQueryActive()
{

View File

@ -187,7 +187,7 @@ void SteamWorkshopItem::submitItemUpdateStatus(SubmitItemUpdateResult_t* pCallba
if (pCallback->m_bUserNeedsToAcceptWorkshopLegalAgreement)
emit userNeedsToAcceptWorkshopLegalAgreement();
setStatus(static_cast<ScreenPlayWorkshopSteamEnums::EResult>(pCallback->m_eResult));
setStatus(static_cast<ScreenPlay::Steam::EResult>(pCallback->m_eResult));
switch (pCallback->m_eResult) {
case EResult::k_EResultOK: {

View File

@ -15,10 +15,10 @@
#include <QUrl>
// Steam
#include "ScreenPlayUtil/steamenumsgenerated.h"
#include "cstring"
#include "stdlib.h"
#include "steam/steam_api.h"
#include "steam/steam_qt_enums_generated.h"
#include "ScreenPlayUtil/util.h"
#include "steamapiwrapper.h"
@ -32,7 +32,7 @@ class SteamWorkshopItem : public QObject {
Q_PROPERTY(QUrl absolutePath READ absolutePath WRITE setAbsolutePath NOTIFY absolutePathChanged)
Q_PROPERTY(int uploadProgress READ uploadProgress WRITE setUploadProgress NOTIFY uploadProgressChanged)
Q_PROPERTY(QUrl absolutePreviewImagePath READ absolutePreviewImagePath WRITE setAbsolutePreviewImagePath NOTIFY absolutePreviewImagePathChanged)
Q_PROPERTY(ScreenPlayWorkshopSteamEnums::EResult status READ status WRITE setStatus NOTIFY statusChanged)
Q_PROPERTY(ScreenPlay::Steam::EResult status READ status WRITE setStatus NOTIFY statusChanged)
Q_PROPERTY(QVariant publishedFileId READ publishedFileId WRITE setPublishedFileId NOTIFY publishedFileIdChanged)
public:
@ -45,7 +45,7 @@ public:
QUrl absolutePath() const { return m_absolutePath; }
int uploadProgress() const { return m_uploadProgress; }
QUrl absolutePreviewImagePath() const { return m_absolutePreviewImagePath; }
ScreenPlayWorkshopSteamEnums::EResult status() const { return m_status; }
ScreenPlay::Steam::EResult status() const { return m_status; }
QVariant publishedFileId() const { return m_publishedFileId; }
public slots:
@ -90,7 +90,7 @@ public slots:
emit absolutePreviewImagePathChanged(m_absolutePreviewImagePath);
}
void setStatus(ScreenPlayWorkshopSteamEnums::EResult status)
void setStatus(ScreenPlay::Steam::EResult status)
{
if (m_status == status)
return;
@ -115,7 +115,7 @@ signals:
void removeThis(SteamWorkshopItem* item);
void absolutePreviewImagePathChanged(QUrl absolutePreviewImagePath);
void uploadComplete(bool successful);
void statusChanged(ScreenPlayWorkshopSteamEnums::EResult status);
void statusChanged(ScreenPlay::Steam::EResult status);
void uploadFailed(const quint64 m_PublishedFileId);
void userNeedsToAcceptWorkshopLegalAgreement();
void publishedFileIdChanged(QVariant publishedFileId);
@ -136,7 +136,7 @@ private:
quint64 m_appID { 0 };
const int m_updateTimerInterval { 500 };
int m_uploadProgress { 0 }; // 0 - 100
ScreenPlayWorkshopSteamEnums::EResult m_status { ScreenPlayWorkshopSteamEnums::EResult::K_EResultNone };
ScreenPlay::Steam::EResult m_status { ScreenPlay::Steam::EResult::K_EResultNone };
UGCUpdateHandle_t m_UGCUpdateHandle { 0 };
SubmitItemUpdateResult_t m_submitItemUpdateResultHanlde;
QTimer m_updateTimer;

View File

@ -14,7 +14,7 @@
#include "cstring"
#include "stdlib.h"
#include "steam/steam_api.h"
#include "steam/steam_qt_enums_generated.h"
#include "ScreenPlayUtil/steamenumsgenerated.h"
/*!
\class Steam Workshop List Model

View File

@ -6,7 +6,7 @@
#include <QUrl>
#include <QVector>
#include "steam/steam_qt_enums_generated.h"
#include "ScreenPlayUtil/steamenumsgenerated.h"
#include "steamworkshopitem.h"
namespace ScreenPlayWorkshop {
@ -116,12 +116,12 @@ public slots:
QObject::connect(item.get(), &SteamWorkshopItem::uploadComplete, this, [=](bool successful) {
onDataChanged();
});
QObject::connect(item.get(), &SteamWorkshopItem::statusChanged, this, [=](ScreenPlayWorkshopSteamEnums::EResult status) {
QObject::connect(item.get(), &SteamWorkshopItem::statusChanged, this, [=](ScreenPlay::Steam::EResult status) {
onDataChanged();
bool allItemsUploaded = std::all_of(m_uploadListModelItems.cbegin(), m_uploadListModelItems.cend(), [](const auto& item) {
const auto status = item->status();
return status == ScreenPlayWorkshopSteamEnums::EResult::K_EResultOK || status == ScreenPlayWorkshopSteamEnums::EResult::K_EResultFail;
return status == ScreenPlay::Steam::EResult::K_EResultOK || status == ScreenPlay::Steam::EResult::K_EResultFail;
});
if (allItemsUploaded) {