Example #1
0
    public static JSONChart CytusChartToJChart(string[] cytusChart)
    {
        JSONChart jchart = new JSONChart();
        int       n      = cytusChart.Length;

        jchart.speed = 5.0f;
        for (int i = 4; i < n; i++)
        {
            int j = 0;
            int ivalue;
            if (cytusChart[i][0] == 'N')
            {
                ivalue = GetInt(cytusChart[i], ref j);
                JSONChart.note note = new JSONChart.note
                {
                    id = ivalue - 3
                };
                float fvalue = GetFloat(cytusChart[i], ref j);
                //note.time = fvalue - 0.08f;
                note.time = fvalue;
                fvalue    = GetFloat(cytusChart[i], ref j);
                note.pos  = fvalue * 4 - 2;
                jchart.notes.Add(note);
            }
            else
            {
                JSONChart.link link = new JSONChart.link();
                while (j < cytusChart[i].Length)
                {
                    ivalue = GetInt(cytusChart[i], ref j);
                    if (ivalue == -2147483648)
                    {
                        continue;
                    }
                    link.noteRef.Add(ivalue + 1);
                    jchart.notes[ivalue].size = 0.8f;
                }
                jchart.links.Add(link);
            }
        }
        return(jchart);
    }
Example #2
0
    public static JSONChart JSONtoJChart(string str)
    {
        JSONChart jchart = new JSONChart();

        /*
         * The json files in the official charts have variables name with "$id"
         * WT* are you using variables named with some strange characters?!!
         * So C# would be messed up with those strange variable names...
         * I'm parsing these values manually...
         */
        string substr;
        int    i = 0, temp = 0;

        while (str[i] != '{')
        {
            i++;
        }
        substr       = GetSubStr(str, ref i); //"speed"
        jchart.speed = GetFloat(str, ref i);
        substr       = GetSubStr(str, ref i); //"notes"
        while (str[i] != ']')
        {
            substr = GetSubStr(str, ref i); //"$id"
            JSONChart.note note = new JSONChart.note();
            temp    = 0;
            note.id = GetInt(GetSubStr(str, ref i), ref temp);
            while (str[i] != '}')
            {
                substr = GetSubStr(str, ref i);
                if (substr == "sounds")
                {
                    while (str[i] != ']')
                    {
                        JSONChart.sound sound = new JSONChart.sound();
                        while (str[i] != '}')
                        {
                            substr = GetSubStr(str, ref i);
                            if (substr == "d")
                            {
                                sound.d = GetFloat(str, ref i);
                            }
                            else if (substr == "p")
                            {
                                sound.p = GetInt(str, ref i);
                            }
                            else if (substr == "v")
                            {
                                sound.v = GetInt(str, ref i);
                            }
                            else if (substr == "w")
                            {
                                sound.w = GetFloat(str, ref i);
                            }
                        }
                        i++;
                        note.sounds.Add(sound);
                    }
                }
                else if (substr == "pos")
                {
                    note.pos = GetFloat(str, ref i);
                }
                else if (substr == "size")
                {
                    note.size = GetFloat(str, ref i);
                }
                else if (substr == "_time")
                {
                    note.time = GetFloat(str, ref i);
                }
                else if (substr == "shift")
                {
                    note.shift = GetFloat(str, ref i);
                }
                else
                {
                    while (str[i] != ',' && str[i] != '}')
                    {
                        i++;
                    }
                }
            }
            i++;
            jchart.notes.Add(note);
        }//"notes" complete
        substr = GetSubStr(str, ref i); //"links"
        i     += 2;
        while (str[i] != ']')
        {
            JSONChart.link link = new JSONChart.link();
            substr = GetSubStr(str, ref i); //"notes"
            while (str[i] != ']')
            {
                substr = GetSubStr(str, ref i); //"$ref"
                temp   = 0;
                link.noteRef.Add(GetInt(GetSubStr(str, ref i), ref temp));
                i++;
            }
            i += 2;
            jchart.links.Add(link);
        }
        return(jchart);
    }
Example #3
0
    public static JSONChart JSONtoJChart(string str)
    {
        JSONChart jchart = new JSONChart();

        /*
         * The json files in the official charts have variables name with "$id"
         * WT* are you using variables named with some strange characters?!!
         * So C# would be messed up with those strange variable names...
         * I'm parsing these values manually...
         */
        int i = 0, temp;

        while (str[i] != '{')
        {
            i++;
        }
        string firstSubStr = GetSubStr(str, ref i);
        bool   isSpeed     = (firstSubStr == "speed");

        if (isSpeed)
        {
            jchart.speed = GetFloat(str, ref i);
            GetSubStr(str, ref i); //"notes"
        }
        while (str[i] != ']')
        {
            string         noteSubStr = GetSubStr(str, ref i);
            bool           isId       = (noteSubStr == "id");
            JSONChart.note note       = new JSONChart.note();
            if (!isId)
            {
                note.time = GetFloat(str, ref i);
                GetSubStr(str, ref i); //"$id"
            }
            note.id = GetIntFromIntOrSubStr(str, ref i);
            while (str[i] != '}')
            {
                string substr = GetSubStr(str, ref i);
                switch (substr)
                {
                case "sounds":
                {
                    while (str[i] != ']')
                    {
                        JSONChart.sound sound = new JSONChart.sound();
                        while (str[i] != '}')
                        {
                            substr = GetSubStr(str, ref i);
                            switch (substr)
                            {
                            case "d":
                                sound.d = GetFloat(str, ref i);
                                break;

                            case "p":
                                sound.p = GetInt(str, ref i);
                                break;

                            case "v":
                                sound.v = GetInt(str, ref i);
                                break;

                            case "w":
                                sound.w = GetFloat(str, ref i);
                                break;
                            }
                        }
                        i++;
                        note.sounds.Add(sound);
                    }
                    break;
                }

                case "pos":
                    note.pos = GetFloat(str, ref i);
                    break;

                case "size":
                    note.size = GetFloat(str, ref i);
                    break;

                case "_time":
                    note.time = GetFloat(str, ref i);
                    break;

                case "shift":
                    note.shift = GetFloat(str, ref i);
                    break;

                default:
                {
                    while (str[i] != ',' && str[i] != '}')
                    {
                        i++;
                    }
                    break;
                }
                }
            }
            i++;
            jchart.notes.Add(note);
        } // "notes" complete
        GetSubStr(str, ref i); // "links"
        i += 2;
        while (str[i] != ']')
        {
            JSONChart.link link = new JSONChart.link();
            GetSubStr(str, ref i); // "notes"
            while (str[i] != ']')
            {
                GetSubStr(str, ref i); // "$ref"
                link.noteRef.Add(GetIntFromIntOrSubStr(str, ref i));
                i++;
            }
            i += 2;
            jchart.links.Add(link);
        }
        if (!isSpeed)
        {
            GetSubStr(str, ref i); // "speed"
            jchart.speed = GetFloat(str, ref i);
        }
        return(jchart);
    }