示例#1
0
        public static bool PickerRow(UnitEntityData ch, BlueprintCharacterClass cl, MulticlassOptions options, float indent = 100)
        {
            var changed  = false;
            var showDesc = settings.toggleMulticlassShowClassDescriptions;

            if (showDesc)
            {
                UI.Div(indent, 15);
            }
            var cd                = ch?.Progression.GetClassData(cl);
            var chArchetype       = cd?.Archetypes.FirstOrDefault <BlueprintArchetype>();
            var archetypeOptions  = options.ArchetypeOptions(cl);
            var showGestaltToggle = false;

            if (ch != null && cd != null)
            {
                var classes            = ch?.Progression.Classes;
                var classCount         = classes?.Count(x => !x.CharacterClass.IsMythic);
                var gestaltCount       = classes?.Count(cd => !cd.CharacterClass.IsMythic && ch.IsClassGestalt(cd.CharacterClass));
                var mythicCount        = classes.Count(x => x.CharacterClass.IsMythic);
                var mythicGestaltCount = classes.Count(cd => cd.CharacterClass.IsMythic && ch.IsClassGestalt(cd.CharacterClass));

                showGestaltToggle = ch.IsClassGestalt(cd.CharacterClass) ||
                                    !cd.CharacterClass.IsMythic && classCount - gestaltCount > 1 ||
                                    cd.CharacterClass.IsMythic && mythicCount - mythicGestaltCount > 1;
            }
            var charHasClass = cd != null && chArchetype == null;
            // Class Toggle
            var canSelectClass = MulticlassOptions.CanSelectClassAsMulticlass(ch, cl);

            using (UI.HorizontalScope()) {
                UI.Space(indent);
                var optionsHasClass = options.Contains(cl);
                UI.ActionToggle(
                    charHasClass ? cl.Name.orange() + $" ({cd.Level})".orange() : cl.Name,
                    () => optionsHasClass,
                    (v) => {
                    if (v)
                    {
                        archetypeOptions = options.Add(cl);
                        if (chArchetype != null)
                        {
                            archetypeOptions.Add(chArchetype);
                            options.SetArchetypeOptions(cl, archetypeOptions);
                        }
                    }
                    else
                    {
                        options.Remove(cl);
                    }
                    var action = v ? "Add".green() : "Del".yellow();
                    Mod.Trace($"PickerRow - {action} class: {cl.HashKey()} - {options} -> {options.Contains(cl)}");
                    changed = true;
                },
                    () => !canSelectClass,
                    350);
                UI.Space(247);
                using (UI.VerticalScope()) {
                    if (!canSelectClass)
                    {
                        UI.Label("to select this class you must unselect at least one of your other existing classes".orange());
                    }
                    if (optionsHasClass && chArchetype != null && archetypeOptions.Empty())
                    {
                        UI.Label($"due to existing archetype, {chArchetype.Name.yellow()},  this multiclass option will only be applied during respec.".orange());
                    }
                    if (showGestaltToggle && chArchetype == null)
                    {
                        using (UI.HorizontalScope()) {
                            UI.Space(-150);
                            UI.ActionToggle("gestalt".grey(), () => ch.IsClassGestalt(cd.CharacterClass),
                                            (v) => {
                                ch.SetClassIsGestalt(cd.CharacterClass, v);
                                ch.Progression.UpdateLevelsForGestalt();
                                changed = true;
                            }, 125);
                            UI.Space(25);
                            UI.Label("this flag lets you not count this class in computing character level".green());
                        }
                    }
                    if (showDesc)
                    {
                        using (UI.HorizontalScope()) {
                            UI.Label(cl.Description.StripHTML().green());
                        }
                    }
                }
            }
            // Archetypes
            using (UI.HorizontalScope()) {
                var showedGestalt = false;
                UI.Space(indent);
                var archetypes = cl.Archetypes;
                if (options.Contains(cl) && archetypes.Any() || chArchetype != null || charHasClass)
                {
                    UI.Space(50);
                    using (UI.VerticalScope()) {
                        foreach (var archetype in cl.Archetypes)
                        {
                            if (showDesc)
                            {
                                UI.Div();
                            }
                            using (UI.HorizontalScope()) {
                                var hasArch = archetypeOptions.Contains(archetype);
                                UI.ActionToggle(
                                    archetype == chArchetype ? cd.ArchetypesName().orange() + $" ({cd.Level})".orange() : archetype.Name,
                                    () => hasArch,
                                    (v) => {
                                    if (v)
                                    {
                                        archetypeOptions.AddExclusive(archetype);
                                    }
                                    else
                                    {
                                        archetypeOptions.Remove(archetype);
                                    }
                                    options.SetArchetypeOptions(cl, archetypeOptions);
                                    var action = v ? "Add".green() : "Del".yellow();
                                    Mod.Trace($"PickerRow -  {action}  - arch: {archetype.HashKey()} - {archetypeOptions}");
                                    changed = true;
                                },
                                    () => !canSelectClass,
                                    300);
                                UI.Space(250);
                                using (UI.VerticalScope()) {
                                    if (hasArch && archetype != chArchetype && (chArchetype != null || charHasClass))
                                    {
                                        if (chArchetype != null)
                                        {
                                            UI.Label($"due to existing archetype, {chArchetype.Name.yellow()}, this multiclass archetype will only be applied during respec.".orange());
                                        }
                                        else
                                        {
                                            UI.Label($"due to existing class, {cd.CharacterClass.Name.yellow()}, this multiclass archetype will only be applied during respec.".orange());
                                        }
                                    }
                                    else if (showGestaltToggle && archetype == chArchetype)
                                    {
                                        using (UI.HorizontalScope()) {
                                            UI.Space(-155);
                                            UI.ActionToggle("gestalt".grey(), () => ch.IsClassGestalt(cd.CharacterClass),
                                                            (v) => {
                                                ch.SetClassIsGestalt(cd.CharacterClass, v);
                                                ch.Progression.UpdateLevelsForGestalt();
                                                changed = true;
                                            }, 125);
                                            UI.Space(25);
                                            UI.Label("this flag lets you not count this class in computing character level".green());
                                            showedGestalt = true;
                                        }
                                    }
                                    if (showDesc)
                                    {
                                        using (UI.VerticalScope()) {
                                            if (showedGestalt)
                                            {
                                                UI.Label("this flag lets you not count this class in computing character level".green());
                                                UI.DivLast();
                                            }
                                            UI.Label(archetype.Description.StripHTML().green());
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(changed);
        }