mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-23 03:02:30 +01:00
Add working upload
This commit is contained in:
parent
48ac3a60d2
commit
6fd4001ab8
2
main.cpp
2
main.cpp
@ -96,7 +96,7 @@ int main(int argc, char* argv[])
|
||||
// Timer for steam polls. WTF?
|
||||
QTimer timer;
|
||||
QObject::connect(&timer, &QTimer::timeout, [&]() { SteamAPI_RunCallbacks(); });
|
||||
timer.setInterval(200);
|
||||
timer.setInterval(100);
|
||||
timer.start();
|
||||
|
||||
int status = app.exec();
|
||||
|
@ -4,6 +4,7 @@ import QtGraphicalEffects 1.0
|
||||
import QtQuick.Controls 2.2
|
||||
import Qt.labs.platform 1.0
|
||||
import QtQuick.Controls.Material 2.2
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
|
||||
import RemoteWorkshopCreationStatus 1.0
|
||||
|
||||
@ -12,6 +13,7 @@ Item {
|
||||
anchors.fill: parent
|
||||
state: "out"
|
||||
Component.onCompleted: state = "in"
|
||||
|
||||
property bool isVideoPlaying: true
|
||||
property url videoFile: ""
|
||||
property url projectFile: ""
|
||||
@ -34,9 +36,10 @@ Item {
|
||||
target: steamWorkshop
|
||||
ignoreUnknownSignals: true
|
||||
onWorkshopItemCreated: {
|
||||
print(userNeedsToAcceptWorkshopLegalAgreement,publishedFileId)
|
||||
steamWorkshop.submitWorkshopItem(txtTitle.text.toString(),
|
||||
txtDescription.text.toString(),
|
||||
"english", "true", projectFile,
|
||||
"english", 0, projectFile,
|
||||
videoFile)
|
||||
}
|
||||
onRemoteWorkshopCreationStatusChanged: {
|
||||
@ -44,6 +47,9 @@ Item {
|
||||
case RemoteWorkshopCreationStatus.Started:
|
||||
timerUpload.start();
|
||||
break;
|
||||
case RemoteWorkshopCreationStatus.ErrorUnknown:
|
||||
timerUpload.stop();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -51,30 +57,44 @@ Item {
|
||||
Timer {
|
||||
id: timerUpload
|
||||
running: false
|
||||
triggeredOnStart: true
|
||||
repeat: true
|
||||
interval: 200
|
||||
interval: 100
|
||||
onTriggered: {
|
||||
var status = steamWorkshop.getItemUpdateProcess()
|
||||
print(status + steamWorkshop.steamWorkshop + " / " + steamWorkshop.bytesTotal)
|
||||
print(status + " - "+ steamWorkshop.itemProcessed + " / " + steamWorkshop.bytesTotal)
|
||||
switch (status) {
|
||||
case 0:
|
||||
txtUploadStatus.text = "The item update handle was invalid, the job might be finished. Who knows..."
|
||||
txtUploadStatus.text = "0. The item update handle was invalid, the job might be finished. Who knows..."
|
||||
break
|
||||
case 1:
|
||||
txtUploadStatus.text = "The item update is processing configuration data."
|
||||
txtUploadStatus.text = "1. The item update is processing configuration data."
|
||||
pbUpload.indeterminate = true
|
||||
break
|
||||
case 2:
|
||||
txtUploadStatus.text = "The item update is reading and processing content files."
|
||||
txtUploadStatus.text = "2. The item update is reading and processing content files."
|
||||
pbUpload.indeterminate = false
|
||||
pbUpload.value = steamWorkshop.itemProcessed / steamWorkshop.bytesTotal
|
||||
break
|
||||
case 3:
|
||||
txtUploadStatus.text = "The item update is uploading content changes to Steam."
|
||||
txtUploadStatus.text = "3. The item update is uploading content changes to Steam."
|
||||
if(steamWorkshop.itemProcessed === 0){
|
||||
if(!pbUpload.indeterminate)
|
||||
pbUpload.indeterminate = true
|
||||
} else {
|
||||
|
||||
if(pbUpload.indeterminate)
|
||||
pbUpload.indeterminate = false
|
||||
|
||||
pbUpload.value = steamWorkshop.itemProcessed / steamWorkshop.bytesTotal
|
||||
}
|
||||
break
|
||||
case 4:
|
||||
txtUploadStatus.text = "The item update is uploading new preview file image."
|
||||
txtUploadStatus.text = "4. The item update is uploading new preview file image."
|
||||
pbUpload.indeterminate = true
|
||||
pbUpload.value = 1
|
||||
break
|
||||
case 5:
|
||||
txtUploadStatus.text = "The item update is committing all changes."
|
||||
txtUploadStatus.text = "5. The item update is committing all changes."
|
||||
timerUpload.running = false
|
||||
break
|
||||
default:
|
||||
@ -373,6 +393,7 @@ Item {
|
||||
opacity: 1
|
||||
}
|
||||
}
|
||||
|
||||
]
|
||||
|
||||
transitions: [
|
||||
|
@ -24,11 +24,22 @@ void SteamWorkshop::createWorkshopItem()
|
||||
m_createWorkshopItemCallResult.Set(hSteamAPICall, this, &SteamWorkshop::workshopItemCreated);
|
||||
}
|
||||
|
||||
void SteamWorkshop::workshopItemCreated(CreateItemResult_t* pCallback, bool bIOFailure)
|
||||
{
|
||||
if (bIOFailure)
|
||||
return;
|
||||
|
||||
m_UGCUpdateHandle = SteamUGC()->StartItemUpdate(m_AppId, pCallback->m_nPublishedFileId);
|
||||
emit workshopItemCreated(pCallback->m_bUserNeedsToAcceptWorkshopLegalAgreement, pCallback->m_eResult, pCallback->m_nPublishedFileId);
|
||||
|
||||
}
|
||||
|
||||
void SteamWorkshop::submitWorkshopItem(QString title, QString description, QString language, int remoteStoragePublishedFileVisibility, const QUrl projectFile, const QUrl videoFile)
|
||||
{
|
||||
|
||||
// Ether way one of the url must have a value
|
||||
if (videoFile.isEmpty() && projectFile.isEmpty()) {
|
||||
emit remoteWorkshopCreationStatusChanged(RemoteWorkshopCreationStatus::ErrorUnknown);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -39,11 +50,9 @@ void SteamWorkshop::submitWorkshopItem(QString title, QString description, QStri
|
||||
tmp.setFile(projectFile.toString());
|
||||
absoluteContentPath = tmp.path();
|
||||
absoluteContentPath = absoluteContentPath.replace("file:///", "");
|
||||
|
||||
absoluteContentPath += "/";
|
||||
projectConfig.setFileName(absoluteContentPath + "/project.json");
|
||||
|
||||
qDebug() << "####" << projectFile << "###" << absoluteContentPath;
|
||||
|
||||
QJsonObject jsonObject;
|
||||
QJsonDocument jsonProject;
|
||||
QJsonParseError parseError;
|
||||
@ -52,27 +61,26 @@ void SteamWorkshop::submitWorkshopItem(QString title, QString description, QStri
|
||||
QString projectConfigData = projectConfig.readAll();
|
||||
jsonProject = QJsonDocument::fromJson(projectConfigData.toUtf8(), &parseError);
|
||||
|
||||
if (!(parseError.error == QJsonParseError::NoError))
|
||||
if (!(parseError.error == QJsonParseError::NoError)) {
|
||||
emit remoteWorkshopCreationStatusChanged(RemoteWorkshopCreationStatus::ErrorUnknown);
|
||||
return;
|
||||
}
|
||||
|
||||
jsonObject = jsonProject.object();
|
||||
|
||||
QString video = absoluteContentPath + "/" + jsonObject.value("file").toString();
|
||||
QString thumb = absoluteContentPath + "/" + jsonObject.value("preview").toString();
|
||||
|
||||
qDebug() << jsonObject << video << thumb;
|
||||
QString preview = absoluteContentPath + jsonObject.value("preview").toString();
|
||||
//absoluteContentPath = absoluteContentPath.replace("/", "\\\\");
|
||||
|
||||
SteamUGC()->SetItemTitle(m_UGCUpdateHandle, QByteArray(title.toLatin1()).data());
|
||||
SteamUGC()->SetItemDescription(m_UGCUpdateHandle, QByteArray(description.toLatin1()).data());
|
||||
SteamUGC()->SetItemUpdateLanguage(m_UGCUpdateHandle, QByteArray(language.toLatin1()).data());
|
||||
SteamUGC()->SetItemContent(m_UGCUpdateHandle, QByteArray(absoluteContentPath.toLatin1()).data());
|
||||
SteamUGC()->SetItemPreview(m_UGCUpdateHandle, QByteArray(preview.toLatin1()).data());
|
||||
|
||||
auto visibility = static_cast<ERemoteStoragePublishedFileVisibility>(remoteStoragePublishedFileVisibility);
|
||||
SteamUGC()->SetItemContent(m_UGCUpdateHandle, QByteArray(video.toLatin1()).data());
|
||||
SteamUGC()->SetItemPreview(m_UGCUpdateHandle, QByteArray(thumb.toLatin1()).data());
|
||||
SteamUGC()->SetItemVisibility(m_UGCUpdateHandle, visibility);
|
||||
SteamUGC()->SubmitItemUpdate(m_UGCUpdateHandle, nullptr);
|
||||
|
||||
emit remoteWorkshopCreationStatusChanged(RemoteWorkshopCreationStatus::Started);
|
||||
|
||||
SteamUGC()->SubmitItemUpdate(m_UGCUpdateHandle, nullptr);
|
||||
}
|
||||
|
||||
int SteamWorkshop::getItemUpdateProcess()
|
||||
@ -80,9 +88,9 @@ int SteamWorkshop::getItemUpdateProcess()
|
||||
unsigned long long _itemProcessed = 0;
|
||||
unsigned long long _bytesTotoal = 0;
|
||||
EItemUpdateStatus status = SteamUGC()->GetItemUpdateProgress(m_UGCUpdateHandle, &_itemProcessed, &_bytesTotoal);
|
||||
qDebug() << _itemProcessed << _bytesTotoal;
|
||||
setItemProcessed(static_cast<unsigned int>(_itemProcessed));
|
||||
setBytesTotal(static_cast<unsigned int>(_bytesTotoal));
|
||||
qDebug() << _itemProcessed << _bytesTotoal << status ;
|
||||
setItemProcessed(_itemProcessed);
|
||||
setBytesTotal(_bytesTotoal);
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -174,15 +182,6 @@ void SteamWorkshop::subscribeItem(unsigned int id)
|
||||
SteamUGC()->SubscribeItem(static_cast<unsigned long long>(id));
|
||||
}
|
||||
|
||||
void SteamWorkshop::workshopItemCreated(CreateItemResult_t* pCallback, bool bIOFailure)
|
||||
{
|
||||
if (bIOFailure)
|
||||
return;
|
||||
|
||||
emit workshopItemCreated(pCallback->m_bUserNeedsToAcceptWorkshopLegalAgreement, pCallback->m_eResult, pCallback->m_nPublishedFileId);
|
||||
m_UGCUpdateHandle = SteamUGC()->StartItemUpdate(m_AppId, pCallback->m_nPublishedFileId);
|
||||
}
|
||||
|
||||
void SteamWorkshop::searchWorkshop()
|
||||
{
|
||||
m_UGCSearchHandle = SteamUGC()->CreateQueryAllUGCRequest(EUGCQuery::k_EUGCQuery_RankedByVote,
|
||||
|
@ -71,7 +71,7 @@ public:
|
||||
public slots:
|
||||
void searchWorkshop();
|
||||
void createWorkshopItem();
|
||||
void submitWorkshopItem(QString title, QString description, QString language, int remoteStoragePublishedFileVisibility, const QUrl projectFile , const QUrl videoFile);
|
||||
void submitWorkshopItem(QString title, QString description, QString language, int remoteStoragePublishedFileVisibility, const QUrl projectFile, const QUrl videoFile);
|
||||
void getAPICallInfo();
|
||||
void createLocalWorkshopItem(QString title, QUrl videoPath, QUrl previewPath);
|
||||
void subscribeItem(unsigned int id);
|
||||
@ -113,11 +113,11 @@ private:
|
||||
CCallResult<SteamWorkshop, SteamUGCQueryCompleted_t> m_steamUGCQueryResult;
|
||||
|
||||
AppId_t m_AppId;
|
||||
UGCUpdateHandle_t m_UGCUpdateHandle;
|
||||
UGCQueryHandle_t m_UGCSearchHandle;
|
||||
UGCUpdateHandle_t m_UGCUpdateHandle = 0;
|
||||
UGCQueryHandle_t m_UGCSearchHandle = 0;
|
||||
SteamAPICall_t m_searchCall;
|
||||
SteamWorkshopListModel* m_workshopListModel;
|
||||
Settings* m_settings;
|
||||
unsigned int m_itemProcessed;
|
||||
unsigned int m_bytesTotal;
|
||||
unsigned int m_itemProcessed = 0;
|
||||
unsigned int m_bytesTotal = 0;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user