Ejemplo n.º 1
0
    private void DeleteSelectedResult()
    {
        SquareImageButtonUI deleteResult = selectedResult;

        SetSelectedResult(null);
        sceneActorLibrary.Delete(deleteResult.GetSearchResult().actorPrefab.GetId());
    }
Ejemplo n.º 2
0
 void UpdateInternalResultShowing(SquareImageButtonUI result)
 {
     if (result == null)
     {
         return;
     }
     SetResultShowing(result, ShouldShowInternalResult(result));
 }
Ejemplo n.º 3
0
 void ResultClicked(SquareImageButtonUI _result)
 {
     sidebarManager.OnClickSoundEffect();
     SetSelectedResult(_result);
     if (libraryMode != LibraryMode.CreateTool && pickerCallback != null)
     {
         pickerCallback(_result.GetSearchResult());
     }
 }
Ejemplo n.º 4
0
    private bool DoesInternalResultMatchSearch(SquareImageButtonUI result)
    {
        if (searchString == "")
        {
            return(true);
        }
        string stringForSearch = result.GetSearchResult().actorPrefab.GetLabel().ToLower();

        return(stringForSearch.Contains(searchString.ToLower()));
    }
Ejemplo n.º 5
0
    void OnResult(ActorableSearchResult incomingResult, bool isInternal)
    {
        // Ignore pfx/sfx results, they are loaded already
        if (incomingResult.name == "Empty" && incomingResult.name == "Sound")
        {
            return;
        }

        SquareImageButtonUI newResult = Instantiate(creationLibraryUI.resultsPrefab, creationLibraryUI.resultsRect);

        newResult.SetImage(incomingResult.thumbnail);
        newResult.onPointerDown = () => ResultClicked(newResult);
        newResult.SetSearchResult(incomingResult);

        ItemWithTooltipWithEventSystem tooltip = newResult.gameObject.AddComponent <ItemWithTooltipWithEventSystem>();

        tooltip.SetupWithUserMain(userMain);
        tooltip.SetDescription(incomingResult.name);

        // int categoryValue = creationLibraryUI.categoryDropdown.value;
        if (isInternal)
        {
            internalResults.Add(newResult);
            // if (incomingResult.actorPrefab != null && !sceneActorLibrary.Exists(incomingResult.actorPrefab.GetId()))
            // {
            //   DropdownCategoryPut(incomingResult.actorPrefab.GetAssetPackName());
            // }
            if (sceneActorLibrary.Exists(incomingResult.actorPrefab.GetId()))
            {
                SetResultShowing(newResult,
                                 selectedCategory == CATEGORY_CUSTOM ||
                                 selectedCategory == null ||
                                 selectedCategory == CATEGORY_ALL);
            }
            else
            {
                UpdateInternalResultShowing(newResult);
            }
        }
        else
        {
            webResults.Add(newResult);
            if (incomingResult.renderableReference.assetType == AssetType.Poly)
            {
                SetResultShowing(newResult,
                                 selectedCategory == CATEGORY_POLY);
            }
            else if (incomingResult.renderableReference.assetType == AssetType.Image)
            {
                SetResultShowing(newResult,
                                 selectedCategory == CATEGORY_GIS);
            }
        }
    }
Ejemplo n.º 6
0
 void SetResultShowing(SquareImageButtonUI result, bool showing)
 {
     if (showing)
     {
         result.GetComponent <RectTransform>().localScale = Vector3.one * 0.01f;
         result.gameObject.SetActive(true);
         timers[result] = 0;
     }
     else
     {
         result.gameObject.SetActive(false);
         timers.Remove(result);
     }
 }
Ejemplo n.º 7
0
    void SetSelectedResult(SquareImageButtonUI result)
    {
        if (selectedResult != null)
        {
            selectedResult.SetSelected(false);
        }
        selectedResult = result;
        if (selectedResult != null)
        {
            selectedResult.SetSelected(true);
        }
        bool isSaved = selectedResult != null && sceneActorLibrary.Exists(selectedResult.GetSearchResult().actorPrefab?.GetId());

        creationLibraryUI.trashButton.gameObject.SetActive(isSaved);
        creationLibraryUI.exportDropdownMenu.gameObject.SetActive(isSaved);
        if (libraryMode == LibraryMode.CreateTool)
        {
            if (result != null)
            {
                UpdateResult(result.GetSearchResult());
            }
        }
        if (isSaved)
        {
#if USE_STEAMWORKS
            if (GetWorkshopIdForActor(selectedResult.GetSearchResult().actorPrefab).HasValue)
            {
                creationLibraryUI.exportDropdownMenu.SetOptions(new List <string>()
                {
                    EXPORT_TO_DISK, UPDATE_WORKSHOP_PREFAB, EXPORT_TO_WORKSHOP
                });
            }
            else
            {
                creationLibraryUI.exportDropdownMenu.SetOptions(new List <string>()
                {
                    EXPORT_TO_DISK, EXPORT_TO_WORKSHOP
                });
            }
#else
            SquareImageButtonUI exportResult = selectedResult;
            ActorPrefab         prefab       = exportResult.GetSearchResult().actorPrefab;
            creationLibraryUI.exportCustomButton.onClick.RemoveAllListeners();
            creationLibraryUI.exportCustomButton.onClick.AddListener(() => ExportToDisk(prefab));
#endif
        }
    }
Ejemplo n.º 8
0
    void OnResult(ActorableSearchResult incomingResult, bool isInternal)
    {
        // hacckk
        if (incomingResult.name == "Empty")
        {
            emptyActorTemplate = incomingResult;
            return;
        }

        SquareImageButtonUI newResult = Instantiate(renderableLibraryUI.resultsPrefab, renderableLibraryUI.resultsRect);

        newResult.SetImage(incomingResult.thumbnail);
        newResult.onPointerDown = () => ResultClicked(newResult);
        newResult.SetSearchResult(incomingResult);

        ItemWithTooltipWithEventSystem tooltip = newResult.gameObject.AddComponent <ItemWithTooltipWithEventSystem>();

        tooltip.SetDescription(incomingResult.name);

        // int categoryValue = creationLibraryUI.categoryDropdown.value;
        if (isInternal)
        {
            internalResults.Add(newResult);
        }
        else
        {
            webResults.Add(newResult);
            if (incomingResult.renderableReference.assetType == AssetType.Poly)
            {
                SetResultShowing(newResult,
                                 selectedCategory == CATEGORY_POLY);
            }
            else if (incomingResult.renderableReference.assetType == AssetType.Image)
            {
                SetResultShowing(newResult,
                                 selectedCategory == CATEGORY_GIS);
            }
        }
    }
Ejemplo n.º 9
0
 void ResultClicked(SquareImageButtonUI _result)
 {
     pickerCallback?.Invoke(_result.GetSearchResult());
 }
Ejemplo n.º 10
0
 private bool IsChallengeAsset(SquareImageButtonUI item)
 {
     return(false);
     // return item.GetSearchResult().actorPrefab?.GetAssetPackName() == "Cooking";
 }
Ejemplo n.º 11
0
 private bool IsChallengeAsset(SquareImageButtonUI item)
 {
     return(false);
 }
Ejemplo n.º 12
0
    public override void Setup(SidebarManager _sidebarManager)
    {
        base.Setup(_sidebarManager);
        Util.FindIfNotSet(this, ref editMain);
        Util.FindIfNotSet(this, ref userMain);
        Util.FindIfNotSet(this, ref assetSearch);
        Util.FindIfNotSet(this, ref sceneActorLibrary);
        Util.FindIfNotSet(this, ref popups);

        ShouldShowInternalResult = (result) => { return(false); };
        lastResult = assetSearch.GetBuiltInSearchResult("Forest/Slime");

        creationLibraryUI.searchInput.onEndEdit.AddListener(OnInputFieldEnd);
        creationLibraryUI.clearSearchButton.onClick.AddListener(ClearSearch);
        sceneActorLibrary.onActorPut    += OnActorPut;
        sceneActorLibrary.onActorDelete += OnActorDelete;

        assetSearch.AddPrefabsProcessor((searchResult) => OnResult(searchResult, true));


        List <Util.Tuple <string, Texture2D> > allCategories = new List <Util.Tuple <string, Texture2D> >();

        allCategories.Add(new Util.Tuple <string, Texture2D>(CATEGORY_ALL, allCategoryIcon));
        foreach (CategoryButton category in dynamicCategories)
        {
            allCategories.Add(new Util.Tuple <string, Texture2D>(category.displayName, category.icon));
        }
        allCategories.Add(new Util.Tuple <string, Texture2D>(CATEGORY_DECORATIONS, decorationCategoryIcon));
        allCategories.Add(new Util.Tuple <string, Texture2D>(CATEGORY_CUSTOM, savedCategoryIcon));

        //NO_POLY_TOOLKIT_INTERNAL_CHECK
        if (!PolyToolkitInternal.PtSettings.Instance.authConfig.apiKey.Contains("INSERT YOUR"))
        {
            allCategories.Add(new Util.Tuple <string, Texture2D>(CATEGORY_POLY, polyCategoryIcon));
        }
        if (GisSearchManager.APIkey != "PUT YOUR KEY HERE")
        {
            allCategories.Add(new Util.Tuple <string, Texture2D>(CATEGORY_GIS, gisCategoryIcon));
        }

        allCategories.Add(new Util.Tuple <string, Texture2D>(CATEGORY_PARTICLES, particlesCategoryIcon));
        allCategories.Add(new Util.Tuple <string, Texture2D>(CATEGORY_SOUNDS, soundsCategoryIcon));

        foreach (Util.Tuple <string, Texture2D> categoryTuple in allCategories)
        {
            string           category       = categoryTuple.first;
            Texture2D        texture        = categoryTuple.second;
            TextIconButtonUI categoryButton = Instantiate(
                creationLibraryUI.categoryButtonPrefab, creationLibraryUI.categoriesList.transform);
            categoryButton.text.text   = category;
            categoryButton.icon.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0, 0));
            categoryButton.button.onClick.AddListener(() =>
            {
                selectedCategory = category;
                UpdateAll();
            });
            if (category == CATEGORY_CHALLENGE)
            {
                categoryButton.medallion.gameObject.SetActive(true);
            }
            categoryButton.gameObject.SetActive(true);
        }

        creationLibraryUI.inCategoryBackButton.onClick.AddListener(() =>
        {
            selectedCategory = null;
            ClearSearch(); //includes update all
            // UpdateAll();
        });

        particleLibrary.Setup();
        particleLibrary.onParticleEffectSelected += OnParticleEffectSelected;
        soundLibrary.onSoundSelected             += OnSoundEffectSelected;
        soundLibrary.Setup();

        creationLibraryUI.inCategoryLink.onClick.AddListener(() =>
        {
            Application.OpenURL(challengeCategoryUrl);
        });

#if USE_STEAMWORKS
        actorPrefabUploadDialog = Instantiate(actorPrefabUploadDialogPrefab);
        actorPrefabUploadDialog.Setup();
        actorPrefabWorkshopMenu = Instantiate(actorPrefabWorkshopMenuPrefab);
        actorPrefabWorkshopMenu.Setup();
#endif

        creationLibraryUI.exportDropdownMenu.onOptionClicked += (value) =>
        {
            SquareImageButtonUI exportResult = selectedResult;
            Debug.Assert(selectedResult != null);
            ActorPrefab prefab = exportResult.GetSearchResult().actorPrefab;
            Debug.Assert(sceneActorLibrary.Exists(prefab?.GetId()));

            if (value == EXPORT_TO_DISK)
            {
                ExportToDisk(prefab);
            }
#if USE_STEAMWORKS
            else if (value == UPDATE_WORKSHOP_PREFAB)
            {
                ulong?id = GetWorkshopIdForActor(prefab);
                actorPrefabUploadDialog.Open(prefab, Util.Maybe <ulong> .CreateWith(id.Value));
            }
            else
            {
                actorPrefabUploadDialog.Open(prefab, Util.Maybe <ulong> .CreateEmpty());
            }
#endif
        };

#if USE_STEAMWORKS
        creationLibraryUI.importDropdownMenu.SetOptions(new List <string>()
        {
            IMPORT_FROM_DISK, IMPORT_FROM_WORKSHOP
        });
#else
        creationLibraryUI.importCustomButton.onClick.AddListener(ImportFromDisk);
#endif

        creationLibraryUI.importDropdownMenu.onOptionClicked += (value) =>
        {
            if (value == IMPORT_FROM_DISK)
            {
                ImportFromDisk();
            }
            else
            {
                actorPrefabWorkshopMenu.Open();
            }
        };

        pfxActorTemplate = assetSearch.GetBuiltInSearchResult("Empty");
        sfxActorTemplate = assetSearch.GetBuiltInSearchResult("Sound");
    }