Description:
More serialization tweaking.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r85:924e7b7e2cf1 -

1 NO CONTENT: modified file, binary diff hidden
@@ -16,12 +16,13
16 16 using isometricparkfna.Utils;
17 17 using isometricparkfna.UI;
18 18
19
19 using Newtonsoft.Json.Serialization;
20 20
21 21
22 22 using ImGuiNET.SampleProgram.XNA;
23 23 using ImGuiNET;
24 24 using TraceryNet;
25 using Newtonsoft.Json;
25 26
26 27 class FNAGame : Game
27 28 {
@@ -420,21 +421,40
420 421
421 422 this.simulation.update(gameTime.ElapsedGameTime);
422 423
423 #if DEBUG
424 #if DEBUG
424 425
425 if (keyboardCur.IsKeyDown(Keys.S) && keyboardPrev.IsKeyUp(Keys.S))
426 if (keyboardCur.IsKeyDown(Keys.S) && keyboardPrev.IsKeyUp(Keys.S))
426 427 {
427 428 System.Runtime.Serialization.IFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
428 429 Stream stream = new FileStream("MyFile.bin", FileMode.Create, FileAccess.Write, FileShare.None);
429 430 formatter.Serialize(stream, this.simulation);
430 stream.Close();
431 stream.Close();
432
433
434 // JsonSerializer serializer = new JsonSerializer();
435 // StreamWriter jsonstream = new StreamWriter("MyFile.json");
436 // JsonWriter writer = new JsonTextWriter(jsonstream);
437 // serializer.Serialize(writer, this.simulation);
438
439 // File.WriteAllText(@"MyFile.json", JsonConvert.SerializeObject(this.simulation));
440
431 441 }
432 442
433 443 if (keyboardCur.IsKeyDown(Keys.L) && keyboardPrev.IsKeyUp(Keys.L))
434 444 {
435 System.Runtime.Serialization.IFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
436 Stream stream = new FileStream("MyFile.bin", FileMode.Open, FileAccess.Read);
437 this.simulation = (Simulation)formatter.Deserialize(stream);
445 System.Runtime.Serialization.IFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
446 Stream stream = new FileStream("MyFile.bin", FileMode.Open, FileAccess.Read);
447 this.simulation = (Simulation)formatter.Deserialize(stream);
448
449 this.simulation.initializeRandom();
450 stream.Close();
451
452
453 // StreamReader loadedFile = new StreamReader(new FileStream("MyFile.json", FileMode.Open, FileAccess.Read));
454 // JsonReader reader = new JsonTextReader(new StreamReader(new FileStream("MyFile.json", FileMode.Open, FileAccess.Read)));
455 // var serializer = new JsonSerializer();
456 // this.simulation = serializer.Deserialize<Simulation>(reader);
457 // reader.Close();
438 458 }
439 459 #endif
440 460
@@ -141,7 +141,6
141 141 public bool paused;
142 142
143 143
144
145 144 [NonSerialized]
146 145 private Random random;
147 146
@@ -340,5 +339,9
340 339
341 340
342 341 }
342
343 public void initializeRandom() {
344 this.random = new Random();
345 }
343 346 }
344 347 }
You need to be logged in to leave comments. Login now