Exemple #1
0
        void SaveMap(string path)
        {
            bool classic = path.EndsWith(".cw");

            try {
                if (File.Exists(path))
                {
                    File.Delete(path);
                }
                using (FileStream fs = new FileStream(path, FileMode.CreateNew, FileAccess.Write)) {
                    IMapFormatExporter exporter = null;
                    if (classic)
                    {
                        exporter = new MapCwExporter();
                    }
                    else
                    {
                        exporter = new MapSchematicExporter();
                    }
                    exporter.Save(fs, game);
                }
            } catch (Exception ex) {
                ErrorHandler.LogError("saving map", ex);
                MakeDescWidget("&cError while trying to save map");
                return;
            }
            game.Chat.Add("&eSaved map to: " + Path.GetFileName(path));
            game.SetNewScreen(new PauseScreen(game));
        }
Exemple #2
0
        void SaveMap(string path)
        {
            bool cw = path.EndsWith(".cw");

            try {
                using (Stream fs = Platform.FileCreate(path)) {
                    IMapFormatExporter exporter = null;
                    if (cw)
                    {
                        exporter = new MapCwExporter();
                    }
                    else
                    {
                        exporter = new MapSchematicExporter();
                    }
                    exporter.Save(fs, game);
                }
            } catch (Exception ex) {
                ErrorHandler.LogError("saving map", ex);
                MakeDescWidget("&cError while trying to save map");
                return;
            }

            game.Chat.Add("&eSaved map to: " + path);
            game.Gui.SetNewScreen(new PauseScreen(game));
        }
        public override void Render(double delta)
        {
            base.Render(delta);
            int cX = game.Width / 2, cY = game.Height / 2;

            game.Graphics.Draw2DQuad(cX - 250, cY + 90, 500, 2, grey);
            if (textPath == null)
            {
                return;
            }

            bool cw = textPath.EndsWith(".cw");

            try {
                using (Stream fs = Platform.FileCreate(textPath)) {
                    IMapFormatExporter exporter = null;
                    if (cw)
                    {
                        exporter = new MapCwExporter();
                    }
                    else
                    {
                        exporter = new MapSchematicExporter();
                    }
                    exporter.Save(fs, game);
                }
            } catch (Exception ex) {
                ErrorHandler.LogError("saving map", ex);
                MakeDescWidget("&cError while trying to save map");
                return;
            }

            game.Chat.Add("&eSaved map to: " + textPath);
            game.Gui.SetNewScreen(new PauseScreen(game));
            textPath = null;
        }