Exemple #1
0
        public override void AddedToContainer()
        {
            base.AddedToContainer();

            leftPanel = new Panel();
            leftPanel.Initialize();
            AddDrawBox(leftPanel);

            rightPanel = new Panel();
            rightPanel.Initialize();
            AddDrawBox(rightPanel);

            var builder = new FieldBuilder();

            builder.BuildSessionStart(leftPanel);

            entitiesWithPainters = builder.AddColumnListBox("Entities being drawn:", 400, 2);
            entitiesWithPainters.SetColumnName(0, "Entity-Type");
            entitiesWithPainters.SetColumnName(1, "Painter-Type");

            builder.BuildSessionEnd();

            builder.BuildSessionStart(rightPanel);

            entityPainters = builder.AddColumnListBox("Entity-painters:", 400, 1);
            entityPainters.SetColumnName(0, "Painter-Type");

            builder.AddResizableButtonField("Add Painter", delegate(object sender)
            {
                AddEntityPainterForm.ShowDialogue(Parent, simulation, delegate(object _sender)
                {
                    var form = (AddEntityPainterForm)_sender;

                    form.Result.Initialize(DrawBox.DefaultSkinFile);
                    simulation.EntityPainters.Add(form.Result);

                    reloadEntitiesWithPaintersList();
                    reloadPainterList();
                });
            }, FieldBuilder.ResizableButtonOrientation.FillWidth);

            builder.AddResizableButtonField("Remove Painter", delegate(object sender)
            {
                if (entityPainters.SelectedRow != null)
                {
                    simulation.EntityPainters.Remove((IEntityPainter)entityPainters.SelectedRow.ExtraValues[0]);
                    reloadEntitiesWithPaintersList();
                    reloadPainterList();
                }
            }, FieldBuilder.ResizableButtonOrientation.FillWidth);

            builder.BuildSessionEnd();

            leftPanel.Width  = Math.Max(leftPanel.Width, rightPanel.Width);
            leftPanel.Height = Math.Max(leftPanel.Height, rightPanel.Height);

            rightPanel.X      = leftPanel.Width + panelMargin;
            rightPanel.Width  = Math.Max(leftPanel.Width, rightPanel.Width);
            rightPanel.Height = Math.Max(leftPanel.Height, rightPanel.Height);

            Wrap();

            reloadEntitiesWithPaintersList();
            reloadPainterList();

            leftPanel.Alignment  = DrawBoxAlignment.GetTopBottom();
            rightPanel.Alignment = DrawBoxAlignment.GetTopBottom();

            SizeChanged += new SizeChangedEvent(EntityDrawingOptionsForm_SizeChanged);

            X = (Parent.Width / 2) - (Width / 2);
            Y = (Parent.Height / 2) - (Height / 2);
        }
Exemple #2
0
        public override void AddedToContainer()
        {
            base.AddedToContainer();

            var builder = new FieldBuilder();

            builder.BuildSessionStart(this);

            var nameField = builder.AddTextField("Name: ");

            nameField.Text = spawnPoint.Name;

            var posX = builder.AddDoubleField("Position X: ");

            posX.Value = spawnPoint.SpawnArea.X;

            var posY = builder.AddDoubleField("Position Y: ");

            posY.Value = spawnPoint.SpawnArea.Y;

            var width = builder.AddIntegerField("Width: ");

            width.Value = spawnPoint.SpawnArea.Width;

            var height = builder.AddIntegerField("Height: ");

            height.Value = spawnPoint.SpawnArea.Height;

            var timeInterval = builder.AddDoubleField("Time Interval: ");

            timeInterval.Value = spawnPoint.TimeInterval;

            reloadValues = delegate()
            {
                nameField.Text     = spawnPoint.Name;
                posX.Value         = spawnPoint.SpawnArea.X;
                posY.Value         = spawnPoint.SpawnArea.Y;
                width.Value        = spawnPoint.SpawnArea.Width;
                height.Value       = spawnPoint.SpawnArea.Height;
                timeInterval.Value = spawnPoint.TimeInterval;
            };

            reloadValues();

            Action setValues = delegate()
            {
                spawnPoint.Name = nameField.Text;

                spawnPoint.SpawnArea.X      = (int)posX.Value;
                spawnPoint.SpawnArea.Y      = (int)posY.Value;
                spawnPoint.SpawnArea.Width  = (int)width.Value;
                spawnPoint.SpawnArea.Height = (int)height.Value;

                spawnPoint.SetTimeInterval(timeInterval.Value);
            };

            builder.AddVerticalMargin(5);

            builder.AddResizableButtonField("Set Spawn-Area with mouse", delegate(object sender)
            {
                setValues();

                Parent.DialoguesAreHidden = true;

                Globals.Editor.Mode = Editor.Modes.SetPeremiter;
                Globals.Editor.Set_SendPeremiterFunction(sendPeremiter);
            }, FieldBuilder.ResizableButtonOrientation.FillWidth);

            builder.AlignTop    = true;
            builder.AlignBottom = true;

            spawnEntitiesList = builder.AddColumnListBox("Spawn-entities", 300, 2);
            spawnEntitiesList.SetIntOrStringSort(false, true);
            spawnEntitiesList.SetColumnName(0, "Entity-Type");
            spawnEntitiesList.SetColumnName(1, "Amount");

            builder.AlignTop    = false;
            builder.AlignBottom = true;

            builder.AddResizableButtonField("Add Entity", delegate(object sender)
            {
                AddSpawnEntityForm.ShowDialogue(Parent, spawnPoint, delegate(object _sender)
                {
                    reloadList();
                });
            }, FieldBuilder.ResizableButtonOrientation.Right);

            builder.AddResizableButtonField("Remove Entity", delegate(object sender)
            {
                if (spawnEntitiesList.SelectedRowIndex == -1)
                {
                    return;
                }

                spawnPoint.SpawnClones.Remove((IEntity)spawnEntitiesList.Values[spawnEntitiesList.SelectedRowIndex].ExtraValues[0]);
                reloadValues();
            }, FieldBuilder.ResizableButtonOrientation.Right);

            builder.AddResizableButtonField("OK", delegate(object sender)
            {
                setValues();
                Close();
            }, FieldBuilder.ResizableButtonOrientation.Right);

            builder.BuildSessionEnd();

            X = (Parent.Width / 2) - (Width / 2);
            Y = (Parent.Height / 2) - (Height / 2);

            CanResizeFormVertically = false;
        }
Exemple #3
0
        public override void AddedToContainer()
        {
            base.AddedToContainer();

            var builder = new FieldBuilder();

            builder.BuildSessionStart(this);

            var painterTypesComboBox = builder.AddComboBoxField("Painter-type: ");
            var painterTypes         = Globals.GetAllTypesDeriving(typeof(IEntityPainter), Assembly.GetExecutingAssembly());

            painterTypesComboBox.Items.AddRange(painterTypes.Select(s => s.Name));

            painterTypesComboBox.SelectedItemChanged += delegate(object sender, int newItemIndex, int oldItemIndex)
            {
                if (painterTypesComboBox.Index == -1)
                {
                    return;
                }

                Result = (IEntityPainter)Activator.CreateInstance(painterTypes[painterTypesComboBox.Index]);

                //loadControls();
            };

            builder.AlignTop    = true;
            builder.AlignBottom = true;
            entitiesToDraw      = builder.AddColumnListBox("Entity-types to draw:", 200, 2);
            entitiesToDraw.SetColumnName(0, "Type-name");
            entitiesToDraw.SetColumnName(1, "State");
            entitiesToDraw.SetIntOrStringSort(false, false);

            builder.AlignTop    = false;
            builder.AlignBottom = true;

            var entityTypesComboBox = builder.AddComboBoxField("Entity-type: ");
            var entityTypes         = Globals.GetAllTypesDeriving(typeof(IEntity), Assembly.GetExecutingAssembly(), true);

            entityTypesComboBox.Items.AddRange(entityTypes.Select(s => s.Name));

            var addEntityButton = builder.AddResizableButtonField("Add Entity", delegate(object sender)
            {
                if (entityTypesComboBox.Index == -1)
                {
                    return;
                }

                Result.EntityTypeList.Add(entityTypes[entityTypesComboBox.Index]);
                reloadList();
            }, FieldBuilder.ResizableButtonOrientation.FillWidth);

            var okButton = builder.AddResizableButtonField("OK", delegate(object sender)
            {
                Close();
            }, FieldBuilder.ResizableButtonOrientation.Right);

            builder.BuildSessionEnd();

            startY = Height;

            painterTypesComboBox.Index = 0;

            X = (Parent.Width / 2) - (Width / 2);
            Y = (Parent.Height / 2) - (Height / 2);

            CanResizeFormVertically = true;
        }