コード例 #1
0
    //public bool ImageDeleteCleanup(string word) { return FileAccessUtil.WordImageDirRepair(word); }

    /// <summary>
    /// Deletes a word entry from the data base and removes it from the word list dictionary.
    /// Additionally, it deletes any .wav or .png files associated with the word too.
    /// Returns true if the entry is successfully deleted from the data base.
    /// </summary>
    /// <param name="key"></param>
    /// <returns>bool</returns>
    public bool RemoveWordListEntry(string key)
    {
        bool success = false;

        wordList.Clear();
        LoadWordList();

        if (dataService.DeleteFromWords(wordList[key].IdNum) > 0)
        {
            success = !success;
            wordList.Remove(key);
            FileAccessUtil.DeleteWordAudio(key);
            List <string> existingPicsFiles = new List <string>();
            string[]      temparr           = Directory.GetFiles(Application.persistentDataPath + "/WordPictures/" + key);

            foreach (string path in temparr)
            {
                existingPicsFiles.Add(path);
            }

            Debug.Log("existingPicsFiles array length = " + existingPicsFiles.Count);

            foreach (string path in existingPicsFiles)
            {
                Debug.Log("existingPicsFiles array element recorded as: " + path);
                File.Delete(path);
            }

            Debug.Log("Done deleting pics for " + key);
            Directory.Delete(Application.persistentDataPath + "/WordPictures/" + key);
            Debug.Log("Done deleting directory for " + key);
            temparr = null;
            existingPicsFiles.Clear();
        }
        else
        {
            Debug.Log("Error trying to delete " + key);
        }

        dataService.RebaseAllWordIDs();

        return(success);
    }
コード例 #2
0
ファイル: VW_Settings.cs プロジェクト: lazyninjacat/mylevelup
    public void Reset()
    {
        CloseConfirmResetModal();
        OpenPleaseWaitModal();
        // Clear playlist table and reset auto increment to 0
        dataService.DeleteAllPlaylist();
        dataService.ReseedTable("playlist", 0);

        // Delete all non stock words
        foreach (var row in wordList)
        {
            if (row.Value.StockCustom == "custom")
            {
                Debug.Log("Adding to wordlist to delete: " + row.Value.Word_name);
                wordIDsForDelete.Add(row.Value.IdNum);
                FileAccessUtil.DeleteWordAudio(row.Value.Word_name);

                List <string> existingPicsFiles = new List <string>();
                string[]      temparr           = System.IO.Directory.GetFiles(Application.persistentDataPath + "/WordPictures/" + row.Value.Word_name);

                foreach (string path in temparr)
                {
                    existingPicsFiles.Add(path);
                }

                Debug.Log("existingPicsFiles array length = " + existingPicsFiles.Count);


                foreach (string path in existingPicsFiles)
                {
                    Debug.Log("existingPicsFiles array element recorded as: " + path);
                    System.IO.File.Delete(path);
                }
                Debug.Log("Done deleting pics for " + row.Value.Word_name);
                System.IO.Directory.Delete(Application.persistentDataPath + "/WordPictures/" + row.Value.Word_name);
                Debug.Log("Done deleting directory for " + row.Value.Word_name);
                temparr = null;
                existingPicsFiles.Clear();
            }
        }
        foreach (int id in wordIDsForDelete)
        {
            Debug.Log(" deleting word ID: " + id);
            dataService.DeleteFromWords(id);
        }
        dataService.ReseedTable("Words", 10);
        wordList.Clear();
        wordIDsForDelete.Clear();


        // Clear existing mastery database records
        dataService.DeleteAllMastery();


        // Reset all Playerprefs
        PlayerPrefs.SetInt("isFirstKey", 0);
        PlayerPrefs.SetInt("AutoPlaylistOnOffKey", 0);
        PlayerPrefs.SetInt("isTutorial", 0);
        PlayerPrefs.SetString("ChildNameKey", "");

        // TODO: reset rewards stuff
        // Reset all rewards

        ClosePleaseWaitModal();
        OpenResetCompleteModal();
    }