BalanceConfigForm.cs 80 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060
  1. using Server.MirEnvir;
  2. using Shared.Extensions;
  3. namespace Server
  4. {
  5. public partial class BalanceConfigForm : Form
  6. {
  7. public Envir Envir => SMain.EditEnvir;
  8. public byte SelectedClassID = 0;
  9. public byte HeroSelectedClassID = 0;
  10. public bool BaseStatsChanged = false;
  11. public bool HeroBaseStatsChanged = false;
  12. public bool RandomItemStatsChanged = false;
  13. public bool GuildsChanged = false;
  14. public bool Populating = false;
  15. public BalanceConfigForm()
  16. {
  17. InitializeComponent();
  18. ClassComboBox.Items.AddRange(Enum.GetValues(typeof(MirClass)).Cast<object>().ToArray());
  19. HeroClassComboBox.Items.AddRange(Enum.GetValues(typeof(MirClass)).Cast<object>().ToArray());
  20. for (int i = 0; i < Settings.RandomItemStatsList.Count; i++)
  21. RISIndexcomboBox.Items.Add(i);
  22. UpdateStatInterface();
  23. UpdateRandomItemStats();
  24. this.BaseStatType.ValueType = typeof(Stat);
  25. this.BaseStatType.DataSource = Enum.GetValues(typeof(Stat));
  26. this.BaseStatFormula.ValueType = typeof(StatFormula);
  27. this.BaseStatFormula.DataSource = Enum.GetValues(typeof(StatFormula));
  28. this.CapType.ValueType = typeof(Stat);
  29. this.CapType.DataSource = Enum.GetValues(typeof(Stat));
  30. this.HeroBaseStatType.ValueType = typeof(Stat);
  31. this.HeroBaseStatType.DataSource = Enum.GetValues(typeof(Stat));
  32. this.HeroBaseStatFormula.ValueType = typeof(StatFormula);
  33. this.HeroBaseStatFormula.DataSource = Enum.GetValues(typeof(StatFormula));
  34. this.HeroCapType.ValueType = typeof(Stat);
  35. this.HeroCapType.DataSource = Enum.GetValues(typeof(Stat));
  36. // Populate hero tab (keep it simple, like other tabs).
  37. if (HeroClassComboBox.Items.Count > 0)
  38. {
  39. HeroSelectedClassID = 0;
  40. HeroClassComboBox.SelectedIndex = 0;
  41. Populating = true;
  42. UpdateHeroClassStatGridView();
  43. UpdateHeroClassCapGridView();
  44. Populating = false;
  45. }
  46. }
  47. private void BalanceConfigForm_FormClosed(object sender, FormClosedEventArgs e)
  48. {
  49. //save configs
  50. if (BaseStatsChanged)
  51. {
  52. Settings.SaveBaseStats();
  53. SMain.Envir.RequiresBaseStatUpdate();
  54. }
  55. if (HeroBaseStatsChanged)
  56. {
  57. Settings.SaveHeroBaseStats();
  58. SMain.Envir.RequiresHeroBaseStatUpdate();
  59. }
  60. if (RandomItemStatsChanged) Settings.SaveRandomItemStats();
  61. if (GuildsChanged) Settings.SaveGuildSettings();
  62. }
  63. private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
  64. {
  65. lblClassStatExample.Visible = false;
  66. lblHeroStatExample.Visible = false;
  67. if (tabControl1.SelectedTab.Name == "tabPage3")
  68. {
  69. lblClassStatExample.Visible = true;
  70. }
  71. if (tabControl1.SelectedTab == tabHero)
  72. {
  73. lblHeroStatExample.Visible = true;
  74. }
  75. }
  76. private void ClassComboBox_SelectedIndexChanged(object sender, EventArgs e)
  77. {
  78. if (ActiveControl != sender) return;
  79. SelectedClassID = (byte)ClassComboBox.SelectedItem;
  80. Populating = true;
  81. UpdateClassStatGridView();
  82. UpdateClassCapGridView();
  83. Populating = false;
  84. }
  85. private void UpdateStatInterface()
  86. {
  87. MagicResistWeigttextbox.Text = Settings.MagicResistWeight.ToString();
  88. PoisonResistWeighttextbox.Text = Settings.PoisonResistWeight.ToString();
  89. CritialRateWeighttextbox.Text = Settings.CriticalRateWeight.ToString();
  90. CriticalDamagetextbox.Text = Settings.CriticalDamageWeight.ToString();
  91. PoisonAttackWeighttextbox.Text = Settings.PoisonAttackWeight.ToString();
  92. FreezingWeighttextbox.Text = Settings.FreezingAttackWeight.ToString();
  93. HealthRegenWeighttextBox.Text = Settings.HealthRegenWeight.ToString();
  94. ManaRegenWeighttextBox.Text = Settings.ManaRegenWeight.ToString();
  95. CanFreezecheckBox.Checked = Settings.PvpCanFreeze;
  96. CanResistPoisoncheckBox.Checked = Settings.PvpCanResistPoison;
  97. CanResistMagiccheckBox.Checked = Settings.PvpCanResistMagic;
  98. }
  99. private void UpdateRandomItemStats()
  100. {
  101. if (RISIndexcomboBox.SelectedItem == null)
  102. {
  103. RISMaxDuraChancetextBox.Text = string.Empty;
  104. RISMaxDuraStatChancetextBox.Text = string.Empty;
  105. RISMaxDuraMaxStattextBox.Text = string.Empty;
  106. RISMaxAcChancetextBox.Text = string.Empty;
  107. RISMaxAcStatChancetextBox.Text = string.Empty;
  108. RISMaxAcMaxStattextBox.Text = string.Empty;
  109. RISMaxMacChancetextBox.Text = string.Empty;
  110. RISMaxMacStatChancetextBox.Text = string.Empty;
  111. RISMaxMacMaxStattextBox.Text = string.Empty;
  112. RISMaxDcChancetextBox.Text = string.Empty;
  113. RISMaxDcStatChancetextBox.Text = string.Empty;
  114. RISMaxDcMaxStattextBox.Text = string.Empty;
  115. RISMaxMcChancetextBox.Text = string.Empty;
  116. RISMaxMcStatChancetextBox.Text = string.Empty;
  117. RISMaxMcMaxStattextBox.Text = string.Empty;
  118. RISMaxScChancetextBox.Text = string.Empty;
  119. RISMaxScStatChancetextBox.Text = string.Empty;
  120. RISMaxScMaxStattextBox.Text = string.Empty;
  121. RISMaxAccChancetextBox.Text = string.Empty;
  122. RISMaxAccStatChancetextBox.Text = string.Empty;
  123. RISMaxAccMaxStattextBox.Text = string.Empty;
  124. RISMaxAgilChancetextBox.Text = string.Empty;
  125. RISMaxAgilStatChancetextBox.Text = string.Empty;
  126. RISMaxAgilMaxStattextBox.Text = string.Empty;
  127. RISMaxHpChancetextBox.Text = string.Empty;
  128. RISMaxHpStatChancetextBox.Text = string.Empty;
  129. RISMaxHpMaxStattextBox.Text = string.Empty;
  130. RISMaxMpChancetextBox.Text = string.Empty;
  131. RISMaxMpStatChancetextBox.Text = string.Empty;
  132. RISMaxMpMaxStattextBox.Text = string.Empty;
  133. RISStrongChancetextBox.Text = string.Empty;
  134. RISStrongStatChancetextBox.Text = string.Empty;
  135. RISStrongMaxStattextBox.Text = string.Empty;
  136. RISMagicResistChancetextBox.Text = string.Empty;
  137. RISMagicResistStatChancetextBox.Text = string.Empty;
  138. RISMagicResistMaxStattextBox.Text = string.Empty;
  139. RISPoisonResistChancetextBox.Text = string.Empty;
  140. RISPoisonResistStatChancetextBox.Text = string.Empty;
  141. RISPoisonResistMaxStattextBox.Text = string.Empty;
  142. RISHpRecovChancetextBox.Text = string.Empty;
  143. RISHpRecovStatChancetextBox.Text = string.Empty;
  144. RISHpRecovMaxStattextBox.Text = string.Empty;
  145. RISMpRecovChancetextBox.Text = string.Empty;
  146. RISMpRecovStatChancetextBox.Text = string.Empty;
  147. RISMpRecovMaxStattextBox.Text = string.Empty;
  148. RISPoisonRecovChancetextBox.Text = string.Empty;
  149. RISPoisonRecovStatChancetextBox.Text = string.Empty;
  150. RISPoisonRecovMaxStattextBox.Text = string.Empty;
  151. RISCriticalRateChancetextBox.Text = string.Empty;
  152. RISCriticalRateStatChancetextBox.Text = string.Empty;
  153. RISCriticalRateMaxStattextBox.Text = string.Empty;
  154. RISCriticalDamageChancetextBox.Text = string.Empty;
  155. RISCriticalDamageStatChancetextBox.Text = string.Empty;
  156. RISCriticalDamageMaxStattextBox.Text = string.Empty;
  157. RISFreezingChancetextBox.Text = string.Empty;
  158. RISFreezingStatChancetextBox.Text = string.Empty;
  159. RISFreezingMaxStattextBox.Text = string.Empty;
  160. RISPoisonAttackChancetextBox.Text = string.Empty;
  161. RISPoisonAttackStatChancetextBox.Text = string.Empty;
  162. RISPoisonAttackMaxStattextBox.Text = string.Empty;
  163. RISAttackSpeedChancetextBox.Text = string.Empty;
  164. RISAttackSpeedStatChancetextBox.Text = string.Empty;
  165. RISAttackSpeedMaxStattextBox.Text = string.Empty;
  166. RISLuckChancetextBox.Text = string.Empty;
  167. RISLuckStatChancetextBox.Text = string.Empty;
  168. RISLuckMaxStattextBox.Text = string.Empty;
  169. RISCurseChancetextBox.Text = string.Empty;
  170. }
  171. else
  172. {
  173. if (Settings.RandomItemStatsList.Count <= RISIndexcomboBox.SelectedIndex)
  174. {
  175. RISIndexcomboBox.SelectedItem = null;
  176. UpdateRandomItemStats();
  177. return;
  178. }
  179. RandomItemStat stat = Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex];
  180. RISMaxDuraChancetextBox.Text = stat.MaxDuraChance.ToString();
  181. RISMaxDuraStatChancetextBox.Text = stat.MaxDuraStatChance.ToString();
  182. RISMaxDuraMaxStattextBox.Text = stat.MaxDuraMaxStat.ToString();
  183. RISMaxAcChancetextBox.Text = stat.MaxAcChance.ToString();
  184. RISMaxAcStatChancetextBox.Text = stat.MaxAcStatChance.ToString();
  185. RISMaxAcMaxStattextBox.Text = stat.MaxAcMaxStat.ToString();
  186. RISMaxMacChancetextBox.Text = stat.MaxMacChance.ToString();
  187. RISMaxMacStatChancetextBox.Text = stat.MaxMacStatChance.ToString();
  188. RISMaxMacMaxStattextBox.Text = stat.MaxMacMaxStat.ToString();
  189. RISMaxDcChancetextBox.Text = stat.MaxDcChance.ToString();
  190. RISMaxDcStatChancetextBox.Text = stat.MaxDcStatChance.ToString();
  191. RISMaxDcMaxStattextBox.Text = stat.MaxDcMaxStat.ToString();
  192. RISMaxMcChancetextBox.Text = stat.MaxMcChance.ToString();
  193. RISMaxMcStatChancetextBox.Text = stat.MaxMcStatChance.ToString();
  194. RISMaxMcMaxStattextBox.Text = stat.MaxMcMaxStat.ToString();
  195. RISMaxScChancetextBox.Text = stat.MaxScChance.ToString();
  196. RISMaxScStatChancetextBox.Text = stat.MaxScStatChance.ToString();
  197. RISMaxScMaxStattextBox.Text = stat.MaxScMaxStat.ToString();
  198. RISMaxAccChancetextBox.Text = stat.AccuracyChance.ToString();
  199. RISMaxAccStatChancetextBox.Text = stat.AccuracyStatChance.ToString();
  200. RISMaxAccMaxStattextBox.Text = stat.AccuracyMaxStat.ToString();
  201. RISMaxAgilChancetextBox.Text = stat.AgilityChance.ToString();
  202. RISMaxAgilStatChancetextBox.Text = stat.AgilityStatChance.ToString();
  203. RISMaxAgilMaxStattextBox.Text = stat.AgilityMaxStat.ToString();
  204. RISMaxHpChancetextBox.Text = stat.HpChance.ToString();
  205. RISMaxHpStatChancetextBox.Text = stat.HpStatChance.ToString();
  206. RISMaxHpMaxStattextBox.Text = stat.HpMaxStat.ToString();
  207. RISMaxMpChancetextBox.Text = stat.MpChance.ToString();
  208. RISMaxMpStatChancetextBox.Text = stat.MpStatChance.ToString();
  209. RISMaxMpMaxStattextBox.Text = stat.MpMaxStat.ToString();
  210. RISStrongChancetextBox.Text = stat.StrongChance.ToString();
  211. RISStrongStatChancetextBox.Text = stat.StrongStatChance.ToString();
  212. RISStrongMaxStattextBox.Text = stat.StrongMaxStat.ToString();
  213. RISMagicResistChancetextBox.Text = stat.MagicResistChance.ToString();
  214. RISMagicResistStatChancetextBox.Text = stat.MagicResistStatChance.ToString();
  215. RISMagicResistMaxStattextBox.Text = stat.MagicResistMaxStat.ToString();
  216. RISPoisonResistChancetextBox.Text = stat.PoisonResistChance.ToString();
  217. RISPoisonResistStatChancetextBox.Text = stat.PoisonResistStatChance.ToString();
  218. RISPoisonResistMaxStattextBox.Text = stat.PoisonResistMaxStat.ToString();
  219. RISHpRecovChancetextBox.Text = stat.HpRecovChance.ToString();
  220. RISHpRecovStatChancetextBox.Text = stat.HpRecovStatChance.ToString();
  221. RISHpRecovMaxStattextBox.Text = stat.HpRecovMaxStat.ToString();
  222. RISMpRecovChancetextBox.Text = stat.MpRecovChance.ToString();
  223. RISMpRecovStatChancetextBox.Text = stat.MpRecovStatChance.ToString();
  224. RISMpRecovMaxStattextBox.Text = stat.MpRecovMaxStat.ToString();
  225. RISPoisonRecovChancetextBox.Text = stat.PoisonRecovChance.ToString();
  226. RISPoisonRecovStatChancetextBox.Text = stat.PoisonRecovStatChance.ToString();
  227. RISPoisonRecovMaxStattextBox.Text = stat.PoisonRecovMaxStat.ToString();
  228. RISCriticalRateChancetextBox.Text = stat.CriticalRateChance.ToString();
  229. RISCriticalRateStatChancetextBox.Text = stat.CriticalRateStatChance.ToString();
  230. RISCriticalRateMaxStattextBox.Text = stat.CriticalRateMaxStat.ToString();
  231. RISCriticalDamageChancetextBox.Text = stat.CriticalDamageChance.ToString();
  232. RISCriticalDamageStatChancetextBox.Text = stat.CriticalDamageStatChance.ToString();
  233. RISCriticalDamageMaxStattextBox.Text = stat.CriticalDamageMaxStat.ToString();
  234. RISFreezingChancetextBox.Text = stat.FreezeChance.ToString();
  235. RISFreezingStatChancetextBox.Text = stat.FreezeStatChance.ToString();
  236. RISFreezingMaxStattextBox.Text = stat.FreezeMaxStat.ToString();
  237. RISPoisonAttackChancetextBox.Text = stat.PoisonAttackChance.ToString();
  238. RISPoisonAttackStatChancetextBox.Text = stat.PoisonAttackStatChance.ToString();
  239. RISPoisonAttackMaxStattextBox.Text = stat.PoisonAttackMaxStat.ToString();
  240. RISAttackSpeedChancetextBox.Text = stat.AttackSpeedChance.ToString();
  241. RISAttackSpeedStatChancetextBox.Text = stat.AttackSpeedStatChance.ToString();
  242. RISAttackSpeedMaxStattextBox.Text = stat.AttackSpeedMaxStat.ToString();
  243. RISLuckChancetextBox.Text = stat.LuckChance.ToString();
  244. RISLuckStatChancetextBox.Text = stat.LuckStatChance.ToString();
  245. RISLuckMaxStattextBox.Text = stat.LuckMaxStat.ToString();
  246. RISCurseChancetextBox.Text = stat.CurseChance.ToString();
  247. RISSlotChancetextBox.Text = stat.SlotChance.ToString();
  248. RISSlotStatChancetextBox.Text = stat.SlotStatChance.ToString();
  249. RISSlotMaxStattextBox.Text = stat.SlotMaxStat.ToString();
  250. }
  251. }
  252. #region ItemStats
  253. private void MagicResistWeigttextbox_TextChanged(object sender, EventArgs e)
  254. {
  255. if (ActiveControl != sender) return;
  256. byte temp;
  257. if (!byte.TryParse(ActiveControl.Text, out temp))
  258. {
  259. ActiveControl.BackColor = Color.Red;
  260. return;
  261. }
  262. ActiveControl.BackColor = SystemColors.Window;
  263. Settings.MagicResistWeight = temp;
  264. }
  265. private void PoisonResistWeighttextbox_TextChanged(object sender, EventArgs e)
  266. {
  267. if (ActiveControl != sender) return;
  268. byte temp;
  269. if (!byte.TryParse(ActiveControl.Text, out temp))
  270. {
  271. ActiveControl.BackColor = Color.Red;
  272. return;
  273. }
  274. ActiveControl.BackColor = SystemColors.Window;
  275. Settings.PoisonResistWeight = temp;
  276. }
  277. private void CritialRateWeighttextbox_TextChanged(object sender, EventArgs e)
  278. {
  279. if (ActiveControl != sender) return;
  280. byte temp;
  281. if (!byte.TryParse(ActiveControl.Text, out temp))
  282. {
  283. ActiveControl.BackColor = Color.Red;
  284. return;
  285. }
  286. ActiveControl.BackColor = SystemColors.Window;
  287. Settings.CriticalRateWeight = temp;
  288. }
  289. private void CriticalDamagetextbox_TextChanged(object sender, EventArgs e)
  290. {
  291. if (ActiveControl != sender) return;
  292. byte temp;
  293. if (!byte.TryParse(ActiveControl.Text, out temp))
  294. {
  295. ActiveControl.BackColor = Color.Red;
  296. return;
  297. }
  298. ActiveControl.BackColor = SystemColors.Window;
  299. Settings.CriticalDamageWeight = temp;
  300. }
  301. private void FreezingWeighttextbox_TextChanged(object sender, EventArgs e)
  302. {
  303. if (ActiveControl != sender) return;
  304. byte temp;
  305. if (!byte.TryParse(ActiveControl.Text, out temp))
  306. {
  307. ActiveControl.BackColor = Color.Red;
  308. return;
  309. }
  310. ActiveControl.BackColor = SystemColors.Window;
  311. Settings.FreezingAttackWeight = temp;
  312. }
  313. private void PoisonAttackWeighttextbox_TextChanged(object sender, EventArgs e)
  314. {
  315. if (ActiveControl != sender) return;
  316. byte temp;
  317. if (!byte.TryParse(ActiveControl.Text, out temp))
  318. {
  319. ActiveControl.BackColor = Color.Red;
  320. return;
  321. }
  322. ActiveControl.BackColor = SystemColors.Window;
  323. Settings.PoisonAttackWeight = temp;
  324. }
  325. private void CanResistMagiccheckBox_CheckedChanged(object sender, EventArgs e)
  326. {
  327. if (ActiveControl != sender) return;
  328. Settings.PvpCanResistMagic = CanResistMagiccheckBox.Checked;
  329. }
  330. private void CanResistPoisoncheckBox_CheckedChanged(object sender, EventArgs e)
  331. {
  332. if (ActiveControl != sender) return;
  333. Settings.PvpCanResistPoison = CanResistPoisoncheckBox.Checked;
  334. }
  335. private void CanFreezecheckBox_CheckedChanged(object sender, EventArgs e)
  336. {
  337. if (ActiveControl != sender) return;
  338. Settings.PvpCanFreeze = CanFreezecheckBox.Checked;
  339. }
  340. private void HealthRegenWeighttextBox_TextChanged(object sender, EventArgs e)
  341. {
  342. if (ActiveControl != sender) return;
  343. byte temp;
  344. if (!byte.TryParse(ActiveControl.Text, out temp))
  345. {
  346. ActiveControl.BackColor = Color.Red;
  347. return;
  348. }
  349. ActiveControl.BackColor = SystemColors.Window;
  350. BaseStatsChanged = true;
  351. Settings.HealthRegenWeight = temp;
  352. }
  353. private void ManaRegenWeighttextBox_TextChanged(object sender, EventArgs e)
  354. {
  355. if (ActiveControl != sender) return;
  356. byte temp;
  357. if (!byte.TryParse(ActiveControl.Text, out temp))
  358. {
  359. ActiveControl.BackColor = Color.Red;
  360. return;
  361. }
  362. ActiveControl.BackColor = SystemColors.Window;
  363. BaseStatsChanged = true;
  364. Settings.ManaRegenWeight = temp;
  365. }
  366. #endregion
  367. #region RandomItemStat
  368. private void RISIndexcomboBox_SelectedIndexChanged(object sender, EventArgs e)
  369. {
  370. if (ActiveControl != sender) return;
  371. UpdateRandomItemStats();
  372. }
  373. private void RISAddIndexbutton_Click(object sender, EventArgs e)
  374. {
  375. RandomItemStatsChanged = true;
  376. Settings.RandomItemStatsList.Add(new RandomItemStat());
  377. RISIndexcomboBox.Items.Add(Settings.RandomItemStatsList.Count - 1);
  378. RISIndexcomboBox.SelectedIndex = Settings.RandomItemStatsList.Count - 1;
  379. UpdateRandomItemStats();
  380. }
  381. private void RISDeleteIndexbutton_Click(object sender, EventArgs e)
  382. {
  383. if (MessageBox.Show("Are you sure you want to delete the last index?", "Delete?", MessageBoxButtons.YesNo) != DialogResult.Yes) return;
  384. RandomItemStatsChanged = true;
  385. RISIndexcomboBox.Items.Remove(Settings.RandomItemStatsList.Count - 1);
  386. Settings.RandomItemStatsList.RemoveAt(Settings.RandomItemStatsList.Count - 1);
  387. UpdateRandomItemStats();
  388. }
  389. private void RISMaxDuraChancetextBox_TextChanged(object sender, EventArgs e)
  390. {
  391. if (ActiveControl != sender) return;
  392. if (RISIndexcomboBox.SelectedItem == null) return;
  393. byte temp;
  394. if (!byte.TryParse(ActiveControl.Text, out temp))
  395. {
  396. ActiveControl.BackColor = Color.Red;
  397. return;
  398. }
  399. ActiveControl.BackColor = SystemColors.Window;
  400. RandomItemStatsChanged = true;
  401. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].MaxDuraChance = temp;
  402. }
  403. private void RISMaxDuraStatChancetextBox_TextChanged(object sender, EventArgs e)
  404. {
  405. if (ActiveControl != sender) return;
  406. if (RISIndexcomboBox.SelectedItem == null) return;
  407. byte temp;
  408. if (!byte.TryParse(ActiveControl.Text, out temp))
  409. {
  410. ActiveControl.BackColor = Color.Red;
  411. return;
  412. }
  413. ActiveControl.BackColor = SystemColors.Window;
  414. RandomItemStatsChanged = true;
  415. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].MaxDuraStatChance = temp;
  416. }
  417. private void RISMaxDuraMaxStattextBox_TextChanged(object sender, EventArgs e)
  418. {
  419. if (ActiveControl != sender) return;
  420. if (RISIndexcomboBox.SelectedItem == null) return;
  421. byte temp;
  422. if ((!byte.TryParse(ActiveControl.Text, out temp)) || (temp < 1))
  423. {
  424. ActiveControl.BackColor = Color.Red;
  425. return;
  426. }
  427. ActiveControl.BackColor = SystemColors.Window;
  428. RandomItemStatsChanged = true;
  429. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].MaxDuraMaxStat = temp;
  430. }
  431. private void RISMaxAcChancetextBox_TextChanged(object sender, EventArgs e)
  432. {
  433. if (ActiveControl != sender) return;
  434. if (RISIndexcomboBox.SelectedItem == null) return;
  435. byte temp;
  436. if (!byte.TryParse(ActiveControl.Text, out temp))
  437. {
  438. ActiveControl.BackColor = Color.Red;
  439. return;
  440. }
  441. ActiveControl.BackColor = SystemColors.Window;
  442. RandomItemStatsChanged = true;
  443. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].MaxAcChance = temp;
  444. }
  445. private void RISMaxAcStatChancetextBox_TextChanged(object sender, EventArgs e)
  446. {
  447. if (ActiveControl != sender) return;
  448. if (RISIndexcomboBox.SelectedItem == null) return;
  449. byte temp;
  450. if (!byte.TryParse(ActiveControl.Text, out temp))
  451. {
  452. ActiveControl.BackColor = Color.Red;
  453. return;
  454. }
  455. ActiveControl.BackColor = SystemColors.Window;
  456. RandomItemStatsChanged = true;
  457. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].MaxAcStatChance = temp;
  458. }
  459. private void RISMaxAcMaxStattextBox_TextChanged(object sender, EventArgs e)
  460. {
  461. if (ActiveControl != sender) return;
  462. if (RISIndexcomboBox.SelectedItem == null) return;
  463. byte temp;
  464. if ((!byte.TryParse(ActiveControl.Text, out temp)) || (temp < 1))
  465. {
  466. ActiveControl.BackColor = Color.Red;
  467. return;
  468. }
  469. ActiveControl.BackColor = SystemColors.Window;
  470. RandomItemStatsChanged = true;
  471. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].MaxAcMaxStat = temp;
  472. }
  473. private void RISMaxMacChancetextBox_TextChanged(object sender, EventArgs e)
  474. {
  475. if (ActiveControl != sender) return;
  476. if (RISIndexcomboBox.SelectedItem == null) return;
  477. byte temp;
  478. if (!byte.TryParse(ActiveControl.Text, out temp))
  479. {
  480. ActiveControl.BackColor = Color.Red;
  481. return;
  482. }
  483. ActiveControl.BackColor = SystemColors.Window;
  484. RandomItemStatsChanged = true;
  485. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].MaxMacChance = temp;
  486. }
  487. private void RISMaxMacStatChancetextBox_TextChanged(object sender, EventArgs e)
  488. {
  489. if (ActiveControl != sender) return;
  490. if (RISIndexcomboBox.SelectedItem == null) return;
  491. byte temp;
  492. if (!byte.TryParse(ActiveControl.Text, out temp))
  493. {
  494. ActiveControl.BackColor = Color.Red;
  495. return;
  496. }
  497. ActiveControl.BackColor = SystemColors.Window;
  498. RandomItemStatsChanged = true;
  499. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].MaxMacStatChance = temp;
  500. }
  501. private void RISMaxMacMaxStattextBox_TextChanged(object sender, EventArgs e)
  502. {
  503. if (ActiveControl != sender) return;
  504. if (RISIndexcomboBox.SelectedItem == null) return;
  505. byte temp;
  506. if ((!byte.TryParse(ActiveControl.Text, out temp)) || (temp < 1))
  507. {
  508. ActiveControl.BackColor = Color.Red;
  509. return;
  510. }
  511. ActiveControl.BackColor = SystemColors.Window;
  512. RandomItemStatsChanged = true;
  513. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].MaxMacMaxStat = temp;
  514. }
  515. private void RISMaxDcChancetextBox_TextChanged(object sender, EventArgs e)
  516. {
  517. if (ActiveControl != sender) return;
  518. if (RISIndexcomboBox.SelectedItem == null) return;
  519. byte temp;
  520. if (!byte.TryParse(ActiveControl.Text, out temp))
  521. {
  522. ActiveControl.BackColor = Color.Red;
  523. return;
  524. }
  525. ActiveControl.BackColor = SystemColors.Window;
  526. RandomItemStatsChanged = true;
  527. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].MaxDcChance = temp;
  528. }
  529. private void RISMaxDcStatChancetextBox_TextChanged(object sender, EventArgs e)
  530. {
  531. if (ActiveControl != sender) return;
  532. if (RISIndexcomboBox.SelectedItem == null) return;
  533. byte temp;
  534. if (!byte.TryParse(ActiveControl.Text, out temp))
  535. {
  536. ActiveControl.BackColor = Color.Red;
  537. return;
  538. }
  539. ActiveControl.BackColor = SystemColors.Window;
  540. RandomItemStatsChanged = true;
  541. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].MaxDcStatChance = temp;
  542. }
  543. private void RISMaxDcMaxStattextBox_TextChanged(object sender, EventArgs e)
  544. {
  545. if (ActiveControl != sender) return;
  546. if (RISIndexcomboBox.SelectedItem == null) return;
  547. byte temp;
  548. if ((!byte.TryParse(ActiveControl.Text, out temp)) || (temp < 1))
  549. {
  550. ActiveControl.BackColor = Color.Red;
  551. return;
  552. }
  553. ActiveControl.BackColor = SystemColors.Window;
  554. RandomItemStatsChanged = true;
  555. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].MaxDcMaxStat = temp;
  556. }
  557. private void RISMaxMcChancetextBox_TextChanged(object sender, EventArgs e)
  558. {
  559. if (ActiveControl != sender) return;
  560. if (RISIndexcomboBox.SelectedItem == null) return;
  561. byte temp;
  562. if (!byte.TryParse(ActiveControl.Text, out temp))
  563. {
  564. ActiveControl.BackColor = Color.Red;
  565. return;
  566. }
  567. ActiveControl.BackColor = SystemColors.Window;
  568. RandomItemStatsChanged = true;
  569. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].MaxMcChance = temp;
  570. }
  571. private void RISMaxMcStatChancetextBox_TextChanged(object sender, EventArgs e)
  572. {
  573. if (ActiveControl != sender) return;
  574. if (RISIndexcomboBox.SelectedItem == null) return;
  575. byte temp;
  576. if (!byte.TryParse(ActiveControl.Text, out temp))
  577. {
  578. ActiveControl.BackColor = Color.Red;
  579. return;
  580. }
  581. ActiveControl.BackColor = SystemColors.Window;
  582. RandomItemStatsChanged = true;
  583. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].MaxMcStatChance = temp;
  584. }
  585. private void RISMaxMcMaxStattextBox_TextChanged(object sender, EventArgs e)
  586. {
  587. if (ActiveControl != sender) return;
  588. if (RISIndexcomboBox.SelectedItem == null) return;
  589. byte temp;
  590. if ((!byte.TryParse(ActiveControl.Text, out temp)) || (temp < 1))
  591. {
  592. ActiveControl.BackColor = Color.Red;
  593. return;
  594. }
  595. ActiveControl.BackColor = SystemColors.Window;
  596. RandomItemStatsChanged = true;
  597. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].MaxMcMaxStat = temp;
  598. }
  599. private void RISMaxScChancetextBox_TextChanged(object sender, EventArgs e)
  600. {
  601. if (ActiveControl != sender) return;
  602. if (RISIndexcomboBox.SelectedItem == null) return;
  603. byte temp;
  604. if (!byte.TryParse(ActiveControl.Text, out temp))
  605. {
  606. ActiveControl.BackColor = Color.Red;
  607. return;
  608. }
  609. ActiveControl.BackColor = SystemColors.Window;
  610. RandomItemStatsChanged = true;
  611. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].MaxScChance = temp;
  612. }
  613. private void RISMaxScStatChancetextBox_TextChanged(object sender, EventArgs e)
  614. {
  615. if (ActiveControl != sender) return;
  616. if (RISIndexcomboBox.SelectedItem == null) return;
  617. byte temp;
  618. if (!byte.TryParse(ActiveControl.Text, out temp))
  619. {
  620. ActiveControl.BackColor = Color.Red;
  621. return;
  622. }
  623. ActiveControl.BackColor = SystemColors.Window;
  624. RandomItemStatsChanged = true;
  625. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].MaxScStatChance = temp;
  626. }
  627. private void RISMaxScMaxStattextBox_TextChanged(object sender, EventArgs e)
  628. {
  629. if (ActiveControl != sender) return;
  630. if (RISIndexcomboBox.SelectedItem == null) return;
  631. byte temp;
  632. if ((!byte.TryParse(ActiveControl.Text, out temp)) || (temp < 1))
  633. {
  634. ActiveControl.BackColor = Color.Red;
  635. return;
  636. }
  637. ActiveControl.BackColor = SystemColors.Window;
  638. RandomItemStatsChanged = true;
  639. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].MaxScMaxStat = temp;
  640. }
  641. private void RISMaxAccChancetextBox_TextChanged(object sender, EventArgs e)
  642. {
  643. if (ActiveControl != sender) return;
  644. if (RISIndexcomboBox.SelectedItem == null) return;
  645. byte temp;
  646. if (!byte.TryParse(ActiveControl.Text, out temp))
  647. {
  648. ActiveControl.BackColor = Color.Red;
  649. return;
  650. }
  651. ActiveControl.BackColor = SystemColors.Window;
  652. RandomItemStatsChanged = true;
  653. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].AccuracyChance = temp;
  654. }
  655. private void RISMaxAccStatChancetextBox_TextChanged(object sender, EventArgs e)
  656. {
  657. if (ActiveControl != sender) return;
  658. if (RISIndexcomboBox.SelectedItem == null) return;
  659. byte temp;
  660. if (!byte.TryParse(ActiveControl.Text, out temp))
  661. {
  662. ActiveControl.BackColor = Color.Red;
  663. return;
  664. }
  665. ActiveControl.BackColor = SystemColors.Window;
  666. RandomItemStatsChanged = true;
  667. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].AccuracyStatChance = temp;
  668. }
  669. private void RISMaxAccMaxStattextBox_TextChanged(object sender, EventArgs e)
  670. {
  671. if (ActiveControl != sender) return;
  672. if (RISIndexcomboBox.SelectedItem == null) return;
  673. byte temp;
  674. if ((!byte.TryParse(ActiveControl.Text, out temp)) || (temp < 1))
  675. {
  676. ActiveControl.BackColor = Color.Red;
  677. return;
  678. }
  679. ActiveControl.BackColor = SystemColors.Window;
  680. RandomItemStatsChanged = true;
  681. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].AccuracyMaxStat = temp;
  682. }
  683. private void RISMaxAgilChancetextBox_TextChanged(object sender, EventArgs e)
  684. {
  685. if (ActiveControl != sender) return;
  686. if (RISIndexcomboBox.SelectedItem == null) return;
  687. byte temp;
  688. if (!byte.TryParse(ActiveControl.Text, out temp))
  689. {
  690. ActiveControl.BackColor = Color.Red;
  691. return;
  692. }
  693. ActiveControl.BackColor = SystemColors.Window;
  694. RandomItemStatsChanged = true;
  695. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].AgilityChance = temp;
  696. }
  697. private void RISMaxAgilStatChancetextBox_TextChanged(object sender, EventArgs e)
  698. {
  699. if (ActiveControl != sender) return;
  700. if (RISIndexcomboBox.SelectedItem == null) return;
  701. byte temp;
  702. if (!byte.TryParse(ActiveControl.Text, out temp))
  703. {
  704. ActiveControl.BackColor = Color.Red;
  705. return;
  706. }
  707. ActiveControl.BackColor = SystemColors.Window;
  708. RandomItemStatsChanged = true;
  709. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].AgilityStatChance = temp;
  710. }
  711. private void RISMaxAgilMaxStattextBox_TextChanged(object sender, EventArgs e)
  712. {
  713. if (ActiveControl != sender) return;
  714. if (RISIndexcomboBox.SelectedItem == null) return;
  715. byte temp;
  716. if ((!byte.TryParse(ActiveControl.Text, out temp)) || (temp < 1))
  717. {
  718. ActiveControl.BackColor = Color.Red;
  719. return;
  720. }
  721. ActiveControl.BackColor = SystemColors.Window;
  722. RandomItemStatsChanged = true;
  723. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].AgilityMaxStat = temp;
  724. }
  725. private void RISMaxHpChancetextBox_TextChanged(object sender, EventArgs e)
  726. {
  727. if (ActiveControl != sender) return;
  728. if (RISIndexcomboBox.SelectedItem == null) return;
  729. byte temp;
  730. if (!byte.TryParse(ActiveControl.Text, out temp))
  731. {
  732. ActiveControl.BackColor = Color.Red;
  733. return;
  734. }
  735. ActiveControl.BackColor = SystemColors.Window;
  736. RandomItemStatsChanged = true;
  737. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].HpChance = temp;
  738. }
  739. private void RISMaxHpStatChancetextBox_TextChanged(object sender, EventArgs e)
  740. {
  741. if (ActiveControl != sender) return;
  742. if (RISIndexcomboBox.SelectedItem == null) return;
  743. byte temp;
  744. if (!byte.TryParse(ActiveControl.Text, out temp))
  745. {
  746. ActiveControl.BackColor = Color.Red;
  747. return;
  748. }
  749. ActiveControl.BackColor = SystemColors.Window;
  750. RandomItemStatsChanged = true;
  751. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].HpStatChance = temp;
  752. }
  753. private void RISMaxHpMaxStattextBox_TextChanged(object sender, EventArgs e)
  754. {
  755. if (ActiveControl != sender) return;
  756. if (RISIndexcomboBox.SelectedItem == null) return;
  757. byte temp;
  758. if ((!byte.TryParse(ActiveControl.Text, out temp)) || (temp < 1))
  759. {
  760. ActiveControl.BackColor = Color.Red;
  761. return;
  762. }
  763. ActiveControl.BackColor = SystemColors.Window;
  764. RandomItemStatsChanged = true;
  765. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].HpMaxStat = temp;
  766. }
  767. private void RISMaxMpChancetextBox_TextChanged(object sender, EventArgs e)
  768. {
  769. if (ActiveControl != sender) return;
  770. if (RISIndexcomboBox.SelectedItem == null) return;
  771. byte temp;
  772. if (!byte.TryParse(ActiveControl.Text, out temp))
  773. {
  774. ActiveControl.BackColor = Color.Red;
  775. return;
  776. }
  777. ActiveControl.BackColor = SystemColors.Window;
  778. RandomItemStatsChanged = true;
  779. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].MpChance = temp;
  780. }
  781. private void RISMaxMpStatChancetextBox_TextChanged(object sender, EventArgs e)
  782. {
  783. if (ActiveControl != sender) return;
  784. if (RISIndexcomboBox.SelectedItem == null) return;
  785. byte temp;
  786. if (!byte.TryParse(ActiveControl.Text, out temp))
  787. {
  788. ActiveControl.BackColor = Color.Red;
  789. return;
  790. }
  791. ActiveControl.BackColor = SystemColors.Window;
  792. RandomItemStatsChanged = true;
  793. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].MpStatChance = temp;
  794. }
  795. private void RISMaxMpMaxStattextBox_TextChanged(object sender, EventArgs e)
  796. {
  797. if (ActiveControl != sender) return;
  798. if (RISIndexcomboBox.SelectedItem == null) return;
  799. byte temp;
  800. if ((!byte.TryParse(ActiveControl.Text, out temp)) || (temp < 1))
  801. {
  802. ActiveControl.BackColor = Color.Red;
  803. return;
  804. }
  805. ActiveControl.BackColor = SystemColors.Window;
  806. RandomItemStatsChanged = true;
  807. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].MpMaxStat = temp;
  808. }
  809. private void RISStrongChancetextBox_TextChanged(object sender, EventArgs e)
  810. {
  811. if (ActiveControl != sender) return;
  812. if (RISIndexcomboBox.SelectedItem == null) return;
  813. byte temp;
  814. if (!byte.TryParse(ActiveControl.Text, out temp))
  815. {
  816. ActiveControl.BackColor = Color.Red;
  817. return;
  818. }
  819. ActiveControl.BackColor = SystemColors.Window;
  820. RandomItemStatsChanged = true;
  821. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].StrongChance = temp;
  822. }
  823. private void RISStrongStatChancetextBox_TextChanged(object sender, EventArgs e)
  824. {
  825. if (ActiveControl != sender) return;
  826. if (RISIndexcomboBox.SelectedItem == null) return;
  827. byte temp;
  828. if (!byte.TryParse(ActiveControl.Text, out temp))
  829. {
  830. ActiveControl.BackColor = Color.Red;
  831. return;
  832. }
  833. ActiveControl.BackColor = SystemColors.Window;
  834. RandomItemStatsChanged = true;
  835. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].StrongStatChance = temp;
  836. }
  837. private void RISStrongMaxStattextBox_TextChanged(object sender, EventArgs e)
  838. {
  839. if (ActiveControl != sender) return;
  840. if (RISIndexcomboBox.SelectedItem == null) return;
  841. byte temp;
  842. if ((!byte.TryParse(ActiveControl.Text, out temp)) || (temp < 1))
  843. {
  844. ActiveControl.BackColor = Color.Red;
  845. return;
  846. }
  847. ActiveControl.BackColor = SystemColors.Window;
  848. RandomItemStatsChanged = true;
  849. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].StrongMaxStat = temp;
  850. }
  851. private void RISMagicResistChancetextBox_TextChanged(object sender, EventArgs e)
  852. {
  853. if (ActiveControl != sender) return;
  854. if (RISIndexcomboBox.SelectedItem == null) return;
  855. byte temp;
  856. if (!byte.TryParse(ActiveControl.Text, out temp))
  857. {
  858. ActiveControl.BackColor = Color.Red;
  859. return;
  860. }
  861. ActiveControl.BackColor = SystemColors.Window;
  862. RandomItemStatsChanged = true;
  863. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].MagicResistChance = temp;
  864. }
  865. private void RISMagicResistStatChancetextBox_TextChanged(object sender, EventArgs e)
  866. {
  867. if (ActiveControl != sender) return;
  868. if (RISIndexcomboBox.SelectedItem == null) return;
  869. byte temp;
  870. if (!byte.TryParse(ActiveControl.Text, out temp))
  871. {
  872. ActiveControl.BackColor = Color.Red;
  873. return;
  874. }
  875. ActiveControl.BackColor = SystemColors.Window;
  876. RandomItemStatsChanged = true;
  877. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].MagicResistStatChance = temp;
  878. }
  879. private void RISMagicResistMaxStattextBox_TextChanged(object sender, EventArgs e)
  880. {
  881. if (ActiveControl != sender) return;
  882. if (RISIndexcomboBox.SelectedItem == null) return;
  883. byte temp;
  884. if ((!byte.TryParse(ActiveControl.Text, out temp)) || (temp < 1))
  885. {
  886. ActiveControl.BackColor = Color.Red;
  887. return;
  888. }
  889. ActiveControl.BackColor = SystemColors.Window;
  890. RandomItemStatsChanged = true;
  891. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].MagicResistMaxStat = temp;
  892. }
  893. private void RISPoisonResistChancetextBox_TextChanged(object sender, EventArgs e)
  894. {
  895. if (ActiveControl != sender) return;
  896. if (RISIndexcomboBox.SelectedItem == null) return;
  897. byte temp;
  898. if (!byte.TryParse(ActiveControl.Text, out temp))
  899. {
  900. ActiveControl.BackColor = Color.Red;
  901. return;
  902. }
  903. ActiveControl.BackColor = SystemColors.Window;
  904. RandomItemStatsChanged = true;
  905. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].PoisonResistChance = temp;
  906. }
  907. private void RISPoisonResistStatChancetextBox_TextChanged(object sender, EventArgs e)
  908. {
  909. if (ActiveControl != sender) return;
  910. if (RISIndexcomboBox.SelectedItem == null) return;
  911. byte temp;
  912. if (!byte.TryParse(ActiveControl.Text, out temp))
  913. {
  914. ActiveControl.BackColor = Color.Red;
  915. return;
  916. }
  917. ActiveControl.BackColor = SystemColors.Window;
  918. RandomItemStatsChanged = true;
  919. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].PoisonResistStatChance = temp;
  920. }
  921. private void RISPoisonResistMaxStattextBox_TextChanged(object sender, EventArgs e)
  922. {
  923. if (ActiveControl != sender) return;
  924. if (RISIndexcomboBox.SelectedItem == null) return;
  925. byte temp;
  926. if ((!byte.TryParse(ActiveControl.Text, out temp)) || (temp < 1))
  927. {
  928. ActiveControl.BackColor = Color.Red;
  929. return;
  930. }
  931. ActiveControl.BackColor = SystemColors.Window;
  932. RandomItemStatsChanged = true;
  933. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].PoisonResistMaxStat = temp;
  934. }
  935. private void RISHpRecovChancetextBox_TextChanged(object sender, EventArgs e)
  936. {
  937. if (ActiveControl != sender) return;
  938. if (RISIndexcomboBox.SelectedItem == null) return;
  939. byte temp;
  940. if (!byte.TryParse(ActiveControl.Text, out temp))
  941. {
  942. ActiveControl.BackColor = Color.Red;
  943. return;
  944. }
  945. ActiveControl.BackColor = SystemColors.Window;
  946. RandomItemStatsChanged = true;
  947. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].HpRecovChance = temp;
  948. }
  949. private void RISHpRecovStatChancetextBox_TextChanged(object sender, EventArgs e)
  950. {
  951. if (ActiveControl != sender) return;
  952. if (RISIndexcomboBox.SelectedItem == null) return;
  953. byte temp;
  954. if (!byte.TryParse(ActiveControl.Text, out temp))
  955. {
  956. ActiveControl.BackColor = Color.Red;
  957. return;
  958. }
  959. ActiveControl.BackColor = SystemColors.Window;
  960. RandomItemStatsChanged = true;
  961. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].HpRecovStatChance = temp;
  962. }
  963. private void RISHpRecovMaxStattextBox_TextChanged(object sender, EventArgs e)
  964. {
  965. if (ActiveControl != sender) return;
  966. if (RISIndexcomboBox.SelectedItem == null) return;
  967. byte temp;
  968. if ((!byte.TryParse(ActiveControl.Text, out temp)) || (temp < 1))
  969. {
  970. ActiveControl.BackColor = Color.Red;
  971. return;
  972. }
  973. ActiveControl.BackColor = SystemColors.Window;
  974. RandomItemStatsChanged = true;
  975. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].HpRecovMaxStat = temp;
  976. }
  977. private void RISMpRecovChancetextBox_TextChanged(object sender, EventArgs e)
  978. {
  979. if (ActiveControl != sender) return;
  980. if (RISIndexcomboBox.SelectedItem == null) return;
  981. byte temp;
  982. if (!byte.TryParse(ActiveControl.Text, out temp))
  983. {
  984. ActiveControl.BackColor = Color.Red;
  985. return;
  986. }
  987. ActiveControl.BackColor = SystemColors.Window;
  988. RandomItemStatsChanged = true;
  989. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].MpRecovChance = temp;
  990. }
  991. private void RISMpRecovStatChancetextBox_TextChanged(object sender, EventArgs e)
  992. {
  993. if (ActiveControl != sender) return;
  994. if (RISIndexcomboBox.SelectedItem == null) return;
  995. byte temp;
  996. if (!byte.TryParse(ActiveControl.Text, out temp))
  997. {
  998. ActiveControl.BackColor = Color.Red;
  999. return;
  1000. }
  1001. ActiveControl.BackColor = SystemColors.Window;
  1002. RandomItemStatsChanged = true;
  1003. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].MpRecovStatChance = temp;
  1004. }
  1005. private void RISMpRecovMaxStattextBox_TextChanged(object sender, EventArgs e)
  1006. {
  1007. if (ActiveControl != sender) return;
  1008. if (RISIndexcomboBox.SelectedItem == null) return;
  1009. byte temp;
  1010. if ((!byte.TryParse(ActiveControl.Text, out temp)) || (temp < 1))
  1011. {
  1012. ActiveControl.BackColor = Color.Red;
  1013. return;
  1014. }
  1015. ActiveControl.BackColor = SystemColors.Window;
  1016. RandomItemStatsChanged = true;
  1017. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].MpRecovMaxStat = temp;
  1018. }
  1019. private void RISPoisonRecovChancetextBox_TextChanged(object sender, EventArgs e)
  1020. {
  1021. if (ActiveControl != sender) return;
  1022. if (RISIndexcomboBox.SelectedItem == null) return;
  1023. byte temp;
  1024. if (!byte.TryParse(ActiveControl.Text, out temp))
  1025. {
  1026. ActiveControl.BackColor = Color.Red;
  1027. return;
  1028. }
  1029. ActiveControl.BackColor = SystemColors.Window;
  1030. RandomItemStatsChanged = true;
  1031. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].PoisonRecovChance = temp;
  1032. }
  1033. private void RISPoisonRecovStatChancetextBox_TextChanged(object sender, EventArgs e)
  1034. {
  1035. if (ActiveControl != sender) return;
  1036. if (RISIndexcomboBox.SelectedItem == null) return;
  1037. byte temp;
  1038. if (!byte.TryParse(ActiveControl.Text, out temp))
  1039. {
  1040. ActiveControl.BackColor = Color.Red;
  1041. return;
  1042. }
  1043. ActiveControl.BackColor = SystemColors.Window;
  1044. RandomItemStatsChanged = true;
  1045. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].PoisonRecovStatChance = temp;
  1046. }
  1047. private void RISPoisonRecovMaxStattextBox_TextChanged(object sender, EventArgs e)
  1048. {
  1049. if (ActiveControl != sender) return;
  1050. if (RISIndexcomboBox.SelectedItem == null) return;
  1051. byte temp;
  1052. if ((!byte.TryParse(ActiveControl.Text, out temp)) || (temp < 1))
  1053. {
  1054. ActiveControl.BackColor = Color.Red;
  1055. return;
  1056. }
  1057. ActiveControl.BackColor = SystemColors.Window;
  1058. RandomItemStatsChanged = true;
  1059. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].PoisonRecovMaxStat = temp;
  1060. }
  1061. private void RISCriticalRateChancetextBox_TextChanged(object sender, EventArgs e)
  1062. {
  1063. if (ActiveControl != sender) return;
  1064. if (RISIndexcomboBox.SelectedItem == null) return;
  1065. byte temp;
  1066. if (!byte.TryParse(ActiveControl.Text, out temp))
  1067. {
  1068. ActiveControl.BackColor = Color.Red;
  1069. return;
  1070. }
  1071. ActiveControl.BackColor = SystemColors.Window;
  1072. RandomItemStatsChanged = true;
  1073. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].CriticalRateChance = temp;
  1074. }
  1075. private void RISCriticalRateStatChancetextBox_TextChanged(object sender, EventArgs e)
  1076. {
  1077. if (ActiveControl != sender) return;
  1078. if (RISIndexcomboBox.SelectedItem == null) return;
  1079. byte temp;
  1080. if (!byte.TryParse(ActiveControl.Text, out temp))
  1081. {
  1082. ActiveControl.BackColor = Color.Red;
  1083. return;
  1084. }
  1085. ActiveControl.BackColor = SystemColors.Window;
  1086. RandomItemStatsChanged = true;
  1087. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].CriticalRateStatChance = temp;
  1088. }
  1089. private void RISCriticalRateMaxStattextBox_TextChanged(object sender, EventArgs e)
  1090. {
  1091. if (ActiveControl != sender) return;
  1092. if (RISIndexcomboBox.SelectedItem == null) return;
  1093. byte temp;
  1094. if ((!byte.TryParse(ActiveControl.Text, out temp)) || (temp < 1))
  1095. {
  1096. ActiveControl.BackColor = Color.Red;
  1097. return;
  1098. }
  1099. ActiveControl.BackColor = SystemColors.Window;
  1100. RandomItemStatsChanged = true;
  1101. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].CriticalRateMaxStat = temp;
  1102. }
  1103. private void RISCriticalDamageChancetextBox_TextChanged(object sender, EventArgs e)
  1104. {
  1105. if (ActiveControl != sender) return;
  1106. if (RISIndexcomboBox.SelectedItem == null) return;
  1107. byte temp;
  1108. if (!byte.TryParse(ActiveControl.Text, out temp))
  1109. {
  1110. ActiveControl.BackColor = Color.Red;
  1111. return;
  1112. }
  1113. ActiveControl.BackColor = SystemColors.Window;
  1114. RandomItemStatsChanged = true;
  1115. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].CriticalDamageChance = temp;
  1116. }
  1117. private void RISCriticalDamageStatChancetextBox_TextChanged(object sender, EventArgs e)
  1118. {
  1119. if (ActiveControl != sender) return;
  1120. if (RISIndexcomboBox.SelectedItem == null) return;
  1121. byte temp;
  1122. if (!byte.TryParse(ActiveControl.Text, out temp))
  1123. {
  1124. ActiveControl.BackColor = Color.Red;
  1125. return;
  1126. }
  1127. ActiveControl.BackColor = SystemColors.Window;
  1128. RandomItemStatsChanged = true;
  1129. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].CriticalDamageStatChance = temp;
  1130. }
  1131. private void RISCriticalDamageMaxStattextBox_TextChanged(object sender, EventArgs e)
  1132. {
  1133. if (ActiveControl != sender) return;
  1134. if (RISIndexcomboBox.SelectedItem == null) return;
  1135. byte temp;
  1136. if ((!byte.TryParse(ActiveControl.Text, out temp)) || (temp < 1))
  1137. {
  1138. ActiveControl.BackColor = Color.Red;
  1139. return;
  1140. }
  1141. ActiveControl.BackColor = SystemColors.Window;
  1142. RandomItemStatsChanged = true;
  1143. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].CriticalDamageMaxStat = temp;
  1144. }
  1145. private void RISFreezingChancetextBox_TextChanged(object sender, EventArgs e)
  1146. {
  1147. if (ActiveControl != sender) return;
  1148. if (RISIndexcomboBox.SelectedItem == null) return;
  1149. byte temp;
  1150. if (!byte.TryParse(ActiveControl.Text, out temp))
  1151. {
  1152. ActiveControl.BackColor = Color.Red;
  1153. return;
  1154. }
  1155. ActiveControl.BackColor = SystemColors.Window;
  1156. RandomItemStatsChanged = true;
  1157. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].FreezeChance = temp;
  1158. }
  1159. private void RISFreezingStatChancetextBox_TextChanged(object sender, EventArgs e)
  1160. {
  1161. if (ActiveControl != sender) return;
  1162. if (RISIndexcomboBox.SelectedItem == null) return;
  1163. byte temp;
  1164. if (!byte.TryParse(ActiveControl.Text, out temp))
  1165. {
  1166. ActiveControl.BackColor = Color.Red;
  1167. return;
  1168. }
  1169. ActiveControl.BackColor = SystemColors.Window;
  1170. RandomItemStatsChanged = true;
  1171. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].FreezeStatChance = temp;
  1172. }
  1173. private void RISFreezingMaxStattextBox_TextChanged(object sender, EventArgs e)
  1174. {
  1175. if (ActiveControl != sender) return;
  1176. if (RISIndexcomboBox.SelectedItem == null) return;
  1177. byte temp;
  1178. if ((!byte.TryParse(ActiveControl.Text, out temp)) || (temp < 1))
  1179. {
  1180. ActiveControl.BackColor = Color.Red;
  1181. return;
  1182. }
  1183. ActiveControl.BackColor = SystemColors.Window;
  1184. RandomItemStatsChanged = true;
  1185. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].FreezeMaxStat = temp;
  1186. }
  1187. private void RISPoisonAttackChancetextBox_TextChanged(object sender, EventArgs e)
  1188. {
  1189. if (ActiveControl != sender) return;
  1190. if (RISIndexcomboBox.SelectedItem == null) return;
  1191. byte temp;
  1192. if (!byte.TryParse(ActiveControl.Text, out temp))
  1193. {
  1194. ActiveControl.BackColor = Color.Red;
  1195. return;
  1196. }
  1197. ActiveControl.BackColor = SystemColors.Window;
  1198. RandomItemStatsChanged = true;
  1199. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].PoisonAttackChance = temp;
  1200. }
  1201. private void RISPoisonAttackStatChancetextBox_TextChanged(object sender, EventArgs e)
  1202. {
  1203. if (ActiveControl != sender) return;
  1204. if (RISIndexcomboBox.SelectedItem == null) return;
  1205. byte temp;
  1206. if (!byte.TryParse(ActiveControl.Text, out temp))
  1207. {
  1208. ActiveControl.BackColor = Color.Red;
  1209. return;
  1210. }
  1211. ActiveControl.BackColor = SystemColors.Window;
  1212. RandomItemStatsChanged = true;
  1213. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].PoisonAttackStatChance = temp;
  1214. }
  1215. private void RISPoisonAttackMaxStattextBox_TextChanged(object sender, EventArgs e)
  1216. {
  1217. if (ActiveControl != sender) return;
  1218. if (RISIndexcomboBox.SelectedItem == null) return;
  1219. byte temp;
  1220. if ((!byte.TryParse(ActiveControl.Text, out temp)) || (temp < 1))
  1221. {
  1222. ActiveControl.BackColor = Color.Red;
  1223. return;
  1224. }
  1225. ActiveControl.BackColor = SystemColors.Window;
  1226. RandomItemStatsChanged = true;
  1227. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].PoisonAttackMaxStat = temp;
  1228. }
  1229. private void RISAttackSpeedChancetextBox_TextChanged(object sender, EventArgs e)
  1230. {
  1231. if (ActiveControl != sender) return;
  1232. if (RISIndexcomboBox.SelectedItem == null) return;
  1233. byte temp;
  1234. if (!byte.TryParse(ActiveControl.Text, out temp))
  1235. {
  1236. ActiveControl.BackColor = Color.Red;
  1237. return;
  1238. }
  1239. ActiveControl.BackColor = SystemColors.Window;
  1240. RandomItemStatsChanged = true;
  1241. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].AttackSpeedChance = temp;
  1242. }
  1243. private void RISAttackSpeedStatChancetextBox_TextChanged(object sender, EventArgs e)
  1244. {
  1245. if (ActiveControl != sender) return;
  1246. if (RISIndexcomboBox.SelectedItem == null) return;
  1247. byte temp;
  1248. if (!byte.TryParse(ActiveControl.Text, out temp))
  1249. {
  1250. ActiveControl.BackColor = Color.Red;
  1251. return;
  1252. }
  1253. ActiveControl.BackColor = SystemColors.Window;
  1254. RandomItemStatsChanged = true;
  1255. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].AttackSpeedStatChance = temp;
  1256. }
  1257. private void RISAttackSpeedMaxStattextBox_TextChanged(object sender, EventArgs e)
  1258. {
  1259. if (ActiveControl != sender) return;
  1260. if (RISIndexcomboBox.SelectedItem == null) return;
  1261. byte temp;
  1262. if ((!byte.TryParse(ActiveControl.Text, out temp)) || (temp < 1))
  1263. {
  1264. ActiveControl.BackColor = Color.Red;
  1265. return;
  1266. }
  1267. ActiveControl.BackColor = SystemColors.Window;
  1268. RandomItemStatsChanged = true;
  1269. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].AttackSpeedMaxStat = temp;
  1270. }
  1271. private void RISLuckChancetextBox_TextChanged(object sender, EventArgs e)
  1272. {
  1273. if (ActiveControl != sender) return;
  1274. if (RISIndexcomboBox.SelectedItem == null) return;
  1275. byte temp;
  1276. if (!byte.TryParse(ActiveControl.Text, out temp))
  1277. {
  1278. ActiveControl.BackColor = Color.Red;
  1279. return;
  1280. }
  1281. ActiveControl.BackColor = SystemColors.Window;
  1282. RandomItemStatsChanged = true;
  1283. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].LuckChance = temp;
  1284. }
  1285. private void RISLuckStatChancetextBox_TextChanged(object sender, EventArgs e)
  1286. {
  1287. if (ActiveControl != sender) return;
  1288. if (RISIndexcomboBox.SelectedItem == null) return;
  1289. byte temp;
  1290. if (!byte.TryParse(ActiveControl.Text, out temp))
  1291. {
  1292. ActiveControl.BackColor = Color.Red;
  1293. return;
  1294. }
  1295. ActiveControl.BackColor = SystemColors.Window;
  1296. RandomItemStatsChanged = true;
  1297. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].LuckStatChance = temp;
  1298. }
  1299. private void RISLuckMaxStattextBox_TextChanged(object sender, EventArgs e)
  1300. {
  1301. if (ActiveControl != sender) return;
  1302. if (RISIndexcomboBox.SelectedItem == null) return;
  1303. byte temp;
  1304. if ((!byte.TryParse(ActiveControl.Text, out temp)) || (temp < 1))
  1305. {
  1306. ActiveControl.BackColor = Color.Red;
  1307. return;
  1308. }
  1309. ActiveControl.BackColor = SystemColors.Window;
  1310. RandomItemStatsChanged = true;
  1311. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].LuckMaxStat = temp;
  1312. }
  1313. private void RISCurseChancetextBox_TextChanged(object sender, EventArgs e)
  1314. {
  1315. if (ActiveControl != sender) return;
  1316. if (RISIndexcomboBox.SelectedItem == null) return;
  1317. byte temp;
  1318. if (!byte.TryParse(ActiveControl.Text, out temp))
  1319. {
  1320. ActiveControl.BackColor = Color.Red;
  1321. return;
  1322. }
  1323. ActiveControl.BackColor = SystemColors.Window;
  1324. RandomItemStatsChanged = true;
  1325. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].CurseChance = temp;
  1326. }
  1327. private void RISSlotChancetextBox_TextChanged(object sender, EventArgs e)
  1328. {
  1329. if (ActiveControl != sender) return;
  1330. if (RISIndexcomboBox.SelectedItem == null) return;
  1331. byte temp;
  1332. if (!byte.TryParse(ActiveControl.Text, out temp))
  1333. {
  1334. ActiveControl.BackColor = Color.Red;
  1335. return;
  1336. }
  1337. ActiveControl.BackColor = SystemColors.Window;
  1338. RandomItemStatsChanged = true;
  1339. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].SlotChance = temp;
  1340. }
  1341. private void RISSlotStatChancetextBox_TextChanged(object sender, EventArgs e)
  1342. {
  1343. if (ActiveControl != sender) return;
  1344. if (RISIndexcomboBox.SelectedItem == null) return;
  1345. byte temp;
  1346. if (!byte.TryParse(ActiveControl.Text, out temp))
  1347. {
  1348. ActiveControl.BackColor = Color.Red;
  1349. return;
  1350. }
  1351. ActiveControl.BackColor = SystemColors.Window;
  1352. RandomItemStatsChanged = true;
  1353. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].SlotStatChance = temp;
  1354. }
  1355. private void RISSlotMaxStattextBox_TextChanged(object sender, EventArgs e)
  1356. {
  1357. if (ActiveControl != sender) return;
  1358. if (RISIndexcomboBox.SelectedItem == null) return;
  1359. byte temp;
  1360. if ((!byte.TryParse(ActiveControl.Text, out temp)) || (temp < 1) || temp > 12)
  1361. {
  1362. ActiveControl.BackColor = Color.Red;
  1363. return;
  1364. }
  1365. ActiveControl.BackColor = SystemColors.Window;
  1366. RandomItemStatsChanged = true;
  1367. Settings.RandomItemStatsList[RISIndexcomboBox.SelectedIndex].SlotMaxStat = temp;
  1368. }
  1369. #endregion
  1370. #region Class
  1371. private void classGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
  1372. {
  1373. classGridView.Rows[e.RowIndex].ErrorText = "";
  1374. if (classGridView.Rows[e.RowIndex].IsNewRow) { return; }
  1375. if (e.ColumnIndex == 2 || e.ColumnIndex == 5)
  1376. {
  1377. if (!int.TryParse(e.FormattedValue.ToString(), out _))
  1378. {
  1379. e.Cancel = true;
  1380. classGridView.Rows[e.RowIndex].ErrorText = "the value must be an integer";
  1381. }
  1382. }
  1383. else if (e.ColumnIndex == 3 || e.ColumnIndex == 4)
  1384. {
  1385. if (!float.TryParse(e.FormattedValue.ToString(), out _))
  1386. {
  1387. e.Cancel = true;
  1388. classGridView.Rows[e.RowIndex].ErrorText = "the value must be a decimal";
  1389. }
  1390. }
  1391. }
  1392. private void classGridView_DefaultValuesNeeded(object sender, DataGridViewRowEventArgs e)
  1393. {
  1394. e.Row.Cells["BaseStatBase"].Value = 0;
  1395. e.Row.Cells["BaseStatGain"].Value = 0.0F;
  1396. e.Row.Cells["BaseStatGainRate"].Value = 0.0F;
  1397. e.Row.Cells["BaseStatMax"].Value = 0;
  1398. }
  1399. private void classGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
  1400. {
  1401. if (e.RowIndex < 0) return;
  1402. if (classGridView.Rows[e.RowIndex].IsNewRow) return;
  1403. if (classGridView.Columns[e.ColumnIndex].Name == "BaseStatFormula")
  1404. {
  1405. var formula = (StatFormula)classGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
  1406. var gainRateCell = classGridView.Rows[e.RowIndex].Cells["BaseStatGainRate"];
  1407. if (formula == StatFormula.Health || formula == StatFormula.Mana)
  1408. {
  1409. gainRateCell.ReadOnly = false;
  1410. gainRateCell.Style.BackColor = gainRateCell.OwningColumn.DefaultCellStyle.BackColor;
  1411. gainRateCell.Style.ForeColor = gainRateCell.OwningColumn.DefaultCellStyle.ForeColor;
  1412. }
  1413. else
  1414. {
  1415. gainRateCell.ReadOnly = true;
  1416. gainRateCell.Style.BackColor = Color.LightGray;
  1417. gainRateCell.Style.ForeColor = Color.DarkGray;
  1418. }
  1419. }
  1420. var statType = (Stat)classGridView.Rows[e.RowIndex].Cells["BaseStatType"].Value;
  1421. UpdateBaseStatData();
  1422. UpdateClassStatExample(statType);
  1423. }
  1424. private void classGridView_SelectionChanged(object sender, EventArgs e)
  1425. {
  1426. if (classGridView.SelectedRows.Count == 1)
  1427. {
  1428. var row = classGridView.SelectedRows[0];
  1429. var statType = (Stat)row.Cells["BaseStatType"].Value;
  1430. UpdateClassStatExample(statType);
  1431. }
  1432. }
  1433. private void classGridView_UserDeletedRow(object sender, DataGridViewRowEventArgs e)
  1434. {
  1435. UpdateBaseStatData();
  1436. }
  1437. private void classCapGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
  1438. {
  1439. classCapGridView.Rows[e.RowIndex].ErrorText = "";
  1440. if (classCapGridView.Rows[e.RowIndex].IsNewRow) { return; }
  1441. if (e.ColumnIndex == 1)
  1442. {
  1443. if (!int.TryParse(e.FormattedValue.ToString(), out _))
  1444. {
  1445. e.Cancel = true;
  1446. classCapGridView.Rows[e.RowIndex].ErrorText = "the value must be an integer";
  1447. }
  1448. }
  1449. }
  1450. private void classCapGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
  1451. {
  1452. if (e.RowIndex < 0) return;
  1453. if (classCapGridView.Rows[e.RowIndex].IsNewRow) return;
  1454. var capType = (Stat)classCapGridView.Rows[e.RowIndex].Cells["CapType"].Value;
  1455. UpdateCapStatData();
  1456. UpdateClassStatExample(capType);
  1457. }
  1458. private void classCapGridView_DefaultValuesNeeded(object sender, DataGridViewRowEventArgs e)
  1459. {
  1460. e.Row.Cells["Value"].Value = 0;
  1461. }
  1462. private void classCapGridView_UserDeletedRow(object sender, DataGridViewRowEventArgs e)
  1463. {
  1464. UpdateCapStatData();
  1465. }
  1466. private void UpdateClassStatExample(Stat type)
  1467. {
  1468. if (Populating) return;
  1469. var str = string.Format("{0} - {1}\r\r", ((MirClass)SelectedClassID), type);
  1470. BaseStats classStats = Settings.ClassBaseStats[SelectedClassID];
  1471. var stat = classStats.Stats.FirstOrDefault(x => x.Type == type);
  1472. if (stat != null)
  1473. {
  1474. var cap = classStats.Caps[type];
  1475. if (cap == 0) cap = int.MaxValue;
  1476. for (int level = 1; level <= 50; level++)
  1477. {
  1478. str += string.Format("Level {0}\t: {1}\n", level, Math.Min(cap, stat.Calculate((MirClass)SelectedClassID, level)));
  1479. }
  1480. lblClassStatExample.Text = str;
  1481. }
  1482. }
  1483. private void UpdateClassStatGridView()
  1484. {
  1485. classGridView.Rows.Clear();
  1486. BaseStats classStats = Settings.ClassBaseStats[SelectedClassID];
  1487. foreach (var stat in classStats.Stats)
  1488. {
  1489. int rowIndex = classGridView.Rows.Add();
  1490. var row = classGridView.Rows[rowIndex];
  1491. row.Cells["BaseStatType"].Value = stat.Type;
  1492. row.Cells["BaseStatFormula"].Value = stat.FormulaType;
  1493. row.Cells["BaseStatBase"].Value = stat.Base;
  1494. row.Cells["BaseStatGain"].Value = stat.Gain;
  1495. row.Cells["BaseStatGainRate"].Value = stat.GainRate;
  1496. row.Cells["BaseStatMax"].Value = stat.Max;
  1497. }
  1498. }
  1499. private void UpdateClassCapGridView()
  1500. {
  1501. classCapGridView.Rows.Clear();
  1502. BaseStats classStats = Settings.ClassBaseStats[SelectedClassID];
  1503. foreach (var cap in classStats.Caps.Values)
  1504. {
  1505. int rowIndex = classCapGridView.Rows.Add();
  1506. var row = classCapGridView.Rows[rowIndex];
  1507. row.Cells["CapType"].Value = cap.Key;
  1508. row.Cells["Value"].Value = cap.Value;
  1509. }
  1510. }
  1511. private void UpdateBaseStatData()
  1512. {
  1513. if (Populating) return;
  1514. BaseStatsChanged = true;
  1515. BaseStats classStats = Settings.ClassBaseStats[SelectedClassID];
  1516. classStats.Stats.Clear();
  1517. foreach (DataGridViewRow row in classGridView.Rows)
  1518. {
  1519. var cells = row.Cells;
  1520. if (cells[0].Value == null || cells[1].Value == null) continue;
  1521. var type = (Stat)row.Cells["BaseStatType"].Value;
  1522. var formula = (StatFormula)row.Cells["BaseStatFormula"].Value;
  1523. if (classStats.Stats.Any(x => x.Type == type))
  1524. {
  1525. MessageBox.Show(string.Format($"The stat '{type}' exists more than once so will not be saved."));
  1526. continue;
  1527. }
  1528. var baseStat = new BaseStat(type)
  1529. {
  1530. FormulaType = (StatFormula)cells["BaseStatFormula"].Value.ValueOrDefault<byte>(),
  1531. Base = cells["BaseStatBase"].Value.ValueOrDefault<int>(),
  1532. Gain = cells["BaseStatGain"].Value.ValueOrDefault<float>(),
  1533. GainRate = cells["BaseStatGainRate"].Value.ValueOrDefault<float>(),
  1534. Max = cells["BaseStatMax"].Value.ValueOrDefault<int>()
  1535. };
  1536. classStats.Stats.Add(baseStat);
  1537. }
  1538. }
  1539. private void UpdateCapStatData()
  1540. {
  1541. if (Populating) return;
  1542. BaseStatsChanged = true;
  1543. BaseStats classStats = Settings.ClassBaseStats[SelectedClassID];
  1544. classStats.Caps.Clear();
  1545. foreach (DataGridViewRow row in classCapGridView.Rows)
  1546. {
  1547. var cells = row.Cells;
  1548. if (cells[0].Value == null || cells[1].Value == null) continue;
  1549. var type = (Stat)row.Cells["CapType"].Value;
  1550. var value = (int)row.Cells["Value"].Value.ValueOrDefault<int>();
  1551. classStats.Caps[type] = value;
  1552. }
  1553. }
  1554. #endregion
  1555. #region Hero Class
  1556. private void HeroClassComboBox_SelectedIndexChanged(object sender, EventArgs e)
  1557. {
  1558. if (ActiveControl != sender) return;
  1559. HeroSelectedClassID = (byte)HeroClassComboBox.SelectedItem;
  1560. Populating = true;
  1561. UpdateHeroClassStatGridView();
  1562. UpdateHeroClassCapGridView();
  1563. Populating = false;
  1564. }
  1565. private void heroGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
  1566. {
  1567. heroGridView.Rows[e.RowIndex].ErrorText = "";
  1568. if (heroGridView.Rows[e.RowIndex].IsNewRow) { return; }
  1569. if (e.ColumnIndex == 2 || e.ColumnIndex == 5)
  1570. {
  1571. if (!int.TryParse(e.FormattedValue.ToString(), out _))
  1572. {
  1573. e.Cancel = true;
  1574. heroGridView.Rows[e.RowIndex].ErrorText = "the value must be an integer";
  1575. }
  1576. }
  1577. else if (e.ColumnIndex == 3 || e.ColumnIndex == 4)
  1578. {
  1579. if (!float.TryParse(e.FormattedValue.ToString(), out _))
  1580. {
  1581. e.Cancel = true;
  1582. heroGridView.Rows[e.RowIndex].ErrorText = "the value must be a decimal";
  1583. }
  1584. }
  1585. }
  1586. private void heroGridView_DefaultValuesNeeded(object sender, DataGridViewRowEventArgs e)
  1587. {
  1588. e.Row.Cells["HeroBaseStatBase"].Value = 0;
  1589. e.Row.Cells["HeroBaseStatGain"].Value = 0.0F;
  1590. e.Row.Cells["HeroBaseStatGainRate"].Value = 0.0F;
  1591. e.Row.Cells["HeroBaseStatMax"].Value = 0;
  1592. }
  1593. private void heroGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
  1594. {
  1595. if (e.RowIndex < 0) return;
  1596. if (heroGridView.Rows[e.RowIndex].IsNewRow) return;
  1597. if (heroGridView.Columns[e.ColumnIndex].Name == "HeroBaseStatFormula")
  1598. {
  1599. var formula = (StatFormula)heroGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
  1600. var gainRateCell = heroGridView.Rows[e.RowIndex].Cells["HeroBaseStatGainRate"];
  1601. if (formula == StatFormula.Health || formula == StatFormula.Mana)
  1602. {
  1603. gainRateCell.ReadOnly = false;
  1604. gainRateCell.Style.BackColor = gainRateCell.OwningColumn.DefaultCellStyle.BackColor;
  1605. gainRateCell.Style.ForeColor = gainRateCell.OwningColumn.DefaultCellStyle.ForeColor;
  1606. }
  1607. else
  1608. {
  1609. gainRateCell.ReadOnly = true;
  1610. gainRateCell.Style.BackColor = Color.LightGray;
  1611. gainRateCell.Style.ForeColor = Color.DarkGray;
  1612. }
  1613. }
  1614. var statType = (Stat)heroGridView.Rows[e.RowIndex].Cells["HeroBaseStatType"].Value;
  1615. UpdateHeroBaseStatData();
  1616. UpdateHeroClassStatExample(statType);
  1617. }
  1618. private void heroGridView_SelectionChanged(object sender, EventArgs e)
  1619. {
  1620. if (heroGridView.SelectedRows.Count == 1)
  1621. {
  1622. var row = heroGridView.SelectedRows[0];
  1623. var statType = (Stat)row.Cells["HeroBaseStatType"].Value;
  1624. UpdateHeroClassStatExample(statType);
  1625. }
  1626. }
  1627. private void heroGridView_UserDeletedRow(object sender, DataGridViewRowEventArgs e)
  1628. {
  1629. UpdateHeroBaseStatData();
  1630. }
  1631. private void heroCapGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
  1632. {
  1633. heroCapGridView.Rows[e.RowIndex].ErrorText = "";
  1634. if (heroCapGridView.Rows[e.RowIndex].IsNewRow) { return; }
  1635. if (e.ColumnIndex == 1)
  1636. {
  1637. if (!int.TryParse(e.FormattedValue.ToString(), out _))
  1638. {
  1639. e.Cancel = true;
  1640. heroCapGridView.Rows[e.RowIndex].ErrorText = "the value must be an integer";
  1641. }
  1642. }
  1643. }
  1644. private void heroCapGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
  1645. {
  1646. if (e.RowIndex < 0) return;
  1647. if (heroCapGridView.Rows[e.RowIndex].IsNewRow) return;
  1648. var capType = (Stat)heroCapGridView.Rows[e.RowIndex].Cells["HeroCapType"].Value;
  1649. UpdateHeroCapStatData();
  1650. UpdateHeroClassStatExample(capType);
  1651. }
  1652. private void heroCapGridView_DefaultValuesNeeded(object sender, DataGridViewRowEventArgs e)
  1653. {
  1654. e.Row.Cells["HeroCapValue"].Value = 0;
  1655. }
  1656. private void heroCapGridView_UserDeletedRow(object sender, DataGridViewRowEventArgs e)
  1657. {
  1658. UpdateHeroCapStatData();
  1659. }
  1660. private void UpdateHeroClassStatExample(Stat type)
  1661. {
  1662. if (Populating) return;
  1663. var str = string.Format("{0} - {1}\r\r", ((MirClass)HeroSelectedClassID), type);
  1664. BaseStats classStats = Settings.HeroBaseStats[HeroSelectedClassID];
  1665. var stat = classStats.Stats.FirstOrDefault(x => x.Type == type);
  1666. if (stat != null)
  1667. {
  1668. var cap = classStats.Caps[type];
  1669. if (cap == 0) cap = int.MaxValue;
  1670. for (int level = 1; level <= 50; level++)
  1671. {
  1672. str += string.Format("Level {0}\t: {1}\n", level, Math.Min(cap, stat.Calculate((MirClass)HeroSelectedClassID, level)));
  1673. }
  1674. if (lblHeroStatExample != null)
  1675. lblHeroStatExample.Text = str;
  1676. }
  1677. }
  1678. private void UpdateHeroClassStatGridView()
  1679. {
  1680. heroGridView.Rows.Clear();
  1681. BaseStats classStats = Settings.HeroBaseStats[HeroSelectedClassID];
  1682. foreach (var stat in classStats.Stats)
  1683. {
  1684. int rowIndex = heroGridView.Rows.Add();
  1685. var row = heroGridView.Rows[rowIndex];
  1686. row.Cells["HeroBaseStatType"].Value = stat.Type;
  1687. row.Cells["HeroBaseStatFormula"].Value = stat.FormulaType;
  1688. row.Cells["HeroBaseStatBase"].Value = stat.Base;
  1689. row.Cells["HeroBaseStatGain"].Value = stat.Gain;
  1690. row.Cells["HeroBaseStatGainRate"].Value = stat.GainRate;
  1691. row.Cells["HeroBaseStatMax"].Value = stat.Max;
  1692. }
  1693. }
  1694. private void UpdateHeroClassCapGridView()
  1695. {
  1696. heroCapGridView.Rows.Clear();
  1697. BaseStats classStats = Settings.HeroBaseStats[HeroSelectedClassID];
  1698. foreach (var cap in classStats.Caps.Values)
  1699. {
  1700. int rowIndex = heroCapGridView.Rows.Add();
  1701. var row = heroCapGridView.Rows[rowIndex];
  1702. row.Cells["HeroCapType"].Value = cap.Key;
  1703. row.Cells["HeroCapValue"].Value = cap.Value;
  1704. }
  1705. }
  1706. private void UpdateHeroBaseStatData()
  1707. {
  1708. if (Populating) return;
  1709. HeroBaseStatsChanged = true;
  1710. BaseStats classStats = Settings.HeroBaseStats[HeroSelectedClassID];
  1711. classStats.Stats.Clear();
  1712. foreach (DataGridViewRow row in heroGridView.Rows)
  1713. {
  1714. var cells = row.Cells;
  1715. if (cells[0].Value == null || cells[1].Value == null) continue;
  1716. var type = (Stat)row.Cells["HeroBaseStatType"].Value;
  1717. var formula = (StatFormula)row.Cells["HeroBaseStatFormula"].Value;
  1718. if (classStats.Stats.Any(x => x.Type == type))
  1719. {
  1720. MessageBox.Show(string.Format($"The stat '{type}' exists more than once so will not be saved."));
  1721. continue;
  1722. }
  1723. var baseStat = new BaseStat(type)
  1724. {
  1725. FormulaType = (StatFormula)cells["HeroBaseStatFormula"].Value.ValueOrDefault<byte>(),
  1726. Base = cells["HeroBaseStatBase"].Value.ValueOrDefault<int>(),
  1727. Gain = cells["HeroBaseStatGain"].Value.ValueOrDefault<float>(),
  1728. GainRate = cells["HeroBaseStatGainRate"].Value.ValueOrDefault<float>(),
  1729. Max = cells["HeroBaseStatMax"].Value.ValueOrDefault<int>()
  1730. };
  1731. classStats.Stats.Add(baseStat);
  1732. }
  1733. }
  1734. private void UpdateHeroCapStatData()
  1735. {
  1736. if (Populating) return;
  1737. HeroBaseStatsChanged = true;
  1738. BaseStats classStats = Settings.HeroBaseStats[HeroSelectedClassID];
  1739. classStats.Caps.Clear();
  1740. foreach (DataGridViewRow row in heroCapGridView.Rows)
  1741. {
  1742. var cells = row.Cells;
  1743. if (cells[0].Value == null || cells[1].Value == null) continue;
  1744. var type = (Stat)row.Cells["HeroCapType"].Value;
  1745. var value = (int)row.Cells["HeroCapValue"].Value.ValueOrDefault<int>();
  1746. classStats.Caps[type] = value;
  1747. }
  1748. }
  1749. #endregion
  1750. }
  1751. }