예제 #1
0
        public static void Prompt(ColoredString message, string yesPrompt, string noPrompt, Action<bool> resultCallback)
        {
            Window window = new Window(message.ToString().Length + 4, 6);

            message.IgnoreBackground = true;

            window._cellData.Print(2, 2, message);

            Button yesButton = new Button(yesPrompt.Length + 2, 1);
            Button noButton = new Button(noPrompt.Length + 2, 1);

            yesButton.Position = new Microsoft.Xna.Framework.Point(2, window._cellData.Height - 2);
            noButton.Position = new Microsoft.Xna.Framework.Point(window._cellData.Width - noButton.Width - 2, window._cellData.Height - 2);

            yesButton.Text = yesPrompt;
            noButton.Text = noPrompt;

            yesButton.ButtonClicked += (o, e) => { window.DialogResult = true; window.Hide(); };
            noButton.ButtonClicked += (o, e) => { window.DialogResult = false; window.Hide(); };

            window.Add(yesButton);
            window.Add(noButton);

            window.Closed += (o, e) =>
                {
                    resultCallback(window.DialogResult);
                };

            window.Show(true);
            window.Center();
        }
        public AnimationSpeedPopup(float speed)
            : base(22, 6)
        {
            Title = "Animation Speed";

            okButton = new Button(8, 1);
            cancelButton = new Button(8, 1);
            textBox = new InputBox(textSurface.Width - 4);
            textBox.IsNumeric = true;
            textBox.AllowDecimal = true;
            textBox.Text = speed.ToString();

            okButton.Position = new Microsoft.Xna.Framework.Point(textSurface.Width - okButton.Width - 2, textSurface.Height - 2);
            cancelButton.Position = new Microsoft.Xna.Framework.Point(2, textSurface.Height - 2);
            textBox.Position = new Microsoft.Xna.Framework.Point(2, 2);

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

            okButton.Text = "Ok";
            cancelButton.Text = "Cancel";

            Add(okButton);
            Add(cancelButton);
            Add(textBox);
        }
예제 #3
0
        public CharacterViewer()
            : base(27, 20)
        {
            //DefaultShowLocation = StartupLocation.CenterScreen;
            //Fill(Color.White, Color.Black, 0, null);
            Title = (char)198 + "Character" + (char)198;
            TitleAlignment = System.Windows.HorizontalAlignment.Left;
            //SetTitle(" Characters ", System.Windows.HorizontalAlignment.Center, Color.Blue, Color.LightGray);
            CloseOnESC = true;

            // CHARACTER SCROLL
            _charScrollBar = ScrollBar.Create(System.Windows.Controls.Orientation.Vertical, 16);
            _charScrollBar.Position = new Point(17, 1);
            _charScrollBar.Name = "ScrollBar";
            _charScrollBar.Maximum = textSurface.Font.Rows - 16;
            _charScrollBar.Value = 0;
            _charScrollBar.ValueChanged += new EventHandler(_charScrollBar_ValueChanged);
            _charScrollBar.IsEnabled = textSurface.Font.Rows > 16;

            // Effects
            effects = new EffectsManager(textSurface);

            // Add all controls
            this.Add(_charScrollBar);

            _closeButton = new Button(6) { Text = "Ok", Position = new Point(19, 1) }; Add(_closeButton); _closeButton.Click += (sender, e) => { DialogResult = true; Hide(); };

            _highlightedCellEffect.Foreground = Color.Blue;
            _highlightedCellEffect.Background = ColorHelper.DarkGray;

            // The frame will have been drawn by the base class, so redraw and our close button will be put on top of it
            Redraw();
        }
예제 #4
0
        public RenamePopup(string text, string title = "Rename")
            : base(22, 7)
        {
            Title = title;

            okButton = new Button(8, 1);
            cancelButton = new Button(8, 1);
            textBox = new InputBox(textSurface.Width - 4);
            textBox.Text = text;

            okButton.Position = new Microsoft.Xna.Framework.Point(textSurface.Width - okButton.Width - 2, textSurface.Height - 3);
            cancelButton.Position = new Microsoft.Xna.Framework.Point(2, textSurface.Height - 3);
            textBox.Position = new Microsoft.Xna.Framework.Point(2, 2);

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

            okButton.Text = "Ok";
            cancelButton.Text = "Cancel";

            Add(okButton);
            Add(cancelButton);
            Add(textBox);

            FocusedControl = textBox;
        }
예제 #5
0
        public KeyValueEditPopup(Dictionary<string, string> settings)
            : base(55, 18)
        {
            Title = "Settings";

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

            objectSettingsListbox.Position = new Point(2, 3);
            settingNameInput.Position = new Point(objectSettingsListbox.Bounds.Right + 1, objectSettingsListbox.Bounds.Top);
            settingValueInput.Position = new Point(objectSettingsListbox.Bounds.Right + 1, settingNameInput.Bounds.Bottom + 2);

            addFieldButton = new Button(14, 1);
            addFieldButton.Text = "Add/Update";
            addFieldButton.Position = new Point(settingValueInput.Bounds.Left, settingValueInput.Bounds.Bottom + 1);

            removeFieldButton = new Button(14, 1);
            removeFieldButton.Text = "Remove";
            removeFieldButton.Position = new Point(objectSettingsListbox.Bounds.Left, objectSettingsListbox.Bounds.Bottom + 1);
            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, 16);
            cancelButton.Position = new Point(2, 16);

            Add(saveButton);
            Add(cancelButton);

            // Read the settings
            foreach (var item in settings)
                objectSettingsListbox.Items.Add(new SettingKeyValue() { Key = item.Key, Value = item.Value });

            SettingsDictionary = settings;

            Redraw();
        }
예제 #6
0
        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;
        }
예제 #7
0
        public ResizeSurfacePopup(int width, int height)
            : base(22, 7)
        {
            //this.DefaultShowPosition = StartupPosition.CenterScreen;
            Title = "Resize";

            textSurface.DefaultBackground = Settings.Color_MenuBack;
            textSurface.DefaultForeground = Settings.Color_TitleText;

            okButton = new Button(8, 1)
            {
                Text = "Accept",
                Position = new Microsoft.Xna.Framework.Point(base.TextSurface.Width - 10, 5)
            };
            okButton.ButtonClicked += new EventHandler(_okButton_Action);

            cancelButton = new Button(8, 1)
            {
                Text = "Cancel",
                Position = new Microsoft.Xna.Framework.Point(2, 5)
            };
            cancelButton.ButtonClicked += new EventHandler(_cancelButton_Action);

            //Print(2, 3, "Name");
            Print(2, 2, "Width");
            Print(2, 3, "Height");

            widthBox = new InputBox(3)
            {
                Text = width.ToString(),
                MaxLength = 3,
                IsNumeric = true,
                Position = new Microsoft.Xna.Framework.Point(base.TextSurface.Width - 5, 2)
            };

            heightBox = new InputBox(3)
            {
                Text = height.ToString(),
                MaxLength = 3,
                IsNumeric = true,
                Position = new Microsoft.Xna.Framework.Point(base.TextSurface.Width - 5, 3)
            };

            //_name = new InputBox(20)
            //{
            //    Text = name,
            //    Position = new Microsoft.Xna.Framework.Point(9, 3)
            //};

            Add(widthBox);
            Add(heightBox);
            Add(cancelButton);
            Add(okButton);
            //Add(_name);
        }
        public AnimationFramesPanel(Action<TextSurfaceBasic> frameChangeCallback)
        {
            Title = "Frames";

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

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

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

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

            addNewFrameFromFile = new Button(Consoles.ToolPane.PanelWidthControls, 1);
            addNewFrameFromFile.Text = "Load From File";
            addNewFrameFromFile.ButtonClicked += addNewFrameFromFile_ButtonClicked;

            saveFrameToFile = new Button(Consoles.ToolPane.PanelWidthControls, 1);
            saveFrameToFile.Text = "Save Frame to File";
            saveFrameToFile.ButtonClicked += saveFrameToFile_ButtonClicked;

            clonePreviousFrame = new Button(Consoles.ToolPane.PanelWidthControls, 1);
            clonePreviousFrame.Text = "Copy prev. frame";
            clonePreviousFrame.ButtonClicked += clonePreviousFrame_ButtonClicked;

            // Frames area
            framesCounterBox = new DrawingSurface(Consoles.ToolPane.PanelWidthControls, 1);

            nextFrame = new Button(4, 1);
            nextFrame.Text = ">>";
            nextFrame.ShowEnds = false;
            nextFrame.ButtonClicked += nextFrame_ButtonClicked;

            previousFrame = new Button(4, 1);
            previousFrame.Text = "<<";
            previousFrame.ShowEnds = false;
            previousFrame.ButtonClicked += previousFrame_ButtonClicked;

            this.frameChangeCallback = frameChangeCallback;

            Controls = new ControlBase[] { framesCounterBox, previousFrame, nextFrame, removeSelected, addNewFrame, clonePreviousFrame, moveSelectedUp, moveSelectedDown, addNewFrameFromFile, saveFrameToFile};
        }
        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);
        }
예제 #10
0
        public FilesPanel()
        {
            Title = "File";

            NewButton = new Button(7, 1)
            {
                Text = "New",
                CanUseKeyboard = false,
            };
            NewButton.ButtonClicked += (o, e) => EditorConsoleManager.ShowNewEditorPopup();

            LoadButton = new Button(8, 1)
            {
                Text = "Load",
            };
            LoadButton.ButtonClicked += (o, e) => EditorConsoleManager.ShowLoadEditorPopup();

            SaveButton = new Button(8, 1)
            {
                Text = "Save",
            };
            SaveButton.ButtonClicked += (o, e) => EditorConsoleManager.SaveEditor();

            ResizeButton = new Button(10, 1)
            {
                Text = "Resize",
            };
            ResizeButton.ButtonClicked += (o, e) => EditorConsoleManager.ShowResizeEditorPopup();

            CloseButton = new Button(9, 1)
            {
                Text = "Close",
            };
            CloseButton.ButtonClicked += (o, e) => EditorConsoleManager.ShowCloseConsolePopup();

            DocumentsListbox = new ListBox<EditorListBoxItem>(Consoles.ToolPane.PanelWidthControls, 6);
            DocumentsListbox.HideBorder = true;
            DocumentsListbox.CompareByReference = true;

            DocumentsListbox.SelectedItemChanged += DocumentsListbox_SelectedItemChanged;

            documentsTitle = new DrawingSurface(13, 1);
            documentsTitle.Fill(Settings.Green, Settings.Color_MenuBack, 0, null);
            documentsTitle.Print(0, 0, new ColoredString("Opened Files", Settings.Green, Settings.Color_MenuBack));

            Controls = new ControlBase[] { NewButton, LoadButton, SaveButton, ResizeButton, CloseButton, documentsTitle, DocumentsListbox };
        }
        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);
        }
예제 #12
0
        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 };
        }
        public PreviewAnimationPopup(AnimatedTextSurface animation)
            : base(animation.Width + 2, animation.Height + 4)
        {
            textSurface.Font = Settings.Config.ScreenFont;
            this.animation = animation;

            CloseOnESC = true;
            entity = new GameObject(Settings.Config.ScreenFont);
            entity.Position = new Point(1, 1);
            entity.Animation = animation;
            animation.Restart();
            entity.Animation.Start();

            restartAnimation = new Button(animation.Width, 1);
            restartAnimation.Text = "Restart";
            restartAnimation.Position = new Point(1, textSurface.Height - 2);
            restartAnimation.ButtonClicked += (s, e) => this.animation.Restart();
            Add(restartAnimation);
        }
예제 #14
0
        public GameObjectNamePanel()
        {
            Title = "Game Object";

            nameTitle = new DrawingSurface(Consoles.ToolPane.PanelWidth - 3, 2);

            setName = new Button(3, 1);
            setName.ShowEnds = false;
            setName.Text = "Set";

            setName.ButtonClicked += (s, e) =>
            {
                Windows.RenamePopup rename = new Windows.RenamePopup(entity.Name);
                rename.Closed += (s2, e2) => { if (rename.DialogResult) entity.Name = rename.NewName; PrintName(); };
                rename.Center();
                rename.Show(true);
            };

            Controls = new ControlBase[] { setName, nameTitle };
        }
예제 #15
0
        /// <summary>
        /// Displays a dialog to the user with a specific message.
        /// </summary>
        /// <param name="message">The message. (background color is ignored)</param>
        /// <param name="closeButtonText">The text of the dialog's close button.</param>
        /// <param name="closedCallback">A callback indicating the message was dismissed.</param>
        public static void Message(ColoredString message, string closeButtonText, Action closedCallback = null)
        {
            Window window = new Window(message.ToString().Length + 4, 6);

            message.IgnoreBackground = true;

            window.Print(2, 2, message);

            Button closeButton = new Button(closeButtonText.Length + 2);

            closeButton.Position = new Point(2, window.textSurface.Height - 2);

            closeButton.Text = closeButtonText;

            closeButton.Click += (o, e) => { window.DialogResult = true; window.Hide(); closedCallback?.Invoke(); };

            window.Add(closeButton);

            window.Show(true);
            window.Center();
        }
예제 #16
0
        public static void Message(ColoredString message, string closeButtonText)
        {
            Window window = new Window(message.ToString().Length + 4, 6);

            message.IgnoreBackground = true;

            window._cellData.Print(2, 2, message);

            Button closeButton = new Button(closeButtonText.Length + 2, 1);

            closeButton.Position = new Microsoft.Xna.Framework.Point(2, window._cellData.Height - 2);

            closeButton.Text = closeButtonText;

            closeButton.ButtonClicked += (o, e) => { window.DialogResult = true; window.Hide(); };

            window.Add(closeButton);

            window.Show(true);
            window.Center();
        }
예제 #17
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));
        }
    }
예제 #18
0
        public SelectionToolPanel(Action<TextSurface> loadBrushHandler, Func<TextSurface> saveBrushHandler)
        {
            reset = new Button(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 1);
            reset.Text = "Reset Steps";
            reset.ButtonClicked += (o, e) => State = CloneState.SelectingPoint1;

            loadBrush = new Button(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 1);
            loadBrush.Text = "Import Brush";
            loadBrush.ButtonClicked += _loadBrush_ButtonClicked;

            saveBrush = new Button(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls, 1);
            saveBrush.Text = "Export Brush";
            saveBrush.ButtonClicked += _saveBrush_ButtonClicked;

            clone = new Button(Consoles.ToolPane.PanelWidthControls, 1);
            clone.Text = "Clone";
            clone.ButtonClicked += clone_ButtonClicked;

            clear = new Button(Consoles.ToolPane.PanelWidthControls, 1);
            clear.Text = "Clear";
            clear.ButtonClicked += clear_ButtonClicked;

            move = new Button(Consoles.ToolPane.PanelWidthControls, 1);
            move.Text = "Move";
            move.ButtonClicked += move_ButtonClicked;

            Controls = new ControlBase[] { reset, loadBrush, saveBrush, clone, clear, move };

            this.loadBrushHandler = loadBrushHandler;
            this.saveBrushHandler = saveBrushHandler;

            Title = "Clone";
            State = CloneState.SelectingPoint1;
        }
예제 #19
0
        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 };
        }
예제 #20
0
        private void InitializeControls()
        {
            symbolsList = new ListBox(4, Height - 5)
            {
                Position = new Point(Width - 5, 2)
            };
            for (int index = 0; index < Font.MaxGlyphIndex; index++)
            {
                symbolsList.Items.Add((char)index);
            }
            symbolsList.SelectedItemChanged += symbolsList_SelectedItemChanged;
            Add(symbolsList);

            var foreColorButton = new Button(1)
            {
                Position = new Point(1, 2),
                CanFocus = false,
                Text     = "Q"
            };

            foreColorButton.Click += foreColorButton_Click;
            Add(foreColorButton);

            var clearForeColorButton = new Button(1)
            {
                Position = new Point(2, 2),
                CanFocus = false,
                Text     = "C"
            };

            clearForeColorButton.Click += clearForeColorButton_Click;
            Add(clearForeColorButton);

            var backColorButton = new Button(1)
            {
                Position = new Point(1, 3),
                CanFocus = false,
                Text     = "Q"
            };

            backColorButton.Click += backColorButton_Click;
            Add(backColorButton);

            var clearBackColorButton = new Button(1)
            {
                Position = new Point(2, 3),
                CanFocus = false,
                Text     = "C"
            };

            clearBackColorButton.Click += clearBackColorButton_Click;
            Add(clearBackColorButton);

            var newImageButton = new Button(6)
            {
                Position = new Point(1, 11),
                Text     = "New",
                CanFocus = false
            };

            newImageButton.Click += newImageButton_Click;
            Add(newImageButton);

            var setBackgroundColor = new Button(6)
            {
                Position = new Point(1, 5),
                Text     = "Back",
                CanFocus = false
            };

            setBackgroundColor.Click += setBackgroundColor_Click;
            Add(setBackgroundColor);

            var loadImageButton = new Button(6)
            {
                Position = new Point(1, 7),
                Text     = "Load",
                CanFocus = false
            };

            loadImageButton.Click += loadImageButton_Click;
            Add(loadImageButton);

            var saveImageButton = new Button(6)
            {
                Position = new Point(1, 9),
                Text     = "Save",
                CanFocus = false
            };

            saveImageButton.Click += saveImageButton_Click;
            Add(saveImageButton);

            var incNewImageWidth = new Button(1)
            {
                Position = new Point(18, 20),
                Text     = "^",
                CanFocus = false
            };

            incNewImageWidth.Click += (sender, args) => newImageWidth++;
            Add(incNewImageWidth);

            var decNewImageWidth = new Button(1)
            {
                Position = new Point(24, 20),
                Text     = "v",
                CanFocus = false
            };

            decNewImageWidth.Click += (sender, args) => newImageWidth = Math.Max(1, newImageWidth - 1);
            Add(decNewImageWidth);

            var incNewImageHeight = new Button(1)
            {
                Position = new Point(18, 22),
                Text     = "^",
                CanFocus = false
            };

            incNewImageHeight.Click += (sender, args) => newImageHeight++;
            Add(incNewImageHeight);

            var decNewImageHeight = new Button(1)
            {
                Position = new Point(24, 22),
                Text     = "v",
                CanFocus = false
            };

            decNewImageHeight.Click += (sender, args) => newImageHeight = Math.Max(1, newImageHeight - 1);
            Add(decNewImageHeight);

            InitializeImageControl();
        }
예제 #21
0
        public MainMenu(int Width, int Height) : base(Width, Height)
        {
            FontMaster fontMaster = SadConsole.Global.LoadFont("cp437_10_ext.font");
            Font       titleFont  = fontMaster.GetFont(Font.FontSizes.Four);

            Basic title = new SadConsole.Surfaces.Basic(20, 1);

            title.Font     = titleFont;
            title.Position = new Point(Width / 4 - "Main Menu".Length / 2, 2);
            title.Print(0, 0, "Main Menu");

            Children.Add(title);

            var tetrisButton = new SadConsole.Controls.Button(11, 3);

            tetrisButton.Text          = "Tetris";
            tetrisButton.TextAlignment = HorizontalAlignment.Center;
            tetrisButton.Position      = new Point(Width / 2 - tetrisButton.Width / 2, 10);
            tetrisButton.Theme         = new SadConsole.Themes.ButtonLinesTheme();

            Add(tetrisButton);

            tetrisButton.Click += (btn, args) =>
            {
                Program.MainMenu.Hide();
                Program.TetrisWindow.Show();
            };

            var snakeButton = new SadConsole.Controls.Button(11, 3);

            snakeButton.Position      = new Point(Width / 2 - snakeButton.Width / 2, 14);
            snakeButton.TextAlignment = HorizontalAlignment.Center;
            snakeButton.Text          = "Snake";
            snakeButton.Theme         = new SadConsole.Themes.ButtonLinesTheme();

            Add(snakeButton);

            snakeButton.Click += (btn, args) =>
            {
                Program.MainMenu.Hide();
                Program.SnakeWindow.Show();
            };

            var themeButton = new SadConsole.Controls.Button(11, 3);

            themeButton.Position      = new Point(Width / 2 - snakeButton.Width / 2, 18);
            themeButton.TextAlignment = HorizontalAlignment.Center;
            themeButton.Text          = "Theme";
            themeButton.Theme         = new SadConsole.Themes.ButtonLinesTheme();

            Add(themeButton);

            themeButton.Click += (btn, args) =>
            {
                Program.MainMenu.Hide();
                Program.ThemeEditor.Show();
            };

            var viewerButton = new SadConsole.Controls.Button(11, 3);

            viewerButton.Position      = new Point(Width / 2 - snakeButton.Width / 2, 22);
            viewerButton.TextAlignment = HorizontalAlignment.Center;
            viewerButton.Text          = "Viewer";
            viewerButton.Theme         = new SadConsole.Themes.ButtonLinesTheme();

            Add(viewerButton);

            viewerButton.Click += (btn, args) =>
            {
                Program.MainMenu.Hide();
                Program.TilesetViewer.Show();
            };

            var mapViewButton = new SadConsole.Controls.Button(11, 3);

            mapViewButton.Position      = new Point(Width / 2 - snakeButton.Width / 2, 26);
            mapViewButton.TextAlignment = HorizontalAlignment.Center;
            mapViewButton.Text          = "MapView";
            mapViewButton.Theme         = new SadConsole.Themes.ButtonLinesTheme();

            Add(mapViewButton);

            mapViewButton.Click += (btn, args) =>
            {
                Program.MainMenu.Hide();
                //Children.Add( Program.MapView );
                //Global.CurrentScreen = Program.MapView;
                Program.MapView.Show();
                Global.FocusedConsoles.Set(Program.MapView);
            };

            var themeRadioButton = new RadioButton(10, 1);

            themeRadioButton.Text      = "Light";
            themeRadioButton.Position  = new Point(60, 2);
            themeRadioButton.GroupName = "Theme";
            Add(themeRadioButton);
            themeRadioButton.IsSelectedChanged += OnThemeRadioChanged;

            themeRadioButton           = new RadioButton(10, 1);
            themeRadioButton.Text      = "Dark";
            themeRadioButton.Position  = new Point(60, 4);
            themeRadioButton.GroupName = "Theme";
            Add(themeRadioButton);
            themeRadioButton.IsSelectedChanged += OnThemeRadioChanged;
        }
예제 #22
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;
            //}
        }
예제 #23
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;
            //}
        }
예제 #24
0
        public SelectFilePopup()
            : base(70, 30)
        {
            Title = "Select File";

            fileLoadersList = new ListBox<FileLoaderListBoxItem>(15, Height - 7);
            fileLoadersList.Position = new Point(2, 4);
            fileLoadersList.SelectedItemChanged += FileLoadersList_SelectedItemChanged;
            fileLoadersList.HideBorder = true;
            Print(fileLoadersList.Bounds.Left, fileLoadersList.Bounds.Top - 2, "Type of file", Settings.Color_TitleText);
            Print(fileLoadersList.Bounds.Left, fileLoadersList.Bounds.Top - 1, new string((char)196, fileLoadersList.Width));

            directoryListBox = new SadConsoleEditor.Controls.FileDirectoryListbox(this.TextSurface.Width - fileLoadersList.Bounds.Right - 3, Height - 10)
            {
                Position = new Point(fileLoadersList.Bounds.Right + 1, fileLoadersList.Bounds.Top),
                HideBorder = true
            };
            directoryListBox.HighlightedExtentions = ".con;.console;.brush";
            directoryListBox.SelectedItemChanged += _directoryListBox_SelectedItemChanged;
            directoryListBox.SelectedItemExecuted += _directoryListBox_SelectedItemExecuted;
            directoryListBox.CurrentFolder = Environment.CurrentDirectory;
            //directoryListBox.HideBorder = true;

            Print(directoryListBox.Bounds.Left, directoryListBox.Bounds.Top - 2, "Files/Directories", Settings.Color_TitleText);
            Print(directoryListBox.Bounds.Left, directoryListBox.Bounds.Top - 1, new string((char)196, directoryListBox.Width));

            fileName = new InputBox(directoryListBox.Width)
            {
                Position = new Point(directoryListBox.Bounds.Left, directoryListBox.Bounds.Bottom + 2),
            };
            fileName.TextChanged += _fileName_TextChanged;
            Print(fileName.Bounds.Left, fileName.Bounds.Top - 1, "Selected file", Settings.Color_TitleText);

            selectButton = new Button(8, 1)
            {
                Text = "Open",
                Position = new Point(Width - 10, this.TextSurface.Height - 2),
                IsEnabled = false
            };
            selectButton.ButtonClicked += new EventHandler(_selectButton_Action);

            cancelButton = new Button(8, 1)
            {
                Text = "Cancel",
                Position = new Point(2, this.TextSurface.Height - 2)
            };
            cancelButton.ButtonClicked += new EventHandler(_cancelButton_Action);

            Add(directoryListBox);
            Add(fileName);
            Add(selectButton);
            Add(cancelButton);
            Add(fileLoadersList);
        }
예제 #25
0
        public NewConsolePopup()
            : base(40, 14)
        {
            //this.DefaultShowPosition = StartupPosition.CenterScreen;
            Title = "New Console";

            textSurface.DefaultBackground = Settings.Color_MenuBack;
            textSurface.DefaultForeground = Settings.Color_TitleText;
            Clear();
            Redraw();

            okButton = new Button(8, 1)
            {
                Text = "Accept",
                Position = new Microsoft.Xna.Framework.Point(base.TextSurface.Width - 10, 12)
            };
            okButton.ButtonClicked += new EventHandler(_okButton_Action);

            cancelButton = new Button(8, 1)
            {
                Text = "Cancel",
                Position = new Microsoft.Xna.Framework.Point(2, 12)
            };
            cancelButton.ButtonClicked += new EventHandler(_cancelButton_Action);

            //Print(2, 3, "Name");
            Print(2, 2, "Editor");
            Print(2, 7, "Width");
            Print(2, 8, "Height");

            editorsListBox = new ListBox(Width - 11, 4)
            {
                Position = new Point(9, 2),
                HideBorder = true
            };
            editorsListBox.SelectedItemChanged += editorsListBox_SelectedItemChanged;

            widthBox = new InputBox(3)
            {
                Text = "0",
                MaxLength = 3,
                IsNumeric = true,
                Position = new Microsoft.Xna.Framework.Point(base.TextSurface.Width - 5, 7)
            };

            heightBox = new InputBox(3)
            {
                Text = "0",
                MaxLength = 3,
                IsNumeric = true,
                Position = new Microsoft.Xna.Framework.Point(base.TextSurface.Width - 5, 8)
            };

            //_name = new InputBox(20)
            //{
            //    Text = name,
            //    Position = new Microsoft.Xna.Framework.Point(9, 3)
            //};

            _foregroundPicker = new SadConsoleEditor.Controls.ColorPresenter("Foreground", Theme.FillStyle.Foreground, textSurface.Width - 4);
            _foregroundPicker.Position = new Point(2, 9);
            _foregroundPicker.SelectedColor = Color.White;

            _backgroundPicker = new SadConsoleEditor.Controls.ColorPresenter("Background", Theme.FillStyle.Foreground, textSurface.Width - 4);
            _backgroundPicker.Position = new Point(2, 10);
            _backgroundPicker.SelectedColor = Color.Black;

            Add(editorsListBox);
            Add(widthBox);
            Add(heightBox);
            Add(cancelButton);
            Add(okButton);
            Add(_foregroundPicker);
            Add(_backgroundPicker);
            //Add(_name);

            foreach (var editor in EditorConsoleManager.Editors.Keys)
                editorsListBox.Items.Add(editor);

            editorsListBox.SelectedItem = editorsListBox.Items[0];
        }
예제 #26
0
        public OtherColorsPopup()
            : base(40, 20)
        {
            Center();

            _ansiSelectButton = new RadioButton(textSurface.Width - 4, 1);
            _ansiSelectButton.Position = new Point(2, 2);
            _ansiSelectButton.Text = "Ansi Colors";
            _ansiSelectButton.CanFocus = false;
            _ansiSelectButton.IsSelectedChanged += _ansiSelectButton_IsSelectedChanged;
            Add(_ansiSelectButton);

            _knownSelectButton = new RadioButton(textSurface.Width - 4, 1);
            _knownSelectButton.Position = new Point(2, 3);
            _knownSelectButton.Text = "List of Known Colors";
            _knownSelectButton.CanFocus = false;
            _knownSelectButton.IsSelectedChanged += _ansiSelectButton_IsSelectedChanged;
            Add(_knownSelectButton);

            #region Ansi Buttons
            int ansiButtonStartY = 5;
            int ansiButtonStartX = 3;
            int ansiButtonStartBrightX = 20;

            _ansiButtons[0] = new Button(15, 1);
            _ansiButtons[0].Position = new Point(ansiButtonStartX, ansiButtonStartY);
            _ansiButtons[0].Text = "Red Dark";
            _ansiButtons[0].Theme = CreateButtonTheme(ColorAnsi.Red, ColorAnsi.RedBright);
            _ansiButtons[0].DetermineAppearance();
            _ansiButtons[0].ButtonClicked += _ansiGreenBright_ButtonClicked;
            _ansiButtons[0].Click();
            Add(_ansiButtons[0]);

            _ansiButtons[1] = new Button(15, 1);
            _ansiButtons[1].Position = new Point(ansiButtonStartBrightX, ansiButtonStartY);
            _ansiButtons[1].Text = "Red Bright";
            _ansiButtons[1].Theme = CreateButtonTheme(ColorAnsi.RedBright, ColorAnsi.Red);
            _ansiButtons[1].DetermineAppearance();
            _ansiButtons[1].ButtonClicked += _ansiGreenBright_ButtonClicked;
            Add(_ansiButtons[1]);

            _ansiButtons[2] = new Button(15, 1);
            _ansiButtons[2].Position = new Point(ansiButtonStartX, ansiButtonStartY + 1);
            _ansiButtons[2].Text = "Yellow Dark";
            _ansiButtons[2].Theme = CreateButtonTheme(ColorAnsi.Yellow, ColorAnsi.YellowBright);
            _ansiButtons[2].DetermineAppearance();
            _ansiButtons[2].ButtonClicked += _ansiGreenBright_ButtonClicked;
            Add(_ansiButtons[2]);

            _ansiButtons[3] = new Button(15, 1);
            _ansiButtons[3].Position = new Point(ansiButtonStartBrightX, ansiButtonStartY + 1);
            _ansiButtons[3].Text = "Yellow Bright";
            _ansiButtons[3].Theme = CreateButtonTheme(ColorAnsi.YellowBright, ColorAnsi.Yellow);
            _ansiButtons[3].DetermineAppearance();
            _ansiButtons[3].ButtonClicked += _ansiGreenBright_ButtonClicked;
            Add(_ansiButtons[3]);

            _ansiButtons[4] = new Button(15, 1);
            _ansiButtons[4].Position = new Point(ansiButtonStartX, ansiButtonStartY + 2);
            _ansiButtons[4].Text = "Green Dark";
            _ansiButtons[4].Theme = CreateButtonTheme(ColorAnsi.Green, ColorAnsi.GreenBright);
            _ansiButtons[4].DetermineAppearance();
            _ansiButtons[4].ButtonClicked += _ansiGreenBright_ButtonClicked;
            Add(_ansiButtons[4]);

            _ansiButtons[5] = new Button(15, 1);
            _ansiButtons[5].Position = new Point(ansiButtonStartBrightX, ansiButtonStartY + 2);
            _ansiButtons[5].Text = "Green Bright";
            _ansiButtons[5].Theme = CreateButtonTheme(ColorAnsi.GreenBright, ColorAnsi.Green);
            _ansiButtons[5].DetermineAppearance();
            _ansiButtons[5].ButtonClicked += _ansiGreenBright_ButtonClicked;
            Add(_ansiButtons[5]);

            _ansiButtons[6] = new Button(15, 1);
            _ansiButtons[6].Position = new Point(ansiButtonStartX, ansiButtonStartY + 3);
            _ansiButtons[6].Text = "Cyan Dark";
            _ansiButtons[6].Theme = CreateButtonTheme(ColorAnsi.Cyan, ColorAnsi.CyanBright);
            _ansiButtons[6].DetermineAppearance();
            _ansiButtons[6].ButtonClicked += _ansiGreenBright_ButtonClicked;
            Add(_ansiButtons[6]);

            _ansiButtons[7] = new Button(15, 1);
            _ansiButtons[7].Position = new Point(ansiButtonStartBrightX, ansiButtonStartY + 3);
            _ansiButtons[7].Text = "Cyan Bright";
            _ansiButtons[7].Theme = CreateButtonTheme(ColorAnsi.CyanBright, ColorAnsi.Cyan);
            _ansiButtons[7].DetermineAppearance();
            _ansiButtons[7].ButtonClicked += _ansiGreenBright_ButtonClicked;
            Add(_ansiButtons[7]);

            _ansiButtons[8] = new Button(15, 1);
            _ansiButtons[8].Position = new Point(ansiButtonStartX, ansiButtonStartY + 4);
            _ansiButtons[8].Text = "Blue Dark";
            _ansiButtons[8].Theme = CreateButtonTheme(ColorAnsi.Blue, ColorAnsi.BlueBright);
            _ansiButtons[8].DetermineAppearance();
            _ansiButtons[8].ButtonClicked += _ansiGreenBright_ButtonClicked;
            Add(_ansiButtons[8]);

            _ansiButtons[9] = new Button(15, 1);
            _ansiButtons[9].Position = new Point(ansiButtonStartBrightX, ansiButtonStartY + 4);
            _ansiButtons[9].Text = "Blue Bright";
            _ansiButtons[9].Theme = CreateButtonTheme(ColorAnsi.BlueBright, ColorAnsi.Blue);
            _ansiButtons[9].DetermineAppearance();
            _ansiButtons[9].ButtonClicked += _ansiGreenBright_ButtonClicked;
            Add(_ansiButtons[9]);

            _ansiButtons[10] = new Button(15, 1);
            _ansiButtons[10].Position = new Point(ansiButtonStartX, ansiButtonStartY + 5);
            _ansiButtons[10].Text = "Magenta Dark";
            _ansiButtons[10].Theme = CreateButtonTheme(ColorAnsi.Magenta, ColorAnsi.MagentaBright);
            _ansiButtons[10].DetermineAppearance();
            _ansiButtons[10].ButtonClicked += _ansiGreenBright_ButtonClicked;
            Add(_ansiButtons[10]);

            _ansiButtons[11] = new Button(15, 1);
            _ansiButtons[11].Position = new Point(ansiButtonStartBrightX, ansiButtonStartY + 5);
            _ansiButtons[11].Text = "Magenta Bright";
            _ansiButtons[11].Theme = CreateButtonTheme(ColorAnsi.MagentaBright, ColorAnsi.Magenta);
            _ansiButtons[11].DetermineAppearance();
            _ansiButtons[11].ButtonClicked += _ansiGreenBright_ButtonClicked;
            Add(_ansiButtons[11]);

            _ansiButtons[12] = new Button(15, 1);
            _ansiButtons[12].Position = new Point(ansiButtonStartX, ansiButtonStartY + 6);
            _ansiButtons[12].Text = "Black Dark";
            _ansiButtons[12].Theme = CreateButtonTheme(ColorAnsi.Black, ColorAnsi.BlackBright);
            _ansiButtons[12].DetermineAppearance();
            _ansiButtons[12].ButtonClicked += _ansiGreenBright_ButtonClicked;
            Add(_ansiButtons[12]);

            _ansiButtons[13] = new Button(15, 1);
            _ansiButtons[13].Position = new Point(ansiButtonStartBrightX, ansiButtonStartY + 6);
            _ansiButtons[13].Text = "Black Bright";
            _ansiButtons[13].Theme = CreateButtonTheme(ColorAnsi.BlackBright, ColorAnsi.Black);
            _ansiButtons[13].DetermineAppearance();
            _ansiButtons[13].ButtonClicked += _ansiGreenBright_ButtonClicked;
            Add(_ansiButtons[13]);

            _ansiButtons[14] = new Button(15, 1);
            _ansiButtons[14].Position = new Point(ansiButtonStartX, ansiButtonStartY + 7);
            _ansiButtons[14].Text = "White Dark";
            _ansiButtons[14].Theme = CreateButtonTheme(ColorAnsi.White, ColorAnsi.WhiteBright);
            _ansiButtons[14].DetermineAppearance();
            _ansiButtons[14].ButtonClicked += _ansiGreenBright_ButtonClicked;
            Add(_ansiButtons[14]);

            _ansiButtons[15] = new Button(15, 1);
            _ansiButtons[15].Position = new Point(ansiButtonStartBrightX, ansiButtonStartY + 7);
            _ansiButtons[15].Text = "White Bright";
            _ansiButtons[15].Theme = CreateButtonTheme(ColorAnsi.WhiteBright, ColorAnsi.White);
            _ansiButtons[15].DetermineAppearance();
            _ansiButtons[15].ButtonClicked += _ansiGreenBright_ButtonClicked;
            Add(_ansiButtons[15]);
            #endregion

            #region Named Color Control
            _namedColorsList = new ListBox<ListBoxItemColor>(textSurface.Width - 4, textSurface.Height - 3 - ansiButtonStartY);
            _namedColorsList.Position = new Point(ansiButtonStartX - 1, ansiButtonStartY);
            Add(_namedColorsList);

            // Fill out the named colors
            Color testColor = Color.AliceBlue;
            Type colorType = testColor.GetType();
            if (null != colorType)
            {
                PropertyInfo[] propInfoList =
                 colorType.GetProperties(BindingFlags.Static | BindingFlags.DeclaredOnly
                    | BindingFlags.Public);
                int nNumProps = propInfoList.Length;
                for (int i = 0; i < nNumProps; i++)
                {
                    PropertyInfo propInfo = (PropertyInfo)propInfoList[i];
                    Color color = (Color)propInfo.GetValue(null, null);
                    _namedColorsList.Items.Add(new Tuple<Color, Color, string>(color, new Color(255 - color.R, 255 - color.G, 255 - color.B), propInfo.Name));
                }
            }
            _namedColorsList.SelectedItem = _namedColorsList.Items[0];
            #endregion

            _cancelButton = new Button(12, 1);
            _cancelButton.Position = new Point(2, textSurface.Height - 2);
            _cancelButton.Text = "Cancel";
            _cancelButton.ButtonClicked += (sender, e) => { DialogResult = false; Hide(); };
            Add(_cancelButton);

            _okButton = new Button(12, 1);
            _okButton.Position = new Point(textSurface.Width - 2 - _okButton.Width, textSurface.Height - 2);
            _okButton.Text = "OK";
            _okButton.ButtonClicked += (sender, e) => { SelectedColor = _ansiSelectButton.IsSelected ? _selectedAnsiColor : (Color)((Tuple<Color, Color, string>)_namedColorsList.SelectedItem).Item1; DialogResult = true; Hide(); };
            Add(_okButton);

            _ansiSelectButton.IsSelected = true;
            this.CloseOnESC = true;
            this.Title = "Pick a known color";
        }
예제 #27
0
        public ScanConsole(int width, int height) : base(width, height)
        {
            // Draw background.
            for (int i = 0; i < width; ++i)
            {
                for (int j = 1; j < height; j++)
                {
                    this.SetBackground(i, j, (j > 1 && j < 20) ? ColorAnsi.White : ColorAnsi.Blue);
                }
            }

            #region Gross Border Drawing

            // Draw Top Border
            for (int i = 1; i < width - 1; i++)
            {
                SetGlyph(i, 2, 196, ColorAnsi.WhiteBright);
            }

            // Draw Top Border Title
            Print((Width - SCANNER_TITLE.Length) / 2, 2, SCANNER_TITLE);

            // Draw Top Border Corners
            SetGlyph(0, 2, 218, ColorAnsi.WhiteBright);
            SetGlyph(Width - 1, 2, 191, ColorAnsi.WhiteBright);

            // Draw Border Edges
            for (int i = 3; i < 19; i++)
            {
                SetGlyph(0, i, 179, ColorAnsi.WhiteBright);
                SetGlyph(Width - 1, i, 179, ColorAnsi.WhiteBright);
            }

            // Draw Bottom Border
            for (int i = 1; i < width - 1; i++)
            {
                SetGlyph(i, 19, 196, ColorAnsi.WhiteBright);
            }

            SetGlyph(0, 19, 192, ColorAnsi.WhiteBright);
            SetGlyph(Width - 1, 19, 217, ColorAnsi.WhiteBright);

            // Draw Button Separator

            for (int i = 1; i < width - 1; i++)
            {
                SetGlyph(i, 17, 196, ColorAnsi.WhiteBright);
            }
            SetGlyph(0, 17, 195, ColorAnsi.WhiteBright);
            SetGlyph(Width - 1, 17, 180, ColorAnsi.WhiteBright);

            #endregion Gross Border Drawing

            // Draw bottom separator
            for (int i = 1; i < width - 1; i++)
            {
                SetGlyph(i, Height - 4, 196, ColorAnsi.White);
            }

            // Add Shop Button

            var shopButton = new SadConsole.Controls.Button(11)
            {
                Text     = "Store",
                Position = new Point(10, Height - 7),
            };
            shopButton.Click += (s, e) =>
            {
                // This is so not right to do, I hate gamedev
                Program.SwitchScreen();
            };
            Add(shopButton);

            var infoButton = new Button(10)
            {
                Text     = "AAAAH!",
                Position = new Point(23, Height - 7)
            };

            infoButton.Click += (s, e) =>
            {
                Window.Message(
                    "It's 1993 and the server hard drive has died!", "go on...", () =>
                {
                    Window.Message("Using your wits, maybe you can save it before the company dies.", "go on...", () =>
                    {
                        Window.Message("Use the companies resources as well as your own to try and speed things up.", "go on...", () =>
                        {
                            Window.Message("But do it cheaply, or you might find yourself poor or even bankrupt.", "oh god.");
                        });
                    });
                });
            };
            Add(infoButton);
            // Add progress bar at bottom.
            var progressBar =
                new ProgressBar(Width - 4 - 15, 1, HorizontalAlignment.Left)
            {
                Position = new Point(2 + 15, Height - 3)
            };
            progressBar.Theme    = YellowProgressBarTheme.ThemeInstance;
            progressBar.Progress = 0.5f;
            Add(progressBar);
            _progressBar = progressBar;
        }
예제 #28
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);
        }
예제 #29
0
        public ColorPickerPopup()
            : base(Settings.Config.ColorPickerSettings.WindowWidth, Settings.Config.ColorPickerSettings.WindowHeight)
        {
            Center();

            otherColorPopup = new OtherColorsPopup();
            otherColorPopup.Closed += (sender2, e2) =>
            {
                if (otherColorPopup.DialogResult)
                {
                    _barR.SelectedColor = otherColorPopup.SelectedColor.RedOnly();
                    _barG.SelectedColor = otherColorPopup.SelectedColor.GreenOnly();
                    _barB.SelectedColor = otherColorPopup.SelectedColor.BlueOnly();
                    _alphaInput.Text = otherColorPopup.SelectedColor.A.ToString();
                }
            };

            _picker = new Controls.ColorPicker(textSurface.Width - RideSideX - 1, textSurface.Height - 11, Color.YellowGreen) { Position = new Point(1, 1) };
            _picker.SelectedColorChanged += _picker_SelectedColorChanged;
            Add(_picker);

            #region TextBoxes
            _redInput = new InputBox(5);
            _redInput.IsNumeric = true;
            _redInput.MaxLength = 3;
            _redInput.Position = new Point(textSurface.Width - 7, textSurface.Height - 14);
            _redInput.TextChanged += (sender, e) => { _barR.SelectedColor = new Color(int.Parse(_redInput.Text), 0, 0); };
            Add(_redInput);

            _greenInput = new InputBox(5);
            _greenInput.IsNumeric = true;
            _greenInput.MaxLength = 3;
            _greenInput.Position = new Point(textSurface.Width - 7, textSurface.Height - 13);
            _greenInput.TextChanged += (sender, e) => { _barG.SelectedColor = new Color(0, int.Parse(_greenInput.Text), 0); };
            Add(_greenInput);

            _blueInput = new InputBox(5);
            _blueInput.IsNumeric = true;
            _blueInput.MaxLength = 3;
            _blueInput.Position = new Point(textSurface.Width - 7, textSurface.Height - 12);
            _blueInput.TextChanged += (sender, e) => { _barB.SelectedColor = new Color(0, 0, int.Parse(_blueInput.Text)); };
            Add(_blueInput);

            _alphaInput = new InputBox(5);
            _alphaInput.IsNumeric = true;
            _alphaInput.MaxLength = 3;
            _alphaInput.Position = new Point(textSurface.Width - 7, textSurface.Height - 11);
            _alphaInput.Text = "255";
            Add(_alphaInput);
            #endregion

            #region Bars
            _barH = new HueBar(base.TextSurface.RenderArea.Width - 2);

            _barH.Position = new Point(1, textSurface.Height - 9);
            _barH.ColorChanged += _barH_ColorChanged;
            Add(_barH);

            _barR = new ColorBar(base.TextSurface.RenderArea.Width - 2);

            _barR.StartingColor = Color.Black;
            _barR.EndingColor = Color.Red;
            _barR.Position = new Point(1, textSurface.Height - 7);
            _barR.ColorChanged += bar_ColorChanged;
            Add(_barR);

            _barG = new ColorBar(base.TextSurface.RenderArea.Width - 2);

            _barG.StartingColor = Color.Black;
            _barG.EndingColor = new Color(0, 255, 0);
            _barG.Position = new Point(1, textSurface.Height - 5);
            _barG.ColorChanged += bar_ColorChanged;
            Add(_barG);

            _barB = new ColorBar(base.TextSurface.RenderArea.Width - 2);

            _barB.StartingColor = Color.Black;
            _barB.EndingColor = Color.Blue;
            _barB.Position = new Point(1, textSurface.Height - 3);
            _barB.ColorChanged += bar_ColorChanged;
            Add(_barB);

            _selectedColor = _picker.SelectedColor;
            _barH.SelectedColor = _selectedColor;
            #endregion

            #region Buttons
            _okButton = new Button(RideSideX - 4, 1);
            _okButton.Text = "OK";
            _okButton.Position = new Point(textSurface.Width - RideSideX + 2, textSurface.Height - 18);
            _okButton.ButtonClicked += (sender, r) =>
            {
                this.DialogResult = true;
                _selectedColor.A = byte.Parse(_alphaInput.Text);
                AddPreviousColor(SelectedColor);
                Hide();
            };
            Add(_okButton);

            _cancelButton = new Button(RideSideX - 4, 1);
            _cancelButton.Text = "Cancel";
            _cancelButton.Position = new Point(textSurface.Width - RideSideX + 2, textSurface.Height - 16);
            _cancelButton.ButtonClicked += (sender, r) => { this.DialogResult = false; Hide(); };
            Add(_cancelButton);

            _otherColorsButton = new Button(RideSideX - 4, 1);
            _otherColorsButton.Text = "Other Colors";
            _otherColorsButton.Position = new Point(textSurface.Width - RideSideX + 2, textSurface.Height - 20);
            _otherColorsButton.ButtonClicked += (sender, e) => { otherColorPopup.Show(true); };
            Add(_otherColorsButton);
            #endregion

            _previousColors = new ListBox<ListBoxItemColor>(RideSideX - 4, textSurface.Height - 20 - 9 + 1);
            _previousColors.Position = new Point(textSurface.Width - RideSideX + 2, 8);
            _previousColors.SelectedItemChanged += (sender, e) => { if (_previousColors.SelectedItem != null) SelectedColor = (Color)_previousColors.SelectedItem; };
            Add(_previousColors);

            this.CloseOnESC = true;
            this.Title = "Select Color";
        }
예제 #30
0
        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();
        }