コード例 #1
0
    public void AddModPack()
    {
        var packName = modPackName.text;

        // validate modpack name
        if (string.IsNullOrEmpty(packName) || packName.Contains("."))
        {
            statusText.text = "Bad modpack name: " + modPackName.text;
        }
        else
        {
            string filename = basePath + packName + ".workshop.json";

            var pack = new WorkshopModPack();
            pack.Save(filename);

            pack.contentfolder = modPackName.text;
            Directory.CreateDirectory(basePath + modPackName.text);

            RefreshPackList();

            SelectModPack(filename);

            CreateWorkshopItem();
        }
    }
コード例 #2
0
    private void SubmitModPack(UGCUpdateHandle_t handle, WorkshopModPack pack)
    {
        SteamAPICall_t call = SteamUGC.SubmitItemUpdate(handle, pack.changenote);

        m_itemSubmitted.Set(call, OnItemSubmitted);
        //In the same way as Creating a Workshop Item, confirm the user has accepted the legal agreement. This is necessary in case where the user didn't initially create the item but is editing an existing item.
    }
コード例 #3
0
 public void OnChanges(WorkshopModPack pack)
 {
     // interface stuff
     pack.previewfile = modPackPreviewFilename.text;
     pack.title       = modPackTitle.text;
     pack.description = modPackDescription.text;
     pack.tags        = new List <string>(modPackTags.text.Split(','));
     pack.visibility  = modPackVisibility.value;
 }
コード例 #4
0
    public static WorkshopModPack Load(string filename)
    {
        WorkshopModPack pack       = null;
        string          jsonString = Utils.LoadTextFile(filename);

        JSON.MakeInto <WorkshopModPack>(JSON.Load(jsonString), out pack);

        pack.filename = filename;

        return(pack);
    }
コード例 #5
0
    private void SetupModPack(UGCUpdateHandle_t handle, WorkshopModPack pack)
    {
        SteamUGC.SetItemTitle(handle, pack.title);
        SteamUGC.SetItemDescription(handle, pack.description);
        SteamUGC.SetItemVisibility(handle, (ERemoteStoragePublishedFileVisibility)pack.visibility);
        SteamUGC.SetItemContent(handle, basePath + pack.contentfolder);
        SteamUGC.SetItemPreview(handle, basePath + pack.previewfile);
        SteamUGC.SetItemMetadata(handle, pack.metadata);

        pack.ValidateTags();
        SteamUGC.SetItemTags(handle, pack.tags);
    }
コード例 #6
0
    public bool ValidateModPack(WorkshopModPack pack)
    {
        statusText.text = "Validating mod pack...";

        string path = basePath + pack.previewfile;

        var info = new FileInfo(path);

        if (info.Length >= 1024 * 1024)
        {
            statusText.text = "ERROR: Preview file must be <1MB!";
            return(false);
        }

        return(true);
    }
コード例 #7
0
    private void UploadModPack(WorkshopModPack pack)
    {
        ulong ulongId = ulong.Parse(pack.publishedfileid);
        var   id      = new PublishedFileId_t(ulongId);

        UGCUpdateHandle_t handle = SteamUGC.StartItemUpdate(new AppId_t(SteamManager.m_steamAppId), id);

        //m_itemUpdated.Set(call);
        //OnItemUpdated(call, false);

        // Only set the changenotes when clicking submit
        pack.changenote = modPackChangeNotes.text;

        currentHandle = handle;
        SetupModPack(handle, pack);
        SubmitModPack(handle, pack);
    }
コード例 #8
0
    public void SelectModPack(string filename)
    {
        if (currentPack != null)
        {
            OnCurrentModPackChanges();
            SaveCurrentModPack();
        }

        var pack = WorkshopModPack.Load(filename);

        if (pack != null)
        {
            currentPack         = pack;
            currentPackFilename = filename;

            RefreshCurrentModPack();
            //EditModPack(filename);
        }
    }
コード例 #9
0
    public void SelectModPack(string filename)
    {
        if(currentPack != null)
        {
            OnCurrentModPackChanges();
            SaveCurrentModPack();
        }

        var pack = WorkshopModPack.Load(filename);

        if (pack != null)
        {
            currentPack = pack;
            currentPackFilename = filename;

            RefreshCurrentModPack();
            //EditModPack(filename);
        }
    }
コード例 #10
0
    public void UploadModPack(WorkshopModPack pack)
    {
        ulong ulongId = ulong.Parse(pack.publishedfileid);
        var id = new PublishedFileId_t(ulongId);

        UGCUpdateHandle_t handle = SteamUGC.StartItemUpdate(new AppId_t(SteamManager.m_steamAppId), id);
        //m_itemUpdated.Set(call);
        //OnItemUpdated(call, false);

        currentHandle = handle;
        SetupModPack(handle, pack);
        SubmitModPack(handle, pack);
    }
コード例 #11
0
 public void SubmitModPack(UGCUpdateHandle_t handle, WorkshopModPack pack)
 {
     SteamAPICall_t call = SteamUGC.SubmitItemUpdate(handle, pack.changenote);
     m_itemSubmitted.Set(call);
     //In the same way as Creating a Workshop Item, confirm the user has accepted the legal agreement. This is necessary in case where the user didn't initially create the item but is editing an existing item.
 }
コード例 #12
0
    public void SetupModPack(UGCUpdateHandle_t handle, WorkshopModPack pack)
    {
        SteamUGC.SetItemTitle(handle, pack.title);
        SteamUGC.SetItemDescription(handle, pack.description);
        SteamUGC.SetItemVisibility(handle, (ERemoteStoragePublishedFileVisibility)pack.visibility);
        SteamUGC.SetItemContent(handle, basePath + pack.contentfolder);
        SteamUGC.SetItemPreview(handle, basePath + pack.previewfile);
        SteamUGC.SetItemMetadata(handle, pack.metadata);

        pack.ValidateTags();
        SteamUGC.SetItemTags(handle, pack.tags);

        // interface stuff
        pack.changenote = modPackChangeNotes.text;
    }
コード例 #13
0
    public void SelectModPack(string filename)
    {
        var pack = WorkshopModPack.Load(filename);

        if (pack != null)
        {
            currentPack = pack;

            RefreshCurrentModPack();

            EditModPack(filename);
        }
    }
コード例 #14
0
    public void AddModPack()
    {
        var packName = modPackName.text;

        // validate modpack name
        if (string.IsNullOrEmpty(packName) || packName.Contains("."))
        {
            statusText.text = "Bad modpack name: " + modPackName.text;
        }
        else
        {
            string filename = basePath + packName + ".workshop.json";

            var pack = new WorkshopModPack();
            pack.Save(filename);

            pack.contentfolder = modPackName.text;
            Directory.CreateDirectory(basePath + modPackName.text);

            RefreshPackList();

            SelectModPack(filename);

            CreateWorkshopItem();
        }
    }
コード例 #15
0
    private void UploadModPack(WorkshopModPack pack)
    {
        ulong ulongId = ulong.Parse(pack.publishedfileid);
        var id = new PublishedFileId_t(ulongId);

        UGCUpdateHandle_t handle = SteamUGC.StartItemUpdate(new AppId_t(SteamManager.m_steamAppId), id);
        //m_itemUpdated.Set(call);
        //OnItemUpdated(call, false);

        // Only set the changenotes when clicking submit
        pack.changenote = modPackChangeNotes.text;

        currentHandle = handle;
        SetupModPack(handle, pack);
        SubmitModPack(handle, pack);
    }
コード例 #16
0
    public bool ValidateModPack(WorkshopModPack pack)
    {
        statusText.text = "Validating mod pack...";

        string path = basePath + pack.previewfile;

        var info = new FileInfo(path);
        if (info.Length >= 1024 * 1024)
        {
            statusText.text = "ERROR: Preview file must be <1MB!";
            return false;
        }

        return true;
    }
コード例 #17
0
    void OnItemCreated(CreateItemResult_t callback, bool ioFailure)
    {
        if (ioFailure)
        {
            statusText.text = "Error: I/O Failure! :(";
            return;
        }

        switch(callback.m_eResult)
        {
            case EResult.k_EResultInsufficientPrivilege:
                // you're banned!
                statusText.text = "Error: Unfortunately, you're banned by the community from uploading to the workshop! Bummer. :(";
                break;
            case EResult.k_EResultTimeout:
                statusText.text = "Error: Timeout :S";
                break;
            case EResult.k_EResultNotLoggedOn:
                statusText.text = "Error: You're not logged into Steam!";
                break;
        }

        if(callback.m_bUserNeedsToAcceptWorkshopLegalAgreement)
        {
            /*
             * Include text next to the button that submits an item to the workshop, something to the effect of: “By submitting this item, you agree to the workshop terms of service” (including the link)
        After a user submits an item, open a browser window to the Steam Workshop page for that item by calling:
        SteamFriends()->ActivateGameOverlayToWebPage( const char *pchURL );
        pchURL should be set to steam://url/CommunityFilePage/PublishedFileId_t replacing PublishedFileId_t with the workshop item Id.
        This has the benefit of directing the author to the workshop page so that they can see the item and configure it further if necessary and will make it easy for the user to read and accept the Steam Workshop Legal Agreement.
             * */
        }

        if(callback.m_eResult == EResult.k_EResultOK)
        {
            statusText.text = "Item creation successful! Published Item ID: " + callback.m_nPublishedFileId.ToString();
            Debug.Log("Item created: Id: " + callback.m_nPublishedFileId.ToString());

            string filename = basePath + modPackName.text + ".workshop.json";

            var pack = new WorkshopModPack();
            pack.publishedfileid = callback.m_nPublishedFileId.ToString();
            pack.Save(filename);

            Directory.CreateDirectory(basePath + modPackName.text);

            RefreshPackList();
        }
    }
コード例 #18
0
 public void OnChanges(WorkshopModPack pack)
 {
     // interface stuff
     pack.previewfile = modPackPreviewFilename.text;
     pack.title = modPackTitle.text;
     pack.description = modPackDescription.text;
     pack.tags = new List<string>(modPackTags.text.Split(','));
     pack.visibility = modPackVisibility.value;
 }