Пример #1
0
        //セーブ
        void GenSaveData(ScoreComponent score)
        {
            if (!Directory.Exists(GetJsonPath()))
            {
                Directory.CreateDirectory(GetJsonPath());
            }

            if (score == null)
            {
                return;
            }

            var timelineList = new List <object>();

            foreach (var timeline in score.timelineTracks_)
            {
                //削除済み
                if (!timeline.IsExistTimeline_)
                {
                    continue;
                }

                var tackList = new List <object>();
                //tack
                foreach (var tack in timeline.tackPoints_)
                {
                    //削除済み
                    if (!tack.IsExistTack_)
                    {
                        continue;
                    }

                    var tackDict = tack.OutputDict();
                    tackList.Add(tackDict);
                }
                //timeline
                var timelineDict = timeline.OutputDict(tackList);

                timelineList.Add(timelineDict);
            }

            //score
            var scoreObject = score.OutputDict(timelineList);

            var dataStr = Json.Serialize(scoreObject);

            //var targetFilePath = Path.Combine(Application.dataPath, TimeFlowShikiSettings.TIMEFLOWSHIKI_DATA_FILEPATH);
            var targetFilePath = GetJsonPath() + "/" + score.id_ + ".json";             // "timeflowshiki.json";// + selectedFile;

            Debug.Log("<color=red>SaveActiveScore:" + targetFilePath + "</color>");

            using (var sw = new StreamWriter(targetFilePath))
            {
                sw.Write(dataStr);
            }

            //セーブしたときはとりあえず全ウインド書き換え
            RepaintAllWindow();
        }
Пример #2
0
        public void DrawTimelines(ScoreComponent auto, float yOffsetPos, float xScrollIndex, float trackWidth)
        {
            var yIndex = yOffsetPos;

            for (var windowIndex = 0; windowIndex < timelineTracks_.Count; windowIndex++)
            {
                var timelineTrack = timelineTracks_[windowIndex];
                if (!timelineTrack.IsExistTimeline_)
                {
                    continue;
                }

                var trackHeight = timelineTrack.DrawTimelineTrack(yOffsetPos, xScrollIndex, yIndex, trackWidth);

                // set next y index.
                yIndex = yIndex + trackHeight + WindowSettings.TIMELINE_SPAN;
            }
        }
Пример #3
0
        //リロードセーブデータ
        public void ReloadSavedData()
        {
            this.scores_.Clear();

            foreach (var item in fileList_)
            {
                var dataPath     = GetJsonPath() + "/" + item + ".json";
                var deserialized = new Dictionary <string, object>();

                if (File.Exists(dataPath))
                {
                    deserialized = LoadData(dataPath);
                }

                if (deserialized.Any())
                {
                    //Debug.Log("LoadScore");
                    ScoreComponent loadScore = LoadScore(deserialized);
                    if (loadScore.id_ != item)
                    {
                        loadScore.id_ = item;                                           //IDとファイル名合わせる
                    }
                    this.scores_.Add(loadScore);
                }
            }

            // load demo data then save it.
            if (!this.scores_.Any())
            {
                foreach (enMotionType item in Enum.GetValues(typeof(enMotionType)))
                {
                    var firstAuto = GenerateFirstScore(item.ToString());
                    this.scores_.Add(firstAuto);
                }

                //生成されたヤツ全保存
                SaveDataAll();
                Debug.Log("SaveDataAll");
            }

            SetActiveScore(activeScoreIndex_);
        }
Пример #4
0
        //スコアファイルを単体JSONに分ける
        ScoreComponent LoadScore(Dictionary <string, object> deserialized)
        {
            var scoreTimelines   = deserialized[TimeFlowShikiSettings.TIMEFLOWSHIKI_DATA_SCORE_TIMELINES] as List <object>;
            var currentTimelines = new List <TimelineTrack>();

            foreach (var scoreTimeline in scoreTimelines)
            {
                var scoreTimelineDict = scoreTimeline as Dictionary <string, object>;

                var timelineTacks = scoreTimelineDict[TimeFlowShikiSettings.TIMEFLOWSHIKI_DATA_TIMELINE_TACKS] as List <object>;
                var currentTacks  = new List <TackPoint>();
                foreach (var timelineTack in timelineTacks)
                {
                    var timelineTacksDict = timelineTack as Dictionary <string, object>;
                    var newTack           = new TackPoint(currentTacks.Count, timelineTacksDict);
                    currentTacks.Add(newTack);
                }
                var newTimeline = new TimelineTrack(currentTimelines.Count, scoreTimelineDict, currentTacks);
                currentTimelines.Add(newTimeline);
            }
            var newScore = new ScoreComponent(deserialized, currentTimelines);

            return(newScore);
        }
Пример #5
0
 public void UpdateTimelineTrack(ScoreComponent score)
 {
     this.score = score;
 }
 void DrawTimelines(ScoreComponent activeAuto, float yOffsetPos, float xScrollIndex, float viewWidth)
 {
     BeginWindows();
     activeAuto.DrawTimelines(activeAuto, yOffsetPos, xScrollIndex, viewWidth);
     EndWindows();
 }