• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqt誰得windowscocoapythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

Automap (client) [VS plugin mod]


Commit MetaInfo

Revision00c120f5a080322ccfdc83687accb00ec2b8bffb (tree)
Time2019-12-24 07:42:02
Authormelchior <melchior@user...>
Commitermelchior

Log Message

re-load partial map metadata

Change Summary

Incremental Difference

--- a/Automap/Automap_Internals.cs
+++ b/Automap/Automap_Internals.cs
@@ -6,6 +6,8 @@ using System.Drawing;
66 using System.Drawing.Imaging;
77 using System.IO;
88 using System.Linq;
9+using System.Text;
10+using System.Text.RegularExpressions;
911 using System.Threading;
1012
1113 using System.Web.UI;
@@ -52,6 +54,7 @@ namespace Automap
5254 chunkTopMetadata = new ColumnsMetadata(startChunkColumn);
5355
5456 Logger.Notification("AUTOMAP Start {0}", startChunkColumn);
57+ Reload_Metadata( );
5558
5659 ClientAPI.Event.ChunkDirty += ChunkAChanging;
5760
@@ -141,6 +144,7 @@ namespace Automap
141144 }
142145
143146 if (updatedChunks > 0) {
147+ //TODO: ONLY update if chunk bounds have changed!
144148 lastUpdate = updatedChunks;
145149 GenerateMapHTML( );
146150 updatedChunks = 0;
@@ -405,13 +409,26 @@ namespace Automap
405409 // <span class="tooltiptext">Tooltip text
406410 tableWriter.AddAttribute(HtmlTextWriterAttribute.Class, "tooltiptext");
407411 tableWriter.RenderBeginTag(HtmlTextWriterTag.Span);
408- tableWriter.WriteEncodedText($"{meta.Location.PrettyCoords(ClientAPI)} "+
409- $" Max-Height: {meta.YMax}, Temp: {meta.Temperature.ToString("F1")}"
410- );
411- tableWriter.RenderEndTag( );//</span>
412412
413-
413+ StringBuilder tooltipText = new StringBuilder( );
414+ tooltipText.Append($"{meta.Location.PrettyCoords(ClientAPI)} ");
415+ tooltipText.Append($" Max-Height: {meta.YMax}, Temp: {meta.Temperature.ToString("F1")} " );
416+ tooltipText.Append($" Rainfall: {meta.Rainfall.ToString("F1")}, ");
417+ tooltipText.Append($" Shrubs: {meta.ShrubDensity.ToString("F1")}, ");
418+ tooltipText.Append($" Forest: {meta.ForestDensity.ToString("F1")}, ");
419+ tooltipText.Append($" Fertility: {meta.Fertility.ToString("F1")}, ");
414420
421+ if (meta.RockRatio != null) {
422+ foreach (KeyValuePair<int, uint> blockID in meta.RockRatio) {
423+ var block = ClientAPI.World.GetBlock(blockID.Key);
424+ tooltipText.AppendFormat(" {0} × {1},\t", block.Code.GetName( ), meta.RockRatio[blockID.Key]);
425+ }
426+ }
427+
428+ tableWriter.WriteEncodedText(tooltipText.ToString() );
429+
430+ tableWriter.RenderEndTag( );//</span>
431+
415432
416433 tableWriter.RenderEndTag( );//</div> --tooltip enclosure
417434 }
@@ -488,14 +505,70 @@ namespace Automap
488505 mapChunk.YMax,
489506 mostActiveCol.Key.Y * ClientAPI.World.BlockAccessor.ChunkSize);
490507
491- var climate = ClientAPI.World.BlockAccessor.GetClimateAt(equivBP);
508+ var climate = ClientAPI.World.BlockAccessor.GetClimateAt(equivBP);
492509 data.Temperature = climate.Temperature;
510+ data.Fertility = climate.Fertility;
511+ data.ForestDensity = climate.ForestDensity;
512+ data.Rainfall = climate.Rainfall;
513+ data.ShrubDensity = climate.ShrubDensity;
514+
493515 data.YMax = mapChunk.YMax;
494516
517+
518+ /* Only present on server....
519+ if (mapChunk.TopRockIdMap != null) {
520+ foreach (var topRockId in mapChunk.TopRockIdMap) {
521+
522+ if (data.RockRatio.ContainsKey(topRockId)) { data.RockRatio[topRockId]++; }
523+ else { data.RockRatio.Add(topRockId, 1); }
524+ }
525+ }*/
495526
496527
497528 return data;
498529 }
530+
531+ /// <summary>
532+ /// Reload chunk bounds from chunk shards
533+ /// </summary>
534+ /// <returns>The metadata.</returns>
535+ private void Reload_Metadata( )
536+ {
537+ string chunkFile_filter = @"*_*.png";
538+ Regex chunkShardRegex = new Regex(@"(?<X>[\d]+)_(?<Z>[\d]+).png", RegexOptions.Singleline);
539+
540+ var worldmapDir = new DirectoryInfo(path);
541+
542+ if (worldmapDir.Exists) {
543+
544+ var files = worldmapDir.GetFiles(chunkFile_filter);
545+
546+ if (files.Length > 0) {
547+ #if DEBUG
548+ Logger.VerboseDebug("{0} Existing world chunk shards", files.Length);
549+ #endif
550+
551+ foreach (var shardFile in files) {
552+ var result = chunkShardRegex.Match(shardFile.Name);
553+ if (result.Success) {
554+ int X_chunk_pos = int.Parse(result.Groups["X"].Value );
555+ int Z_chunk_pos = int.Parse(result.Groups["Z"].Value );
556+ //TODO: METADATA from shard
557+ chunkTopMetadata.Add(new ColumnMeta(new Vec2i(X_chunk_pos, Z_chunk_pos)));
558+ }
559+ }
560+
561+ }
562+ }
563+ else {
564+ #if DEBUG
565+ Logger.VerboseDebug("Could not open world map directory");
566+ #endif
567+ }
568+
569+
570+
571+ }
499572 }
500573
501574 }
\ No newline at end of file
--- a/Automap/Data/ColumnMeta.cs
+++ b/Automap/Data/ColumnMeta.cs
@@ -12,8 +12,12 @@ namespace Automap
1212 {
1313 public Vec2i Location;
1414 public float Temperature;// Temperature
15- public int YMax;// Y feature height
15+ public ushort YMax;// Y feature height
1616 public Dictionary<int,uint> RockRatio;//(surface) Geographic region (rock) Ratio. [BlockID * count]
17+ public float Fertility;
18+ public float ForestDensity;
19+ public float Rainfall;
20+ public float ShrubDensity;
1721
1822 public ColumnMeta(Vec2i loc)
1923 {
@@ -21,6 +25,10 @@ namespace Automap
2125 Temperature = 0f;
2226 YMax = 0;
2327 RockRatio = new Dictionary<int, uint>( 10 );
28+ Fertility = 0f;
29+ ForestDensity = 0f;
30+ Rainfall = 0f;
31+ ShrubDensity = 0f;
2432 }
2533 }
2634
--- a/Automap/Data/Designator.cs
+++ b/Automap/Data/Designator.cs
@@ -43,7 +43,7 @@ namespace Automap
4343
4444 public override string ToString( )
4545 {
46- return Pattern.ToShortString() +"-"+ OverwriteColor.Name + "-" + Material ?? "";
46+ return Pattern.ToShortString() +"|"+ OverwriteColor.Name + "|" + Material ?? "";
4747 }
4848 }
4949 }