Example #1
0
        public static bool TryRename(ModList list, string oldName, bool force = false)
        {
            if (!File.Exists(FilePath(oldName)))
            {
                Log.Warning($"List not saved: {oldName} ({FilePath(oldName)})");
                return(false);
            }
            if (File.Exists(FilePath(list.Name)) && !force)
            {
                Log.Warning($"File exists: {list.Name} ({FilePath( list )})");
                return(false);
            }

            try
            {
                File.Delete(FilePath(oldName));
                var success = list.Save();
                if (success)
                {
                    Messages.Message(I18n.ModListRenamed(oldName, list.Name), MessageTypeDefOf.TaskCompletion, false);
                }
                return(success);
            }
            catch (Exception e)
            {
                Log.Error(e.Message);
                return(false);
            }
        }
Example #2
0
        public static bool TryCreate(ModList list, bool force = false)
        {
            var success = list.Save(force);

            if (success)
            {
                Messages.Message(I18n.ModListCreated(list.Name), MessageTypeDefOf.TaskCompletion, false);
            }
            return(success);
        }
        public static void TryRename(ModList list, string oldName, Action failureCallback, Action successCallback)
        {
            if (!File.Exists(FilePath(oldName)))
            {
                Log.Warning($"List not saved: {oldName} ({FilePath(oldName)})");
                failureCallback?.Invoke();
                return;
            }

            try
            {
                File.Delete(FilePath(oldName));
                list.Save(false, failureCallback, successCallback);
            }
            catch (Exception e)
            {
                Log.Error(e.Message);
                failureCallback?.Invoke();
            }
        }
 public static void TryCreate(ModList list, Action failureCallback, Action successCallback)
 {
     list.Save(false, failureCallback, successCallback);
 }