private void CopyCommand_Execute(object sender, RoutedEventArgs e) { e.Handled = true; CharacterFile @char = ClothesViewModel.CharacterViewModel.Character; string tgt = ClipboardHelper.GetSuitPrefix(ClothesViewModel.Kind); var clothBytes = new byte[92]; ClothFile cf = ClothFile.Load(clothBytes); var attribs = cf.Attributes.Keys.Select (s => { string tgtKey = s.Replace("CLOTH", tgt); if (@char.CharAttributes.ContainsKey(tgtKey)) { return(@char.CharAttributes[tgtKey]); } return(null); }) .Where(wrapper => wrapper != null); String str = ClipboardHelper.GetAttributesString(attribs, ClipboardHelper.REIAA2_SUITFLAG); //[WXP] Replaced Lambda to new Func/Action Dispatcher.Invoke (new Action (() => { string clothesPrefix = ClipboardHelper.GetSuitPrefix(ClothesViewModel.Kind); Clipboard.SetText(str.Replace(clothesPrefix, "CLOTH")); })); }
private ClothFile CreateClothFile() { string[] targets = { "UNIFORM", "SWIMSUIT", "SPORT", "CLUB" }; int suit = (int)ClothesViewModel.Kind; CharacterFile @char = ClothesViewModel.CharacterViewModel.Character; var attribs = @char.CharAttributes.Where(pair => pair.Key.StartsWith(targets[suit])) .Select(pair => pair.Value); ClothFile cf = new ClothFile { RawData = new byte[92], }; cf.Attributes["CLOTH_GENDER"].Value = ClothesViewModel.CharacterViewModel.Profile.Gender.Value; foreach (DataBlockWrapper wrapperChar in attribs) { string tgtKey = wrapperChar.Key.Replace(targets[suit], "CLOTH"); if (!cf.Attributes.ContainsKey(tgtKey)) { continue; } DataBlockWrapper wrapperCloth = cf.Attributes[tgtKey]; wrapperCloth.Value = wrapperChar.Value; } return(cf); }
private void SaveCommand_Execute(object sender, ExecutedRoutedEventArgs e) { e.Handled = true; string clothPath = Path.Combine(Core.PlaySaveDir, "Cloth"); SaveFileDialog svfd = new SaveFileDialog { AddExtension = true, Filter = "Cloth Files (*.cloth)|*.cloth", InitialDirectory = clothPath, FileName = ClothesViewModel.CharacterViewModel.Profile.Gender.Value.Equals((byte)0) ? "M_" : "F_" }; svfd.CustomPlaces.Add(new FileDialogCustomPlace(clothPath)); if (!svfd.ShowDialog(Window.GetWindow(this)) .Value) { return; } ClothFile cf = CreateClothFile(); FileStream fs = File.OpenWrite(svfd.FileName); fs.Write(cf.RawData, 0, cf.RawData.Length); fs.Close(); }
private void LoadCommand_OnExecuted(object sender, ExecutedRoutedEventArgs e) { e.Handled = true; string clothPath = Path.Combine(Core.PlaySaveDir, "Cloth"); OpenFileDialog opfd = new OpenFileDialog { AddExtension = true, CheckFileExists = true, Filter = "Cloth Files (*.cloth)|*.cloth", InitialDirectory = clothPath }; opfd.CustomPlaces.Add(new FileDialogCustomPlace(clothPath)); if (!opfd.ShowDialog(Window.GetWindow(this)) .Value) { return; } var data = File.ReadAllBytes(opfd.FileName); ClothFile cf = ClothFile.Load(data); ApplyClothFile(cf); }
private void ApplyClothFile(ClothFile cf) { string[] targets = { "UNIFORM", "SWIMSUIT", "SPORT", "CLUB" }; int suit = (int)ClothesViewModel.Kind; CharacterFile @char = ClothesViewModel.CharacterViewModel.Character; foreach (DataBlockWrapper wrapperCloth in cf.Attributes.Values) { string tgtKey = wrapperCloth.Key.Replace("CLOTH", targets[suit]); if ([email protected](tgtKey)) { continue; } DataBlockWrapper wrapperChar = @char.CharAttributes[tgtKey]; if (wrapperChar.ReadOnly) { continue; } wrapperChar.Value = wrapperCloth.Value; } }