public EffectConfig(EffectData effectData, EffectInfo effectInfo)
        {
            InitializeComponent();

            Title = effectInfo.Name;

            m_isTimedEffect = effectInfo.IsTimed;

            if (m_isTimedEffect)
            {
                effectconf_timer_type_enable.IsChecked = effectData.EffectTimedType != (effectInfo.IsShort ? EffectTimedType.TIMED_SHORT : EffectTimedType.TIMED_NORMAL);
                effectconf_timer_type.ItemsSource      = new string[]
                {
                    "Normal",
                    "Short"
                };
                effectconf_timer_type.SelectedIndex = effectData.EffectTimedType == EffectTimedType.TIMED_SHORT ? 1 : 0;

                if (effectData.EffectCustomTime >= 0)
                {
                    effectconf_timer_time_enable.IsChecked = true;
                    effectconf_timer_time.Text             = $"{effectData.EffectCustomTime}";
                }
            }

            effectconf_timer_permanent_enable.IsChecked = effectData.EffectPermanent;

            int[] weightItems = new int[10];
            for (int i = 0; i < 10; i++)
            {
                weightItems[i] = i + 1;
            }
            effectconf_effect_weight.ItemsSource   = weightItems;
            effectconf_effect_weight.SelectedIndex = effectData.EffectWeight - 1;

            effectconf_exclude_voting_enable.IsChecked = effectData.EffectExcludedFromVoting;

            effectconf_effect_custom_name.Text = effectData.EffectCustomName;

            effectconf_mp3_label.Text += $"{effectInfo.Id}.mp3";

            CheckEnableConfigurables();
        }
Exemple #2
0
        private void WriteEffectsFile()
        {
            string data = "";

            for (EffectType effectType = 0; effectType < EffectType._EFFECT_ENUM_MAX; effectType++)
            {
                EffectInfo effectInfo = EffectsMap[effectType];

                EffectDataMap.TryGetValue(effectType, out EffectData effectData);
                if (effectData == null)
                {
                    effectData = new EffectData(effectInfo.IsShort ? EffectTimedType.TIMED_SHORT : EffectTimedType.TIMED_NORMAL, -1, 5, false);
                }

                data += $"{EffectsMap[effectType].Id}={(TreeMenuItemsMap[effectType].IsChecked ? 1 : 0)}" +
                        $",{(effectData.EffectTimedType == EffectTimedType.TIMED_NORMAL ? 0 : 1)},{effectData.EffectCustomTime},{effectData.EffectWeight},{(effectData.EffectPermanent ? 1 : 0)}\n";
            }

            File.WriteAllText(EffectsFile, data);
        }
Exemple #3
0
        private void effect_user_config_Click(object sender, RoutedEventArgs e)
        {
            TreeMenuItem curTreeMenuItem = (TreeMenuItem)((TreeViewItem)((Grid)((Border)((ContentPresenter)((StackPanel)((Button)sender).Parent).TemplatedParent).Parent).Parent).TemplatedParent).DataContext;

            EffectType effectType = EffectType._EFFECT_ENUM_MAX;

            foreach (var pair in m_treeMenuItemsMap)
            {
                if (pair.Value == curTreeMenuItem)
                {
                    effectType = pair.Key;

                    break;
                }
            }

            if (effectType != EffectType._EFFECT_ENUM_MAX)
            {
                EffectInfo effectInfo = EffectsMap[effectType];
                EffectData effectData = GetEffectData(effectType);

                EffectConfig effectConfig = new EffectConfig(effectData, effectInfo);
                effectConfig.ShowDialog();

                if (effectConfig.IsSaved)
                {
                    effectData.TimedType = effectConfig.effectconf_timer_type_enable.IsChecked.Value ? (EffectTimedType)effectConfig.effectconf_timer_type.SelectedIndex
                        : effectInfo.IsShort ? EffectTimedType.TIMED_SHORT : EffectTimedType.TIMED_NORMAL;
                    effectData.CustomTime = effectConfig.effectconf_timer_time_enable.IsChecked.Value
                        ? effectConfig.effectconf_timer_time.Text.Length > 0 ? int.Parse(effectConfig.effectconf_timer_time.Text) : -1 : -1;
                    effectData.Permanent          = effectConfig.effectconf_timer_permanent_enable.IsChecked.Value;
                    effectData.WeightMult         = effectConfig.effectconf_effect_weight_mult.SelectedIndex + 1;
                    effectData.ExcludedFromVoting = effectConfig.effectconf_exclude_voting_enable.IsChecked.Value;
                    effectData.CustomName         = effectConfig.effectconf_effect_custom_name.Text.Trim();
                    Key shortcut = (Key)effectConfig.effectconf_effect_shortcut_combo.SelectedItem;
                    effectData.Shortcut = KeyInterop.VirtualKeyFromKey(shortcut);
                }
            }
        }
Exemple #4
0
        private void effect_user_config_Click(object sender, RoutedEventArgs e)
        {
            TreeMenuItem curTreeMenuItem = (TreeMenuItem)((TreeViewItem)((Grid)((Border)((ContentPresenter)((StackPanel)((Button)sender).Parent).TemplatedParent).Parent).Parent).TemplatedParent).DataContext;

            EffectType effectType = EffectType._EFFECT_ENUM_MAX;

            foreach (var pair in TreeMenuItemsMap)
            {
                if (pair.Value == curTreeMenuItem)
                {
                    effectType = pair.Key;

                    break;
                }
            }

            if (effectType != EffectType._EFFECT_ENUM_MAX)
            {
                EffectInfo effectInfo = EffectsMap[effectType];
                EffectData effectData = EffectDataMap[effectType];

                EffectConfig effectConfig = new EffectConfig(effectData, effectInfo);
                effectConfig.Title = effectInfo.Name;
                effectConfig.ShowDialog();

                if (effectConfig.IsSaved)
                {
                    effectData.EffectTimedType = effectConfig.effectconf_timer_type_enable.IsChecked.Value ? (EffectTimedType)effectConfig.effectconf_timer_type.SelectedIndex
                        : effectInfo.IsShort ? EffectTimedType.TIMED_SHORT : EffectTimedType.TIMED_NORMAL;
                    effectData.EffectCustomTime = effectConfig.effectconf_timer_time_enable.IsChecked.Value
                        ? effectConfig.effectconf_timer_time.Text.Length > 0 ? int.Parse(effectConfig.effectconf_timer_time.Text) : -1 : -1;
                    effectData.EffectPermanent = effectConfig.effectconf_timer_permanent_enable.IsChecked.Value;
                    effectData.EffectWeight    = effectConfig.effectconf_effect_weight.SelectedIndex + 1;
                }
            }
        }
        private void rename_written_effects(int lang)
        {
            for (EffectType effectType = 0; effectType < EffectType._EFFECT_ENUM_MAX; effectType++)
            {
                EffectData effectData = GetEffectData(effectType);

                string customName;
                string translatedName = getTranslation(EffectsMap[effectType].Id, lang);
                if (effectData.CustomName == "" && effectData.CustomName != translatedName)
                {
                    customName = getTranslation(EffectsMap[effectType].Id, lang_list.SelectedIndex);
                }
                else
                {
                    customName = effectData.CustomName;
                }

                m_effectsFile.WriteValue(EffectsMap[effectType].Id, $"{(m_treeMenuItemsMap[effectType].IsChecked ? 1 : 0)},{(effectData.TimedType == EffectTimedType.TIMED_NORMAL ? 0 : 1)}"
                                         + $",{effectData.CustomTime},{effectData.WeightMult},{(effectData.Permanent ? 1 : 0)},{(effectData.ExcludedFromVoting ? 1 : 0)}"
                                         + $",{customName}");

                m_effectsFile.WriteFile();
            }
        }
Exemple #6
0
        public EffectConfig(EffectData effectData, EffectInfo effectInfo, int lang)
        {
            InitializeComponent();

            effect_rename.Content = Lang.effect_config("effect_rename", lang);
            effect_override_timer_type.Content             = Lang.effect_config("effect_override_timer_type", lang);
            effect_override_timer_manual.Content           = Lang.effect_config("effect_override_timer_manual", lang);
            effect_make_permanent.Content                  = Lang.effect_config("effect_make_permanent", lang);
            effectconf_effect_weight_mult_title.Content    = Lang.effect_config("effectconf_effect_weight_mult_title", lang);
            effectconf_exclude_voting_enable_title.Content = Lang.effect_config("effectconf_exclude_voting_enable_title", lang);
            effectconf_mp3_label.Text = Lang.effect_config("effectconf_mp3_label", lang) + $"{effectInfo.Id}.mp3";
            button_save.Content       = Lang.effect_config("button_save", lang);

            Title = effectInfo.Name;

            m_isTimedEffect = effectInfo.IsTimed;

            if (m_isTimedEffect)
            {
                effectconf_timer_type_enable.IsChecked = effectData.TimedType != (effectInfo.IsShort ? EffectTimedType.TIMED_SHORT : EffectTimedType.TIMED_NORMAL);
                effectconf_timer_type.ItemsSource      = new string[]
                {
                    "Normal",
                    "Short"
                };
                effectconf_timer_type.SelectedIndex = effectData.TimedType == EffectTimedType.TIMED_SHORT ? 1 : 0;

                if (effectData.CustomTime >= 0)
                {
                    effectconf_timer_time_enable.IsChecked = true;
                    effectconf_timer_time.Text             = $"{effectData.CustomTime}";
                }
            }

            effectconf_timer_permanent_enable.IsChecked = effectData.Permanent;

            int[] weightItems = new int[10];
            for (int i = 0; i < 10; i++)
            {
                weightItems[i] = i + 1;
            }
            effectconf_effect_weight_mult.ItemsSource   = weightItems;
            effectconf_effect_weight_mult.SelectedIndex = effectData.WeightMult - 1;

            effectconf_exclude_voting_enable.IsChecked = effectData.ExcludedFromVoting;

            effectconf_effect_custom_name.Text = $"{(Title == effectData.CustomName ? "" : effectData.CustomName)}";

            effectconf_mp3_label.Text += $"{effectInfo.Id}.mp3";

            // Meta Effect Handling

            if (effectInfo.EffectCategory == EffectCategory.META)
            {
                effectconf_exclude_voting_enable_title.Visibility = Visibility.Hidden;
                effectconf_exclude_voting_enable.Visibility       = Visibility.Hidden;
                effectconf_exclude_voting_enable.IsChecked        = false;
            }

            CheckEnableConfigurables();
        }
Exemple #7
0
        public EffectConfig(EffectData effectData, EffectInfo effectInfo)
        {
            InitializeComponent();

            Title = effectInfo.Name;

            m_isTimedEffect = effectInfo.IsTimed;

            if (m_isTimedEffect)
            {
                effectconf_timer_type_enable.IsChecked = effectData.TimedType != (effectInfo.IsShort ? EffectTimedType.TIMED_SHORT : EffectTimedType.TIMED_NORMAL);
                effectconf_timer_type.ItemsSource      = new string[]
                {
                    "Normal",
                    "Short"
                };
                effectconf_timer_type.SelectedIndex = effectData.TimedType == EffectTimedType.TIMED_SHORT ? 1 : 0;

                if (effectData.CustomTime >= 0)
                {
                    effectconf_timer_time_enable.IsChecked = true;
                    effectconf_timer_time.Text             = $"{effectData.CustomTime}";
                }
            }

            effectconf_timer_permanent_enable.IsChecked = effectData.Permanent;

            int[] weightItems = new int[10];
            for (int i = 0; i < 10; i++)
            {
                weightItems[i] = i + 1;
            }
            effectconf_effect_weight_mult.ItemsSource   = weightItems;
            effectconf_effect_weight_mult.SelectedIndex = effectData.WeightMult - 1;

            effectconf_exclude_voting_enable.IsChecked = effectData.ExcludedFromVoting;

            effectconf_effect_custom_name.Text         = effectData.CustomName;
            effectconf_effect_custom_name.TextChanged += CustomEffectNameTextFieldTextChanged;
            effectconf_effect_custom_name.KeyDown     += Effectconf_effect_custom_name_KeyDown;

            effectconf_mp3_label.Text = $@"
                Sound to play when this effect gets activated: chaosmod/sounds/{effectInfo.Id}.mp3
                Or create the following folder and drop mp3 files in there to play a random one: chaosmod/sounds/{effectInfo.Id}
                ";

            // Meta Effect Handling

            if (effectInfo.EffectCategory == EffectCategory.META)
            {
                effectconf_exclude_voting_enable_title.Visibility = Visibility.Hidden;
                effectconf_exclude_voting_enable.Visibility       = Visibility.Hidden;
                effectconf_exclude_voting_enable.IsChecked        = false;
            }

            // Shortcut
            List <Key> availableKeys = new List <Key> {
                Key.None,
                Key.F1, Key.F2, Key.F3, Key.F4, Key.F5, Key.F6, Key.F7, Key.F8, Key.F9, Key.F10, Key.F11, Key.F12, Key.F13, Key.F14, Key.F15, Key.F16, Key.F17, Key.F18, Key.F19, Key.F20, Key.F21, Key.F22, Key.F23, Key.F24,
                Key.NumPad0, Key.NumPad1, Key.NumPad2, Key.NumPad3, Key.NumPad4, Key.NumPad5, Key.NumPad6, Key.NumPad7, Key.NumPad8, Key.NumPad9,
                Key.Multiply, Key.Divide, Key.Subtract, Key.Add, Key.Separator
            };
            Key selectedKey = Key.None;

            if (int.TryParse(effectData.Shortcut.ToString(), out int savedWin32Key) && savedWin32Key >= 0)
            {
                selectedKey = KeyInterop.KeyFromVirtualKey(savedWin32Key);
            }

            effectconf_effect_shortcut_combo.ItemsSource  = availableKeys;
            effectconf_effect_shortcut_combo.SelectedItem = selectedKey;

            CheckEnableConfigurables();
        }