private void loadButton_Click(object sender, EventArgs e) { string toneSavePath; using (var ofd = new OpenFileDialog()) { ofd.Filter = "Rocksmith Tone (*.tone.xml)|*.tone.xml"; if (ofd.ShowDialog() != DialogResult.OK) return; toneSavePath = ofd.FileName; } Tone tone = null; var serializer = new DataContractSerializer(typeof(Tone)); using (var stm = new XmlTextReader(toneSavePath)) { try { tone = (Tone)serializer.ReadObject(stm); } catch (Exception ex) { MessageBox.Show("Can't load saved tone. \n\r" + ex.Message, "DLCPackageCreator", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } toneControl1.Tone = tone; LoadedTone = toneControl1.Tone; MessageBox.Show("Tone was loaded.", "DLC Package Creator", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private static void generateManifest(Stream outManifest, Tone.Tone tone) { var manifest = new Tone.Manifest(); manifest.Entries.Add(tone); var data = JsonConvert.SerializeObject(manifest, Formatting.Indented); var writer = new StreamWriter(outManifest); writer.Write(data); writer.Flush(); outManifest.Seek(0, SeekOrigin.Begin); }
public static void Generate(string toneKey, Tone.Tone tone, Stream outManifest, Stream outXblock, Stream aggregateGraph) { var id = IdGenerator.Guid().ToString().Replace("-", ""); if (string.IsNullOrEmpty(tone.Name)) { tone.Name = toneKey; } tone.Key = toneKey; tone.PersistentID = id; tone.BlockAsset = String.Format("urn:emergent-world:DLC_Tone_{0}", toneKey); generateManifest(outManifest, tone); generateXBlock(toneKey, outXblock, tone); generateAggregateGraph(toneKey, aggregateGraph); }
private static void generateXBlock(string toneKey, Stream outXblock, Tone.Tone tone) { var game = new GameXblock <Entity>(); var entity = new Entity { Name = String.Format("GRTonePreset_{0}", toneKey), Iterations = 1, ModelName = "GRTonePreset", Id = tone.PersistentID.ToLower() }; var properties = entity.Properties = new List <Property>(); var addProperty = new Action <string, object>((a, b) => properties.Add(CreateProperty(a, b.ToString()))); addProperty("Key", tone.Key); addProperty("Name", tone.Name); game.EntitySet = new List <Entity> { entity }; game.Serialize(outXblock); }
public ToneForm(Tone tone) { InitializeComponent(); toneControl1.Tone = tone; }