Пример #1
0
        public static async Task Show(AGSEditor editor)
        {
            if (_component != null)
            {
                _component.PropertyChanged -= onPropertyChanged;
            }
            var gameSelector      = new ComboboxboxField("Game", "Game", "Editor");
            var entitySelector    = new TextboxField("Entity ID");
            var componentSelector = new TextboxField("Component");
            var propertySelector  = new TextboxField("Property Name");
            var simpleForm        = new SimpleForm(editor.Editor, gameSelector, entitySelector, componentSelector, propertySelector);
            await simpleForm.ShowAsync("Break Debugger when property changes");

            var game   = gameSelector.Value == "Game" ? editor.Game : editor.Editor;
            var entity = game.Find <IEntity>(entitySelector.Value);

            if (entity == null)
            {
                await AGSMessageBox.DisplayAsync($"Did not find entity id {entitySelector.Value}", editor.Editor);

                return;
            }
            var component = entity.FirstOrDefault(c => c.Name == componentSelector.Value);

            if (component == null)
            {
                await AGSMessageBox.DisplayAsync($"Did not find component {componentSelector.Value} for entity id {entitySelector.Value}", editor.Editor);

                return;
            }
            _component = component;
            _property  = propertySelector.Value;
            component.PropertyChanged += onPropertyChanged;
        }
Пример #2
0
        private async Task <bool> validate(Dictionary <string, object> map)
        {
            var id = map["id"];

            if (_editor.Project.Model.Entities.ContainsKey(id.ToString()))
            {
                var settings = new AGSMessageBoxSettings(_editor.Editor);
                settings.RenderLayer = new AGSRenderLayer(settings.RenderLayer.Z - 1000, independentResolution: settings.RenderLayer.IndependentResolution);
                await AGSMessageBox.DisplayAsync($"ID {id} is already taken, please select another ID.", _editor.Editor, settings);

                return(false);
            }
            return(true);
        }
Пример #3
0
        public static async Task Show(AGSEditor editor)
        {
            var gameSelector         = new ComboboxboxField("Game", "Game", "Editor");
            var entitySelector       = new TextboxField("Text to search");
            var propertyTypeSelector = new ComboboxboxField("Search By", nameof(IEntity.ID), nameof(ITextComponent.Text));
            var testTypeSelector     = new ComboboxboxField("Test By", "Includes", "Exact Match");
            var caseSensitive        = new CheckboxField("Case Sensitive");
            var simpleForm           = new SimpleForm(editor.Editor, gameSelector, entitySelector, propertyTypeSelector, testTypeSelector, caseSensitive);
            await simpleForm.ShowAsync("Find Object");

            if (entitySelector.Value == null)
            {
                return;
            }
            Debug.WriteLine($"Searching for {entitySelector.Value} ({propertyTypeSelector.Value}, {testTypeSelector.Value}, Case Sensitive={caseSensitive.Value}) in {gameSelector.Value}");
            var game    = gameSelector.Value == "Game" ? editor.Game : editor.Editor;
            var matches = game.State.All <IObject>().Where(e =>
            {
                var property = e.GetType().GetProperty(propertyTypeSelector.Value);
                if (property == null)
                {
                    return(false);
                }
                string value = property.GetValue(e)?.ToString();
                if (value == null)
                {
                    return(false);
                }
                string matchWith = entitySelector.Value;
                if (!caseSensitive.Value)
                {
                    value     = value.ToLowerInvariant();
                    matchWith = matchWith.ToLowerInvariant();
                }
                if (testTypeSelector.Value == "Exact Match")
                {
                    return(value == matchWith);
                }
                return(value.Contains(matchWith));
            });

            foreach (var match in matches)
            {
                Debug.WriteLine($"Found match: {(match, match.Position, match.WorldXY)}");
            }
            await AGSMessageBox.DisplayAsync($"Done. Results written to console.", editor.Editor);
        }