Пример #1
0
        public void UI_SetProjectType(int type)
        {
            CurrentProjectType = (ProjectTemplateType)type;
            ProjectTemplateAsset template = null;

            foreach (var _template in m_Templates)
            {
                if (_template.Type == CurrentProjectType)
                {
                    template = _template;
                    break;
                }
            }
            if (template != null)
            {
                m_GeneHintLabel.text = $"{GetLanguage(PROJECT_TEMPLATE_HINT_KEY)}{GetLanguage(template.Gene.Key + (CurrentProjectType == m_FuckedType ? PROJECT_TYPE_HINT_KEY_FUCK : ""))}";
            }
        }
Пример #2
0
        public void UI_Create()
        {
            // Check
            if (string.IsNullOrEmpty(m_ProjectName.text))
            {
                DialogUtil.Dialog_OK(DIALOG_NoTitle, DialogUtil.MarkType.Warning);
                return;
            }
            if (MusicData is null)
            {
                DialogUtil.Dialog_OK(DIALOG_NoMusic, DialogUtil.MarkType.Warning);
                return;
            }
            // Create Project
            var result = new Project()
            {
                LastEditTime     = Util.GetLongTime(),
                ProjectName      = m_ProjectName.text,
                Description      = m_ProjectDescription.text,
                BackgroundAuthor = "",
                BeatmapAuthor    = m_BeatmapAuthor.text,
                MusicAuthor      = m_MusicAuthor.text,
                MusicData        = MusicData,
                BackgroundData   = null,
                FrontCover       = null,
            };
            // Template
            ProjectTemplateAsset template = null;

            foreach (var _template in m_Templates)
            {
                if (_template.Type == CurrentProjectType)
                {
                    template = _template;
                    break;
                }
            }
            if (template != null)
            {
                // Data
                try {
                    result.Palette.AddRange(template.Palette.GetPixels32());
                    result.Tweens.AddRange(JsonUtility.FromJson <Project.TweenArray>(template.Tween.text).GetAnimationTweens());
                } catch {
                    Debug.LogError("Failed to add data");
                }
                // Beatmap
                try {
                    var key = System.Guid.NewGuid().ToString();
                    result.OpeningBeatmap = key;
                    Beatmap map = template.Beatmap != null?JsonUtility.FromJson <Beatmap>(template.Beatmap.text) : Beatmap.NewBeatmap();

                    map.CreatedTime = Util.GetLongTime();
                    result.BeatmapMap.Add(key, map);
                } catch {
                    Debug.LogError("Failed to create beatmap");
                }
                // Gene
                try {
                    result.Gene = template.Gene;
                } catch {
                    Debug.LogError("Failed to do gene");
                }
            }
            // Create File
            string path = Util.CombinePaths(RootPath, $"{Util.GetTimeString()}_{m_ProjectName.text}.stager");

            try {
                using (var stream = System.IO.File.Create(path)) {
                    using (var writer = new System.IO.BinaryWriter(stream)) {
                        result.Write(writer);
                    }
                }
                UI_Close();
                GotoEditor(path);
            } catch (System.Exception ex) {
                DialogUtil.Open(GetLanguage(DIALOG_ErrorOnCreateProject) + "\n" + ex.Message, DialogUtil.MarkType.Warning, () => { });
            }
        }