Beispiel #1
0
    public async Task Find(IFindAnywhereResultContext resultContext, IReadOnlyList <string> parameterNames, long parameterValue, CancellationToken cancellationToken)
    {
        foreach (var definition in definitionProvider.Definitions)
        {
            if (definition.IsOnlyConditionsTable)
            {
                continue;
            }

            foreach (var tableGroup in definition.Groups.SelectMany(group => group.Fields.Select(column => (group, column))).GroupBy(c => c.column.ForeignTable ?? definition.TableName))
            {
                var tableName = tableGroup.Key;
                var table     = Queries.Table(tableName);
                var where = table.ToWhere();

                if (tableName == definition.TableName && definition.Picker != null && parameterNames.IndexOf(definition.Picker) != -1)
                {
                    where = where.OrWhere(row => row.Column <long>(definition.TablePrimaryKeyColumnName) == parameterValue);
                }

                foreach (var(group, column) in tableGroup)
                {
                    if (parameterNames.IndexOf(column.ValueType) != -1)
                    {
                        if (group.ShowIf is {} showIf)
                        {
                            where = where.OrWhere(row => row.Column <long>(column.DbColumnName) == parameterValue && row.Column <long>(showIf.ColumnName) == showIf.Value);
                        }
                        else
                        {
                            where = where.OrWhere(row => row.Column <long>(column.DbColumnName) == parameterValue);
                        }
                    }
    public async Task Find(IFindAnywhereResultContext resultContext, IReadOnlyList <string> parameterName, IReadOnlyList <long> parameterValue, CancellationToken cancellationToken)
    {
        foreach (var source in sources)
        {
            if (cancellationToken.IsCancellationRequested)
            {
                return;
            }

            foreach (var val in parameterValue)
            {
                await source.Find(resultContext, parameterName, val, cancellationToken);
            }
        }
    }
Beispiel #3
0
    public async Task Find(IFindAnywhereResultContext resultContext, IReadOnlyList <string> parameterNames, long parameterValue,
                           CancellationToken cancellationToken)
    {
        var results = await databaseProvider.FindSmartScriptLinesBy(PrepareCondition(parameterNames, parameterValue));

        foreach (var result in results)
        {
            var item = GenerateSolutionItem(result);
            var name = nameRegistry.GetName(item);
            var icon = iconRegistry.GetIcon(item);
            resultContext.AddResult(new FindAnywhereResult(
                                        icon,
                                        name + " (" + result.EntryOrGuid + ")",
                                        result.Comment,
                                        item));
        }
    }
Beispiel #4
0
    public async Task Find(IFindAnywhereResultContext resultContext, IReadOnlyList <string> parameterNames, long parameterValue, CancellationToken cancellationToken)
    {
        EventScriptType?lookForType = null;

        if (parameterNames.IndexOf("EventScriptParameter") != -1)
        {
            lookForType = EventScriptType.Event;
        }
        else if (parameterNames.IndexOf("SpellParameter") != -1)
        {
            lookForType = EventScriptType.Spell;
        }

        if (lookForType.HasValue)
        {
            var result = await databaseProvider.GetEventScript(lookForType.Value, (uint)parameterValue);

            if (result.Count > 0)
            {
                var item = new EventScriptSolutionItem(lookForType.Value, (uint)parameterValue);
                var vm   = viewModelFactory.Factory(result[0]);
                resultContext.AddResult(new FindAnywhereResult(
                                            new ImageUri("Icons/document_event_script_big.png"),
                                            lookForType.Value + " Script",
                                            vm.Text,
                                            item
                                            ));
            }
        }

        var found = await databaseProvider.FindEventScriptLinesBy(GenerateConditions(parameterNames, parameterValue).ToList());

        foreach (var f in found)
        {
            var item = new EventScriptSolutionItem(f.Type, f.Id);
            var vm   = viewModelFactory.Factory(f);
            resultContext.AddResult(new FindAnywhereResult(
                                        new ImageUri("Icons/document_event_script_big.png"),
                                        f.Type + " Script",
                                        vm.Text,
                                        item
                                        ));
        }
    }
    public async Task Find(IFindAnywhereResultContext resultContext, IReadOnlyList <string> parameterNames, long parameterValue, CancellationToken cancellationToken)
    {
        var command = new DelegateCommand(() =>
        {
            messageBoxService.Value.ShowDialog(new MessageBoxFactory <bool>()
                                               .SetTitle("Operation not supported yet")
                                               .SetMainInstruction("Conditions not yet supported")
                                               .SetContent("Sorry, opening conditions directly is not yet supported")
                                               .WithButton("Sorry again", false, true, true)
                                               .Build()).ListenErrors();
        });
        var table = Queries.Table("conditions");

        var where = table.ToWhere();
        foreach (var cond in dataManager.AllConditionData)
        {
            if (cond.Parameters == null)
            {
                continue;
            }

            for (int i = 0; i < cond.Parameters.Count; ++i)
            {
                if (cond.Parameters[i].Type == "ConditionObjectEntryParameter")
                {
                    if (parameterNames.IndexOf("CreatureParameter") != -1)
                    {
                        where = where.OrWhere(row => row.Column <int>("ConditionValue1") == 3 &&
                                              row.Column <long>("ConditionValue3") == parameterValue);
                    }
                    else if (parameterNames.IndexOf("GameobjectParameter") != -1)
                    {
                        where = where.OrWhere(row => row.Column <int>("ConditionValue1") == 5 &&
                                              row.Column <long>("ConditionValue3") == parameterValue);
                    }
                }
                else if (cond.Parameters[i].Type == "ConditionObjectGuidParameter")
                {
                    if (parameterNames.IndexOf("CreatureGUIDParameter") != -1)
                    {
                        where = where.OrWhere(row => row.Column <int>("ConditionValue1") == 3 &&
                                              row.Column <long>("ConditionValue3") == parameterValue);
                    }
                    else if (parameterNames.IndexOf("GameobjectGUIDParameter") != -1)
                    {
                        where = where.OrWhere(row => row.Column <int>("ConditionValue1") == 5 &&
                                              row.Column <long>("ConditionValue3") == parameterValue);
                    }
                }
                else
                {
                    if (parameterNames.IndexOf(cond.Parameters[i].Type) == -1)
                    {
                        continue;
                    }

                    var colName = "ConditionValue" + (i + 1);

                    where = where.OrWhere(row => row.Column <int>("ConditionTypeOrReference") == cond.Id &&
                                          row.Column <long>(colName) == parameterValue);
                }
            }
        }

        foreach (var cond in dataManager.AllConditionSourceData)
        {
            if (parameterNames.IndexOf(cond.Group.Type) != -1)
            {
                where = where.OrWhere(row => row.Column <int>("SourceTypeOrReferenceId") == cond.Id &&
                                      row.Column <long>("SourceGroup") == parameterValue);
            }
            if (parameterNames.IndexOf(cond.SourceId.Type) != -1)
            {
                where = where.OrWhere(row => row.Column <int>("SourceTypeOrReferenceId") == cond.Id &&
                                      row.Column <long>("SourceId") == parameterValue);
            }
            if (parameterNames.IndexOf(cond.Entry.Type) != -1)
            {
                where = where.OrWhere(row => row.Column <int>("SourceTypeOrReferenceId") == cond.Id &&
                                      row.Column <long>("SourceEntry") == parameterValue);
            }
        }

        var result = await mySqlExecutor.ExecuteSelectSql(where.Select().QueryString);

        foreach (var row in result)
        {
            resultContext.AddResult(new FindAnywhereResult(new ImageUri("Icons/document_conditions.png"),
                                                           "Condition " + row["Comment"].Item2,
                                                           string.Join(", ", row.Select(pair => pair.Key + ": " + pair.Value.Item2)),
                                                           null,
                                                           command));
        }
    }
    public async Task Find(IFindAnywhereResultContext resultContext, IReadOnlyList <string> parameterNames, long parameterValue, CancellationToken cancellationToken)
    {
        var command = new AsyncAutoCommand(() => messageBoxService.Value.ShowDialog(new MessageBoxFactory <bool>()
                                                                                    .SetTitle("DBC entry")
                                                                                    .SetMainInstruction("This is a DBC spell")
                                                                                    .SetContent("You cannot open it, it is just an info for you that such spell exists")
                                                                                    .WithButton("Understood!", true, true, true)
                                                                                    .Build()));

        var spellService = spellServiceLazy.Value;
        var spellStore   = spellStoreLazy.Value;
        var mainThread   = mainThreadLazy.Value;

        void AddThing(uint spell, string name, string description, ImageUri icon)
        {
            mainThread.Dispatch(() =>
            {
                resultContext.AddResult(new FindAnywhereResult(icon,
                                                               name + " (" + spell + ")",
                                                               description,
                                                               null,
                                                               command));
            });
        }

        if (parameterNames.IndexOf("SpellParameter") != -1)
        {
            if (spellStore.HasSpell((uint)parameterValue))
            {
                AddThing((uint)parameterValue, spellStore.GetName((uint)parameterValue) ?? "(unknown)", spellService.GetDescription((uint)parameterValue) ?? "Spell in DBC", new ImageUri("Icons/document_instance_template_big.png"));
            }
        }

        await Task.Run(() =>
        {
            foreach (var(spell, name) in spellStore.SpellsWithName)
            {
                if (cancellationToken.IsCancellationRequested)
                {
                    return;
                }

                for (int i = 0; i < spellService.GetSpellEffectsCount(spell); ++i)
                {
                    var type = spellService.GetSpellEffectType(spell, i);
                    if (type == SpellEffectType.SendEvent)
                    {
                        if (parameterNames.IndexOf("EventScriptParameter") != -1)
                        {
                            var @event = spellService.GetSpellEffectMiscValueA(spell, i);
                            if (@event == parameterValue)
                            {
                                AddThing(spell, name, $"Effect {i}: SPELL_EFFECT_SEND_EVENT with event {@event}", new ImageUri("Icons/document_instance_template_big.png"));
                            }
                        }
                    }
                    else if (type == SpellEffectType.Summon)
                    {
                        if (parameterNames.IndexOf("CreatureParameter") != -1)
                        {
                            var entry = spellService.GetSpellEffectMiscValueA(spell, i);
                            if (entry == parameterValue)
                            {
                                AddThing(spell, name, $"Effect {i}: SPELL_EFFECT_SUMMON with npc {entry}", new ImageUri("Icons/document_instance_template_big.png"));
                            }
                        }
                    }

                    var triggerSpell = spellService.GetSpellEffectTriggerSpell(spell, i);
                    if (triggerSpell == parameterValue && parameterNames.IndexOf("SpellParameter") != -1)
                    {
                        AddThing(spell, name, $"Effect {i}: Trigger spell {triggerSpell}", new ImageUri("Icons/document_spell_linked_big.png"));
                    }
                }
            }
        }, cancellationToken);
    }