Inheritance: ControlBase
        public BoxToolPanel()
        {
            Title = "Settings";

            fillBoxOption = new CheckBox(18, 1);
            fillBoxOption.Text = "Fill";

            useCharBorder = new CheckBox(18, 1);
            useCharBorder.Text = "Char. Border";
            useCharBorder.IsSelectedChanged += (s, o) => { characterPicker.IsVisible = useCharBorder.IsSelected; EditorConsoleManager.ToolsPane.RedrawPanels(); };

            lineForeColor = new Controls.ColorPresenter("Border Fore", Settings.Green, 18);
            lineForeColor.SelectedColor = Color.White;

            lineBackColor = new Controls.ColorPresenter("Border Back", Settings.Green, 18);
            lineBackColor.SelectedColor = Color.Black;

            fillColor = new Controls.ColorPresenter("Fill Color", Settings.Green, 18);
            fillColor.SelectedColor = Color.Black;

            characterPicker = new Controls.CharacterPicker(Settings.Red, Settings.Color_ControlBack, Settings.Green);
            characterPicker.IsVisible = false;

            Controls = new ControlBase[] { lineForeColor, lineBackColor, fillColor, fillBoxOption, useCharBorder, characterPicker };
        }
        public HotspotToolPanel()
        {
            Title = "Hotspots";

            hotspotsListbox = new ListBox<HotspotListBoxItem>(Consoles.ToolPane.PanelWidthControls, 7);
            createButton = new Button(Consoles.ToolPane.PanelWidthControls, 1);
            editButton = new Button(Consoles.ToolPane.PanelWidthControls, 1);
            deleteButton = new Button(Consoles.ToolPane.PanelWidthControls, 1);
            exportListButton = new Button(Consoles.ToolPane.PanelWidthControls, 1);
            cloneHotspot = new Button(Consoles.ToolPane.PanelWidthControls, 1);
            importListButton = new Button(Consoles.ToolPane.PanelWidthControls, 1);

            hotspotsListbox.SelectedItemChanged += hotspotsListbox_SelectedItemChanged;
            createButton.ButtonClicked += _createNewObjectButton_ButtonClicked;
            editButton.ButtonClicked += _editObjectButton_ButtonClicked;
            deleteButton.ButtonClicked += _deleteObjectButton_ButtonClicked;
            exportListButton.ButtonClicked += _exportListButton_ButtonClicked;
            cloneHotspot.ButtonClicked += CloneHotspot_ButtonClicked;
            importListButton.ButtonClicked += ImportListButton_ButtonClicked;

            editButton.IsEnabled = false;
            deleteButton.IsEnabled = false;
            cloneHotspot.IsEnabled = false;

            hotspotsListbox.HideBorder = true;

            createButton.Text = "Define New";
            editButton.Text = "Edit";
            deleteButton.Text = "Delete";
            exportListButton.Text = "Export";
            cloneHotspot.Text = "Clone";
            importListButton.Text = "Import";

            drawHotspotsCheckbox = new CheckBox(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 1);
            drawHotspotsCheckbox.IsSelected = true;
            drawHotspotsCheckbox.Text = "Draw hotspots";

            Controls = new ControlBase[] { createButton, null, hotspotsListbox, null, editButton, cloneHotspot, deleteButton, null, exportListButton, importListButton, null, drawHotspotsCheckbox };

            // Load the known object types.
            //if (System.IO.File.Exists(Settings.FileObjectTypes))
            //{
            //    using (var fileObject = System.IO.File.OpenRead(Settings.FileObjectTypes))
            //    {
            //        var serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(GameObject[]));

            //        var gameObjects = serializer.ReadObject(fileObject) as GameObject[];

            //        foreach (var item in gameObjects)
            //        {
            //            var newItem = new GameObjectMeta(item, true);
            //            hotspotsListbox.Items.Add(newItem);
            //        }
            //    }
            //}

            exportListButton.IsEnabled = hotspotsListbox.Items.Count != 0;
        }
        public RecolorToolPanel()
        {
            ignoreBackCheck = new CheckBox(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 1);
            ignoreBackCheck.Text = "Ignore Back";

            ignoreForeCheck = new CheckBox(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 1);
            ignoreForeCheck.Text = "Ignore Fore";

            Title = "Recolor Options";

            Controls = new ControlBase[] { ignoreForeCheck, ignoreBackCheck };
        }
        public CharacterPickPanel(string title, bool hideCharacter, bool hideForeground, bool hideBackground)
        {
            Title = title;

            _foreColor = new ColorPresenter("Foreground", Settings.Green, SadConsoleEditor.Consoles.ToolPane.PanelWidthControls);
            _backColor = new ColorPresenter("Background", Settings.Green, SadConsoleEditor.Consoles.ToolPane.PanelWidthControls);
            _charPreview = new ColorPresenter("Character", Settings.Green, SadConsoleEditor.Consoles.ToolPane.PanelWidthControls);
            _mirrorLR = new CheckBox(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 1);
            _mirrorTB = new CheckBox(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 1);
            _characterPicker = new CharacterPicker(Settings.Red, Settings.Color_ControlBack, Settings.Green);
            _popupCharacterWindow = new Windows.CharacterQuickSelectPopup(0);

            _mirrorLR.Text = "Mirror Horiz.";
            _mirrorTB.Text = "Mirror Vert.";

            _foreColor.SelectedColor = Color.White;
            _backColor.SelectedColor = Color.Black;

            _foreColor.RightClickedColor += (s, e) => { var tempColor = SettingBackground; SettingBackground = SettingForeground; SettingForeground = tempColor; };
            _backColor.RightClickedColor += (s, e) => { var tempColor = SettingForeground; SettingForeground = SettingBackground; SettingBackground = tempColor; };

            _charPreview.CharacterColor = _foreColor.SelectedColor;
            _charPreview.SelectedColor = _backColor.SelectedColor;
            _charPreview.Character = 0;
            _charPreview.DisableColorPicker = true;
            _charPreview.EnableCharacterPicker = true;

            _popupCharacterWindow.TextSurface.Font = Settings.Config.ScreenFont;
            _popupCharacterWindow.Closed += (o, e) => { _characterPicker.SelectedCharacter = _popupCharacterWindow.SelectedCharacter; };

            _mirrorLR.IsSelectedChanged += Mirror_IsSelectedChanged;
            _mirrorTB.IsSelectedChanged += Mirror_IsSelectedChanged;
            _foreColor.ColorChanged += (o, e) => { _charPreview.CharacterColor = _foreColor.SelectedColor; OnChanged(); };
            _backColor.ColorChanged += (o, e) => { _charPreview.SelectedColor = _backColor.SelectedColor; OnChanged(); };
            _characterPicker.SelectedCharacterChanged += (sender, e) => { _charPreview.Character = e.NewCharacter; _charPreview.Title = "Character (" + e.NewCharacter.ToString() + ")"; OnChanged(); };
            _characterPicker.SelectedCharacter = 1;
            _charPreview.MouseButtonClicked += (o, e) => {
                if (e.LeftButtonClicked)
                {
                    _popupCharacterWindow.Center();
                    _popupCharacterWindow.Show(true);
                }
            };

            HideCharacter = hideCharacter;
            HideForeground = hideForeground;
            HideBackground = hideBackground;

            HideMirrorLR = HideMirrorTB = HideCharacter;

            Reset();
        }
        public SelectionToolAltPanel()
        {
            Title = "Sel.Rect Options";

            skipEmptyColor = new CheckBox(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 1);
            skipEmptyColor.Text = "Skip Empty";

            altEmptyColorCheck = new CheckBox(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 1);
            altEmptyColorCheck.Text = "Use Alt. Empty";

            altEmptyColor = new Controls.ColorPresenter("Alt. Empty Clr", Settings.Green, 18);
            altEmptyColor.SelectedColor = Color.Black;

            Controls = new ControlBase[] { skipEmptyColor, altEmptyColorCheck, altEmptyColor };
        }
        public GameObjectManagementPanel()
        {
            Title = "Entities";
            GameObjectList = new ListBox<EntityListBoxItem>(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 4);
            GameObjectList.HideBorder = true;
            GameObjectList.SelectedItemChanged += GameObject_SelectedItemChanged;
            GameObjectList.CompareByReference = true;

            removeSelected = new Button(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 1);
            removeSelected.Text = "Remove";
            removeSelected.ButtonClicked += RemoveSelected_ButtonClicked;

            moveSelectedUp = new Button(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 1);
            moveSelectedUp.Text = "Move Up";
            moveSelectedUp.ButtonClicked += MoveSelectedUp_ButtonClicked;

            moveSelectedDown = new Button(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 1);
            moveSelectedDown.Text = "Move Down";
            moveSelectedDown.ButtonClicked += MoveSelectedDown_ButtonClicked;

            renameLayer = new Button(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 1);
            renameLayer.Text = "Rename";
            renameLayer.ButtonClicked += RenameEntity_ButtonClicked;

            importGameObject = new Button(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 1);
            importGameObject.Text = "Import File";
            importGameObject.ButtonClicked += ImportEntity_ButtonClicked;

            drawGameObjectsCheckbox = new CheckBox(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 1);
            drawGameObjectsCheckbox.IsSelected = true;
            drawGameObjectsCheckbox.Text = "Draw Objects";

            animationListTitle = new DrawingSurface(Consoles.ToolPane.PanelWidthControls, 2);
            animationListTitle.Print(0, 0, "Animations", Settings.Green);

            animationsListBox = new ListBox<AnimationListBoxItem>(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 4);
            animationsListBox.SelectedItemChanged += AnimationList_SelectedItemChanged;
            animationsListBox.HideBorder = true;
            animationsListBox.CompareByReference = true;

            playAnimationButton = new Button(Consoles.ToolPane.PanelWidthControls, 1);
            playAnimationButton.Text = "Play Animation";
            playAnimationButton.ButtonClicked += (o, e) => { if (animationsListBox.SelectedItem != null) ((AnimatedTextSurface)animationsListBox.SelectedItem).Restart(); };

            Controls = new ControlBase[] { GameObjectList, removeSelected, moveSelectedUp, moveSelectedDown, renameLayer, importGameObject, null, drawGameObjectsCheckbox, null, animationListTitle,animationsListBox, null, playAnimationButton };

            GameObject_SelectedItemChanged(null, null);
        }
        public RegionManagementPanel()
        {
            Title = "Zones";
            GameObjectList = new ListBox<EntityListBoxItem>(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 4);
            GameObjectList.HideBorder = true;
            GameObjectList.SelectedItemChanged += GameObject_SelectedItemChanged;
            GameObjectList.CompareByReference = true;

            removeSelected = new Button(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 1);
            removeSelected.Text = "Remove";
            removeSelected.ButtonClicked += RemoveSelected_ButtonClicked;

            moveSelectedUp = new Button(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 1);
            moveSelectedUp.Text = "Move Up";
            moveSelectedUp.ButtonClicked += MoveSelectedUp_ButtonClicked;

            moveSelectedDown = new Button(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 1);
            moveSelectedDown.Text = "Move Down";
            moveSelectedDown.ButtonClicked += MoveSelectedDown_ButtonClicked;

            renameZoneButton = new Button(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 1);
            renameZoneButton.Text = "Rename";
            renameZoneButton.ButtonClicked += RenameZone_ButtonClicked;

            addZoneButton = new Button(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 1);
            addZoneButton.Text = "Add New";
            addZoneButton.ButtonClicked += AddZone_ButtonClicked;

            editSettings = new Button(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 1);
            editSettings.Text = "Edit Settings";
            editSettings.ButtonClicked += EditSettings_ButtonClicked;

            zoneColorPresenter = new SadConsoleEditor.Controls.ColorPresenter("Zone Color", Settings.Green, SadConsoleEditor.Consoles.ToolPane.PanelWidthControls);
            zoneColorPresenter.SelectedColor = Color.Aqua;
            zoneColorPresenter.IsEnabled = false;
            zoneColorPresenter.ColorChanged += ZoneColorPresenter_ColorChanged;

            drawZonesCheckbox = new CheckBox(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 1);
            drawZonesCheckbox.IsSelected = true;
            drawZonesCheckbox.Text = "Draw zones";

            propertySurface = new DrawingSurface(Consoles.ToolPane.PanelWidthControls, 2);

            Controls = new ControlBase[] { addZoneButton, null, GameObjectList, removeSelected, moveSelectedUp, moveSelectedDown, renameZoneButton, editSettings, null, drawZonesCheckbox, null, zoneColorPresenter, propertySurface };

            GameObject_SelectedItemChanged(null, null);
        }
        public LayersPanel()
        {
            Title = "Layers";
            layers = new ListBox<LayerListBoxItem>(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 4);
            layers.HideBorder = true;
            layers.SelectedItemChanged += layers_SelectedItemChanged;
            layers.CompareByReference = true;

            removeSelected = new Button(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 1);
            removeSelected.Text = "Remove";
            removeSelected.ButtonClicked += removeSelected_ButtonClicked;

            moveSelectedUp = new Button(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 1);
            moveSelectedUp.Text = "Move Up";
            moveSelectedUp.ButtonClicked += moveSelectedUp_ButtonClicked;

            moveSelectedDown = new Button(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 1);
            moveSelectedDown.Text = "Move Down";
            moveSelectedDown.ButtonClicked += moveSelectedDown_ButtonClicked;

            toggleHideShow = new CheckBox(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 1);
            toggleHideShow.Text = "Show/Hide";
            toggleHideShow.TextAlignment = System.Windows.HorizontalAlignment.Center;
            toggleHideShow.IsSelectedChanged += toggleHideShow_IsSelectedChanged;

            addNewLayer = new Button(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 1);
            addNewLayer.Text = "Add New";
            addNewLayer.ButtonClicked += addNewLayer_ButtonClicked;

            renameLayer = new Button(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 1);
            renameLayer.Text = "Rename";
            renameLayer.ButtonClicked += renameLayer_ButtonClicked;

            addNewLayerFromFile = new Button(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 1);
            addNewLayerFromFile.Text = "Load From File";
            addNewLayerFromFile.ButtonClicked += addNewLayerFromFile_ButtonClicked;

            saveLayerToFile = new Button(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 1);
            saveLayerToFile.Text = "Save Layer to File";
            saveLayerToFile.ButtonClicked += saveLayerToFile_ButtonClicked;

            Controls = new ControlBase[] { layers, toggleHideShow, removeSelected, moveSelectedUp, moveSelectedDown, addNewLayer, renameLayer, addNewLayerFromFile, saveLayerToFile };
        }
Exemple #9
0
    private void Generate()
    {
        DefaultBackground = Color.Black;
        DefaultForeground = Color.White;

        this.PrintCentre(Width / 2, 1, "Options");

        this.PrintCentre(Width / 2, 4, "Game Size");

        this.PrintCentre(Width / 2, 6, "                  ");
        this.PrintCentre(Width / 2, 6, "Width (" + Settings.gameSettings.width + ")");
        Print(Width / 2 - 18, 7, Settings.MinWidth.ToString());
        Print(Width / 2 + 16, 7, Settings.MaxWidth.ToString());
        var widthScroll = new SadConsole.Controls.ScrollBar(Orientation.Horizontal, 30)
        {
            Position = new Point(Width / 2 - 15, 7)
        };

        widthScroll.Maximum       = Settings.MaxWidth - Settings.MinWidth;
        widthScroll.Step          = 1;
        widthScroll.Value         = Settings.Width - Settings.MinWidth;
        widthScroll.ValueChanged += WidthScroll_ValueChanged;
        Add(widthScroll);

        this.PrintCentre(Width / 2, 9, "                  ");
        this.PrintCentre(Width / 2, 9, "Height (" + Settings.gameSettings.height + ")");
        Print(Width / 2 - 18, 10, Settings.MinHeight.ToString());
        Print(Width / 2 + 16, 10, Settings.MaxHeight.ToString());
        var heightScroll = new SadConsole.Controls.ScrollBar(Orientation.Horizontal, 30)
        {
            Position = new Point(Width / 2 - 15, 10)
        };

        heightScroll.Maximum       = Settings.MaxHeight - Settings.MinHeight;
        heightScroll.Step          = 1;
        heightScroll.Value         = Settings.Height - Settings.MinHeight;
        heightScroll.ValueChanged += HeightScroll_ValueChanged;
        Add(heightScroll);

        this.PrintCentre(Width / 2, 14, "Game Settings");

        var debug = new SadConsole.Controls.CheckBox(15, 1)
        {
            Text = "Debug Mode", Position = new Point(Width / 2 - 7, 16)
        };

        debug.IsSelected         = Settings.DebugMode;
        debug.IsSelectedChanged += (a, b) =>
        {
            Settings.DebugMode          = ((a as SadConsole.Controls.CheckBox).IsSelected);
            Settings.gameSettings.debug = Settings.DebugMode;
            if (Settings.DebugMode)
            {
                GameScreen.PrintLine($"\nDebug mode enabled - You can simulate the bodyparts on yourself to test the blood and organs systems with the <{Color.Cyan.ToInteger()},debug simulate me>debug simulate me@ command.");
                GameScreen.Print($"You can also get a summary of all your bodyparts with the <{Color.Cyan.ToInteger()},debug look at me>debug look at me@ command.");
            }
        };
        Add(debug);

        Add(new BackButton(30, 3)
        {
            Text     = "Discard changes and return",
            Position = new Point(Width / 2 - 32, Settings.Height - 8)
        });

        var backbutton = new SadConsole.Controls.Button(30, 3)
        {
            Text     = "Save changes and return",
            Position = new Point(Width / 2 + 2, Settings.Height - 8)
        };

        backbutton.Click += (a, b) =>
        {
            Settings.SaveSettings();
            GameWindow.NavigateBack();
        };

        Add(backbutton);

        if (Settings.gameSettings.width != Settings.Width || Settings.gameSettings.height != Settings.Height)
        {
            this.PrintCentre(Width / 2, 12, "Resolution changes will require a restart", new Cell(Color.OrangeRed, Color.Black));
        }
    }
        public AnimationsPanel(Action<AnimatedTextSurface> animationChangeCallback)
        {
            Title = "Animations";
            animations = new ListBox(Consoles.ToolPane.PanelWidthControls, 4);
            animations.HideBorder = true;
            animations.SelectedItemChanged += animations_SelectedItemChanged;
            animations.CompareByReference = true;

            removeSelected = new Button(Consoles.ToolPane.PanelWidthControls, 1);
            removeSelected.Text = "Remove";
            removeSelected.ButtonClicked += removeAnimation_ButtonClicked;

            addNewAnimation = new Button(Consoles.ToolPane.PanelWidthControls, 1);
            addNewAnimation.Text = "Add New";
            addNewAnimation.ButtonClicked += addNewAnimation_ButtonClicked;

            renameAnimation = new Button(Consoles.ToolPane.PanelWidthControls, 1);
            renameAnimation.Text = "Rename";
            renameAnimation.ButtonClicked += renameAnimation_ButtonClicked;

            addNewAnimationFromFile = new Button(Consoles.ToolPane.PanelWidthControls, 1);
            addNewAnimationFromFile.Text = "Import Anim.";
            addNewAnimationFromFile.ButtonClicked += addNewAnimationFromFile_ButtonClicked;

            saveAnimationToFile = new Button(Consoles.ToolPane.PanelWidthControls, 1);
            saveAnimationToFile.Text = "Export Anim.";
            saveAnimationToFile.ButtonClicked += saveAnimationToFile_ButtonClicked;

            changeSpeedButton = new Button(3, 1);
            changeSpeedButton.ShowEnds = false;
            changeSpeedButton.Text = "Set";
            changeSpeedButton.ButtonClicked += changeSpeedButton_ButtonClicked;

            cloneSelectedAnimationButton = new Button(Consoles.ToolPane.PanelWidthControls, 1);
            cloneSelectedAnimationButton.Text = "Clone Sel. Anim";
            cloneSelectedAnimationButton.ButtonClicked += cloneSelectedAnimation_ButtonClicked;

            reverseAnimationButton = new Button(Consoles.ToolPane.PanelWidthControls, 1);
            reverseAnimationButton.Text = "Reverse Animation";
            reverseAnimationButton.ButtonClicked += reverseAnimation_ButtonClicked; ;

            setCenterButton = new Button(Consoles.ToolPane.PanelWidthControls, 1);
            setCenterButton.Text = "Set Center";
            setCenterButton.ButtonClicked += (s, e) => invokeCustomToolCallback(CustomTool.Center);

            setBoundingBoxButton = new Button(Consoles.ToolPane.PanelWidthControls, 1);
            setBoundingBoxButton.Text = "Set Collision";
            setBoundingBoxButton.ButtonClicked += (s, e) => invokeCustomToolCallback(CustomTool.CollisionBox);

            animationSpeedLabel = new DrawingSurface(Consoles.ToolPane.PanelWidthControls - changeSpeedButton.Width, 1);

            repeatCheck = new CheckBox(Consoles.ToolPane.PanelWidthControls, 1);
            repeatCheck.Text = "Repeat";
            repeatCheck.IsSelectedChanged += repeatCheck_IsSelectedChanged;

            playPreview = new Button(Consoles.ToolPane.PanelWidthControls, 1);
            playPreview.Text = "Play Preview";
            playPreview.ButtonClicked += playPreview_ButtonClicked; ;

            this.animationChangeCallback = animationChangeCallback;
            //_invokeCustomToolCallback = invokeCustomToolCallback;

            Controls = new ControlBase[] { animations, null, removeSelected, addNewAnimation, renameAnimation, cloneSelectedAnimationButton, null, addNewAnimationFromFile, saveAnimationToFile, null, playPreview, null, animationSpeedLabel, changeSpeedButton, repeatCheck, null, reverseAnimationButton };
        }
Exemple #11
0
        public ControlsTest() : base(80, 23)
        {
            //ThemeColors = SadConsole.Themes.Colors.CreateFromAnsi();

            var prog1 = new ProgressBar(10, 1, HorizontalAlignment.Left)
            {
                Position = new Point(16, 5)
            };

            Add(prog1);

            var prog2 = new ProgressBar(1, 6, VerticalAlignment.Bottom)
            {
                Position = new Point(18, 7)
            };

            Add(prog2);

            var slider = new ScrollBar(Orientation.Horizontal, 10)
            {
                Position = new Point(16, 3),
                Maximum  = 18
            };

            Add(slider);

            slider = new ScrollBar(Orientation.Vertical, 6)
            {
                Position = new Point(16, 7),
                Maximum  = 6
            };
            Add(slider);

            progressTimer = new Timer(TimeSpan.FromSeconds(0.5));
            progressTimer.TimerElapsed += (timer, e) => { prog1.Progress = prog1.Progress >= 1f ? 0f : prog1.Progress + 0.1f; prog2.Progress = prog2.Progress >= 1f ? 0f : prog2.Progress + 0.1f; };

            Components.Add(progressTimer);

            var listbox = new SadConsole.Controls.ListBox(20, 6)
            {
                Position = new Point(28, 3)
            };

            listbox.Items.Add("item 1");
            listbox.Items.Add("item 2");
            listbox.Items.Add("item 3");
            listbox.Items.Add("item 4");
            listbox.Items.Add("item 5");
            listbox.Items.Add("item 6");
            listbox.Items.Add("item 7");
            listbox.Items.Add("item 8");
            Add(listbox);

            var radioButton = new RadioButton(20, 1)
            {
                Text     = "Group 1 Option 1",
                Position = new Point(28, 12)
            };

            Add(radioButton);

            radioButton = new RadioButton(20, 1)
            {
                Text     = "Group 1 Option 2",
                Position = new Point(28, 13)
            };
            Add(radioButton);

            var selButton = new SadConsole.Controls.SelectionButton(24, 1)
            {
                Text     = "Selection Button 1",
                Position = new Point(51, 3)
            };

            Add(selButton);

            var selButton1 = new SadConsole.Controls.SelectionButton(24, 1)
            {
                Text     = "Selection Button 2",
                Position = new Point(51, 4)
            };

            Add(selButton1);

            var selButton2 = new SadConsole.Controls.SelectionButton(24, 1)
            {
                Text     = "Selection Button 3",
                Position = new Point(51, 5)
            };

            Add(selButton2);

            selButton.PreviousSelection  = selButton2;
            selButton.NextSelection      = selButton1;
            selButton1.PreviousSelection = selButton;
            selButton1.NextSelection     = selButton2;
            selButton2.PreviousSelection = selButton1;
            selButton2.NextSelection     = selButton;

            var input = new TextBox(10)
            {
                Position = new Point(51, 9)
            };

            Add(input);

            var password = new TextBox(10)
            {
                PasswordChar = "*",
                Position     = new Point(65, 9)
            };

            Add(password);

            var button = new SadConsole.Controls.Button(11, 1)
            {
                Text     = "Click",
                Position = new Point(1, 3)
            };

            button.Click += (s, a) => Window.Message("This has been clicked -- and your password field contains '" + password.Text + "'", "Close");
            Add(button);

            button = new SadConsole.Controls.Button(11, 3)
            {
                Text     = "Click",
                Position = new Point(1, 5),
                Theme    = new Button3dTheme()
            };
            //button.AlternateFont = SadConsole.Global.LoadFont("Fonts/Cheepicus12.font").GetFont(Font.FontSizes.One);
            Add(button);

            button = new SadConsole.Controls.Button(11, 3)
            {
                Text     = "Click",
                Position = new Point(1, 10),
                Theme    = new ButtonLinesTheme()
            };
            Add(button);

            var checkbox = new SadConsole.Controls.CheckBox(13, 1)
            {
                Text     = "Check box",
                Position = new Point(51, 13)
            };

            Add(checkbox);

            FocusedControl = null;
            //DisableControlFocusing = true;

            var colorValues = ThemeColors ?? Library.Default.Colors;

            List <Tuple <Color, string> > colors = new List <Tuple <Color, string> >
            {
                new Tuple <Color, string>(colorValues.Red, "Red"),
                new Tuple <Color, string>(colorValues.RedDark, "DRed"),
                new Tuple <Color, string>(colorValues.Purple, "Prp"),
                new Tuple <Color, string>(colorValues.PurpleDark, "DPrp"),
                new Tuple <Color, string>(colorValues.Blue, "Blu"),
                new Tuple <Color, string>(colorValues.BlueDark, "DBlu"),
                new Tuple <Color, string>(colorValues.Cyan, "Cya"),
                new Tuple <Color, string>(colorValues.CyanDark, "DCya"),
                new Tuple <Color, string>(colorValues.Green, "Gre"),
                new Tuple <Color, string>(colorValues.GreenDark, "DGre"),
                new Tuple <Color, string>(colorValues.Yellow, "Yel"),
                new Tuple <Color, string>(colorValues.YellowDark, "DYel"),
                new Tuple <Color, string>(colorValues.Orange, "Ora"),
                new Tuple <Color, string>(colorValues.OrangeDark, "DOra"),
                new Tuple <Color, string>(colorValues.Brown, "Bro"),
                new Tuple <Color, string>(colorValues.BrownDark, "DBrow"),
                new Tuple <Color, string>(colorValues.Gray, "Gray"),
                new Tuple <Color, string>(colorValues.GrayDark, "DGray"),
                new Tuple <Color, string>(colorValues.White, "White"),
                new Tuple <Color, string>(colorValues.Black, "Black")
            };

            backgroundcycle = colors.Select(i => i.Item1).ToArray();
            backIndex       = 5;

            // Ensure our color changes take affect.
            Invalidate();

            //int y = 25 - 20;
            //int x = 0;
            //int colorLength = 4;
            //foreach (var color1 in colors)
            //{
            //    foreach (var color2 in colors)
            //    {
            //        _Print(x, y, new ColoredString(color2.Item2.PadRight(colorLength).Substring(0, colorLength), color2.Item1, color1.Item1, null));
            //        y++;
            //    }

            //    y = 25 -20;
            //    x += colorLength;
            //}
        }
Exemple #12
0
        public SampleConsole( ) : base(50, 36)
        {
            Title = "Preview";
            Global.FocusedConsoles.Push(this);

            var panel = new Panel(20, 2)
            {
                Fake3D = false
            };

            panel.DrawPanel();
            panel.Position = new Point(1, 24);
            panel.AddLine("This is a Panel.");

            Children.Add(panel);

            var button = new SadConsole.Controls.Button(11, 3)
            {
                Text     = "Click",
                Position = new Point(1, 6),
                Theme    = new Button3dTheme()
            };

            Add(button);

            button = new SadConsole.Controls.Button(11, 3)
            {
                Text     = "Click",
                Position = new Point(1, 10),
                Theme    = new ButtonLinesTheme()
            };
            Add(button);

            var prog1 = new ProgressBar(10, 1, HorizontalAlignment.Left);

            prog1.Position = new Point(16, 5);
            Add(prog1);

            var prog2 = new ProgressBar(1, 6, VerticalAlignment.Bottom);

            prog2.Position = new Point(18, 7);
            Add(prog2);

            var slider = SadConsole.Controls.ScrollBar.Create(Orientation.Horizontal, 10);

            slider.Position = new Point(16, 3);
            slider.Maximum  = 18;
            Add(slider);

            slider          = SadConsole.Controls.ScrollBar.Create(Orientation.Vertical, 6);
            slider.Position = new Point(16, 7);
            slider.Maximum  = 6;
            Add(slider);

            var listbox = new SadConsole.Controls.ListBox(20, 6);

            listbox.Position   = new Point(28, 3);
            listbox.HideBorder = false;
            listbox.Items.Add("item 1");
            listbox.Items.Add("item 2");
            listbox.Items.Add("item 3");
            listbox.Items.Add("item 4");
            listbox.Items.Add("item 5");
            listbox.Items.Add("item 6");
            listbox.Items.Add("item 7");
            listbox.Items.Add("item 8");
            Add(listbox);

            var radioButton = new RadioButton(20, 1);

            radioButton.Text     = "Group 1 Option 1";
            radioButton.Position = new Point(28, 12);
            Add(radioButton);

            radioButton          = new RadioButton(20, 1);
            radioButton.Text     = "Group 1 Option 2";
            radioButton.Position = new Point(28, 13);
            Add(radioButton);

            var selButton = new SadConsole.Controls.SelectionButton(24, 1);

            selButton.Text     = "Selection Button 1";
            selButton.Position = new Point(1, 15);
            Add(selButton);

            var selButton1 = new SadConsole.Controls.SelectionButton(24, 1);

            selButton1.Text     = "Selection Button 2";
            selButton1.Position = new Point(1, 16);
            Add(selButton1);

            var selButton2 = new SadConsole.Controls.SelectionButton(24, 1);

            selButton2.Text     = "Selection Button 3";
            selButton2.Position = new Point(1, 17);
            Add(selButton2);

            selButton.PreviousSelection  = selButton2;
            selButton.NextSelection      = selButton1;
            selButton1.PreviousSelection = selButton;
            selButton1.NextSelection     = selButton2;
            selButton2.PreviousSelection = selButton1;
            selButton2.NextSelection     = selButton;

            var input = new TextBox(20);

            input.Position = new Point(1, 20);
            Add(input);

            var checkbox = new SadConsole.Controls.CheckBox(13, 1)
            {
                Text     = "Check box",
                Position = new Point(24, 20)
            };

            Add(checkbox);
        }
Exemple #13
0
        public ControlsTest() : base(80, 23)
        {
            var prog1 = new ProgressBar(10, 1, HorizontalAlignment.Left);

            prog1.Position = new Point(16, 5);
            Add(prog1);

            var prog2 = new ProgressBar(1, 6, VerticalAlignment.Bottom);

            prog2.Position = new Point(18, 7);
            Add(prog2);

            var slider = new ScrollBar(Orientation.Horizontal, 10);

            slider.Position = new Point(16, 3);
            slider.Maximum  = 18;
            Add(slider);

            slider          = new ScrollBar(Orientation.Vertical, 6);
            slider.Position = new Point(16, 7);
            slider.Maximum  = 6;
            Add(slider);

            progressTimer = new Timer(0.5, (timer, time) => { prog1.Progress = prog1.Progress >= 1f ? 0f : prog1.Progress + 0.1f; prog2.Progress = prog2.Progress >= 1f ? 0f : prog2.Progress + 0.1f; });

            var listbox = new SadConsole.Controls.ListBox(20, 6);

            listbox.Position = new Point(28, 3);
            listbox.Items.Add("item 1");
            listbox.Items.Add("item 2");
            listbox.Items.Add("item 3");
            listbox.Items.Add("item 4");
            listbox.Items.Add("item 5");
            listbox.Items.Add("item 6");
            listbox.Items.Add("item 7");
            listbox.Items.Add("item 8");
            Add(listbox);

            var radioButton = new RadioButton(20, 1);

            radioButton.Text     = "Group 1 Option 1";
            radioButton.Position = new Point(28, 12);
            Add(radioButton);

            radioButton          = new RadioButton(20, 1);
            radioButton.Text     = "Group 1 Option 2";
            radioButton.Position = new Point(28, 13);
            Add(radioButton);

            var selButton = new SadConsole.Controls.SelectionButton(24, 1);

            selButton.Text     = "Selection Button 1";
            selButton.Position = new Point(51, 3);
            Add(selButton);

            var selButton1 = new SadConsole.Controls.SelectionButton(24, 1);

            selButton1.Text     = "Selection Button 2";
            selButton1.Position = new Point(51, 4);
            Add(selButton1);

            var selButton2 = new SadConsole.Controls.SelectionButton(24, 1);

            selButton2.Text     = "Selection Button 3";
            selButton2.Position = new Point(51, 5);
            Add(selButton2);

            selButton.PreviousSelection  = selButton2;
            selButton.NextSelection      = selButton1;
            selButton1.PreviousSelection = selButton;
            selButton1.NextSelection     = selButton2;
            selButton2.PreviousSelection = selButton1;
            selButton2.NextSelection     = selButton;

            var input = new TextBox(10);

            input.Position = new Point(51, 9);
            Add(input);

            var password = new TextBox(10);

            password.PasswordChar = "*";
            password.Position     = new Point(65, 9);
            Add(password);

            var button = new SadConsole.Controls.Button(11, 1)
            {
                Text     = "Click",
                Position = new Point(1, 3)
            };

            button.Click += (s, a) => Window.Message("This has been clicked -- and your password field contains '" + password.Text + "'", "Close");
            Add(button);

            button = new SadConsole.Controls.Button(11, 3)
            {
                Text     = "Click",
                Position = new Point(1, 5),
                Theme    = new Button3dTheme()
            };
            Add(button);

            button = new SadConsole.Controls.Button(11, 3)
            {
                Text     = "Click",
                Position = new Point(1, 10),
                Theme    = new ButtonLinesTheme()
            };
            Add(button);

            var checkbox = new SadConsole.Controls.CheckBox(13, 1)
            {
                Text     = "Check box",
                Position = new Point(51, 13)
            };

            Add(checkbox);

            FocusedControl = null;
            //DisableControlFocusing = true;

            List <Tuple <Color, string> > colors = new List <Tuple <Color, string> >();

            colors.Add(new Tuple <Color, string>(Library.Default.Colors.Red, "Red"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.RedDark, "DRed"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.Purple, "Prp"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.PurpleDark, "DPrp"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.Blue, "Blu"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.BlueDark, "DBlu"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.Cyan, "Cya"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.CyanDark, "DCya"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.Green, "Gre"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.GreenDark, "DGre"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.Yellow, "Yel"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.YellowDark, "DYel"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.Orange, "Ora"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.OrangeDark, "DOra"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.Brown, "Bro"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.BrownDark, "DBrow"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.Gray, "Gray"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.GrayDark, "DGray"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.White, "White"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.Black, "Black"));

            backgroundcycle = colors.Select(i => i.Item1).ToArray();
            backIndex       = 5;


            //int y = 25 - 20;
            //int x = 0;
            //int colorLength = 4;
            //foreach (var color1 in colors)
            //{
            //    foreach (var color2 in colors)
            //    {
            //        _Print(x, y, new ColoredString(color2.Item2.PadRight(colorLength).Substring(0, colorLength), color2.Item1, color1.Item1, null));
            //        y++;
            //    }

            //    y = 25 -20;
            //    x += colorLength;
            //}
        }
        public EditHotspotPopup(Hotspot oldHotspot)
            : base(39, 29)
        {
            textSurface.Font = Settings.Config.ScreenFont;
            Title = "Hotspot Editor";

            CreatedHotspot = new Hotspot();
            CreatedHotspot.Title = oldHotspot.Title;
            CreatedHotspot.Positions = new List<Point>(oldHotspot.Positions);
            oldHotspot.DebugAppearance.CopyAppearanceTo(CreatedHotspot.DebugAppearance);

            foreach (var key in oldHotspot.Settings.Keys)
                CreatedHotspot.Settings[key] = oldHotspot.Settings[key];

            // Settings of the appearance fields
            nameInput = new InputBox(13);
            characterPicker = new SadConsoleEditor.Controls.CharacterPicker(Settings.Red, Settings.Color_ControlBack, Settings.Green);
            foregroundPresenter = new SadConsoleEditor.Controls.ColorPresenter("Foreground", Settings.Green, 18);
            backgroundPresenter = new SadConsoleEditor.Controls.ColorPresenter("Background", Settings.Green, 18);
            characterPresenter = new SadConsoleEditor.Controls.ColorPresenter("Preview", Settings.Green, 18);
            mirrorHorizCheck = new CheckBox(18, 1);
            mirrorVertCheck = new CheckBox(18, 1);

            characterPicker.SelectedCharacterChanged += (o, e) => characterPresenter.Character = characterPicker.SelectedCharacter;
            foregroundPresenter.ColorChanged += (o, e) => characterPresenter.CharacterColor = foregroundPresenter.SelectedColor;
            backgroundPresenter.ColorChanged += (o, e) => characterPresenter.SelectedColor = backgroundPresenter.SelectedColor;

            Print(2, 2, "Name", Settings.Green);
            nameInput.Position = new Point(7, 2);
            foregroundPresenter.Position = new Point(2, 4);
            backgroundPresenter.Position = new Point(2, 5);
            characterPresenter.Position = new Point(2, 6);
            characterPicker.Position = new Point(21, 2);
            mirrorHorizCheck.Position = new Point(2, 7);
            mirrorVertCheck.Position = new Point(2, 8);

            nameInput.Text = "New";

            mirrorHorizCheck.IsSelectedChanged += Mirror_IsSelectedChanged;
            mirrorVertCheck.IsSelectedChanged += Mirror_IsSelectedChanged;
            mirrorHorizCheck.Text = "Mirror Horiz.";
            mirrorVertCheck.Text = "Mirror Vert.";

            foregroundPresenter.SelectedColor = Color.White;
            backgroundPresenter.SelectedColor = Color.DarkRed;

            characterPresenter.CharacterColor = foregroundPresenter.SelectedColor;
            characterPresenter.SelectedColor = backgroundPresenter.SelectedColor;
            characterPicker.SelectedCharacter = 1;

            Add(characterPicker);
            Add(nameInput);
            Add(foregroundPresenter);
            Add(backgroundPresenter);
            Add(characterPresenter);
            Add(mirrorHorizCheck);
            Add(mirrorVertCheck);

            // Setting controls of the game object
            objectSettingsListbox = new ListBox(18, 7);
            settingNameInput = new InputBox(18);
            settingValueInput = new InputBox(18);
            objectSettingsListbox.HideBorder = true;

            Print(2, 10, "Settings/Flags", Settings.Green);
            objectSettingsListbox.Position = new Point(2, 11);

            Print(2, 19, "Setting Name", Settings.Green);
            Print(2, 22, "Setting Value", Settings.Green);
            settingNameInput.Position = new Point(2, 20);
            settingValueInput.Position = new Point(2, 23);

            addFieldButton = new Button(16, 1);
            addFieldButton.Text = "Save/Update";
            addFieldButton.Position = new Point(textSurface.Width - 18, 20);

            removeFieldButton = new Button(16, 1);
            removeFieldButton.Text = "Remove";
            removeFieldButton.Position = new Point(textSurface.Width - 18, 21);
            removeFieldButton.IsEnabled = false;

            objectSettingsListbox.SelectedItemChanged += _objectSettingsListbox_SelectedItemChanged;
            addFieldButton.ButtonClicked += _addFieldButton_ButtonClicked;
            removeFieldButton.ButtonClicked += _removeFieldButton_ButtonClicked;

            Add(objectSettingsListbox);
            Add(settingNameInput);
            Add(settingValueInput);
            Add(addFieldButton);
            Add(removeFieldButton);

            // Save/close buttons
            saveButton = new Button(10, 1);
            cancelButton = new Button(10, 1);

            saveButton.Text = "Save";
            cancelButton.Text = "Cancel";

            saveButton.ButtonClicked += _saveButton_ButtonClicked;
            cancelButton.ButtonClicked += (o, e) => { DialogResult = false; Hide(); };

            saveButton.Position = new Point(textSurface.Width - 12, 26);
            cancelButton.Position = new Point(2, 26);

            Add(saveButton);
            Add(cancelButton);

            // Read the gameobject
            nameInput.Text = CreatedHotspot.Title;
            mirrorHorizCheck.IsSelected = (CreatedHotspot.DebugAppearance.SpriteEffect & Microsoft.Xna.Framework.Graphics.SpriteEffects.FlipHorizontally) == Microsoft.Xna.Framework.Graphics.SpriteEffects.FlipHorizontally;
            mirrorVertCheck.IsSelected = (CreatedHotspot.DebugAppearance.SpriteEffect & Microsoft.Xna.Framework.Graphics.SpriteEffects.FlipVertically) == Microsoft.Xna.Framework.Graphics.SpriteEffects.FlipVertically;
            characterPicker.SelectedCharacter = CreatedHotspot.DebugAppearance.GlyphIndex;
            foregroundPresenter.SelectedColor = CreatedHotspot.DebugAppearance.Foreground;
            backgroundPresenter.SelectedColor = CreatedHotspot.DebugAppearance.Background;

            foreach (var item in CreatedHotspot.Settings)
            {
                var newSetting = new SettingKeyValue() { Key = item.Key, Value = item.Value };
                objectSettingsListbox.Items.Add(newSetting);
            }

            Redraw();
        }