Пример #1
0
        private void SaveAsHelper(bool saveAs)
        {
            using (SaveFileDialog sfd = new SaveFileDialog())
            {
                sfd.AddExtension    = true;
                sfd.CheckPathExists = true;
                sfd.DefaultExt      = ".bmap";
                sfd.Filter          = "Binary Map|*.bmap";
                sfd.OverwritePrompt = true;

                DialogResult dr = sfd.ShowDialog();
                if (dr == DialogResult.OK)
                {
                    try
                    {
                        if (!m_openMap.Save(sfd.FileName, saveAs))
                        {
                            MessageBox.Show("Error saving file!");
                        }
                        else
                        {
                            m_buffer.UpdateFilePath(sfd.FileName);
                            tslblFileName.Text = sfd.FileName;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }

            RegistryAccess.AddRecentFile(m_openMap.FileName, RegistrySetting.RecentMaps);
            RefreshRecentList(mnuFileRecent, RegistrySetting.RecentMaps);
        }
Пример #2
0
 void HandleMaximization(object sender, EventArgs e)
 {
     if (WindowState == FormWindowState.Maximized)
     {
         RegistryAccess.SetValue(RegistrySetting.WindowMaximized, true);
     }
 }
Пример #3
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog od = new OpenFileDialog();

            od.Title  = "Open tileset file";
            od.Filter = "Tileset files|*.tileset";
            od.ShowDialog();

            Tileset temp = new Tileset();

            temp.LoadFromFile(od.FileName);
            mapViewer1.TileSize = temp.Images.ImageSize.Width;

            if (!temp.CheckAgainst(m_openMap))
            {
                if (MessageBox.Show("Some features of the current map don't work with this tileset.\n Would you like to close the current map?", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    mnuClose_Click(null, null);
                }

                if (m_fileOpen)
                {
                    return;
                }
            }

            tileset = temp;

            RefreshListViewer();
            RegistryAccess.AddRecentFile(tileset.FileName, RegistrySetting.RecentTilesets);
            RefreshRecentList(recentToolStripMenuItem, RegistrySetting.RecentTilesets);
        }
Пример #4
0
        private void RefreshRecentList(ToolStripMenuItem menuItem, RegistrySetting setting)
        {
            string[] fileNames = (string[])RegistryAccess.GetValueOrDefault(setting, new string[] { "" }, Microsoft.Win32.RegistryValueKind.MultiString);

            if (fileNames.Length == 1 && fileNames[0] == "")
            {
                return;
            }

            if (menuItem.HasDropDownItems)
            {
                menuItem.DropDownItems.Clear();
            }

            for (int i = 0; i < fileNames.Length; ++i)
            {
                menuItem.DropDownItems.Add((i + 1) + "  " + RegistryAccess.MakeShorter(fileNames[i]), null, new EventHandler(recentFile_click));
                menuItem.DropDownItems[i].Tag = fileNames[i];
            }

            if (menuItem.HasDropDownItems)
            {
                menuItem.Enabled = true;
            }
            else
            {
                menuItem.Enabled = false;
            }
        }
Пример #5
0
        private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog sd = new SaveFileDialog();

            sd.Title  = "Save tileset file";
            sd.Filter = "Tileset files|*.tileset";
            sd.ShowDialog();

            tileset.SaveToFile(sd.FileName);
            RegistryAccess.AddRecentFile(tileset.FileName, RegistrySetting.RecentTilesets);
            RefreshRecentList(recentToolStripMenuItem, RegistrySetting.RecentTilesets);
        }
Пример #6
0
        void WindowBoundsChanged(object sender, EventArgs e)
        {
            if (size != Size)
            {
                size = Size;
                RegistryAccess.SetValue(RegistrySetting.WindowMaximized, false);
                RegistryAccess.SetValue(RegistrySetting.WindowWidth, ClientSize.Width);
                RegistryAccess.SetValue(RegistrySetting.WindowHeight, ClientSize.Height);
            }

            if (loaded)
            {
                RegistryAccess.SetValue(RegistrySetting.WindowX, Bounds.X);
                RegistryAccess.SetValue(RegistrySetting.WindowY, Bounds.Y);
            }
        }
Пример #7
0
        private void OpenFile(string fName = null)
        {
            //open an existing file
            string filepath;

            if (fName == null)
            {
                using (OpenFileDialog ofd = new OpenFileDialog())
                {
                    ofd.AddExtension    = true;
                    ofd.CheckFileExists = true;
                    ofd.CheckPathExists = true;
                    ofd.DefaultExt      = "bmap";
                    ofd.Filter          = "Binary Map|*.bmap|Plaintext Map|*.txt";
                    DialogResult dr = ofd.ShowDialog();
                    if (dr == DialogResult.OK)
                    {
                        filepath = ofd.FileName;
                    }
                    else
                    {
                        return;
                    }
                }
            }
            else
            {
                filepath = fName;
            }

            Map newMap = new Map(filepath);

            if (!newMap.Loaded)
            {
                MessageBox.Show("Error loading map!");
                return;
            }

            m_openMap = newMap;
            OpenEnableControls();
            mapViewer1.SetMapData(m_openMap.Layers, m_openMap.Width, m_openMap.Height);
            RegistryAccess.AddRecentFile(m_openMap.FileName, RegistrySetting.RecentMaps);
            RefreshRecentList(mnuFileRecent, RegistrySetting.RecentMaps);
        }
Пример #8
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            mapViewer1.DrawImages = new List <Texture2D>();

            string defaultTilesetPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\Resources\\default.tileset";

            if (!File.Exists(defaultTilesetPath))
            {
                if (MessageBox.Show("No default tileset found. Create one now?", "", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    Application.Exit();
                    return;
                }

                EditTileset();
                if (tileset.Tiles.Count == 0)
                {
                    Application.Exit();
                    return;
                }
            }
            else
            {
                tileset.LoadFromFile(defaultTilesetPath);
                mapViewer1.TileSize = tileset.Images.ImageSize.Width;
                RegistryAccess.AddRecentFile(tileset.FileName, RegistrySetting.RecentTilesets);
                RefreshListViewer();
            }

            //set up graphics device to pass to the created content manager
            GraphicsDeviceService gds     = GraphicsDeviceService.AddRef(Handle, ClientSize.Width, ClientSize.Height);
            ServiceContainer      service = new ServiceContainer();

            service.AddService <IGraphicsDeviceService>(gds);
            ContentManager cont = new ContentManager(service, EditorConst.CONTENT_ROOT_DIR);

            Left = (int)RegistryAccess.GetValue(RegistrySetting.WindowX);
            Top  = (int)RegistryAccess.GetValue(RegistrySetting.WindowY);

            Size = new Size((int)RegistryAccess.GetValue(RegistrySetting.WindowWidth), (int)RegistryAccess.GetValue(RegistrySetting.WindowHeight));

            //if (((int)RegistryAccess.GetValueOrDefault(RegistrySetting.WindowMaximized, EditorConst.WINDOW_DEFAULT_MAXIMIZATION)).ToBool())
            WindowState = FormWindowState.Maximized;
            //WindowState = FormWindowState.Maximized;
            //	WindowState = FormWindowState.Maximized;

            mapViewer1.GridText     = cont.Load <Texture2D>("gridbox");
            mapViewer1.SelectorText = cont.Load <Texture2D>("selector");

            System.Resources.ResourceSet res = GenericMapEditor.Properties.Resources.ResourceManager.GetResourceSet(new System.Globalization.CultureInfo("en-us"), true, true);

            for (int i = 0; i < (int)SpecialTileSpec.NUM_VALS; ++i)
            {
                cmbSpecialType.Items.Add(Enum.GetName(typeof(SpecialTileSpec), (SpecialTileSpec)i));
            }
            cmbSpecialType.SelectedIndex = 0;
            for (int i = (int)WarpAnim.NONE; i < (int)WarpAnim.NUM_VALS; ++i)
            {
                cmbWarpAnim.Items.Add(Enum.GetName(typeof(WarpAnim), (WarpAnim)i));
            }
            cmbWarpAnim.SelectedIndex = 0;

            RefreshRecentList(mnuFileRecent, RegistrySetting.RecentMaps);
            RefreshRecentList(recentToolStripMenuItem, RegistrySetting.RecentTilesets);
        }