Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.18 KB | None | 0 0
  1. private void LoadData()
  2. {
  3. // Load data
  4. _ucDemonbuddy.textBox1.Text = bot.Name;
  5. _ucDemonbuddy.textBox2.Text = bot.Description;
  6.  
  7. // Advanced section
  8. _ucAdvanced.checkBox2.Checked = bot.CreateWindowsUser;
  9. _ucAdvanced.checkBox1.Checked = bot.UseWindowsUser;
  10. _ucAdvanced.textBox1.Text = bot.WindowsUserName;
  11. _ucAdvanced.maskedTextBox1.Text = bot.WindowsUserPassword;
  12. _ucAdvanced.textBox3.Text = bot.D3PrefsLocation;
  13. _ucAdvanced.checkBox3.Checked = bot.UseDiabloClone;
  14. _ucAdvanced.textBox2.Text = bot.DiabloCloneLocation;
  15.  
  16. // Demonbuddy
  17. _ucDemonbuddy.textBox4.Text = bot.Demonbuddy.Location;
  18. _ucDemonbuddy.textBox3.Text = bot.Demonbuddy.Key;
  19.  
  20. _ucDemonbuddy.comboBox1.Text = bot.Demonbuddy.CombatRoutine;
  21. _ucDemonbuddy.checkBox1.Checked = bot.Demonbuddy.NoFlash;
  22. _ucDemonbuddy.checkBox2.Checked = bot.Demonbuddy.AutoUpdate;
  23. _ucDemonbuddy.checkBox3.Checked = bot.Demonbuddy.NoUpdate;
  24. _ucDemonbuddy.textBox9.Text = bot.Demonbuddy.BuddyAuthUsername;
  25. _ucDemonbuddy.maskedTextBox2.Text = bot.Demonbuddy.BuddyAuthPassword;
  26. _ucDemonbuddy.comboBox2.SelectedIndex = bot.Demonbuddy.Priority;
  27. _ucDemonbuddy.checkBox5.Checked = bot.Demonbuddy.ForceEnableAllPlugins;
  28. // Demonbuddy manual position
  29. _ucDemonbuddy.checkBox4.Checked = bot.Demonbuddy.ManualPosSize;
  30. _ucDemonbuddy.textBox6.Text = bot.Demonbuddy.X.ToString();
  31. _ucDemonbuddy.textBox5.Text = bot.Demonbuddy.Y.ToString();
  32. _ucDemonbuddy.textBox10.Text = bot.Demonbuddy.W.ToString();
  33. _ucDemonbuddy.textBox11.Text = bot.Demonbuddy.H.ToString();
  34.  
  35. // Diablo
  36. _ucDiablo.username.Text = bot.Diablo.Username;
  37. _ucDiablo.password.Text = bot.Diablo.Password;
  38. _ucDiablo.diablo3Path.Text = bot.Diablo.Location;
  39. _ucDiablo.language.SelectedItem = bot.Diablo.Language;
  40. _ucDiablo.region.SelectedItem = bot.Diablo.Region;
  41. _ucDiablo.checkBox1.Checked = bot.Diablo.UseAuthenticator;
  42. _ucDiablo.useInnerSpace.Checked = bot.Diablo.UseIsBoxer;
  43. _ucDiablo.isBoxerLaunchAll.Checked = bot.Diablo.ISBoxerLaunchCharacterSet;
  44. _ucDiablo.characterSet.Text = bot.Diablo.CharacterSet;
  45. _ucDiablo.displaySlot.Text = bot.Diablo.DisplaySlot;
  46. _ucDiablo.removeWindowFrame.Checked = bot.Diablo.NoFrame;
  47.  
  48. // Affinity Diablo
  49. if (bot.Diablo.CpuCount != Environment.ProcessorCount)
  50. {
  51. bot.Diablo.ProcessorAffinity = bot.Diablo.AllProcessors;
  52. bot.Diablo.CpuCount = Environment.ProcessorCount;
  53. }
  54.  
  55. if (AffinityDiablo.cpus.Count != bot.Diablo.CpuCount)
  56. {
  57. Logger.Instance.Write(
  58. "For whatever reason Diablo and UI see different number of CPUs, affinity disabled");
  59. }
  60. else
  61. {
  62. for (int i = 0; i < bot.Diablo.CpuCount; i++)
  63. {
  64. AffinityDiablo.cpus[i].Checked = ((bot.Diablo.ProcessorAffinity & (1 << i)) != 0);
  65. }
  66. }
  67. // Affinity Demonbuddy
  68. if (bot.Demonbuddy.CpuCount != Environment.ProcessorCount)
  69. {
  70. bot.Demonbuddy.ProcessorAffinity = bot.Demonbuddy.AllProcessors;
  71. bot.Demonbuddy.CpuCount = Environment.ProcessorCount;
  72. }
  73.  
  74. if (AffinityDemonbuddy.cpus.Count != bot.Demonbuddy.CpuCount)
  75. {
  76. Logger.Instance.Write(
  77. "For whatever reason Demonbuddy and UI see different number of CPUs, affinity disabled");
  78. }
  79. else
  80. {
  81. for (int i = 0; i < bot.Demonbuddy.CpuCount; i++)
  82. {
  83. AffinityDemonbuddy.cpus[i].Checked = ((bot.Demonbuddy.ProcessorAffinity & (1 << i)) != 0);
  84. }
  85. }
  86.  
  87. //!!!d.Serial = string.Format("{0}-{1}-{2}-{3}", ucDiablo.textBox4.Text, ucDiablo.textBox5.Text, ucDiablo.textBox7.Text, ucDiablo.textBox6.Text);
  88. //!!!ucDiablo.textBox8.Text = bot.diablo.RestoreCode;
  89.  
  90. /*
  91. d.Serial = string.Format("{0}-{1}-{2}-{3}", _ucDiablo.textBox4.Text, _ucDiablo.textBox5.Text,
  92. _ucDiablo.textBox7.Text, _ucDiablo.textBox6.Text);
  93. d.RestoreCode = _ucDiablo.textBox8.Text;
  94. */
  95.  
  96. string SerialCode = bot.Diablo.Serial;
  97. string[] words;
  98. words = SerialCode.Split('-');
  99.  
  100. _ucDiablo.authField1.Text = words[0];
  101. _ucDiablo.authField2.Text = words[1];
  102. _ucDiablo.authField3.Text = words[2];
  103. _ucDiablo.authField4.Text = words[3];
  104. _ucDiablo.textBox8.Text = bot.Diablo.RestoreCode;
  105.  
  106.  
  107. _ucDiablo.processorAffinity.SelectedIndex = bot.Diablo.Priority;
  108.  
  109. // Diablo manual position
  110. _ucDiablo.manualPositionAndSize.Checked = bot.Diablo.ManualPosSize;
  111. _ucDiablo.positionX.Text = bot.Diablo.X.ToString();
  112. _ucDiablo.positionY.Text = bot.Diablo.Y.ToString();
  113. _ucDiablo.width.Text = bot.Diablo.W.ToString();
  114. _ucDiablo.height.Text = bot.Diablo.H.ToString();
  115.  
  116. // Profile Schedule
  117. _ucProfileSchedule.Profiles = bot.ProfileSchedule.Profiles;
  118. _ucProfileSchedule.textBox1.Text = bot.ProfileSchedule.MaxRandomTime.ToString();
  119. _ucProfileSchedule.textBox2.Text = bot.ProfileSchedule.MaxRandomRuns.ToString();
  120. _ucProfileSchedule.checkBox1.Checked = bot.ProfileSchedule.Random;
  121.  
  122. // Load Weekschedule
  123. _ucWeekSchedule.textBox1.Text = bot.Week.MinRandom.ToString();
  124. _ucWeekSchedule.textBox2.Text = bot.Week.MaxRandom.ToString();
  125. _ucWeekSchedule.checkBox1.Checked = bot.Week.Shuffle;
  126. _ucWeekSchedule.LoadSchedule(bot);
  127. }
  128.  
  129. private void button1_Click(object sender, EventArgs e)
  130. {
  131. // NEXT / finish
  132. if (_stepCount == FinishCount)
  133. {
  134. int result;
  135. var b = new BotClass();
  136. var db = new DemonbuddyClass();
  137. var d = new DiabloClass();
  138. var ps = new ProfileScheduleClass();
  139. var w = new Helpers.Bot.WeekSchedule();
  140.  
  141.  
  142. b.Name = _ucDemonbuddy.textBox1.Text;
  143. b.Description = _ucDemonbuddy.textBox2.Text;
  144.  
  145. // Advanced
  146. b.CreateWindowsUser = _ucAdvanced.checkBox2.Checked;
  147. b.UseWindowsUser = _ucAdvanced.checkBox1.Checked;
  148. b.WindowsUserName = _ucAdvanced.textBox1.Text;
  149. b.WindowsUserPassword = _ucAdvanced.maskedTextBox1.Text;
  150. b.D3PrefsLocation = _ucAdvanced.textBox3.Text;
  151. b.UseDiabloClone = _ucAdvanced.checkBox3.Checked;
  152. b.DiabloCloneLocation = _ucAdvanced.textBox2.Text;
  153.  
  154. // Demonbuddy
  155. db.Location = _ucDemonbuddy.textBox4.Text;
  156. db.Key = _ucDemonbuddy.textBox3.Text;
  157. db.CombatRoutine = _ucDemonbuddy.comboBox1.SelectedItem != null
  158. ? _ucDemonbuddy.comboBox1.SelectedItem.ToString()
  159. : _ucDemonbuddy.comboBox1.Text;
  160. db.NoFlash = _ucDemonbuddy.checkBox1.Checked;
  161. db.AutoUpdate = _ucDemonbuddy.checkBox2.Checked;
  162. db.NoUpdate = _ucDemonbuddy.checkBox3.Checked;
  163. db.BuddyAuthUsername = _ucDemonbuddy.textBox9.Text;
  164. db.BuddyAuthPassword = _ucDemonbuddy.maskedTextBox2.Text;
  165. db.Priority = _ucDemonbuddy.comboBox2.SelectedIndex;
  166. db.ForceEnableAllPlugins = _ucDemonbuddy.checkBox5.Checked;
  167.  
  168.  
  169. db.ManualPosSize = _ucDemonbuddy.checkBox4.Checked;
  170. int.TryParse(_ucDemonbuddy.textBox6.Text, out result);
  171. db.X = result;
  172. int.TryParse(_ucDemonbuddy.textBox5.Text, out result);
  173. db.Y = result;
  174. int.TryParse(_ucDemonbuddy.textBox10.Text, out result);
  175. db.W = result;
  176. int.TryParse(_ucDemonbuddy.textBox11.Text, out result);
  177. db.H = result;
  178.  
  179. // Diablo
  180. d.Username = _ucDiablo.username.Text;
  181. d.Password = _ucDiablo.password.Text;
  182. d.Location = _ucDiablo.diablo3Path.Text;
  183. d.Language = _ucDiablo.language.SelectedItem.ToString();
  184. d.Region = _ucDiablo.region.SelectedItem.ToString();
  185. d.UseAuthenticator = _ucDiablo.checkBox1.Checked;
  186. d.Serial = string.Format("{0}-{1}-{2}-{3}", _ucDiablo.authField1.Text, _ucDiablo.authField2.Text,
  187. _ucDiablo.authField3.Text, _ucDiablo.authField4.Text);
  188. d.Serial2 = string.Format("{0}{1}{2}{3}", _ucDiablo.authField1.Text, _ucDiablo.authField2.Text,
  189. _ucDiablo.authField3.Text, _ucDiablo.authField4.Text);
  190. d.RestoreCode = _ucDiablo.textBox8.Text;
  191. d.Priority = _ucDiablo.processorAffinity.SelectedIndex;
  192. d.UseIsBoxer = _ucDiablo.useInnerSpace.Checked;
  193. d.ISBoxerLaunchCharacterSet = _ucDiablo.isBoxerLaunchAll.Checked;
  194. d.CharacterSet = _ucDiablo.characterSet.Text;
  195. d.DisplaySlot = _ucDiablo.displaySlot.Text;
  196. d.NoFrame = _ucDiablo.removeWindowFrame.Checked;
  197.  
  198. // Affinity Diablo
  199. if (d.CpuCount != Environment.ProcessorCount)
  200. {
  201. d.ProcessorAffinity = d.AllProcessors;
  202. d.CpuCount = Environment.ProcessorCount;
  203. }
  204.  
  205. if (AffinityDiablo.cpus.Count != d.CpuCount)
  206. {
  207. Logger.Instance.Write(
  208. "For whatever reason Diablo and UI see different number of CPUs, affinity disabled");
  209. }
  210. else
  211. {
  212. int intProcessorAffinity = 0;
  213. for (int i = 0; i < d.CpuCount; i++)
  214. {
  215. if (AffinityDiablo.cpus[i].Checked)
  216. intProcessorAffinity |= (1 << i);
  217. }
  218. if (intProcessorAffinity == 0)
  219. intProcessorAffinity = -1;
  220. d.ProcessorAffinity = intProcessorAffinity;
  221. }
  222. if (AffinityDiablo != null)
  223. AffinityDiablo.Dispose();
  224.  
  225. // Affinity Demonbuddy
  226. if (db.CpuCount != Environment.ProcessorCount)
  227. {
  228. db.ProcessorAffinity = db.AllProcessors;
  229. db.CpuCount = Environment.ProcessorCount;
  230. }
  231.  
  232. if (AffinityDemonbuddy.cpus.Count != db.CpuCount)
  233. {
  234. Logger.Instance.Write(
  235. "For whatever reason Demonbuddy and UI see different number of CPUs, affinity disabled");
  236. }
  237. else
  238. {
  239. int intProcessorAffinity = 0;
  240. for (int i = 0; i < db.CpuCount; i++)
  241. {
  242. if (AffinityDemonbuddy.cpus[i].Checked)
  243. intProcessorAffinity |= (1 << i);
  244. }
  245. if (intProcessorAffinity == 0)
  246. intProcessorAffinity = -1;
  247. db.ProcessorAffinity = intProcessorAffinity;
  248. }
  249. if (AffinityDemonbuddy != null)
  250. AffinityDemonbuddy.Dispose();
  251.  
  252. d.ManualPosSize = _ucDiablo.manualPositionAndSize.Checked;
  253. if (d.ManualPosSize)
  254. {
  255. int.TryParse(_ucDiablo.positionX.Text, out result);
  256. d.X = result;
  257. int.TryParse(_ucDiablo.positionY.Text, out result);
  258. d.Y = result;
  259. int.TryParse(_ucDiablo.width.Text, out result);
  260. d.W = result;
  261. int.TryParse(_ucDiablo.height.Text, out result);
  262. d.H = result;
  263. }
  264.  
  265. w.GenerateNewSchedule();
  266. w.Shuffle = _ucWeekSchedule.checkBox1.Checked;
  267. w.MinRandom = Convert.ToInt32(_ucWeekSchedule.textBox1.Text);
  268. w.MaxRandom = Convert.ToInt32(_ucWeekSchedule.textBox2.Text);
  269.  
  270. ps.Profiles = _ucProfileSchedule.Profiles;
  271. ps.MaxRandomTime = Convert.ToInt32(_ucProfileSchedule.textBox1.Text);
  272. ps.MaxRandomRuns = Convert.ToInt32(_ucProfileSchedule.textBox2.Text);
  273. ps.Random = _ucProfileSchedule.checkBox1.Checked;
  274.  
  275. b.Week = w;
  276. b.Demonbuddy = db;
  277. b.Diablo = d;
  278. b.ProfileSchedule = ps;
  279.  
  280.  
  281. if (bot != null && index >= 0)
  282. {
  283. Logger.Instance.WriteGlobal("Editing bot: {0}", b.Name);
  284.  
  285. // Copy some important stuff from old bot
  286.  
  287. b.IsStarted = BotSettings.Instance.Bots[index].IsStarted;
  288. b.IsEnabled = BotSettings.Instance.Bots[index].IsEnabled;
  289. b.IsRunning = BotSettings.Instance.Bots[index].IsRunning;
  290. b.Diablo.Proc = BotSettings.Instance.Bots[index].Diablo.Proc;
  291. b.Demonbuddy.Proc = BotSettings.Instance.Bots[index].Demonbuddy.Proc;
  292. b.Demonbuddy.MainWindowHandle = BotSettings.Instance.Bots[index].Demonbuddy.MainWindowHandle;
  293. b.Diablo.MainWindowHandle = BotSettings.Instance.Bots[index].Diablo.MainWindowHandle;
  294. b.AntiIdle = BotSettings.Instance.Bots[index].AntiIdle;
  295. b.Week.ForceStart = BotSettings.Instance.Bots[index].Week.ForceStart;
  296. b.RunningTime = BotSettings.Instance.Bots[index].RunningTime;
  297.  
  298. BotSettings.Instance.Bots[index] = b;
  299. }
  300. else
  301. {
  302. Logger.Instance.WriteGlobal("Adding new bot: {0}", b.Name);
  303. BotSettings.Instance.Bots.Add(b);
  304. }
  305.  
  306. BotSettings.Instance.Save();
  307. shouldClose = true;
  308. ActiveForm.Close();
  309.  
  310. BotSettings.Instance.Save();
  311. Program.Mainform.UpdateGridView();
  312. return;
  313. }
  314.  
  315. if (ValidateControl(Controls[_stepCount]))
  316. {
  317. Controls[_stepCount].Visible = false; // Hide old
  318. _stepCount++;
  319. Controls[_stepCount].Visible = true; // Show new
  320. }
  321.  
  322. if (_stepCount > _mainCount)
  323. buttonBack.Enabled = true;
  324. if (_stepCount == FinishCount)
  325. buttonNext.Text = "Save!";
  326. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement