Example #1
0
        public void Load(frmMain parent)
        {
            this.parent = parent;

            PulseFrequency = int.Parse(ConfigFile.Pulse.ToString());
            Log.Write("Using Pulse Frequency (ms) = " + PulseFrequency);

            characterInfo = new Thread(CharacterInfoThread)
            {
                IsBackground = true
            };
            characterInfo.Start();

            mainThread = new Thread(MainThreadTick)
            {
                IsBackground = true
            };
            mainThread.Start();

            combatRoutine = this;

            Initialize();
        }
Example #2
0
        private bool LoadProfile(string fileName)
        {
            using (var sr = new StreamReader(fileName))
            {
                var code = sr.ReadToEnd();

                if (code.Trim() == "")
                {
                    MessageBox.Show("Please select a non blank file", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return false;
                }

                if (fileName.EndsWith(".enc"))
                {
                    Log.Write("Decrypting profile...", Color.Black);

                    try
                    {
                        code = Encryption.Decrypt(code);

                        Log.Write("Profile has been decrypted successfully", Color.Green);
                    }
                    catch (Exception ex)
                    {
                        Log.Write(ex.Message, Color.Red);
                    }
                }

                Log.Write($"Compiling profile [{fileName}]...", Color.Black);

                var provider = new CSharpCodeProvider();
                var parameters = new CompilerParameters();

                parameters.ReferencedAssemblies.Add("System.Windows.Forms.dll"); // For Windows Forms use
                parameters.ReferencedAssemblies.Add("System.Drawing.dll"); // For System.Drawing.Point and System.Drawing.Color use
                parameters.ReferencedAssemblies.Add("System.Data.dll");
                parameters.ReferencedAssemblies.Add("System.Xml.dll");
                parameters.ReferencedAssemblies.Add("System.Linq.dll");
                parameters.ReferencedAssemblies.Add("System.dll");
                parameters.ReferencedAssemblies.Add("System.IO.dll");
                parameters.ReferencedAssemblies.Add("System.Threading.dll");
                parameters.ReferencedAssemblies.Add(Application.ExecutablePath);
                parameters.GenerateInMemory = true;
                parameters.GenerateExecutable = false;

                var results = provider.CompileAssemblyFromSource(parameters, code);

                if (results.Errors.HasErrors)
                {
                    foreach (CompilerError error in results.Errors)
                    {
                        Log.Write($"Error ({error.ErrorNumber}): {error.ErrorText}", Color.Red);
                    }

                    return false;
                }

                var assembly = results.CompiledAssembly;

                foreach (var t in assembly.GetTypes())
                {
                    if (t.IsClass)
                    {
                        var obj = Activator.CreateInstance(t);
                        combatRoutine = (CombatRoutine)obj;

                        combatRoutine.Load(this);
                        combatRoutine.FileName = fileName;

                        Log.Write("Successfully loaded combat routine: " + combatRoutine.Name, Color.Green);

                        Overlay.showOverlay(new Point(20, 680));

                        if (SpellBook.Initialize(fileName))
                        {
                            spellbookToolStripMenuItem.Enabled = true;
                            submitTicketToolStripMenuItem.Enabled = true;

                            cmdStartBot.Enabled = true;
                            cmdStartBot.BackColor = Color.LightGreen;
                            cmdRotationSettings.Enabled = true;
                            return true;
                        }

                        spellbookToolStripMenuItem.Enabled = false;
                        submitTicketToolStripMenuItem.Enabled = false;

                        cmdStartBot.Enabled = false;
                        cmdStartBot.BackColor = Color.WhiteSmoke;
                        return false;
                    }
                }

                return false;
            }
        }