Changeset 230 for binary-improvements/MapRendering
- Timestamp:
- Apr 18, 2015, 4:27:57 PM (10 years ago)
- Location:
- binary-improvements/MapRendering
- Files:
-
- 16 added
- 1 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/MapRendering/API.cs
r228 r230 3 3 namespace MapRendering 4 4 { 5 public class API : AllocsFixes.ModAPI { 6 public override string ModName () { 7 return "AllocsMapRendering"; 5 public class API : ModApiAbstract { 6 7 public override void GameAwake () { 8 new AllocsFixes.NetConnections.Servers.Web.Web (); 8 9 } 9 10 10 public override string ModVersion () {11 return "1.0 for A11.2";11 public override void CalcChunkColorsDone (Chunk _chunk) { 12 AllocsFixes.MapRendering.MapRendering.RenderSingleChunk (_chunk); 12 13 } 13 14 14 public override void CalcMapColors (Chunk _chunk) {15 AllocsFixes.MapRendering.MapRendering.RenderSingleChunk (_chunk);16 }17 15 } 18 16 } -
binary-improvements/MapRendering/Commands/EnableRendering.cs
r224 r230 4 4 namespace AllocsFixes.CustomCommands 5 5 { 6 public class EnableRendering : ConsoleC ommand6 public class EnableRendering : ConsoleCmdAbstract 7 7 { 8 public EnableRendering (ConsoleSdtd cons) : base(cons) 9 { 10 } 11 12 public override string Description () 8 public override string GetDescription () 13 9 { 14 10 return "enable/disable live map rendering"; 15 11 } 16 12 17 public override string[] Names ()13 public override string[] GetCommands () 18 14 { 19 return new string[] { "enablerendering" , string.Empty};15 return new string[] { "enablerendering" }; 20 16 } 21 17 22 public override void Run (string[] _params)18 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) 23 19 { 24 20 try { 25 if (_params. Length!= 1) {26 m_Console.SendResult ("Current state: " + AllocsFixes.MapRendering.MapRendering.renderingEnabled);21 if (_params.Count != 1) { 22 SdtdConsole.Instance.Output ("Current state: " + AllocsFixes.MapRendering.MapRendering.renderingEnabled); 27 23 return; 28 24 } 29 25 30 26 AllocsFixes.MapRendering.MapRendering.renderingEnabled = _params[0].Equals("1"); 31 m_Console.SendResult ("Set live map rendering to " + _params [0].Equals ("1"));27 SdtdConsole.Instance.Output ("Set live map rendering to " + _params [0].Equals ("1")); 32 28 } catch (Exception e) { 33 29 Log.Out ("Error in EnableRendering.Run: " + e); -
binary-improvements/MapRendering/Commands/RenderMap.cs
r224 r230 6 6 namespace AllocsFixes.CustomCommands 7 7 { 8 public class RenderMap : ConsoleC ommand8 public class RenderMap : ConsoleCmdAbstract 9 9 { 10 public RenderMap (ConsoleSdtd cons) : base(cons) 11 { 12 } 13 14 public override string Description () 10 public override string GetDescription () 15 11 { 16 12 return "render the current map to a file"; 17 13 } 18 14 19 public override string[] Names ()15 public override string[] GetCommands () 20 16 { 21 return new string[] { "rendermap" , "rm"};17 return new string[] { "rendermap" }; 22 18 } 23 19 24 public override void Run (string[] _params)20 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) 25 21 { 26 22 try { 27 23 AllocsFixes.MapRendering.MapRendering.Instance.RenderFullMap (); 28 24 29 m_Console.SendResult ("Render map done");25 SdtdConsole.Instance.Output ("Render map done"); 30 26 } catch (Exception e) { 31 27 Log.Out ("Error in RenderMap.Run: " + e); -
binary-improvements/MapRendering/MapRendering/MapRenderBlockBuffer.cs
r224 r230 53 53 } 54 54 55 public void SetPart (Vector2i offset, int partSize, Color[] pixels) 56 { 55 public void SetPart (Vector2i offset, int partSize, Color[] pixels) { 56 if (offset.x + partSize > blockMap.width || offset.y + partSize > blockMap.height) { 57 Log.Error (string.Format ("MapBlockBuffer[{0}].SetPart ({1}, {2}, {3}) has blockMap.size ({4}/{5})", zoomLevel, offset, partSize, pixels.Length, blockMap.width, blockMap.height)); 58 return; 59 } 57 60 blockMap.SetPixels (offset.x, offset.y, partSize, partSize, pixels); 58 61 } … … 71 74 { 72 75 byte[] array = cache.LoadTile (zoomLevel, _fileName); 73 if (array != null) { 74 blockMap.LoadImage (array); 75 } else { 76 //try { 77 //byte[] array = File.ReadAllBytes (_fileName); 78 //blockMap.LoadImage (array); 79 //} catch (Exception) { 76 if (array == null || !blockMap.LoadImage (array)) { 77 if (blockMap.height != Constants.MAP_BLOCK_SIZE || blockMap.width != Constants.MAP_BLOCK_SIZE) { 78 blockMap.Resize (Constants.MAP_BLOCK_SIZE, Constants.MAP_BLOCK_SIZE); 79 } 80 80 for (int x = 0; x < Constants.MAP_BLOCK_SIZE; x++) { 81 81 for (int y = 0; y < Constants.MAP_BLOCK_SIZE; y++) { … … 86 86 } 87 87 88 private void saveTextureToFile (string _fileName) 89 { 88 private void saveTextureToFile (string _fileName) { 90 89 byte[] array = blockMap.EncodeToPNG (); 91 90 cache.SaveTile (zoomLevel, array); 92 // try {93 // byte[] array = blockMap.EncodeToPNG ();94 // File.WriteAllBytes (_fileName, array);95 // } catch (Exception e) {96 // Log.Out ("Exception in MapRenderBlockBuffer.saveTextureToFile(): " + e);97 // }98 91 } 99 92 -
binary-improvements/MapRendering/MapRendering/MapRendering.cs
r224 r230 210 210 //Log.Out ("Dirty: " + v + " render: true"); 211 211 chunksDone.Add (v); 212 if (dirtyChunks [v].Length != Constants.MAP_CHUNK_SIZE * Constants.MAP_CHUNK_SIZE) { 213 Log.Error (string.Format ("Rendering chunk has incorrect data size of {0} instead of {1}", dirtyChunks [v].Length, Constants.MAP_CHUNK_SIZE * Constants.MAP_CHUNK_SIZE)); 214 } 212 215 zoomLevelBuffers [Constants.ZOOMLEVELS - 1].SetPart (v_blockOffset, Constants.MAP_CHUNK_SIZE, dirtyChunks [v]); 213 216 } else {
Note:
See TracChangeset
for help on using the changeset viewer.