diff --git a/Assets/Raindrop/UI/map/MapDataManager.cs b/Assets/Raindrop/UI/map/MapDataManager.cs
index eb92b17..54bf9e3 100644
--- a/Assets/Raindrop/UI/map/MapDataManager.cs
+++ b/Assets/Raindrop/UI/map/MapDataManager.cs
@@ -5,7 +5,7 @@ using System.Collections.Generic;
namespace Raindrop.Map
{
///
- /// API to retrieve, delete, modify MapTiles in the scene
+ /// API to retrieve, delete, modify, create MapTiles in the scene
///
public class MapDataManager
{
@@ -34,7 +34,7 @@ namespace Raindrop.Map
}
///
- /// gets a maptile
+ /// gets a maptile, if it is present
///
/// the region handle of the tile to get ; gridCoords * 256 and pack X&Y together.
/// Tile
@@ -52,6 +52,18 @@ namespace Raindrop.Map
return tile;
}
}
+
+ ///
+ /// creates a blank maptile at a grid handle.
+ ///
+ /// the region handle of the tile to get ; gridCoords * 256 and pack X&Y together.
+ /// Tile
+ public MapTile setEmptyTile(ulong handle)
+ {
+ MapTile tile = pool.acquireTile();
+ sceneTiles.Add(handle, tile);
+ return tile;
+ }
///
/// Returns a Region to the pool. -- EG not visible anymore
diff --git a/Assets/Raindrop/UI/map/MapLogic.cs b/Assets/Raindrop/UI/map/MapLogic.cs
index 19a0feb..c015fca 100644
--- a/Assets/Raindrop/UI/map/MapLogic.cs
+++ b/Assets/Raindrop/UI/map/MapLogic.cs
@@ -81,9 +81,9 @@ namespace Raindrop.Map
//}
//catch (Exception)
//{
- // uint x, y;
- // Utils.LongToUInts(handle, out x, out y);
- // throw new Exception("no tile found at " + x + " " + y);
+ uint x, y;
+ Utils.LongToUInts(handle, out x, out y);
+ Debug.LogError("no tile found at " + x + " " + y);
//}
return res;
}
@@ -135,11 +135,11 @@ namespace Raindrop.Map
Debug.Log("1");
//decode http response data into texture2d
//MapTile tex = mapData.getTile();
- MapTile tex = GetMapTile(handle,1 ); //Tile is a empty tile right now -- we write to it soon.
+ MapTile tex = mapDataMgr.setEmptyTile(handle); //Tile is a empty tile right now -- we write to it soon.
Debug.Log("2");
//run jpeg decoding on the main thread, for now.
- mainThreadInstance.Enqueue(TestAsync(tex, responseData));
+ mainThreadInstance.Enqueue(DecodeDataToTexAsync(tex, responseData));
Debug.Log("3");
//set the tile into tile manager
@@ -166,20 +166,20 @@ namespace Raindrop.Map
}
}
- private IEnumerator TestAsync(MapTile tex, byte[] responseData)
+ private IEnumerator DecodeDataToTexAsync(MapTile tex, byte[] responseData)
{
- //try
- //{
- // bool success = tex.texture.LoadImage(responseData);
+ try
+ {
+ Texture2D _tex = tex.getTex();
+ bool success = _tex.LoadImage(responseData);
- //}
- //catch (Exception w)
- //{
- // Debug.Log("decode the texture failed : " + w.Message);
- //}
- //Debug.Log("completed mainthread async texture Decode.");
+ }
+ catch (Exception w)
+ {
+ Debug.Log("decode the texture failed : " + w.Message);
+ }
+ Debug.Log("completed mainthread async texture Decode.");
- Debug.Log("5");
yield return null;
}