示例#1
0
        private void RunBuild(ListViewItem pli, bool isBatch = false)
        {
            if (plsDie)
                return;

            if (currentBuild != null)
                currentBuild.isRun = false;

            if (pli.Tag != null)
            {
                Stopwatch buildTime = Stopwatch.StartNew();
                Build b = (Build)pli.Tag;
                currentBuild = b;

                ListViewItem[] olvs = null;
                Invoke((MethodInvoker)delegate { olvs = listView3.Items.Find(b.ID.ToString(), false); });

                if (olvs.Length > 0)
                {
                    var olv = olvs.First();
                    Loadout ob = (Loadout)olv.Tag;
                    foreach (Rune r in ob.runes)
                    {
                        r.Locked = false;
                    }
                }

                b.GenRunes(data, false, useEquipped, isBatch);
                b.shrines = data.shrines;

                string nR = "";

                for (int i = 0; i < b.runes.Length; i++)
                {
                    if (b.runes[i] != null && b.runes[i].Length == 0)
                        nR += (i + 1) + " ";
                }

                if (nR != "")
                {
                    this.Invoke((MethodInvoker)delegate
                    {
                        pli.SubItems[3].Text = ":( " + nR + "Runes";
                    });
                    return;
                }

                b.GenBuilds(0, 0, (str) =>
                {
                    this.Invoke((MethodInvoker)delegate
                    {
                        pli.SubItems[3].Text = str;
                    });
                }, null, true, isBatch);

                if (b.Best == null)
                {
                    return;
                }

                int numchanged = 0;
                int numnew = 0;
                int powerup = 0;
                int upgrades = 0;
                foreach (Rune r in b.Best.Current.runes)
                {
                    r.Locked = true;
                    if (r.AssignedName != b.Best.Name)
                    {
                        //if (b.mon.Current.runes[r.Slot - 1] == null)
                        if (r.AssignedName == "Unknown name")
                            numnew++;
                        else
                            numchanged++;
                    }
                    powerup += Math.Max(0, b.Best.Current.FakeLevel[r.Slot - 1] - r.Level);
                    if (b.Best.Current.FakeLevel[r.Slot -1] != 0)
                    {
                        int tup = (int)Math.Floor(Math.Min(12, b.Best.Current.FakeLevel[r.Slot - 1]) / (double)3);
                        int cup = (int)Math.Floor(Math.Min(12, r.Level) / (double)3);
                        upgrades += Math.Max(0, tup - cup);
                    }
                }
                currentBuild = null;
                b.Time = buildTime.ElapsedMilliseconds;
                buildTime.Stop();

                this.Invoke((MethodInvoker)delegate
                {
                    checkLocked();

                    ListViewItem nli;

                    var lvs = listView3.Items.Find(b.ID.ToString(), false);

                    if (lvs.Length == 0)
                        nli = new ListViewItem();
                    else
                        nli = lvs.First();

                    nli.Tag = b.Best.Current;
                    nli.Text = b.ID.ToString();
                    nli.Name = b.ID.ToString();
                    while (nli.SubItems.Count < 6)
                        nli.SubItems.Add("");
                    nli.SubItems[0] = new ListViewItem.ListViewSubItem(nli, b.ID.ToString());
                    nli.SubItems[1] = new ListViewItem.ListViewSubItem(nli, b.Best.Name);
                    nli.SubItems[2] = new ListViewItem.ListViewSubItem(nli, b.Best.ID.ToString());
                    nli.SubItems[3] = new ListViewItem.ListViewSubItem(nli, (numnew + numchanged).ToString());
                    if (Main.config.AppSettings.Settings.AllKeys.Contains("splitassign"))
                    {
                        bool check = false;
                        bool.TryParse(Main.config.AppSettings.Settings["splitassign"].Value, out check);
                        if (check)
                            nli.SubItems[3].Text = numnew.ToString() + "/" + numchanged.ToString();
                    }
                    nli.SubItems[4] = new ListViewItem.ListViewSubItem(nli, powerup.ToString());
                    //nli.SubItems[5] = new ListViewItem.ListViewSubItem(nli, upgrades.ToString());
                    nli.SubItems[5] = new ListViewItem.ListViewSubItem(nli, (b.Time/(double)1000).ToString("0.##"));

                    if (lvs.Length == 0)
                        listView3.Items.Add(nli);

                });

            }
        }
示例#2
0
        // When the window is told to appear (hopefully we have everything)
        void Create_Shown(object sender, EventArgs e)
        {
            if (Tag == null)
            {
                // don't have. :(
                Close();
                return;
            }
            // warning, now loading
            loading = true;

            build = (Build)Tag;
            Monster mon = (Monster)build.mon;
            Stats cur = mon.GetStats();
            monLabel.Text = "Build for " + mon.Name + " (" + mon.ID + ")";

            build.VERSIONNUM = VERSIONNUM;

            checkDL6star.Checked = build.DownloadStats;
            checkDLawake.Checked = build.DownloadAwake;
            checkDL6star.Enabled = !checkDLawake.Checked;

            if (build.leader.NonZero())
            {
                Attr t = build.leader.FirstNonZero();
                if (t != Attr.Null)
                {
                    leaderTypeBox.SelectedIndex = leadTypes.ToList().FindIndex(lt => lt.type == t);
                }
            }

            // move the sets around in the list a little
            foreach (RuneSet s in build.BuildSets)
            {
                ListViewItem li = listView1.Items.Find(s.ToString(), true).FirstOrDefault();
                if (li == null)
                    li.Group = rsExc;
                if (li != null)
                    li.Group = rsInc;
            }
            foreach (RuneSet s in build.RequiredSets)
            {
                ListViewItem li = listView1.Items.Find(s.ToString(), true).FirstOrDefault();
                if (li != null)
                    li.Group = rsReq;
                int num = build.RequiredSets.Count(r => r == s);
                if (num > 1)
                    li.Text = s.ToString() + " x" + num;

            }

            // for 2,4,6 - make sure that the Attrs are set up
            var lists = new ListView[]{listView2, listView4, listView6};
            for (int j = 0; j < lists.Length; j++)
            {
                var lv = lists[j];

                var attrs = Enum.GetValues(typeof(Attr));
                for (int i = 0; i < statNames.Length; i++)
                {
                    var bl = build.slotStats[(j+1)*2 - 1];

                    string stat = statNames[i];
                    if (i < 3)
                    {
                        if (bl.Contains(stat + "flat"))
                            lv.Items.Find(stat + "flat", true).FirstOrDefault().Group = lv.Groups[0];

                        if (bl.Contains(stat + "perc") || build.New)
                            lv.Items.Find(stat + "perc", true).FirstOrDefault().Group = lv.Groups[0];
                    }
                    else
                    {
                        if (j == 0 && stat != "SPD")
                            continue;
                        if (j == 1 && (stat != "CR" && stat != "CD"))
                            continue;
                        if (j == 2 && (stat != "ACC" && stat != "RES"))
                            continue;

                        if (bl.Contains(stat + (stat == "SPD" ? "flat" : "perc")) || build.New)
                            lv.Items.Find(stat + (stat == "SPD" ? "flat" : "perc"), true).FirstOrDefault().Group = lv.Groups[0];
                    }
                }

            }

            refreshStats(mon, cur);

            // do we allow broken sets?
            ChangeBroken(build.AllowBroken);

            // for each tabs filter
            foreach (var rs in build.runeFilters)
            {
                var tab = rs.Key;
                TabPage ctab = GetTab(tab);
                // for each stats filter
                foreach (var f in rs.Value)
                {
                    var stat = f.Key;
                    // for each stat type
                    foreach (var type in new string[] { "flat", "perc", "test" })
                    {
                        // find the controls and shove the value in it
                        var ctrl = ctab.Controls.Find(tab + stat + type, true).FirstOrDefault();
                        if (ctrl != null)
                        {
                            int val = f.Value[type];
                            // unless it's zero, I don't want zeros
                            if (val != 0)
                                ctrl.Text = val.ToString();
                            else
                                ctrl.Text = "";
                        }
                    }
                }
            }
            foreach (var tab in build.runePrediction)
            {
                TabPage ctab = GetTab(tab.Key);
                TextBox tb = (TextBox)ctab.Controls.Find(tab.Key + "raise", true).FirstOrDefault();
                if (tb != null)
                {
                    if (tab.Value.Key != 0)
                        tb.Text = tab.Value.Key.ToString();
                }
                CheckBox cb = (CheckBox)ctab.Controls.Find(tab.Key + "bonus", true).FirstOrDefault();
                if (cb != null)
                {
                    cb.Checked = tab.Value.Value;
                }
            }

            // for each tabs scoring
            foreach (var tab in build.runeScoring)
            {
                TabPage ctab = GetTab(tab.Key);
                // find that box
                ComboBox box = (ComboBox)ctab.Controls.Find(tab.Key + "join", true).FirstOrDefault();
                if (box != null)
                {
                    // manually kajigger it
                    box.SelectedIndex = tab.Value.Key;
                    foreach (var stat in statNames)
                    {
                        Control ctrl;
                        foreach (var type in new string[] { "flat", "perc" })
                        {
                            if (type == "perc" && stat == "SPD")
                                continue;
                            if (type == "flat" && (stat == "ACC" || stat == "RES" || stat == "CD" || stat == "CR"))
                                continue;
                            ctrl = ctab.Controls.Find(tab.Key + stat + type, true).FirstOrDefault();
                        }
                        ctrl = ctab.Controls.Find(tab.Key + stat + "test", true).FirstOrDefault();
                        ctrl.Enabled = (box.SelectedIndex != 2);
                        ctrl = ctab.Controls.Find(tab.Key + "test", true).FirstOrDefault();
                        ctrl.Enabled = (box.SelectedIndex == 2);
                    }
                }

                var tb = (TextBox)ctab.Controls.Find(tab.Key + "test", true).FirstOrDefault();
                if (tab.Value.Value != 0)
                    tb.Text = tab.Value.Value.ToString();
            }
            // done loading!
            loading = false;
            // this build is no longer considered new
            build.New = false;
            // oh yeah, update everything now that it's finally loaded
            UpdateGlobal();
            CalcPerms();
        }
示例#3
0
        private void toolStripButton7_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count > 0)
            {
                using (var ff = new Create())
                {
                    var bb = new Build();
                    bb.New = true;
                    bb.mon = (Monster)listView1.SelectedItems[0].Tag;
                    bb.ID = listView5.Items.Count + 1;
                    ff.Tag = bb;
                    var res = ff.ShowDialog();
                    if (res == System.Windows.Forms.DialogResult.OK)
                    {
                        if (builds.Count > 0)
                            ff.build.priority = builds.Max(b => b.priority) + 1;
                        else
                            ff.build.priority = 1;

                        ListViewItem li = new ListViewItem(new string[]{ff.build.priority.ToString(), ff.build.ID.ToString(), ff.build.mon.Name,"0%"});
                        li.Tag = ff.build;
                        listView5.Items.Add(li);
                        builds.Add(ff.build);

                        var lv1li = listView1.Items.Cast<ListViewItem>().Where(i => i.SubItems.Cast<ListViewItem.ListViewSubItem>().Where(s => s.Text == ff.build.mon.Name).Count() > 0).FirstOrDefault();
                        if (lv1li != null)
                            lv1li.ForeColor = Color.Green;

                    }
                }
            }
        }
示例#4
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;
                });

            });
        }