Example #1
0
        private bool SaveLevelInDesigner()
        {
            bool returnMe         = false;
            FileSaveNameDialog sn = new FileSaveNameDialog();

            sn.SetName(Designer.GetName());

            while (true)
            {
                if (sn.ShowDialog() == DialogResult.OK) //if file doesn't exist or it's ok to overwrite
                {
                    string toFileName = sn.GetName();

                    if (toFileName.Length > 0 &&
                        (!Filer.LevelExists(toFileName) ||
                         MessageBox.Show("Overwite Level?",
                                         "Level file already exists.",
                                         MessageBoxButtons.YesNo) == DialogResult.Yes))
                    {
                        Filer.Save(toFileName, Designer);
                        returnMe = true;
                        MessageBox.Show("Level " + sn.GetName() + " saved successfully.");
                        break;
                    }
                }
                else
                {
                    break;
                }
            }
            sn.Dispose();
            return(returnMe);
        }
Example #2
0
        protected string GetPlayerName()
        {
            FileSaveNameDialog sn = new FileSaveNameDialog();

            sn.SetLabel("Your name:");
            sn.ShowDialog();
            return(sn.GetName());
        }
Example #3
0
        public void SaveGameState()
        {
            FileSaveNameDialog sn = new FileSaveNameDialog();

            sn.SetLabel("Name for state:");

            if (sn.ShowDialog() == DialogResult.OK && sn.GetName().Length > 0)
            {
                string file  = Filer.Load(Game.GetName());
                string name  = sn.GetName();
                string state = Game.SaveState();
                if (FM.StateExists(file, name) &&
                    MessageBox.Show("State Exists", "OK to overwrite?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    Filer.ReplaceFile(name, FM.OverwriteSavedState(file, name, state));
                }
                else if (!FM.StateExists(file, name))
                {
                    Filer.AppendState(file, name, state);
                }
            }
        }