A group of positions with a set of settings.
示例#1
0
        public bool LoadHotspot(Hotspot spot)
        {
            Hotspots.Add(spot);
            HotspotPanel.RebuildListBox();

            return true;
        }
        void _exportListButton_ButtonClicked(object sender, EventArgs e)
        {
            var editor = (Editors.SceneEditor)EditorConsoleManager.ActiveEditor;

            if (editor.Hotspots.Count == 0)
                return;

            Windows.SelectFilePopup popup = new Windows.SelectFilePopup();
            popup.Center();
            popup.Closed += (s, e2) =>
            {
                if (popup.DialogResult)
                {
                    List<Hotspot> clonedSpots = new List<Hotspot>(editor.Hotspots.Count);

                    foreach (var spot in editor.Hotspots)
                    {
                        Hotspot newSpot = new Hotspot();
                        newSpot.Title = spot.Title;
                        spot.DebugAppearance.CopyAppearanceTo(newSpot.DebugAppearance);
                        newSpot.Settings = new Dictionary<string, string>(spot.Settings);
                        clonedSpots.Add(newSpot);
                    }

                    popup.SelectedLoader.Save(clonedSpots, popup.SelectedFile);
                }
            };
            popup.FileLoaderTypes = new FileLoaders.IFileLoader[] { new FileLoaders.Hotspots() };
            popup.SkipFileExistCheck = true;
            popup.SelectButtonText = "Save";
            popup.Show(true);
        }
        void _createNewObjectButton_ButtonClicked(object sender, EventArgs e)
        {
            Hotspot hotSpot = new Hotspot();
            Windows.EditHotspotPopup popup = new Windows.EditHotspotPopup(hotSpot);
            popup.Closed += (o, e2) =>
                {
                    if (popup.DialogResult)
                    {
                        hotSpot = popup.CreatedHotspot;
                        hotspotsListbox.Items.Add(hotSpot);
                        hotspotsListbox.SelectedItem = hotSpot;
                        exportListButton.IsEnabled = true;
                        ((Editors.SceneEditor)EditorConsoleManager.ActiveEditor).Hotspots.Add(hotSpot);
                    }
                };

            popup.Show(true);
        }
        void hotspotsListbox_SelectedItemChanged(object sender, ListBox<HotspotListBoxItem>.SelectedItemEventArgs e)
        {
            if (hotspotsListbox.SelectedItem == null)
                SelectedObject = null;
            else
                SelectedObject = (Hotspot)hotspotsListbox.SelectedItem;

            editButton.IsEnabled = SelectedObject != null;
            deleteButton.IsEnabled = SelectedObject != null;
            cloneHotspot.IsEnabled = SelectedObject != null;
            //EditorConsoleManager.Instance.ToolPane.SelectedTool.RefreshTool();
        }
 private void CloneHotspot_ButtonClicked(object sender, EventArgs e)
 {
     Windows.RenamePopup popup = new Windows.RenamePopup("Name", "Clone hotspot");
     popup.Closed += (o, ev) =>
     {
         if (popup.DialogResult)
         {
             var hotspot = new Hotspot();
             hotspot.Title = popup.NewName;
             SelectedObject.DebugAppearance.CopyAppearanceTo(hotspot.DebugAppearance);
             hotspot.Settings = new Dictionary<string, string>(SelectedObject.Settings);
             ((Editors.SceneEditor)EditorConsoleManager.ActiveEditor).Hotspots.Add(hotspot);
         }
     };
     popup.Show(true);
     popup.Center();
 }
        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();
        }