Example #1
0
    private void DeleteSelectedResult()
    {
        SquareImageButtonUI deleteResult = selectedResult;

        SetSelectedResult(null);
        sceneActorLibrary.Delete(deleteResult.GetSearchResult().actorPrefab.GetId());
    }
Example #2
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
        }
    }
Example #3
0
 void ResultClicked(SquareImageButtonUI _result)
 {
     sidebarManager.OnClickSoundEffect();
     SetSelectedResult(_result);
     if (libraryMode != LibraryMode.CreateTool && pickerCallback != null)
     {
         pickerCallback(_result.GetSearchResult());
     }
 }
Example #4
0
    private bool DoesInternalResultMatchSearch(SquareImageButtonUI result)
    {
        if (searchString == "")
        {
            return(true);
        }
        string stringForSearch = result.GetSearchResult().actorPrefab.GetLabel().ToLower();

        return(stringForSearch.Contains(searchString.ToLower()));
    }
Example #5
0
 void ResultClicked(SquareImageButtonUI _result)
 {
     pickerCallback?.Invoke(_result.GetSearchResult());
 }
Example #6
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");
    }