Exemplo n.º 1
0
        public Main()
        {
            InitializeComponent();
            config = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath);
            bool dontupdate = false;
            if (config != null)
            {
                // it's stored as string, what is fasted yescompare?
                if (config.AppSettings.Settings.AllKeys.Contains("useEquipped") && config.AppSettings.Settings["useEquipped"].Value == true.ToString())
                {
                    useRunesCheck.Checked = true;
                    useEquipped = true;
                }
                // this?
                if (Main.config.AppSettings.Settings.AllKeys.Contains("noupdate"))
                    bool.TryParse(Main.config.AppSettings.Settings["noupdate"].Value, out dontupdate);

            }

            runes = new RuneControl[] { runeControl1, runeControl2, runeControl3, runeControl4, runeControl5, runeControl6 };
            var sorter = new ListViewSort();
            sorter.OnColumnClick(MonPriority.Index);
            listView1.ListViewItemSorter = sorter;
            listView2.ListViewItemSorter = new ListViewSort();

            sorter = new ListViewSort();
            sorter.OnColumnClick(0);
            listView5.ListViewItemSorter = sorter;

            if (!dontupdate)
            {
                Task.Factory.StartNew(() =>
                {
                    using (WebClient client = new WebClient())
                    {
                        client.DownloadStringCompleted += client_DownloadStringCompleted;
                        client.DownloadStringAsync(new Uri("https://raw.github.com/Skibisky/RuneManager/master/version.txt"));
                    }
                });
            }
            else
            {
                updateBox.Show();
                updateComplain.Text = "Updates Disabled";
                var ver = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
                string oldvernum = ver.ProductVersion;
                updateCurrent.Text = "Current: " + oldvernum;
                updateNew.Text = "";
            }

            for (int i = 0; i < 11; i++)
            {
                ToolStripItem it = new ToolStripMenuItem(i.ToString() + (i > 0 ? " (" + Math.Ceiling(i * 1.5).ToString() + "%)" : ""));
                it.Tag = (int)Math.Floor(i * 1.5);
                it.Click += ShrineClickSpeed;
                speedToolStripMenuItem.DropDownItems.Add(it);
            }
        }
Exemplo n.º 2
0
        public MonSelect(Monster c)
        {
            InitializeComponent();


            foreach (Monster mon in Program.data.Monsters)
            {
                string pri = "";
                if (mon.priority != 0)
                {
                    pri = mon.priority.ToString();
                }

                ListViewItem item = new ListViewItem(new string[] {
                    mon.FullName,
                    mon.Id.ToString(),
                    pri,
                    mon.level.ToString(),
                });
                if (mon.inStorage)
                {
                    item.ForeColor = Color.Gray;
                }

                item.Tag = mon;
                dataMonsterList.Items.Add(item);
                if (mon == c)
                {
                    item.Selected = true;
                }
            }

            var sorter = new ListViewSort();

            dataMonsterList.ListViewItemSorter = sorter;
            sorter.OnColumnClick(MonName.Index);
            sorter.OnColumnClick(MonLvl.Index);
            sorter.OnColumnClick(MonPriority.Index);
            dataMonsterList.Sort();
        }
Exemplo n.º 3
0
        public Generate(Build bb)
        {
            InitializeComponent();

            loadoutList.SetDoubleBuffered();

            // master has given Gener a Build?
            build = bb;

            // cool clicky thing
            var sorter = new ListViewSort();

            // sort decending on POINTS
            sorter.OnColumnClick(0, false);
            loadoutList.ListViewItemSorter = sorter;

            // place controls in a nice grid-like manner
            foreach (string stat in Build.StatNames)
            {
                loadoutList.Columns.Add(stat).Width = 80;
            }
            foreach (string extra in Build.ExtraNames)
            {
                loadoutList.Columns.Add(extra).Width = 80;
            }
            loadoutList.Columns.Add("Skill1").Width = 80;
            loadoutList.Columns.Add("Skill2").Width = 80;
            loadoutList.Columns.Add("Skill3").Width = 80;
            loadoutList.Columns.Add("Skill4").Width = 80;

            toolStripStatusLabel1.Text = "Press 'Run' to begin.";
            building = true;
            toolStripProgressBar1.Maximum = Program.Settings.TestShow;

            build.Loads.CollectionChanged += Loads_CollectionChanged;

            foreach (var b in build.Loads)
            {
                loadoutList.Items.Add(renderLoadoutTest(b));
            }

            statColScore.Stats        = build.Sort;
            build.Sort.OnStatChanged += Sort_OnStatChanged;
            statColScore.SetSkills(build.Mon.SkillList.Count);

            // Disregard locked, but honor equippedness checking
            build.BuildPrintTo += Build_BuildPrintTo;
            build.BuildProgTo  += Build_BuildProgTo;
        }
Exemplo n.º 4
0
        public Main()
        {
            InitializeComponent();
            config = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath);
            if (config != null)
            {
                // it's stored as string, what is fasted yescompare?
                if (config.AppSettings.Settings.AllKeys.Contains("useEquipped") && config.AppSettings.Settings["useEquipped"].Value == true.ToString())
                {
                    useRunesCheck.Checked = true;
                    useEquipped           = true;
                }
            }

            runes = new RuneControl[] { runeControl1, runeControl2, runeControl3, runeControl4, runeControl5, runeControl6 };
            var sorter = new ListViewSort();

            sorter.OnColumnClick(MonPriority.Index);
            listView1.ListViewItemSorter = sorter;
            listView2.ListViewItemSorter = new ListViewSort();

            sorter = new ListViewSort();
            sorter.OnColumnClick(0);
            listView5.ListViewItemSorter = sorter;

            Task.Factory.StartNew(() =>
            {
                using (WebClient client = new WebClient())
                {
                    client.DownloadStringCompleted += client_DownloadStringCompleted;
                    client.DownloadStringAsync(new Uri("https://raw.github.com/Skibisky/RuneManager/master/version.txt"));
                }
            });

            for (int i = 0; i < 11; i++)
            {
                ToolStripItem it = new ToolStripMenuItem(i.ToString() + (i > 0 ? " (" + Math.Ceiling(i * 1.5).ToString() + "%)" : ""));
                it.Tag    = (int)Math.Floor(i * 1.5);
                it.Click += ShrineClickSpeed;
                speedToolStripMenuItem.DropDownItems.Add(it);
            }
        }
Exemplo n.º 5
0
        public GenerateLive(Build bb)
        {
            InitializeComponent();

            // master has given Gener a Build?
            build = bb;

            // cool clicky thing
            var sorter = new ListViewSort();

            // sort decending on POINTS
            sorter.OnColumnClick(0, false);
            loadoutList.ListViewItemSorter = sorter;

            foreach (Attr stat in Build.StatAll)
            {
                loadoutList.Columns.Add(stat.ToShortForm()).Width = 80;
            }

            toolStripStatusLabel1.Text = "Generating...";
            building = true;
            toolStripProgressBar1.Maximum = Program.Settings.TestShow * 2;

            //for (int i = 0; i < 20; i++)
            {
                Task.Factory.StartNew(() => {
                    DateTime start = DateTime.Now;
                    while (true)
                    {
                        long total      = getTotal();
                        var partitioner = Partitioner.Create(buildsToGen.GetConsumingEnumerable(), EnumerablePartitionerOptions.NoBuffering);
                        Parallel.ForEach(partitioner, (batch, state) => {
                            //string compKey = batch;// buildsToGen.Take();
                            if (batch.rs[0].Id == 638 &&
                                batch.rs[1].Id == 465 &&
                                batch.rs[2].Id == 763 &&
                                batch.rs[3].Id == 467 &&
                                batch.rs[4].Id == 612 &&
                                batch.rs[5].Id == 487)
                            {
                                total -= 1;
                            }


                            var tb = build.GenBuild(batch.rs);
                            if (tb != null)
                            {
                                //Console.WriteLine("Created build " + compKey);
                                freshMons.Add(tb);
                                monsList.AddOrUpdate(batch, tb, (k, v) => tb);
                            }

                            if (buildsToGen.Count == 0 || DateTime.Now > start.AddSeconds(1))
                            {
                                if (!IsDisposed && progState == 1)
                                {
                                    Invoke((MethodInvoker) delegate {
                                        int num = buildsToGen.Count;
                                        // put the thing in on the main thread and bump the progress bar
                                        int v = (int)(toolStripProgressBar1.Maximum * num / (double)total);
                                        if (v >= toolStripProgressBar1.Minimum && v <= toolStripProgressBar1.Maximum)
                                        {
                                            toolStripProgressBar1.Value = v;
                                        }
                                        toolStripStatusLabel1.Text = "Remaining Sets " + num.ToString("#,##0");
                                    });
                                }
                                //Thread.Sleep(20);
                                start = DateTime.Now;
                            }
                        });
                        Invoke((MethodInvoker) delegate {
                            int num = buildsToGen.Count;
                            // put the thing in on the main thread and bump the progress bar
                            int v = (int)(toolStripProgressBar1.Maximum * num / (double)total);
                            if (v >= toolStripProgressBar1.Minimum && v <= toolStripProgressBar1.Maximum)
                            {
                                toolStripProgressBar1.Value = v;
                            }
                            toolStripStatusLabel1.Text = "Remaining Sets " + num.ToString("#,##0");
                        });
                    }
                });
            }

            Task.Factory.StartNew(() => {
                while (true)
                {
                    bool hasChanged = false;
                    Monster fresh;
                    if (freshMons.TryTake(out fresh))
                    {
                        if (fresh.Score == 0)
                        {
                            fresh.Score = build.CalcScore(fresh);
                        }
                        //Console.WriteLine("Checking build " + string.Join(",", fresh.Current.Runes.Select(r => r.ID.ToString())));
                        if (currentList.Count < Program.Settings.TestShow || fresh.Score > currentList.Min(qq => qq.Score))
                        {
                            currentList.Add(fresh); //.Where(IsOkayBuild)
                            currentList = currentList.OrderByDescending(m => m.Score).Take(Program.Settings.TestShow).ToList();
                            hasChanged  = true;
                        }
                    }

                    if (changedSpec && monsList.Count > 0)
                    {
                        // todo: recheck min/max //  && IsOkayBuild(m.Value)
                        currentList = monsList.Where(m => m.Value != null).Select(m => m.Value).OrderByDescending(m => m.Score).Take(Program.Settings.TestShow).ToList();
                        if (currentList.Count > 0)
                        {
                            hasChanged = true;
                        }
                    }

                    if (!hasChanged)
                    {
                        //Thread.Sleep(50);
                        continue;
                    }

                    IEnumerable <Monster> llist = currentList.ToList();
                    List <ListViewItem> ilist   = null;
                    Invoke((MethodInvoker) delegate {
                        ilist = loadoutList.Items.OfType <ListViewItem>().ToList();
                    });

                    foreach (var li in ilist)
                    {
                        if (listGenCancelled)
                        {
                            break;
                        }

                        var mon = li.Tag as Monster;
                        if (mon == null)
                        {
                            continue;
                        }

                        var compKey = string.Join(",", mon.Current.Runes.Select(r => r.Id.ToString()));
                        if (!llist.Any(m => string.Join(",", m.Current.Runes.Select(r => r.Id.ToString())) == compKey))
                        {
                            // new list doen't contain old build
                            Invoke((MethodInvoker) delegate {
                                li.Remove();
                            });
                        }
                        else
                        {
                            currentList.Add(mon);
                            // new list does contain old build
                            llist = llist.Except(llist.Where(m => string.Join(",", m.Current.Runes.Select(r => r.Id.ToString())) == compKey));
                        }
                    }

                    if (listGenCancelled)
                    {
                        return;
                    }

                    foreach (var b in llist)
                    {
                        if (listGenCancelled)
                        {
                            break;
                        }

                        ListViewItem li = new ListViewItem();
                        var Cur         = b.GetStats();

                        //currentList.Add(b);

                        int underSpec = 0;
                        int under12   = 0;
                        foreach (var r in b.Current.Runes)
                        {
                            if (r.Level < 12)
                            {
                                under12 += 12 - r.Level;
                            }
                            if (build.RunePrediction.ContainsKey((SlotIndex)r.Slot) && r.Level < (build.RunePrediction[(SlotIndex)r.Slot].Key ?? 0))
                            {
                                underSpec += (build.RunePrediction[(SlotIndex)r.Slot].Key ?? 0) - r.Level;
                            }
                        }

                        li.SubItems.Add(underSpec + "/" + under12);
                        double pts = GetPoints(Cur, (str, i) => { li.SubItems.Add(str); });
                        b.Score    = pts;

                        // put the sum points into the first item
                        li.SubItems[0].Text = pts.ToString("0.##");

                        li.Tag = b;
                        if (Program.Settings.TestGray && b.Current.Runes.Any(r => r.UsedInBuild))
                        {
                            li.ForeColor = Color.Gray;
                        }
                        else
                        {
                            if (b.Current.Sets.Any(rs => RuneProperties.MagicalSets.Contains(rs) && Rune.SetRequired(rs) == 2) &&
                                b.Current.Sets.Any(rs => RuneProperties.MagicalSets.Contains(rs) && Rune.SetRequired(rs) == 4))
                            {
                                li.ForeColor = Color.Green;
                            }
                            else if (b.Current.Sets.Any(rs => RuneProperties.MagicalSets.Contains(rs) && Rune.SetRequired(rs) == 2))
                            {
                                li.ForeColor = Color.Goldenrod;
                            }
                            else if (b.Current.Sets.Any(rs => RuneProperties.MagicalSets.Contains(rs) && Rune.SetRequired(rs) == 4))
                            {
                                li.ForeColor = Color.DarkBlue;
                            }
                        }

                        if (!IsDisposed && IsHandleCreated)
                        {
                            Invoke((MethodInvoker) delegate {
                                // put the thing in on the main thread and bump the progress bar
                                loadoutList.Items.Add(li);
                            });
                        }
                    }
                    changedSpec = false;
                }
            });

            RegenSets();
        }
Exemplo n.º 6
0
        public Generate(Build bb)
        {
            InitializeComponent();

            // master has given Gener a Build?
            build = bb;
            Label   label   = null;
            TextBox textBox = null;

            // cool clicky thing
            var sorter = new ListViewSort();

            // sort decending on POINTS
            sorter.OnColumnClick(0, false);
            listView1.ListViewItemSorter = sorter;

            // place controls in a nice grid-like manner
            int x, y;

            y = 20;
            foreach (string stat in statNames)
            {
                x              = 25;
                label          = new Label();
                label.Name     = stat + "Label";
                label.Location = new Point(x, y);
                label.Size     = new Size(40, 20);
                label.Text     = stat;
                groupBox1.Controls.Add(label);
                x += 45;

                textBox          = new TextBox();
                textBox.Name     = stat + "Worth";
                textBox.Location = new Point(x, y);
                textBox.Size     = new Size(40, 20);
                if (build.Sort[stat] != 0)
                {
                    textBox.Text = build.Sort[stat].ToString();
                }
                textBox.TextChanged += textBox_TextChanged;
                groupBox1.Controls.Add(textBox);

                y += 22;

                listView1.Columns.Add(stat).Width = 80;
            }
            foreach (string extra in extraNames)
            {
                x              = 25;
                label          = new Label();
                label.Name     = extra + "Label";
                label.Location = new Point(x, y);
                label.Size     = new Size(40, 20);
                label.Text     = extra;
                groupBox1.Controls.Add(label);
                x += 45;

                textBox          = new TextBox();
                textBox.Name     = extra + "Worth";
                textBox.Location = new Point(x, y);
                textBox.Size     = new Size(40, 20);
                if (build.Sort.ExtraGet(extra) != 0)
                {
                    textBox.Text = build.Sort.ExtraGet(extra).ToString();
                }
                textBox.TextChanged += textBox_TextChanged;
                groupBox1.Controls.Add(textBox);

                y += 22;

                listView1.Columns.Add(extra).Width = 80;
            }

            toolStripStatusLabel1.Text = "Generating...";
            building = true;

            Task.Factory.StartNew(() =>
            {
                // Allow the window to draw before destroying the CPU
                Thread.Sleep(100);

                // Disregard locked, but honor equippedness checking
                build.GenRunes(Main.data, true, Main.useEquipped);

                // generate 5000 builds
                build.GenBuilds(5000, 0, (s) => { }, (d) =>
                {
                    Invoke((MethodInvoker) delegate
                    {
                        toolStripProgressBar1.Value = (int)(d * numBuilds);
                    });
                });

                int num     = 0;
                int tbuilds = build.loads.Take(numBuilds).Count();
                // pick the top 100
                // Believe it or not, putting 100 into the list takes a *lot* longer than making 5000
                foreach (var b in build.loads.Take(numBuilds))
                {
                    ListViewItem li = new ListViewItem();
                    var Cur         = b.GetStats();

                    double pts = GetPoints(Cur, (str, i) => { li.SubItems.Add(str); });

                    /*
                     *                  foreach (var stat in statNames)
                     *                  {
                     *                          string str = Cur[stat].ToString();
                     *                          if (build.Sort[stat] != 0)
                     *                          {
                     *      double p = Cur[stat] / build.Sort[stat];
                     *                                  if (build.Threshold[stat] != 0)
                     *                                          p -= Math.Max(0, Cur[stat] - build.Threshold[stat]) / build.Sort[stat];
                     *                                  str = p.ToString() + " (" + Cur[stat].ToString() + ")";
                     *                                  pts += p;
                     *                          }
                     *                          li.SubItems.Add(str);
                     *                  }
                     * foreach (var extra in extraNames)
                     * {
                     *  string str = Cur.ExtraValue(extra).ToString();
                     *  if (build.Sort.ExtraGet(extra) != 0)
                     *  {
                     *      double p = Cur.ExtraValue(extra) / build.Sort.ExtraGet(extra);
                     *      if (build.Threshold.ExtraGet(extra) != 0)
                     *          p -= Math.Max(0, Cur.ExtraValue(extra) - build.Threshold.ExtraGet(extra)) / build.Sort.ExtraGet(extra);
                     *      str = p.ToString() + " (" + Cur.ExtraValue(extra).ToString() + ")";
                     *      pts += p;
                     *  }
                     *  li.SubItems.Add(str);
                     * }
                     */
                    // put the sum points into the first item
                    li.SubItems[0].Text = pts.ToString("0.##");
                    li.Tag = b;
                    Invoke((MethodInvoker) delegate
                    {
                        // put the thing in on the main thread and bump the progress bar
                        listView1.Items.Add(li);
                        num++;
                        toolStripProgressBar1.Value = numBuilds + (int)(numBuilds * num / (double)tbuilds);
                    });
                }

                Invoke((MethodInvoker) delegate
                {
                    toolStripStatusLabel1.Text = "Generated " + listView1.Items.Count + " builds";
                    building = false;
                });
            });
        }
Exemplo n.º 7
0
        public Generate(Build bb)
        {
            InitializeComponent();
            if (Main.config.AppSettings.Settings.AllKeys.Contains("locktest"))
                bool.TryParse(Main.config.AppSettings.Settings["locktest"].Value, out noLocked);
            if (Main.config.AppSettings.Settings.AllKeys.Contains("testgray"))
                bool.TryParse(Main.config.AppSettings.Settings["testgray"].Value, out grayLocked);
            if (Main.config.AppSettings.Settings.AllKeys.Contains("testGen"))
                int.TryParse(Main.config.AppSettings.Settings["testGen"].Value, out buildsGen);
            if (Main.config.AppSettings.Settings.AllKeys.Contains("testShow"))
                int.TryParse(Main.config.AppSettings.Settings["testShow"].Value, out buildsShow);

            // master has given Gener a Build?
            build = bb;
            Label label = null;
            TextBox textBox = null;

            // cool clicky thing
            var sorter = new ListViewSort();
            // sort decending on POINTS
            sorter.OnColumnClick(0, false);
            listView1.ListViewItemSorter = sorter;

            // place controls in a nice grid-like manner
            int x, y;

            y = 20;
            foreach (string stat in statNames)
            {
                x = 25;
                label = new Label();
                label.Name = stat + "Label";
                label.Location = new Point(x, y);
                label.Size = new Size(40, 20);
                label.Text = stat;
                groupBox1.Controls.Add(label);
                x += 45;

                textBox = new TextBox();
                textBox.Name = stat + "Worth";
                textBox.Location = new Point(x, y);
                textBox.Size = new Size(40, 20);
                if (build.Sort[stat] != 0)
                    textBox.Text = build.Sort[stat].ToString();
                textBox.TextChanged += textBox_TextChanged;
                groupBox1.Controls.Add(textBox);

                y += 22;

                listView1.Columns.Add(stat).Width = 80;
            }
            foreach (string extra in extraNames)
            {
                x = 25;
                label = new Label();
                label.Name = extra + "Label";
                label.Location = new Point(x, y);
                label.Size = new Size(40, 20);
                label.Text = extra;
                groupBox1.Controls.Add(label);
                x += 45;

                textBox = new TextBox();
                textBox.Name = extra + "Worth";
                textBox.Location = new Point(x, y);
                textBox.Size = new Size(40, 20);
                if (build.Sort.ExtraGet(extra) != 0)
                    textBox.Text = build.Sort.ExtraGet(extra).ToString();
                textBox.TextChanged += textBox_TextChanged;
                groupBox1.Controls.Add(textBox);

                y += 22;

                listView1.Columns.Add(extra).Width = 80;
            }

            toolStripStatusLabel1.Text = "Generating...";
            building = true;
            toolStripProgressBar1.Maximum = buildsShow * 2;

            Task.Factory.StartNew(() =>
            {
                // Allow the window to draw before destroying the CPU
                Thread.Sleep(100);

                // Disregard locked, but honor equippedness checking
                build.GenRunes(Main.data, noLocked, Main.useEquipped);

                // generate 5000 builds
                build.GenBuilds(buildsGen, 0, (s) => { }, (d) =>
                {
                    Invoke((MethodInvoker)delegate
                    {
                        toolStripProgressBar1.Value = (int)(d * buildsShow);
                    });
                });
                if (build.loads == null)
                {
                    toolStripStatusLabel1.Text = "Error: no builds";
                    return;
                }

                int num = 0;
                var takenLoads = build.loads.Take(buildsShow);
                int tbuilds = takenLoads.Count();
                // pick the top 100
                // Believe it or not, putting 100 into the list takes a *lot* longer than making 5000
                foreach (var b in takenLoads)
                {
                    ListViewItem li = new ListViewItem();
                    var Cur = b.GetStats();

                    double pts = GetPoints(Cur, (str, i)=> { li.SubItems.Add(str); });

                    // put the sum points into the first item
                    li.SubItems[0].Text = pts.ToString("0.##");
                    li.Tag = b;
                    if (grayLocked && b.Current.runes.Any(r => r.Locked))
                        li.ForeColor = Color.Gray;

                    Invoke((MethodInvoker)delegate
                    {
                        // put the thing in on the main thread and bump the progress bar
                        listView1.Items.Add(li);
                        num++;
                        toolStripProgressBar1.Value = buildsShow + (int)(buildsShow * num / (double)tbuilds);
                    });
                }

                Invoke((MethodInvoker)delegate
                {
                    toolStripStatusLabel1.Text = "Generated " + listView1.Items.Count + " builds";
                    building = false;
                });

            });
        }