private void ReloadCursorsFromSavedCursors() { foreach (NewCursorEntry savedEntry in savedCursors) { NewCursorEntry entry; if ((entry = cursorEntries.Find(x => x.SavedAsFileName == savedEntry.SavedAsFileName)) != null) // == precedes && { // overload the == operator in NewCursorEntry instead // just reload it entry.SetCursorPreferences(savedEntry); entry.SetSaveState(SaveState.Saved); } else // re-create it i guess { // Debug.Log("Recreating"); // Debug.Log(savedEntry.GetCursorName + " | " + savedEntry.GetCursorColor + " | " + savedEntry.GetCursorSprite.name); // Debug.Log(cursorEntries.Find(x => x.GetCursorName == savedEntry.GetCursorName && x.SavedAsFileName == savedEntry.SavedAsFileName)); // Debug.Log(curCursorName + " | " + savedEntry.isSaveEntry + " | " + savedEntry.GetCursorName + " | " + savedEntry.SavedAsFileName); // 850 true 850 850 NewCursorEntry reloadedCursor = CreateCursor(); // instantiates it, adds it to created cursors list, sets preferences and // on click but the sprite is created beforehand so this method isn't as resource heavy // check if a cursor with the same shit already exists // which is technically being done above? reloadedCursor.SavedAsFileName = savedEntry.SavedAsFileName; reloadedCursor.SetCursorPreferences(savedEntry); reloadedCursor.SetSaveState(SaveState.Saved); } } }
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); } } }
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); } } }
private void SaveCursorEntryToFile(NewCursorEntry entry) { cursorSaveLoadUtility.JsonSerialize(entry); entry.SetSaveState(SaveState.Saved); entry.SavedAsFileName = entry.GetCursorName; }