Exemplo n.º 1
0
        private void continueButton_Click(object sender, RoutedEventArgs e)
        {
            var simc = ((TextBox)this.FindName("SimC")).Text;

            if (simc == null || simc.Length == 0)
            {
                return;
            }
            var window = new SimcRunner();

            window.Top             = App.Current.MainWindow.Top;
            window.Left            = App.Current.MainWindow.Left;
            App.Current.MainWindow = window;
            var nameCache = new HashSet <string>();

            LoadCharacterSet((SimcRunnerData)window.DataContext,
                             SimC.Text.Split(new string[] { "\n\n", "\r\n\r\n" }, StringSplitOptions.RemoveEmptyEntries)
                             .Select(x => x.Trim())
                             .Where(x => x.Length > 0)
                             .Select(x => {
                var nameClassRegex = new Regex("([^=]+)=\"?([^\r\n\"]+)\"?");
                var name           = nameClassRegex.Match(x).Groups[2].Value;
                var tempName       = name;
                int i = 0;
                while (nameCache.Contains(tempName))
                {
                    tempName = name + i++;
                }
                name = tempName;
                nameCache.Add(name);
                if (!nameCache.Contains(name))
                {
                    nameCache.Add(name);
                }
                var path    = "./characters/" + name + ".simc";
                var profile = x + "\nsave=" + path;
                if (!Directory.Exists("characters"))
                {
                    Directory.CreateDirectory("characters");
                }
                File.WriteAllText(path, profile);
                return(path);
            }).ToList(),
                             1);
            this.Close();
            window.Show();
        }
Exemplo n.º 2
0
        private void Simulate_Click(object sender, RoutedEventArgs e)
        {
            var   context = (SimQueueData)this.DataContext;
            Model selectedModel;
            var   potentialMatch = models.Where((model) =>
            {
                return(model.dispName.Equals(context.SelectedModel));
            });

            if (potentialMatch.Count() > 0)
            {
                selectedModel = potentialMatch.ElementAt(0);
            }
            else
            {
                return;
            }
            var guid    = Guid.NewGuid().ToString().Substring(0, 8);
            var simList = new List <string>();

            foreach (var sim in selectedModel.model.Keys)
            {
                if (selectedModel.timeModel.Count != 0)
                {
                    foreach (var time in selectedModel.timeModel.Keys)
                    {
                        simList.Add(SimHelper.CreateSimForModel(sim, time, context.PTRMode, context.FixedIterationOrError != 0, context.Sims.ToList(), !context.DisableStatWeights,
                                                                context.ReforgeEnabled, context.ReforgeHaste, context.ReforgeCrit, context.ReforgeVers, context.ReforgeMastery, context.ReforgeAmount,
                                                                context.ReforgeStepSize, context.Threads, guid, false, true));
                    }
                }
                else
                {
                    simList.Add(SimHelper.CreateSimForModel(sim, null, context.PTRMode, context.FixedIterationOrError != 0, context.Sims.ToList(), !context.DisableStatWeights,
                                                            context.ReforgeEnabled, context.ReforgeHaste, context.ReforgeCrit, context.ReforgeVers, context.ReforgeMastery, context.ReforgeAmount,
                                                            context.ReforgeStepSize, context.Threads, guid, false, true));
                }
            }
            var window = new SimcRunner();

            window.Top             = App.Current.MainWindow.Top;
            window.Left            = App.Current.MainWindow.Left;
            App.Current.MainWindow = window;
            LoadMagicsimLoadout((SimcRunnerData)window.DataContext, simList, context.Processes, selectedModel);
            this.Close();
            window.Show();
        }
Exemplo n.º 3
0
        private void Simulate_Click(object sender, RoutedEventArgs e)
        {
            var   context = (SimQueueData)this.DataContext;
            Model selectedModel;
            var   potentialMatch = models.Where((model) =>
            {
                return(model.dispName.Equals(context.SelectedModel));
            });

            if (potentialMatch.Count() > 0)
            {
                selectedModel = potentialMatch.ElementAt(0);
            }
            else
            {
                return;
            }
            var guid           = Guid.NewGuid().ToString().Substring(0, 8);
            var simList        = new List <string>();
            var createModelSim = new Action <string, string>((string sim, string time) => {
                try
                {
                    var simProfile = "";
                    if (context.PTRMode)
                    {
                        simProfile += "ptr=1";
                    }
                    context.Sims.ToList().ForEach((simChar) =>
                    {
                        var nameRegex   = new Regex("[^=]+=\"?([^\r\n\"]+)\"?");
                        simChar.Profile = simChar.Profile.Replace(nameRegex.Match(simChar.Profile).Groups[1].Value, simChar.Name);
                        simProfile     += simChar.Profile + "\r\n";
                    });
                    if (context.FixedIterationOrError != 0)
                    {
                        simProfile += "target_error=0.1\r\n";
                    }
                    simProfile += "iterations=10000\r\nthreads=" + context.Threads + "\r\noptimize_expressions=1\r\noptimal_raid=1\r\n";
                    if (time != null)
                    {
                        simProfile += "max_time=" + time + "\r\n";
                    }
                    if (Directory.EnumerateFiles("adaptiveTemplates").Contains("adaptiveTemplates" + System.IO.Path.DirectorySeparatorChar + sim + ".simc"))
                    {
                        simProfile += File.ReadAllText("adaptiveTemplates" + System.IO.Path.DirectorySeparatorChar + sim + ".simc") + "\r\n";
                    }
                    else
                    {
                        MessageBox.Show(String.Format("Couldn't find template \"{0}\" requested. Sim results will be skewed.", sim), "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                        return;
                    }

                    var filePrefix = time != null ? "results" + System.IO.Path.DirectorySeparatorChar + guid + System.IO.Path.DirectorySeparatorChar + time + "_" + sim + "."
                        : "results" + System.IO.Path.DirectorySeparatorChar + guid + System.IO.Path.DirectorySeparatorChar + sim + ".";

                    if (context.DisableStatWeights)
                    {
                        simProfile += "calculate_scale_factors=0\r\n";
                    }
                    else
                    {
                        simProfile += "calculate_scale_factors=1\r\n";
                    }
                    if (context.ReforgeEnabled)
                    {
                        var reforge_stat = "";
                        if (context.ReforgeCrit)
                        {
                            reforge_stat += "crit";
                        }
                        if (context.ReforgeHaste)
                        {
                            if (reforge_stat.Equals(""))
                            {
                                reforge_stat += "haste";
                            }
                            else
                            {
                                reforge_stat += ",haste";
                            }
                        }
                        if (context.ReforgeMastery)
                        {
                            if (reforge_stat.Equals(""))
                            {
                                reforge_stat += "mastery";
                            }
                            else
                            {
                                reforge_stat += ",mastery";
                            }
                        }
                        if (context.ReforgeVers)
                        {
                            if (reforge_stat.Equals(""))
                            {
                                reforge_stat += "versatility";
                            }
                            else
                            {
                                reforge_stat += ",versatility";
                            }
                        }
                        if (!reforge_stat.Contains(","))
                        {
                            MessageBox.Show(String.Format("At least 2 stats are required to reforge. Reforging will be disabled.", sim), "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                        }
                        else if (context.ReforgeAmount == 0 || context.ReforgeStepSize == 0)
                        {
                            MessageBox.Show("No reforging size supplied. Reforging will be disabled", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                        }
                        else
                        {
                            simProfile += "reforge_plot_stat=" + reforge_stat + "\r\nreforge_plot_amount=" + context.ReforgeAmount + "\r\nreforge_plot_step=" + context.ReforgeStepSize + "\r\nreforge_plot_output_file=" + filePrefix + "csv\r\n";
                        }
                    }

                    simProfile += "json2=" + filePrefix + "json\r\nhtml=" + filePrefix + "html\r\n";
                    simList.Add(simProfile);
                }
                catch (Exception)
                {
                    MessageBox.Show("Failed to create your character model. You may have selected an invalid character name or advanced parameter.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    App.Current.Dispatcher.Invoke(() =>
                    {
                        var window1            = new SimQueue();
                        window1.Top            = App.Current.MainWindow.Top;
                        window1.Left           = App.Current.MainWindow.Left;
                        App.Current.MainWindow = window1;
                        this.Close();
                        window1.Show();
                    });
                    return;
                }
            });

            foreach (var sim in selectedModel.model.Keys)
            {
                if (selectedModel.timeModel.Count != 0)
                {
                    foreach (var time in selectedModel.timeModel.Keys)
                    {
                        createModelSim(sim, time);
                    }
                }
                else
                {
                    createModelSim(sim, null);
                }
            }
            var window = new SimcRunner();

            window.Top             = App.Current.MainWindow.Top;
            window.Left            = App.Current.MainWindow.Left;
            App.Current.MainWindow = window;
            LoadMagicsimLoadout((SimcRunnerData)window.DataContext, simList, context.Processes, selectedModel);
            this.Close();
            window.Show();
        }
Exemplo n.º 4
0
        private void continueButton_Click(object sender, RoutedEventArgs e)
        {
            var guid    = Guid.NewGuid().ToString().Substring(0, 8);
            var window  = new SimcRunner();
            var context = (QuickSimCustomizationData)this.DataContext;

            window.Top             = App.Current.MainWindow.Top;
            window.Left            = App.Current.MainWindow.Left;
            App.Current.MainWindow = window;
            var nameCache = new HashSet <string>();
            var simList   = new List <string>();
            var threads   = Math.Min(8, Environment.ProcessorCount);
            var profile   = "";

            Model selectedModel;
            var   potentialMatch = models.Where((model) =>
            {
                return(model.dispName.Equals(context.SelectedModel));
            });

            if (potentialMatch.Count() > 0)
            {
                selectedModel = potentialMatch.ElementAt(0);
            }
            else
            {
                return;
            }


            if (CharacterSourceControl.SelectedItem as TabItem == SimC)
            {
                profile = SimCInput.Text;
            }
            else
            {
                Properties.Settings.Default.characterName = context.Name;
                Properties.Settings.Default.realmName     = context.SelectedServer;
                Properties.Settings.Default.regionName    = context.SelectedRegion;
                profile = String.Format("armory=" + context.SelectedRegion + "," + context.SelectedServer + "," + context.Name);
            }

            foreach (var sim in selectedModel.model.Keys)
            {
                if (selectedModel.timeModel.Count != 0)
                {
                    foreach (var time in selectedModel.timeModel.Keys)
                    {
                        simList.Add(SimHelper.CreateSimForModel(sim, time, false, true, new List <Sim>()
                        {
                            new Sim()
                            {
                                Name = guid, Profile = profile
                            }
                        }, !context.DisableStatWeights,
                                                                false, false, false, false, false, 0, 0, threads, guid, context.DisableBuffs, false));
                    }
                }
                else
                {
                    simList.Add(SimHelper.CreateSimForModel(sim, null, false, true, new List <Sim>()
                    {
                        new Sim()
                        {
                            Name = guid, Profile = profile
                        }
                    }, !context.DisableStatWeights,
                                                            false, false, false, false, false, 0, 0, threads, guid, context.DisableBuffs, false));
                }
            }

            LoadMagicsimLoadout((SimcRunnerData)window.DataContext, simList, 1, selectedModel);
            this.Close();
            window.Show();
        }