-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcsteammanager.cpp
90 lines (74 loc) · 2.62 KB
/
csteammanager.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "csteammanager.h"
CSteamManager::CSteamManager()
{
}
CSteamManager::~CSteamManager()
{
}
CSteamManager* CSteamManager::GetInstance()
{
static CSteamManager _instance;
return &_instance;
}
void CSteamManager::Init()
{
if(!SteamAPI_Init())
{
return;
}
m_IsInit = true;
}
bool CSteamManager::IsInitialized() const
{
return m_IsInit;
}
bool CSteamManager::Send_CreateItem()
{
API_CHECK
SteamAPICall_t hSteamAPICall = SteamUGC()->CreateItem(SteamUtils()->GetAppID() , k_EWorkshopFileTypeCommunity);
m_CreateItemResult.Set(hSteamAPICall, this, &CSteamManager::On_ItemCreate_Result);
return true;
}
bool CSteamManager::Send_SubmitItemUpdate(const SteamUgc_UpdateDetail_t& detailInfo)
{
API_CHECK
UGCUpdateHandle_t handle = SteamUGC()->StartItemUpdate(SteamUtils()->GetAppID(), detailInfo.m_nPublishedFileId);
SteamUGC()->SetItemTitle(handle, detailInfo.itemTitle.c_str());
SteamUGC()->SetItemDescription(handle, detailInfo.itemDescription.c_str());
SteamUGC()->SetItemUpdateLanguage(handle, "English");
SteamUGC()->SetItemVisibility(handle, detailInfo.visibilty);
SteamUGC()->SetItemContent(handle, detailInfo.fileFolder.c_str());
SteamUGC()->SetItemPreview(handle, detailInfo.previewImagePath.c_str());
SteamAPICall_t submit_item_call = SteamUGC()->SubmitItemUpdate(handle, detailInfo.changeNote.c_str());
m_SubmitItemUpdateResult.Set(submit_item_call, this, &CSteamManager::On_ItemSubmit_Result);
emit signal_BeginItemUpdate(handle);
return true;
}
void CSteamManager::On_ItemCreate_Result(CreateItemResult_t *pCallback, bool bIOFailure)
{
if(pCallback->m_eResult != k_EResultOK || bIOFailure)
{
qDebug("mod创建失败");
emit signal_ItemCreateFail(pCallback->m_eResult);
return;
}
qDebug("请求创建mod成功");
emit signal_ItemCreateSuccess(pCallback->m_eResult, pCallback->m_nPublishedFileId);
}
void CSteamManager::On_ItemSubmit_Result(SubmitItemUpdateResult_t *pCallback, bool bIOFailure)
{
if(pCallback->m_eResult != k_EResultOK || bIOFailure)
{
qDebug("mod更新失败");
emit signal_ItemSubmitFail(pCallback->m_eResult);
return;
}
qDebug("请求更新mod成功");
emit signal_ItemSubmitSuccess(pCallback->m_eResult, pCallback->m_nPublishedFileId);
}
EItemUpdateStatus CSteamManager::GetItemUpdateProgress(UGCUpdateHandle_t handle, uint64 *punBytesProcessed, uint64* punBytesTotal)
{
if(!IsInitialized())
return EItemUpdateStatus::k_EItemUpdateStatusInvalid;
return SteamUGC()->GetItemUpdateProgress(handle, punBytesProcessed, punBytesTotal);
}