public void Save(string name, Optional <Image> preview)
 {
     IsSaving = true;
     MapWorker.BuilderMapController.MapHost += (map, isSuccessful, error) =>
     {
         if (isSuccessful)
         {
             var mapMeta = new MapMeta(map, new List <MapMeta.PropInfo>());
             MapMetaManager.Save(mapMeta);
             GUIPopup.EnqueueMessage("Map Generated", 3);
             GUIPopup.EnqueueMessage("Notice: map name can be changed on website," + Environment.NewLine +
                                     "while the SDK side will not get updated until map cache cleared and a re-download has been triggered.", 5);
             Saved = true;
         }
         else
         {
             GUIPopup.EnqueueMessage("Fail to generate Map" + (string.IsNullOrEmpty(error) ? "" : "\n error: " + error), 5);
         }
         IsSaving = false;
     };
     try
     {
         MapWorker.BuilderMapController.Host(name, preview);
     }
     catch (Exception e)
     {
         GUIPopup.EnqueueMessage("Fail to host map: " + e.Message, 5);
         IsSaving = false;
     }
 }
Exemple #2
0
 public static bool Save(MapMeta meta)
 {
     try
     {
         File.WriteAllText(GetPath(meta.Map.ID), JsonUtility.ToJson(meta));
     }
     catch (System.Exception e)
     {
         Debug.LogError(e.Message);
         return(false);
     }
     return(true);
 }
Exemple #3
0
 public static bool Delete(MapMeta meta)
 {
     if (!File.Exists(GetPath(meta.Map.ID)))
     {
         return(false);
     }
     try
     {
         File.Delete(GetPath(meta.Map.ID));
     }
     catch (System.Exception e)
     {
         Debug.LogError(e.Message);
         return(false);
     }
     return(true);
 }
        public static bool Save(MapMeta meta, FileNameType fileNameType = FileNameType.ID)
        {
            try
            {
                switch (fileNameType)
                {
                case FileNameType.ID:
                    File.WriteAllText(GetPath(meta.Map.ID), JsonUtility.ToJson(meta, true));
                    break;

                case FileNameType.Name:
                    File.WriteAllText(GetPath(meta.Map.Name), JsonUtility.ToJson(meta, true));
                    break;
                }
            }
            catch (System.Exception e)
            {
                Debug.LogError(e.Message);
                return(false);
            }
            return(true);
        }
 public void SetData(MapMeta meta)
 {
     MapMeta   = meta;
     text.text = meta.Map.Name;
 }