Пример #1
0
        private void MainOsu()
        {
            BlackCurtain.Visibility = Visibility.Collapsed;
            imgOsuLogo.BeginAnimation(OpacityProperty, null);
            imgOsuLogo.Opacity = 1;
            currentSection     = OsuSection.MainScreen;
            HotkeyImplementing();
            BackgroundSlide();
            BGMPlayer.Source = new Uri(workingResources.BaseDir + @"\Resources\Default Audio\Circle.wav");
            BGMPlayer.Play();
            MainOsuHeader.Visibility = Visibility.Visible;
            BGMPlayer.MediaEnded    += BGMPlayer_MediaEnded;
            AccountInfo.Visibility   = Visibility.Visible;
            imgOsuLogo.Margin        = new Thickness(130);
            defaultLogoMargin        = imgOsuLogo.Margin;
            osuCookieBehaviour       = OsuCookieBehaviour.ClickToOpenTab;
            ChangeAllSettingIconUnlit(SettingIcon1);
            SettingIcon1.Opacity = 1;
            OsuBouncingController(240);
            grdBackLightContainer.Visibility = Visibility.Visible;

            //Add default margin to SelectionTab
            imgPlayTab.Tag   = new EndAnimationPos(new Thickness(450, 155, 210, 515), new Thickness(490, 155, 170, 515));
            imgExitTab.Tag   = new EndAnimationPos(new Thickness(450, 505, 210, 165), new Thickness(490, 505, 170, 165));
            imgEditTab.Tag   = new EndAnimationPos(new Thickness(430, 275, 130, 395), new Thickness(470, 275, 130, 395));
            imgOptionTab.Tag = new EndAnimationPos(new Thickness(440, 385, 110, 285), new Thickness(470, 385, 130, 285));
            imgSoloTab.Tag   = new EndAnimationPos(new Thickness(460, 225, 210, 447), new Thickness(500, 225, 170, 447));
            imgMultiTab.Tag  = new EndAnimationPos(new Thickness(460, 335, 200, 335), new Thickness(500, 335, 160, 335));
            imgBackTab.Tag   = new EndAnimationPos(new Thickness(460, 440, 200, 230), new Thickness(500, 440, 160, 230));
        }
Пример #2
0
        public static ChartFile ConvertOsuFile(string file)
        {
            FileInfo fI = new FileInfo(file);

            if (!fI.Exists)
            {
                return(null);
            }

            OsuFile osuFile = new OsuFile(fI.Name + fI.Extension, fI.Directory.FullName, new Dictionary <string, OsuSection>());

            using (StreamReader sreader = new StreamReader(fI.FullName))
            {
                bool   readSection = true;
                bool   readProps   = false;
                string sectionName = null;
                string line;
                while (!sreader.EndOfStream)
                {
                    line = sreader.ReadLine();

                    if (string.IsNullOrEmpty(line))
                    {
                        continue;
                    }

Begin:
                    if (readSection)
                    {
                        if (line[0].Equals('['))
                        {
                            line = line.Trim('[', ']', ' ');

                            sectionName = line;
                            Logger.Log(sectionName);
                            osuFile.Sections.Add(line, new OsuSection(line, new Dictionary <string, OsuProperty>()));

                            readSection = false;
                            readProps   = true;
                        }
                        continue;
                    }

                    if (readProps)
                    {
                        if (line[0].Equals('['))
                        {
                            readSection = true;
                            readProps   = false;
                            goto Begin;
                        }

                        OsuProperty prop;
                        switch (sectionName.ToLower())
                        {
                        case "difficulty":
                        case "events":
                        case "editor":
                            continue;

                        case "timingpoints":
                            string[] timingSplit = line.Split(',');
                            int.TryParse(timingSplit[0], out int offset);
                            osuFile.Offset = offset;
                            float.TryParse(timingSplit[1], out float bpm);
                            osuFile.BPM = bpm;
                            readSection = true;
                            readProps   = false;
                            continue;

                        case "hitobjects":
                            string[] noteSplit = line.Split(',').Skip(2).ToArray();

                            if (noteSplit == null || noteSplit.Length < 3)
                            {
                                continue;
                            }

                            long[] iNoteSplit = new long[noteSplit.Length];
                            for (int i = 0; i < noteSplit.Length; i++)
                            {
                                long.TryParse(noteSplit[i], out iNoteSplit[i]);
                            }

                            prop = new OsuProperty("Note." + noteSplit[0], new long[] { iNoteSplit[0], iNoteSplit[1], iNoteSplit[2] });
                            osuFile.Sections[sectionName].Properties.Add(prop.Name, prop);
                            continue;

                        default:
                            break;
                        }

                        string[] propSplit = line.Split(':');

                        if (propSplit == null || propSplit.Length < 2)
                        {
                            continue;
                        }
                        if (float.TryParse(propSplit[1], out float fval))
                        {
                            prop = new OsuProperty(propSplit[0], fval);
                            osuFile.Sections[sectionName].Properties.Add(prop.Name, prop);
                            continue;
                        }

                        prop = new OsuProperty(propSplit[0], propSplit[1]);
                        osuFile.Sections[sectionName].Properties.Add(prop.Name, prop);
                    }
                }
            }

            OsuSection general  = osuFile.Sections["General"];
            OsuSection metadata = osuFile.Sections["Metadata"];

            ChartFile ch = new ChartFile
            {
                ID           = 0,
                Artist       = (string)metadata.Properties["Artist"].Value,
                Title        = (string)metadata.Properties["Title"].Value,
                Tags         = (string)metadata.Properties["Tags"].Value,
                Difficulty   = (string)metadata.Properties["Version"].Value,
                Creator      = (string)metadata.Properties["Creator"].Value,
                Source       = (string)metadata.Properties["Source"].Value,
                PreviewStart = (long)(float)general.Properties["PreviewTime"].Value,
                Offset       = osuFile.Offset,
                SoundFile    = ((string)general.Properties["AudioFilename"].Value).TrimStart(' '),

                Notes = new List <ChartNote>()
            };
            OsuSection snote = osuFile.Sections["HitObjects"];

            ChartNote cn;

            long[]   vals;
            bool     bigNote;
            TimeSpan timing;
            short    color;

            foreach (var prop in snote.Properties)
            {
                vals = (long[])prop.Value.Value;

                timing = TimeSpan.FromMilliseconds(vals[0]);

                switch (vals[2])
                {
                default:
                case 0:
                    bigNote = false;
                    color   = 1;
                    break;

                case 2:
                    bigNote = false;
                    color   = 0;
                    break;

                case 4:
                    bigNote = true;
                    color   = 1;
                    break;

                case 6:
                    bigNote = true;
                    color   = 0;
                    break;

                case 8:
                    bigNote = false;
                    color   = 0;
                    break;

                case 12:
                    bigNote = true;
                    color   = 0;
                    break;
                }

                cn = new ChartNote(timing, bigNote, color);

                ch.Notes.Add(cn);
            }

            return(ch);
        }