mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-22 18:52:30 +01:00
Add basic but working steam workshop
This commit is contained in:
parent
ca0bfbb281
commit
e6fa34efbf
29
main.cpp
29
main.cpp
@ -11,6 +11,7 @@
|
||||
#include <QQuickStyle>
|
||||
#include <QQuickView>
|
||||
#include <QScreen>
|
||||
#include <QTimer>
|
||||
#include <QUrl>
|
||||
#include <QVariant>
|
||||
#include <QWindow>
|
||||
@ -22,9 +23,9 @@
|
||||
#include "packagefilehandler.h"
|
||||
#include "profilelistmodel.h"
|
||||
#include "quazip/quazip.h"
|
||||
#include "screenplay.h"
|
||||
#include "settings.h"
|
||||
|
||||
#include "steam/steam_api.h"
|
||||
#include "steamworkshop.h"
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
@ -33,6 +34,19 @@ int main(int argc, char* argv[])
|
||||
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
AppId_t steamID = 672870;
|
||||
|
||||
if (SteamAPI_RestartAppIfNecessary(steamID)) {
|
||||
qWarning() << "SteamAPI_RestartAppIfNecessary";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!SteamAPI_Init()) {
|
||||
qWarning() << "Could not init steam sdk!";
|
||||
return 1;
|
||||
}
|
||||
|
||||
SteamWorkshop steamWorkshop(steamID);
|
||||
|
||||
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QCoreApplication::setOrganizationName("Aimber");
|
||||
@ -63,6 +77,7 @@ int main(int argc, char* argv[])
|
||||
mainWindowEngine.rootContext()->setContextProperty("settings", &settings);
|
||||
mainWindowEngine.rootContext()->setContextProperty("packageFileHandler", &packageFileHandler);
|
||||
mainWindowEngine.rootContext()->setContextProperty("profileListModel", &profileListModel);
|
||||
mainWindowEngine.rootContext()->setContextProperty("steamWorkshop", &steamWorkshop);
|
||||
mainWindowEngine.load(QUrl(QStringLiteral("qrc:/qml/main.qml")));
|
||||
|
||||
// FIXME: Needed workaround to close the app because
|
||||
@ -70,9 +85,15 @@ int main(int argc, char* argv[])
|
||||
QObject::connect(&app, &QGuiApplication::lastWindowClosed,
|
||||
[&]() { exit(app.exec()); });
|
||||
|
||||
profileListModel.loadProfiles();
|
||||
// Timer for steam polls. WTF?
|
||||
QTimer timer;
|
||||
QObject::connect(&timer, &QTimer::timeout, [&]() { SteamAPI_RunCallbacks(); });
|
||||
timer.setInterval(500);
|
||||
timer.start();
|
||||
|
||||
int status = app.exec();
|
||||
|
||||
//Shutdown
|
||||
return app.exec();
|
||||
return status;
|
||||
SteamAPI_Shutdown();
|
||||
}
|
||||
|
@ -1,5 +1,23 @@
|
||||
#include "steamworkshop.h"
|
||||
|
||||
SteamWorkshop::SteamWorkshop()
|
||||
SteamWorkshop::SteamWorkshop(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SteamWorkshop::SteamWorkshop(AppId_t nConsumerAppId)
|
||||
{
|
||||
m_AppId = nConsumerAppId;
|
||||
}
|
||||
|
||||
void SteamWorkshop::createWorkshopItem()
|
||||
{
|
||||
SteamAPICall_t hSteamAPICall = SteamUGC()->CreateItem(m_AppId, EWorkshopFileType::k_EWorkshopFileTypeCommunity);
|
||||
m_createWorkshopItemCallResult.Set(hSteamAPICall, this, &SteamWorkshop::onWorkshopItemCreated);
|
||||
}
|
||||
|
||||
void SteamWorkshop::onWorkshopItemCreated(CreateItemResult_t* pCallback, bool bIOFailure)
|
||||
{
|
||||
|
||||
emit workshopItemCreatedQML(pCallback->m_bUserNeedsToAcceptWorkshopLegalAgreement, pCallback->m_eResult, pCallback->m_nPublishedFileId);
|
||||
}
|
||||
|
@ -3,15 +3,28 @@
|
||||
|
||||
#include <QObject>
|
||||
|
||||
//#include "isteamugc.h"
|
||||
//#include "steam_api.h" public ISteamUGC,
|
||||
|
||||
#include "steam/steam_api.h"
|
||||
#include <QDebug>
|
||||
|
||||
class SteamWorkshop : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
SteamWorkshop();
|
||||
explicit SteamWorkshop(QObject *parent = nullptr);
|
||||
SteamWorkshop(AppId_t nConsumerAppId);
|
||||
|
||||
// ISteamUGC interface
|
||||
public:
|
||||
|
||||
private:
|
||||
void onWorkshopItemCreated(CreateItemResult_t* pCallback, bool bIOFailure);
|
||||
CCallResult<SteamWorkshop, CreateItemResult_t> m_createWorkshopItemCallResult;
|
||||
|
||||
AppId_t m_AppId;
|
||||
public slots:
|
||||
void createWorkshopItem();
|
||||
|
||||
signals:
|
||||
void workshopItemCreatedQML(bool islegalAgreementAccepted, int eResult, int publishedFileId);
|
||||
};
|
||||
|
||||
#endif // STEAMWORKSHOP_H
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user