void OnWorkshopUploadComplete(Util.Maybe <ulong> result)
    {
        pleaseWait.SetActive(false);
        if (result.IsEmpty())
        {
            // Error.
            popups.Show("Failed to upload image to Steam Workshop. " + result.GetErrorMessage(), "OK", () => { });
            return;
        }
        popups.Show("Image uploaded successfully.", "OK", () => { });
        LoadPreviewImage("sw:" + result.Get());
        ulong steamWorkshopId = result.Get();

        // Import image into the Image System and get its ID.
        currentImageId = imageSystem.ImportImageFromUrl("sw:" + steamWorkshopId);
    }
 private void OnUploadComplete(string name, string desc, Util.Maybe <ulong> result)
 {
     uploadProgressGetter = null;
     if (result.GetErrorMessage() != null)
     {
         finishedMessage.text = result.GetErrorMessage();
     }
     else
     {
         string url = $"https://steamcommunity.com/sharedfiles/filedetails/?id={result.Get()}";
         finishedMessage.text = "Finished uploading! (Note: takes about 15 minutes to show up for other players)";
         visitButton.onClick.AddListener(() => Application.OpenURL(url));
         visitButton.gameObject.SetActive(true);
         OnUploadSuccess(result.Get());
     }
 }
Esempio n. 3
0
    public Util.Maybe <TReturn> CallBehaviorUseMethod <TArgs, TReturn>(string useId, string actorId, string methodName, TArgs args)
    {
        using (Util.Profile("CallBehaviorUseMethod"))
        {
            var request = new CallBehaviorUseMethodRequest <TArgs>
            {
                actorId    = actorId,
                useId      = useId,
                methodName = methodName,
                args       = args
            };

            Util.Maybe <CallBehaviorUseMethodResponse <TReturn> > response =
                voosEngine.CommunicateWithAgent <CallBehaviorUseMethodRequest <TArgs>, CallBehaviorUseMethodResponse <TReturn> >(request);

            if (response.IsEmpty())
            {
                return(Util.Maybe <TReturn> .CreateEmpty());
            }
            else
            {
                return(Util.Maybe <TReturn> .CreateWith(response.Get().returnValue));
            }
        }
    }
Esempio n. 4
0
 private void FetchCardStatus()
 {
     lastCardStatus = new RuntimeCardStatus();
     if (IsAssignmentValid())
     {
         Util.Maybe <RuntimeCardStatus> maybeStatus = this.assignment.GetAssignedBehavior().
                                                      CallScriptFunction <int, RuntimeCardStatus>("getCardStatus", 0);
         if (!maybeStatus.IsEmpty())
         {
             lastCardStatus = maybeStatus.Get();
         }
     }
     else
     {
         lastCardStatus = new RuntimeCardStatus();
     }
     // Fill in with defaults for nulls or empty strings:
     lastCardStatus.title       = string.IsNullOrEmpty(lastCardStatus.title) ? card.GetTitle() : lastCardStatus.title;
     lastCardStatus.description = string.IsNullOrEmpty(lastCardStatus.description) ? card.GetDescription() : lastCardStatus.description;
     lastCardStatus.debugText   = string.IsNullOrEmpty(lastCardStatus.debugText) ? "(No debug text)" : lastCardStatus.debugText;
     // For the error message, if there is a legacy getCardErrorMessage function in the card, use it:
     if (string.IsNullOrEmpty(lastCardStatus.errorMessage))
     {
         lastCardStatus.errorMessage = GetCardErrorMessage_LEGACY() ?? "";
     }
 }
 public void Open(IEnumerable <string> pack, Util.Maybe <ulong> workshopId)
 {
     Open(workshopId);
     this.pack = pack;
     if (!workshopId.IsEmpty())
     {
         BehaviorSystem.SavedCardPack existingPack = behaviorSystem.GetCardPack(workshopId.Get());
         nameField.text = existingPack.workshopName;
         descField.text = existingPack.workshopDesc;
     }
 }
Esempio n. 6
0
 void StartSelection(System.Action <IEnumerable <string> > selectionFinishedCallback, Util.Maybe <ulong> workshopId)
 {
     BehaviorSystem.SavedCardPack pack = null;
     if (!workshopId.IsEmpty())
     {
         pack = behaviorSystem.GetCardPack(workshopId.Get());
     }
     this.selection = new Selection(selectionFinishedCallback);
     cardLibraryUI.selectionModePrompt.SetActive(true);
     foreach (GameObject containerObj in cardContainerObjects)
     {
         StartSelectionForContainerObj(containerObj, pack);
     }
 }
Esempio n. 7
0
    void OnWorkshopFetchComplete(string url, Util.Maybe <string> workshopResult)
    {
        PendingRequest request;

        if (!pendingRequests.TryGetValue(url, out request))
        {
            // Definitely weird, but not fatal.
            Debug.LogError("Fetched workshop image has no corresponding request: " + url);
            return;
        }
        pendingRequests.Remove(url);
        if (workshopResult.IsEmpty())
        {
            // Failed.
            Debug.LogError("Failed to fetch image from Steam Workshop URL " + url +
                           ". Error: " + workshopResult.GetErrorMessage());
            SetColorsAndTexture(request.targetImages, Color.magenta);
            CallCallbacks(request.callbacks, url, false);
            return;
        }
        string directory   = workshopResult.Get();
        string pngFilePath = Path.Combine(directory, "image.png");
        string jpgFilePath = Path.Combine(directory, "image.jpg");
        string filePath    = File.Exists(pngFilePath) ? pngFilePath : File.Exists(jpgFilePath) ? jpgFilePath : null;

        if (filePath == null)
        {
            Debug.LogError("Steam workshop image has no image.png or image.jpg in it: " + url);
            SetColorsAndTexture(request.targetImages, Color.yellow);
            CallCallbacks(request.callbacks, url, false);
            return;
        }
        Texture2D tex = Util.ReadPngToTexture(filePath);

        if (tex == null)
        {
            Debug.LogError("Failed to convert steam workshop image to texture: " + url);
            SetColorsAndTexture(request.targetImages, Color.red);
            CallCallbacks(request.callbacks, url, false);
            return;
        }

        loadedTextures[url] = tex;
        SetColorsAndTexture(request.targetImages, Color.white, tex);
        CallCallbacks(request.callbacks, url, true);
    }
Esempio n. 8
0
    public string GetBehaviorPropertiesJson(string behaviorUri)
    {
        var request = new GetBehaviorPropertiesRequest();

        request.behaviorUri = behaviorUri;

        if (!SyncBehaviorIfNeeded(behaviorUri))
        {
            Util.LogError($"GetBehaviorPropertiesJson failed for {behaviorUri} because it did not compile.");
            return(null);
        }

        Util.Maybe <GetBehaviorPropertiesResponse> response = voosEngine.CommunicateWithAgent <GetBehaviorPropertiesRequest, GetBehaviorPropertiesResponse>(request);
        if (response.IsEmpty())
        {
            Util.LogError($"GetBehaviorPropertiesJson failed for behavior URI {behaviorUri}");
            return(null);
        }
        else
        {
            return(response.Get().propsJson);
        }
    }
Esempio n. 9
0
    public void Open(ActorPrefab actorPrefab, Util.Maybe <ulong> workshopId)
    {
        Open(workshopId);

        SceneActorLibrary.SavedActorPacks actorPacks = sceneActorLibrary.GetActorPacks();
        this.actorPrefab       = actorPrefab;
        thumbnailImage.texture = actorPrefab.GetThumbnail();

        if (!workshopId.IsEmpty())
        {
            SceneActorLibrary.SavedActorPack existingPack = sceneActorLibrary.GetActorPack(workshopId.Get());
            nameField.text = existingPack.workshopName;
            descField.text = existingPack.workshopDesc;
        }
        else
        {
            nameField.text = actorPrefab.GetLabel();
            descField.text = actorPrefab.GetDescription();
        }
    }