Automap (client) [VS plugin mod]
Revision | 9ff3843035f5a07a42fb9a60b5352494aa875a8f (tree) |
---|---|
Time | 2020-02-24 03:36:03 |
Author | The Grand Dog <alex.h@me.c...> |
Commiter | The Grand Dog |
prep Metadata.js for ViewFrame, bug fix with POI positions
@@ -92,10 +92,12 @@ namespace Automap | ||
92 | 92 | |
93 | 93 | ClientAPI.Event.ChunkDirty += ChunkAChanging; |
94 | 94 | |
95 | - cartographer_thread = new Thread(Cartographer); | |
96 | - cartographer_thread.Name = "Cartographer"; | |
97 | - cartographer_thread.Priority = ThreadPriority.Lowest; | |
98 | - cartographer_thread.IsBackground = true; | |
95 | + cartographer_thread = new Thread(Cartographer) | |
96 | + { | |
97 | + Name = "Cartographer", | |
98 | + Priority = ThreadPriority.Lowest, | |
99 | + IsBackground = true | |
100 | + }; | |
99 | 101 | |
100 | 102 | ClientAPI.Event.RegisterGameTickListener(AwakenCartographer, 6000); |
101 | 103 | } |
@@ -308,21 +310,6 @@ namespace Automap | ||
308 | 310 | tableWriter.Write(stylesFile.ToText()); |
309 | 311 | tableWriter.RenderEndTag();//</style> |
310 | 312 | |
311 | - //## JSON map-state data ###################### | |
312 | - tableWriter.AddAttribute(HtmlTextWriterAttribute.Type, "text/javascript"); | |
313 | - tableWriter.RenderBeginTag(HtmlTextWriterTag.Script); | |
314 | - | |
315 | - tableWriter.Write("var available_images = ["); | |
316 | - | |
317 | - foreach (var shard in this.chunkTopMetadata) | |
318 | - { | |
319 | - tableWriter.Write("{{X:{0},Y:{1} }}, ", shard.Location.X, shard.Location.Y); | |
320 | - } | |
321 | - | |
322 | - tableWriter.Write(" ];\n"); | |
323 | - | |
324 | - tableWriter.RenderEndTag(); | |
325 | - | |
326 | 313 | tableWriter.RenderEndTag(); |
327 | 314 | |
328 | 315 | tableWriter.RenderBeginTag(HtmlTextWriterTag.Body); |
@@ -507,57 +494,58 @@ namespace Automap | ||
507 | 494 | StreamWriter jsonWriter = new StreamWriter(jsonFilename, false, Encoding.UTF8); |
508 | 495 | using (jsonWriter) |
509 | 496 | { |
510 | - jsonWriter.WriteLine("var worldSeedNum = {0};", ClientAPI.World.Seed); | |
511 | - jsonWriter.WriteLine("var genTime = new Date('{0}');", DateTimeOffset.UtcNow.ToString("O")); | |
512 | - jsonWriter.WriteLine("var startCoords = {{X:{0},Y:{1}}};", startChunkColumn.X, startChunkColumn.Y); | |
513 | - jsonWriter.WriteLine("var chunkSize = {0};", chunkSize); | |
514 | - jsonWriter.WriteLine("var northMostChunk ={0};", chunkTopMetadata.North_mostChunk); | |
515 | - jsonWriter.WriteLine("var southMostChunk ={0};", chunkTopMetadata.South_mostChunk); | |
516 | - jsonWriter.WriteLine("var eastMostChunk ={0};", chunkTopMetadata.East_mostChunk); | |
517 | - jsonWriter.WriteLine("var westMostChunk ={0};", chunkTopMetadata.West_mostChunk); | |
497 | + jsonWriter.Write("ViewFrame.chunks={};"); | |
498 | + jsonWriter.Write("ViewFrame.chunks.worldSeedNum={0};", ClientAPI.World.Seed); | |
499 | + jsonWriter.Write("ViewFrame.chunks.genTime=new Date('{0}');", DateTimeOffset.UtcNow.ToString("O")); | |
500 | + jsonWriter.Write("ViewFrame.chunks.startCoords=[{0},{1}];", startChunkColumn.X, startChunkColumn.Y); | |
501 | + jsonWriter.Write("ViewFrame.chunks.chunkSize={0};", chunkSize); | |
502 | + jsonWriter.Write("ViewFrame.chunks.northMostChunk={0};", chunkTopMetadata.North_mostChunk); | |
503 | + jsonWriter.Write("ViewFrame.chunks.southMostChunk={0};", chunkTopMetadata.South_mostChunk); | |
504 | + jsonWriter.Write("ViewFrame.chunks.eastMostChunk={0};", chunkTopMetadata.East_mostChunk); | |
505 | + jsonWriter.Write("ViewFrame.chunks.westMostChunk={0};", chunkTopMetadata.West_mostChunk); | |
518 | 506 | //MAP object format - [key, value]: key is "x_y" |
519 | - jsonWriter.Write("let shardsMetadata = new Map(["); | |
507 | + jsonWriter.Write("ViewFrame.chunks.chunkMetadata=new Map(["); | |
520 | 508 | foreach (var shard in chunkTopMetadata) |
521 | 509 | { |
522 | 510 | jsonWriter.Write("['{0}_{1}',", shard.Location.X, shard.Location.Y); |
523 | 511 | jsonWriter.Write("{"); |
524 | - jsonWriter.Write("ChunkAge: '{0}',", shard.ChunkAge);//World age - relative? or last edit ?? | |
525 | - jsonWriter.Write("Temperature: {0},", shard.Temperature.ToString("F1")); | |
526 | - jsonWriter.Write("YMax: {0},", shard.YMax); | |
527 | - jsonWriter.Write("Fertility: {0},", shard.Fertility.ToString("F1")); | |
528 | - jsonWriter.Write("ForestDensity: {0},", shard.ForestDensity.ToString("F1")); | |
529 | - jsonWriter.Write("Rainfall: {0},", shard.Rainfall.ToString("F1")); | |
530 | - jsonWriter.Write("ShrubDensity: {0},", shard.ShrubDensity.ToString("F1")); | |
531 | - jsonWriter.Write("AirBlocks: {0},", shard.AirBlocks); | |
532 | - jsonWriter.Write("NonAirBlocks: {0},", shard.NonAirBlocks); | |
512 | + jsonWriter.Write("chunkAge:'{0}',", shard.ChunkAge.ToString("g"));//World age - relative? or last edit ?? | |
513 | + jsonWriter.Write("temp:{0},", shard.Temperature.ToString("F1")); | |
514 | + jsonWriter.Write("YMax:{0},", shard.YMax); | |
515 | + jsonWriter.Write("fert:{0},", shard.Fertility.ToString("F1")); | |
516 | + jsonWriter.Write("forestDens:{0},", shard.ForestDensity.ToString("F1")); | |
517 | + jsonWriter.Write("rain:{0},", shard.Rainfall.ToString("F1")); | |
518 | + jsonWriter.Write("shrubDens:{0},", shard.ShrubDensity.ToString("F1")); | |
519 | + jsonWriter.Write("airBlocks:{0},", shard.AirBlocks); | |
520 | + jsonWriter.Write("nonAirBlocks:{0},", shard.NonAirBlocks); | |
533 | 521 | //TODO: Heightmap |
534 | 522 | //TODO: Rock-ratio |
535 | 523 | jsonWriter.Write("}],"); |
536 | 524 | } |
537 | - jsonWriter.Write("]);\n\n"); | |
525 | + jsonWriter.Write("]);"); | |
538 | 526 | |
539 | 527 | |
540 | - jsonWriter.Write("let pointsOfInterest = new Map(["); | |
528 | + jsonWriter.Write("ViewFrame.chunks.pointsOfInterest = new Map(["); | |
541 | 529 | foreach (var poi in POIs) |
542 | 530 | { |
543 | - jsonWriter.Write("['{0}_{1}',", poi.Location.X, poi.Location.Y); | |
531 | + jsonWriter.Write("['{0}_{1}',", poi.Location.X, poi.Location.Z); | |
544 | 532 | jsonWriter.Write("{"); |
545 | - jsonWriter.Write("notes: '{0}',", poi.Notes.Replace("'", " ")); | |
546 | - jsonWriter.Write("timestamp : new Date('{0}'),", poi.Timestamp.ToString("O")); | |
547 | - jsonWriter.Write("chunkPos:'{0}_{1}',", (poi.Location.X / chunkSize), (poi.Location.Y / chunkSize)); | |
533 | + jsonWriter.Write("notes:'{0}',", poi.Notes.Replace("'", "\'").Replace("\n","\\n")); | |
534 | + jsonWriter.Write("time:new Date('{0}'),", poi.Timestamp.ToString("O")); | |
535 | + jsonWriter.Write("chunkPos:'{0}_{1}',", (poi.Location.X / chunkSize), (poi.Location.Z / chunkSize)); | |
548 | 536 | jsonWriter.Write("}],"); |
549 | 537 | } |
550 | 538 | |
551 | 539 | foreach (var poi in EOIs.PointsList) |
552 | 540 | { |
553 | - jsonWriter.Write("['{0}_{1}',", poi.Location.X, poi.Location.Y); | |
541 | + jsonWriter.Write("['{0}_{1}',", poi.Location.X, poi.Location.Z); | |
554 | 542 | jsonWriter.Write("{"); |
555 | - jsonWriter.Write("notes: '{0}',", poi.Notes.Replace("'", " ")); | |
556 | - jsonWriter.Write("timestamp : new Date('{0}'),", poi.Timestamp.ToString("O")); | |
557 | - jsonWriter.Write("chunkPos:'{0}_{1}',", (poi.Location.X / chunkSize), (poi.Location.Y / chunkSize)); | |
543 | + jsonWriter.Write("notes:'{0}',", poi.Notes.Replace("'", "\'")); | |
544 | + jsonWriter.Write("time:new Date('{0}'),", poi.Timestamp.ToString("O")); | |
545 | + jsonWriter.Write("chunkPos:'{0}_{1}',", (poi.Location.X / chunkSize), (poi.Location.Z / chunkSize)); | |
558 | 546 | jsonWriter.Write("}],"); |
559 | 547 | } |
560 | - jsonWriter.Write("]);\n\n"); | |
548 | + jsonWriter.Write("]);"); | |
561 | 549 | |
562 | 550 | jsonWriter.Flush(); |
563 | 551 | } |