Exemplo n.º 1
0
        private void BtnMapResize_Click(object sender, EventArgs e)
        {
            MapSizeInputWindow dialog = new MapSizeInputWindow(Map.Width, Map.Height);

            dialog.Location = MousePosition;
            if (dialog.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            if (dialog.NewWidth < Map.Width || dialog.NewHeight < Map.Height)
            {
                string oldSizeStr = "(" + Map.Width + "," + Map.Height + ")";
                string newSizeStr = "(" + dialog.NewWidth + "," + dialog.NewHeight + ")";

                if (!Confirm("The new size " + newSizeStr + " is smaller than the current size " + oldSizeStr +
                             ". This will delete objects that are out of bounds. Are you sure?"))
                {
                    return;
                }
            }

            Map.Resize(dialog.NewWidth, dialog.NewHeight);
            MapBox.AdjustSize();
            MapBox.InvalidateAllMapPositionsAndRefresh();
        }
Exemplo n.º 2
0
 private void CmbMapLayer_SelectedIndexChanged(object sender, EventArgs e)
 {
     MapBox.MapLayer = CmbMapLayer.SelectedIndex;
     if (MapBox.DrawOnlyCurrentLayer)
     {
         MapBox.InvalidateAllMapPositionsAndRefresh();
     }
 }
Exemplo n.º 3
0
 private void BtnMapFill_Click(object sender, EventArgs e)
 {
     if (Confirm("Fill current map layer with selected object?"))
     {
         MapBox.CurrentMapLayer.FillObject(CurrentObject);
         MapBox.InvalidateAllMapPositionsAndRefresh();
     }
 }
Exemplo n.º 4
0
 private void BtnMapClear_Click(object sender, EventArgs e)
 {
     if (Confirm("Clear the current map layer?"))
     {
         MapBox.CurrentMapLayer.Clear();
         MapBox.InvalidateAllMapPositionsAndRefresh();
     }
 }
Exemplo n.º 5
0
        private void MenuSetBackgroundImage_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.InitialDirectory = DataDirectory;
            dialog.Filter           = "Image files|*.png";
            if (dialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            MapBox.BackgroundImage = Image.FromFile(dialog.FileName);
            MapBox.InvalidateAllMapPositionsAndRefresh();
        }
Exemplo n.º 6
0
        private void BtnMapBackColor_Click(object sender, EventArgs e)
        {
            ColorPicker picker = new ColorPicker(Palette, "Pick map background color");

            picker.Location = MousePosition;
            if (picker.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            Map.BackColor = picker.SelectedColor;
            MapBox.InvalidateAllMapPositionsAndRefresh();
            UpdateTilePreview();
        }
Exemplo n.º 7
0
        private void DeleteCurrentMapLayer()
        {
            int index = CmbMapLayer.SelectedIndex;

            if (index == 0)
            {
                ShowWarning("Layer 0 cannot be deleted");
                return;
            }

            MapBox.Map.Layers.RemoveAt(index);
            UpdateMapLayerList();
            MapBox.InvalidateAllMapPositionsAndRefresh();
        }
Exemplo n.º 8
0
        public void EditSelectedTile()
        {
            TileEditor.MainWindow editor = new TileEditor.MainWindow(Tileset, TileIndex);
            editor.MapEditorWindow = this;
            editor.ShowDialog(this);

            TilesetBox.Refresh();
            UpdateTilesetPageIndicator();
            UpdateTilePreview();

            Tileset.Save(TilesetFile);
            Log("Tileset saved to " + TilesetFile);

            MapBox.InvalidateAllMapPositionsAndRefresh();
        }
Exemplo n.º 9
0
        private void BtnTilesetClear_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show(
                "This will load the default tileset. Are you sure?",
                "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);

            if (result == DialogResult.OK)
            {
                Tileset.Load(DefaultTilesetFile);

                TileIndex = 0;
                TilesetBox.Refresh();
                UpdateTilesetPageIndicator();
                UpdateTilePreview();
                MapBox.InvalidateAllMapPositionsAndRefresh();

                Log("Tileset imported from file " + DefaultTilesetFile);
            }
        }
Exemplo n.º 10
0
        private void ImportTileset()
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.InitialDirectory = DataDirectory;
            dialog.Filter           = "Tileset files|*.dat";

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                Tileset.Load(dialog.FileName);

                TileIndex = 0;
                TilesetBox.Refresh();
                UpdateTilesetPageIndicator();
                UpdateTilePreview();
                MapBox.InvalidateAllMapPositionsAndRefresh();

                Log("Tileset imported from file " + dialog.FileName);
            }
        }
Exemplo n.º 11
0
        private void LoadMap(string filename)
        {
            try
            {
                Map.Load(filename);
                UpdateMapLayerList(false);
                MapBox.AdjustSize();
                MapBox.InvalidateAllMapPositionsAndRefresh();
                TxtMapName.Text = Map.Name;
                UpdateTilePreview();

                Log("Map loaded from file " + filename);
                SetCurrentMapFile(filename);
            }
            catch (Exception ex)
            {
                ShowError("Error loading map from file " + filename + ":" +
                          Environment.NewLine + Environment.NewLine + ex.Message);
            }
        }
Exemplo n.º 12
0
 private void MenuShowMapBoundary_Click(object sender, EventArgs e)
 {
     MapBox.ShowBoundary = MenuShowMapBoundary.Checked;
     MapBox.InvalidateAllMapPositionsAndRefresh();
 }
Exemplo n.º 13
0
 private void MenuRemoveBackgroundImage_Click(object sender, EventArgs e)
 {
     MapBox.BackgroundImage = null;
     MapBox.InvalidateAllMapPositionsAndRefresh();
 }
Exemplo n.º 14
0
        private void ExecCommand(string[] command)
        {
            MapLayer map = MapBox.CurrentMapLayer;

            command[0] = command[0].Trim().ToLower();

            if (command[0] == "set")
            {
                int x = int.Parse(command[1]);
                int y = int.Parse(command[2]);

                map.SetObject(x, y, CurrentObject);
            }
            else if (command[0] == "fill")
            {
                map.FillObject(CurrentObject);
            }
            else if (command[0] == "clear")
            {
                map.Clear();
            }
            else if (command[0] == "rect")
            {
                int x = int.Parse(command[1]);
                int y = int.Parse(command[2]);
                int w = int.Parse(command[3]);
                int h = int.Parse(command[4]);

                for (int py = y; py < y + h; py++)
                {
                    for (int px = x; px < x + w; px++)
                    {
                        map.SetObject(px, py, CurrentObject);
                    }
                }
            }
            else if (command[0] == "hline")
            {
                int x = int.Parse(command[1]);
                int y = int.Parse(command[2]);
                int w = int.Parse(command[3]);

                for (int px = x; px < x + w; px++)
                {
                    map.SetObject(px, y, CurrentObject);
                }
            }
            else if (command[0] == "vline")
            {
                int x = int.Parse(command[1]);
                int y = int.Parse(command[2]);
                int h = int.Parse(command[3]);

                for (int py = y; py < y + h; py++)
                {
                    map.SetObject(x, py, CurrentObject);
                }
            }
            else if (command[0] == "box")
            {
                int x = int.Parse(command[1]);
                int y = int.Parse(command[2]);
                int w = int.Parse(command[3]);
                int h = int.Parse(command[4]);

                for (int px = x; px < x + w + 1; px++)
                {
                    map.SetObject(px, y, CurrentObject);
                    map.SetObject(px, y + h, CurrentObject);
                }
                for (int py = y; py < y + h; py++)
                {
                    map.SetObject(x, py, CurrentObject);
                    map.SetObject(x + w, py, CurrentObject);
                }
            }
            else if (command[0].StartsWith("print"))
            {
                int x  = int.Parse(command[1]);
                int y  = int.Parse(command[2]);
                int px = x;
                int py = y;

                string text = command[3];

                if (command.Length > 4)
                {
                    for (int i = 4; i < command.Length; i++)
                    {
                        text += " " + command[i];
                    }
                }

                foreach (char ch in text)
                {
                    GameObject o = new GameObject(CurrentObject);
                    o.Bytes.Clear();
                    o.Graphics.Index = ch;

                    if (ch == '\\')
                    {
                        px = x;
                        py++;
                    }
                    else
                    {
                        map.SetObject(px++, py, o);
                    }
                }
            }
            else if (command[0] == "select")
            {
                MapBox.SelectArea(
                    int.Parse(command[1]), int.Parse(command[2]),
                    int.Parse(command[3]), int.Parse(command[4]));

                MapBox.InvalidateAllMapPositionsAndRefresh();
                Log("Area selected: " + MapBox.GetSelectedArea());
            }
            else if (command[0] == "deselect")
            {
                MapBox.DeselectArea();
                MapBox.InvalidateAllMapPositionsAndRefresh();
                Log("Area deselected");
            }
            else if (command[0] == "erase")
            {
                MapBox.EraseSelectedArea();
                MapBox.InvalidateAllMapPositionsAndRefresh();
                Log("Selected area erased");
            }
            else if (command[0] == "copy")
            {
                int x = int.Parse(command[1]);
                int y = int.Parse(command[2]);

                MapBox.CopySelectedAreaTo(x, y, false);
                MapBox.InvalidateAllMapPositionsAndRefresh();
                Log("Selected area copied to X:" + x + ",Y:" + y);
            }
            else if (command[0] == "cut")
            {
                int x = int.Parse(command[1]);
                int y = int.Parse(command[2]);

                MapBox.CopySelectedAreaTo(x, y, true);
                MapBox.InvalidateAllMapPositionsAndRefresh();
                Log("Selected area cut and pasted to X:" + x + ",Y:" + y);
            }
            else if (command[0] == "savesel")
            {
                SaveFileDialog dialog = new SaveFileDialog();
                dialog.InitialDirectory = DataDirectory;
                dialog.Filter           = "PNG image files|*.png";
                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                MapBox.SaveSelectedAreaAsImage(dialog.FileName);
                Log("Selected area saved to file:" + dialog.FileName);
            }

            MapBox.InvalidateAllMapPositionsAndRefresh();
        }
Exemplo n.º 15
0
 private void BtnMapShowCurLayerOnly_Click(object sender, EventArgs e)
 {
     MapBox.DrawOnlyCurrentLayer = BtnMapShowCurLayerOnly.Checked;
     MapBox.InvalidateAllMapPositionsAndRefresh();
 }
Exemplo n.º 16
0
 public void UpdateTileViews()
 {
     TilesetBox.Refresh();
     MapBox.InvalidateAllMapPositionsAndRefresh();
     UpdateTilePreview();
 }