Exemplo n.º 1
0
        private void BlessingWorldEdition()
        {
            Config config = new Config(CONFIG_PATH);
            try
            {
                config.Load();
            }
            catch (Exception)
            {
                Uri cfgUri = new Uri(new Uri(Environment.CurrentDirectory), CONFIG_PATH);
                MessageBox.Show("在 " + Uri.UnescapeDataString(cfgUri.AbsoluteUri) + " 找不到配置文件。请把我放在皮肤根目录里,皮肤要放在 osu!/Skins 里。", "我想回家");
                Application.Current.Shutdown(1);
                return;
            }
            config.Parse();
            Debug.WriteLine("Config OK");

            Skin skin = new Skin(SKIN_PATH);
            try
            {
                skin.Load();
            }
            catch (Exception)
            {
                MessageBox.Show("这个文件夹里没找到" + SKIN_PATH + "呀。你确定放到皮肤的根目录里了吗?", "智商美丽");
                Application.Current.Shutdown(2);
                return;
            }
            skin.Parse();
            Debug.WriteLine("Parse OK");

            skin.CenterAll();
            try
            {
                skin.Save();
            }
            catch (Exception)
            {
                MessageBox.Show("写入文件发生了错误,目测 skin.ini 被占用了,不然的话就是管理员权限的问题?", "明明还差最后一步了的说");
                Application.Current.Shutdown(3);
                return;
            }

            MessageBox.Show("成功了哟", "主人我要吃糖糖");
            Application.Current.Shutdown();
        }
Exemplo n.º 2
0
        public Section(Skin Skin, string Name, string Content, int Index)
        {
            this.Skin = Skin;
            this.Name = Name;
            this.Content = Content;
            this.Index = Index;

            // Initialize `Lines`
            var re = new Regex(@"(?<!\s*//)\s*(?<key>\w+)\s*:\s*(?<value>.+(?<!\r))\r?$", RegexOptions.Multiline | RegexOptions.ExplicitCapture);
            var matches = re.Matches(Content);
            var length = matches.Count;

            for (int i = 0; i < length; i++)
            {
                var groups = matches[i].Groups;

                Lines[groups["key"].Value] = new Line
                (
                    ContentBuilder: Skin.ContentBuilder,
                    Value: groups["value"].Value,
                    ValueIndex: groups["value"].Index + Index
                );
            }
        }