Exemplo n.º 1
0
 public void CopyData(KanjiData otherKanji)
 {
     this.kanjiString      = otherKanji.kanjiString;
     this.romanjiString    = otherKanji.romanjiString;
     this.englishString    = otherKanji.englishString;
     this.romanjiStringAlt = otherKanji.romanjiStringAlt;
 }
Exemplo n.º 2
0
 public KanjiData(KanjiData other)
 {
     this.kanjiString      = other.kanjiString;
     this.romanjiString    = other.romanjiString;
     this.englishString    = other.englishString;
     this.romanjiStringAlt = other.romanjiStringAlt;
 }
Exemplo n.º 3
0
        public int CompareTo(object obj)
        {
            if (obj == null)
            {
                return(1);
            }

            if (obj is Compound)
            {
                Compound otherCompound = obj as Compound;

                string thisCompoundString  = this.ToString();
                string otherCompoundString = otherCompound.ToString();

                KanjiData thisKanji  = null;
                KanjiData otherKanji = null;

                // Check 0: Are they the same word?
                if (thisCompoundString == otherCompoundString)
                {
                    return(string.Compare(thisCompoundString, otherCompoundString));
                }

                // Check 1: Shorter strings come first.
                if (thisCompoundString.Length != otherCompoundString.Length)
                {
                    return(thisCompoundString.Length.CompareTo(otherCompoundString.Length));
                }
                else
                {
                    // Find the first character that doesn't match.
                    for (int x = 0; x < thisCompoundString.Length; x++)
                    {
                        if (thisCompoundString[x] != otherCompoundString[x])
                        {
                            // Check if it's in the kanjiDictionary. If not, assume it's a kana. If it is a kanji, do kanji comparison.
                            thisKanji  = _kanjiDictionary.Lookup(thisCompoundString[x].ToString());
                            otherKanji = _kanjiDictionary.Lookup(otherCompoundString[x].ToString());

                            if (thisKanji != null && otherKanji != null)
                            {
                                return(thisKanji.CompareTo(otherKanji));
                            }
                            else
                            {
                                return(string.Compare(thisCompoundString, otherCompoundString));
                            }
                        }
                    }

                    return(string.Compare(thisCompoundString, otherCompoundString));
                }
            }
            throw new ArgumentException("Object is not a User");
        }
Exemplo n.º 4
0
        // Shows info about the selected kanji in the message box.
        // TODO: Move this out of this class and into something more relevant.
        public static void ShowKanjiSelectionInfo(string toLookup, TextBox outputMessage, TextBox outputReading, TextBox outputMeaning)
        {
            KanjiData selected = kanjiDictionary.Lookup(toLookup);

            if (selected != null)
            {
                outputMessage.Text = string.Concat("Strokes: ", selected.Strokes().ToString(), " :: Freq: ", selected.Frequency().ToString(),
                                                   " :: Rads: ", kanjiToRadicalDictionary.Lookup(toLookup));
                outputReading.Text = string.Concat("On: ", selected.onReads, " :: Kun: ", selected.kunReads);
                outputMeaning.Text = selected.meanings;
            }
            else
            {
                outputMessage.Text = "No data found for the selected kanji.";
            }
        }
        private void toggleSortByFreq()
        {
            kanjiSearchManager.ForceNewSearch();
            compoundSearchHandler.ForceNewSearch();

            if (KanjiData.ToggleSortingMethod() == KanjiData.SortingMethod.FrequencyOnly)
            {
                messageBox.Text         = "Now sorting by frequency only.";
                frequencySortCB.Checked = true;
            }
            else
            {
                messageBox.Text         = "Now sorting by stroke count and frequency.";
                frequencySortCB.Checked = false;
            }
        }
Exemplo n.º 6
0
    //takes a line from the text file and fills in the appropriate fields in the Kanji Data object
    private void ParseLine(string parser, KanjiData inputField)
    {
        string[] parts = parser.Split(new[] { '/' });

        //if there are if only 1 pronunciation
        if (parts.Length == 3)
        {
            inputField.kanjiString      = parts[0];
            inputField.romanjiString    = parts[1];
            inputField.romanjiStringAlt = null;
            inputField.englishString    = parts[2];
        }
        //if there are pronunciations
        else
        {
            inputField.kanjiString      = parts[0];
            inputField.romanjiString    = parts[1];
            inputField.romanjiStringAlt = parts[2];
            inputField.englishString    = parts[3];
        }
    }
Exemplo n.º 7
0
        protected override List <Piece> GenerateStage(StageData stageData)
        {
            List <string> partNameList = exerciseLoader.GetPieceList(stageData).ToList();

            if (partNameList.Count == 0)
            {
                return(null);
            }

            List <Piece> pieceList = new List <Piece> ();

            for (int i = 0; i < kanjiFields.Length; i++)
            {
                KanjiPiece kanjiPiece = Instantiate(piecePrefab, kanjiFieldTransform);
                kanjiPiece.StartParent = kanjiFields[i];
                KanjiData kanjiData = kanjiPiece.GetKanjiData();
                kanjiData.SetKanji(partNameList[i]);
                pieceList.Add(kanjiPiece);

                NetworkServer.Spawn(kanjiPiece.gameObject);
            }

            return(pieceList);
        }
Exemplo n.º 8
0
            public int CompareTo(object obj)
            {
                if (obj == null)
                {
                    return(1);
                }

                if (obj is KanjiData)
                {
                    KanjiData otherKanjiData = obj as KanjiData;

                    // Sort differently depending on what sortByFreq is set to.
                    if (parent.sortByFreq == false)
                    {
                        // If the stroke counts are different, compare on that; otherwise, if the stroke counts are the same, compare on frequency.
                        if (this.strokes.CompareTo(otherKanjiData.strokes) == 0)
                        {
                            return(this.freq.CompareTo(otherKanjiData.freq));
                        }
                        return(this.strokes.CompareTo(otherKanjiData.strokes));
                    }
                    else
                    {
                        // Sort by hex value if freq == 9999.
                        if (this.freq == 9999 && otherKanjiData.freq == 9999)
                        {
                            return(string.Compare(this.ToString(), otherKanjiData.ToString()));
                        }
                        else
                        {
                            return(this.freq.CompareTo(otherKanjiData.freq));
                        }
                    }
                }
                throw new ArgumentException("Object is not a User");
            }