Ejemplo n.º 1
0
    //Get all words
    private List <wordItem> getLists()
    {
        string          sql       = "SELECT * FROM SM_Words WHERE  wordListID = " + PlayerPrefs.GetInt("CurrentWordList");
        List <wordItem> wordLists = dbManager.Query <wordItem>(sql);

        return(wordLists);
    }
Ejemplo n.º 2
0
    private static int DbContainsCollumns(string dbName, string collumn, SimpleSQLManager db)
    {
        int result;

        try
        {
            bool   flag  = false;
            string query = "pragma table_info(\"" + dbName + "\")";
            List <DatabaseValidator.TableInfo> list = db.Query <DatabaseValidator.TableInfo>(query, new object[0]);
            foreach (DatabaseValidator.TableInfo tableInfo in list)
            {
                if (tableInfo.name.Equals(collumn))
                {
                    flag = true;
                    break;
                }
            }
            result = ((!flag) ? 0 : 1);
        }
        catch (Exception ex)
        {
            UnityEngine.Debug.Log(" " + ex.Message);
            result = -1;
        }
        return(result);
    }
Ejemplo n.º 3
0
    //Get all words
    private List <wordListItem> getLists()
    {
        string sql = "SELECT * FROM SM_WordList ";
        List <wordListItem> wordLists = dbManager.Query <wordListItem> (sql);

        return(wordLists);
    }
    private List <wordPackage> getWords(int activeID)
    {
        string             sql      = "SELECT w.id, w.word, w.wordListID, a.fileName FROM SM_Words w LEFT JOIN SM_WordAudio a ON w.id = a.wordID WHERE w.wordListID = " + activeID;
        List <wordPackage> wordList = dbManager.Query <wordPackage>(sql);

        return(wordList);
    }
Ejemplo n.º 5
0
    private List <wordContent> getWords()
    {
        string             curShareId = PlayerPrefs.GetInt("ShareWordList").ToString();
        string             sql        = "SELECT id, word FROM SM_Words WHERE  wordListID = " + curShareId;
        List <wordContent> words      = dbManager.Query <wordContent>(sql);

        return(words);
    }
Ejemplo n.º 6
0
        public SessionRow LoadSession(SimpleSQLManager dbManager)
        {
            List <SessionRow> sessionRows = dbManager.Query <SessionRow>("SELECT * FROM SessionRow WHERE Id = 1");

            if (sessionRows == null || sessionRows.Count == 0)
            {
                return(null);
            }
            return(sessionRows[0]);
        }
    public void GetDriftTablesList()
    {
        sql =
            "SELECT MIN(DriftIndex), DriftID, DriftName, DriftDateTime, DriftTexLocation  " +
            "FROM Drift " +
            "GROUP BY DriftID " +
            "ORDER BY DriftDateTime DESC";

        GameManager.driftSets = DriftsDatabaseManager.Query <DriftSets>(sql);

        foreach (var driftSet in GameManager.driftSets)
        {
            Debug.Log(driftSet.DriftName);
        }
    }
Ejemplo n.º 8
0
    //Delete the word list
    private void deleteWordList()
    {
        string sql = "DELETE FROM SM_WordList WHERE id = ?";

        dbManager.Execute(sql, PlayerPrefs.GetInt("CurrentWordList"));

        string             wordSql = "SELECT id FROM SM_Words WHERE wordListID = " + PlayerPrefs.GetInt("CurrentWordList");
        List <wordContent> words   = dbManager.Query <wordContent> (wordSql);

        foreach (wordContent myWord in words)
        {
            Debug.Log("DELETING A WORD");
            //Delete any audio
            if (wordHasAudio())
            {
                string wordAudioSql = "DELETE FROM SM_WordAudio WHERE wordID = ?";
                dbManager.Execute(wordAudioSql, myWord.id);
                System.IO.File.Delete(Application.persistentDataPath + "/" + myWord.id + ".wav");
            }
            //Delete the word
            string delWordsSql = "DELETE FROM SM_Words WHERE id = ?";
            dbManager.Execute(delWordsSql, int.Parse(myWord.id));
        }
    }
Ejemplo n.º 9
0
        public ConfigRow LoadConfig(SimpleSQLManager dbManager)
        {
            ConfigRow        configRow;
            List <ConfigRow> configRows = dbManager.Query <ConfigRow>("SELECT * FROM ConfigRow WHERE Id = 1");

            if (configRows == null || configRows.Count == 0)
            {
                configRow = SaveDefaultConfig(dbManager);
            }
            else
            {
                configRow = configRows[0];
            }
            return(configRow);
        }
Ejemplo n.º 10
0
        ///  <summary>
        /// Loads blob data from database and converts to images
        ///  </summary>
        private void LoadImages()
        {
            // clear out previous image UI elements
            foreach (var t in imageGroup.GetComponentsInChildren <Transform>())
            {
                if (t != imageGroup.transform)
                {
                    GameObject.Destroy(t.gameObject);
                }
            }

            // load data from database
            var sql     = "SELECT ID, ImageData FROM Images";
            var results = dbManager.Query <Images>(sql);

            // display results
            foreach (var result in results)
            {
                // set up a new texture element. The size is irrelevant since it will be overwritten
                var texture = new Texture2D(2, 2);
                // load image data from database blob (byte array)
                texture.LoadImage(result.ImageData);

                // instantiate the ui element
                var uiImageObj = GameObject.Instantiate(imagePrefab);
                uiImageObj.transform.SetParent(imageGroup.transform);

                // get the image component of the ui element and set its size and Sprite
                // based on the texture2D data loaded above
                var uiImage = uiImageObj.GetComponent <UnityEngine.UI.Image>();
                uiImageObj.GetComponent <RectTransform>().sizeDelta = new Vector2(texture.width, texture.height);
                uiImage.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));

                // get the ui element script and set up its properties and delegates
                var blobImage = uiImageObj.GetComponent <BlobImage>();
                blobImage.Set(result, DeleteImage);
            }
        }