using System.Drawing.Imaging;
using System.IO;
using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
using System.Threading;
using System.Web.UI;
chunkTopMetadata = new ColumnsMetadata(startChunkColumn);
Logger.Notification("AUTOMAP Start {0}", startChunkColumn);
+ Reload_Metadata( );
ClientAPI.Event.ChunkDirty += ChunkAChanging;
}
if (updatedChunks > 0) {
+ //TODO: ONLY update if chunk bounds have changed!
lastUpdate = updatedChunks;
GenerateMapHTML( );
updatedChunks = 0;
// <span class="tooltiptext">Tooltip text
tableWriter.AddAttribute(HtmlTextWriterAttribute.Class, "tooltiptext");
tableWriter.RenderBeginTag(HtmlTextWriterTag.Span);
- tableWriter.WriteEncodedText($"{meta.Location.PrettyCoords(ClientAPI)} "+
- $" Max-Height: {meta.YMax}, Temp: {meta.Temperature.ToString("F1")}"
- );
- tableWriter.RenderEndTag( );//</span>
-
+ StringBuilder tooltipText = new StringBuilder( );
+ tooltipText.Append($"{meta.Location.PrettyCoords(ClientAPI)} ");
+ tooltipText.Append($" Max-Height: {meta.YMax}, Temp: {meta.Temperature.ToString("F1")} " );
+ tooltipText.Append($" Rainfall: {meta.Rainfall.ToString("F1")}, ");
+ tooltipText.Append($" Shrubs: {meta.ShrubDensity.ToString("F1")}, ");
+ tooltipText.Append($" Forest: {meta.ForestDensity.ToString("F1")}, ");
+ tooltipText.Append($" Fertility: {meta.Fertility.ToString("F1")}, ");
+ if (meta.RockRatio != null) {
+ foreach (KeyValuePair<int, uint> blockID in meta.RockRatio) {
+ var block = ClientAPI.World.GetBlock(blockID.Key);
+ tooltipText.AppendFormat(" {0} × {1},\t", block.Code.GetName( ), meta.RockRatio[blockID.Key]);
+ }
+ }
+
+ tableWriter.WriteEncodedText(tooltipText.ToString() );
+
+ tableWriter.RenderEndTag( );//</span>
+
tableWriter.RenderEndTag( );//</div> --tooltip enclosure
}
mapChunk.YMax,
mostActiveCol.Key.Y * ClientAPI.World.BlockAccessor.ChunkSize);
- var climate = ClientAPI.World.BlockAccessor.GetClimateAt(equivBP);
+ var climate = ClientAPI.World.BlockAccessor.GetClimateAt(equivBP);
data.Temperature = climate.Temperature;
+ data.Fertility = climate.Fertility;
+ data.ForestDensity = climate.ForestDensity;
+ data.Rainfall = climate.Rainfall;
+ data.ShrubDensity = climate.ShrubDensity;
+
data.YMax = mapChunk.YMax;
+
+ /* Only present on server....
+ if (mapChunk.TopRockIdMap != null) {
+ foreach (var topRockId in mapChunk.TopRockIdMap) {
+
+ if (data.RockRatio.ContainsKey(topRockId)) { data.RockRatio[topRockId]++; }
+ else { data.RockRatio.Add(topRockId, 1); }
+ }
+ }*/
return data;
}
+
+ /// <summary>
+ /// Reload chunk bounds from chunk shards
+ /// </summary>
+ /// <returns>The metadata.</returns>
+ private void Reload_Metadata( )
+ {
+ string chunkFile_filter = @"*_*.png";
+ Regex chunkShardRegex = new Regex(@"(?<X>[\d]+)_(?<Z>[\d]+).png", RegexOptions.Singleline);
+
+ var worldmapDir = new DirectoryInfo(path);
+
+ if (worldmapDir.Exists) {
+
+ var files = worldmapDir.GetFiles(chunkFile_filter);
+
+ if (files.Length > 0) {
+ #if DEBUG
+ Logger.VerboseDebug("{0} Existing world chunk shards", files.Length);
+ #endif
+
+ foreach (var shardFile in files) {
+ var result = chunkShardRegex.Match(shardFile.Name);
+ if (result.Success) {
+ int X_chunk_pos = int.Parse(result.Groups["X"].Value );
+ int Z_chunk_pos = int.Parse(result.Groups["Z"].Value );
+ //TODO: METADATA from shard
+ chunkTopMetadata.Add(new ColumnMeta(new Vec2i(X_chunk_pos, Z_chunk_pos)));
+ }
+ }
+
+ }
+ }
+ else {
+ #if DEBUG
+ Logger.VerboseDebug("Could not open world map directory");
+ #endif
+ }
+
+
+
+ }
}
}
\ No newline at end of file