示例#1
0
 private void WriteSoundsFromReader(SkinWizardViewModel vm, SkinSoundReader reader, string skinPath)
 {
     foreach (SoundEntry entry in reader.Files)
     {
         WriteFile(vm, skinPath, entry.Name + entry.PreferredFormat, reader);
     }
 }
示例#2
0
        internal void ApplyData(NewSkinViewModel vm)
        {
            SkinWizardViewModel wizardVm = DataContext as SkinWizardViewModel;

            wizardVm.Name          = vm.Name;
            wizardVm.Author        = vm.Author;
            wizardVm.AddDummyFiles = vm.AddDummyFiles;
        }
示例#3
0
 /// <summary>
 /// This method iterates through all entries inside the given <see cref="SkinElementReader"/> and writes them into the given path.
 /// </summary>
 /// <param name="vm">The viewmodel of the skin creation wizard</param>
 /// <param name="reader">The reader which contains all information about skin elements</param>
 /// <param name="skinPath">The path where all elements should be saved to</param>
 /// <param name="useNewStyle">Optional: If true, this method will only export elements without flag or with the flag "New".
 /// <para>If false, this method will only export elements without flag or with the flag "Old".</para>
 /// <para>If null, flags are ignored.</para></param>
 private void WriteFilesFromReader(SkinWizardViewModel vm, SkinElementReader reader, string skinPath, bool?useNewStyle = null)
 {
     foreach (SkinningEntry entry in reader.Files)
     {
         if (useNewStyle == null)
         {
             WriteFile(vm, skinPath, entry.Name + entry.PreferredFormat, reader);
         }
         else if (useNewStyle == true && !entry.Flags.Contains("old"))
         {
             WriteFile(vm, skinPath, entry.Name + entry.PreferredFormat, reader);
         }
         else if (useNewStyle == false && !entry.Flags.Contains("new"))
         {
             WriteFile(vm, skinPath, entry.Name + entry.PreferredFormat, reader);
         }
     }
 }
示例#4
0
        private async void Confirm_Click(object sender, RoutedEventArgs e)
        {
            SkinWizardViewModel vm = DataContext as SkinWizardViewModel;

            vm.IsCreating       = true;
            vm.FilesToCreate    = 0;
            vm.CurrentFileCount = 0;
            vm.CurrentFileName  = "";

            if (vm.ComponentInterface)
            {
                vm.FilesToCreate += FixedValues.readerInterface.FileCount;
            }
            if (vm.ComponentOsu)
            {
                vm.FilesToCreate += FixedValues.readerStandard.FileCount;
            }
            if (vm.ComponentMania)
            {
                vm.FilesToCreate += FixedValues.readerMania.FileCount;
            }
            if (vm.ComponentCTB)
            {
                vm.FilesToCreate += FixedValues.readerCatch.FileCount;
            }
            if (vm.ComponentTaiko)
            {
                vm.FilesToCreate += FixedValues.readerTaiko.FileCount;
            }
            if (vm.ComponentSounds)
            {
                vm.FilesToCreate += FixedValues.readerSounds.FileCount;
            }

            Logger.Instance.WriteLog("Creating new skin \"{0}\"... ({1} files to generate)",
                                     vm.Name, vm.FilesToCreate);

            string skinPath = App.ProfileManager.Profile.OsuDirectory + "\\" + vm.Name;

            Directory.CreateDirectory(skinPath);
            bool spinnerNewChecked = (bool)cb_spinnerNew.IsChecked;
            bool catcherNewChecked = (bool)cb_catcherNew.IsChecked;

            new Thread(() =>
            {
                if (vm.ComponentInterface)
                {
                    WriteFilesFromReader(vm, FixedValues.readerInterface, skinPath);
                    Logger.Instance.WriteLog("Generating interface elements... ({0} files)",
                                             FixedValues.readerInterface.FileCount);
                }
                if (vm.ComponentOsu)
                {
                    WriteFilesFromReader(vm, FixedValues.readerStandard, skinPath, spinnerNewChecked);
                    Logger.Instance.WriteLog("Generating osu! Standard elements... ({0} files)",
                                             FixedValues.readerStandard.FileCount);
                }
                if (vm.ComponentMania)
                {
                    WriteFilesFromReader(vm, FixedValues.readerMania, skinPath);
                    Logger.Instance.WriteLog("Generating Mania elements... ({0} files)",
                                             FixedValues.readerMania.FileCount);
                }
                if (vm.ComponentCTB)
                {
                    WriteFilesFromReader(vm, FixedValues.readerCatch, skinPath, catcherNewChecked);
                    Logger.Instance.WriteLog("Generating CTB elements... ({0} files)",
                                             FixedValues.readerCatch.FileCount);
                }
                if (vm.ComponentTaiko)
                {
                    WriteFilesFromReader(vm, FixedValues.readerTaiko, skinPath);
                    Logger.Instance.WriteLog("Generating Taiko elements... ({0} files)",
                                             FixedValues.readerTaiko.FileCount);
                }
                if (vm.ComponentSounds)
                {
                    WriteSoundsFromReader(vm, FixedValues.readerSounds, skinPath);
                    Logger.Instance.WriteLog("Generating sounds... ({0} files)",
                                             FixedValues.readerSounds.FileCount);
                }
            }).Start();

            string skinIniRaw = Properties.Resources.DefaulSkinIni;

            skinIniRaw = skinIniRaw.Replace("[NAME]", vm.Name)
                         .Replace("[AUTHOR]", vm.Author)
                         .Replace("[VERSION]", combo_version.Text);

            File.WriteAllText(Path.Combine(skinPath, "skin.ini"), skinIniRaw);
            Logger.Instance.WriteLog("skin.ini created!");
            vm.IsCreating = false;
            Skin skin = new Skin(skinPath);

            vm.Master.Skins.Add(skin);
            Logger.Instance.WriteLog("Skin \"{0}\" successfully created!", vm.Name);
            if (await SkinEditor.Instance.LoadSkin(skin))
            {
                vm.Master.SelectedSidebarIndex = FixedValues.EDITOR_INDEX;
            }
        }
示例#5
0
 private void WriteFile(SkinWizardViewModel vm, string skinPath, string name, ElementGenerator gen)
 {
     vm.CurrentFileCount++;
     vm.CurrentFileName = name;
     gen.Generate(Path.Combine(skinPath, name));
 }
        private void Confirm_Click(object sender, RoutedEventArgs e)
        {
            SkinWizardViewModel vm = DataContext as SkinWizardViewModel;

            vm.IsCreating       = true;
            vm.FilesToCreate    = 0;
            vm.CurrentFileCount = 0;
            vm.CurrentFileName  = "";

            if (vm.ComponentInterface)
            {
                vm.FilesToCreate += FixedValues.readerInterface.FileCount;
            }
            if (vm.ComponentOsu)
            {
                vm.FilesToCreate += FixedValues.readerStandard.FileCount;
            }
            if (vm.ComponentMania)
            {
                vm.FilesToCreate += FixedValues.readerMania.FileCount;
            }
            if (vm.ComponentCTB)
            {
                vm.FilesToCreate += FixedValues.readerCatch.FileCount;
            }
            if (vm.ComponentTaiko)
            {
                vm.FilesToCreate += FixedValues.readerTaiko.FileCount;
            }
            if (vm.ComponentSounds)
            {
                vm.FilesToCreate += FixedValues.readerSounds.FileCount;
            }

            string skinPath = AppConfiguration.GetInstance().OsuDirectory + "\\Skins\\" + vm.Name;

            Directory.CreateDirectory(skinPath);
            bool spinnerNewChecked = (bool)cb_spinnerNew.IsChecked;
            bool catcherNewChecked = (bool)cb_catcherNew.IsChecked;

            new Thread(() =>
            {
                if (vm.ComponentInterface)
                {
                    WriteFilesFromReader(vm, FixedValues.readerInterface, skinPath);
                }
                if (vm.ComponentOsu)
                {
                    WriteFilesFromReader(vm, FixedValues.readerStandard, skinPath, spinnerNewChecked);
                }
                if (vm.ComponentMania)
                {
                    WriteFilesFromReader(vm, FixedValues.readerMania, skinPath);
                }
                if (vm.ComponentCTB)
                {
                    WriteFilesFromReader(vm, FixedValues.readerCatch, skinPath, catcherNewChecked);
                }
                if (vm.ComponentTaiko)
                {
                    WriteFilesFromReader(vm, FixedValues.readerTaiko, skinPath);
                }
                if (vm.ComponentSounds)
                {
                    WriteSoundsFromReader(vm, FixedValues.readerSounds, skinPath);
                }
            }).Start();

            string skinIniRaw = Properties.Resources.DefaulSkinIni;

            skinIniRaw = skinIniRaw.Replace("[NAME]", vm.Name)
                         .Replace("[AUTHOR]", vm.Author)
                         .Replace("[VERSION]", combo_version.Text);

            File.WriteAllText(Path.Combine(skinPath, "skin.ini"), skinIniRaw);
            vm.IsCreating = false;
            Skin skin = new Skin(skinPath);

            vm.Master.Skins.Add(skin);
            SkinEditor.Instance.LoadSkin(skin);
            vm.Master.SelectedSidebarIndex = FixedValues.EDITOR_INDEX;
        }