Exemple #1
0
        private bool saveToFile()
        {
            var      romFname = OpenFile.FileName;
            LevelRec lr       = getLevelRecForGameType();

            //TODO: return free space checking

            /*int addrBase = lr.objectsBeginAddr;
             * int objCount = lr.objCount;
             * if (activeObjectList.objects.Count > objCount)
             * {
             *  MessageBox.Show(String.Format("Too many objects in level ({0}). Maximum: {1}", activeObjectList.objects.Count, lr.objCount));
             *  return false;
             * }*/
            try
            {
                ConfigScript.setObjects(curActiveLayout, objectLists);
            }
            catch (IndexOutOfRangeException ex)
            {
                MessageBox.Show(ex.Message, "Save error");
                return(false);
            }

            dirty           = !Globals.flushToFile();
            bttSave.Enabled = false;

            return(!dirty);
        }
Exemple #2
0
        private bool saveToJsonFile(string fname)
        {
            LevelRec lr = getLevelRecForGameType();

            try
            {
                using (TextWriter f = new StreamWriter(fname))
                {
                    for (int i = 0; i < objectLists.Count; i++)
                    {
                        var    obj  = objectLists[i];
                        string json = JsonConvert.SerializeObject(obj);
                        f.WriteLine(json);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Save error");
                return(false);
            }

            return(true);
        }