Advertisement
PastebinnerMKII

ui_debug_main

Nov 29th, 2015
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 69.43 KB | None | 0 0
  1. -- axr_debug_tools UI script
  2. -- Alundaio
  3. --[[
  4. Copyright (C) 2012 Alundaio
  5. This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License-]]
  6. --]]
  7.  
  8. id_to_spawn_table = {
  9. [1] = "Ammo",
  10. [2] = "Artefacts",
  11. [3] = "Items (Consumable)",
  12. [4] = "Items (Misc.)",
  13. [5] = "Items (Quest)",
  14. [6] = "NPC (Mutant)",
  15. [7] = "NPC (Stalker)",
  16. [8] = "Outfits",
  17. [9] = "Physic (Misc.)",
  18. [10] = "Squads (Mutant)",
  19. [11] = "Squads (Stalker)",
  20. [12] = "Weapons (Addon)",
  21. [13] = "Weapons (Misc.)",
  22. [14] = "Weapons (Pistol)",
  23. [15] = "Weapons (Rifle)",
  24. [16] = "Vehicles",
  25. [17] = "Anomaly",
  26. [18] = "Phantom"
  27. }
  28.  
  29. function get_spawn_table(name)
  30. if (name == "Phantom") then
  31. return {
  32. "m_phantom_bloodsucker",
  33. "m_phantom_tushkano",
  34. "m_phantom_controller",
  35. "m_phantom_zombi",
  36. "m_phantom_snork",
  37. "m_phantom_boar",
  38. "m_phantom_flesh",
  39. "m_phantom_dog",
  40. "m_phantom_pseudodog",
  41. "m_phantom_cat"
  42. }
  43. elseif (name == "Anomaly") then
  44. return {
  45. "zone_mine_gravitational_weak",
  46. "zone_mine_thermal_weak",
  47. "zone_mine_acidic_weak",
  48. "zone_mine_electric_weak",
  49. "zone_field_radioactive_weak",
  50. "zone_mine_steam_weak",
  51. "zone_field_psychic_weak",
  52. --"fireball_zone",
  53. --"fireball_electric_zone",
  54. --"fireball_acidic_zone",
  55. "zone_mine_field",
  56. "zone_mine_field_soc",
  57. "zone_no_gravity",
  58. "zone_teleport"
  59. }
  60. elseif (name == "Artefacts") then
  61. return {
  62. "af_medusa", -- 1
  63. "af_cristall_flower", -- 2
  64. "af_night_star", -- 3
  65. "af_vyvert", -- 4
  66. "af_gravi", -- 5
  67. "af_gold_fish", -- 6
  68. "af_cristall", -- 7
  69. "af_fireball", -- 8
  70. "af_dummy_glassbeads", -- 9
  71. "af_eye", -- 10
  72. "af_fire", -- 11
  73. "af_blood", -- 12
  74. "af_mincer_meat", -- 13
  75. "af_soul", -- 14
  76. "af_fuzz_kolobok", -- 15
  77. "af_baloon", -- 16
  78. "af_glass", -- 17
  79. "af_electra_sparkler", -- 18
  80. "af_electra_flash", -- 19
  81. "af_electra_moonlight", -- 20
  82. "af_dummy_battery", -- 21
  83. "af_dummy_dummy", -- 22
  84. "af_ice", -- 23
  85. "af_compass", -- 24
  86. "af_oasis_heart", -- 25
  87. "jup_b1_half_artifact", -- 26
  88. "af_quest_b14_twisted", -- 27
  89. "af_drops", -- 28
  90. "af_ameba_slime", -- 29
  91. "af_ameba_slug", -- 30
  92. "af_ameba_mica", -- 31
  93. "af_dummy_spring", -- 32
  94. "af_dummy_pellicle", -- 33
  95. "af_rusty_thorn", -- 34
  96. "af_rusty_kristall", -- 35
  97. "af_rusty_sea", -- 36
  98. }
  99. elseif (name == "Outfits") then
  100. return {
  101. "helm_respirator",
  102. "helm_hardhat",
  103. "helm_protective",
  104. "helm_tactic",
  105. "helm_battle",
  106. "helm_respirator_joker",
  107. "helm_hardhat_snag",
  108. "helm_m40",
  109.  
  110. --Freedom
  111. "svoboda_novice_outfit",
  112. "svoboda_light_outfit",
  113. "svoboda_heavy_outfit",
  114. "svoboda_heavy_outfit_2",
  115. "svoboda_exo_outfit",
  116.  
  117. --Ecolog
  118. "ecolog_outfit_green",
  119. "ecolog_outfit_orange",
  120. "scientific_outfit",
  121. "ecolog_guard_outfit",
  122.  
  123. --Stalker
  124. "novice_outfit",
  125. "stalker_outfit",
  126. "stalker_outfit_barge",
  127. "exo_outfit",
  128.  
  129. --Bandit
  130. "bandit_novice_outfit",
  131. "banditmerc_outfit",
  132. "trenchcoat_outfit",
  133.  
  134. -- Duty
  135. "dolg_novice_outfit",
  136. "dolg_outfit",
  137. "dolg_heavy_outfit",
  138. "dolg_exo_outfit",
  139.  
  140. -- Army
  141. "military_outfit",
  142. "specops_outfit",
  143.  
  144. -- Clear Sky
  145. "cs_novice_outfit",
  146. "cs_light_outfit",
  147. "cs_medium_outfit",
  148. "cs_heavy_outfit",
  149.  
  150. -- Mercenary
  151. "merc_outfit",
  152.  
  153.  
  154. "god_outfit"
  155. }
  156. elseif (name == "Items (Misc.)") then
  157. return {
  158. "mutant_part_krovosos_jaw",
  159. "mutant_part_boar_leg",
  160. "mutant_part_chimera_kogot",
  161. "mutant_part_chimera_claw",
  162. "mutant_part_dog_tail",
  163. "mutant_part_flesh_eye",
  164. "mutant_part_psevdodog_tail",
  165. "mutant_part_snork_leg",
  166. "mutant_part_tushkano_head",
  167. "mutant_part_pseudogigant_hand",
  168. "mutant_part_pseudogigant_eye",
  169. "mutant_part_controller_glass",
  170. "mutant_part_controller_hand",
  171. "mutant_part_burer_hand",
  172. "mutant_part_cat_tail",
  173. "mutant_part_fracture_hand",
  174. "mutant_part_zombi_hand",
  175. "device_torch",
  176. "detector_simple",
  177. "detector_advanced",
  178. "detector_elite",
  179. "detector_scientific",
  180. "itm_actor_backpack",
  181. "itm_backpack",
  182. "itm_sleepbag",
  183. "itm_pda_common",
  184. "itm_pda_uncommon",
  185. "itm_pda_rare",
  186. "itm_gunsmith_toolkit",
  187. "itm_gunsmith_toolkit_tier_2",
  188. "stalker_patch",
  189. "ecolog_patch",
  190. "duty_patch",
  191. "merc_patch",
  192. "freedom_patch",
  193. "bandit_patch",
  194. "army_patch",
  195. "monolith_patch",
  196. "csky_patch"
  197. }
  198. elseif (name == "Items (Consumable)") then
  199. return {
  200. "bandage",
  201. "antirad",
  202. "medkit",
  203. "medkit_army",
  204. "medkit_scientic",
  205.  
  206. "drug_booster",
  207. "drug_coagulant",
  208. "drug_psy_blockade",
  209. "drug_antidot",
  210. "drug_radioprotector",
  211. "drug_anabiotic",
  212.  
  213. "bread",
  214. "kolbasa",
  215. "conserva",
  216. "vodka",
  217. "energy_drink"
  218. }
  219. elseif (name == "Weapons (Addon)") then
  220. return {
  221. "pso",
  222. "acog",
  223. "eot",
  224. "c-more",
  225. "ekp",
  226. "1p29",
  227. "ac11090",
  228. "pu",
  229. "wpn_addon_silencer10",
  230. "wpn_addon_silencer45",
  231. "wpn_addon_silencer50",
  232. "wpn_addon_silencer545",
  233. "wpn_addon_silencer556",
  234. "wpn_addon_silencer68",
  235. "wpn_addon_silencer762",
  236. "wpn_addon_silencer9x39",
  237. "wpn_addon_silencer12",
  238. "wpn_addon_silencer",
  239. "wpn_addon_grenade_launcher",
  240. "wpn_addon_grenade_launcher_m203"
  241. }
  242. elseif (name == "Weapons (Pistol)") then
  243. return {
  244. "wpn_beretta",
  245. "wpn_desert_eagle",
  246. "wpn_desert_eagle_nimble",
  247. "wpn_pm",
  248. "wpn_pm_actor",
  249. "wpn_pb",
  250. "wpn_fort",
  251. "wpn_fort_snag",
  252. "wpn_hpsa",
  253. "wpn_walther",
  254. "wpn_sig220",
  255. "wpn_sig220_nimble",
  256. "wpn_colt1911",
  257. "wpn_usp",
  258. "wpn_usp_nimble",
  259. "wpn_mp412",
  260. "wpn_pmm",
  261. "wpn_coltde",
  262. "wpn_colt1911_sk2",
  263. "wpn_colt1911_sk3",
  264. "wpn_glock17",
  265. "wpn_glock21",
  266. "wpn_glock20",
  267. "wpn_glock35",
  268. "wpn_usp40",
  269. "wpn_usp10",
  270. "wpn_hpsa40",
  271. "wpn_beretta96",
  272. "wpn_walther40",
  273. "wpn_fnp45",
  274. "wpn_fnp40",
  275. "wpn_gsh18",
  276. "wpn_mp443",
  277. "wpn_cz40",
  278. "wpn_cz75",
  279. "wpn_ots33",
  280. "wpn_cz52",
  281. "wpn_tt33",
  282. "wpn_desert_eagle_357"
  283. }
  284. elseif (name == "Weapons (Rifle)") then
  285. return {
  286. "wpn_bm16",
  287. "wpn_toz34",
  288. "wpn_wincheaster1300",
  289. "wpn_spas12",
  290. "wpn_spas12_nimble",
  291. "wpn_protecta",
  292. "wpn_protecta_nimble",
  293. "wpn_ak74u",
  294. "wpn_mp5",
  295. "wpn_ak74",
  296. "wpn_abakan",
  297. "wpn_l85",
  298. "wpn_lr300",
  299. "wpn_sig550",
  300. "wpn_groza",
  301. "wpn_val",
  302. "wpn_vintorez",
  303. "wpn_svu",
  304. "wpn_svd",
  305. "wpn_rg-6",
  306. "wpn_rpg7",
  307. "wpn_g36",
  308. "wpn_fn2000",
  309. "wpn_pkm",
  310. "wpn_gauss",
  311. "wpn_wincheaster1300_trapper",
  312. "wpn_ak74u_snag",
  313. "wpn_mp5_nimble",
  314. "wpn_sig550_luckygun",
  315. "wpn_groza_nimble",
  316. "wpn_vintorez_nimble",
  317. "wpn_svu_nimble",
  318. "wpn_svd_nimble",
  319. "wpn_g36_nimble",
  320. "wpn_fn2000_nimble",
  321. "wpn_pkm_zulus",
  322. "pri_a17_gauss_rifle",
  323. "wpn_ak74u_1p29",
  324. "wpn_mp5sd",
  325. "wpn_aek971",
  326. "wpn_aek973",
  327. "wpn_ak12",
  328. "wpn_ak12_762",
  329. "wpn_ak47",
  330. "wpn_aks47",
  331. "wpn_akm",
  332. "wpn_akms",
  333. "wpn_aks74",
  334. "wpn_aks74n",
  335. "wpn_ak74m",
  336. "wpn_ak101",
  337. "wpn_ak102",
  338. "wpn_ak103",
  339. "wpn_ak104",
  340. "wpn_ak105",
  341. "wpn_sks",
  342. "wpn_g3",
  343. "wpn_g3a3",
  344. "wpn_g3sg1",
  345. "wpn_scar-h",
  346. "wpn_stg58",
  347. "wpn_m4bm",
  348. "wpn_m4a1",
  349. "wpn_g36c",
  350. "wpn_saiga",
  351. "wpn_sr3m",
  352. "wpn_vz65",
  353. "wpn_mp5sd_nimble",
  354. "wpn_remington870",
  355. "wpn_mossberg",
  356. "wpn_9a91",
  357. "wpn_bizon",
  358. "wpn_groza1",
  359. "wpn_l96",
  360. "wpn_trg42",
  361. "wpn_trg22",
  362. "wpn_l115a3",
  363. "wpn_svt40",
  364. "wpn_mn91",
  365. "wpn_toz34_so",
  366. "wpn_izh43",
  367. "wpn_m60",
  368. "wpn_m249",
  369. "wpn_m16",
  370. "wpn_m16_68",
  371. "wpn_rpk",
  372. "wpn_rpk74",
  373. "wpn_ar15",
  374. "wpn_aug",
  375. "wpn_ump40",
  376. "wpn_ump45",
  377. "wpn_vsk94",
  378. "wpn_pp2000",
  379. "wpn_lr680",
  380. "wpn_avt40",
  381. "wpn_saiga_nimble",
  382. "wpn_m249_nimble",
  383. "wpn_vks"
  384. }
  385. elseif (name == "Weapons (Misc.)") then
  386. return {
  387. -- "explosive_barrel",
  388. -- "explosive_mobiltank",
  389. -- "explosive_dinamit",
  390. "grenade_f1",
  391. "grenade_rgd5",
  392. "grenade_gd-05",
  393. "wpn_knife",
  394. "wpn_binoc",
  395. "wpn_mine"
  396. }
  397. elseif (name == "Items (Quest)") then
  398. return {
  399. "bad_psy_helmet",
  400. "good_psy_helmet",
  401. "jup_a9_conservation_info",
  402. "jup_a9_power_info",
  403. "jup_a9_way_info",
  404. "jup_a9_evacuation_info",
  405. "jup_a9_meeting_info",
  406. "jup_a9_losses_info",
  407. "jup_a9_delivery_info",
  408. "jup_b10_ufo_memory",
  409. "jup_b10_ufo_memory_2",
  410. "jup_b10_notes_01",
  411. "jup_b10_notes_02",
  412. "jup_b10_notes_03",
  413. "jup_b205_sokolov_note",
  414. "jup_b206_plant",
  415. "jup_b209_monster_scanner",
  416. "jup_b200_tech_materials_wire",
  417. "jup_b200_tech_materials_acetone",
  418. "jup_b200_tech_materials_textolite",
  419. "jup_b200_tech_materials_transistor",
  420. "jup_b200_tech_materials_capacitor",
  421. "jup_b202_bandit_pda",
  422. "device_flash_snag",
  423. "jup_b9_blackbox",
  424. "jup_b32_scanner_device",
  425. "jup_b46_duty_founder_pda",
  426. "jup_b207_merc_pda_with_contract",
  427. "jup_b47_jupiter_products_info",
  428. "jup_b47_merc_pda",
  429. "toolkit_1",
  430. "toolkit_2",
  431. "toolkit_3",
  432. "zat_b33_safe_container",
  433. "zat_b57_gas",
  434. "zat_b12_key_1",
  435. "zat_b12_key_2",
  436. "zat_b12_documents_1",
  437. "zat_b12_documents_2",
  438. "device_pda_port_bandit_leader",
  439. "zat_b40_notebook",
  440. "zat_b40_pda_1",
  441. "zat_b40_pda_2",
  442. "device_pda_zat_b5_dealer",
  443. "zat_b20_noah_pda",
  444. "zat_a23_access_card",
  445. "zat_a23_gauss_rifle_docs",
  446. "zat_b44_barge_pda",
  447. "zat_b39_joker_pda",
  448. "zat_b22_medic_pda",
  449. "pri_b35_lab_x8_key",
  450. "pri_b306_envoy_pda",
  451. "pri_b36_monolith_hiding_place_pda",
  452. "pri_a25_explosive_charge_item",
  453. "pri_a19_american_experiment_info",
  454. "pri_a19_lab_x16_info",
  455. "pri_a19_lab_x10_info",
  456. "pri_a19_lab_x7_info",
  457. "pri_a19_lab_x18_info",
  458. "zat_a23_labx8_key",
  459. "lx8_service_instruction"
  460. }
  461. elseif (name == "Ammo") then
  462. return {
  463. "ammo_9x18_fmj",
  464. "ammo_9x18_pmm",
  465. "ammo_9x19_fmj",
  466. "ammo_9x19_pbp",
  467. "ammo_11.43x23_fmj",
  468. "ammo_11.43x23_hydro",
  469. "ammo_5.45x39_fmj",
  470. "ammo_5.45x39_ap",
  471. "ammo_5.56x45_ss190",
  472. "ammo_5.56x45_ap",
  473. "ammo_pkm_100",
  474. "ammo_7.62x54_7h1",
  475. "ammo_gauss",
  476. "ammo_gauss_cardan",
  477. "ammo_9x39_pab9",
  478. "ammo_9x39_ap",
  479. "ammo_12x70_buck",
  480. "ammo_12x76_zhekan",
  481. "ammo_og-7b",
  482. "ammo_vog-25",
  483. "ammo_m209",
  484. "ammo_7.62x39_fmj",
  485. "ammo_7.62x39_ap",
  486. "ammo_7.62x51_fmj",
  487. "ammo_7.62x51_ap",
  488. "ammo_7.62x25_fmj",
  489. "ammo_7.62x25_hp",
  490. "ammo_357_fmj",
  491. "ammo_357_hp",
  492. "ammo_50ae_fmj",
  493. "ammo_7.62x54_fmj",
  494. "ammo_12.7x55",
  495. "ammo_8.58×70_ap",
  496. "ammo_6.8x43_fmj",
  497. "ammo_10x25_fmj",
  498. "ammo_10x22_fmj"
  499. }
  500. elseif (name == "NPC (Stalker)") then
  501. return {
  502. "sim_default_stalker_0",
  503. "sim_default_stalker_1",
  504. "sim_default_stalker_2",
  505. "sim_default_stalker_3",
  506. "sim_default_stalker_4",
  507. "sim_default_bandit_0",
  508. "sim_default_bandit_1",
  509. "sim_default_bandit_2",
  510. "sim_default_bandit_3",
  511. "sim_default_bandit_4",
  512. "sim_default_killer_0",
  513. "sim_default_killer_1",
  514. "sim_default_killer_2",
  515. "sim_default_killer_3",
  516. "sim_default_killer_4",
  517. "sim_default_duty_0",
  518. "sim_default_duty_1",
  519. "sim_default_duty_2",
  520. "sim_default_duty_3",
  521. "sim_default_duty_4",
  522. "sim_default_freedom_0",
  523. "sim_default_freedom_1",
  524. "sim_default_freedom_2",
  525. "sim_default_freedom_3",
  526. "sim_default_freedom_4",
  527. "sim_default_army_0",
  528. "sim_default_army_1",
  529. "sim_default_army_2",
  530. "sim_default_army_3",
  531. "sim_default_army_4",
  532. "sim_default_monolith_0",
  533. "sim_default_monolith_1",
  534. "sim_default_monolith_2",
  535. "sim_default_monolith_3",
  536. "sim_default_monolith_4",
  537. "sim_monolith_sniper",
  538. "sim_monolith_specnaz_rg6",
  539. "sim_default_zombied_0",
  540. "sim_default_zombied_1",
  541. "sim_default_zombied_2",
  542. "sim_default_zombied_3",
  543. "sim_default_zombied_4",
  544. "sim_default_csky_0",
  545. "sim_default_csky_1",
  546. "sim_default_csky_2",
  547. "sim_default_csky_3",
  548. "sim_default_csky_4",
  549. "sim_default_ecolog_0",
  550. "sim_default_ecolog_1",
  551. "sim_default_ecolog_2",
  552. "sim_default_ecolog_3",
  553. "sim_default_ecolog_4",
  554. "sim_default_military_0",
  555. "sim_default_military_1",
  556. "sim_default_military_2",
  557. "sim_default_military_3",
  558. "sim_default_military_4"
  559. }
  560. elseif (name == "NPC (Mutant)") then
  561. return {
  562. "cat_weak",
  563. "cat_normal",
  564. "cat_strong",
  565. "dog_weak",
  566. "dog_normal",
  567. "dog_strong",
  568. "rat_weak",
  569. "rat_normal",
  570. "rat_strong",
  571. "chimera_weak",
  572. "chimera_normal",
  573. "chimera_strong",
  574. "m_controller_normal",
  575. "m_controller_normal2",
  576. "bloodsucker_weak",
  577. "bloodsucker_normal",
  578. "bloodsucker_strong",
  579. "boar_weak",
  580. "boar_normal",
  581. "boar_strong",
  582. "flesh_weak",
  583. "flesh_normal",
  584. "flesh_strong",
  585. "fracture_weak",
  586. "fracture_normal",
  587. "fracture_strong",
  588. "zombie_weak",
  589. "zombie_normal",
  590. "zombie_strong",
  591. "gigant_weak",
  592. "gigant_normal",
  593. "gigant_strong",
  594. "snork_weak",
  595. "snork_normal",
  596. "snork_strong",
  597. "pseudodog_weak",
  598. "pseudodog_normal",
  599. "pseudodog_strong",
  600. "burer_weak",
  601. "burer_normal",
  602. "burer_strong",
  603. "tushkano_weak",
  604. "tushkano_normal",
  605. "tushkano_strong",
  606. "borya_normal",
  607. "psysucker_weak",
  608. "psysucker_normal",
  609. "psysucker_strong",
  610. "m_controller_psy"
  611. }
  612. elseif (name == "Squads (Stalker)") then
  613. return {
  614. "stalker_sim_squad_novice",
  615. "stalker_sim_squad_advanced",
  616. "stalker_sim_squad_veteran",
  617. "bandit_sim_squad_novice",
  618. "bandit_sim_squad_advanced",
  619. "bandit_sim_squad_veteran",
  620. "duty_sim_squad_novice",
  621. "duty_sim_squad_advanced",
  622. "duty_sim_squad_veteran",
  623. "freedom_sim_squad_novice",
  624. "freedom_sim_squad_advanced",
  625. "freedom_sim_squad_veteran",
  626. "army_sim_squad_novice",
  627. "army_sim_squad_advanced",
  628. "army_sim_squad_veteran",
  629. "merc_sim_squad_novice",
  630. "merc_sim_squad_advanced",
  631. "merc_sim_squad_veteran",
  632. "monolith_sim_squad_novice",
  633. "monolith_sim_squad_advanced",
  634. "monolith_sim_squad_veteran",
  635. "csky_sim_squad_novice",
  636. "csky_sim_squad_advanced",
  637. "csky_sim_squad_veteran",
  638. "ecolog_sim_squad_novice",
  639. "ecolog_sim_squad_advanced",
  640. "ecolog_sim_squad_veteran",
  641. "zombied_sim_squad_novice",
  642. "zombied_sim_squad_advanced",
  643. "zombied_sim_squad_veteran"
  644. }
  645. elseif (name == "Squads (Mutant)") then
  646. return {
  647. "simulation_bloodsucker",
  648. "simulation_boar",
  649. "simulation_burer",
  650. "simulation_dog",
  651. "simulation_pseudodog",
  652. "simulation_flesh",
  653. "simulation_snork",
  654. "simulation_controller",
  655. "simulation_mix_dogs",
  656. "simulation_mix_boar_flesh",
  657. "simulation_poltergeist_tele",
  658. "simulation_chimera",
  659. "simulation_chimera_zaton",
  660. "simulation_chimera_pripyat",
  661. "simulation_chimera_jupiter",
  662. "simulation_psy_dog",
  663. "simulation_tushkano",
  664. "simulation_gigant",
  665. "simulation_cat",
  666. "simulation_zombie",
  667. "simulation_rat",
  668. "simulation_rats",
  669. "simulation_fracture",
  670. "simulation_psysucker",
  671. "simulation_controller_psy"
  672. }
  673. elseif (name == "Vehicles") then
  674. return {
  675. "veh_niva",
  676. "veh_uaz_01",
  677. "veh_uaz_02",
  678. "veh_uaz_buhanka",
  679. "veh_zaz",
  680. "veh_zaz_968",
  681. "veh_moskvich",
  682. "veh_tr13",
  683. "veh_zil_130",
  684. "veh_zil_131",
  685. "veh_kamaz_fura",
  686. "veh_kamaz",
  687. "veh_laz",
  688. "veh_kavz",
  689. "veh_gaz",
  690. "veh_btr",
  691. "veh_hl2baggi"
  692. }
  693. elseif (name == "Physic (Misc.)") then
  694. return {
  695. "mine_blow",
  696. "jup_b209_ph_scanner",
  697. "jup_b207_depot_cover",
  698. "pri_a28_actor_hideout",
  699. "jup_b219_gate",
  700. "pri_a25_explosive_charge",
  701. "pri_a28_earth_helli_1",
  702. "pri_a28_earth_helli_2",
  703. "jup_b206_plant_ph",
  704. "shooting_target_1",
  705. "balon_01",
  706. "balon_02",
  707. "balon_02link",
  708. "balon_02a",
  709. "bidon",
  710. "bochka_close_1",
  711. "bochka_close_2",
  712. "bochka_close_3",
  713. "bochka_close_4",
  714. "gaz_balon",
  715. "disel_generator",
  716. "krisagenerator",
  717. "ventilator_01",
  718. "ventilator_02",
  719. "ventilator_03",
  720. "ventilator_04",
  721. "ventilator_05",
  722. "notebook",
  723. "priemnik_gorizont",
  724. "rupor",
  725. "transiver",
  726. "tv_1",
  727. "table_lamp_01",
  728. "komp_monitor",
  729. "komp_klava",
  730. "komp_block",
  731. "debris_01",
  732. "wood_fence_1",
  733. "wood_fence_2",
  734. "wood_fence_3",
  735. "wood_fence_4",
  736. "banka_kraski_1",
  737. "kanistra_01",
  738. "tiski",
  739. "kanistra_02",
  740. "vedro_01",
  741. "axe",
  742. "hammer",
  743. "hatch_01",
  744. "keyga",
  745. "lopata",
  746. "molot",
  747. "pick",
  748. "riffler",
  749. "saw",
  750. "box_1a",
  751. "box_1b",
  752. "box_1c",
  753. "box_bottle_1",
  754. "box_metall_01",
  755. "box_wood_01",
  756. "box_wood_02",
  757. "box_paper"
  758. }
  759. end
  760. end
  761.  
  762. ------------------------------------------------------------
  763. -- List box
  764. ------------------------------------------------------------
  765. class "set_list_text" (CUIListBoxItem)
  766. function set_list_text:__init(height) super(height)
  767. self.sect = self:GetTextItem()
  768. self.sect:SetWndRect (Frect():set(0,0,300,22))
  769. self:SetTextColor (GetARGB(255, 216, 186, 140))
  770. self.sect:SetFont (GetFontLetterica18Russian())
  771. self.sect:SetWndSize (vector2():set(400,height))
  772. self.sect:SetEllipsis (true)
  773. end
  774.  
  775. ------------------------------------------------------------
  776. -- MAIN DEBUG UI
  777. ------------------------------------------------------------
  778. class "debug_ui" (CUIScriptWnd)
  779. function debug_ui:__init(owner,binds) super()
  780. self.owner = owner
  781. self.binds = binds
  782. self.txt_console = {}
  783. self.tab_list = {}
  784. self.console_size = 27
  785. self:InitControls()
  786. self:InitCallBacks()
  787. self.tab:SetActiveTab("spawner")
  788. self:SendOutput("Alundaio's xrs_debug_tools version 2.5 [Type help for a list of commands]")
  789. self.console_relay = false
  790. end
  791.  
  792. function debug_ui:__finalize()
  793.  
  794. end
  795.  
  796. function debug_ui:Reinit(level_present)
  797. self.level_present = level_present
  798. if not (level_present) then
  799. self.tab:SetActiveTab("editor")
  800. else
  801. self.tab:SetActiveTab("spawner")
  802. end
  803.  
  804. self:OnTabChange()
  805. end
  806.  
  807. function debug_ui:CreateTab(uID)
  808. self.tab_list[uID] = true
  809. self["dlg_"..uID] = this["debug_ui_"..uID](self,binds)
  810. self["dlg_"..uID]:InitControls(0,0, self.xml, self)
  811. self["dlg_"..uID]:Show(false)
  812. self.dialog:AttachChild(self["dlg_"..uID])
  813. self.xml:InitWindow("tab_size", 0, self["dlg_"..uID])
  814. end
  815.  
  816. function debug_ui:InitControls()
  817. self:SetWndRect (Frect():set(0,0,1024,768))
  818. self:Enable (true)
  819.  
  820. local xml = CScriptXmlInit()
  821. self.xml = xml
  822. xml:ParseFile ("ui_debug_main.xml")
  823.  
  824. xml:InitStatic ("background", self)
  825. self.dialog = xml:InitStatic("main_dialog:dialog", self)
  826.  
  827. -- Menu Quit
  828. local btn = xml:Init3tButton("main_dialog:btn_quit", self.dialog)
  829. self:Register(btn,"btn_quit")
  830.  
  831. -- Teleport Button
  832. btn = xml:Init3tButton("main_dialog:btn_tp", self.dialog)
  833. self:Register(btn,"btn_tp")
  834.  
  835. -- Console
  836. self.console = xml:InitStatic("console",self)
  837. self.console_input = xml:InitEditBox("console:input",self)
  838. self:Register(self.console_input,"console_input")
  839.  
  840. --self.scroll_v = xml:InitScrollView("console:scroll_v", self.dialog)
  841. --self.scroll_v:AddWindow(self.console, true)
  842.  
  843. local offset = vector2()
  844. offset.x = 10
  845. offset.y = 10
  846.  
  847. for i=1,self.console_size do
  848. self.txt_console[i] = xml:InitTextWnd("console:ln",self.console)
  849. self.txt_console[i]:SetWndPos(offset)
  850. offset.y = offset.y + 15
  851.  
  852. self.txt_console[i]:SetTextColor( GetARGB(255,240, 240, 240))
  853. end
  854. self.txt_console[1]:SetTextColor( GetARGB(255,255, 255, 255))
  855.  
  856. -- Info
  857. self.form = xml:InitStatic("main_dialog:form",self.dialog)
  858.  
  859. xml:InitStatic("main_dialog:cap_focus_id", self.dialog)
  860. self.txt_focus = xml:InitTextWnd("main_dialog:form:txt_focus", self.form)
  861.  
  862. xml:InitStatic("main_dialog:cap_near_id", self.dialog)
  863. self.txt_near = xml:InitTextWnd("main_dialog:form:txt_near", self.form)
  864.  
  865. -- Tabs
  866. --self:CreateTab("spawner")
  867. --self:CreateTab("editor")
  868. --self:CreateTab("object")
  869. --self:CreateTab("advanced")
  870.  
  871. -- Dialog Tab
  872. self.tab = xml:InitTab("main_dialog:tab", self.dialog)
  873. self:Register(self.tab, "tab")
  874. end
  875.  
  876. function debug_ui:SetCurrentValues()
  877.  
  878. end
  879.  
  880. function debug_ui:ShowConsole()
  881. if not (self.console:IsShown()) then
  882. self.console:Show(true)
  883. self.console_input:Show(true)
  884. end
  885. end
  886.  
  887. function debug_ui:HideConsole()
  888. if (self.console:IsShown()) then
  889. self.console:Show(false)
  890. self.console_input:Show(false)
  891. end
  892. end
  893.  
  894. function debug_ui:Update()
  895. CUIScriptWnd.Update(self)
  896. end
  897.  
  898. function debug_ui:InitCallBacks()
  899. self:AddCallback("tab", ui_events.TAB_CHANGED, self.OnTabChange, self)
  900. self:AddCallback("btn_quit", ui_events.BUTTON_CLICKED, self.OnQuit, self)
  901. self:AddCallback("btn_tp", ui_events.BUTTON_CLICKED, self.OnBtnTeleport, self)
  902. self:AddCallback("btn_spawn", ui_events.BUTTON_CLICKED, self.OnBtnSpawn, self)
  903. self:AddCallback("btn_spawn_squad", ui_events.BUTTON_CLICKED, self.OnBtnSpawnSquad, self)
  904. self:AddCallback("btn_focus", ui_events.BUTTON_CLICKED, self.OnBtnFocus, self)
  905. self:AddCallback("btn_execute_string", ui_events.BUTTON_CLICKED, self.OnBtnExecuteString, self)
  906. --self:AddCallback("btn_switch_distance", ui_events.BUTTON_CLICKED, self.OnBtnSwitchDistance, self)
  907. self:AddCallback("btn_find", ui_events.BUTTON_CLICKED, self.OnBtnFindNearest, self)
  908. self:AddCallback("btn_set", ui_events.BUTTON_CLICKED, self.OnBtnSetLogic, self)
  909. self:AddCallback("btn_revert", ui_events.BUTTON_CLICKED, self.OnBtnRevertLogic, self)
  910. self:AddCallback("btn_reload", ui_events.BUTTON_CLICKED, self.OnBtnReloadIni, self)
  911. self:AddCallback("console_input", ui_events.EDIT_TEXT_COMMIT, self.OnConsoleInput, self)
  912.  
  913. --- Spawner Tab
  914. self:AddCallback("list_sections", ui_events.LIST_ITEM_SELECT, self.OnSelectSectionList, self)
  915. self:AddCallback("list_window", ui_events.WINDOW_LBUTTON_DB_CLICK, self.OnButton_create_clicked, self)
  916. --self:AddCallback("btn_create", ui_events.BUTTON_CLICKED, self.OnButton_create_clicked, self)
  917.  
  918. -- Icon Editor
  919. self:AddCallback("editor_list_sections", ui_events.LIST_ITEM_SELECT, self.OnSelectEditorSectionList, self)
  920. self:AddCallback("editor_list_window", ui_events.WINDOW_LBUTTON_DB_CLICK, self.OnEditorTriggerSectionSelection, self)
  921.  
  922. self:AddCallback("fld_icon_x", ui_events.EDIT_TEXT_COMMIT, self.OnEditIconX, self)
  923. self:AddCallback("fld_icon_y", ui_events.EDIT_TEXT_COMMIT, self.OnEditIconY, self)
  924. self:AddCallback("fld_icon_width", ui_events.EDIT_TEXT_COMMIT, self.OnEditIconW, self)
  925. self:AddCallback("fld_icon_height", ui_events.EDIT_TEXT_COMMIT, self.OnEditIconH, self)
  926. self:AddCallback("fld_addon_offset_x", ui_events.EDIT_TEXT_COMMIT, self.OnEditIconOffX, self)
  927. self:AddCallback("fld_addon_offset_y", ui_events.EDIT_TEXT_COMMIT, self.OnEditIconOffY, self)
  928.  
  929. self:AddCallback("editor_list_addon", ui_events.LIST_ITEM_SELECT, self.OnEditorTriggerAddonSectionSelection, self)
  930. self:AddCallback("btn_editor_save", ui_events.BUTTON_CLICKED, self.OnEditorSave, self)
  931. --
  932.  
  933. -- level jump tab
  934. self:AddCallback("list_levels_window", ui_events.WINDOW_LBUTTON_DB_CLICK, self.JumpLevel, self)
  935. end
  936.  
  937. function debug_ui:OnConsoleInput()
  938. local txt = self.console_input:GetText()
  939. if (txt == "") then
  940. return
  941. end
  942.  
  943. local wrd = ""
  944. local _strt, _end = string.find(txt,".%S+")
  945. if (_strt and _end) then
  946. wrd = string.sub(txt,_strt, _end)
  947. wrd = string.lower(wrd)
  948. else
  949. return "For usage type echo help"
  950. end
  951.  
  952. if not (debug_cmd_list.command_exists(wrd)) then
  953. self:SendOutput("Command %s cannot be found. Type help for a list of commands.",wrd)
  954. return
  955. end
  956.  
  957. -- Grab rest of str
  958. local args = string.sub(txt,string.len(wrd)+1)
  959.  
  960. -- Trim
  961. args = string.gsub(args, "^%s*(.-)%s*$", "%1")
  962.  
  963. -- Perform execute string on $vars
  964. local p ={}
  965. local var_list = debug_cmd_list.get_var_list()
  966. for s in string.gmatch(args,"$(.-)%$") do
  967. s = string.gsub(s, "^%s*(.-)%s*$", "%1")
  968. if (s and s ~= "" and var_list[s]) then
  969. table.insert(p,s)
  970. else
  971. local ls,err = loadstring("return function() local val = " .. s .."; return val; end")
  972. local func = ls and ls() or err
  973. local val = func and type(func) == "function" and func()
  974. table.insert(p,val)
  975. end
  976. end
  977.  
  978. -- replace all %s with returned vals
  979. local i = 0
  980. local function sr(a)
  981. i = i + 1
  982.  
  983. if ( type(p[i] ~= "userdata") )then
  984. if ( var_list[p[i]] and type(var_list[p[i]] ~= "userdata") ) then
  985. return tostring(var_list[p[i]])
  986. end
  987. return tostring(p[i])
  988. end
  989. return ""
  990. end
  991. local output = string.gsub(args,"%%s",sr)
  992.  
  993. -- Remove all $exe_strs
  994. output = string.gsub(output,"$(.-)%$","")
  995.  
  996. -- Send Output
  997. self:SendOutput(debug_cmd_list.command_give(wrd,output,self,p))
  998. end
  999.  
  1000. function debug_ui:OnBtnTeleport()
  1001. local pos = xrs_debug_tools.LastCameraPos
  1002. if (pos) then
  1003. local car = db.actor:get_attached_vehicle()
  1004. if (car) then
  1005. db.actor:detach_vehicle()
  1006. end
  1007. db.actor:set_actor_position(pos)
  1008.  
  1009. self:OnQuit()
  1010. end
  1011. end
  1012.  
  1013. function debug_ui:OnBtnSpawn()
  1014. local txt = self.fld_spawn:GetText()
  1015. if (txt ~= "") then
  1016. self:spawn_section(txt)
  1017. end
  1018. end
  1019.  
  1020. function debug_ui:OnBtnSpawnSquad()
  1021. local sec = self.fld_spawn_squad:GetText()
  1022. local smrt = self.fld_spawn_smart:GetText()
  1023. if (sec ~= "" and smrt ~= "") then
  1024. self:spawn_squad(sec,smrt)
  1025. end
  1026. end
  1027.  
  1028. function debug_ui:SendOutput(txt,...)
  1029. if not (txt) or (txt == "") then
  1030. return
  1031. end
  1032.  
  1033. local i = 0
  1034. local out = txt
  1035. local p = {...}
  1036. if (#p > 0) then
  1037. local function sr(a)
  1038. i = i + 1
  1039. return tostring(p[i])
  1040. end
  1041. out = string.gsub(txt,"%%s",sr)
  1042. end
  1043.  
  1044. for n=1,#self.txt_console-1,1 do
  1045. local s = self.txt_console[n+1]:GetText()
  1046. self.txt_console[n]:SetText(s)
  1047. end
  1048. self.txt_console[#self.txt_console]:SetText(out)
  1049.  
  1050. if (self.console_relay) then
  1051. printf("Debug Console: %s",out)
  1052. end
  1053. end
  1054.  
  1055. function debug_ui:SendOutputList(list,start,finish)
  1056. if not (list and not empty(list)) then
  1057. return
  1058. end
  1059.  
  1060. local count = 1
  1061. local n = 1
  1062. local size = #self.txt_console
  1063. for k,v in pairs(list) do
  1064. if (start and count >= start) then
  1065. if (n < (finish or size)) then
  1066. self:SendOutput(tostring(v))
  1067. n = n + 1
  1068. else
  1069. self:SendOutput(tostring(v))
  1070. return
  1071. end
  1072. else
  1073. count = count + 1
  1074. end
  1075. end
  1076. for i=n,finish do
  1077. self:SendOutput(" ")
  1078. end
  1079. end
  1080.  
  1081. function debug_ui:OnBtnFocus()
  1082. local txt = self.fld_focus:GetText()
  1083. if (txt ~= "") then
  1084. xrs_debug_tools.set_debug_npc(tonumber(txt))
  1085. self.txt_focus:SetText(txt)
  1086. else
  1087. xrs_debug_tools.set_debug_npc()
  1088. self.txt_focus:SetText("")
  1089. end
  1090. end
  1091.  
  1092. function debug_ui:OnBtnExecuteString()
  1093. local txt = self.fld_execute_string:GetText()
  1094. if (txt ~= "") then
  1095. assert(loadstring(txt))()
  1096. end
  1097. end
  1098.  
  1099. function debug_ui:OnBtnSwitchDistance()
  1100. local txt = self.fld_switch_distance:GetText()
  1101. if (txt ~= "") then
  1102. local a = alife()
  1103. local old = a:switch_distance()
  1104. local amt = tonumber(txt)
  1105. --alun_utils.debug_write("%s %s ",old,amt)
  1106. a:switch_distance(amt)
  1107. self:SendOutput("Switch Distance changed from %s to %s.",old,amt)
  1108. end
  1109. end
  1110.  
  1111. function debug_ui:OnBtnFindNearest()
  1112. local txt = self.fld_find:GetText()
  1113. self:FindNearest(txt)
  1114. end
  1115.  
  1116. function debug_ui:OnBtnSetLogic()
  1117. local section = self.fld_section:GetText()
  1118. if (section == "") then
  1119. return
  1120. end
  1121. local id = self.fld_id:GetText()
  1122. id = id and tonumber(id)
  1123. local scheme = utils.get_scheme_by_section(section)
  1124. local logic = self.fld_logic:GetText()
  1125. local ini_filename = self.fld_filename:GetText()
  1126.  
  1127. if (id and scheme and section and ini_filename) then
  1128. local obj = db.storage[id] and db.storage[id].object or level.object_by_id(id)
  1129. if (obj) then
  1130. axr_logic.set_new_scheme_and_logic(obj,scheme,section,logic,nil,ini_filename)
  1131. self:SendOutput("New scheme and logic set for %s.",obj:name())
  1132. end
  1133. end
  1134. end
  1135.  
  1136. function debug_ui:OnBtnRevertLogic()
  1137. local id = self.fld_id:GetText()
  1138. id = id and tonumber(id)
  1139. if (id) then
  1140. local obj = db.storage[id] and db.storage[id].object or level.object_by_id(id)
  1141. if (obj) then
  1142. axr_logic.restore_scheme_and_logic(obj)
  1143. self:SendOutput("Reverted scheme and logic for %s.",obj:name())
  1144. end
  1145. end
  1146. end
  1147.  
  1148. function debug_ui:OnBtnReloadIni()
  1149. local txt = self.fld_reload:GetText()
  1150. if (txt and txt ~= "") then
  1151. local st = db.storage[tonumber(txt)]
  1152. if (st) then
  1153. st.ini = nil
  1154. st.ini = xr_logic.get_customdata_or_ini_file(st.object, st.ini_filename)
  1155. xr_logic.switch_to_section(st.object,nil,nil)
  1156. self:SendOutput("INI reload performed on %s.",obj:name())
  1157. end
  1158. end
  1159. end
  1160.  
  1161. function debug_ui:OnQuit()
  1162. self:HideDialog()
  1163. if (self.level_present) then
  1164. local console = get_console()
  1165. console:execute("main_menu off")
  1166. else
  1167. self.owner:ShowDialog()
  1168. self.owner:Show(true)
  1169. end
  1170. end
  1171.  
  1172. function debug_ui:OnTabChange()
  1173. for k,v in pairs(self.tab_list) do
  1174. self["dlg_"..k]:Show(false)
  1175. end
  1176.  
  1177. local ids = self.tab:GetActiveId()
  1178.  
  1179. if (ids == "editor" or not self.level_present) then
  1180. if not (self.dlg_editor) then
  1181. self:CreateTab("editor")
  1182. end
  1183.  
  1184. self.dlg_editor:Show(true)
  1185.  
  1186. if (self.ui_icon_equipment) then
  1187. self:HideConsole()
  1188. self.ui_icon_equipment:Show(true)
  1189. self.ui_icon_equipment_back:Show(true)
  1190. self.icon_square:Show(true)
  1191. end
  1192. return
  1193. else
  1194. if not (self.level_present) then
  1195. return
  1196. end
  1197.  
  1198. if (self.ui_icon_equipment) then
  1199. self.ui_icon_equipment:Show(false)
  1200. self.icon_square:Show(false)
  1201. self.ui_icon_equipment_back:Show(false)
  1202. self:ShowConsole()
  1203. end
  1204. end
  1205.  
  1206. if not (self["dlg_"..ids]) then
  1207. self:CreateTab(ids)
  1208. end
  1209.  
  1210. self["dlg_"..ids]:Show(true)
  1211. end
  1212.  
  1213. function debug_ui:OnKeyboard(dik, keyboard_action)
  1214. CUIScriptWnd.OnKeyboard(self,dik,keyboard_action)
  1215. if keyboard_action == ui_events.WINDOW_KEY_RELEASED then
  1216. local keybinds = self.binds or {}
  1217. if dik == DIK_keys.DIK_ESCAPE then
  1218. self:OnQuit()
  1219. elseif (keybinds["keybind_teleport_to_cam"] and dik == DIK_keys["DIK_"..keybinds["keybind_teleport_to_cam"]]) then
  1220. self:OnBtnTeleport()
  1221. elseif (keybinds["debug_ui_nearest_stalker"] and dik == DIK_keys["DIK_"..keybinds["debug_ui_nearest_stalker"]]) then
  1222. self:FindNearest("clsid.script_stalker")
  1223. elseif (keybinds["debug_ui_spawn_position"] and dik == DIK_keys["DIK_"..keybinds["debug_ui_spawn_position"]]) then
  1224. self.spawn_pos = db.actor:position()
  1225. self.spawn_lvid = db.actor:level_vertex_id()
  1226. self.spawn_gvid = db.actor:game_vertex_id()
  1227. self:SendOutput("Set current spawning position to actor location. [To set to default type spawn reset]")
  1228. end
  1229. end
  1230. return true
  1231. end
  1232.  
  1233. function debug_ui:spawn_section(text)
  1234. if not system_ini():section_exist(text) then
  1235. return false
  1236. end
  1237.  
  1238. local pos, lvid, gvid
  1239. if (self.spawn_pos) then
  1240. pos = self.spawn_pos
  1241. lvid = self.spawn_lvid
  1242. gvid = self.spawn_gvid
  1243. else
  1244. pos = db.actor:position()
  1245. lvid = db.actor:level_vertex_id()
  1246. gvid = db.actor:game_vertex_id()
  1247. end
  1248.  
  1249. local obj = alife():create(text,pos,lvid,gvid)
  1250. --printf("Spawned Object %s as ID: %s",obj:name(),obj.id)
  1251. self:SendOutput("Object %s created as ID %s.",obj:name(),obj.id)
  1252. return true
  1253. end
  1254.  
  1255. function debug_ui:spawn_squad(section,smart)
  1256. if not system_ini():section_exist(section) then
  1257. self:SendOutput("UISpawner: Section %s does not exist in system INI.",section)
  1258. return false
  1259. end
  1260.  
  1261. if not (smart) then
  1262. self:SendOutput("UISpawner: Smart by name %s does not exist.",smart)
  1263. return false
  1264. end
  1265. local sim = SIMBOARD
  1266. if not (sim.smarts_by_names[smart]) then
  1267. self:SendOutput("UISpawner: Smart by name %s does not exist.",smart)
  1268. return false
  1269. end
  1270. local squad = alun_utils.create_squad(section,smart)
  1271. self:SendOutput("UISpawner: Squad %s created as ID %s at %s.",squad:name(),squad.id,smart)
  1272. return true
  1273. end
  1274.  
  1275. function debug_ui:FindNearest(txt)
  1276. if (txt and txt ~= "") then
  1277. local near,dist
  1278. if (string.find(txt,"clsid")) then
  1279. local cls = string.sub(txt,7)
  1280. if (clsid[cls]) then
  1281. near,dist = alun_utils.nearest_object(clsid[cls],true)
  1282. end
  1283. else
  1284. near,dist = alun_utils.nearest_object(txt,true)
  1285. end
  1286.  
  1287.  
  1288. if (near) then
  1289. local id = near.id
  1290. local st = near:clsid() == clsid.script_stalker and db.storage[id]
  1291. if (st) then
  1292. local scheme = st.active_scheme
  1293. local section = st.active_section
  1294. local logic = st.section_logic
  1295. local ini_filename = st.ini_filename
  1296.  
  1297. if not (self.dlg_object) then
  1298. self:CreateTab("object")
  1299. end
  1300.  
  1301. if (self.fld_id) then
  1302. self.fld_id:SetText(id or "")
  1303. self.fld_section:SetText(section or "")
  1304. self.fld_logic:SetText(logic or "")
  1305. self.fld_filename:SetText(ini_filename or "")
  1306. if (self.fld_focus) then
  1307. self.fld_focus:SetText(id or "")
  1308. end
  1309. if (self.fld_reload) then
  1310. self.fld_reload:SetText(id or "")
  1311. end
  1312. end
  1313. self.txt_near:SetText(id)
  1314. end
  1315. self:SendOutput("%s with ID %s found with distance %s",near:name(),id,dist)
  1316. else
  1317. --printf("Could not find object matching name")
  1318. self.txt_near:SetText("Not Found")
  1319. self:SendOutput("Object with name not found.")
  1320. end
  1321. end
  1322. end
  1323.  
  1324. function debug_ui:FillList(name)
  1325. if not (name) then
  1326. self:SendOutput("UISpawner: No spawn table could be created for %s",name)
  1327. return
  1328. end
  1329.  
  1330. self.spawn_list:Clear()
  1331.  
  1332. local spawntbl = get_spawn_table(name)
  1333.  
  1334. if not (spawntbl) then
  1335. self:SendOutput("UISpawner: No spawn table could be created for %s",name)
  1336. return
  1337. end
  1338.  
  1339.  
  1340. local is_squad = string.find(name,"Squad")
  1341. local cant_spawn_actor = string.find(name,"NPC") or string.find(name,"Physic")
  1342. local is_veh = string.find(name,"Vehicles")
  1343. local is_anom = string.find(name,"Anomaly")
  1344. local is_phantom = string.find(name,"Phantom")
  1345. if (is_squad) then
  1346. -- self.smarts_list:Show(true)
  1347. else
  1348. -- self.smarts_list:Show(false)
  1349. end
  1350.  
  1351. local ini = system_ini()
  1352.  
  1353. table.sort(spawntbl)
  1354. for i = 1, #spawntbl do
  1355. if (ini:section_exist(spawntbl[i])) then
  1356. local _itm = set_list_text(22)
  1357. --local name = game.translate_string(system_ini():r_string(sections[i], "inv_name"))
  1358.  
  1359. --_itm.name:SetText(name)
  1360. _itm.sect:SetText(spawntbl[i])
  1361.  
  1362. if (is_squad) then
  1363. _itm.no_id = true
  1364. _itm.squad = true
  1365. elseif (cant_spawn_actor) then
  1366. _itm.no_id = true
  1367. elseif (is_veh) then
  1368. _itm.no_id = true
  1369. _itm.spawn_at_look = true
  1370. elseif (is_anom) then
  1371. _itm.no_id = true
  1372. _itm.spawn_at_look = true
  1373. _itm.is_anom = true
  1374. elseif (is_phantom) then
  1375. _itm.no_id = true
  1376. _itm.spawn_at_look = true
  1377. _itm.use_level_spawn = true
  1378. end
  1379.  
  1380. self.spawn_list:AddExistingItem(_itm)
  1381. end
  1382. end
  1383. end
  1384.  
  1385. function debug_ui:FillEditorList(name)
  1386. self.editor_icon:SetTextureRect(Frect():set(0,0,0,0))
  1387.  
  1388. if not (name) then
  1389. self:SendOutput("UIEditor: No spawn table could be created for %s",name)
  1390. return
  1391. end
  1392.  
  1393. self.editor_spawn_list:Clear()
  1394.  
  1395. local spawntbl = get_spawn_table(name)
  1396.  
  1397. if not (spawntbl) then
  1398. self:SendOutput("UIEditor: No spawn table could be created for %s",name)
  1399. return
  1400. end
  1401.  
  1402. local ini = system_ini()
  1403.  
  1404. table.sort(spawntbl)
  1405. for i = 1, #spawntbl do
  1406. if (ini:section_exist(spawntbl[i])) then
  1407. local _itm = set_list_text(22)
  1408. _itm.sect:SetText(spawntbl[i])
  1409. self.editor_spawn_list:AddExistingItem(_itm)
  1410. end
  1411. end
  1412. end
  1413.  
  1414. function debug_ui:FillLevelList()
  1415. local levels = alun_utils.collect_section(game_ini(),"level_maps_single")
  1416. for i,level in pairs(levels) do
  1417. local _itm = set_list_text(22)
  1418. _itm.sect:SetText(game.translate_string(level))
  1419. _itm.name = level
  1420. self.levels_list:AddExistingItem(_itm)
  1421. end
  1422. end
  1423.  
  1424. function debug_ui:JumpLevel()
  1425. local item
  1426. item = self.levels_list:GetSelectedItem()
  1427. if not(item) then
  1428. self:SendOutput("UIAdvanced: No level was selected in the list.")
  1429. return
  1430. end
  1431.  
  1432. self:OnQuit()
  1433.  
  1434. _G.JumpToLevel(item.name)
  1435. end
  1436.  
  1437. function debug_ui:OnSelectSectionList()
  1438. self:FillList(self.sections_list:GetText())
  1439. end
  1440.  
  1441. function debug_ui:OnSelectEditorSectionList()
  1442. self:FillEditorList(self.editor_sections_list:GetText())
  1443. end
  1444.  
  1445. function debug_ui:OnButton_create_clicked()
  1446. if self.spawn_list:GetSize() == 0 then
  1447. self:SendOutput("UISpawner: List is empty.")
  1448. return
  1449. end
  1450.  
  1451. local item
  1452. item = self.spawn_list:GetSelectedItem()
  1453. if not(item) then
  1454. self:SendOutput("UISpawner: No item section was selected in the list.")
  1455. return
  1456. end
  1457.  
  1458. local section = item.sect:GetText()
  1459.  
  1460. if (item.squad) then
  1461. local smart = self.smarts_list:GetText()
  1462. self:spawn_squad(section,smart)
  1463. return
  1464. end
  1465.  
  1466. local pos, lvid, gvid
  1467.  
  1468. if (item.spawn_at_look) then
  1469. gvid = db.actor:game_vertex_id()
  1470. local r = level.get_target_dist and level.get_target_dist() or 3
  1471. pos = vector():set(db.actor:position())
  1472. pos:add(device().cam_dir:mul(r))
  1473. pos = vector():set(pos.x,db.actor:position().y,pos.z)
  1474. lvid = level.vertex_id(pos)
  1475. elseif (self.spawn_pos) then
  1476. pos = self.spawn_pos
  1477. lvid = self.spawn_lvid
  1478. gvid = self.spawn_gvid
  1479. else
  1480. pos = db.actor:position()
  1481. lvid = db.actor:level_vertex_id()
  1482. gvid = db.actor:game_vertex_id()
  1483. end
  1484.  
  1485. if (item.use_level_spawn) then
  1486. if (level.spawn_item) then
  1487. level.spawn_item(section,pos,lvid,65535,false)
  1488. self:SendOutput("UISpawner: Spawned")
  1489. end
  1490. return
  1491. end
  1492.  
  1493. local id = not item.no_id and self.check_to_actor:GetCheck() and 0
  1494. local se_obj
  1495. if (id) then
  1496. se_obj = alife():create(section, vector(), 0, 0, id)
  1497. else
  1498. se_obj = alife():create(section, pos, lvid, gvid)
  1499. end
  1500.  
  1501. if not (se_obj) then
  1502. self:SendOutput("UISpawner: Failure to create item with alife create method %s",section)
  1503. return
  1504. end
  1505.  
  1506. if (item.is_anom) then
  1507. local data = stpk_utils.get_anom_zone_data(se_obj)
  1508. if (data) then
  1509. data.object_flags = 31
  1510. --data.artefact_spawn_count = 1
  1511. data.restrictor_type = 0
  1512. data.shapes = {}
  1513. data.shapes[1] = {}
  1514. data.shapes[1].shtype = 0
  1515. data.shapes[1].offset = vector():set(0,0,0)
  1516. data.shapes[1].radius = 5
  1517. stpk_utils.set_anom_zone_data(data,se_obj)
  1518. end
  1519. end
  1520.  
  1521. self:SendOutput("UISpawner: Spawned %s on %s as id %s",se_obj:name(),id == 0 and "Actor" or "level",se_obj.id)
  1522. end
  1523.  
  1524. function debug_ui:OnEditorTriggerAddonSectionSelection()
  1525. local item
  1526. item = self.editor_spawn_list:GetSelectedItem()
  1527. if not(item) then
  1528. self:SendOutput("UIEditor: No item section was selected in the list.")
  1529. return
  1530. end
  1531.  
  1532. local section = item.sect:GetText()
  1533. local ini = system_ini()
  1534. if not (ini:section_exist(section)) then
  1535. self:SendOutput(strformat("UIEditor: Section %s does not exist",section))
  1536. return
  1537. end
  1538.  
  1539. local addon_sec = self.addon_list:GetText()
  1540. if not (addon_sec and addon_sec ~= "" and addon_sec ~= "Select Attachment" and ini:section_exist(addon_sec)) then
  1541. self.editor_icon_addon:SetTextureRect(Frect():set(0,0,0,0))
  1542. self.fld_addon_offset_x:SetText("")
  1543. self.fld_addon_offset_y:SetText("")
  1544. return
  1545. end
  1546.  
  1547. local scope_sec = section
  1548. local ind = self.addon_list:CurrentID()
  1549. if (self._addons[ind] == "scope" and self._scopes[ind]) then
  1550. local s = alun_utils.read_from_ini(ini,self._scopes[ind],self._addons[ind].."_name","string")
  1551. addon_sec = s or addon_sec
  1552. scope_sec = self._scopes[ind] or section
  1553. end
  1554.  
  1555. local scale = 0.75
  1556.  
  1557. local addon_inv_grid_width = alun_utils.read_from_ini(ini,addon_sec,"inv_grid_width","float",0)
  1558. local addon_inv_grid_height = alun_utils.read_from_ini(ini,addon_sec,"inv_grid_height","float",0)
  1559. local addon_inv_grid_x = alun_utils.read_from_ini(ini,addon_sec,"inv_grid_x","float",0)
  1560. local addon_inv_grid_y = alun_utils.read_from_ini(ini,addon_sec,"inv_grid_y","float",0)
  1561.  
  1562. local addon_x1 = addon_inv_grid_x*50
  1563. local addon_y1 = addon_inv_grid_y*50
  1564.  
  1565. local addon_w = addon_inv_grid_width*50
  1566. local addon_h = addon_inv_grid_height*50
  1567.  
  1568. local addon_x2 = addon_x1 + addon_w
  1569. local addon_y2 = addon_y1 + addon_h
  1570.  
  1571. local offset_x = alun_utils.read_from_ini(ini,scope_sec,self._addons[ind].."_x","float",0)
  1572. local offset_y = alun_utils.read_from_ini(ini,scope_sec,self._addons[ind].."_y","float",0)
  1573.  
  1574. self.editor_icon_addon:InitTexture("ui\\ui_icon_equipment")
  1575. self.editor_icon_addon:SetTextureRect(Frect():set(addon_x1,addon_y1,addon_x2,addon_y2))
  1576. self.editor_icon_addon:SetWndSize(vector2():set(addon_w*scale,addon_h*scale))
  1577.  
  1578. pos = self.editor_icon:GetWndPos()
  1579. self.editor_icon_addon:SetWndPos(vector2():set(pos.x+offset_x*scale,pos.y+offset_y*scale))
  1580.  
  1581. self.fld_addon_offset_x:SetText(tostring(offset_x))
  1582. self.fld_addon_offset_y:SetText(tostring(offset_y))
  1583. end
  1584.  
  1585.  
  1586. function debug_ui:OnEditorTriggerSectionSelection()
  1587.  
  1588. self.editor_icon:SetTextureRect(Frect():set(0,0,0,0))
  1589. self.editor_icon_addon:SetTextureRect(Frect():set(0,0,0,0))
  1590.  
  1591. if self.editor_spawn_list:GetSize() == 0 then
  1592. self:SendOutput("UIEditor: List is empty.")
  1593. return
  1594. end
  1595.  
  1596. local item
  1597. item = self.editor_spawn_list:GetSelectedItem()
  1598. if not(item) then
  1599. self:SendOutput("UIEditor: No item section was selected in the list.")
  1600. return
  1601. end
  1602.  
  1603. local section = item.sect:GetText()
  1604. local ini = system_ini()
  1605. if not (ini:section_exist(section)) then
  1606. self:SendOutput(strformat("UIEditor: Section %s does not exist",section))
  1607. return
  1608. end
  1609.  
  1610. self._addons = {} -- temp
  1611. self._scopes = {} -- temp
  1612.  
  1613. self.addon_list:ClearList()
  1614. self.addon_list:AddItem("Select Attachment",0) -- default
  1615. self._addons[0] = "none"
  1616.  
  1617. -----------------------
  1618. local scale = 0.75
  1619.  
  1620. local inv_grid_width = alun_utils.read_from_ini(ini,section,"inv_grid_width","float",0)
  1621. local inv_grid_height = alun_utils.read_from_ini(ini,section,"inv_grid_height","float",0)
  1622. local inv_grid_x = alun_utils.read_from_ini(ini,section,"inv_grid_x","float",0)
  1623. local inv_grid_y = alun_utils.read_from_ini(ini,section,"inv_grid_y","float",0)
  1624.  
  1625. self.editor_old_x = inv_grid_x
  1626. self.editor_old_y = inv_grid_y
  1627. self.editor_old_w = inv_grid_width
  1628. self.editor_old_h = inv_grid_height
  1629.  
  1630. local x1 = inv_grid_x*50
  1631. local y1 = inv_grid_y*50
  1632.  
  1633. local w = inv_grid_width*50
  1634. local h = inv_grid_height*50
  1635.  
  1636. local x2 = x1 + w
  1637. local y2 = y1 + h
  1638.  
  1639. self.editor_icon:InitTexture("ui\\ui_icon_equipment")
  1640. self.editor_icon:SetTextureRect(Frect():set(x1,y1,x2,y2))
  1641. self.editor_icon:SetWndSize(vector2():set(w*scale,h*scale))
  1642.  
  1643. self.fld_icon_x:SetText(tostring(inv_grid_x))
  1644. self.fld_icon_y:SetText(tostring(inv_grid_y))
  1645.  
  1646. self.fld_icon_width:SetText(tostring(inv_grid_width))
  1647. self.fld_icon_height:SetText(tostring(inv_grid_height))
  1648.  
  1649. local pos = self.ui_icon_equipment:GetWndPos()
  1650. self.icon_square:SetWndPos(vector2():set( pos.x+x1/4 , pos.y+y1/4 ))
  1651. self.icon_square:SetWndSize(vector2():set(w/4,h/4))
  1652.  
  1653. -- attachments
  1654. local silencer = alun_utils.read_from_ini(ini,section,"silencer_name","string")
  1655. local grenade_launcher = alun_utils.read_from_ini(ini,section,"grenade_launcher_name","string")
  1656.  
  1657. local ind = 1
  1658. if (silencer and ini:section_exist(silencer)) then
  1659. self.addon_list:AddItem(silencer,ind)
  1660. self._addons[ind] = "silencer"
  1661. ind = ind + 1
  1662. end
  1663.  
  1664. if (grenade_launcher and ini:section_exist(grenade_launcher)) then
  1665. self.addon_list:AddItem(grenade_launcher,ind)
  1666. self._addons[ind] = "grenade_launcher"
  1667. ind = ind + 1
  1668. end
  1669.  
  1670. local scopes = alun_utils.parse_list(ini,section,"scopes_sect")
  1671. if (scopes and #scopes > 0) then
  1672. for k,v in pairs(scopes) do
  1673. self.addon_list:AddItem(v,ind)
  1674. self._scopes[ind] = v
  1675. self._addons[ind] = "scope"
  1676. ind = ind + 1
  1677. end
  1678. end
  1679.  
  1680. self.editor_icon_addon:SetTextureRect(Frect():set(0,0,0,0))
  1681. self.fld_addon_offset_x:SetText("")
  1682. self.fld_addon_offset_y:SetText("")
  1683. --[[
  1684. local name = self.addon_list:GetText()
  1685. if not (name and name ~= "Select Addon Type") then
  1686. return
  1687. end
  1688.  
  1689. local scopes = name == "scope" and alun_utils.parse_list(ini,section,"scopes_sect")
  1690. local scope_sec = section
  1691. if (scopes and #scopes > 0) then
  1692. scope_sec = scopes[1]
  1693. end
  1694.  
  1695. local addon_sec = alun_utils.read_from_ini(ini,scope_sec,name.."_name","string")
  1696. if not (addon_sec and ini:section_exist(addon_sec)) then
  1697. return
  1698. end
  1699.  
  1700. local addon_inv_grid_width = alun_utils.read_from_ini(ini,addon_sec,"inv_grid_width","float",0)
  1701. local addon_inv_grid_height = alun_utils.read_from_ini(ini,addon_sec,"inv_grid_height","float",0)
  1702. local addon_inv_grid_x = alun_utils.read_from_ini(ini,addon_sec,"inv_grid_x","float",0)
  1703. local addon_inv_grid_y = alun_utils.read_from_ini(ini,addon_sec,"inv_grid_y","float",0)
  1704.  
  1705. local addon_x1 = addon_inv_grid_x*50
  1706. local addon_y1 = addon_inv_grid_y*50
  1707.  
  1708. local addon_w = addon_inv_grid_width*50
  1709. local addon_h = addon_inv_grid_height*50
  1710.  
  1711. local addon_x2 = addon_x1 + addon_w
  1712. local addon_y2 = addon_y1 + addon_h
  1713.  
  1714. local offset_x = alun_utils.read_from_ini(ini,scope_sec,name.."_x","float",0)
  1715. local offset_y = alun_utils.read_from_ini(ini,scope_sec,name.."_y","float",0)
  1716.  
  1717. self.editor_old_offset_x = offset_x
  1718. self.editor_old_offset_y = offset_y
  1719.  
  1720. self.editor_icon_addon:InitTexture("ui\\ui_icon_equipment")
  1721. self.editor_icon_addon:SetTextureRect(Frect():set(addon_x1,addon_y1,addon_x2,addon_y2))
  1722. self.editor_icon_addon:SetWndSize(vector2():set(addon_w*scale,addon_h*scale))
  1723.  
  1724. pos = self.editor_icon:GetWndPos()
  1725. self.editor_icon_addon:SetWndPos(vector2():set(pos.x+offset_x*scale,pos.y+offset_y*scale))
  1726.  
  1727. self.fld_addon_offset_x:SetText(tostring(offset_x))
  1728. self.fld_addon_offset_y:SetText(tostring(offset_y))
  1729. --]]
  1730. end
  1731.  
  1732. function debug_ui:OnEditIconX()
  1733. local v = tonumber(self.fld_icon_x:GetText())
  1734. if (v and v ~= self.editor_old_x) then
  1735. self.need_save_x = true
  1736. end
  1737.  
  1738. self:OnEditIcon()
  1739. end
  1740.  
  1741. function debug_ui:OnEditIconY()
  1742. local v = tonumber(self.fld_icon_y:GetText())
  1743. if (v and v ~= self.editor_old_y) then
  1744. self.need_save_y = true
  1745. end
  1746.  
  1747. self:OnEditIcon()
  1748. end
  1749.  
  1750. function debug_ui:OnEditIconW()
  1751. local v = tonumber(self.fld_icon_width:GetText())
  1752. if (v and v ~= self.editor_old_w) then
  1753. self.need_save_w = true
  1754. end
  1755.  
  1756. self:OnEditIcon()
  1757. end
  1758.  
  1759. function debug_ui:OnEditIconH()
  1760. local v = tonumber(self.fld_icon_height:GetText())
  1761. if (v and v ~= self.editor_old_h) then
  1762. self.need_save_h = true
  1763. end
  1764.  
  1765. self:OnEditIcon()
  1766. end
  1767.  
  1768. function debug_ui:OnEditIconOffX()
  1769. local v = tonumber(self.fld_addon_offset_x:GetText())
  1770. if (v and v ~= self.editor_old_offset_x) then
  1771. self.need_save_offset_x = true
  1772. end
  1773. self:OnEditIcon()
  1774. end
  1775.  
  1776. function debug_ui:OnEditIconOffY()
  1777. local v = tonumber(self.fld_addon_offset_y:GetText())
  1778. if (v and v ~= self.editor_old_offset_y) then
  1779. self.need_save_offset_y = true
  1780. end
  1781. self:OnEditIcon()
  1782. end
  1783.  
  1784. function debug_ui:OnEditIcon()
  1785.  
  1786. local x1 = tonumber(self.fld_icon_x:GetText())
  1787. local y1 = x1 and tonumber(self.fld_icon_y:GetText())
  1788.  
  1789. local w = y1 and tonumber(self.fld_icon_width:GetText())
  1790. local h = w and tonumber(self.fld_icon_height:GetText())
  1791.  
  1792. if not (x1 and y1 and w and h) then
  1793. return
  1794. end
  1795.  
  1796. local scale = 0.75
  1797.  
  1798. x1 = x1*50
  1799. y1 = y1*50
  1800. w = w*50
  1801. h = h*50
  1802.  
  1803. local x2 = x1 + w
  1804. local y2 = y1 + h
  1805.  
  1806. --self.editor_icon:InitTexture("ui\\ui_icon_equipment")
  1807. self.editor_icon:SetTextureRect(Frect():set(x1,y1,x2,y2))
  1808. self.editor_icon:SetWndSize(vector2():set(w*scale,h*scale))
  1809.  
  1810. local pos = self.ui_icon_equipment:GetWndPos()
  1811. self.icon_square:SetWndPos(vector2():set( pos.x+x1/4 , pos.y+y1/4 ))
  1812. self.icon_square:SetWndSize(vector2():set(w/4,h/4))
  1813.  
  1814. local name = self.addon_list:GetText()
  1815. if not (name and name ~= "" and name ~= "Select Attachment") then
  1816. self.editor_icon_addon:SetTextureRect(Frect():set(0,0,0,0))
  1817. self.fld_addon_offset_x:SetText("")
  1818. self.fld_addon_offset_y:SetText("")
  1819. return
  1820. end
  1821.  
  1822. local offset_x = tonumber(self.fld_addon_offset_x:GetText())
  1823. local offset_y = offset_x and tonumber(self.fld_addon_offset_y:GetText())
  1824.  
  1825. if not (offset_y) then
  1826. self.editor_icon_addon:SetTextureRect(Frect():set(0,0,0,0))
  1827. self.fld_addon_offset_x:SetText("")
  1828. self.fld_addon_offset_y:SetText("")
  1829. return
  1830. end
  1831.  
  1832. pos = self.editor_icon:GetWndPos()
  1833. self.editor_icon_addon:SetWndPos(vector2():set(pos.x+offset_x*scale,pos.y+offset_y*scale))
  1834. end
  1835.  
  1836. function debug_ui:OnEditorSave()
  1837. if not (self.need_save_x or self.need_save_y or self.need_save_w or self.need_save_h or self.need_save_offset_x or self.need_save_offset_y) then
  1838. return
  1839. end
  1840.  
  1841. local x1 = tonumber(self.fld_icon_x:GetText())
  1842. local y1 = x1 and tonumber(self.fld_icon_y:GetText())
  1843.  
  1844. local w = y1 and tonumber(self.fld_icon_width:GetText())
  1845. local h = w and tonumber(self.fld_icon_height:GetText())
  1846.  
  1847. if not (h) then
  1848. return
  1849. end
  1850.  
  1851. local offset_x = tonumber(self.fld_addon_offset_x:GetText())
  1852. local offset_y = offset_x and tonumber(self.fld_addon_offset_y:GetText())
  1853.  
  1854. local item = self.editor_spawn_list:GetSelectedItem()
  1855. if not(item) then
  1856. self:SendOutput("UIEditorSave: No item section was selected in the list.")
  1857. return
  1858. end
  1859.  
  1860. local section = item.sect:GetText()
  1861. local ini = system_ini()
  1862. if not (ini:section_exist(section)) then
  1863. self:SendOutput(strformat("UIEditorSave: Section %s does not exist",section))
  1864. return
  1865. end
  1866.  
  1867. local ind = self.addon_list:CurrentID()
  1868. local addon_sec = self.addon_list:GetTextOf(ind)
  1869. if (addon_sec == nil or addon_sec == "" or addon_sec == "Select Attachment") then
  1870. addon_sec = nil
  1871. self.need_save_offset_x = nil
  1872. self.need_save_offset_y = nil
  1873. ind = 0
  1874. end
  1875.  
  1876. local search_sec = self._addons[ind] == "scope" and self._scopes[ind] or section
  1877.  
  1878. local function file_exists(path)
  1879. return io.open(path) ~= nil
  1880. end
  1881.  
  1882. local function on_execute(path,filename,quit)
  1883. local fullpath = path.."\\"..filename
  1884. local ltx = io.open(fullpath,"rb")
  1885. if (ltx) then
  1886. local data = ltx:read("*all")
  1887. ltx:close()
  1888. if (data) then
  1889. if (string.find(data,"["..section.."]",nil,true)) then
  1890. ltx = alun_utils.cfg_file(fullpath)
  1891. if (ltx) then
  1892. if (self.need_save_x) then
  1893. ltx:SetValue(section,"inv_grid_x",x1)
  1894. end
  1895. if (self.need_save_y) then
  1896. ltx:SetValue(section,"inv_grid_y",y1)
  1897. end
  1898. if (self.need_save_w) then
  1899. ltx:SetValue(section,"inv_grid_width",w)
  1900. end
  1901. if (self.need_save_h) then
  1902. ltx:SetValue(section,"inv_grid_height",h)
  1903. end
  1904. ltx:SaveExt()
  1905. end
  1906. end
  1907. if (self.need_save_offset_x or self.need_save_offset_y) and (string.find(data,"["..search_sec.."]",nil,true)) then
  1908. ltx = alun_utils.cfg_file(fullpath)
  1909. if (ltx) then
  1910. if (self.need_save_offset_x) then
  1911. ltx:SetValue(search_sec,self._addons[ind].."_x",offset_x)
  1912. end
  1913. if (self.need_save_offset_y) then
  1914. ltx:SetValue(search_sec,self._addons[ind].."_y",offset_y)
  1915. end
  1916. ltx:SaveExt()
  1917. end
  1918. end
  1919. end
  1920. end
  1921. end
  1922.  
  1923. local sp = getFS():update_path('$game_config$', '')
  1924. sp = string.sub(sp,0,string.len(sp)-1)
  1925. lua_extensions.recurse_subdirectories_and_execute(sp,{"ltx"},on_execute)
  1926.  
  1927. if (reload_system_ini) then
  1928. reload_system_ini()
  1929. end
  1930.  
  1931. self.need_save_x = nil
  1932. self.need_save_y = nil
  1933. self.need_save_w = nil
  1934. self.need_save_h = nil
  1935. self.need_save_offset_x = nil
  1936. self.need_save_offset_y = nil
  1937. end
  1938.  
  1939.  
  1940. -- SPAWNER UI
  1941. class "debug_ui_spawner" (CUIWindow)
  1942. function debug_ui_spawner:__init(owner, binds) super()
  1943. self.owner = owner
  1944. end
  1945. function debug_ui_spawner:__finalize()
  1946.  
  1947. end
  1948.  
  1949. function debug_ui_spawner:InitControls(x, y, xml, owner)
  1950. self:SetWndPos(vector2():set(x-50,y))
  1951. self:SetWndSize(vector2():set(800,416))
  1952. self:SetAutoDelete(true)
  1953.  
  1954. owner.sections_list = xml:InitComboBox("tab_spawner:list_sections", self)
  1955. owner.sections_list:ClearList()
  1956. owner.sections_list:SetAutoDelete(true)
  1957.  
  1958. for i=1,#id_to_spawn_table do
  1959. owner.sections_list:AddItem(id_to_spawn_table[i],i-1)
  1960. end
  1961.  
  1962. owner:Register(owner.sections_list, "list_sections")
  1963.  
  1964. owner.spawn_list_frame = xml:InitFrame("tab_spawner:list_frame",self)
  1965. owner.spawn_list = xml:InitListBox("tab_spawner:list",self)
  1966. owner.spawn_list:ShowSelectedItem(true)
  1967.  
  1968. owner:Register(owner.spawn_list, "list_window")
  1969.  
  1970. owner.check_to_actor = xml:InitCheck("tab_spawner:check_own_to_actor",self)
  1971. owner.check_to_actor:SetCheck(true)
  1972.  
  1973. --local ctrl = xml:Init3tButton("tab_spawner:btn_create",self)
  1974. --owner:Register(ctrl, "btn_create")
  1975.  
  1976.  
  1977. owner.smarts_list = xml:InitComboBox("tab_spawner:list_smarts", self)
  1978. owner.smarts_list:ClearList()
  1979. owner.smarts_list:SetAutoDelete(true)
  1980.  
  1981. local sim = alife()
  1982. local actor_level = sim:level_name(game_graph():vertex(sim:actor().m_game_vertex_id):level_id())
  1983. local board = SIMBOARD
  1984. local smrts = {}
  1985. for id,t in pairs(board.smarts) do
  1986. if (t.smrt and actor_level == t.smrt.smart_level) then
  1987. smrts[#smrts+1] = t.smrt:name()
  1988. end
  1989. end
  1990.  
  1991. table.sort(smrts)
  1992. for i=1,#smrts do
  1993. owner.smarts_list:AddItem(smrts[i],i)
  1994. end
  1995.  
  1996. owner.smarts_list:SetText("Squad to Smart")
  1997.  
  1998. --owner.smarts_list:Show(false)
  1999.  
  2000. owner.smarts_list_cap = xml:InitStatic("tab_spawner:cap_smarts", self)
  2001.  
  2002. --owner:Register(owner.smarts_list, "list_smarts")
  2003.  
  2004. -- Set defaults
  2005. owner.sections_list:SetText("Spawn Sections")
  2006. --owner:FillList("Weapons (Rifle)")
  2007.  
  2008. ------------------------- manual input
  2009. xml:InitStatic("tab_spawner:cap_spawn", self)
  2010. owner.fld_spawn = xml:InitEditBox("tab_spawner:fld_spawn", self)
  2011.  
  2012. btn = xml:Init3tButton("tab_spawner:btn_spawn",self)
  2013. owner:Register(btn, "btn_spawn")
  2014.  
  2015. xml:InitStatic("tab_spawner:cap_spawn_squad", self)
  2016. owner.fld_spawn_squad = xml:InitEditBox("tab_spawner:fld_spawn_squad", self)
  2017.  
  2018. xml:InitStatic("tab_spawner:cap_spawn_smart", self)
  2019. owner.fld_spawn_smart = xml:InitEditBox("tab_spawner:fld_spawn_smart", self)
  2020.  
  2021. btn = xml:Init3tButton("tab_spawner:btn_spawn_squad",self)
  2022. owner:Register(btn, "btn_spawn_squad")
  2023. end
  2024.  
  2025. -- HUD UI
  2026. class "debug_ui_hud" (CUIWindow)
  2027. function debug_ui_hud:__init(owner, binds) super()
  2028. self.owner = owner
  2029. end
  2030. function debug_ui_hud:__finalize()
  2031.  
  2032. end
  2033. function debug_ui_hud:InitControls(x, y, xml, owner)
  2034. self:SetWndPos(vector2():set(x,y))
  2035. self:SetWndSize(vector2():set(800,416))
  2036. self:SetAutoDelete(true)
  2037.  
  2038. xml:InitStatic("tab_hud:cap_focus", self)
  2039. owner.fld_focus = xml:InitEditBox("tab_hud:fld_focus", self)
  2040.  
  2041. local btn = xml:Init3tButton("tab_hud:btn_focus",self)
  2042. owner:Register(btn, "btn_focus")
  2043. end
  2044.  
  2045. -- object UI
  2046. class "debug_ui_object" (CUIWindow)
  2047. function debug_ui_object:__init(owner, binds) super()
  2048. self.owner = owner
  2049. end
  2050. function debug_ui_object:__finalize()
  2051.  
  2052. end
  2053. function debug_ui_object:InitControls(x, y, xml, owner)
  2054. self:SetWndPos(vector2():set(x,y))
  2055. self:SetWndSize(vector2():set(800,416))
  2056. self:SetAutoDelete(true)
  2057.  
  2058. xml:InitStatic("tab_object:cap_find", self)
  2059. owner.fld_find = xml:InitEditBox("tab_object:fld_find", self)
  2060.  
  2061. local btn
  2062. btn = xml:Init3tButton("tab_object:btn_find",self)
  2063. owner:Register(btn, "btn_find")
  2064.  
  2065. xml:InitStatic("tab_object:cap_id", self)
  2066. owner.fld_id = xml:InitEditBox("tab_object:fld_id", self)
  2067.  
  2068. xml:InitStatic("tab_object:cap_section", self)
  2069. owner.fld_section = xml:InitEditBox("tab_object:fld_section", self)
  2070.  
  2071. xml:InitStatic("tab_object:cap_logic", self)
  2072. owner.fld_logic = xml:InitEditBox("tab_object:fld_logic", self)
  2073.  
  2074. xml:InitStatic("tab_object:cap_filename", self)
  2075. owner.fld_filename = xml:InitEditBox("tab_object:fld_filename", self)
  2076.  
  2077. btn = xml:Init3tButton("tab_object:btn_set",self)
  2078. owner:Register(btn, "btn_set")
  2079.  
  2080. btn = xml:Init3tButton("tab_object:btn_revert",self)
  2081. owner:Register(btn, "btn_revert")
  2082.  
  2083. xml:InitStatic("tab_object:cap_reload", self)
  2084. owner.fld_reload = xml:InitEditBox("tab_object:fld_reload", self)
  2085.  
  2086. btn = xml:Init3tButton("tab_object:btn_reload",self)
  2087. owner:Register(btn, "btn_reload")
  2088. end
  2089.  
  2090. -- ADVANCED UI
  2091. class "debug_ui_advanced" (CUIWindow)
  2092. function debug_ui_advanced:__init(owner, binds) super()
  2093. self.owner = owner
  2094. end
  2095. function debug_ui_advanced:__finalize()
  2096.  
  2097. end
  2098. function debug_ui_advanced:InitControls(x, y, xml, owner)
  2099. self:SetWndPos(vector2():set(x,y))
  2100. self:SetWndSize(vector2():set(800,416))
  2101. self:SetAutoDelete(true)
  2102.  
  2103. xml:InitStatic("tab_advanced:cap_execute_string", self)
  2104. owner.fld_execute_string = xml:InitEditBox("tab_advanced:fld_execute_string", self)
  2105.  
  2106. local btn = xml:Init3tButton("tab_advanced:btn_execute_string",self)
  2107. owner:Register(btn, "btn_execute_string")
  2108.  
  2109. xml:InitStatic("tab_advanced:cap_jump_level", self)
  2110.  
  2111. owner.levels_list_frame = xml:InitFrame("tab_advanced:list_frame",self)
  2112. owner.levels_list = xml:InitListBox("tab_advanced:list",self)
  2113. owner.levels_list:ShowSelectedItem(true)
  2114.  
  2115. owner:Register(owner.levels_list, "list_levels_window")
  2116.  
  2117. owner:FillLevelList()
  2118. end
  2119.  
  2120. -- ICON EDITOR
  2121. class "debug_ui_editor" (CUIWindow)
  2122. function debug_ui_editor:__init(owner, binds) super()
  2123. self.owner = owner
  2124. end
  2125. function debug_ui_editor:__finalize()
  2126.  
  2127. end
  2128. function debug_ui_editor:InitControls(x, y, xml, owner)
  2129. self:SetWndPos(vector2():set(x-50,y))
  2130. self:SetWndSize(vector2():set(800,416))
  2131. self:SetAutoDelete(true)
  2132.  
  2133. owner.editor_sections_list = xml:InitComboBox("tab_editor:list_sections", self)
  2134. owner.editor_sections_list:ClearList()
  2135. owner.editor_sections_list:SetAutoDelete(true)
  2136.  
  2137. local invalid_ids = {[6] = true , [7] = true, [9] = true, [10] = true, [11] = true}
  2138. for i=1,#id_to_spawn_table do
  2139. if not (invalid_ids[i]) then
  2140. owner.editor_sections_list:AddItem(id_to_spawn_table[i],i-1)
  2141. end
  2142. end
  2143.  
  2144. owner:Register(owner.editor_sections_list, "editor_list_sections")
  2145.  
  2146. owner.editor_spawn_list_frame = xml:InitFrame("tab_editor:list_frame",self)
  2147. owner.editor_spawn_list = xml:InitListBox("tab_editor:list",self)
  2148. owner.editor_spawn_list:ShowSelectedItem(true)
  2149.  
  2150. owner:Register(owner.editor_spawn_list, "editor_list_window")
  2151.  
  2152. owner.editor_icon_back = xml:InitStatic("tab_editor:icon_back",self)
  2153. owner.editor_icon = xml:InitStatic("tab_editor:icon",self)
  2154.  
  2155. -- Set defaults
  2156. owner.editor_sections_list:SetText("Weapons (Rifle)")
  2157. owner:FillEditorList("Weapons (Rifle)")
  2158.  
  2159.  
  2160. -------
  2161. xml:InitStatic("tab_editor:cap_w", self)
  2162. owner.fld_icon_width = xml:InitEditBox("tab_editor:fld_w", self)
  2163. owner:Register(owner.fld_icon_width,"fld_icon_width")
  2164.  
  2165. xml:InitStatic("tab_editor:cap_h", self)
  2166. owner.fld_icon_height = xml:InitEditBox("tab_editor:fld_h", self)
  2167. owner:Register(owner.fld_icon_height,"fld_icon_height")
  2168.  
  2169. xml:InitStatic("tab_editor:cap_x", self)
  2170. owner.fld_icon_x = xml:InitEditBox("tab_editor:fld_x", self)
  2171. owner:Register(owner.fld_icon_x,"fld_icon_x")
  2172.  
  2173. xml:InitStatic("tab_editor:cap_y", self)
  2174. owner.fld_icon_y = xml:InitEditBox("tab_editor:fld_y", self)
  2175. owner:Register(owner.fld_icon_y,"fld_icon_y")
  2176.  
  2177.  
  2178. owner.ui_icon_equipment_back = xml:InitFrame("ui_icon_equipment_back",owner)
  2179. owner.ui_icon_equipment = xml:InitStatic("ui_icon_equipment",owner)
  2180. owner.ui_icon_equipment:InitTexture("ui\\ui_icon_equipment")
  2181. --owner.ui_icon_equipment:SetTextureRect(Frect():set(0,0,300,200))
  2182. owner.ui_icon_equipment:SetWndSize(vector2():set(512,512))
  2183. owner.ui_icon_equipment_back:SetWndSize(vector2():set(448,540))
  2184.  
  2185.  
  2186. owner.icon_square = xml:InitFrame("square",owner)
  2187.  
  2188. xml:InitStatic("tab_editor:cap_addon_x", self)
  2189. owner.fld_addon_offset_x = xml:InitEditBox("tab_editor:fld_addon_x", self)
  2190. owner:Register(owner.fld_addon_offset_x,"fld_addon_offset_x")
  2191.  
  2192. xml:InitStatic("tab_editor:cap_addon_y", self)
  2193. owner.fld_addon_offset_y = xml:InitEditBox("tab_editor:fld_addon_y", self)
  2194. owner:Register(owner.fld_addon_offset_y,"fld_addon_offset_y")
  2195.  
  2196. owner.addon_list = xml:InitComboBox("tab_editor:list_addon", self)
  2197. owner:Register(owner.addon_list, "editor_list_addon")
  2198. local t = {"Select Addon Type", "silencer", "grenade_launcher", "scope" }
  2199. for i=1,#t do
  2200. owner.addon_list:AddItem(t[i],i-1)
  2201. end
  2202.  
  2203. owner.addon_list:SetText("Select Addon Type")
  2204.  
  2205. owner.editor_icon_addon = xml:InitStatic("tab_editor:icon_addon",self)
  2206.  
  2207. local btn = xml:Init3tButton("tab_editor:btn_save",self)
  2208. owner:Register(btn, "btn_editor_save")
  2209. end
  2210.  
  2211. ---------------------------------------------------- Attach Offsets
  2212. local _attached
  2213. local _last_section
  2214.  
  2215. class "debug_ui_attach" (CUIScriptWnd)
  2216. function debug_ui_attach:__init(owner, binds) super()
  2217. self:SetWndRect (Frect():set(0,0,1024,768))
  2218. self:Enable (true)
  2219.  
  2220. local xml = CScriptXmlInit()
  2221. self.xml = xml
  2222. xml:ParseFile ("ui_debug_main.xml")
  2223.  
  2224. self:SetAutoDelete(true)
  2225. self.owner = owner
  2226. self.need_save = {}
  2227.  
  2228. local ctrl = CUIWindow()
  2229. self.xml:InitWindow("wnd_attach_editor:file_item:main",0,ctrl)
  2230. self.form = self.xml:InitStatic("wnd_attach_editor:form",self)
  2231. self.xml:InitFrame("wnd_attach_editor:form:list_frame",self.form)
  2232.  
  2233. ctrl = self.xml:Init3tButton("wnd_attach_editor:form:btn_attach",self.form)
  2234. self:Register(ctrl, "button_attach_npc")
  2235. self:AddCallback("button_attach_npc", ui_events.BUTTON_CLICKED, self.OnAttach, self)
  2236.  
  2237. --[[
  2238. ctrl = self.xml:Init3tButton("wnd_attach_editor:form:btn_save",self.form)
  2239. self:Register(ctrl, "button_attach_save")
  2240. self:AddCallback("button_attach_save", ui_events.BUTTON_CLICKED, self.OnAttachSave, self)
  2241. --]]
  2242.  
  2243. xml:InitStatic("wnd_attach_editor:form:cap_pos", self.form)
  2244. xml:InitStatic("wnd_attach_editor:form:cap_angle", self.form)
  2245.  
  2246. self.flds = {"x","y","z","rot_x","rot_y","rot_z"}
  2247. for i=1,#self.flds do
  2248. xml:InitStatic("wnd_attach_editor:form:cap_"..self.flds[i], self.form)
  2249. self["fld_attach_"..self.flds[i]] = xml:InitEditBox("wnd_attach_editor:form:fld_"..self.flds[i], self.form)
  2250. self:Register(self["fld_attach_"..self.flds[i]],"fld_attach_"..self.flds[i])
  2251.  
  2252. self:AddCallback("fld_attach_"..self.flds[i], ui_events.EDIT_TEXT_COMMIT, self["On_fld_attach_"..self.flds[i]], self)
  2253. end
  2254.  
  2255. self.attachable = xml:InitComboBox("wnd_attach_editor:form:list_attach", self.form)
  2256. self:Register(self.attachable, "attach_list")
  2257. self:AddCallback("attach_list", ui_events.LIST_ITEM_SELECT, self.OnAttachListSelect,self)
  2258.  
  2259. local sys_ini = system_ini()
  2260. local t = alun_utils.parse_list(sys_ini,"stalker","attachable_items")
  2261. if (#t > 0) then
  2262. for i=1,#t do
  2263. if (sys_ini:section_exist(t[i])) then
  2264. self.attachable:AddItem(t[i],i-1)
  2265. end
  2266. end
  2267. end
  2268.  
  2269. -- TODO:
  2270. -- NOT IMPLEMENTED FULLY YET
  2271. self.weapons = xml:InitComboBox("wnd_attach_editor:form:list_weapons", self.form)
  2272. self:Register(self.weapons, "weapon_list")
  2273. self:AddCallback("weapon_list", ui_events.LIST_ITEM_SELECT, self.OnWeaponListSelect,self)
  2274.  
  2275. local valid_ids = {13,14,15} -- Weapon spawn tables only
  2276.  
  2277. for n=1,#valid_ids do
  2278. local slist = get_spawn_table(id_to_spawn_table[valid_ids[n]])
  2279. if (slist) then
  2280. local cnt = 0
  2281. for i=1,#slist do
  2282. if (sys_ini:section_exist(slist[i])) then
  2283. self.weapons:AddItem(slist[i],cnt)
  2284. cnt = cnt + 1
  2285. end
  2286. end
  2287. end
  2288. end
  2289. end
  2290. function debug_ui_attach:__finalize()
  2291.  
  2292. end
  2293. function debug_ui_attach:OnAttachListSelect()
  2294. self._last = "attach"
  2295. for i=1,#self.flds do
  2296. self.need_save[self.flds[i]] = nil
  2297. end
  2298.  
  2299. local section = self.attachable:GetText()
  2300. if not (section and system_ini():section_exist(section)) then
  2301. return
  2302. end
  2303.  
  2304. local pos = alun_utils.parse_list(system_ini(),section,"attach_position_offset")
  2305. local angle = alun_utils.parse_list(system_ini(),section,"attach_angle_offset")
  2306.  
  2307. if not (#pos > 0) then
  2308. return
  2309. end
  2310.  
  2311. for i=1,#pos do
  2312. if (self["fld_attach_"..self.flds[i]]) then
  2313. self["fld_attach_"..self.flds[i]]:SetText(pos[i])
  2314. end
  2315. end
  2316.  
  2317. if not (#angle > 0) then
  2318. return
  2319. end
  2320.  
  2321. for i=1,#angle do
  2322. if (self["fld_attach_"..self.flds[i+3]]) then
  2323. self["fld_attach_"..self.flds[i+3]]:SetText(angle[i])
  2324. end
  2325. end
  2326. end
  2327. function debug_ui_attach:OnWeaponListSelect()
  2328. self._last = "weapon"
  2329. for i=1,#self.flds do
  2330. self.need_save[self.flds[i]] = nil
  2331. end
  2332.  
  2333. local section = self.weapons:GetText()
  2334. if not (section and system_ini():section_exist(section)) then
  2335. return
  2336. end
  2337.  
  2338. local pos = alun_utils.parse_list(system_ini(),section,"position")
  2339. local angle = alun_utils.parse_list(system_ini(),section,"orientation")
  2340.  
  2341. if not (#pos > 0) then
  2342. return
  2343. end
  2344.  
  2345. for i=1,#pos do
  2346. if (self["fld_attach_"..self.flds[i]]) then
  2347. self["fld_attach_"..self.flds[i]]:SetText(pos[i])
  2348. end
  2349. end
  2350.  
  2351. if not (#angle > 0) then
  2352. return
  2353. end
  2354.  
  2355. for i=1,#angle do
  2356. if (self["fld_attach_"..self.flds[i+3]]) then
  2357. self["fld_attach_"..self.flds[i+3]]:SetText(angle[i])
  2358. end
  2359. end
  2360. end
  2361. function debug_ui_attach:OnAttachSave(section)
  2362. local need_save
  2363. local fld
  2364. local vals = {}
  2365. for i=1,#self.flds do
  2366. fld = self["fld_attach_"..self.flds[i]]
  2367. if not (fld) then
  2368. return
  2369. end
  2370.  
  2371. if not (tonumber(fld:GetText())) then
  2372. return
  2373. end
  2374.  
  2375. if (self.need_save[self.flds[i]] == true) then
  2376. need_save = true
  2377. end
  2378.  
  2379. vals[self.flds[i]] = tonumber(fld:GetText())
  2380. end
  2381.  
  2382. if not (need_save) then
  2383. return
  2384. end
  2385.  
  2386. local function file_exists(path)
  2387. return io.open(path) ~= nil
  2388. end
  2389.  
  2390. local function on_execute(path,filename,quit)
  2391. local fullpath = path.."\\"..filename
  2392. local ltx = io.open(fullpath,"rb")
  2393. if (ltx) then
  2394. local data = ltx:read("*all")
  2395. ltx:close()
  2396. if (data) then
  2397. if (string.find(data,"["..section.."]",nil,true)) then
  2398. ltx = alun_utils.cfg_file(fullpath)
  2399. if (ltx) then
  2400. if (self._last == "attach") then
  2401. if (self.need_save.x or self.need_save.y or self.need_save.z) then
  2402. ltx:SetValue(section,"attach_position_offset",vals.x .. ", " .. vals.y .. ", " .. vals.z)
  2403. end
  2404.  
  2405. if (self.need_save.rot_x or self.need_save.rot_y or self.need_save.rot_z) then
  2406. ltx:SetValue(section,"attach_angle_offset",vals.rot_x .. ", " .. vals.rot_y .. ", " .. vals.rot_z)
  2407. end
  2408. elseif (self._last == "weapon") then
  2409. if (self.need_save.x or self.need_save.y or self.need_save.z) then
  2410. ltx:SetValue(section,"position",vals.x .. ", " .. vals.y .. ", " .. vals.z)
  2411. end
  2412.  
  2413. if (self.need_save.rot_x or self.need_save.rot_y or self.need_save.rot_z) then
  2414. ltx:SetValue(section,"orientation",vals.rot_x .. ", " .. vals.rot_y .. ", " .. vals.rot_z)
  2415. end
  2416. end
  2417.  
  2418. ltx:SaveExt()
  2419. return
  2420. end
  2421. end
  2422. end
  2423. end
  2424. end
  2425.  
  2426. local sp = getFS():update_path('$game_config$', '')
  2427. sp = string.sub(sp,0,string.len(sp)-1)
  2428. lua_extensions.recurse_subdirectories_and_execute(sp,{"ltx"},on_execute)
  2429.  
  2430. if (reload_system_ini) then
  2431. reload_system_ini()
  2432. end
  2433. end
  2434. function debug_ui_attach:On_fld_attach_x()
  2435. self:OnEditAttach("x")
  2436. end
  2437. function debug_ui_attach:On_fld_attach_y()
  2438. self:OnEditAttach("y")
  2439. end
  2440. function debug_ui_attach:On_fld_attach_z()
  2441. self:OnEditAttach("z")
  2442. end
  2443. function debug_ui_attach:On_fld_attach_rot_x()
  2444. self:OnEditAttach("rot_x")
  2445. end
  2446. function debug_ui_attach:On_fld_attach_rot_y()
  2447. self:OnEditAttach("rot_y")
  2448. end
  2449. function debug_ui_attach:On_fld_attach_rot_z()
  2450. self:OnEditAttach("rot_z")
  2451. end
  2452. function debug_ui_attach:OnEditAttach(fld)
  2453. if not (_attached) then
  2454. return
  2455. end
  2456. local section = self._last == "attach" and self.attachable:GetText() or self._last == "weapon" and self.weapons:GetText() or nil
  2457. if not (section and system_ini():section_exist(section)) then
  2458. return
  2459. end
  2460.  
  2461. local itm = level.object_by_id(_attached)
  2462. if not (itm) then
  2463. return
  2464. end
  2465.  
  2466. if not (section == itm:section()) then
  2467. printf("ERROR: ui_debug_main.debug_ui_attach : section in combo box is not same section as item! itm=%s selected=%s",itm:section(),section)
  2468. return
  2469. end
  2470.  
  2471. self.need_save[fld] = true
  2472.  
  2473. self:OnAttachSave(section)
  2474.  
  2475. itm:attachable_item_load_attach(section)
  2476. end
  2477. function debug_ui_attach:OnKeyboard(dik, keyboard_action)
  2478. CUIScriptWnd.OnKeyboard(self,dik,keyboard_action)
  2479. if keyboard_action == ui_events.WINDOW_KEY_RELEASED then
  2480. local keybinds = self.binds or {}
  2481. if (dik == DIK_keys.DIK_ESCAPE) then
  2482. self:OnQuit()
  2483. end
  2484. end
  2485. return true
  2486. end
  2487. local function delayed_attach(id)
  2488. local itm = id and level.object_by_id(id)
  2489. if (itm) then
  2490. itm:enable_attachable_item(true)
  2491. _attached = itm:id()
  2492. return true
  2493. end
  2494. return false
  2495. end
  2496. function debug_ui_attach:OnAttach()
  2497. local npc = xrs_debug_tools.get_debug_npc() or xrs_debug_tools.NEAREST_STALKER
  2498. if not (npc and npc:id() ~= 0) then
  2499. return
  2500. end
  2501.  
  2502. local section = self._last == "attach" and self.attachable:GetText() or self._last == "weapon" and self.weapons:GetText() or nil
  2503. if not (section and system_ini():section_exist(section)) then
  2504. return
  2505. end
  2506.  
  2507. if (_last_section ~= section) then
  2508. _last_section = section
  2509. if (_attached) then
  2510. local itm = level.object_by_id(_attached)
  2511. if (itm) then
  2512. itm:enable_attachable_item(false)
  2513. end
  2514. _attached = nil
  2515. end
  2516. end
  2517.  
  2518. local itm = npc:object(section)
  2519. if not (itm) then
  2520. local se_itm = alife():create(section,npc:position(),npc:level_vertex_id(),npc:game_vertex_id(),npc:id())
  2521. if (se_itm) then
  2522. CreateTimeEvent(se_itm.id,"delayed_attach",1,delayed_attach,se_itm.id)
  2523. end
  2524. else
  2525. if (_attached) then
  2526. itm:enable_attachable_item(false)
  2527. end
  2528. _attached = itm:id()
  2529. CreateTimeEvent(itm:id(),"delayed_attach",1,delayed_attach,itm:id())
  2530. end
  2531. end
  2532. function debug_ui_attach:OnQuit()
  2533. self:HideDialog()
  2534. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement