Example #1
0
 //Passing main and help form links so that i know whose functions to call
 internal Options(Form1 parentForm1,HelpForm parentHelpForm,CombinePerformer CP)
 {
     this.parentForm1 = parentForm1;
     this.parentHelpForm = parentHelpForm;
     this.CP = CP;
     InitializeComponent();
 }
Example #2
0
        private void CombineButton_Click(object sender, EventArgs e)
        {
            if (this.asyncWaiting)
            {
                return;                 // there was already a thread waiting for hotkey
            }

            while (GetAsyncKeyState((Keys)Settings.Default.Hotkey) != 0)
            {
                // MessageBox.Show("Key detection failed, or you were already holding hotkey. Try again.");
                Thread.Sleep(200);
            }

            this.combineButton.Text = "Press " + SettingsHandler.HotkeyText + " on A1";             // hotkey
            this.asyncWaiting       = true;
            do
            {
                Application.DoEvents();
                Thread.Sleep(10);

                // [HR] Cancel before starting or if form is closing
                if (GetAsyncKeyState(Keys.Escape) != 0 || !CombinePerformer.Enabled)
                {
                    this.combineButton.Text = "Combine";
                    this.asyncWaiting       = false;
                    return;
                }
            }while (GetAsyncKeyState((Keys)Settings.Default.Hotkey) == 0 || Control.ModifierKeys != Keys.None);

            // User pressed hotkey
            this.asyncWaiting          = false;
            CombinePerformer.SleepTime = (int)this.delayNumeric.Value;
            this.stopwatch.Reset();
            this.stopwatch.Start();
            this.combineProgressBar.Maximum = CombinePerformer.Instructions.Count;
            // Don't combine if recipe is a simple g1
            if (this.stepNumeric.Value > 0)
            {
                CombinePerformer.PerformCombine((int)this.stepNumeric.Value);
            }

            // Combine finished
            this.combineProgressBar.Value = this.combineProgressBar.Minimum;
            this.GuessEta();
            this.combineButton.Text = "Combine";
            if (Settings.Default.AutoCombine)
            {
                this.combineButton.PerformClick();                 // guess it's finished, click the "combine" again
            }
        }
        // CondenseSlots seems to be messed up, I can't get the 262144-combine to work.
        private List<Point> CondenseSlots(Gem g, List<Point> bigInst, bool keepBase, int slotLimit)
        {
            // Get the combine INST for both components. (Will not include duplicating base gem.)
            // If the combine for a component exceeds the slotLimit, CondenseSlots to get new INST.
            //
            // Each component's combine INST must include placing the base gem in slot 0.
            // If I add the duplicate step to p1.inst, then the new condensed one will already have it.
            // To solve this, try: If the INST does not begin with duplicate step, add it.

            Gem c1 = g.Component1;
            Gem c2 = g.Component2;
            CombinePerformer p1 = new CombinePerformer(); p1.limitSlots = false;
            p1.SetMethod(c1.GetFullCombine()); p1.resultGem.strID = c1.strID;
            CombinePerformer p2 = new CombinePerformer(); p2.limitSlots = false;
            p2.SetMethod(c2.GetFullCombine()); p2.resultGem.strID = c2.strID;

            if (p1.Slots_Required > slotLimit - 1)
                p1.inst = CondenseSlots(c1, p1.inst, true, slotLimit);
            // Move result gem to highest open slot
            p1.inst.Add(new Point(p1.inst.Last().Y, -(slotLimit - 1))); // Move to 1st open space.
            if (p2.Slots_Required > slotLimit - 1)
                p2.inst = CondenseSlots(c2, p2.inst, false, slotLimit - 1);
            if (keepBase) // Is slot 36 used by baseGem?
                p2.inst.Add(new Point(p2.inst.Last().Y, -(slotLimit - 2))); // 2nd open (now 1st) space.
            else
                p2.inst.Add(new Point(p2.inst.Last().Y, -36));

            List<Point> newInst = new List<Point>();
            // Both combines require placing a base gem in slot 0 first.
            if (p1.inst[0].X != 35)
                newInst.Add(new Point(35, INST_DUPE));
            newInst.AddRange(p1.inst);

            if (keepBase || p2.Slots_Required > slotLimit - 1) // Duplicate base_gem
                newInst.Add(new Point(35, INST_DUPE));
            else // Move base_gem
                newInst.Add(new Point(35, -1));
            newInst.AddRange(p2.inst);

            // Combine the two resulting gems
            if (keepBase)
                newInst.Add(new Point((slotLimit - 3), (slotLimit - 2))); // Combine to the higher slot (shouldn't matter, last gem is moved later anyway)
            else
                newInst.Add(new Point((slotLimit - 2), 35));

            // Finally
            return newInst;
        }