public static String GenerateCodes(int index, Map map, ImageFormat format, Tile[] tileLibrary, ProgrammingLanguage language)
        {
            if (!CodesDictionary.IsValidName(map.Layers[index].Name, language))
            {
                MessageBox.Show("\"" + map.Layers[index].Name + "\" is a reserved word!\nPlease change the layer name", "Update Layer", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return("");
            }

            string formatExtension = MapInfo.GetTileExtension(format);

            switch (language)
            {
            case ProgrammingLanguage.CPP:
                return(GenerateCPPCodes(index, map, tileLibrary, formatExtension));

            case ProgrammingLanguage.CSharp:
                return(GenerateCSharpCodes(index, map, tileLibrary, formatExtension));

            case ProgrammingLanguage.ActionScript:
                return(GenerateASCodes(index, map, tileLibrary, formatExtension));

            case ProgrammingLanguage.XML:
                return(GenerateXMLCodes(index, map, tileLibrary, formatExtension));

            case ProgrammingLanguage.XMLLite:
                return(GenerateXMLLiteCodes(index, map, tileLibrary, formatExtension));

            default:
                return("");
            }
        }
Пример #2
0
 private void tbMapName_TextChanged(object sender, EventArgs e)
 {
     if (!CodesDictionary.IsValidNameFormat(tbMapName.Text))
     {
         MessageBox.Show("\"" + tbMapName.Text + "\" is not a valid name", "Map Name", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         tbMapName.Text = Path.GetFileNameWithoutExtension(_map.MapFileName);
     }
     else
     {
         _map.MapFileName = tbMapName.Text + ".d2d";
     }
 }
Пример #3
0
        public void SetupLayer(int index)
        {   // setup layer
            if (index == -1)
            {
                return;
            }
            else
            {
                if (tbLayerName.Text != _map.Layers[index].Name || nudLayerWidth.Value != _map.GetMapWidth() || nudLayerHeight.Value != _map.GetMapHeight() || nudTileWidth.Value != _map.TileWidth || nudTileHeight.Value != _map.TileHeight)
                {
                    DialogResult resizeDialog = MessageBox.Show("Do you want to do these changes? \nThis action cannot be undone", "Update Layer?", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                    if (resizeDialog != DialogResult.OK)
                    {
                        lblLayerId.Text        = _map.Layers[index].LayerId.ToString();
                        tbLayerName.Text       = _map.Layers[index].Name;
                        nudLayerWidth.Value    = _map.Layers[index].Width;
                        nudLayerHeight.Value   = _map.Layers[index].Height;
                        nudTileWidth.Value     = _map.TileWidth;
                        nudTileHeight.Value    = _map.TileHeight;
                        cbLayerVisible.Checked = _map.Layers[index].Visible;
                        tbarLayerAlpha.Value   = _map.Layers[index].Alpha;
                        return;
                    }
                }
            }

            if (!CodesDictionary.IsValidName(tbLayerName.Text, _map_info.Language))
            {
                MessageBox.Show("\"" + tbLayerName.Text + "\" is not a valid name!", "Update Layer", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            _map.TileWidth  = Convert.ToInt32(nudTileWidth.Value);
            _map.TileHeight = Convert.ToInt32(nudTileHeight.Value);
            _map.Layers[index].SetupLayer(tbLayerName.Text, Convert.ToInt32(nudLayerWidth.Value), Convert.ToInt32(nudLayerHeight.Value), tbarLayerAlpha.Value, cbLayerVisible.Checked, Convert.ToInt32(lblLayerId.Text));

            pbMap.Width  = _map.Layers[index].Width * _map.GetMapWidth();
            pbMap.Height = _map.Layers[index].Height * _map.GetMapHeight();

            RenderMap();
        }