Exemplo n.º 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;
        }
Exemplo n.º 2
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);
        }