MapInfoForm.cs 79 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032
  1. using Server.MirDatabase;
  2. using Server.MirEnvir;
  3. namespace Server
  4. {
  5. public partial class MapInfoForm : Form
  6. {
  7. public Envir Envir => SMain.EditEnvir;
  8. private List<MapInfo> _selectedMapInfos;
  9. private List<SafeZoneInfo> _selectedSafeZoneInfos;
  10. private List<RespawnInfo> _selectedRespawnInfos;
  11. private List<MovementInfo> _selectedMovementInfos;
  12. private List<MineZone> _selectedMineZones;
  13. private MapInfo _info;
  14. public MapInfoForm()
  15. {
  16. InitializeComponent();
  17. List<string> mineItems = new() { { "Disabled" } };
  18. Settings.MineSetList.ForEach(x => mineItems.Add(x.Name));
  19. MineComboBox.DataSource = mineItems;
  20. MineZoneComboBox.DataSource = mineItems;
  21. LightsComboBox.Items.AddRange(Enum.GetValues(typeof(LightSetting)).Cast<object>().ToArray());
  22. List<MonsterInfo> monsterInfoItems = new();
  23. Envir.MonsterInfoList.ForEach(x => monsterInfoItems.Add(x));
  24. MonsterInfoComboBox.DataSource = monsterInfoItems;
  25. List<String> conquestItems = new() { { "None" } };
  26. Envir.ConquestInfoList.ForEach(x => conquestItems.Add(x.Name));
  27. ConquestComboBox.DataSource = conquestItems;
  28. lstParticles.Items.AddRange(Enum.GetValues(typeof(WeatherSetting)).Cast<object>().ToArray());
  29. UpdateInterface(true);
  30. }
  31. private void MapInfoForm_FormClosed(object sender, FormClosedEventArgs e)
  32. {
  33. Envir.SaveDB();
  34. }
  35. private void UpdateInterface(bool refresh = false)
  36. {
  37. MapInfoListBox.SelectedIndexChanged -= MapInfoListBox_SelectedIndexChanged;
  38. if (refresh || MapInfoListBox.Items.Count != Envir.MapInfoList.Count)
  39. {
  40. MapInfo selectedMap = MapInfoListBox.SelectedItem as MapInfo;
  41. MapInfoListBox.Items.Clear();
  42. DestMapComboBox.Items.Clear();
  43. lstParticles.SelectedItems.Clear();
  44. for (int i = 0; i < Envir.MapInfoList.Count; i++)
  45. {
  46. if (!string.IsNullOrEmpty(MapSearchTextBox.Text) &&
  47. !Envir.MapInfoList[i].Title.Contains(MapSearchTextBox.Text, StringComparison.OrdinalIgnoreCase))
  48. continue;
  49. MapInfoListBox.Items.Add(Envir.MapInfoList[i]);
  50. DestMapComboBox.Items.Add(Envir.MapInfoList[i]);
  51. }
  52. // Restore the selection if possible
  53. if (selectedMap != null && MapInfoListBox.Items.Contains(selectedMap))
  54. {
  55. MapInfoListBox.SelectedItem = selectedMap;
  56. }
  57. }
  58. MapInfoListBox.SelectedIndexChanged += MapInfoListBox_SelectedIndexChanged;
  59. _selectedMapInfos = MapInfoListBox.SelectedItems.Cast<MapInfo>().ToList();
  60. if (_selectedMapInfos == null || _selectedMapInfos.Count == 0)
  61. {
  62. tabPage1.Show();
  63. MapTabs.Enabled = false;
  64. MapIndexTextBox.Text = string.Empty;
  65. FileNameTextBox.Text = string.Empty;
  66. MapNameTextBox.Text = string.Empty;
  67. MiniMapTextBox.Text = string.Empty;
  68. BigMapTextBox.Text = string.Empty;
  69. LightsComboBox.SelectedItem = null;
  70. MineComboBox.SelectedItem = null;
  71. MusicTextBox.Text = string.Empty;
  72. lstParticles.SelectedItems.Clear();
  73. NoTeleportCheckbox.Checked = false;
  74. NoReconnectCheckbox.Checked = false;
  75. NoRandomCheckbox.Checked = false;
  76. NoEscapeCheckbox.Checked = false;
  77. NoRecallCheckbox.Checked = false;
  78. NoDrugCheckbox.Checked = false;
  79. NoPositionCheckbox.Checked = false;
  80. NoThrowItemCheckbox.Checked = false;
  81. NoDropPlayerCheckbox.Checked = false;
  82. NoDropMonsterCheckbox.Checked = false;
  83. NoNamesCheckbox.Checked = false;
  84. FightCheckbox.Checked = false;
  85. FireCheckbox.Checked = false;
  86. LightningCheckbox.Checked = false;
  87. NoReconnectTextbox.Text = string.Empty;
  88. FireTextbox.Text = string.Empty;
  89. LightningTextbox.Text = string.Empty;
  90. MapDarkLighttextBox.Text = string.Empty;
  91. GTBox.Checked = false;
  92. GTIndexBox.Text = string.Empty;
  93. NoExperienceCheckbox.Checked = false;
  94. noGroupCheckbox.Checked = false;
  95. NoPetsCheckbox.Checked = false;
  96. NoHeroesCheckbox.Checked = false;
  97. RequiredGroupTextBox.Text = string.Empty;
  98. RequiredGroupCheckBox.Checked = false;
  99. return;
  100. }
  101. MapInfo mi = _selectedMapInfos[0];
  102. MapTabs.Enabled = true;
  103. MapIndexTextBox.Text = mi.Index.ToString();
  104. FileNameTextBox.Text = mi.FileName;
  105. MapNameTextBox.Text = mi.Title;
  106. MiniMapTextBox.Text = mi.MiniMap.ToString();
  107. BigMapTextBox.Text = mi.BigMap.ToString();
  108. LightsComboBox.SelectedItem = mi.Light;
  109. MineComboBox.SelectedIndex = mi.MineIndex;
  110. MusicTextBox.Text = mi.Music.ToString();
  111. if (mi.WeatherParticles != WeatherSetting.None)
  112. {
  113. for (int i = 0; i < lstParticles.Items.Count; i++)
  114. {
  115. var item = lstParticles.Items[i];
  116. if (item != null)
  117. {
  118. if (((mi.WeatherParticles & (WeatherSetting)item)) == (WeatherSetting)item)
  119. lstParticles.SetSelected(i, true);
  120. continue;
  121. }
  122. }
  123. }
  124. //map attributes
  125. NoTeleportCheckbox.Checked = mi.NoTeleport;
  126. NoReconnectCheckbox.Checked = mi.NoReconnect;
  127. NoReconnectTextbox.Text = mi.NoReconnectMap;
  128. NoRandomCheckbox.Checked = mi.NoRandom;
  129. NoEscapeCheckbox.Checked = mi.NoEscape;
  130. NoRecallCheckbox.Checked = mi.NoRecall;
  131. NoDrugCheckbox.Checked = mi.NoDrug;
  132. NoPositionCheckbox.Checked = mi.NoPosition;
  133. NoThrowItemCheckbox.Checked = mi.NoThrowItem;
  134. NoDropPlayerCheckbox.Checked = mi.NoDropPlayer;
  135. NoDropMonsterCheckbox.Checked = mi.NoDropMonster;
  136. NoNamesCheckbox.Checked = mi.NoNames;
  137. FightCheckbox.Checked = mi.Fight;
  138. NoFightCheckbox.Checked = mi.NoFight;
  139. FireCheckbox.Checked = mi.Fire;
  140. FireTextbox.Text = mi.FireDamage.ToString();
  141. LightningCheckbox.Checked = mi.Lightning;
  142. LightningTextbox.Text = mi.LightningDamage.ToString();
  143. MapDarkLighttextBox.Text = mi.MapDarkLight.ToString();
  144. NoMountCheckbox.Checked = mi.NoMount;
  145. NeedBridleCheckbox.Checked = mi.NeedBridle;
  146. NoTownTeleportCheckbox.Checked = mi.NoTownTeleport;
  147. NoReincarnation.Checked = mi.NoReincarnation;
  148. GTBox.Checked = mi.GT;
  149. GTIndexBox.Text = mi.GTIndex.ToString();
  150. NoExperienceCheckbox.Checked = mi.NoExperience;
  151. noGroupCheckbox.Checked = mi.NoGroup;
  152. NoPetsCheckbox.Checked = mi.NoPets;
  153. NoIntelligentCreatureCheckbox.Checked = mi.NoIntelligentCreatures;
  154. NoHeroesCheckbox.Checked = mi.NoHero;
  155. RequiredGroupTextBox.Text = mi.RequiredGroupSize.ToString();
  156. RequiredGroupCheckBox.Checked = mi.RequiredGroup;
  157. FireWallCheckBox.Checked = mi.FireWallLimit;
  158. FireWallCount.Text = mi.FireWallCount > 0 ? mi.FireWallCount.ToString() : string.Empty;
  159. FireWallCount.Enabled = FireWallCheckBox.Checked;
  160. for (int i = 1; i < _selectedMapInfos.Count; i++)
  161. {
  162. mi = _selectedMapInfos[i];
  163. if (MapIndexTextBox.Text != mi.Index.ToString()) MapIndexTextBox.Text = string.Empty;
  164. if (FileNameTextBox.Text != mi.FileName) FileNameTextBox.Text = string.Empty;
  165. if (MapNameTextBox.Text != mi.Title) MapNameTextBox.Text = string.Empty;
  166. if (MiniMapTextBox.Text != mi.MiniMap.ToString()) MiniMapTextBox.Text = string.Empty;
  167. if (BigMapTextBox.Text != mi.BigMap.ToString()) BigMapTextBox.Text = string.Empty;
  168. if (LightsComboBox.SelectedItem == null || (LightSetting)LightsComboBox.SelectedItem != mi.Light) LightsComboBox.SelectedItem = null;
  169. if (MineComboBox.SelectedItem == null || MineComboBox.SelectedIndex != mi.MineIndex) MineComboBox.SelectedIndex = 1;
  170. if (MusicTextBox.Text != mi.Music.ToString()) MusicTextBox.Text = string.Empty;
  171. if (NoTeleportCheckbox.Checked != mi.NoTeleport) NoTeleportCheckbox.Checked = false;
  172. if (NoReconnectCheckbox.Checked != mi.NoReconnect) NoReconnectCheckbox.Checked = false;
  173. if (NoReconnectTextbox.Text != mi.NoReconnectMap) NoReconnectTextbox.Text = string.Empty;
  174. if (NoRandomCheckbox.Checked != mi.NoRandom) NoRandomCheckbox.Checked = false;
  175. if (NoEscapeCheckbox.Checked != mi.NoEscape) NoEscapeCheckbox.Checked = false;
  176. if (NoRecallCheckbox.Checked != mi.NoRecall) NoRecallCheckbox.Checked = false;
  177. if (NoDrugCheckbox.Checked != mi.NoDrug) NoDrugCheckbox.Checked = false;
  178. if (NoPositionCheckbox.Checked != mi.NoPosition) NoPositionCheckbox.Checked = false;
  179. if (NoThrowItemCheckbox.Checked != mi.NoThrowItem) NoThrowItemCheckbox.Checked = false;
  180. if (NoDropPlayerCheckbox.Checked != mi.NoDropPlayer) NoDropPlayerCheckbox.Checked = false;
  181. if (NoDropMonsterCheckbox.Checked != mi.NoDropMonster) NoDropMonsterCheckbox.Checked = false;
  182. if (NoNamesCheckbox.Checked != mi.NoNames) NoNamesCheckbox.Checked = false;
  183. if (FightCheckbox.Checked != mi.Fight) FightCheckbox.Checked = false;
  184. if (NoFightCheckbox.Checked != mi.NoFight) NoFightCheckbox.Checked = false;
  185. if (FireCheckbox.Checked != mi.Fire) FireCheckbox.Checked = false;
  186. if (FireTextbox.Text != mi.FireDamage.ToString()) FireTextbox.Text = string.Empty;
  187. if (LightningCheckbox.Checked != mi.Lightning) LightningCheckbox.Checked = false;
  188. if (LightningTextbox.Text != mi.LightningDamage.ToString()) LightningTextbox.Text = string.Empty;
  189. if (MapDarkLighttextBox.Text != mi.MapDarkLight.ToString()) MapDarkLighttextBox.Text = string.Empty;
  190. if (NoMountCheckbox.Checked != mi.NoMount) NoMountCheckbox.Checked = false;
  191. if (NeedBridleCheckbox.Checked != mi.NeedBridle) NeedBridleCheckbox.Checked = false;
  192. if (NoTownTeleportCheckbox.Checked != mi.NoTownTeleport) NoTownTeleportCheckbox.Checked = false;
  193. if (NoReincarnation.Checked != mi.NoReincarnation) NoReincarnation.Checked = false;
  194. if (GTBox.Checked != mi.GT) GTBox.Checked = false;
  195. if (GTIndexBox.Text != mi.GTIndex.ToString()) GTIndexBox.Text = string.Empty;
  196. if (NoExperienceCheckbox.Checked != mi.NoExperience) NoExperienceCheckbox.Checked = false;
  197. if (noGroupCheckbox.Checked != mi.NoGroup) noGroupCheckbox.Checked = false;
  198. if (NoPetsCheckbox.Checked != mi.NoPets) NoPetsCheckbox.Checked = false;
  199. if (NoIntelligentCreatureCheckbox.Checked != mi.NoIntelligentCreatures) NoIntelligentCreatureCheckbox.Checked = false;
  200. if (NoHeroesCheckbox.Checked != mi.NoHero) NoHeroesCheckbox.Checked = false;
  201. if (RequiredGroupTextBox.Text != mi.RequiredGroupSize.ToString()) RequiredGroupTextBox.Text = string.Empty;
  202. if (RequiredGroupCheckBox.Checked != (mi.RequiredGroupSize > 0)) RequiredGroupCheckBox.Checked = false;
  203. if (FireWallCount.Text != mi.FireWallCount.ToString()) FireWallCount.Text = string.Empty;
  204. if (FireWallCheckBox.Checked != mi.FireWallLimit) FireWallCheckBox.Checked = false;
  205. // Keep the enable state in sync after possible changes
  206. FireWallCount.Enabled = FireWallCheckBox.Checked;
  207. }
  208. UpdateSafeZoneInterface();
  209. UpdateRespawnInterface();
  210. UpdateMovementInterface();
  211. UpdateMineZoneInterface();
  212. }
  213. private void UpdateSafeZoneInterface()
  214. {
  215. if (_selectedMapInfos.Count != 1)
  216. {
  217. SafeZoneInfoListBox.Items.Clear();
  218. if (_selectedSafeZoneInfos != null && _selectedSafeZoneInfos.Count > 0)
  219. _selectedSafeZoneInfos.Clear();
  220. _info = null;
  221. SafeZoneInfoPanel.Enabled = false;
  222. SZXTextBox.Text = string.Empty;
  223. SZYTextBox.Text = string.Empty;
  224. StartPointCheckBox.CheckState = CheckState.Unchecked;
  225. return;
  226. }
  227. if (_info != _selectedMapInfos[0])
  228. {
  229. SafeZoneInfoListBox.Items.Clear();
  230. _info = _selectedMapInfos[0];
  231. }
  232. if (SafeZoneInfoListBox.Items.Count != _info.SafeZones.Count)
  233. {
  234. SafeZoneInfoListBox.Items.Clear();
  235. for (int i = 0; i < _info.SafeZones.Count; i++) SafeZoneInfoListBox.Items.Add(_info.SafeZones[i]);
  236. }
  237. _selectedSafeZoneInfos = SafeZoneInfoListBox.SelectedItems.Cast<SafeZoneInfo>().ToList();
  238. if (_selectedSafeZoneInfos.Count == 0)
  239. {
  240. SafeZoneInfoPanel.Enabled = false;
  241. SZXTextBox.Text = string.Empty;
  242. SZYTextBox.Text = string.Empty;
  243. StartPointCheckBox.CheckState = CheckState.Unchecked;
  244. return;
  245. }
  246. SafeZoneInfo info = _selectedSafeZoneInfos[0];
  247. SafeZoneInfoPanel.Enabled = true;
  248. SZXTextBox.Text = info.Location.X.ToString();
  249. SZYTextBox.Text = info.Location.Y.ToString();
  250. StartPointCheckBox.CheckState = info.StartPoint ? CheckState.Checked : CheckState.Unchecked;
  251. SizeTextBox.Text = info.Size.ToString();
  252. for (int i = 1; i < _selectedSafeZoneInfos.Count; i++)
  253. {
  254. info = _selectedSafeZoneInfos[i];
  255. if (SZXTextBox.Text != info.Location.X.ToString()) SZXTextBox.Text = string.Empty;
  256. if (SZYTextBox.Text != info.Location.Y.ToString()) SZYTextBox.Text = string.Empty;
  257. if (StartPointCheckBox.Checked != info.StartPoint) StartPointCheckBox.CheckState = CheckState.Indeterminate;
  258. if (SizeTextBox.Text != info.Size.ToString()) SizeTextBox.Text = string.Empty;
  259. }
  260. }
  261. private void UpdateRespawnInterface()
  262. {
  263. if (_selectedMapInfos.Count != 1)
  264. {
  265. RespawnInfoListBox.Items.Clear();
  266. if (_selectedRespawnInfos != null && _selectedRespawnInfos.Count > 0)
  267. _selectedRespawnInfos.Clear();
  268. _info = null;
  269. RespawnInfoPanel.Enabled = false;
  270. MonsterInfoComboBox.SelectedItem = null;
  271. RXTextBox.Text = string.Empty;
  272. RYTextBox.Text = string.Empty;
  273. CountTextBox.Text = string.Empty;
  274. SpreadTextBox.Text = string.Empty;
  275. DelayTextBox.Text = string.Empty;
  276. chkrespawnsave.Enabled = false;
  277. chkRespawnEnableTick.Checked = false;
  278. chkrespawnsave.Checked = false;
  279. DirectionTextBox.Text = string.Empty;
  280. RoutePathTextBox.Text = string.Empty;
  281. Randomtextbox.Text = string.Empty;
  282. return;
  283. }
  284. if (_info != _selectedMapInfos[0])
  285. {
  286. RespawnInfoListBox.Items.Clear();
  287. _info = _selectedMapInfos[0];
  288. }
  289. if (RespawnInfoListBox.Items.Count != _info.Respawns.Count)
  290. {
  291. RespawnInfoListBox.Items.Clear();
  292. for (int i = 0; i < _info.Respawns.Count; i++) RespawnInfoListBox.Items.Add(_info.Respawns[i]);
  293. }
  294. _selectedRespawnInfos = RespawnInfoListBox.SelectedItems.Cast<RespawnInfo>().ToList();
  295. if (_selectedRespawnInfos.Count == 0)
  296. {
  297. RespawnInfoPanel.Enabled = false;
  298. MonsterInfoComboBox.SelectedItem = null;
  299. RXTextBox.Text = string.Empty;
  300. RYTextBox.Text = string.Empty;
  301. CountTextBox.Text = string.Empty;
  302. SpreadTextBox.Text = string.Empty;
  303. DelayTextBox.Text = string.Empty;
  304. chkrespawnsave.Enabled = false;
  305. chkRespawnEnableTick.Checked = false;
  306. chkrespawnsave.Checked = false;
  307. DirectionTextBox.Text = string.Empty;
  308. RoutePathTextBox.Text = string.Empty;
  309. Randomtextbox.Text = string.Empty;
  310. return;
  311. }
  312. RespawnInfo info = _selectedRespawnInfos[0];
  313. RespawnInfoPanel.Enabled = true;
  314. MonsterInfoComboBox.SelectedItem = Envir.MonsterInfoList.FirstOrDefault(x => x.Index == info.MonsterIndex);
  315. RXTextBox.Text = info.Location.X.ToString();
  316. RYTextBox.Text = info.Location.Y.ToString();
  317. CountTextBox.Text = info.Count.ToString();
  318. SpreadTextBox.Text = info.Spread.ToString();
  319. DelayTextBox.Text = info.RespawnTicks == 0 ? info.Delay.ToString() : info.RespawnTicks.ToString();
  320. chkrespawnsave.Enabled = info.RespawnTicks != 0;
  321. chkRespawnEnableTick.Checked = info.RespawnTicks != 0;
  322. chkrespawnsave.Checked = ((info.RespawnTicks != 0) && (info.SaveRespawnTime)) ? true : false;
  323. DirectionTextBox.Text = info.Direction.ToString();
  324. RoutePathTextBox.Text = info.RoutePath;
  325. Randomtextbox.Enabled = info.RespawnTicks == 0;
  326. Randomtextbox.Text = info.RandomDelay.ToString();
  327. for (int i = 1; i < _selectedRespawnInfos.Count; i++)
  328. {
  329. info = _selectedRespawnInfos[i];
  330. if (MonsterInfoComboBox.SelectedItem != Envir.MonsterInfoList.FirstOrDefault(x => x.Index == info.MonsterIndex)) MonsterInfoComboBox.SelectedItem = null;
  331. if (RXTextBox.Text != info.Location.X.ToString()) RXTextBox.Text = string.Empty;
  332. if (RYTextBox.Text != info.Location.Y.ToString()) RYTextBox.Text = string.Empty;
  333. if (CountTextBox.Text != info.Count.ToString()) CountTextBox.Text = string.Empty;
  334. if (SpreadTextBox.Text != info.Spread.ToString()) SpreadTextBox.Text = string.Empty;
  335. if (chkRespawnEnableTick.Checked != (info.RespawnTicks == 0))
  336. {
  337. DelayTextBox.Text = string.Empty;
  338. chkrespawnsave.Enabled = false;
  339. chkrespawnsave.Checked = false;
  340. Randomtextbox.Text = string.Empty;
  341. }
  342. else
  343. {
  344. if (chkRespawnEnableTick.Checked)
  345. {
  346. if (DelayTextBox.Text != info.RespawnTicks.ToString()) DelayTextBox.Text = string.Empty;
  347. if (chkrespawnsave.Checked != info.SaveRespawnTime)
  348. {
  349. chkrespawnsave.Enabled = false;
  350. chkrespawnsave.Checked = false;
  351. }
  352. Randomtextbox.Enabled = false;
  353. Randomtextbox.Text = string.Empty;
  354. }
  355. else
  356. {
  357. if (DelayTextBox.Text != info.Delay.ToString()) DelayTextBox.Text = string.Empty;
  358. chkrespawnsave.Enabled = false;
  359. chkrespawnsave.Checked = false;
  360. if (Randomtextbox.Text != info.RandomDelay.ToString()) Randomtextbox.Text = string.Empty;
  361. }
  362. }
  363. if (DirectionTextBox.Text != info.Direction.ToString()) DirectionTextBox.Text = string.Empty;
  364. if (RoutePathTextBox.Text != info.RoutePath) RoutePathTextBox.Text = string.Empty;
  365. }
  366. }
  367. private void UpdateMovementInterface()
  368. {
  369. if (_selectedMapInfos.Count != 1)
  370. {
  371. MovementInfoListBox.Items.Clear();
  372. if (_selectedMovementInfos != null && _selectedMovementInfos.Count > 0)
  373. _selectedMovementInfos.Clear();
  374. _info = null;
  375. MovementInfoPanel.Enabled = false;
  376. SourceXTextBox.Text = string.Empty;
  377. SourceYTextBox.Text = string.Empty;
  378. DestMapComboBox.SelectedItem = null;
  379. ConquestComboBox.SelectedIndex = 0;
  380. DestXTextBox.Text = string.Empty;
  381. DestYTextBox.Text = string.Empty;
  382. BigMapIconTextBox.Text = string.Empty;
  383. return;
  384. }
  385. if (_info != _selectedMapInfos[0])
  386. {
  387. MovementInfoListBox.Items.Clear();
  388. _info = _selectedMapInfos[0];
  389. }
  390. if (MovementInfoListBox.Items.Count != _info.Movements.Count)
  391. {
  392. MovementInfoListBox.Items.Clear();
  393. for (int i = 0; i < _info.Movements.Count; i++) MovementInfoListBox.Items.Add(_info.Movements[i]);
  394. }
  395. _selectedMovementInfos = MovementInfoListBox.SelectedItems.Cast<MovementInfo>().ToList();
  396. if (_selectedMovementInfos.Count == 0)
  397. {
  398. MovementInfoPanel.Enabled = false;
  399. SourceXTextBox.Text = string.Empty;
  400. SourceYTextBox.Text = string.Empty;
  401. NeedHoleMCheckBox.Checked = false;
  402. NeedMoveMCheckBox.Checked = false;
  403. DestMapComboBox.SelectedItem = null;
  404. ConquestComboBox.SelectedIndex = 0;
  405. DestXTextBox.Text = string.Empty;
  406. DestYTextBox.Text = string.Empty;
  407. BigMapIconTextBox.Text = string.Empty;
  408. return;
  409. }
  410. MovementInfo info = _selectedMovementInfos[0];
  411. MovementInfoPanel.Enabled = true;
  412. SourceXTextBox.Text = info.Source.X.ToString();
  413. SourceYTextBox.Text = info.Source.Y.ToString();
  414. NeedHoleMCheckBox.Checked = info.NeedHole;
  415. NeedMoveMCheckBox.Checked = info.NeedMove;
  416. ShowBigMapCheckBox.Checked = info.ShowOnBigMap;
  417. DestMapComboBox.SelectedItem = Envir.MapInfoList.FirstOrDefault(x => x.Index == info.MapIndex);
  418. DestXTextBox.Text = info.Destination.X.ToString();
  419. DestYTextBox.Text = info.Destination.Y.ToString();
  420. BigMapIconTextBox.Text = info.Icon.ToString();
  421. ConquestComboBox.SelectedItem = Envir.ConquestInfoList.FirstOrDefault(x => x.Index == info.ConquestIndex)?.Name;
  422. if (ConquestComboBox.SelectedItem == null) ConquestComboBox.SelectedIndex = 0;
  423. for (int i = 1; i < _selectedMovementInfos.Count; i++)
  424. {
  425. info = _selectedMovementInfos[i];
  426. SourceXTextBox.Text = info.Source.X.ToString();
  427. SourceYTextBox.Text = info.Source.Y.ToString();
  428. DestMapComboBox.SelectedItem = Envir.MapInfoList.FirstOrDefault(x => x.Index == info.MapIndex);
  429. DestXTextBox.Text = info.Destination.X.ToString();
  430. DestYTextBox.Text = info.Destination.Y.ToString();
  431. ConquestComboBox.SelectedItem = Envir.ConquestInfoList.FirstOrDefault(x => x.Index == info.ConquestIndex)?.Name;
  432. BigMapIconTextBox.Text = info.Icon.ToString();
  433. if (SourceXTextBox.Text != info.Source.X.ToString()) SourceXTextBox.Text = string.Empty;
  434. if (SourceYTextBox.Text != info.Source.Y.ToString()) SourceYTextBox.Text = string.Empty;
  435. if (DestMapComboBox.SelectedItem != Envir.MapInfoList.FirstOrDefault(x => x.Index == info.MapIndex)) DestMapComboBox.SelectedItem = null;
  436. if (DestXTextBox.Text != info.Destination.X.ToString()) DestXTextBox.Text = string.Empty;
  437. if (DestYTextBox.Text != info.Destination.Y.ToString()) DestYTextBox.Text = string.Empty;
  438. if (BigMapIconTextBox.Text != info.Icon.ToString()) BigMapIconTextBox.Text = string.Empty;
  439. if (ConquestComboBox.SelectedItem != Envir.ConquestInfoList.FirstOrDefault(x => x.Index == info.ConquestIndex)) ConquestComboBox.SelectedItem = null;
  440. }
  441. }
  442. private void UpdateMineZoneInterface()
  443. {
  444. if (_selectedMapInfos.Count != 1)
  445. {
  446. MZListlistBox.Items.Clear();
  447. if (_selectedMineZones != null && _selectedMineZones.Count > 0)
  448. _selectedMineZones.Clear();
  449. _info = null;
  450. MineZonepanel.Enabled = false;
  451. MZXtextBox.Text = string.Empty;
  452. MZYtextBox.Text = string.Empty;
  453. MineZoneComboBox.SelectedItem = null;
  454. MZSizetextBox.Text = string.Empty;
  455. return;
  456. }
  457. if (_info != _selectedMapInfos[0])
  458. {
  459. MZListlistBox.Items.Clear();
  460. _info = _selectedMapInfos[0];
  461. }
  462. if (MZListlistBox.Items.Count != _info.MineZones.Count)
  463. {
  464. MZListlistBox.Items.Clear();
  465. for (int i = 0; i < _info.MineZones.Count; i++) MZListlistBox.Items.Add(_info.MineZones[i]);
  466. }
  467. _selectedMineZones = MZListlistBox.SelectedItems.Cast<MineZone>().ToList();
  468. if (_selectedMineZones.Count == 0)
  469. {
  470. MineZonepanel.Enabled = false;
  471. MZXtextBox.Text = string.Empty;
  472. MZYtextBox.Text = string.Empty;
  473. MineZoneComboBox.SelectedItem = null;
  474. MZSizetextBox.Text = string.Empty;
  475. return;
  476. }
  477. MineZone info = _selectedMineZones[0];
  478. MineZonepanel.Enabled = true;
  479. MZXtextBox.Text = info.Location.X.ToString();
  480. MZYtextBox.Text = info.Location.Y.ToString();
  481. MineZoneComboBox.SelectedIndex = info.Mine;
  482. MZSizetextBox.Text = info.Size.ToString();
  483. for (int i = 1; i < _selectedMineZones.Count; i++)
  484. {
  485. info = _selectedMineZones[i];
  486. if (MZXtextBox.Text != info.Location.X.ToString()) MZXtextBox.Text = string.Empty;
  487. if (MZYtextBox.Text != info.Location.Y.ToString()) MZYtextBox.Text = string.Empty;
  488. if (MineComboBox.SelectedIndex != info.Mine) MineComboBox.SelectedIndex = 1;
  489. if (MZSizetextBox.Text != info.Size.ToString()) MZSizetextBox.Text = string.Empty;
  490. }
  491. }
  492. private void RefreshMapList()
  493. {
  494. MapInfoListBox.SelectedIndexChanged -= MapInfoListBox_SelectedIndexChanged;
  495. List<bool> selected = new List<bool>();
  496. for (int i = 0; i < MapInfoListBox.Items.Count; i++) selected.Add(MapInfoListBox.GetSelected(i));
  497. MapInfoListBox.Items.Clear();
  498. for (int i = 0; i < Envir.MapInfoList.Count; i++) MapInfoListBox.Items.Add(Envir.MapInfoList[i]);
  499. for (int i = 0; i < selected.Count; i++) MapInfoListBox.SetSelected(i, selected[i]);
  500. MapInfoListBox.SelectedIndexChanged += MapInfoListBox_SelectedIndexChanged;
  501. }
  502. private void RefreshSafeZoneList()
  503. {
  504. SafeZoneInfoListBox.SelectedIndexChanged -= SafeZoneInfoListBox_SelectedIndexChanged;
  505. List<bool> selected = new List<bool>();
  506. for (int i = 0; i < SafeZoneInfoListBox.Items.Count; i++) selected.Add(SafeZoneInfoListBox.GetSelected(i));
  507. SafeZoneInfoListBox.Items.Clear();
  508. for (int i = 0; i < _info.SafeZones.Count; i++) SafeZoneInfoListBox.Items.Add(_info.SafeZones[i]);
  509. for (int i = 0; i < selected.Count; i++) SafeZoneInfoListBox.SetSelected(i, selected[i]);
  510. SafeZoneInfoListBox.SelectedIndexChanged += SafeZoneInfoListBox_SelectedIndexChanged;
  511. }
  512. private void RefreshRespawnList()
  513. {
  514. RespawnInfoListBox.SelectedIndexChanged -= RespawnInfoListBox_SelectedIndexChanged;
  515. List<bool> selected = new List<bool>();
  516. for (int i = 0; i < RespawnInfoListBox.Items.Count; i++)
  517. selected.Add(RespawnInfoListBox.GetSelected(i));
  518. RespawnInfoListBox.Items.Clear();
  519. for (int i = 0; i < _info.Respawns.Count; i++)
  520. RespawnInfoListBox.Items.Add(_info.Respawns[i]);
  521. for (int i = 0; i < selected.Count; i++)
  522. RespawnInfoListBox.SetSelected(i, selected[i]);
  523. RespawnInfoListBox.SelectedIndexChanged += RespawnInfoListBox_SelectedIndexChanged;
  524. }
  525. private void RefreshMovementList()
  526. {
  527. MovementInfoListBox.SelectedIndexChanged -= MovementInfoListBox_SelectedIndexChanged;
  528. List<bool> selected = new List<bool>();
  529. for (int i = 0; i < MovementInfoListBox.Items.Count; i++) selected.Add(MovementInfoListBox.GetSelected(i));
  530. MovementInfoListBox.Items.Clear();
  531. for (int i = 0; i < _info.Movements.Count; i++) MovementInfoListBox.Items.Add(_info.Movements[i]);
  532. for (int i = 0; i < selected.Count; i++) MovementInfoListBox.SetSelected(i, selected[i]);
  533. MovementInfoListBox.SelectedIndexChanged += MovementInfoListBox_SelectedIndexChanged;
  534. }
  535. private void RefreshMineZoneList()
  536. {
  537. MZListlistBox.SelectedIndexChanged -= MZListlistBox_SelectedIndexChanged;
  538. List<bool> selected = new List<bool>();
  539. for (int i = 0; i < MZListlistBox.Items.Count; i++) selected.Add(MZListlistBox.GetSelected(i));
  540. MZListlistBox.Items.Clear();
  541. for (int i = 0; i < _info.MineZones.Count; i++) MZListlistBox.Items.Add(_info.MineZones[i]);
  542. for (int i = 0; i < selected.Count; i++) MZListlistBox.SetSelected(i, selected[i]);
  543. MZListlistBox.SelectedIndexChanged += MZListlistBox_SelectedIndexChanged;
  544. }
  545. private void AddButton_Click(object sender, EventArgs e)
  546. {
  547. Envir.CreateMapInfo();
  548. UpdateInterface(true);
  549. }
  550. private void RemoveButton_Click(object sender, EventArgs e)
  551. {
  552. if (_selectedMapInfos.Count == 0) return;
  553. if (MessageBox.Show("Are you sure you want to remove the selected maps?", "Remove Maps?", MessageBoxButtons.YesNo) != DialogResult.Yes) return;
  554. for (int i = 0; i < _selectedMapInfos.Count; i++) Envir.Remove(_selectedMapInfos[i]);
  555. if (Envir.MapInfoList.Count == 0) Envir.MapIndex = 0;
  556. MapTabs.SelectTab(0);
  557. UpdateInterface(true);
  558. }
  559. private void MapInfoListBox_SelectedIndexChanged(object sender, EventArgs e)
  560. {
  561. SafeZoneInfoListBox.Items.Clear();
  562. RespawnInfoListBox.Items.Clear();
  563. MovementInfoListBox.Items.Clear();
  564. MZListlistBox.Items.Clear();
  565. lstParticles.SelectedItems.Clear();
  566. _selectedMapInfos = MapInfoListBox.SelectedItems.Cast<MapInfo>().ToList();
  567. if (_selectedMapInfos == null || _selectedMapInfos.Count == 0)
  568. {
  569. UpdateInterface(false);
  570. return;
  571. }
  572. UpdateInterface(false);
  573. }
  574. private void FileNameTextBox_TextChanged(object sender, EventArgs e)
  575. {
  576. if (ActiveControl != sender) return;
  577. for (int i = 0; i < _selectedMapInfos.Count; i++)
  578. _selectedMapInfos[i].FileName = ActiveControl.Text;
  579. }
  580. private void MapNameTextBox_TextChanged(object sender, EventArgs e)
  581. {
  582. if (ActiveControl != sender) return;
  583. for (int i = 0; i < _selectedMapInfos.Count; i++)
  584. _selectedMapInfos[i].Title = ActiveControl.Text;
  585. RefreshMapList();
  586. }
  587. private void MiniMapTextBox_TextChanged(object sender, EventArgs e)
  588. {
  589. if (!ushort.TryParse(MiniMapTextBox.Text, out ushort temp))
  590. {
  591. MiniMapTextBox.BackColor = Color.Red;
  592. return;
  593. }
  594. ActiveControl.BackColor = SystemColors.Window;
  595. MiniMapTextBox.BackColor = SystemColors.Window;
  596. for (int i = 0; i < _selectedMapInfos.Count; i++)
  597. _selectedMapInfos[i].MiniMap = temp;
  598. LoadImage(temp);
  599. }
  600. private void LoadImage(ushort miniMapValue)
  601. {
  602. string imagePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Envir", "Previews", "Minimaps", miniMapValue + ".bmp");
  603. if (File.Exists(imagePath))
  604. {
  605. MinimapPreview.Image = Image.FromFile(imagePath);
  606. MinimapPreview.SizeMode = PictureBoxSizeMode.StretchImage;
  607. }
  608. else
  609. {
  610. MinimapPreview.Image = null;
  611. }
  612. }
  613. private void LightsComboBox_SelectedIndexChanged(object sender, EventArgs e)
  614. {
  615. if (ActiveControl != sender) return;
  616. for (int i = 0; i < _selectedMapInfos.Count; i++)
  617. _selectedMapInfos[i].Light = (LightSetting)LightsComboBox.SelectedItem;
  618. }
  619. private void AddSZButton_Click(object sender, EventArgs e)
  620. {
  621. if (_info == null) return;
  622. _info.CreateSafeZone();
  623. UpdateSafeZoneInterface();
  624. }
  625. private void RemoveSZButton_Click(object sender, EventArgs e)
  626. {
  627. if (_selectedSafeZoneInfos.Count == 0) return;
  628. if (MessageBox.Show("Are you sure you want to remove the selected SafeZones?", "Remove SafeZones?", MessageBoxButtons.YesNo) != DialogResult.Yes) return;
  629. for (int i = 0; i < _selectedSafeZoneInfos.Count; i++) _info.SafeZones.Remove(_selectedSafeZoneInfos[i]);
  630. UpdateSafeZoneInterface();
  631. }
  632. private void SafeZoneInfoListBox_SelectedIndexChanged(object sender, EventArgs e)
  633. {
  634. UpdateSafeZoneInterface();
  635. }
  636. private void SZXTextBox_TextChanged(object sender, EventArgs e)
  637. {
  638. if (ActiveControl != sender) return;
  639. int temp;
  640. if (!int.TryParse(ActiveControl.Text, out temp))
  641. {
  642. ActiveControl.BackColor = Color.Red;
  643. return;
  644. }
  645. ActiveControl.BackColor = SystemColors.Window;
  646. for (int i = 0; i < _selectedSafeZoneInfos.Count; i++)
  647. _selectedSafeZoneInfos[i].Location.X = temp;
  648. RefreshSafeZoneList();
  649. }
  650. private void SZYTextBox_TextChanged(object sender, EventArgs e)
  651. {
  652. if (ActiveControl != sender) return;
  653. int temp;
  654. if (!int.TryParse(ActiveControl.Text, out temp))
  655. {
  656. ActiveControl.BackColor = Color.Red;
  657. return;
  658. }
  659. ActiveControl.BackColor = SystemColors.Window;
  660. for (int i = 0; i < _selectedSafeZoneInfos.Count; i++)
  661. _selectedSafeZoneInfos[i].Location.Y = temp;
  662. RefreshSafeZoneList();
  663. }
  664. private void SizeTextBox_TextChanged(object sender, EventArgs e)
  665. {
  666. if (ActiveControl != sender) return;
  667. ushort temp;
  668. if (!ushort.TryParse(ActiveControl.Text, out temp))
  669. {
  670. ActiveControl.BackColor = Color.Red;
  671. return;
  672. }
  673. ActiveControl.BackColor = SystemColors.Window;
  674. for (int i = 0; i < _selectedSafeZoneInfos.Count; i++)
  675. _selectedSafeZoneInfos[i].Size = temp;
  676. }
  677. private void StartPointCheckBox_CheckedChanged(object sender, EventArgs e)
  678. {
  679. if (ActiveControl != sender) return;
  680. for (int i = 0; i < _selectedSafeZoneInfos.Count; i++)
  681. _selectedSafeZoneInfos[i].StartPoint = StartPointCheckBox.Checked;
  682. RefreshSafeZoneList();
  683. }
  684. private void AddRButton_Click(object sender, EventArgs e)
  685. {
  686. if (_info == null) return;
  687. _info.CreateRespawnInfo();
  688. UpdateRespawnInterface();
  689. }
  690. private void RemoveRButton_Click(object sender, EventArgs e)
  691. {
  692. if (_selectedRespawnInfos.Count == 0) return;
  693. if (MessageBox.Show("Are you sure you want to remove the selected Respawns?", "Remove Respawns?", MessageBoxButtons.YesNo) != DialogResult.Yes) return;
  694. for (int i = 0; i < _selectedRespawnInfos.Count; i++) _info.Respawns.Remove(_selectedRespawnInfos[i]);
  695. UpdateRespawnInterface();
  696. }
  697. private void RespawnInfoListBox_SelectedIndexChanged(object sender, EventArgs e)
  698. {
  699. UpdateRespawnInterface();
  700. }
  701. private void MonsterInfoComboBox_SelectedIndexChanged(object sender, EventArgs e)
  702. {
  703. if (ActiveControl != sender) return;
  704. MonsterInfo info = MonsterInfoComboBox.SelectedItem as MonsterInfo;
  705. if (info == null) return;
  706. for (int i = 0; i < _selectedRespawnInfos.Count; i++)
  707. _selectedRespawnInfos[i].MonsterIndex = info.Index;
  708. RefreshRespawnList();
  709. }
  710. private void RXTextBox_TextChanged(object sender, EventArgs e)
  711. {
  712. if (ActiveControl != sender) return;
  713. int temp;
  714. if (!int.TryParse(ActiveControl.Text, out temp))
  715. {
  716. ActiveControl.BackColor = Color.Red;
  717. return;
  718. }
  719. ActiveControl.BackColor = SystemColors.Window;
  720. for (int i = 0; i < _selectedRespawnInfos.Count; i++)
  721. _selectedRespawnInfos[i].Location.X = temp;
  722. RefreshRespawnList();
  723. }
  724. private void RYTextBox_TextChanged(object sender, EventArgs e)
  725. {
  726. if (ActiveControl != sender) return;
  727. int temp;
  728. if (!int.TryParse(ActiveControl.Text, out temp))
  729. {
  730. ActiveControl.BackColor = Color.Red;
  731. return;
  732. }
  733. ActiveControl.BackColor = SystemColors.Window;
  734. for (int i = 0; i < _selectedRespawnInfos.Count; i++)
  735. _selectedRespawnInfos[i].Location.Y = temp;
  736. RefreshRespawnList();
  737. }
  738. private void CountTextBox_TextChanged(object sender, EventArgs e)
  739. {
  740. if (ActiveControl != sender) return;
  741. ushort temp;
  742. if (!ushort.TryParse(ActiveControl.Text, out temp))
  743. {
  744. ActiveControl.BackColor = Color.Red;
  745. return;
  746. }
  747. ActiveControl.BackColor = SystemColors.Window;
  748. for (int i = 0; i < _selectedRespawnInfos.Count; i++)
  749. _selectedRespawnInfos[i].Count = temp;
  750. RefreshRespawnList();
  751. }
  752. private void SpreadTextBox_TextChanged(object sender, EventArgs e)
  753. {
  754. if (ActiveControl != sender) return;
  755. ushort temp;
  756. if (!ushort.TryParse(ActiveControl.Text, out temp))
  757. {
  758. ActiveControl.BackColor = Color.Red;
  759. return;
  760. }
  761. ActiveControl.BackColor = SystemColors.Window;
  762. for (int i = 0; i < _selectedRespawnInfos.Count; i++)
  763. _selectedRespawnInfos[i].Spread = temp;
  764. RefreshRespawnList();
  765. }
  766. private void DelayTextBox_TextChanged(object sender, EventArgs e)
  767. {
  768. if (ActiveControl != sender) return;
  769. ushort temp;
  770. if (!ushort.TryParse(ActiveControl.Text, out temp))
  771. {
  772. ActiveControl.BackColor = Color.Red;
  773. return;
  774. }
  775. ActiveControl.BackColor = SystemColors.Window;
  776. for (int i = 0; i < _selectedRespawnInfos.Count; i++)
  777. {
  778. if (chkRespawnEnableTick.Checked)
  779. {
  780. _selectedRespawnInfos[i].RespawnTicks = Math.Max((ushort)1, temp);
  781. _selectedRespawnInfos[i].Delay = 0;
  782. }
  783. else
  784. {
  785. _selectedRespawnInfos[i].Delay = temp;
  786. _selectedRespawnInfos[i].RespawnTicks = 0;
  787. }
  788. }
  789. RefreshRespawnList();
  790. }
  791. private void DirectionTextBox_TextChanged(object sender, EventArgs e)
  792. {
  793. if (ActiveControl != sender) return;
  794. byte temp;
  795. if (!byte.TryParse(ActiveControl.Text, out temp))
  796. {
  797. ActiveControl.BackColor = Color.Red;
  798. return;
  799. }
  800. ActiveControl.BackColor = SystemColors.Window;
  801. for (int i = 0; i < _selectedRespawnInfos.Count; i++)
  802. _selectedRespawnInfos[i].Direction = temp;
  803. RefreshRespawnList();
  804. }
  805. private void RoutePathTextBox_TextChanged(object sender, EventArgs e)
  806. {
  807. if (ActiveControl != sender) return;
  808. for (int i = 0; i < _selectedRespawnInfos.Count; i++)
  809. _selectedRespawnInfos[i].RoutePath = ActiveControl.Text;
  810. RefreshRespawnList();
  811. }
  812. private void RPasteButton_Click(object sender, EventArgs e)
  813. {
  814. if (_info == null) return;
  815. string data = Clipboard.GetText();
  816. if (!data.StartsWith("Respawn", StringComparison.OrdinalIgnoreCase))
  817. {
  818. MessageBox.Show("Cannot Paste, Copied data is not Respawn Information.");
  819. return;
  820. }
  821. string[] respawns = data.Split(new[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);
  822. for (int i = 1; i < respawns.Length; i++)
  823. {
  824. RespawnInfo info = RespawnInfo.FromText(respawns[i]);
  825. if (info == null) continue;
  826. _info.Respawns.Add(info);
  827. }
  828. UpdateRespawnInterface();
  829. }
  830. //RCopy
  831. private void AddMButton_Click(object sender, EventArgs e)
  832. {
  833. if (_info == null) return;
  834. _info.CreateMovementInfo();
  835. UpdateMovementInterface();
  836. }
  837. private void RemoveMButton_Click(object sender, EventArgs e)
  838. {
  839. if (_selectedMovementInfos.Count == 0) return;
  840. if (MessageBox.Show("Are you sure you want to remove the selected Movements?", "Remove Movements?", MessageBoxButtons.YesNo) != DialogResult.Yes) return;
  841. for (int i = 0; i < _selectedMovementInfos.Count; i++) _info.Movements.Remove(_selectedMovementInfos[i]);
  842. UpdateMovementInterface();
  843. }
  844. private void SourceXTextBox_TextChanged(object sender, EventArgs e)
  845. {
  846. if (ActiveControl != sender) return;
  847. int temp;
  848. if (!int.TryParse(ActiveControl.Text, out temp))
  849. {
  850. ActiveControl.BackColor = Color.Red;
  851. return;
  852. }
  853. ActiveControl.BackColor = SystemColors.Window;
  854. for (int i = 0; i < _selectedMovementInfos.Count; i++)
  855. _selectedMovementInfos[i].Source.X = temp;
  856. RefreshMovementList();
  857. }
  858. private void SourceYTextBox_TextChanged(object sender, EventArgs e)
  859. {
  860. if (ActiveControl != sender) return;
  861. int temp;
  862. if (!int.TryParse(ActiveControl.Text, out temp))
  863. {
  864. ActiveControl.BackColor = Color.Red;
  865. return;
  866. }
  867. ActiveControl.BackColor = SystemColors.Window;
  868. for (int i = 0; i < _selectedMovementInfos.Count; i++)
  869. _selectedMovementInfos[i].Source.Y = temp;
  870. RefreshMovementList();
  871. }
  872. private void DestXTextBox_TextChanged(object sender, EventArgs e)
  873. {
  874. if (ActiveControl != sender) return;
  875. int temp;
  876. if (!int.TryParse(ActiveControl.Text, out temp))
  877. {
  878. ActiveControl.BackColor = Color.Red;
  879. return;
  880. }
  881. ActiveControl.BackColor = SystemColors.Window;
  882. for (int i = 0; i < _selectedMovementInfos.Count; i++)
  883. _selectedMovementInfos[i].Destination.X = temp;
  884. RefreshMovementList();
  885. }
  886. private void DestYTextBox_TextChanged(object sender, EventArgs e)
  887. {
  888. if (ActiveControl != sender) return;
  889. int temp;
  890. if (!int.TryParse(ActiveControl.Text, out temp))
  891. {
  892. ActiveControl.BackColor = Color.Red;
  893. return;
  894. }
  895. ActiveControl.BackColor = SystemColors.Window;
  896. for (int i = 0; i < _selectedMovementInfos.Count; i++)
  897. _selectedMovementInfos[i].Destination.Y = temp;
  898. RefreshMovementList();
  899. }
  900. private void DestMapComboBox_SelectedIndexChanged(object sender, EventArgs e)
  901. {
  902. if (ActiveControl != sender) return;
  903. MapInfo info = DestMapComboBox.SelectedItem as MapInfo;
  904. if (info == null) return;
  905. for (int i = 0; i < _selectedMovementInfos.Count; i++)
  906. _selectedMovementInfos[i].MapIndex = info.Index;
  907. RefreshMovementList();
  908. }
  909. private void NeedHoleMCheckBox_CheckedChanged(object sender, EventArgs e)
  910. {
  911. if (ActiveControl != sender) return;
  912. for (int i = 0; i < _selectedMovementInfos.Count; i++)
  913. _selectedMovementInfos[i].NeedHole = NeedHoleMCheckBox.Checked;
  914. }
  915. private void NeedScriptMCheckBox_CheckedChanged(object sender, EventArgs e)
  916. {
  917. if (ActiveControl != sender) return;
  918. for (int i = 0; i < _selectedMovementInfos.Count; i++)
  919. _selectedMovementInfos[i].NeedMove = NeedMoveMCheckBox.Checked;
  920. }
  921. private void MovementInfoListBox_SelectedIndexChanged(object sender, EventArgs e)
  922. {
  923. UpdateMovementInterface();
  924. }
  925. private void PasteMapButton_Click(object sender, EventArgs e)
  926. {
  927. string data = Clipboard.GetText();
  928. if (!data.StartsWith("Map", StringComparison.OrdinalIgnoreCase))
  929. {
  930. MessageBox.Show("Cannot Paste, Copied data is not Map Information.");
  931. return;
  932. }
  933. string[] maps = data.Split(new[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);
  934. for (int i = 1; i < maps.Length; i++)
  935. MapInfo.FromText(maps[i]);
  936. UpdateInterface();
  937. }
  938. private void BigMapTextBox_TextChanged(object sender, EventArgs e)
  939. {
  940. if (ActiveControl != sender) return;
  941. ushort temp;
  942. if (!ushort.TryParse(ActiveControl.Text, out temp))
  943. {
  944. ActiveControl.BackColor = Color.Red;
  945. return;
  946. }
  947. ActiveControl.BackColor = SystemColors.Window;
  948. for (int i = 0; i < _selectedMapInfos.Count; i++)
  949. _selectedMapInfos[i].BigMap = temp;
  950. }
  951. private void NoTeleportCheckbox_CheckedChanged(object sender, EventArgs e)
  952. {
  953. if (ActiveControl != sender) return;
  954. for (int i = 0; i < _selectedMapInfos.Count; i++)
  955. _selectedMapInfos[i].NoTeleport = NoTeleportCheckbox.Checked;
  956. }
  957. private void NoReconnectCheckbox_CheckedChanged(object sender, EventArgs e)
  958. {
  959. if (ActiveControl != sender) return;
  960. for (int i = 0; i < _selectedMapInfos.Count; i++)
  961. _selectedMapInfos[i].NoReconnect = NoReconnectCheckbox.Checked;
  962. }
  963. private void NoReconnectTextbox_TextChanged(object sender, EventArgs e)
  964. {
  965. if (ActiveControl != sender) return;
  966. for (int i = 0; i < _selectedMapInfos.Count; i++)
  967. _selectedMapInfos[i].NoReconnectMap = ActiveControl.Text;
  968. }
  969. private void NoRandomCheckbox_CheckedChanged(object sender, EventArgs e)
  970. {
  971. if (ActiveControl != sender) return;
  972. for (int i = 0; i < _selectedMapInfos.Count; i++)
  973. _selectedMapInfos[i].NoRandom = NoRandomCheckbox.Checked;
  974. }
  975. private void NoEscapeCheckbox_CheckedChanged(object sender, EventArgs e)
  976. {
  977. if (ActiveControl != sender) return;
  978. for (int i = 0; i < _selectedMapInfos.Count; i++)
  979. _selectedMapInfos[i].NoEscape = NoEscapeCheckbox.Checked;
  980. }
  981. private void NoRecallCheckbox_CheckedChanged(object sender, EventArgs e)
  982. {
  983. if (ActiveControl != sender) return;
  984. for (int i = 0; i < _selectedMapInfos.Count; i++)
  985. _selectedMapInfos[i].NoRecall = NoRecallCheckbox.Checked;
  986. }
  987. private void NoDrugCheckbox_CheckedChanged(object sender, EventArgs e)
  988. {
  989. if (ActiveControl != sender) return;
  990. for (int i = 0; i < _selectedMapInfos.Count; i++)
  991. _selectedMapInfos[i].NoDrug = NoDrugCheckbox.Checked;
  992. }
  993. private void NoPositionCheckbox_CheckedChanged(object sender, EventArgs e)
  994. {
  995. if (ActiveControl != sender) return;
  996. for (int i = 0; i < _selectedMapInfos.Count; i++)
  997. _selectedMapInfos[i].NoPosition = NoPositionCheckbox.Checked;
  998. }
  999. private void NoThrowItemCheckbox_CheckedChanged(object sender, EventArgs e)
  1000. {
  1001. if (ActiveControl != sender) return;
  1002. for (int i = 0; i < _selectedMapInfos.Count; i++)
  1003. _selectedMapInfos[i].NoThrowItem = NoThrowItemCheckbox.Checked;
  1004. }
  1005. private void NoDropPlayerCheckbox_CheckedChanged(object sender, EventArgs e)
  1006. {
  1007. if (ActiveControl != sender) return;
  1008. for (int i = 0; i < _selectedMapInfos.Count; i++)
  1009. _selectedMapInfos[i].NoDropPlayer = NoDropPlayerCheckbox.Checked;
  1010. }
  1011. private void NoDropMonsterCheckbox_CheckedChanged(object sender, EventArgs e)
  1012. {
  1013. if (ActiveControl != sender) return;
  1014. for (int i = 0; i < _selectedMapInfos.Count; i++)
  1015. _selectedMapInfos[i].NoDropMonster = NoDropMonsterCheckbox.Checked;
  1016. }
  1017. private void NoNamesCheckbox_CheckedChanged(object sender, EventArgs e)
  1018. {
  1019. if (ActiveControl != sender) return;
  1020. for (int i = 0; i < _selectedMapInfos.Count; i++)
  1021. _selectedMapInfos[i].NoNames = NoNamesCheckbox.Checked;
  1022. }
  1023. private void FightCheckbox_CheckedChanged(object sender, EventArgs e)
  1024. {
  1025. if (ActiveControl != sender) return;
  1026. for (int i = 0; i < _selectedMapInfos.Count; i++)
  1027. _selectedMapInfos[i].Fight = FightCheckbox.Checked;
  1028. }
  1029. private void FireCheckbox_CheckStateChanged(object sender, EventArgs e)
  1030. {
  1031. if (ActiveControl != sender) return;
  1032. for (int i = 0; i < _selectedMapInfos.Count; i++)
  1033. _selectedMapInfos[i].Fire = FireCheckbox.Checked;
  1034. }
  1035. private void FireTextbox_TextChanged(object sender, EventArgs e)
  1036. {
  1037. if (ActiveControl != sender) return;
  1038. int temp;
  1039. if (!int.TryParse(ActiveControl.Text, out temp))
  1040. {
  1041. ActiveControl.BackColor = Color.Red;
  1042. return;
  1043. }
  1044. ActiveControl.BackColor = SystemColors.Window;
  1045. for (int i = 0; i < _selectedMapInfos.Count; i++)
  1046. _selectedMapInfos[i].FireDamage = temp;
  1047. }
  1048. private void LightningCheckbox_CheckedChanged(object sender, EventArgs e)
  1049. {
  1050. if (ActiveControl != sender) return;
  1051. for (int i = 0; i < _selectedMapInfos.Count; i++)
  1052. _selectedMapInfos[i].Lightning = LightningCheckbox.Checked;
  1053. }
  1054. private void LightningTextbox_TextChanged(object sender, EventArgs e)
  1055. {
  1056. if (ActiveControl != sender) return;
  1057. int temp;
  1058. if (!int.TryParse(ActiveControl.Text, out temp))
  1059. {
  1060. ActiveControl.BackColor = Color.Red;
  1061. return;
  1062. }
  1063. ActiveControl.BackColor = SystemColors.Window;
  1064. for (int i = 0; i < _selectedMapInfos.Count; i++)
  1065. _selectedMapInfos[i].LightningDamage = temp;
  1066. }
  1067. private void ClearHButton_Click(object sender, EventArgs e)
  1068. {
  1069. }
  1070. private void MapDarkLighttextBox_TextChanged(object sender, EventArgs e)
  1071. {
  1072. if (ActiveControl != sender) return;
  1073. byte temp;
  1074. if (!byte.TryParse(ActiveControl.Text, out temp))
  1075. {
  1076. ActiveControl.BackColor = Color.Red;
  1077. return;
  1078. }
  1079. ActiveControl.BackColor = SystemColors.Window;
  1080. for (int i = 0; i < _selectedMapInfos.Count; i++)
  1081. _selectedMapInfos[i].MapDarkLight = temp;
  1082. }
  1083. private void MZDeletebutton_Click(object sender, EventArgs e)
  1084. {
  1085. if (_selectedMineZones.Count == 0) return;
  1086. if (MessageBox.Show("Are you sure you want to remove the selected MineZones?", "Remove MineZones?", MessageBoxButtons.YesNo) != DialogResult.Yes) return;
  1087. for (int i = 0; i < _selectedMineZones.Count; i++) _info.MineZones.Remove(_selectedMineZones[i]);
  1088. UpdateMineZoneInterface();
  1089. }
  1090. private void MZAddbutton_Click(object sender, EventArgs e)
  1091. {
  1092. if (_info == null) return;
  1093. _info.MineZones.Add(new MineZone());
  1094. UpdateMineZoneInterface();
  1095. }
  1096. private void MZListlistBox_SelectedIndexChanged(object sender, EventArgs e)
  1097. {
  1098. UpdateMineZoneInterface();
  1099. }
  1100. private void MZMineIndextextBox_TextChanged(object sender, EventArgs e)
  1101. {
  1102. if (ActiveControl != sender) return;
  1103. byte temp;
  1104. if ((!byte.TryParse(ActiveControl.Text, out temp)) || (Settings.MineSetList.Count < temp))
  1105. {
  1106. ActiveControl.BackColor = Color.Red;
  1107. return;
  1108. }
  1109. ActiveControl.BackColor = SystemColors.Window;
  1110. for (int i = 0; i < _selectedMineZones.Count; i++)
  1111. _selectedMineZones[i].Mine = temp;
  1112. RefreshMineZoneList();
  1113. }
  1114. private void MZXtextBox_TextChanged(object sender, EventArgs e)
  1115. {
  1116. if (ActiveControl != sender) return;
  1117. int temp;
  1118. if (!int.TryParse(ActiveControl.Text, out temp))
  1119. {
  1120. ActiveControl.BackColor = Color.Red;
  1121. return;
  1122. }
  1123. ActiveControl.BackColor = SystemColors.Window;
  1124. for (int i = 0; i < _selectedMineZones.Count; i++)
  1125. _selectedMineZones[i].Location.X = temp;
  1126. RefreshMineZoneList();
  1127. }
  1128. private void MZYtextBox_TextChanged(object sender, EventArgs e)
  1129. {
  1130. if (ActiveControl != sender) return;
  1131. int temp;
  1132. if (!int.TryParse(ActiveControl.Text, out temp))
  1133. {
  1134. ActiveControl.BackColor = Color.Red;
  1135. return;
  1136. }
  1137. ActiveControl.BackColor = SystemColors.Window;
  1138. for (int i = 0; i < _selectedMineZones.Count; i++)
  1139. _selectedMineZones[i].Location.Y = temp;
  1140. RefreshMineZoneList();
  1141. }
  1142. private void MZSizetextBox_TextChanged(object sender, EventArgs e)
  1143. {
  1144. if (ActiveControl != sender) return;
  1145. ushort temp;
  1146. if (!ushort.TryParse(ActiveControl.Text, out temp))
  1147. {
  1148. ActiveControl.BackColor = Color.Red;
  1149. return;
  1150. }
  1151. ActiveControl.BackColor = SystemColors.Window;
  1152. for (int i = 0; i < _selectedMineZones.Count; i++)
  1153. _selectedMineZones[i].Size = temp;
  1154. RefreshMineZoneList();
  1155. }
  1156. private void ImportMapInfoButton_Click(object sender, EventArgs e)
  1157. {
  1158. OpenFileDialog ofd = new OpenFileDialog();
  1159. ofd.Filter = "Text File|*.txt";
  1160. ofd.ShowDialog();
  1161. if (ofd.FileName == string.Empty) return;
  1162. MirForms.ConvertMapInfo.Path = ofd.FileName;
  1163. MirForms.ConvertMapInfo.Start(Envir);
  1164. MirForms.ConvertMapInfo.End();
  1165. UpdateInterface(true);
  1166. }
  1167. private void ExportMapInfoButton_Click(object sender, EventArgs e)
  1168. {
  1169. if (_selectedMapInfos.Count == 0) return;
  1170. SaveFileDialog sfd = new SaveFileDialog();
  1171. sfd.InitialDirectory = Path.Combine(Application.StartupPath, "Exports");
  1172. sfd.FileName = "MapInfoExport";
  1173. sfd.Filter = "Text File|*.txt";
  1174. sfd.ShowDialog();
  1175. if (sfd.FileName == string.Empty) return;
  1176. using (StreamWriter sw = File.CreateText(sfd.FileNames[0]))
  1177. {
  1178. for (int i = 0; i < _selectedMapInfos.Count; i++)
  1179. {
  1180. string textOut = string.Empty;
  1181. textOut += $"[{_selectedMapInfos[i].FileName} {_selectedMapInfos[i].Title.Replace(' ', '*')}]";
  1182. textOut += " LIGHT(" + _selectedMapInfos[i].Light + ")";
  1183. textOut += " MINIMAP(" + _selectedMapInfos[i].MiniMap + ")";
  1184. textOut += " BIGMAP(" + _selectedMapInfos[i].BigMap + ")";
  1185. textOut += " MAPLIGHT(" + _selectedMapInfos[i].MapDarkLight + ")";
  1186. textOut += " MINE(" + _selectedMapInfos[i].MineIndex + ")";
  1187. textOut += " MUSIC(" + _selectedMapInfos[i].Music + ")";
  1188. textOut += PrintMapAttributes(_selectedMapInfos[i]);
  1189. sw.WriteLine(textOut);
  1190. for (int j = 0; j < _selectedMapInfos[i].SafeZones.Count; j++)
  1191. {
  1192. string safeZoneOut = _selectedMapInfos[i].SafeZones[j].StartPoint ? "STARTZONE" : "SAFEZONE";
  1193. safeZoneOut += "(" + _selectedMapInfos[i].FileName + "," +
  1194. _selectedMapInfos[i].SafeZones[j].Size.ToString() + "," +
  1195. _selectedMapInfos[i].SafeZones[j].Location.X.ToString() + "," +
  1196. _selectedMapInfos[i].SafeZones[j].Location.Y.ToString() + ")";
  1197. sw.WriteLine(safeZoneOut);
  1198. }
  1199. for (int j = 0; j < _selectedMapInfos[i].Movements.Count; j++)
  1200. {
  1201. try
  1202. {
  1203. string movement =
  1204. $"{_selectedMapInfos[i].FileName} {_selectedMapInfos[i].Movements[j].Source.X + "," + _selectedMapInfos[i].Movements[j].Source.Y} {"->"} {Envir.MapInfoList.First(it=>it.Index== _selectedMapInfos[i].Movements[j].MapIndex).FileName} {_selectedMapInfos[i].Movements[j].Destination.X + "," + _selectedMapInfos[i].Movements[j].Destination.Y} {(_selectedMapInfos[i].Movements[j].NeedHole ? "NEEDHOLE " : "") + (_selectedMapInfos[i].Movements[j].NeedMove ? "NEEDMOVE " : "") + (_selectedMapInfos[i].Movements[j].ConquestIndex > 0 ? "NEEDCONQUEST(" + _selectedMapInfos[i].Movements[j].ConquestIndex + ")" : "") + (_selectedMapInfos[i].Movements[j].ShowOnBigMap ? "SHOWONBIGMAP " : "") + (_selectedMapInfos[i].Movements[j].Icon > 0 ? "BIGMAPICON(" + _selectedMapInfos[i].Movements[j].Icon + ")" : "")}";
  1205. sw.WriteLine(movement);
  1206. }
  1207. catch
  1208. {
  1209. continue;
  1210. }
  1211. }
  1212. for (int j = 0; j < _selectedMapInfos[i].MineZones.Count; j++)
  1213. {
  1214. try
  1215. {
  1216. string mineZones =
  1217. $"MINEZONE {_selectedMapInfos[i].FileName} -> {_selectedMapInfos[i].MineZones[j].Mine.ToString()} {_selectedMapInfos[i].MineZones[j].Location.X.ToString()} {_selectedMapInfos[i].MineZones[j].Location.Y.ToString()} {_selectedMapInfos[i].MineZones[j].Size.ToString()}";
  1218. sw.WriteLine(mineZones);
  1219. }
  1220. catch
  1221. {
  1222. continue;
  1223. }
  1224. }
  1225. }
  1226. }
  1227. MessageBox.Show("Map Info Export Complete");
  1228. }
  1229. private String PrintMapAttributes(MapInfo map)
  1230. {
  1231. string textOut = string.Empty;
  1232. if (map.NoTeleport) textOut += " NOTELEPORT";
  1233. if (map.NoReconnect) textOut += " NORECONNECT(" + map.NoReconnectMap + ")";
  1234. if (map.NoRandom) textOut += " NORANDOMMOVE";
  1235. if (map.NoEscape) textOut += " NOESCAPE";
  1236. if (map.NoRecall) textOut += " NORECALL";
  1237. if (map.NoDrug) textOut += " NODRUG";
  1238. if (map.NoPosition) textOut += " NOPOSITIONMOVE";
  1239. if (map.NoThrowItem) textOut += " NOTHROWITEM";
  1240. if (map.NoDropPlayer) textOut += " NOPLAYERDROP";
  1241. if (map.NoDropMonster) textOut += " NOMONSTERDROP";
  1242. if (map.NoNames) textOut += " NONAMES";
  1243. if (map.NoMount) textOut += " NOMOUNT";
  1244. if (map.NeedBridle) textOut += " NEEDBRIDLE";
  1245. if (map.NoFight) textOut += " NOFIGHT";
  1246. if (map.Fight) textOut += " FIGHT";
  1247. if (map.Fire) textOut += " FIRE(" + map.FireDamage + ")";
  1248. if (map.Lightning) textOut += " LIGHTNING(" + map.LightningDamage + ")";
  1249. if (map.NoTownTeleport) textOut += " NOTownTeleport";
  1250. if (map.GT) textOut += " GT(" + map.GTIndex + ")";
  1251. if (map.NoExperience) textOut += " NOEXPERIENCE";
  1252. if (map.NoGroup) textOut += " NOGROUP";
  1253. if (map.NoPets) textOut += " NOPETS";
  1254. if (map.NoIntelligentCreatures) textOut += " NOINTELLIGENTCREATURES";
  1255. if (map.NoHero) textOut += " NOHERO";
  1256. if (map.RequiredGroupSize > 1) textOut += " REQUIREDGROUP(" + map.RequiredGroupSize + ")";
  1257. if (map.FireWallLimit && map.FireWallCount > 0) textOut += " FIREWALL(" + map.FireWallCount + ")";
  1258. return textOut;
  1259. }
  1260. private void ImportMonGenButton_Click(object sender, EventArgs e)
  1261. {
  1262. bool hasImported = false;
  1263. if (Envir.MapInfoList.Count == 0) return;
  1264. MirForms.ConvertMonGenInfo.Start();
  1265. for (int i = 0; i < MirForms.ConvertMonGenInfo.monGenList.Count; i++)
  1266. {
  1267. try
  1268. {
  1269. int monsterIndex = Envir.MonsterInfoList.Find(a => a.Name == MirForms.ConvertMonGenInfo.monGenList[i].Name).Index;
  1270. if (monsterIndex == -1) continue;
  1271. RespawnInfo respawnInfo = new RespawnInfo
  1272. {
  1273. MonsterIndex = monsterIndex,
  1274. Location = new Point(MirForms.ConvertMonGenInfo.monGenList[i].X, MirForms.ConvertMonGenInfo.monGenList[i].Y),
  1275. Count = (ushort)MirForms.ConvertMonGenInfo.monGenList[i].Count,
  1276. Spread = (ushort)MirForms.ConvertMonGenInfo.monGenList[i].Range,
  1277. Delay = (ushort)MirForms.ConvertMonGenInfo.monGenList[i].Delay,
  1278. Direction = (byte)MirForms.ConvertMonGenInfo.monGenList[i].Direction,
  1279. RoutePath = MirForms.ConvertMonGenInfo.monGenList[i].RoutePath,
  1280. RespawnIndex = ++Envir.RespawnIndex
  1281. };
  1282. int index = Envir.MapInfoList.FindIndex(a => a.FileName == MirForms.ConvertMonGenInfo.monGenList[i].Map);
  1283. if (index == -1) continue;
  1284. Envir.MapInfoList[index].Respawns.Add(respawnInfo);
  1285. hasImported = true;
  1286. }
  1287. catch (Exception)
  1288. {
  1289. continue;
  1290. }
  1291. }
  1292. MirForms.ConvertMonGenInfo.Stop();
  1293. if (!hasImported) return;
  1294. UpdateInterface(true);
  1295. MessageBox.Show("MonGen Import complete");
  1296. }
  1297. private void ExportMonGenButton_Click(object sender, EventArgs e)
  1298. {
  1299. if (_selectedMapInfos.Count == 0) return;
  1300. SaveFileDialog sfd = new SaveFileDialog();
  1301. sfd.InitialDirectory = Path.Combine(Application.StartupPath, "Exports");
  1302. sfd.Filter = "Text File|*.txt";
  1303. sfd.ShowDialog();
  1304. if (sfd.FileName == string.Empty) return;
  1305. for (int i = 0; i < _selectedMapInfos.Count; i++)
  1306. {
  1307. using (StreamWriter sw = File.AppendText(sfd.FileNames[0]))
  1308. {
  1309. for (int j = 0; j < _selectedMapInfos[i].Respawns.Count; j++)
  1310. {
  1311. MonsterInfo mob = Envir.GetMonsterInfo(_selectedMapInfos[i].Respawns[j].MonsterIndex);
  1312. if (mob == null) continue;
  1313. string Output = $"{_selectedMapInfos[i].FileName}" +
  1314. $",{_selectedMapInfos[i].Respawns[j].Location.X}" +
  1315. $",{_selectedMapInfos[i].Respawns[j].Location.Y}" +
  1316. $",{mob.Name}" +
  1317. $",{_selectedMapInfos[i].Respawns[j].Spread}" +
  1318. $",{_selectedMapInfos[i].Respawns[j].Count}" +
  1319. $",{_selectedMapInfos[i].Respawns[j].Delay}" +
  1320. $",{_selectedMapInfos[i].Respawns[j].Direction}" +
  1321. $",{_selectedMapInfos[i].Respawns[j].RoutePath}";
  1322. sw.WriteLine(Output);
  1323. }
  1324. }
  1325. }
  1326. MessageBox.Show("MonGen Export complete");
  1327. }
  1328. private void VisualizerButton_Click(object sender, EventArgs e)
  1329. {
  1330. if (_selectedMapInfos.Count != 1)
  1331. return;
  1332. MirForms.VisualMapInfo.VForm VForm = new MirForms.VisualMapInfo.VForm();
  1333. MirForms.VisualMapInfo.Class.VisualizerGlobal.MapInfo = _selectedMapInfos[0];
  1334. VForm.FormClosed += VForm_Disposed;
  1335. VForm.ShowDialog();
  1336. _selectedMapInfos[0] = MirForms.VisualMapInfo.Class.VisualizerGlobal.MapInfo;
  1337. UpdateMineZoneInterface();
  1338. UpdateRespawnInterface();
  1339. }
  1340. private void VForm_Disposed(object sender, EventArgs e)
  1341. {
  1342. RefreshRespawnList();
  1343. RefreshMineZoneList();
  1344. }
  1345. private void MineComboBox_SelectedIndexChanged(object sender, EventArgs e)
  1346. {
  1347. if (ActiveControl != sender) return;
  1348. for (int i = 0; i < _selectedMapInfos.Count; i++)
  1349. _selectedMapInfos[i].MineIndex = Convert.ToByte(MineComboBox.SelectedIndex);
  1350. }
  1351. private void MineZoneComboBox_SelectedIndexChanged(object sender, EventArgs e)
  1352. {
  1353. if (ActiveControl != sender) return;
  1354. for (int i = 0; i < _selectedMineZones.Count; i++)
  1355. _selectedMineZones[i].Mine = Convert.ToByte(MineZoneComboBox.SelectedIndex);
  1356. RefreshMineZoneList();
  1357. }
  1358. private void NoMountCheckbox_CheckedChanged(object sender, EventArgs e)
  1359. {
  1360. if (ActiveControl != sender) return;
  1361. for (int i = 0; i < _selectedMapInfos.Count; i++)
  1362. _selectedMapInfos[i].NoMount = NoMountCheckbox.Checked;
  1363. }
  1364. private void NeedBridleCheckbox_CheckedChanged(object sender, EventArgs e)
  1365. {
  1366. if (ActiveControl != sender) return;
  1367. for (int i = 0; i < _selectedMapInfos.Count; i++)
  1368. _selectedMapInfos[i].NeedBridle = NeedBridleCheckbox.Checked;
  1369. }
  1370. private void NoFightCheckbox_CheckedChanged(object sender, EventArgs e)
  1371. {
  1372. if (ActiveControl != sender) return;
  1373. for (int i = 0; i < _selectedMapInfos.Count; i++)
  1374. _selectedMapInfos[i].NoFight = NoFightCheckbox.Checked;
  1375. }
  1376. private void MusicTextBox_TextChanged(object sender, EventArgs e)
  1377. {
  1378. if (ActiveControl != sender) return; ushort temp;
  1379. if (!ushort.TryParse(ActiveControl.Text, out temp))
  1380. {
  1381. ActiveControl.BackColor = Color.Red;
  1382. return;
  1383. }
  1384. ActiveControl.BackColor = SystemColors.Window;
  1385. for (int i = 0; i < _selectedMapInfos.Count; i++)
  1386. _selectedMapInfos[i].Music = temp;
  1387. }
  1388. private void RandomTextBox_TextChanged(object sender, EventArgs e)
  1389. {
  1390. if (ActiveControl != sender) return;
  1391. ushort temp;
  1392. if (!ushort.TryParse(ActiveControl.Text, out temp))
  1393. {
  1394. ActiveControl.BackColor = Color.Red;
  1395. return;
  1396. }
  1397. ActiveControl.BackColor = SystemColors.Window;
  1398. for (int i = 0; i < _selectedRespawnInfos.Count; i++)
  1399. _selectedRespawnInfos[i].RandomDelay = temp;
  1400. RefreshRespawnList();
  1401. }
  1402. private void chkRespawnEnableTick_CheckedChanged(object sender, EventArgs e)
  1403. {
  1404. if (ActiveControl != sender) return;
  1405. if (chkRespawnEnableTick.Checked)
  1406. {
  1407. chkrespawnsave.Enabled = true;
  1408. for (int i = 0; i < _selectedRespawnInfos.Count; i++)
  1409. {
  1410. _selectedRespawnInfos[i].RespawnTicks = _selectedRespawnInfos[i].Delay;
  1411. _selectedRespawnInfos[i].Delay = 0;
  1412. }
  1413. }
  1414. else
  1415. {
  1416. chkrespawnsave.Enabled = false;
  1417. for (int i = 0; i < _selectedRespawnInfos.Count; i++)
  1418. {
  1419. _selectedRespawnInfos[i].Delay = _selectedRespawnInfos[i].RespawnTicks;
  1420. _selectedRespawnInfos[i].RespawnTicks = 0;
  1421. }
  1422. }
  1423. RefreshRespawnList();
  1424. }
  1425. private void chkrespawnsave_CheckedChanged(object sender, EventArgs e)
  1426. {
  1427. if (ActiveControl != sender) return;
  1428. if (chkRespawnEnableTick.Checked)
  1429. {
  1430. for (int i = 0; i < _selectedRespawnInfos.Count; i++)
  1431. {
  1432. _selectedRespawnInfos[i].SaveRespawnTime = chkrespawnsave.Checked;
  1433. }
  1434. }
  1435. RefreshRespawnList();
  1436. }
  1437. private void ConquestComboBox_SelectedIndexChanged(object sender, EventArgs e)
  1438. {
  1439. if (ActiveControl != sender) return;
  1440. ComboBox cmb = sender as ComboBox;
  1441. for (int i = 0; i < _selectedMovementInfos.Count; i++)
  1442. {
  1443. var conquestIndex = 0;
  1444. if (cmb.SelectedIndex >= 0)
  1445. {
  1446. ConquestInfo info = Envir.ConquestInfoList.FirstOrDefault(x => x.Name == ConquestComboBox.SelectedItem.ToString());
  1447. if (info != null)
  1448. {
  1449. conquestIndex = info.Index;
  1450. }
  1451. MovementInfo thisMovement = _info.Movements.FirstOrDefault(x => x.MapIndex == _selectedMovementInfos[i].MapIndex &&
  1452. x.Source == _selectedMovementInfos[i].Source &&
  1453. x.Destination == _selectedMovementInfos[i].Destination);
  1454. if (thisMovement != null)
  1455. {
  1456. thisMovement.ConquestIndex = conquestIndex;
  1457. }
  1458. }
  1459. }
  1460. RefreshMovementList();
  1461. }
  1462. private void NoTownTeleportCheckbox_CheckedChanged(object sender, EventArgs e)
  1463. {
  1464. if (ActiveControl != sender) return;
  1465. for (int i = 0; i < _selectedMapInfos.Count; i++)
  1466. _selectedMapInfos[i].NoTownTeleport = NoTownTeleportCheckbox.Checked;
  1467. }
  1468. private void NoReincarnation_CheckedChanged(object sender, EventArgs e)
  1469. {
  1470. if (ActiveControl != sender) return;
  1471. for (int i = 0; i < _selectedMapInfos.Count; i++)
  1472. _selectedMapInfos[i].NoReincarnation = NoReincarnation.Checked;
  1473. }
  1474. private void ShowBigMapCheckBox_CheckedChanged(object sender, EventArgs e)
  1475. {
  1476. if (ActiveControl != sender) return;
  1477. for (int i = 0; i < _selectedMovementInfos.Count; i++)
  1478. _selectedMovementInfos[i].ShowOnBigMap = ShowBigMapCheckBox.Checked;
  1479. }
  1480. private void BigMapIconTextBox_TextChanged(object sender, EventArgs e)
  1481. {
  1482. if (ActiveControl != sender) return;
  1483. int temp;
  1484. if (!int.TryParse(ActiveControl.Text, out temp))
  1485. {
  1486. ActiveControl.BackColor = Color.Red;
  1487. return;
  1488. }
  1489. ActiveControl.BackColor = SystemColors.Window;
  1490. for (int i = 0; i < _selectedMovementInfos.Count; i++)
  1491. _selectedMovementInfos[i].Icon = temp;
  1492. RefreshMovementList();
  1493. }
  1494. private void lstParticles_SelectedIndexChanged(object sender, EventArgs e)
  1495. {
  1496. if (ActiveControl != sender) return;
  1497. WeatherSetting newvalue = WeatherSetting.None;
  1498. foreach (WeatherSetting item in lstParticles.SelectedItems)
  1499. newvalue = newvalue | item;
  1500. for (int i = 0; i < _selectedMapInfos.Count; i++)
  1501. {
  1502. _selectedMapInfos[i].WeatherParticles = newvalue;
  1503. }
  1504. //UpdateInterface(true); This isn't needed
  1505. }
  1506. private void MapSearchButton_Click(object sender, EventArgs e)
  1507. {
  1508. if (MapSearchTextBox.Text == null)
  1509. return;
  1510. UpdateInterface(true);
  1511. }
  1512. #region GT
  1513. private void GTBox_CheckedChanged(object sender, EventArgs e)
  1514. {
  1515. if (ActiveControl != sender) return;
  1516. for (int i = 0; i < _selectedMapInfos.Count; i++)
  1517. _selectedMapInfos[i].GT = GTBox.Checked;
  1518. }
  1519. private void GTIndexBox_TextChanged(object sender, EventArgs e)
  1520. {
  1521. if (ActiveControl != sender) return;
  1522. if (!byte.TryParse(ActiveControl.Text, out byte temp))
  1523. {
  1524. ActiveControl.BackColor = Color.Red;
  1525. return;
  1526. }
  1527. ActiveControl.BackColor = SystemColors.Window;
  1528. for (int i = 0; i < _selectedMapInfos.Count; i++)
  1529. _selectedMapInfos[i].GTIndex = temp;
  1530. }
  1531. #endregion
  1532. private void NoExperienceCheckbox_CheckedChanged(object sender, EventArgs e)
  1533. {
  1534. if (ActiveControl != sender) return;
  1535. for (int i = 0; i < _selectedMapInfos.Count; i++)
  1536. _selectedMapInfos[i].NoExperience = NoExperienceCheckbox.Checked;
  1537. }
  1538. private void noGroupCheckbox_CheckedChanged(object sender, EventArgs e)
  1539. {
  1540. if (ActiveControl != sender) return;
  1541. for (int i = 0; i < _selectedMapInfos.Count; i++)
  1542. _selectedMapInfos[i].NoGroup = noGroupCheckbox.Checked;
  1543. }
  1544. private void NoPetsCheckbox_CheckedChanged(object sender, EventArgs e)
  1545. {
  1546. if (ActiveControl != sender) return;
  1547. for (int i = 0; i < _selectedMapInfos.Count; i++)
  1548. _selectedMapInfos[i].NoPets = NoPetsCheckbox.Checked;
  1549. }
  1550. private void NoIntelligentCreatureCheckbox_CheckedChanged(object sender, EventArgs e)
  1551. {
  1552. if (ActiveControl != sender) return;
  1553. for (int i = 0; i < _selectedMapInfos.Count; i++)
  1554. _selectedMapInfos[i].NoIntelligentCreatures = NoIntelligentCreatureCheckbox.Checked;
  1555. }
  1556. private void NoHeroesCheckbox_CheckedChanged(object sender, EventArgs e)
  1557. {
  1558. if (ActiveControl != sender) return;
  1559. for (int i = 0; i < _selectedMapInfos.Count; i++)
  1560. _selectedMapInfos[i].NoHero = NoHeroesCheckbox.Checked;
  1561. }
  1562. private void RequiredGroupTextBox_TextChanged(object sender, EventArgs e)
  1563. {
  1564. if (ActiveControl != sender) return;
  1565. string txt = RequiredGroupTextBox.Text.Trim();
  1566. int value;
  1567. if (txt.Length == 0)
  1568. {
  1569. // blank = off
  1570. value = 0;
  1571. RequiredGroupTextBox.BackColor = SystemColors.Window;
  1572. }
  1573. else if (!int.TryParse(txt, out value))
  1574. {
  1575. RequiredGroupTextBox.BackColor = Color.Red;
  1576. return;
  1577. }
  1578. else
  1579. {
  1580. RequiredGroupTextBox.BackColor = SystemColors.Window;
  1581. // 0 or 1 = off
  1582. if (value <= 1) value = 0;
  1583. // clamp upper bound
  1584. value = Math.Min(Globals.MaxGroup, value);
  1585. }
  1586. for (int i = 0; i < _selectedMapInfos.Count; i++)
  1587. _selectedMapInfos[i].RequiredGroupSize = value;
  1588. }
  1589. private void RequiredGroupCheckBox_CheckedChanged(object sender, EventArgs e)
  1590. {
  1591. if (ActiveControl != sender) return;
  1592. bool value = RequiredGroupCheckBox.Checked;
  1593. for (int i = 0; i < _selectedMapInfos.Count; i++)
  1594. _selectedMapInfos[i].RequiredGroup = value;
  1595. }
  1596. private void FireWallCheckBox_CheckedChanged(object sender, EventArgs e)
  1597. {
  1598. if (ActiveControl != sender) return;
  1599. FireWallCount.Enabled = FireWallCheckBox.Checked;
  1600. for (int i = 0; i < _selectedMapInfos.Count; i++)
  1601. {
  1602. _selectedMapInfos[i].FireWallLimit = FireWallCheckBox.Checked;
  1603. if (_selectedMapInfos[i].FireWallLimit)
  1604. {
  1605. if (!int.TryParse(FireWallCount.Text, out var parsed) || parsed <= 0)
  1606. {
  1607. _selectedMapInfos[i].FireWallCount = 1;
  1608. FireWallCount.Text = "1";
  1609. }
  1610. }
  1611. }
  1612. }
  1613. private void FireWallCount_TextChanged(object sender, EventArgs e)
  1614. {
  1615. if (ActiveControl != sender) return;
  1616. if (!FireWallCheckBox.Checked)
  1617. {
  1618. ActiveControl.BackColor = SystemColors.Window;
  1619. return;
  1620. }
  1621. if (!int.TryParse(FireWallCount.Text, out var temp) || temp <= 0)
  1622. {
  1623. ActiveControl.BackColor = Color.Red;
  1624. return;
  1625. }
  1626. ActiveControl.BackColor = SystemColors.Window;
  1627. for (int i = 0; i < _selectedMapInfos.Count; i++)
  1628. _selectedMapInfos[i].FireWallCount = temp;
  1629. }
  1630. }
  1631. }