Ejemplo n.º 1
0
    private void LoadCursor(CursorSaveEntry saveEntry) // Load them into saved stuff
    {
        CursorTextureEntry cursorTexture = textureEntries.Find(x => x.GetTextureName == saveEntry.textureName);

        if (cursorTexture == null)
        {
            Debug.LogError("Can not find texture associated with save entry, texture name: " + saveEntry.textureName);
        }
        else
        {
            Input_CursorNameInput(saveEntry.cursorName);

            curSelectedTexture = cursorTexture.GetTexture;

            Sprite loadedCursorSprite = Sprite.Create(cursorTexture.GetTexture,
                                                      new Rect(0f, 0f, curSelectedTexture.width, curSelectedTexture.height), new Vector2(0.5f, 0.5f),
                                                      pixelsPerUnit);

            // cursorColorPicker.color is throwing an error
            // how f****n fun
            cursorColorPicker.color = saveEntry.cursorColor;
            cursorPreview.sprite    = loadedCursorSprite;

            OnClick_PreviewCursor();

            NewCursorEntry loadedCursor = CreateCursor(false); // Change this to a create method instead?
            loadedCursor.SetSaveState(SaveState.Saved);
            loadedCursor.SavedAsFileName = saveEntry.cursorName;
            loadedCursor.isSaveEntry     = false; // THIS IS THE NORMAL F*****G CURSOR

            #region Creating cursorEntry for savedList, perhaps add an overload for CreateCursor instead?

            NewCursorEntry savedCursor = Instantiate(loadedCursor, savedCursorListContent);
            savedCursor.SetCursorPreferences(loadedCursor);
            savedCursor.SetSaveState(SaveState.Saved);
            savedCursor.isSaveEntry = true; // THIS IS THE F*****G SAVED CURSOR

            Button loadedEntryButton = savedCursor.GetComponent <Button>();
            loadedEntryButton.onClick.AddListener(() => OnClick_SelectCursor(savedCursor));

            #endregion

            if (!savedCursors.Contains(savedCursor))
            {
                savedCursors.Add(savedCursor);
            }
        }
    }
Ejemplo n.º 2
0
    private void LoadCursorSave(CursorSaveEntry saveEntry) // Load it into save only
    {
        CursorTextureEntry cursorTexture = textureEntries.Find(x => x.GetTextureName == saveEntry.textureName);

        if (cursorTexture == null)
        {
            Debug.LogError("Can not find texture associated with save entry, texture name: " + saveEntry.textureName);
        }
        else
        {
            Input_CursorNameInput(saveEntry.cursorName);

            curSelectedTexture = cursorTexture.GetTexture;

            Sprite loadedCursorSprite = Sprite.Create(cursorTexture.GetTexture,
                                                      new Rect(0f, 0f, curSelectedTexture.width, curSelectedTexture.height), new Vector2(0.5f, 0.5f),
                                                      pixelsPerUnit);

            // cursorColorPicker.color is throwing an error
            // how f****n fun
            cursorColorPicker.color = saveEntry.cursorColor;
            cursorPreview.sprite    = loadedCursorSprite;

            OnClick_PreviewCursor(); // should work? no?

            NewCursorEntry savedCursor = CreateCursor(true);
            savedCursor.transform.SetParent(savedCursorListContent);
            savedCursor.SetCursorPreferences(savedCursor);
            savedCursor.SetSaveState(SaveState.Saved);
            savedCursor.SavedAsFileName = saveEntry.cursorName;
            savedCursor.isSaveEntry     = true; // THIS IS THE F*****G SAVED CURSOR

            Button loadedEntryButton = savedCursor.GetComponent <Button>();
            loadedEntryButton.onClick.AddListener(() => OnClick_SelectCursor(savedCursor));

            if (!savedCursors.Contains(savedCursor)) // do this beforef
            {
                savedCursors.Add(savedCursor);
            }
        }
    }
Ejemplo n.º 3
0
    public void OnClick_SelectCursor(NewCursorEntry entry)
    {
        if (!Input.GetKey(KeyCode.LeftControl) || entry.isSaveEntry) // perhaps be able to select multiple entries?
        {
            if (curSelectedCursorEntry)
            {
                curSelectedCursorEntry.GetComponent <Image>().color = Color.white;
            }

            ClearCursorSelectedEntries();
        }

        curSelectedCursorEntry = entry;
        curSelectedCursorEntry.GetComponent <Image>().color = Color.green;

        if (!selectedCursorEntryList.Contains(curSelectedCursorEntry))
        {
            if (!Input.GetKey(KeyCode.LeftControl))
            {
                if (selectedCursorEntryList.Count > 0)
                {
                    ClearCursorSelectedEntries();
                }
            }

            selectedCursorEntryList.Add(entry);
        }

        selectedTextureRawImage.texture = entry.GetCursorTexture;
        selectedTextureName.text        = entry.GetCursorTexture.name;
        cursorColorPicker.color         = entry.GetCursorColor;
        selectedCursorName.text         = entry.GetCursorName;

        curCursorName           = entry.GetCursorName;
        cursorColorPicker.color = entry.GetCursorColor;
        curSelectedTexture      = entry.GetCursorTexture;

        saveCursorButton.gameObject.SetActive(true);

        //if (Input.GetKey(KeyCode.LeftControl))
        //{
        //    if (selectedCursorEntryList.Contains(entry))
        //    {
        //        entry.GetComponent<Image>().color = Color.white;
        //        Debug.Log("Deslected " + entry.name);
        //        selectedCursorEntryList.Remove(entry);
        //    }
        //    else // Not found in queue
        //    {
        //        entry.GetComponent<Image>().color = Color.green;
        //        Debug.Log("Selected " + entry.name);
        //        selectedCursorEntryList.Add(entry);
        //    }
        //}
        //else
        //{
        //    ClearCursorSelectedEntries();
        //}

        // Debug.Log("selecto");

        OnClick_PreviewCursor();
    }