Пример #1
0
        private static void Open(HorizonSave file)
        {
            bool sized = file.ValidateSizes();

            if (!sized)
            {
                const string sizeBad = "Save file sizes appear to be incorrect.";
                if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, sizeBad, "Continue?") != DialogResult.Yes)
                {
                    return;
                }
            }

            new Editor(file).Show();
        }
Пример #2
0
        private static void Open(HorizonSave file)
        {
            bool sized = file.ValidateSizes();

            if (!sized)
            {
                var prompt = WinFormsUtil.Prompt(MessageBoxButtons.YesNo, MessageStrings.MsgSaveDataSizeMismatch, MessageStrings.MsgAskContinue);
                if (prompt != DialogResult.Yes)
                {
                    return;
                }
            }

            new Editor(file).Show();
        }
Пример #3
0
        public bool OpenSaveFromFolder(string saveDirectory, out MainSave mainSave)
        {
            mainSave = null;
            var result            = false;
            var mainDatPath       = Path.Combine(saveDirectory, MainDat);
            var mainHeaderDatPath = Path.Combine(saveDirectory, MainHeaderDat);

            if (!File.Exists(mainDatPath))
            {
                MessageBox.Show($"{mainDatPath} doesn't exist!", "Failed to open save file", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (!File.Exists(mainHeaderDatPath))
            {
                MessageBox.Show($"{mainHeaderDatPath} doesn't exist!", "Failed to open save file header", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                try
                {
                    var mainSaveFile = new HorizonSave(saveDirectory);
                    if (mainSaveFile.ValidateSizes())
                    {
                        result   = true;
                        mainSave = mainSaveFile.Main;
                    }
                    else
                    {
                        MessageBox.Show("Save file sizes appear to be incorrect.", "Version doesn't match", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                catch (Exception e)
                {
                    Logger.Error(e);
                    MessageBox.Show(e.Message, "Failed to load save file", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            return(result);
        }