Beispiel #1
0
 public void OpenPanel_StudyFlashcards(StudySet set)
 {
     if (OpenPanelStudyFlashcardsEvent != null)
     {
         OpenPanelStudyFlashcardsEvent(set);
     }
 }
Beispiel #2
0
 /// Adds a term to the main list, and to the provided set.
 public void AddNewTerm(Term term, StudySet set)
 {
     allTermsD.Add(term.myGuid, term);
     allTermsL.Add(term);
     term.mySet = set; // set ref to set.
     set.AddTerm(term.myGuid);
 }
Beispiel #3
0
 public void OpenPanelEditSet(StudySet set)
 {
     if (OpenPanelEditSetEvent != null)
     {
         OpenPanelEditSetEvent(set);
     }
 }
    // ================================================================
    //  Start / Destroy
    // ================================================================
    void Start()
    {
        // Open the last panel that was open!
        PanelTypes lastPanelOpenType = (PanelTypes)SaveStorage.GetInt(SaveKeys.LastPanelOpen);
        string     lastSetName       = SaveStorage.GetString(SaveKeys.LastStudySetOpenName);
        StudySet   lastSet           = dm.library.GetSetByName(lastSetName);

        if (lastSet != null && lastPanelOpenType == PanelTypes.EditSet)
        {
            OpenPanel_EditSet(lastSet);
        }
        else if (lastSet != null && lastPanelOpenType == PanelTypes.StudyFlashcards)
        {
            OpenPanel_StudyFlashcards(lastSet);
        }
        else
        {
            OpenPanel_ChooseSet();
        }

        // Add event listeners.
        GameManagers.Instance.EventManager.OpenPanelEditSetEvent         += OpenPanel_EditSet;
        GameManagers.Instance.EventManager.OpenPanelChooseSetEvent       += OpenPanel_ChooseSet;
        GameManagers.Instance.EventManager.OpenPanelStudyFlashcardsEvent += OpenPanel_StudyFlashcards;
    }
Beispiel #5
0
    // ----------------------------------------------------------------
    //  Start
    // ----------------------------------------------------------------
    private void Start()
    {
        mySet = GameManagers.Instance.DataManager.library.setSourdough;
        rt_numTermsCardIcon.localEulerAngles = new Vector3(0, 0, Random.Range(-5f, 5f));

        UpdateVisuals();
    }
Beispiel #6
0
 public StudySetLibrary()
 {
     setAced          = new StudySet(this, "ACED", SetTypes.Benched);
     setInQueue       = new StudySet(this, "IN QUEUE", SetTypes.Benched);
     setShelved       = new StudySet(this, "SHELVED", SetTypes.Benched);
     setToValidate    = new StudySet(this, "TO VALIDATE", SetTypes.Benched);
     setWantRecording = new StudySet(this, "WANT RECORDING", SetTypes.Benched);
     setToughies      = new StudySet(this, "TOUGHIES", SetTypes.Remix);
     setSourdough     = new StudySet(this, "SOURDOUGH SET", SetTypes.Remix);
 }
    // ----------------------------------------------------------------
    //  Initialize
    // ----------------------------------------------------------------
    public void Initialize(PopupMoveTerm myPopup, RectTransform tf_parent, StudySet mySet, bool isSameSet)
    {
        this.myPopup = myPopup;
        this.mySet   = mySet;
        GameUtils.ParentAndReset(gameObject, tf_parent);

        i_currSetBorder.gameObject.SetActive(isSameSet);
        t_name.text     = mySet.name;
        t_numTerms.text = mySet.NumTotal.ToString();
    }
Beispiel #8
0
 // ----------------------------------------------------------------
 //  Events
 // ----------------------------------------------------------------
 public void OnClickStudySet(StudySet set)
 {
     // See ya!
     Hide();
     // Actually move it!
     GameManagers.Instance.DataManager.MoveTermToSet(currTerm, set);
     // Dispatch event so folks can update their visuals.
     GameManagers.Instance.EventManager.OnAnySetContentsChanged();
     GameManagers.Instance.EventManager.CloseTermOptionsPopup(); // make sure we directly close the TermOptions popup, too.
 }
 public void DeleteSet(StudySet set)
 {
     // First, delete all audio from any terms.
     foreach (string termG in set.allTermGs)
     {
         Term term = library.GetTerm(termG);
         DeleteTermAudio0(term);
     }
     // Now, remove the set from the library!
     library.sets.Remove(set);
 }
    /// <summary>e.g. "I can. - Jeg kan. - ja kan"</summary>
    public string GetStudySetExportedString_NativeForeignPhonetic(StudySet set)
    {
        string str = "";

        foreach (string guid in set.allTermGs)
        {
            Term term = library.GetTerm(guid);
            str += term.native + " - " + term.foreign + " - " + term.phonetic;
            str += "\n";
        }
        return(str);
    }
    public void Debug_RebuildSourdoughSet()
    {
        StudySet setSD = library.setSourdough;

        // Remove all terms from Sourdough set.
        for (int i = setSD.allTermGs.Count - 1; i >= 0; --i)
        {
            setSD.RemoveTerm(setSD.allTermGs[i]);
        }
        // Now just refill it like normal.
        RefillSourdoughSet();
    }
Beispiel #12
0
    public void ChangeSetIndexInList(StudySet set, int indexDelta)
    {
        if (!sets.Contains(set))
        {
            return;
        }                                    // Safety check.

        int newIndex = sets.IndexOf(set) + indexDelta;

        newIndex = Mathf.Clamp(newIndex, 0, sets.Count - 1);
        sets.Remove(set);
        sets.Insert(newIndex, set);
    }
Beispiel #13
0
    // ----------------------------------------------------------------
    //  Update Visuals
    // ----------------------------------------------------------------
    public void UpdateVisuals(PanelChooseSet myPanel, StudySet mySet)
    {
        this.myPanel = myPanel;
        this.mySet   = mySet;

        // Update visuals
        int numTerms = mySet.NumTotal;

        t_name.text     = mySet.name;
        t_numTerms.text = numTerms.ToString();// + " terms";
        rt_numTermsCardIcon.localEulerAngles = new Vector3(0, 0, Random.Range(-5f, 5f));
        t_numTerms.gameObject.SetActive(numTerms > 0);
        rt_numTermsCardIcon.gameObject.SetActive(numTerms > 0);
    }
    // ----------------------------------------------------------------
    //  DEBUG
    // ----------------------------------------------------------------
    public void ReplaceAllStudySetsWithPremadeHardcodedOnes()
    {
        library = new StudySetLibrary();

        // Pull what I need from this text file.
        TextAsset textAsset = Resources.Load <TextAsset>("Data/AllSetsBackup");

        string[] allLines         = textAsset.text.Split('\n');
        bool     wasPrevLineEmpty = true; // so we know if we've reached the name of a new StudySet, which always comes after a blank line.

        StudySet currSet = null;

        for (int i = 0; i < allLines.Length; i++)
        {
            string line = allLines[i];
            if (string.IsNullOrWhiteSpace(line))   // Skip blank lines.
            {
                wasPrevLineEmpty = true;
                continue;
            }
            if (wasPrevLineEmpty)   // We made it to a new set! Set the name, and move on to the next line.
            {
                string setName = line;
                switch (setName)
                {
                case "ACED": currSet = library.setAced; break;

                case "IN QUEUE": currSet = library.setInQueue; break;

                case "SHELVED": currSet = library.setShelved; break;

                case "TO VALIDATE": currSet = library.setToValidate; break;

                case "WANT RECORDING": currSet = library.setWantRecording; break;

                default:
                    currSet = new StudySet(library, line, SetTypes.Regular);
                    library.sets.Add(currSet);     // of course, add regular sets to the library right away.
                    break;
                }
                wasPrevLineEmpty = false;
                continue;
            }
            AddTermFromExportedString(currSet, line);
            wasPrevLineEmpty = false;
        }

        SaveStudySetLibrary();
    }
    // Update Visuals
    public void UpdateVisuals(StudySet mySet)
    {
        this.gameObject.SetActive(mySet.IsInProgress);

        // Add missing dashes
        int numDashesToAdd = mySet.NumTotal - i_dashes.Count;

        for (int i = 0; i < numDashesToAdd; i++)
        {
            Image newImg = new GameObject().AddComponent <Image>();
            newImg.gameObject.name = "PBarDash_" + i;
            GameUtils.ParentAndReset(newImg.gameObject, rt_layoutGroup);
            i_dashes.Add(newImg);
        }

        // Hide surplus dashes.
        for (int i = 0; i < i_dashes.Count; i++)
        {
            i_dashes[i].gameObject.SetActive(i < mySet.NumTotal);
        }

        // Update all dash visuals!
        int numYesed  = mySet.NumTotal - (mySet.pileYesesAndNosG.Count + mySet.pileQueueG.Count);
        int numRecent = mySet.pileYesesAndNosG.Count;

        for (int i = 0; i < mySet.NumTotal; i++)
        {
            Color color;
            if (i < numYesed) // Yesed
            {
                color = colorYesed;
            }
            else if (i < numYesed + numRecent) // Recent
            {
                bool wasAYes = mySet.pileYesG.Contains(mySet.pileYesesAndNosG[i - numYesed]);
                color = wasAYes ? colorRecentYes : colorRecentNo;
            }
            else // Upcoming
            {
                color = colorUpcoming;
            }
            i_dashes[i].color = color;
        }

        // Update bar width!
        float barWidth = Mathf.Min(myRectTransform.rect.width, mySet.NumTotal * 9);

        rt_layoutGroup.sizeDelta = new Vector2(barWidth, myRectTransform.rect.height);
    }
    public void MoveTermToSet(Term term, StudySet newSet)
    {
        // Swap its set.
        StudySet prevSet = term.mySet;

        prevSet.RemoveTerm(term.myGuid);
        newSet.AddTerm(term.myGuid);
        // If it's not a main set, then also attempt to remove from the remix sets.
        if (!newSet.canIncludeMeInRemixes)
        {
            library.RemoveTermFromRemixSets(term.myGuid);
        }
        // Save!
        SaveStudySetLibrary();
    }
    /// <summary>e.g. "Jeg kan. [ja kan] - I can."</summary>
    public string GetStudySetExportedString_ForeignBracketPhoneticNative(StudySet set)
    {
        string str = "";

        foreach (string guid in set.allTermGs)
        {
            Term term = library.GetTerm(guid);
            str += term.foreign;
            if (term.phonetic.Length > 0)
            {
                str += " [" + term.phonetic + "]";
            }
            str += " - " + term.native;
            str += "\n";
        }
        return(str);
    }
    //private void AddHardcodedSetFromString(string setName, string allTermsStr) {
    //    // Make and add empty new set.
    //    StudySet newSet = new StudySet(library, setName, SetTypes.Regular);
    //    library.sets.Add(newSet);

    //    // Make all the new terms.
    //    string[] termStrings = allTermsStr.Split('\n');
    //    foreach (string str in termStrings) {
    //        AddTermFromExportedString(newSet, str);
    //    }
    //}

    private void AddTermFromExportedString(StudySet set, string str)
    {
        try {
            int splitIndex;
            if (str.Contains(" — "))
            {
                splitIndex = str.IndexOf(" — ");                      // use double-sized hyphen, if that's how it's (optionally) formatted.
            }
            else
            {
                splitIndex = str.IndexOf(" - ");  // otherwise, split by the regular hyphen.
            }
            string native   = str.Substring(splitIndex + 3);
            string foreign  = str.Substring(0, splitIndex);
            string phonetic = "";
            // pull out the phonetic pronunciation
            int lbIndex = foreign.LastIndexOf('['); // left bracket index
            int rbIndex = foreign.LastIndexOf(']'); // right bracket index
            if (rbIndex == foreign.Length - 1)      // if this one ENDS in a phonetic explanation...
            {
                phonetic = foreign.Substring(lbIndex + 1);
                phonetic = phonetic.Substring(0, phonetic.Length - 1); // get rid of that last ] char.
                foreign  = foreign.Substring(0, lbIndex - 1);
            }
            //int splitIndexA = str.IndexOf(" — ");
            //int splitIndexB = str.LastIndexOf(" — ");
            //string native = str.Substring(splitIndex + 3);
            //string foreign = str.Substring(0, splitIndex);
            //string phonetic = "";
            //// pull out the phonetic pronunciation
            //int lbIndex = foreign.LastIndexOf('['); // left bracket index
            //int rbIndex = foreign.LastIndexOf(']'); // right bracket index
            //if (rbIndex == foreign.Length - 1) { // if this one ENDS in a phonetic explanation...
            //    phonetic = foreign.Substring(lbIndex + 1);
            //    phonetic = phonetic.Substring(0, phonetic.Length - 1); // get rid of that last ] char.
            //    foreign = foreign.Substring(0, lbIndex - 1);
            //}
            Term newTerm = new Term(native, foreign, phonetic);
            // Add this term to the library!
            library.AddNewTerm(newTerm, set);
        }
        catch {
            AppDebugLog.LogError("Issue with imported term string: " + str);
        }
    }
Beispiel #19
0
    public void SetMySet(StudySet mySet)
    {
        this.mySet = mySet;

        // Update visuals
        t_name.text              = mySet.name;
        t_numTerms.text          = mySet.NumTotal.ToString();                                  // + " terms";
        t_avgTimesCompleted.text = TextUtils.DecimalPlaces1(mySet.GetAverageTimesCompleted()); // numRoundsFinished.ToString();
        //progressBar.SetActive(mySet.IsInProgress);
        progressBar.UpdateVisuals(mySet);
        //if (mySet.IsInProgress) {
        //    float barWidth = i_progressBarBack.rectTransform.rect.width;
        //    float progLocYeses = (mySet.NumTotal-(mySet.pileYesesAndNosG.Count+mySet.pileQueueG.Count)) / (float)mySet.NumTotal;
        //    float progLocRecent = mySet.NumDone / (float)mySet.NumTotal;
        //    float yesWidth = barWidth * progLocYeses;
        //    i_progressBarFillYeses.rectTransform.sizeDelta = new Vector2(yesWidth, i_progressBarFillYeses.rectTransform.sizeDelta.y);
        //    i_progressBarFillRecent.rectTransform.anchoredPosition = new Vector2(yesWidth, 0);
        //    i_progressBarFillRecent.rectTransform.sizeDelta = new Vector2(barWidth * progLocRecent, i_progressBarFillRecent.rectTransform.sizeDelta.y);
        //}
        rt_numTermsCardIcon.localEulerAngles = new Vector3(0, 0, Random.Range(-5f, 5f));
    }
    private static string GetRoundCompleteText(StudySet set)
    {
        //int numUnderstood = set.NumTotal - currStudySet.pileNo.Count;
        int    numNewYeses  = set.pileYesG.Count;
        int    numRemaining = set.pileNoG.Count;
        string returnStr    = "";

        if (numRemaining > 0 && numNewYeses > 0)
        {
            returnStr += "learned " + numNewYeses + " new ones!\n";
        }
        if (numRemaining > 0)
        {
            returnStr += numRemaining + " remaining\n";
        }
        else
        {
            returnStr += "\n\nYou got 'em all, woot!";
        }
        return(returnStr);
    }
 // ================================================================
 //  Events
 // ================================================================
 public void OnClickedStudyASet(StudySet set)
 {
     menuController.OpenPanel_StudyFlashcards(set);
 }
 public void OpenPanel_EditSet(StudySet set)
 {
     dm.SetCurrSet(set);
     OpenPanel_EditSet();
 }
 public void OnClickedEditASet(StudySet set)
 {
     menuController.OpenPanel_EditSet(set);
 }
 public void OpenPanel_StudyFlashcards(StudySet set)
 {
     dm.SetCurrSet(set);
     OpenPanel_StudyFlashcards();
 }
 public void SetCurrSet(StudySet set)
 {
     _currSet = set;
     SaveStorage.SetString(SaveKeys.LastStudySetOpenName, _currSet.name);
 }
 // ----------------------------------------------------------------
 //  Getters
 // ----------------------------------------------------------------
 public bool IsSourdoughSet(StudySet set)
 {
     return(library.setSourdough == set);
 }
    // ----------------------------------------------------------------
    //  Sourdough Handling
    // ----------------------------------------------------------------
    public void RefillSourdoughSet()
    {
        // FIRST, update the terms in the sourdough set!
        StudySet      setSD      = library.setSourdough;
        List <string> termsLeave = new List <string>();
        List <string> termsStay  = new List <string>();

        foreach (string termG in setSD.allTermGs)
        {
            if (setSD.pileNoG.Contains(termG) ||
                setSD.pileQueueG.Contains(termG))
            {
                termsStay.Add(termG);
            }
            else
            {
                termsLeave.Add(termG);
            }
        }
        foreach (string termG in termsLeave)
        {
            library.GetTerm(termG).nSDLeaves++;
        }
        foreach (string termG in termsStay)
        {
            library.GetTerm(termG).nSDStays++;
        }
        // Remove the yes-ed terms entirely from the set!
        for (int i = 0; i < termsLeave.Count; i++)
        {
            setSD.RemoveTerm(termsLeave[i]);
        }

        // Refill the holes!
        int numToAdd = SourdoughMaxTerms - setSD.allTermGs.Count;
        // Make a safe copy-list of all terms!
        List <Term> allTerms = library.GetOnlyMainTerms();

        // Remove terms that are gonna STAY in Sourdough from the all-terms list, so we don't accidentally add the same ones again.
        for (int i = 0; i < termsStay.Count; i++)
        {
            Term term = library.GetTerm(termsStay[i]);
            allTerms.Remove(term);
        }
        // Shuffle them all, then sort them by sourdough wins.
        GameUtils.Shuffle(allTerms);
        //allTerms = allTerms.OrderBy(c => c.yToNPlusRatio).ToList(); // TEST! Put the hard ones in first.
        allTerms = allTerms.OrderBy(c => c.nSDLeaves).ToList();

        // Add the right amount to the set.
        for (int i = 0; i < numToAdd && i < allTerms.Count; i++)
        {
            setSD.AddTerm(allTerms[i].myGuid);
        }
        setSD.ShuffleAndRestartDeck();

        // Save library
        SaveStudySetLibrary();

        // Finally, save WHEN we last refilled (now)!
        SaveStorage.SetDateTime(SaveKeys.SourdoughTimeLastRefilled, DateTime.Now);
    }