private void btnGenerate_Click(object sender, EventArgs e)
        {
            if (!ValidateForm())
            {
                return;
            }

            EditorLandscape landscape;

            if (tbHeightmap.Text == string.Empty)
            {
                landscape = new EditorLandscape(Host.Game, Convert.ToInt16(tbBlockSize2.Text), Convert.ToInt16(tbWidth.Text), Convert.ToInt16(tbHeight.Text), Host.Camera);
            }
            else
            {
                // File stream is non-seekable so convert to memory stream
                using (Stream stream = File.Open(tbHeightmap.Text, FileMode.Open))
                {
                    landscape = new EditorLandscape(Host.Game, Convert.ToInt16(tbBlockSize1.Text), stream, Host.Camera);
                }
            }

            landscape.Host = Host;

            Host.SceneManager.CurrentScreen.AddVisualObject(landscape);

            // Fire the delegate
            Globals.LandscapeAction land = (Globals.LandscapeAction)Tag;
            land.Invoke(landscape);

            Dispose();
        }
Ejemplo n.º 2
0
        public override void Register(IAddinHost host)
        {
            // copy host to local instance
            Host = host;

            if (host != null)
            {
                Trace.WriteLine(DateTime.Now + " | Landscape Addin Loaded .. ");

                // Create our control for the brush texture
                conBrushSettings         = new conBrushSettings(Host);
                conBrushSettings.Enabled = false;

                // Add our control to the docking manager
                Host.DockManager.SetDock(conBrushSettings, DockPosition.Default);

                ToolStripSeparator s = new ToolStripSeparator();

                ToolStripButton tsAddLandscape = new ToolStripButton();
                tsAddLandscape.Text         = "Generate Landscape";
                tsAddLandscape.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
                tsAddLandscape.Click       += OnAddLandscape_Clicked;
                Host.ToolStrip.Items.Add(tsAddLandscape);

                // Add a seperator
                Host.ToolStrip.Items.Add(s);

                // Create a Label for our Brush Size
                ToolStripLabel lb1 = new ToolStripLabel("Brush Size : ");
                lb1.Margin = new Padding(5, 0, 0, 0);
                Host.ToolStrip.Items.Add(lb1);

                // Create our Brush Size combo box
                tsBrushSize      = new ToolStripComboBox("tsBrushSize");
                tsBrushSize.Text = "4";
                tsBrushSize.Items.Add("4");
                tsBrushSize.Items.Add("6");
                tsBrushSize.Items.Add("8");
                tsBrushSize.Items.Add("10");
                tsBrushSize.Items.Add("12");
                tsBrushSize.Items.Add("14");
                tsBrushSize.Items.Add("16");
                tsBrushSize.Items.Add("18");
                tsBrushSize.Items.Add("20");
                tsBrushSize.Items.Add("22");
                tsBrushSize.Items.Add("24");
                tsBrushSize.Items.Add("26");
                tsBrushSize.Items.Add("28");
                tsBrushSize.Items.Add("30");
                tsBrushSize.Items.Add("32");
                tsBrushSize.Items.Add("64");
                tsBrushSize.Items.Add("128");
                tsBrushSize.Items.Add("256");
                tsBrushSize.TextChanged += OnBrushSize_TextChanged;
                tsBrushSize.Width        = 20;
                Host.ToolStrip.Items.Add(tsBrushSize);

                // Brush Weight
                ToolStripLabel lb2 = new ToolStripLabel("Brush Weight : ");
                lb2.Margin = new Padding(5, 0, 0, 0);
                Host.ToolStrip.Items.Add(lb2);

                tbWeight       = new ToolStripTextBox("tbBrushWeight");
                tbWeight.Text  = "2.0";
                tbWeight.Width = 30;

                tbWeight.TextChanged += OnBrushWeight_TextChanged;
                Host.ToolStrip.Items.Add(tbWeight);

                // Raise Terrain Tool Panel Button
                tRaise             = new conTool();
                tRaise.ButtonImage = Resource1.btnRaise;
                tRaise.IsSelected  = true;
                tRaise.BackColor   = Color.Yellow;
                tRaise.MouseClick += OnRaiseClicked;
                Host.ToolPanel.Controls.Add(tRaise);

                // Lower Terrain Tool Panel Button
                tLower             = new conTool();
                tLower.ButtonImage = Resource1.btnLower;
                tLower.MouseClick += OnLowerClicked;
                Host.ToolPanel.Controls.Add(tLower);

                tPaint             = new conTool();
                tPaint.ButtonImage = Resource1.PaintBrush;
                tPaint.MouseClick += OnPaintClicked;
                Host.ToolPanel.Controls.Add(tPaint);

                LandscapeGenerated += OnLandscapeAdded;
            }
        }