private void WriteSoundsFromReader(SkinWizardViewModel vm, SkinSoundReader reader, string skinPath) { foreach (SoundEntry entry in reader.Files) { WriteFile(vm, skinPath, entry.Name + entry.PreferredFormat, reader); } }
internal void ApplyData(NewSkinViewModel vm) { SkinWizardViewModel wizardVm = DataContext as SkinWizardViewModel; wizardVm.Name = vm.Name; wizardVm.Author = vm.Author; wizardVm.AddDummyFiles = vm.AddDummyFiles; }
/// <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); } } }
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; } }
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; }