private void LoadSettings()
        {
            if (_ELITEAPI == null)
            {
                var msg = new CustomMessageDialog("ERROR", "You must select a character before loading configuration settings.");
                msg.ShowDialog();
                return;
            }

            OpenFileDialog openFileDialog = new OpenFileDialog
            {
                Filter           = "Text files (*.txt)|*.txt",
                InitialDirectory = ConfigPath
            };

            if (openFileDialog.ShowDialog() == true)
            {
                SendCommand("hb reload");
                Thread.Sleep(1000);

                Toggle_Attack.IsOn       = false;
                Toggle_Curing.IsOn       = false;
                Toggle_Curaga.IsOn       = false;
                Toggle_Na.IsOn           = false;
                Toggle_Erase.IsOn        = false;
                Toggle_Buffs.IsOn        = false;
                Toggle_Debuffs.IsOn      = false;
                Toggle_IgnoreTrusts.IsOn = false;

                LoadSettingsFromConfig(openFileDialog.FileName);
            }
        }
Пример #2
0
        private void Button_RemoveSet_Click(object sender, RoutedEventArgs e)
        {
            var set = cb_CurePotencySets.SelectedItem != null?cb_CurePotencySets.SelectedItem.ToString() : string.Empty;

            var job = cb_CurePotencySetsJobs.SelectedItem != null?cb_CurePotencySetsJobs.SelectedItem.ToString() : string.Empty;

            if (string.IsNullOrEmpty(set) && string.IsNullOrEmpty(job))
            {
                return;
            }
            else if (string.IsNullOrEmpty(job) && (set == "default" || set == "None"))
            {
                var msg = new CustomMessageDialog("Denied", "You are not allowed to remove the following required sets: 'default', 'None'");
                msg.ShowDialog();
                return;
            }

            if (!string.IsNullOrEmpty(set) && string.IsNullOrEmpty(job))
            {
                // remove the whole set because a job wasn't selected.
                ModifiedCurePotencySets.Remove(set);
                SetupSetsCombobox();
            }
            else
            {
                // remove the job from the set.
                ModifiedCurePotencySets[set].Remove(job);
                SetupSetsCombobox();
                cb_CurePotencySets.SelectedItem = set;
            }

            ClearPotencyTextBoxes();
        }
        private void Button_EditPriorities_Click(object sender, RoutedEventArgs e)
        {
            if (_HbData == null)
            {
                return;
            }

            var popup = new PrioritiesWindow(_HbData.PrioritySets);

            if (popup.ShowDialog() == true)
            {
                _HbData.PrioritySets = popup.ModifiedPrioritySets;
                if (!_HbData.SavePrioritySets())
                {
                    var msg = new CustomMessageDialog("ERROR", "There was an issue saving the data to priorities.lua");
                    msg.ShowDialog();
                }
            }
        }
        private void Button_EditCurePotency_Click(object sender, RoutedEventArgs e)
        {
            if (_HbData == null)
            {
                return;
            }

            var popup = new CurePotencyWindow(_HbData.CurePotencySets);

            if (popup.ShowDialog() == true)
            {
                _HbData.CurePotencySets = popup.ModifiedCurePotencySets;
                if (!_HbData.SaveCurePotencySets())
                {
                    var msg = new CustomMessageDialog("ERROR", "There was an issue saving the data to cure_potency.lua");
                    msg.ShowDialog();
                }
            }
        }
Пример #5
0
        private void Button_AddNewSet_Click(object sender, RoutedEventArgs e)
        {
            var set = txt_NewSetName.Text;
            var job = cb_NewSetJob.SelectedItem != null?cb_NewSetJob.SelectedItem.ToString() : string.Empty;

            if (string.IsNullOrEmpty(set) || string.IsNullOrEmpty(job))
            {
                return;
            }

            // get default to use as a base.
            var baseSettings = ModifiedCurePotencySets["default"][""];

            var checkForJob = string.Empty;

            var checkForSet = ModifiedCurePotencySets.Keys.Where(x => x.ToLower() == set.ToLower()).FirstOrDefault();

            if (checkForSet == null)
            {
                ModifiedCurePotencySets.Add(set, new Dictionary <string, Dictionary <string, List <int> > >());
            }
            else
            {
                set = checkForSet;
            }

            checkForJob = ModifiedCurePotencySets[set].Keys.Where(x => x.ToLower() == job.ToLower()).FirstOrDefault();
            if (checkForJob != null)
            {
                var msg = new CustomMessageDialog("ERROR", "Job for this set already exists. Modify the existing Set > Job.");
                msg.ShowDialog();

                SetComboboxesSelectedItems(set, job);
            }
            else
            {
                ModifiedCurePotencySets[set].Add(job, baseSettings);
                SetupSetsCombobox();
                SetComboboxesSelectedItems(set, job);
            }
            ClearAddFields();
        }
        private void Select_HealbotPlayer_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (IsAdministrator())
            {
                var cb       = (ComboBox)sender;
                var selected = (ComboboxItem)cb.SelectedItem;
                _ELITEAPI = new EliteAPI((int)selected.Value);

                FillLists(true);
                SetupDefaults();
            }
            else
            {
                var msg = new CustomMessageDialog("ERROR", "You must run this program as ADMINISTRATOR!");
                msg.ShowDialog();
                Select_HealbotPlayer.SelectedIndex = -1;
            }

            GetHbData();
        }
        private void Button_DeleteBuffList_Click(object sender, RoutedEventArgs e)
        {
            var player = "me";

            if (_ELITEAPI != null)
            {
                player = _ELITEAPI.Player.Name;
            }

            var sel_bufflist = Select_BuffList.SelectedItem != null ? (string)Select_BuffList.SelectedItem : !string.IsNullOrEmpty(Select_BuffList.Text) ? Select_BuffList.Text : string.Empty;

            if (string.IsNullOrEmpty(sel_bufflist))
            {
                return;
            }

            var splat = sel_bufflist.Split();
            var set   = splat[0];

            var inner = string.Empty;

            if (splat.Length > 1 && splat[1] != player)
            {
                inner = splat[1];
            }

            var msg = new CustomMessageDialog("Success!", "Buff List: '" + sel_bufflist + "' was removed from [..healbot\\data\\buffLists.lua]");

            // remove it from the data set
            if (_HbData.RemoveBuffList(set, inner))
            {
                // no need to reload the data, just remove it from the select
                Select_BuffList.Items.Remove(sel_bufflist);
            }
            else
            {
                msg = new CustomMessageDialog("ERROR", "An error occured while trying to remove the set of buffs!" + Environment.NewLine + Environment.NewLine + "Buff list name: '" + sel_bufflist + "'");
            }
            msg.ShowDialog();
        }
        private void Button_SaveBuffs_Click(object sender, RoutedEventArgs e)
        {
            if (_HbData == null)
            {
                return;
            }

            var inputDialog = new CustomInputDialog("Buff list name:", "mybuffs");

            if (inputDialog.ShowDialog() == true)
            {
                var bufflistname = inputDialog.DialogValue;
                if (!string.IsNullOrEmpty(bufflistname))
                {
                    bufflistname = bufflistname.ToLower().Trim();

                    // handle duplicate list names automatically
                    var check = _HbData.BuffLists.Where(x => x.Name.ToLower() == bufflistname).FirstOrDefault();
                    if (check != null)
                    {
                        int i = 1;
                        while (check != null)
                        {
                            i++;
                            var temp = bufflistname + i.ToString();
                            check = _HbData.BuffLists.Where(x => x.Name.ToLower() == temp).FirstOrDefault();
                        }
                    }

                    var buffs = new List <string>();
                    foreach (var item in Lb_Buffs.Items)
                    {
                        if (item.ToString().Contains(_ELITEAPI.Player.Name))
                        {
                            buffs.Add(item.ToString().Replace(_ELITEAPI.Player.Name + " ", "").Trim());
                        }
                    }

                    var bufflist = new BuffList
                    {
                        Name = bufflistname,
                        List = new Dictionary <string, List <string> > {
                            { "me", buffs }
                        }
                    };

                    var msg = new CustomMessageDialog("Saved!", "Buff List: '" + bufflistname + "' has been saved to [..healbot\\data\\buffLists.lua]");
                    if (_HbData.SaveBuffList(bufflist))
                    {
                        _HbData = new HealbotData(Settings.Default.WindowerPath);                         // reload the settings
                    }
                    else
                    {
                        msg = new CustomMessageDialog("ERROR", "An error occured while trying to save the set of buffs!" + Environment.NewLine + Environment.NewLine + "Buff list name: '" + bufflistname + "'");
                    }

                    msg.ShowDialog();
                }
            }
            else
            {
                var msg = new CustomMessageDialog("ERROR", "A name must be provided in order to save the buffs as a list in [..healbot\\data\\buffLists.lua]");
                msg.ShowDialog();
            }
        }