Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,25 @@ export declare namespace workshop {
progress: bigint
total: bigint
}
export function createItem(appId?: number | undefined | null): Promise<UgcResult>
export const enum FileType {
Community = 0,
Microtransaction = 1,
Collection = 2,
Art = 3,
Video = 4,
Screenshot = 5,
Game = 6,
Software = 7,
Concept = 8,
WebGuide = 9,
IntegratedGuide = 10,
Merch = 11,
ControllerBinding = 12,
SteamworksAccessInvite = 13,
SteamVideo = 14,
GameManagedItem = 15
}
export function createItem(appId?: number | undefined | null, fileType?: FileType | undefined | null): Promise<UgcResult>
export function updateItem(itemId: bigint, updateDetails: UgcUpdate, appId?: number | undefined | null): Promise<UgcResult>
export function updateItemWithCallback(itemId: bigint, updateDetails: UgcUpdate, appId: number | undefined | null, successCallback: (data: UgcResult) => void, errorCallback: (err: any) => void, progressCallback?: (data: UpdateProgress) => void, progressCallbackIntervalMs?: number | undefined | null): void
/**
Expand Down
53 changes: 50 additions & 3 deletions src/api/workshop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub mod workshop {
use napi::threadsafe_function::ThreadsafeFunction;
use napi::threadsafe_function::ThreadsafeFunctionCallMode;
use std::path::Path;
use steamworks::{ClientManager, FileType, PublishedFileId, UpdateHandle};
use steamworks::{ClientManager, PublishedFileId, UpdateHandle};
use tokio::sync::oneshot;

#[napi(object)]
Expand Down Expand Up @@ -142,17 +142,64 @@ pub mod workshop {
}

#[napi]
pub async fn create_item(app_id: Option<u32>) -> Result<UgcResult, Error> {
pub enum FileType {
Community,
Microtransaction,
Collection,
Art,
Video,
Screenshot,
Game,
Software,
Concept,
WebGuide,
IntegratedGuide,
Merch,
ControllerBinding,
SteamworksAccessInvite,
SteamVideo,
GameManagedItem,
}

impl From<FileType> for steamworks::FileType {
fn from(file_type: FileType) -> steamworks::FileType {
match file_type {
FileType::Community => steamworks::FileType::Community,
FileType::Microtransaction => steamworks::FileType::Microtransaction,
FileType::Collection => steamworks::FileType::Collection,
FileType::Art => steamworks::FileType::Art,
FileType::Video => steamworks::FileType::Video,
FileType::Screenshot => steamworks::FileType::Screenshot,
FileType::Game => steamworks::FileType::Game,
FileType::Software => steamworks::FileType::Software,
FileType::Concept => steamworks::FileType::Concept,
FileType::WebGuide => steamworks::FileType::WebGuide,
FileType::IntegratedGuide => steamworks::FileType::IntegratedGuide,
FileType::Merch => steamworks::FileType::Merch,
FileType::ControllerBinding => steamworks::FileType::ControllerBinding,
FileType::SteamworksAccessInvite => steamworks::FileType::SteamworksAccessInvite,
FileType::SteamVideo => steamworks::FileType::SteamVideo,
FileType::GameManagedItem => steamworks::FileType::GameManagedItem,
}
}
}

#[napi]
pub async fn create_item(
app_id: Option<u32>,
file_type: Option<FileType>,
) -> Result<UgcResult, Error> {
let client = crate::client::get_client();
let app_id = app_id
.map(steamworks::AppId)
.unwrap_or_else(|| client.utils().app_id());
let file_type = file_type.unwrap_or(FileType::Community);

let (tx, rx) = oneshot::channel();

client
.ugc()
.create_item(app_id, FileType::Community, |result| {
.create_item(app_id, file_type.into(), |result| {
tx.send(result).unwrap();
});

Expand Down
Loading