Ejemplo n.º 1
0
 private void BValidate_Click(object sender, RoutedEventArgs e)
 {
     if (!String.IsNullOrWhiteSpace(tbMercenaryCode.Text))
     {
         testMerc = new MercenaryItem(tbMercenaryCode.Text);
         if (testMerc.ValidateMercenaryCode())
         {
             if (testMerc.isHordeMercenary)
             {
                 MessageBox.Show("Horde Mercenary code successfully validated, you may now import this mercenary!", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                 bSave.IsEnabled = true;
             }
             else
             {
                 MessageBox.Show("Mercenary code successfully validated, you may now import this mercenary!", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                 bSave.IsEnabled = true;
             }
         }
         else
         {
             MessageBox.Show("The code does not appear to be valid! Make sure you copied the code correctly and try again.\n\nI'm a bit stupid at the moment, in the future I might be able to help you!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
         }
     }
     else
     {
         MessageBox.Show("I can't validate something that doesn't exist you dum-dum. Try actually pasting something, huh? What do you take me for?!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
Ejemplo n.º 2
0
        private void BReplace_Click(object sender, RoutedEventArgs e)
        {
            MercenaryItem selectedMerc = lbConflictedMercenaries.SelectedItem as MercenaryItem;

            if (selectedMerc != null)
            {
                ListBoxItem item1 = (ListBoxItem)lbConflictedMercenaries.ItemContainerGenerator.ContainerFromItem(lbConflictedMercenaries.SelectedItem);
                ListBoxItem item2 = (ListBoxItem)lbNewMercenaries.ItemContainerGenerator.ContainerFromItem(lbNewMercenaries.SelectedItem);

                //MessageBox.Show(String.Format("Replace\n{0}\n\nWith\n{1}", selectedMerc.OriginalEntry, item2.Content));
                selectedMerc.OriginalEntry = item2.Content.ToString();

                lbConflictedMercenaries.SelectedIndex = -1;
                lbNewMercenaries.SelectedIndex        = -1;

                item1.IsEnabled = false;
                item2.IsEnabled = false;
            }
            // Check if any Mercs left
            for (int i = 0; i < lbConflictedMercenaries.Items.Count; i++)
            {
                ListBoxItem item = (ListBoxItem)lbConflictedMercenaries.ItemContainerGenerator.ContainerFromIndex(i);
                if (item.IsEnabled)
                {
                    return;
                }
            }
            bSave.IsEnabled = true;
        }
Ejemplo n.º 3
0
        public void ProcessMercenaries()
        {
            int counter = 0;

            foreach (string parsedMercenary in parsedMercenaries)
            {
                // Create a new mercenary
                MercenaryItem mercenary = new MercenaryItem(parsedMercenary);
                mercenary.index = counter;
                counter++;
                // Name + ItemText
                Regex rx = new Regex("\"(.*?)\"");                                  // Use Regex to find the mercenary's name
                mercenary.Name = rx.Match(parsedMercenary).Value.Replace("\"", ""); // Once found, remove the quotation marks - they were only used to help find the name
                // Check if the Name is empty, if true - that means it's the Horde character and needs to be handled differently
                if (!String.IsNullOrWhiteSpace(mercenary.Name))
                {
                    /*
                     * We parse all of this to make re-writing the config file easier later. So instead of replacing only certain values which would be a headache
                     * we just replace the entire line instead.
                     */
                    mercenary.OriginalName = mercenary.Name;
                    mercenary.ItemText     = mercenary.Name; // Set ItemText to be same as the name - this is what's actually shown in the ListBox
                    // Parse the Gear Customization
                    rx = new Regex(@"GearCustomization=\(.+\)\)\)");
                    mercenary.GearString = rx.Match(parsedMercenary).Value;
                    // Parse the Appearance Customization
                    rx = new Regex(@"AppearanceCustomization=\(.+\),F");
                    mercenary.AppearanceString = rx.Match(parsedMercenary).Value.Replace("),F", ")");
                    // Parse the Face Customization
                    rx = new Regex(@"FaceCustomization=\(.+\)\),");
                    mercenary.FaceString = rx.Match(parsedMercenary).Value.Replace(")),", "))");
                    // Parse the Skills
                    rx = new Regex(@"SkillsCustomization=\(.+\),");
                    mercenary.SkillString = rx.Match(parsedMercenary).Value.Replace("),", ")");
                    rx = new Regex(@"Category=.+\)");
                    mercenary.CategoryString = rx.Match(parsedMercenary).Value.Replace(")", "");
                }
                else
                {
                    mercenary.OriginalName = "Horde Mercenary";
                    mercenary.Name         = "Horde Mercenary";
                    mercenary.ItemText     = mercenary.Name;
                    // Parse the Face Customization
                    rx = new Regex(@"(DefaultCharacterFace=\(.+)");
                    mercenary.FaceString       = rx.Match(parsedMercenary).Value;
                    mercenary.isHordeMercenary = true;
                }
                if (mercenary.ParseFaceValues())
                {
                    Mercenaries.Add(mercenary);
                }
                else
                {
                    // We already get an error message in ParseFaceValues()
                    //System.Windows.MessageBox.Show(String.Format("There was an error trying to parse mercenary: {0}.", mercenary.Name), "Warning", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning);
                }
            }
        }
Ejemplo n.º 4
0
        private void BValidate_Click(object sender, RoutedEventArgs e)
        {
            List <string>        parsedMercenaries = new List <string>();
            List <MercenaryItem> _invalidMercs     = new List <MercenaryItem>();

            if (!String.IsNullOrWhiteSpace(tbMercenaryCode.Text))
            {
                _mercenaryList.Clear(); // Clear List For Next Validation

                Regex profile = new Regex(@"^CharacterProfiles=\(.+\)", RegexOptions.Multiline);
                Regex ws      = new Regex(@"^\s+CharacterProfiles=\(.+\)", RegexOptions.Multiline); // We'll also look for any leading whitespace
                Regex horde   = new Regex(@"(DefaultCharacterFace=\(.+)");
                foreach (Match match in profile.Matches(tbMercenaryCode.Text))
                {
                    parsedMercenaries.Add(match.Value);
                }
                foreach (Match match in ws.Matches(tbMercenaryCode.Text))
                {
                    parsedMercenaries.Add(match.Value.TrimStart());
                }
                if (horde.IsMatch(tbMercenaryCode.Text))
                {
                    parsedMercenaries.Add(horde.Match(tbMercenaryCode.Text).Value);
                }

                foreach (string parsedMercenary in parsedMercenaries)
                {
                    MercenaryItem mercenary = new MercenaryItem(parsedMercenary);
                    if (mercenary.ValidateMercenaryCode())
                    {
                        _mercenaryList.Add(mercenary);
                        bSave.IsEnabled = true;
                    }
                    else
                    {
                        _invalidMercs.Add(mercenary);
                    }
                }
                _mercenaryList.Reverse(); // Reverse the list so it appears in the order it was pasted in
                if (_mercenaryList.Count == 0 && _invalidMercs.Count == 0)
                {
                    MessageBox.Show("Invalid mercenary code! Make sure you copied the code correctly and try again.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                else
                {
                    MessageBox.Show(String.Format("{0} mercenaries successfully validated!\n\n{1} mercenaries failed to validate!", _mercenaryList.Count, _invalidMercs.Count), "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
            else
            {
                MessageBox.Show("Cannot validate empty code, you dummy!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Ejemplo n.º 5
0
        public CompareWindow(MercenaryItem modifiedMerc, List <string> newMercs)
        {
            InitializeComponent();

            Owner = Application.Current.MainWindow;

            ModifiedMercs.Add(modifiedMerc);
            NewMercs = newMercs;

            lbConflictedMercenaries.ItemsSource = ModifiedMercs;
            lbNewMercenaries.ItemsSource        = NewMercs;

            SolidColorBrush newColor = (Properties.Settings.Default.appTheme == "Dark") ? new SolidColorBrush(Color.FromRgb(69, 69, 69)) : new SolidColorBrush(Color.FromRgb(245, 245, 245));

            gBackground.Background = newColor;
        }
Ejemplo n.º 6
0
        public MercenaryEditor(MercenaryItem selectedMerc)
        {
            InitializeComponent();
            mercenary = selectedMerc;

            Owner = Application.Current.MainWindow; // Set MainWindow as owner, so it'll make proper use of WindowStartupLocation.Owner
            #region Update colours to fit the active theme + alternating colors for readability
            Tuple <AppTheme, Accent> appStyle = ThemeManager.DetectAppStyle(Application.Current);
            if (appStyle.Item1.Name == "BaseDark")
            {
                gBackground.Background = new SolidColorBrush(Color.FromRgb(55, 55, 55));
                dgValueList.AlternatingRowBackground = new SolidColorBrush(Color.FromRgb(55, 55, 55));
            }
            else
            {
                gBackground.Background = new SolidColorBrush(Color.FromRgb(245, 245, 245));
                dgValueList.AlternatingRowBackground = new SolidColorBrush(Color.FromRgb(235, 235, 235));
            }
            #endregion

            string[] nameValue =
            { "Mouth - Middle",                  "Mouth - Edges",          "Maxilla",           "Left Eyebrow",         "Unknown Value [1]",     "Right Eyebrow",         "Right Eye",
              "Unknown Value [2]",           "Unknown Value [3]",      "Unknown Value [4]", "Mouth",                "Left Eye",              "Lips - Left Edge",      "Lips - Right Edge",
              "Chin",                        "Jaw - Left",             "Jaw - Right",       "Lower Lip",            "Lower Lip - Left",      "Lower Lip - Right",     "Infraorbital Margin - Left",
              "Medial Cleft",                "Lip - Left",             "Lip - Right",       "Philtrum",             "Nose - Tip",            "Nose Bridge",           "Nose Bridge - Top",
              "Infraorbital Margin - Right", "Cheek - Left",           "Cheek - Right",     "Left Eyebrow - Inner", "Right Eyebrow - Inner", "Left Eyebrow - Middle", "Right Eyebrow - Middle",
              "Left Eyebrow - Outter",       "Right Eyebrow - Outter", "Ear - Left",        "Ear - Right",          "Unknown Value [5]",     "Unknown Value [6]",     "Left Eyelid - Top",
              "Left Eyelid - Bottom",        "Unknown Value [7]",      "Unknown Value [8]", "Right Eyelid - Top",   "Right Eyelid - Bottom", "Cheekbone - Left",      "Cheekbone - Right" };

            // Create 49 sliders, it consists of 3 separate sliders - one for each value
            dgValueList.ItemsSource = _sliders;
            for (int i = 0; i < 49; i++)
            {
                var newSlider = new FaceValueSliderItem();
                newSlider.Translation = selectedMerc.FaceValues[i].Translation;
                newSlider.Rotation    = selectedMerc.FaceValues[i].Rotation;
                newSlider.Scale       = selectedMerc.FaceValues[i].Scale;
                //newSlider.UpdateDescription(String.Format("{0}: Unknown Value", (i + 1)));
                newSlider.UpdateDescription(string.Format(nameValue[i]));
                _sliders.Add(newSlider);
            }
            tbNewName.IsEnabled = !mercenary.isHordeMercenary;
        }
Ejemplo n.º 7
0
        public MercenaryEditor(MercenaryItem selectedMerc)
        {
            InitializeComponent();
            mercenary = selectedMerc;

            Owner = Application.Current.MainWindow; // Set MainWindow as owner, so it'll make proper use of WindowStartupLocation.Owner
            #region Update colours to fit the active theme + alternating colors for readability
            Tuple <AppTheme, Accent> appStyle = ThemeManager.DetectAppStyle(Application.Current);
            if (appStyle.Item1.Name == "BaseDark")
            {
                gBackground.Background = new SolidColorBrush(Color.FromRgb(69, 69, 69));
                dgValueList.AlternatingRowBackground = new SolidColorBrush(Color.FromRgb(69, 69, 69));
            }
            else
            {
                gBackground.Background = new SolidColorBrush(Color.FromRgb(245, 245, 245));
                dgValueList.AlternatingRowBackground = new SolidColorBrush(Color.FromRgb(245, 245, 245));
            }
            #endregion

            // Create 49 sliders, it consists of 3 separate sliders - one for each value
            dgValueList.ItemsSource = _sliders;

            string[] nameValue =
            { "middle part of mouth",          "left&right part of mouth", "nose to bottom",     "left eyebrow",         "(to test)nothing",      "right eyebrow",          "right eye",
              "(to test)nothing",          "(to test)nothing",         "(to test)nothing",   "mouth",                "left eye",              "left lip commissure",    "right lip commissure",
              "chin",                      "bottom left cheek",        "bottom right cheek", "bottom of lip",        "bottom left of lip",    "bottom right of lip",    "top left cheek",
              "bottom philtrum",           "left lip",                 "right lip",          "top philtrum",         "nose to top",           "bottom glabella",        "top glabella",
              "right infraorbital margin", "middle cheek left",        "middle cheek right", "head of left eyebrow", "head of right eyebrow", "middle of left eyebrow", "middle of right eyebrow",
              "tail of left eyebrow",      "tail of right eyebrow",    "left hear",          "right hear",           "(to test)nothing",      "top left eyelid",        "left bottom eyelid",
              "(to test)nothing",          "(to test)nothing",         "(to test)nothing",   "top right eyelid",     "bottom right eyelid",   "left cheek #4",          "right cheek #4" };
            for (int i = 0; i < 49; i++)
            {
                var newSlider = new FaceValueSliderItem();
                newSlider.Translation = selectedMerc.FaceValues[i].Translation;
                newSlider.Rotation    = selectedMerc.FaceValues[i].Rotation;
                newSlider.Scale       = selectedMerc.FaceValues[i].Scale;
                newSlider.UpdateDescription(String.Format(nameValue[i]));
                _sliders.Add(newSlider);
            }
            tbNewName.IsEnabled = !mercenary.isHordeMercenary;
        }