示例#1
0
    void OnCreateItemResult(CreateItemResult_t p, bool ioFailure)
    {
        bool ok = true;

        this.lastResult = p.m_eResult;

        if (ioFailure)
        {
            SetError("Create Item failed, IO Failure!");
            ok = false;
        }
        else if (p.m_eResult != EResult.k_EResultOK)
        {
            SetError("Create Item failed, error: " + p.m_eResult.ToString());
            ok = false;
        }
        else
        {
            this.needsToAcceptWorkshopLegalAgreement = p.m_bUserNeedsToAcceptWorkshopLegalAgreement;

            this.currentItem       = new WorkshopItem(p.m_nPublishedFileId);
            this.currentItem.title = "My new item";
        }

        if (OnCreateItemDone != null)
        {
            OnCreateItemDone(ok, p.m_nPublishedFileId);
        }

        SignalStateChanged();
    }
    private void OnQueryCompleted(SteamUGCQueryCompleted_t p_callback, bool p_bIOFailure)
    {
        waitingOnQuery = false;
        items.Clear();

        if (p_bIOFailure || p_callback.m_eResult != EResult.k_EResultOK)
        {
            Util.LogError($"Failed to query featured workshop items. Result code: {p_callback.m_eResult}");
            return;
        }

        for (uint i = 0; i < p_callback.m_unNumResultsReturned; i++)
        {
            SteamUGCDetails_t itemDetails;
            if (SteamUGC.GetQueryUGCResult(p_callback.m_handle, i, out itemDetails))
            {
                if (itemDetails.m_eResult != Steamworks.EResult.k_EResultOK)
                {
                    Util.LogError($"Something is wrong with featured file ID {FeaturedPublishedFileIds[i]} - ignoring.");
                }
                else
                {
                    WorkshopItem item = SteamWorkshopMain.Instance.RegisterQueryResultItem(p_callback.m_handle, i, itemDetails);
                    items.Add(item);
                    // Util.Log($"got WorkshopItem for featured ID {item.SteamNative.m_nPublishedFileId}, name is {item.Name} {item.PreviewImageURL}. sub'd? {item.IsSubscribed}");
                }
            }
            else
            {
                Util.LogError($"Could not query details of featured file ID {FeaturedPublishedFileIds[i]} - ignoring.");
            }
        }
    }
 public void Open(string text, WorkshopItem item)
 {
     this.opened = true;
     this._text  = text;
     SFX.Play("openClick", 0.4f);
     this._item = item;
 }
示例#4
0
        private static void OnQueryCompleted(SteamUGCQueryCompleted_t p_callback, bool p_bIOFailure, WorkShopItemHandler handleItem, ulong requestedFileId)
        {
            if (p_bIOFailure || p_callback.m_eResult != EResult.k_EResultOK)
            {
                Util.LogError($"Failed to query workshop item {requestedFileId}. Result code: {p_callback.m_eResult}");
                handleItem(Util.Maybe <WorkshopItem> .CreateEmpty());
                return;
            }

            // There should just be 1..but doesn't hurt.
            for (uint i = 0; i < p_callback.m_unNumResultsReturned; i++)
            {
                SteamUGCDetails_t itemDetails;
                if (SteamUGC.GetQueryUGCResult(p_callback.m_handle, i, out itemDetails))
                {
                    if (itemDetails.m_eResult != Steamworks.EResult.k_EResultOK)
                    {
                        Util.LogError($"Something is wrong with workshop item {requestedFileId} - returning empty. Result code: {itemDetails.m_eResult}");
                        handleItem(Util.Maybe <WorkshopItem> .CreateEmpty());
                    }
                    else
                    {
                        WorkshopItem item = SteamWorkshopMain.Instance.RegisterQueryResultItem(p_callback.m_handle, i, itemDetails);
                        handleItem(Util.Maybe <WorkshopItem> .CreateWith(item));
                    }
                }
                else
                {
                    Util.LogError($"Could not query details of workshop item {requestedFileId} - returning empty. Result code: {itemDetails.m_eResult}");
                    handleItem(Util.Maybe <WorkshopItem> .CreateEmpty());
                }
            }
        }
示例#5
0
    private void OnOwnedItemSelectedForUpdate(WorkshopItem p_item)
    {
        uMyGUI_PopupManager.Instance.HidePopup(uMyGUI_PopupManager.POPUP_DROPDOWN);

        // only installed items can be updated
        if (!p_item.IsInstalled)
        {
            ((uMyGUI_PopupText)uMyGUI_PopupManager.Instance.ShowPopup(uMyGUI_PopupManager.POPUP_TEXT))
            .SetText("Not Installed", "This item is not installed. Please subscribe this item first!")
            .ShowButton(uMyGUI_PopupManager.BTN_OK, Start);                     // retry on OK button
            return;
        }

        // generate a WorkshopItemUpdate instance
        WorkshopItemUpdate updateExistingItem = new WorkshopItemUpdate(p_item);

        string itemContentFile = Path.Combine(updateExistingItem.ContentPath, "ItemData.txt");

        if (File.Exists(itemContentFile))
        {
            // update the content of your item
            File.AppendAllText(itemContentFile, "\nUpdate - " + System.DateTime.Now);

            // show the Steam Workshop item upload popup
            ((SteamWorkshopPopupUpload)uMyGUI_PopupManager.Instance.ShowPopup("steam_ugc_upload")).UploadUI.SetItemData(updateExistingItem);
        }
        else
        {
            ((uMyGUI_PopupText)uMyGUI_PopupManager.Instance.ShowPopup(uMyGUI_PopupManager.POPUP_TEXT))
            .SetText("Not Installed", "This item is subscribed, but not installed. Please sync local files in Steam!")
            .ShowButton(uMyGUI_PopupManager.BTN_OK, Start);                     // retry on OK button
        }
    }
        public static void InitializeLevels()
        {
            MonoMain.loadMessage = "Loading Levels";
            DuckGame.Content.SearchDirLevels("Content/levels", LevelLocation.Content);
            DuckGame.Content.SearchDirLevels(DuckFile.levelDirectory, LevelLocation.Custom);
            if (!Steam.IsInitialized())
            {
                return;
            }
            bool done = false;
            WorkshopQueryUser queryUser = Steam.CreateQueryUser(Steam.user.id, WorkshopList.Subscribed, WorkshopType.UsableInGame, WorkshopSortOrder.TitleAsc);

            queryUser.requiredTags.Add("Map");
            queryUser.onlyQueryIDs   = true;
            queryUser.QueryFinished += (WorkshopQueryFinished)(sender => done = true);
            queryUser.ResultFetched += (WorkshopQueryResultFetched)((sender, result) =>
            {
                WorkshopItem publishedFile = result.details.publishedFile;
                if ((publishedFile.stateFlags & WorkshopItemState.Installed) == WorkshopItemState.None)
                {
                    return;
                }
                DuckGame.Content.SearchDirLevels(publishedFile.path, LevelLocation.Workshop);
            });
            queryUser.Request();
            while (!done)
            {
                Steam.Update();
                Thread.Sleep(13);
            }
        }
示例#7
0
 public static void Update()
 {
     if (!Steam.IsInitialized() || !Network.isServer || TeamSelect2.GetSettingInt("workshopmaps") <= 0)
     {
         return;
     }
     if (RandomLevelDownloader._downloading != null)
     {
         if (!RandomLevelDownloader._downloading.finishedProcessing)
         {
             return;
         }
         if (RandomLevelDownloader._downloading.downloadResult == SteamResult.OK)
         {
             RandomLevelDownloader.SearchDirLevels(RandomLevelDownloader._downloading.path, LevelLocation.Workshop);
         }
         RandomLevelDownloader._downloading = (WorkshopItem)null;
     }
     else
     {
         if (RandomLevelDownloader._currentQuery != null || RandomLevelDownloader._readyLevels.Count == RandomLevelDownloader.numToHaveReady)
         {
             return;
         }
         RandomLevelDownloader._toFetchIndex = -1;
         RandomLevelDownloader._numFetch     = 0;
         RandomLevelDownloader._currentQuery = Steam.CreateQueryAll(RandomLevelDownloader._orderMode, WorkshopType.Items);
         RandomLevelDownloader._currentQuery.requiredTags.Add("Deathmatch");
         RandomLevelDownloader._currentQuery.QueryFinished += new WorkshopQueryFinished(RandomLevelDownloader.FinishedTotalQuery);
         RandomLevelDownloader._currentQuery.fetchedData    = WorkshopQueryData.TotalOnly;
         RandomLevelDownloader._currentQuery.Request();
         DevConsole.Log(DCSection.Steam, "Querying for random levels.");
     }
 }
示例#8
0
            public static bool Prefix(PublishedFileId_t pfid)
            {
                // TODO: display some sort of in-progress indicator
                Debug.Log("Notify_Subscribed");

                // check if item was already present.
                var item = WorkshopItem.MakeFrom(pfid);

                if (item is WorkshopItem_Mod item_installed)
                {
                    // register item in WorkshopItems
                    workshopitems.Add(item_installed);

                    // register item in ModLister
                    var mod = new ModMetaData(item_installed);
                    modlister.Add(mod);

                    // show a message
                    Messages.Message(I18n.ModInstalled(mod.Name), MessageTypeDefOf.PositiveEvent, false);

                    // notify button manager that we done stuff.
                    ModButtonManager.Notify_DownloadCompleted(mod);
                }
                else
                {
                    // add dowloading item to MBM
                    var button = new ModButton_Downloading(pfid);
                    ModButtonManager.TryAdd(button);
                    Page_BetterModConfig.Instance.Selected = button;
                }

                // do whatever needs doing for ScenarioLister.
                ScenarioLister.MarkDirty();
                return(false);
            }
 /// <summary>
 /// Internal method triggering the SteamWorkshopUIBrowse.OnItemDataSet event with exception handling. Required to ensure code execution even if your code throws exceptions.
 /// </summary>
 public void InvokeOnItemDataSet(WorkshopItem p_itemData, SteamWorkshopItemNode p_itemUI)
 {
     InvokeEventHandlerSafely(OnItemDataSet, new SteamWorkshopItemNode.ItemDataSetEventArgs()
     {
         ItemData = p_itemData, ItemUI = p_itemUI
     });
 }
示例#10
0
 private void OnSubscribed(WorkshopItemEventArgs args)
 {
     if (args.Item.SteamNative.m_nPublishedFileId == workshopItem.SteamNative.m_nPublishedFileId)
     {
         workshopItem = args.Item;
         unsubscribeButton.gameObject.SetActive(true);
     }
 }
示例#11
0
    public unsafe static bool DownloadWorkshopItem(WorkshopItem item)
    {
        bool result = SteamUGC.DownloadItem(new PublishedFileId_t(item.id), true);

        item.ResetProcessing();
        _pendingItemDownload = item;
        return(result);
    }
示例#12
0
    public void SetCurrentItem(WorkshopItem item)
    {
        CheckInitialized();

        this.currentItem = item;

        SignalStateChanged();
    }
示例#13
0
 void OpenWorkshopEntry(GameThumbnail gameThumbnail, WorkshopItem item)
 {
     SelectThumbnail(gameThumbnail, (rect) =>
     {
         gameDetail.FitTo(rect);
         gameDetail.OpenWorkshop(gameThumbnail.GetTexture(), item);
     });
 }
 void OpenWorkshopEntry(ThumbnailItem thumbnailItem, WorkshopItem item)
 {
     SelectThumbnail(thumbnailItem, (rect) =>
     {
         cardPackDetail.FitTo(rect);
         cardPackDetail.Open(thumbnailItem.GetTexture(), item);
     });
 }
示例#15
0
 void OnUnsubscribed(WorkshopItemEventArgs args)
 {
     // Debug.Log(args.ErrorMessage);
     // if (args.IsError) Debug.Log(args.ErrorMessage);
     // else Debug.Log("ybsubbed" + args.Item.IsSubscribed);
     workshopItem             = args.Item;
     subscribeButtonText.text = SUBSCRIBE_TEXT;
 }
 void OpenWorkshopEntry(ThumbnailItem thumbnailItem, WorkshopItem item)
 {
     SelectThumbnail(thumbnailItem, (rect) =>
     {
         actorPrefabDetail.FitTo(rect);
         actorPrefabDetail.Open(thumbnailItem.GetTexture(), item);
     });
 }
示例#17
0
 public void SetWorkshopItem(WorkshopItem item)
 {
     gameObject.SetActive(true);
     workshopItem  = item;
     localVoosFile = null;
     SetThumbnailUrl(item.PreviewImageURL);
     nameField.text = $"<b>{item.Name}</b>";//\n{item.Description}";
 }
示例#18
0
 public unsafe static void StartUpload(WorkshopItem item)
 {
     if (!_initialized)
     {
         return;
     }
     _pendingItem = item;
     SetCallResult <SubmitItemUpdateResult_t>(SteamUGC.SubmitItemUpdate(new UGCUpdateHandle_t(item.updateHandle), item.data.changeNotes));
 }
示例#19
0
 public void SetLocalVoosFile(string localFileFullPath, string localThumbnailFullPath, string title, string description)
 {
     gameObject.SetActive(true);
     workshopItem  = null;
     localVoosFile = localFileFullPath;
     // The file:// prefix is necessary on OSX.
     SetThumbnailUrl("file://" + localThumbnailFullPath);
     nameField.text = $"<b>{title}</b>\n{description}";
 }
示例#20
0
 private void ImportAsset(WorkshopItem item)
 {
     if (item.InstalledLocalFolder.IsNullOrEmpty())
     {
         Debug.LogError("Item was not installed");
         return;
     }
     DoImport(item);
 }
示例#21
0
    public void Open(WorkshopItem newItem)
    {
        workshopItem                 = newItem;
        infoUI.titleField.text       = newItem.Name;
        infoUI.descriptionField.text = newItem.Description;
        SetThumbnailUrl(newItem.PreviewImageURL);

        gameObject.SetActive(true);
    }
 public void Close()
 {
     Editor.lockInput = (ContextMenu)null;
     this.opened      = false;
     this._descriptionBox.LoseFocus();
     this._nameBox.LoseFocus();
     this._currentItem = (WorkshopItem)null;
     this.ClearItems();
 }
示例#23
0
 public static WorkshopItem CreateItem()
 {
     if (!_initialized)
     {
         return(null);
     }
     _pendingItem = new WorkshopItem();
     SetCallResult <CreateItemResult_t>(SteamUGC.CreateItem(SteamUtils.GetAppID(), EWorkshopFileType.k_EWorkshopFileTypeFirst));
     return(_pendingItem);
 }
示例#24
0
 private void OnUnsubscribeButtonClicked()
 {
     SteamWorkshopMain.Instance.Unsubscribe(workshopItem, (args) =>
     {
         if (args.Item.SteamNative.m_nPublishedFileId == workshopItem.SteamNative.m_nPublishedFileId)
         {
             workshopItem = args.Item;
             unsubscribeButton.gameObject.SetActive(false);
         }
     });
 }
示例#25
0
 string GetWorkshopHeader(WorkshopItem item)
 {
     if (item.VotesUp + item.VotesDown > 5)
     {
         return($"{Mathf.RoundToInt(100 * item.VotesUp / (item.VotesUp + item.VotesDown))}% rating - {item.Subscriptions} subs");
     }
     else
     {
         return($"{item.Subscriptions} subscribers");
     }
 }
示例#26
0
 public void Open(Texture2D texture, WorkshopItem item)
 {
     gameObject.SetActive(true);
     workshopItem           = item;
     workshopItemInProgress = false;
     descriptionField.text  = $"<b>{item.Name}</b> - {GetWorkshopHeader(item)}\n{item.Description}";
     if (texture != null)
     {
         thumbnailImage.sprite = Sprite.Create(
             texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0, 0), 100F, 0, SpriteMeshType.FullRect);
     }
     unsubscribeButton.gameObject.SetActive(workshopItem.IsSubscribed);
 }
示例#27
0
 private static void Fetched(object sender, WorkshopQueryResult result)
 {
     if (RandomLevelDownloader._toFetchIndex == -1)
     {
         RandomLevelDownloader._toFetchIndex = Rando.Int((int)(sender as WorkshopQueryAll).numResultsFetched);
     }
     if (RandomLevelDownloader._toFetchIndex == RandomLevelDownloader._numFetch && Steam.DownloadWorkshopItem(result.details.publishedFile))
     {
         RandomLevelDownloader._downloading = result.details.publishedFile;
     }
     RandomLevelDownloader._currentQuery = (WorkshopQueryAll)null;
     ++RandomLevelDownloader._numFetch;
 }
示例#28
0
    public unsafe static List <WorkshopItem> GetAllWorkshopItems()
    {
        if (!_initialized)
        {
            return(new List <WorkshopItem>());
        }
        // FIXME: This seems wrong, but the original basically just does this.
        PublishedFileId_t[] tmp = new PublishedFileId_t[GetNumWorkshopItems()];
        SteamUGC.GetSubscribedItems(tmp, (uint)tmp.Length);
        List <WorkshopItem> list = _.GetList(tmp.Length, i => WorkshopItem.GetItem(tmp[i].m_PublishedFileId));

        RequestWorkshopInfo(list);
        return(list);
    }
示例#29
0
 public void OpenWorkshop(Texture2D texture, WorkshopItem item)
 {
     gameObject.SetActive(true);
     gameSource            = GameSource.Workshop;
     workshopItem          = item;
     descriptionField.text = $"<b>{workshopItem.Name}</b> - {GetWorkshopHeader(workshopItem)}\n{workshopItem.Description}";
     if (texture != null)
     {
         thumbnailImage.sprite = Sprite.Create(
             texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0, 0), 100F, 0, SpriteMeshType.FullRect);
     }
     playAction  = () => OnPlayTriggered(playOpts => LoadByWorkshopItem(workshopItem, playOpts));
     buildAction = () => popups.Show("Not implemented", "OK", () => { });
     subscribeButtonText.text = workshopItem.IsSubscribed ? UNSUBSCRIBE_TEXT : SUBSCRIBE_TEXT;
 }
示例#30
0
    IEnumerator DownloadRoutine(WorkshopItem item, System.Action <Util.Maybe <string> > onComplete, System.Action <float> onProgress)
    {
        float t0 = Time.realtimeSinceStartup;

        while (true)
        {
            onProgress?.Invoke(SteamWorkshopMain.Instance.GetDownloadProgress(item));

            Util.Log($"Downloading work shop item {item.GetId()}.. progress: {SteamWorkshopMain.Instance.GetDownloadProgress(item)}. Still downloading? {item.IsDownloading}");

            //if (!item.IsSubscribed)
            //{
            //  onComplete(Util.Maybe<string>.CreateError($"Workshop item {item.GetId()} was requested for download but not subscribed?"));
            //  yield break;
            // }

            if (item.IsInstalled)
            {
                if (item.InstalledLocalFolder == null)
                {
                    onComplete(Util.Maybe <string> .CreateError($"Workshop item {item.GetId()} was installed but with no local folder?"));
                    yield break;
                }
                else
                {
                    onComplete(Util.Maybe <string> .CreateWith(item.InstalledLocalFolder));
                    yield break;
                }
            }

            if (Time.realtimeSinceStartup - t0 > 300f)
            {
                onComplete(Util.Maybe <string> .CreateError($"Workshop item {item.GetId()} has been downloading for over 5 minutes - giving up."));
            }

            // IMPORTANT: IsInstalled and IsDownloading can be set at the same time so we should always check
            // IsInstalled first before deciding that we failed.
            if (!item.IsDownloading)
            {
                // OK we failed some how.
                onComplete(Util.Maybe <string> .CreateError($"Workshop item {item.GetId()} failed to download. It may be missing."));
                yield break;
            }

            yield return(new WaitForSeconds(1f));
        }
    }