void InitialiseEmptyProfiles()
        {
            foreach (WowClass wowClass in Enum.GetValues(typeof(WowClass)))
            {
                if (!ProfileDb.Instance.ProfileList.Any(profile => profile.Class == wowClass))
                    ProfileDb.Instance.ProfileList.Add(new Profile { Class = wowClass });
            }

            foreach (var profile in ProfileDb.Instance.ProfileList)
            {
                foreach (WowSpecializations spec in Enum.GetValues(typeof(WowSpecializations)))
                {
                    if (((int)spec >> 16) == (byte)profile.Class)
                    {
                        if (!profile.RotationList.Any(r => r.Spec == spec))
                        {
                            var name = Localization.ResourceManager.GetString($"WowSpecializations_{spec}", CultureInfo.CurrentUICulture);
                            var rotation = new Rotation { Spec = spec, Name = name };
                            if (profile.RotationList.Count < Keys.Length)
                                rotation.HotKey = new HotKey(Keys[profile.RotationList.Count], ModifierKeys.Alt);
                            profile.RotationList.Add(rotation);
                        }
                    }
                }
            }

            // Профиль общих ротаций должен быть в самом низу.
            var old = ProfileDb.Instance.ProfileList.IndexOf(
                ProfileDb.Instance.ProfileList.First(p => p.Class == WowClass.None));
            if (old > -1 && old != ProfileDb.Instance.ProfileList.Count - 1)
                ProfileDb.Instance.ProfileList.Move(old, ProfileDb.Instance.ProfileList.Count - 1);
        }
Beispiel #2
0
        /// <summary>
        /// Создает новый экземпляр класса с текщими значениями.
        /// </summary>
        public object Clone()
        {
            var rotation = new Rotation {
                Name   = Name + " (Копия)",
                Lua    = Lua,
                HotKey = new HotKey(),
            };

            foreach (var ability in AbilityList)
                rotation.AbilityList.Add(ability.Clone());
            return rotation;
        }
Beispiel #3
0
        void InitStructure()
        {
            Key[] key_list = { Key.X, Key.C, Key.V, Key.B, Key.N };

            foreach (WowClass wowClass in Enum.GetValues(typeof(WowClass)))
            {
                if (!ProfileList.Any(profile => profile.Class == wowClass))
                    ProfileList.Add(new Profile { Class = wowClass });
            }

            foreach (var profile in ProfileList)
            {
                foreach (WowSpecializations spec in Enum.GetValues(typeof(WowSpecializations)))
                {
                    if (spec.IsWowClass(profile.Class))
                    {
                        if (!profile.RotationList.Any(r => r.Spec == spec))
                        {
                            var rotation = new Rotation {
                                Spec = spec,
                                Name = spec.ToString().Split('_').Last(),
                                AbilityList = new ObservableCollection<Ability> {
                                    new Ability {
                                        TargetList = new List<TargetType> { TargetType.None }
                                    }
                                }
                            };

                            if (profile.RotationList.Count < key_list.Length)
                                rotation.HotKey = new HotKey(key_list[profile.RotationList.Count], ModifierKeys.Alt);
                            profile.RotationList.Add(rotation);
                        }
                    }
                }
            }

            var old = ProfileList.IndexOf(ProfileList.First(p => p.Class == WowClass.None));
            if (old > -1 && old != ProfileList.Count - 1)
                ProfileList.Move(old, ProfileList.Count - 1);
        }
        // rotations
        void CommandBinding_Executed_AddRotation(object sender, ExecutedRoutedEventArgs e)
        {
            if (CurrentProfile == null)
                throw new YanittaException("Не выбран класс для новой ротации!");

            var mod = ModifierKeys.Alt | (CurrentProfile.Class == WowClass.None
                ? ModifierKeys.Shift
                : ModifierKeys.None);

            var rotation = new Rotation();
            if (CurrentProfile.RotationList.Count < Keys.Length)
                rotation.HotKey = new HotKey(Keys[CurrentProfile.RotationList.Count], mod);
            CurrentProfile.RotationList.Add(rotation);
            rotationList.SelectedIndex = CurrentProfile.RotationList.Count - 1;
            tbRotationName.Focus();
            tbRotationName.SelectAll();
            rotationList.ScrollIntoView(rotationList.SelectedItem);
            CollectionViewSource.GetDefaultView(rotationList.ItemsSource).Refresh();
        }
Beispiel #5
0
        /// <summary>
        /// Start/Stop rotation
        /// </summary>
        /// <param name="rotation">Curent rotation.</param>
        void ExecuteProfile(Rotation rotation)
        {
            if (rotation == null)
                throw new ArgumentNullException(nameof(rotation));

            var builder = new StringBuilder();
            builder.AppendLine(ProfileDb.Instance.LuaDocument?.Text);
            builder.AppendLine();

            builder.AppendLine($"ABILITY_TABLE = {{\n{string.Join(",\n", rotation.AbilityList)}\n}};");
            builder.AppendLine();

            builder.AppendLine(ProfileDb.Instance[Class].LuaDocument?.Text);
            builder.AppendLine();

            builder.AppendLine(ProfileDb.Instance[WowClass.None].LuaDocument?.Text);
            builder.AppendLine(rotation.LuaDocument?.Text);
            builder.AppendLine($"Yanitta_RANGE_CHECK_SPELL = {rotation.InRangeSpell};");
            builder.AppendLine();

            // Run rotation
            builder.AppendLine("assert(type(ChangeRotation) == \"function\", 'Не найдена функция \"ChangeRotation\"');");
            builder.AppendLine($"ChangeRotation(\"{rotation.Name}\");");

            var code = builder.ToString();

            System.IO.File.WriteAllText("InjectedLuaCode.lua", code);

            LuaExecute(code);
        }
Beispiel #6
0
        /// <summary>
        /// Запускает/останавливает ротацию.
        /// </summary>
        /// <param name="rotation">Текущая ротация.</param>
        void ExecuteProfile(Rotation rotation)
        {
            if (rotation == null)
                throw new ArgumentNullException(nameof(rotation));

            var builder = new StringBuilder();
            builder.AppendLine(ProfileDb.Instance.Lua);
            builder.AppendLine();

            builder.AppendLine($"ABILITY_TABLE = {{\n{string.Join(",\n", rotation.AbilityList)}\n}};");
            builder.AppendLine();

            builder.AppendLine(ProfileDb.Instance[Class].Lua);
            builder.AppendLine();

            builder.AppendLine(ProfileDb.Instance[WowClass.None].Lua);
            builder.AppendLine(rotation.Lua);
            builder.AppendLine();

            builder.AppendLine($"DebugMode = {Settings.Default.DebugMode.ToString().ToLower()};");
            // Запуск ротации
            builder.AppendLine("assert(type(ChangeRotation) == \"function\", 'Не найдена функция \"ChangeRotation\"');");
            builder.AppendLine($"ChangeRotation(\"{rotation.Name}\");");

            var code = builder.ToString();

            System.IO.File.WriteAllText("InjectedLuaCode.lua", code);

            LuaExecute(code);
        }