sceneeditormenu.c 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405
  1. class SceneEditorMenu extends UIScriptedMenu
  2. {
  3. //---------------------------------------------------------------------------------
  4. // >> Public Scope
  5. static const int POPUP_ID_SCENE_MANAGER = 0;
  6. static const int POPUP_ID_SCENE_SETTINGS = 1;
  7. static const int POPUP_ID_SCENE_NEW = 2;
  8. static const int POPUP_ID_SCENE_RENAME = 3;
  9. static const int POPUP_ID_SCENE_DELETE = 4;
  10. static const int POPUP_ID_NOTIFY = 5;
  11. static const int POPUP_ID_EDITOR_SETTINGS = 6;
  12. static const int POPUP_ID_INIT_SCRIPT = 7;
  13. static const int POPUP_ID_POSITION_MANAGER = 8;
  14. static const int POPUP_ID_PRESET_NEW = 9;
  15. static const int POPUP_ID_PRESET_RENAME = 10;
  16. static const int POPUP_ID_CONFIGS = 11;
  17. const string CONST_DEFAULT_PRESET_PREFIX = "[Default]";
  18. // Render specific Preset Items
  19. void RenderPresets()
  20. {
  21. m_PresetsTextListbox.ClearItems();
  22. int i;
  23. TBoolArray preset_params;
  24. // load fixed presets list
  25. TStringArray presets_array = m_ConfigDebugProfileFixed.GetPresets();
  26. for ( i = 0; i < presets_array.Count(); i++ )
  27. {
  28. m_PresetsTextListbox.AddItem( "["+presets_array.Get(i)+"]", new PresetParams ( presets_array.Get(i), true, false), 0);
  29. }
  30. // load custom presets list
  31. TStringArray custom_presets_array = m_ConfigDebugProfile.GetPresets();
  32. for ( i = 0; i < custom_presets_array.Count(); i++ )
  33. {
  34. m_PresetsTextListbox.AddItem( custom_presets_array.Get(i), new PresetParams ( custom_presets_array.Get(i),false, false), 0);
  35. }
  36. string default_preset = m_ConfigDebugProfile.GetDefaultPreset();
  37. if ( default_preset != "" )
  38. {
  39. // if is fixed
  40. int index = GetPresetIndexByName( default_preset );
  41. if ( IsPresetFixed( default_preset) )
  42. {
  43. default_preset = "[" + default_preset + "]";
  44. }
  45. PresetParams preset_params_array;
  46. if( index > -1 && index < m_PresetsTextListbox.GetNumItems() )
  47. {
  48. m_PresetsTextListbox.GetItemData( index, 0, preset_params_array );
  49. m_PresetsTextListbox.SetItem( index, default_preset + CONST_DEFAULT_PRESET_PREFIX, preset_params_array, 0 );
  50. }
  51. }
  52. }
  53. bool IsPresetFixed( string preset_name )
  54. {
  55. int preset_index = GetPresetIndexByName( preset_name);
  56. PresetParams item_params_array;
  57. if ( preset_index > -1 && preset_index < m_PresetsTextListbox.GetNumItems() )
  58. {
  59. m_PresetsTextListbox.GetItemData( preset_index, 0, item_params_array );
  60. return item_params_array.param2;
  61. }
  62. return false;
  63. }
  64. int GetPresetIndexByName( string preset_name )
  65. {
  66. int i;
  67. for ( i = 0; i < m_PresetsTextListbox.GetNumItems(); i++ )
  68. {
  69. PresetParams item_params_array;
  70. m_PresetsTextListbox.GetItemData( i, 0, item_params_array );
  71. if ( item_params_array.param1 == preset_name )
  72. {
  73. return i;
  74. }
  75. }
  76. return -1;
  77. }
  78. void NewPreset( string preset_name )
  79. {
  80. m_ConfigDebugProfile.PresetAdd( preset_name );
  81. RefreshLists();
  82. }
  83. void DeletePreset()
  84. {
  85. if ( GetCurrentPresetIndex() != -1 )
  86. {
  87. bool result = m_ConfigDebugProfile.PresetRemove( GetCurrentPresetName() );
  88. RefreshLists();
  89. }
  90. }
  91. void SetDefaultPreset( int preset_index )
  92. {
  93. // remove previous default parameter
  94. string default_preset = m_ConfigDebugProfile.GetDefaultPreset();
  95. if ( default_preset != "" )
  96. {
  97. int index = GetPresetIndexByName( default_preset );
  98. // if is fixed
  99. if ( IsPresetFixed( default_preset) )
  100. {
  101. default_preset = "[" + default_preset + "]";
  102. }
  103. PresetParams prev_preset_params_array;
  104. if( index > -1 && index < m_PresetsTextListbox.GetNumItems() )
  105. {
  106. m_PresetsTextListbox.GetItemData( index, 0, prev_preset_params_array );
  107. prev_preset_params_array.param3 = false; // remove DEFAULT
  108. m_PresetsTextListbox.SetItem( index, default_preset, prev_preset_params_array, 0 );
  109. }
  110. }
  111. // set preset on preset_index to default
  112. // if is fixed
  113. string preset_name = GetCurrentPresetName();
  114. if ( IsPresetFixed( preset_name) )
  115. {
  116. preset_name = "[" + preset_name + "]";
  117. }
  118. // set new default preset
  119. PresetParams preset_params_array;
  120. index = GetCurrentPresetIndex();
  121. if ( index > -1 && index < m_PresetsTextListbox.GetNumItems() )
  122. {
  123. m_PresetsTextListbox.GetItemData( index, 0, preset_params_array );
  124. preset_params_array.param3 = true; // DEFAULT
  125. m_PresetsTextListbox.SetItem( index, preset_name + CONST_DEFAULT_PRESET_PREFIX, preset_params_array, 0 );
  126. }
  127. // store preset
  128. m_ConfigDebugProfile.SetDefaultPreset( GetCurrentPresetName() );
  129. }
  130. void RefreshLists()
  131. {
  132. RenderPresets();
  133. RenderPresetItems();
  134. }
  135. void RenamePreset( string new_preset_name )
  136. {
  137. if ( GetCurrentPresetIndex() != -1 )
  138. {
  139. bool result = m_ConfigDebugProfile.PresetRename( GetCurrentPresetName(), new_preset_name );
  140. RefreshLists();
  141. }
  142. }
  143. // Render specific Preset Items
  144. void RenderPresetItems()
  145. {
  146. // load preset items list
  147. int i;
  148. m_PresetItemsTextListbox.ClearItems();
  149. if ( GetCurrentPresetIndex() != -1 )
  150. {
  151. bool isFixed = IsCurrentPresetFixed();
  152. TStringArray preset_array = new TStringArray;
  153. if ( isFixed )
  154. {
  155. m_ConfigDebugProfileFixed.GetPresetItems( GetCurrentPresetName(), preset_array );
  156. }
  157. else
  158. {
  159. m_ConfigDebugProfile.GetPresetItems( GetCurrentPresetName(), preset_array );
  160. }
  161. if ( preset_array )
  162. {
  163. for ( i = 0; i < preset_array.Count(); i++)
  164. {
  165. m_PresetItemsTextListbox.AddItem( preset_array.Get(i), NULL, 0);
  166. }
  167. }
  168. }
  169. }
  170. string GetCurrentPresetName()
  171. {
  172. int index = GetCurrentPresetIndex();
  173. // load preset items list
  174. if ( index > -1 && index < m_PresetsTextListbox.GetNumItems() )
  175. {
  176. PresetParams item_params_array;
  177. m_PresetsTextListbox.GetItemData( index, 0, item_params_array );
  178. return item_params_array.param1;
  179. }
  180. return "";
  181. }
  182. string GetCurrentItemName()
  183. {
  184. if ( GetCurrentItemIndex() != -1 )
  185. {
  186. string item_name;
  187. m_PresetItemsTextListbox.GetItemText( GetCurrentItemIndex(), 0, item_name );
  188. return item_name;
  189. }
  190. return "";
  191. }
  192. string GetCurrentObjectName()
  193. {
  194. int selected_row_index = m_ClWgtLbxClassesList.GetSelectedRow();
  195. if ( selected_row_index != -1 )
  196. {
  197. string item_name;
  198. m_ClWgtLbxClassesList.GetItemText( selected_row_index, 0, item_name );
  199. return item_name;
  200. }
  201. return "";
  202. }
  203. int GetCurrentPresetIndex()
  204. {
  205. return m_PresetsTextListbox.GetSelectedRow();
  206. }
  207. int GetCurrentItemIndex()
  208. {
  209. return m_PresetItemsTextListbox.GetSelectedRow();
  210. }
  211. bool IsCurrentPresetFixed()
  212. {
  213. int index = GetCurrentPresetIndex();
  214. if ( index > -1 && index < m_PresetsTextListbox.GetNumItems() )
  215. {
  216. PresetParams item_params_array;
  217. m_PresetsTextListbox.GetItemData( index, 0, item_params_array );
  218. return item_params_array.param2;
  219. }
  220. return -1;
  221. }
  222. void AddItemToPreset()
  223. {
  224. int selected_row_index = m_ClWgtLbxClassesList.GetSelectedRow();
  225. if ( selected_row_index != -1 && GetCurrentPresetIndex() != -1 )
  226. {
  227. string item_name;
  228. m_ClWgtLbxClassesList.GetItemText( selected_row_index, 0, item_name );
  229. m_ConfigDebugProfile.ItemAddToPreset( GetCurrentPresetName(), item_name);
  230. RenderPresetItems();
  231. }
  232. }
  233. void RemoveItemFromPreset()
  234. {
  235. if ( GetCurrentItemIndex() != -1 && GetCurrentPresetIndex() != -1 )
  236. {
  237. m_ConfigDebugProfile.ItemRemoveFromPreset( GetCurrentPresetName(), GetCurrentItemIndex() );
  238. RenderPresetItems();
  239. }
  240. }
  241. /// spawn preset items into inventory
  242. void SetPreset( bool clear_inventory, string preset_name)
  243. {
  244. int i;
  245. if ( GetCurrentPresetIndex() != -1 )
  246. {
  247. bool is_preset_fixed = IsCurrentPresetFixed();
  248. TStringArray preset_array = new TStringArray;
  249. if ( is_preset_fixed )
  250. {
  251. m_ConfigDebugProfileFixed.GetPresetItems( preset_name, preset_array );
  252. }
  253. else
  254. {
  255. m_ConfigDebugProfile.GetPresetItems( preset_name, preset_array );
  256. }
  257. PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
  258. if ( clear_inventory )
  259. {
  260. m_Developer.ClearInventory(player);
  261. }
  262. for ( i = 0; i < preset_array.Count(); i++)
  263. {
  264. float health = -1;
  265. int quantity = -1;
  266. if ( is_preset_fixed )
  267. {
  268. health = m_ConfigDebugProfileFixed.GetItemHealth( preset_name, i );
  269. quantity = m_ConfigDebugProfileFixed.GetItemQuantity( preset_name, i );
  270. }
  271. else
  272. {
  273. health = m_ConfigDebugProfile.GetItemHealth( preset_name, i );
  274. quantity = m_ConfigDebugProfile.GetItemQuantity( preset_name, i );
  275. }
  276. m_Developer.SpawnEntityInPlayerInventory(player, preset_array.Get(i), health, quantity);
  277. }
  278. }
  279. }
  280. void ItemMoveUp()
  281. {
  282. int new_index = GetCurrentItemIndex() - 1;
  283. if ( GetCurrentItemIndex() != -1 && GetCurrentPresetIndex() != -1 && new_index > -1)
  284. {
  285. m_ConfigDebugProfile.SwapItem( GetCurrentPresetName(), GetCurrentItemIndex(), new_index );
  286. RenderPresetItems();
  287. m_PresetItemsTextListbox.SelectRow (new_index);
  288. }
  289. }
  290. void ItemMoveDown()
  291. {
  292. int new_index = GetCurrentItemIndex() + 1;
  293. if ( GetCurrentItemIndex() != -1 && GetCurrentPresetIndex() != -1 && new_index < m_PresetItemsTextListbox.GetNumItems() )
  294. {
  295. m_ConfigDebugProfile.SwapItem( GetCurrentPresetName(), GetCurrentItemIndex(), new_index );
  296. RenderPresetItems();
  297. m_PresetItemsTextListbox.SelectRow (new_index);
  298. }
  299. }
  300. void SaveProfileSpawnDistance()
  301. {
  302. if ( m_ConfigDebugProfile && m_SpawnDistanceEditBox )
  303. {
  304. m_ConfigDebugProfile.SetSpawnDistance( m_SpawnDistanceEditBox.GetText().ToFloat() );
  305. }
  306. }
  307. // Overrided Parent Functions
  308. //============================================
  309. // UseMouse (override)
  310. //============================================
  311. override bool UseMouse()
  312. {
  313. return true;
  314. }
  315. //============================================
  316. // UseKeyboard (override)
  317. //============================================
  318. override bool UseKeyboard()
  319. {
  320. return true;
  321. }
  322. // System Events
  323. //============================================
  324. // SceneEditorMenu
  325. //============================================
  326. void SceneEditorMenu()
  327. {
  328. m_ModuleSceneManager = PluginSceneManager.Cast( GetPlugin(PluginSceneManager) );
  329. m_ModuleSceneManager.OnUIEditorOpened();
  330. m_Popups = new map<int, ref UIPopupScript>;
  331. m_SlObjectsList = new map<int, SceneObject>;
  332. m_OpenedPopups = new TIntArray;
  333. m_ClClassesList = new TStringArray;
  334. }
  335. //============================================
  336. // ~SceneEditorMenu
  337. //============================================
  338. void ~SceneEditorMenu()
  339. {
  340. PopupCloseAll();
  341. if ( IsModuleExist(PluginSceneManager) )
  342. {
  343. m_ModuleSceneManager.OnUIEditorClosed();
  344. m_ModuleSceneManager = NULL;
  345. }
  346. m_NotifyFadeTimer.Stop();
  347. }
  348. //============================================
  349. // Init
  350. //============================================
  351. override Widget Init()
  352. {
  353. // Create Main layout menu
  354. layoutRoot = GetGame().GetWorkspace().CreateWidgets("gui/layouts/scene_editor/day_z_scene_editor.layout");
  355. m_WgtPnlWrapper = layoutRoot.FindAnyWidget("pnl_presets_wrapper_outer");
  356. m_SlWgtLoadedScene = TextWidget.Cast( layoutRoot.FindAnyWidget("txt_left_label_loaded_scene") );
  357. // Find ListTextBoxWidget for objects list
  358. m_SlWgtLbxObjectsList = TextListboxWidget.Cast(layoutRoot.FindAnyWidget("txtlist_left_items") );
  359. // Find Edit Box for shearching in object list
  360. m_SlWgtEbxFilter = EditBoxWidget.Cast(layoutRoot.FindAnyWidget("edit_left_search_item") );
  361. // Find Select Button for selecting in object list
  362. m_SlWgtSelect = ButtonWidget.Cast(layoutRoot.FindAnyWidget("btn_left_select") );
  363. m_SlWgtFocus = ButtonWidget.Cast(layoutRoot.FindAnyWidget("btn_left_focus") );
  364. // Find Popup main panel
  365. m_WgtPopupsMain = layoutRoot.FindAnyWidget("pnl_popups");
  366. // Find Poups backgroudn
  367. m_WgtPopupsBg = layoutRoot.FindAnyWidget("pnl_popup_bg");
  368. // Find Edit Box for shearching in class list
  369. m_ClWgtEbxFilter = EditBoxWidget.Cast(layoutRoot.FindAnyWidget("edit_left_search_class") );
  370. // Find ListTextBoxWidget for class list
  371. m_ClWgtLbxClassesList = TextListboxWidget.Cast(layoutRoot.FindAnyWidget("txtlist_left_classes") );
  372. // Find Buttons
  373. m_WgtBtnSceneManager = ButtonWidget.Cast(layoutRoot.FindAnyWidget("btn_top_scene_manager") );
  374. m_WgtBtnPositionManager = ButtonWidget.Cast(layoutRoot.FindAnyWidget("btn_top_position_manager") );
  375. m_WgtBtnSceneSettings = ButtonWidget.Cast(layoutRoot.FindAnyWidget("btn_top_settings") );
  376. m_ClWgtButtonAddAtt = ButtonWidget.Cast(layoutRoot.FindAnyWidget("btn_left_cl_add_attachment") );
  377. m_WgtBtnSceneSave = ButtonWidget.Cast(layoutRoot.FindAnyWidget("btn_top_save_scene") );
  378. m_WgtBtnEditorSettings = ButtonWidget.Cast(layoutRoot.FindAnyWidget("btn_top_editor_settings") );
  379. m_WgtBtnEditInitScript = ButtonWidget.Cast(layoutRoot.FindAnyWidget("btn_right_prop_pos_iscr_value") );
  380. m_WgtBtnDeleteRuler = ButtonWidget.Cast(layoutRoot.FindAnyWidget("btn_delete_ruler") );
  381. m_WgtBtnLeftPresets = ButtonWidget.Cast(layoutRoot.FindAnyWidget("btn_left_presets") );
  382. // Find Widgets for properties
  383. m_PrWgtClassName = TextWidget.Cast(layoutRoot.FindAnyWidget("txt_right_prop_class_value") );
  384. m_PrWgtPoxX = EditBoxWidget.Cast(layoutRoot.FindAnyWidget("ebx_right_prop_pos_x_value") );
  385. m_PrWgtPoxY = EditBoxWidget.Cast(layoutRoot.FindAnyWidget("ebx_right_prop_pos_y_value") );
  386. m_PrWgtPoxZ = EditBoxWidget.Cast(layoutRoot.FindAnyWidget("ebx_right_prop_pos_z_value") );
  387. m_PrWgtDir = EditBoxWidget.Cast(layoutRoot.FindAnyWidget("ebx_right_prop_pos_dir_value") );
  388. m_PrWgtDmg = EditBoxWidget.Cast(layoutRoot.FindAnyWidget("ebx_right_prop_pos_hlt_value") );
  389. m_PrWgtAttRoot = layoutRoot.FindAnyWidget("pnl_right_inspector_attachments");
  390. m_PrWgtAttTitle = layoutRoot.FindAnyWidget("pnl_att_title");
  391. m_PrWidgetsAttachments = new array<ref UIPropertyAttachment>;
  392. // Notify
  393. m_NotifyWgtPanel = layoutRoot.FindAnyWidget("pnl_notify");
  394. m_NotifyWgtPanel.SetAlpha(0.0);
  395. m_NotifyFadeTimer = new WidgetFadeTimer;
  396. // Register Poups
  397. m_Popups.Insert(POPUP_ID_SCENE_MANAGER, new UIPopupScriptSceneManager(layoutRoot.FindAnyWidget("pnl_popup_scene_manager")));
  398. m_Popups.Insert(POPUP_ID_POSITION_MANAGER, new UIPopupScriptPositionManager(layoutRoot.FindAnyWidget("pnl_popup_position_manager")));
  399. m_Popups.Insert(POPUP_ID_SCENE_SETTINGS, new UIPopupScriptSceneSettings(layoutRoot.FindAnyWidget("pnl_popup_settings")) );
  400. m_Popups.Insert(POPUP_ID_SCENE_NEW, new UIPopupScriptSceneNew(layoutRoot.FindAnyWidget("pnl_popup_scene_new")) );
  401. m_Popups.Insert(POPUP_ID_SCENE_RENAME, new UIPopupScriptSceneRename(layoutRoot.FindAnyWidget("pnl_popup_scene_rename")) );
  402. m_Popups.Insert(POPUP_ID_SCENE_DELETE, new UIPopupScriptSceneDelete(layoutRoot.FindAnyWidget("pnl_popup_scene_delete")) );
  403. m_Popups.Insert(POPUP_ID_NOTIFY, new UIPopupScriptNotify(layoutRoot.FindAnyWidget("pnl_popup_notify")) );
  404. m_Popups.Insert(POPUP_ID_EDITOR_SETTINGS, new UIPopupScriptEditorSettings(layoutRoot.FindAnyWidget("pnl_popup_editor_settings")));
  405. m_Popups.Insert(POPUP_ID_INIT_SCRIPT, new UIPopupScriptInitScript(layoutRoot.FindAnyWidget("pnl_popup_init_script")));
  406. m_Popups.Insert(POPUP_ID_PRESET_NEW, new UIPopupScriptPresetNew(layoutRoot.FindAnyWidget("pnl_popup_preset_new")));
  407. m_Popups.Insert(POPUP_ID_PRESET_RENAME, new UIPopupScriptPresetRename(layoutRoot.FindAnyWidget("pnl_popup_preset_rename")));
  408. m_Popups.Insert(POPUP_ID_CONFIGS, new UIPopupScriptConfigs(layoutRoot.FindAnyWidget("pnl_popup_configs")));
  409. m_PresetsTextListbox = TextListboxWidget.Cast( layoutRoot.FindAnyWidget("pnl_presets") );
  410. m_PresetItemsTextListbox = TextListboxWidget.Cast( layoutRoot.FindAnyWidget("pnl_preset_items") );
  411. m_ConfigDebugProfileFixed = PluginConfigDebugProfileFixed.Cast( GetPlugin(PluginConfigDebugProfileFixed) );
  412. m_ConfigDebugProfile = PluginConfigDebugProfile.Cast( GetPlugin(PluginConfigDebugProfile) );
  413. m_PresetAddItemtButton = ButtonWidget.Cast( layoutRoot.FindAnyWidget("btn_add_to_preset") );
  414. m_PresetRemoveItemButton = ButtonWidget.Cast( layoutRoot.FindAnyWidget("btn_remove_from_preset") );
  415. m_SpawnOnGroundButton = ButtonWidget.Cast( layoutRoot.FindAnyWidget("btn_spawn_on_ground") );
  416. m_SpawnInInventoryButton = ButtonWidget.Cast( layoutRoot.FindAnyWidget("btn_spawn_in_inventory") );
  417. m_SpawnAsAttachmentButton = ButtonWidget.Cast( layoutRoot.FindAnyWidget("btn_spawn_as_attachment") );
  418. m_UpButton = ButtonWidget.Cast( layoutRoot.FindAnyWidget("btn_up") );
  419. m_DownButton = ButtonWidget.Cast( layoutRoot.FindAnyWidget("btn_down") );
  420. m_Developer = PluginDeveloper.Cast( GetPlugin(PluginDeveloper) );
  421. m_QuantityEditBox = EditBoxWidget.Cast( layoutRoot.FindAnyWidget("txt_quantity_value") );
  422. m_DamageEditBox = EditBoxWidget.Cast( layoutRoot.FindAnyWidget("txt_damage_value") );
  423. m_SpawnDistanceEditBox = EditBoxWidget.Cast( layoutRoot.FindAnyWidget("txt_distance_value") );
  424. m_PresetNewButton = ButtonWidget.Cast( layoutRoot.FindAnyWidget("btn_new") );
  425. m_PresetDeleteButton = ButtonWidget.Cast( layoutRoot.FindAnyWidget("btn_delete") );
  426. m_PresetRenameButton = ButtonWidget.Cast( layoutRoot.FindAnyWidget("btn_rename") );
  427. m_PresetSetDefaultButton = ButtonWidget.Cast( layoutRoot.FindAnyWidget("btn_default") );
  428. m_CopyToClipboardButton = ButtonWidget.Cast( layoutRoot.FindAnyWidget("btn_copy_to_clipboard") );
  429. m_ConfigsButton = EditBoxWidget.Cast( layoutRoot.FindAnyWidget("btn_top_configs") );
  430. m_SpawnDistanceEditBox.SetText( m_ConfigDebugProfile.GetSpawnDistance().ToString() );
  431. RenderPresets();
  432. UpdateListObjects();
  433. UpdateListClasses();
  434. PopupHideAll();
  435. return layoutRoot;
  436. }
  437. override bool OnDoubleClick( Widget w, int x, int y, int button )
  438. {
  439. if( w == m_PresetItemsTextListbox || w == m_PresetsTextListbox || w == m_ClWgtLbxClassesList )
  440. {
  441. SaveProfileSpawnDistance();
  442. //float distance = m_SpawnDistanceEditBox.GetText().ToFloat();
  443. if ( m_SelectedObjectIsPreset )
  444. {
  445. SetPreset( true, m_SelectedObject);
  446. return true;
  447. }
  448. else
  449. {
  450. float health = -1;
  451. int quantity = -1;
  452. if(GetCurrentItemIndex() != -1)
  453. {
  454. health = m_ConfigDebugProfile.GetItemHealth( GetCurrentPresetName(), GetCurrentItemIndex() );
  455. quantity = m_ConfigDebugProfile.GetItemQuantity( GetCurrentPresetName(), GetCurrentItemIndex() );
  456. }
  457. m_Developer.SpawnEntityInPlayerInventory( PlayerBase.Cast( GetGame().GetPlayer() ), m_SelectedObject, health, quantity);
  458. return true;
  459. }
  460. }
  461. return false;
  462. }
  463. //============================================
  464. // OnClick
  465. //============================================
  466. override bool OnClick(Widget w, int x, int y, int button)
  467. {
  468. super.OnClick(w, x, y, button);
  469. int row_index;
  470. if ( w == m_WgtBtnSceneManager )
  471. {
  472. PopupOpen(POPUP_ID_SCENE_MANAGER, Param.Cast( NULL ) );
  473. return true;
  474. }
  475. else if( w == m_ConfigsButton )
  476. {
  477. PopupOpen( POPUP_ID_CONFIGS, NULL );
  478. return true;
  479. }
  480. else if( w == m_PresetsTextListbox )
  481. {
  482. RenderPresetItems();
  483. m_SelectedObjectIsPreset = true;
  484. m_SelectedObject = GetCurrentPresetName();
  485. return true;
  486. }
  487. else if ( w == m_PresetSetDefaultButton )
  488. {
  489. if ( GetCurrentPresetName() != "" )
  490. {
  491. SetDefaultPreset( GetCurrentPresetIndex() );
  492. }
  493. return true;
  494. }
  495. else if ( w == m_PresetNewButton )
  496. {
  497. PopupOpen( POPUP_ID_PRESET_NEW, NULL );
  498. RefreshLists();
  499. return true;
  500. }
  501. else if ( w == m_PresetRenameButton )
  502. {
  503. PopupOpen( POPUP_ID_PRESET_RENAME, NULL );
  504. return true;
  505. }
  506. else if( w == m_CopyToClipboardButton )
  507. {
  508. GetGame().CopyToClipboard( m_SelectedObject );
  509. return true;
  510. }
  511. else if ( w == m_PresetDeleteButton )
  512. {
  513. if ( GetCurrentPresetName() != "" )
  514. {
  515. DeletePreset();
  516. }
  517. return true;
  518. }
  519. else if( w == m_SpawnOnGroundButton || w == m_SpawnAsAttachmentButton || w == m_SpawnInInventoryButton )
  520. {
  521. SaveProfileSpawnDistance();
  522. float distance = m_SpawnDistanceEditBox.GetText().ToFloat();
  523. float health = -1;
  524. int quantity = -1;
  525. if( GetCurrentItemIndex() != -1 )
  526. {
  527. health = m_ConfigDebugProfile.GetItemHealth( GetCurrentPresetName(), GetCurrentItemIndex() );
  528. quantity = m_ConfigDebugProfile.GetItemQuantity( GetCurrentPresetName(), GetCurrentItemIndex() );
  529. }
  530. switch ( w )
  531. {
  532. case m_SpawnOnGroundButton:
  533. {
  534. if ( m_SelectedObjectIsPreset )
  535. {
  536. // SpawnPresetOnGround
  537. ;//SetPreset( true, m_SelectedObject, spawn_type, distance );
  538. }
  539. else
  540. m_Developer.SpawnEntityOnCursorDir( PlayerBase.Cast( GetGame().GetPlayer() ), m_SelectedObject, quantity, distance, health );
  541. break;
  542. }
  543. case m_SpawnAsAttachmentButton:
  544. {
  545. Man player = GetGame().GetPlayer();
  546. vector rayStart = GetGame().GetCurrentCameraPosition();
  547. vector rayEnd = rayStart + GetGame().GetCurrentCameraDirection() * 1.5;
  548. vector hitPos;
  549. vector hitNormal;
  550. int hitComponentIndex;
  551. ref set<Object> hitObjects = new set<Object>;
  552. DayZPhysics.RaycastRV(rayStart, rayEnd, hitPos, hitNormal, hitComponentIndex, hitObjects, NULL, player);
  553. Object target = NULL;
  554. if( hitObjects.Count() )
  555. target = hitObjects.Get(0);
  556. if ( target != NULL && target.IsInherited(EntityAI) )
  557. {
  558. EntityAI att_parent = EntityAI.Cast( target );
  559. m_Developer.SpawnEntityAsAttachment( PlayerBase.Cast( player ), att_parent, m_SelectedObject, health, quantity);
  560. }
  561. else
  562. {
  563. m_Developer.SpawnEntityAsAttachment( PlayerBase.Cast( player ), player, m_SelectedObject, health, quantity);
  564. }
  565. break;
  566. }
  567. case m_SpawnInInventoryButton:
  568. {
  569. m_Developer.SpawnEntityInPlayerInventory( PlayerBase.Cast( GetGame().GetPlayer() ), m_SelectedObject, health, quantity);
  570. break;
  571. }
  572. }
  573. return true;
  574. }
  575. else if( w == m_PresetItemsTextListbox )
  576. {
  577. m_SelectedObjectIsPreset = false;
  578. m_SelectedObject = GetCurrentItemName();
  579. if( GetCurrentItemIndex() != -1 )
  580. {
  581. float item_health = m_ConfigDebugProfile.GetItemHealth( GetCurrentPresetName(), GetCurrentItemIndex() );
  582. int item_quantity = m_ConfigDebugProfile.GetItemQuantity( GetCurrentPresetName(), GetCurrentItemIndex() );
  583. m_DamageEditBox.SetText( item_health.ToString() );
  584. m_QuantityEditBox.SetText( item_quantity.ToString() );
  585. }
  586. return true;
  587. }
  588. else if( w == m_UpButton )
  589. {
  590. ItemMoveUp();
  591. return true;
  592. }
  593. else if( w == m_DownButton )
  594. {
  595. ItemMoveDown();
  596. return true;
  597. }
  598. else if( w == m_WgtBtnLeftPresets )
  599. {
  600. if( m_WgtPnlWrapper.IsVisible() )
  601. {
  602. m_WgtPnlWrapper.Show(false);
  603. m_WgtBtnLeftPresets.SetText("Presets >>");
  604. }
  605. else
  606. {
  607. m_WgtPnlWrapper.Show(true);
  608. m_WgtBtnLeftPresets.SetText("Presets <<");
  609. }
  610. return true;
  611. }
  612. else if ( w == m_PresetAddItemtButton )
  613. {
  614. AddItemToPreset();
  615. return true;
  616. }
  617. else if ( w == m_PresetRemoveItemButton )
  618. {
  619. RemoveItemFromPreset();
  620. return true;
  621. }
  622. else if ( w == m_WgtBtnPositionManager )
  623. {
  624. m_PopupScriptPositionManager = UIPopupScriptPositionManager.Cast( PopupOpen( POPUP_ID_POSITION_MANAGER, Param.Cast( NULL ) ) );
  625. return true;
  626. }
  627. else if ( w == m_WgtBtnSceneSettings )
  628. {
  629. PopupOpen(POPUP_ID_SCENE_SETTINGS, NULL);
  630. return true;
  631. }
  632. else if ( w == m_SlWgtSelect )
  633. {
  634. row_index = m_SlWgtLbxObjectsList.GetSelectedRow();
  635. if ( m_SlObjectsList.Count() > 0 && m_SlObjectsList.Count() > row_index )
  636. {
  637. m_ModuleSceneManager.SelectObject(m_SlObjectsList.GetElement(row_index));
  638. }
  639. return true;
  640. }
  641. else if ( w == m_SlWgtFocus )
  642. {
  643. m_ModuleSceneManager.SelectedObjectFocus();
  644. return true;
  645. }
  646. else if ( w == m_WgtBtnSceneSave )
  647. {
  648. m_ModuleSceneManager.SceneSave();
  649. return true;
  650. }
  651. else if ( w == m_WgtBtnEditorSettings )
  652. {
  653. PopupOpen(POPUP_ID_EDITOR_SETTINGS, NULL);
  654. return true;
  655. }
  656. else if ( w == m_WgtBtnEditInitScript )
  657. {
  658. Param2<int, SceneObject> param = new Param2<int, SceneObject>( m_ModuleSceneManager.GetSelectedSceneObjectIndex(), m_ModuleSceneManager.GetSelectedSceneObject() );
  659. PopupOpen(POPUP_ID_INIT_SCRIPT, param);
  660. return true;
  661. }
  662. else if ( w == m_WgtBtnDeleteRuler )
  663. {
  664. m_ModuleSceneManager.RulerDelete();
  665. return true;
  666. }
  667. bool ret = ComponentsOnClick(w, x, y, button);
  668. return ret;
  669. }
  670. //============================================
  671. // OnChange
  672. //============================================
  673. override bool OnChange(Widget w, int x, int y, bool finished)
  674. {
  675. super.OnChange(w, x, y, finished);
  676. if (w == m_ClWgtEbxFilter)
  677. {
  678. UpdateListClasses();
  679. return true;
  680. }
  681. else if (w == m_SlWgtEbxFilter)
  682. {
  683. UpdateListObjects();
  684. return true;
  685. }
  686. else if ( w == m_PrWgtPoxX && finished )
  687. {
  688. m_ModuleSceneManager.SelectedObjectSetPosX(m_PrWgtPoxX.GetText().ToFloat());
  689. }
  690. else if ( w == m_PrWgtPoxY && finished )
  691. {
  692. m_ModuleSceneManager.SelectedObjectSetPosY(m_PrWgtPoxY.GetText().ToFloat());
  693. }
  694. else if ( w == m_PrWgtPoxZ && finished )
  695. {
  696. m_ModuleSceneManager.SelectedObjectSetPosZ(m_PrWgtPoxZ.GetText().ToFloat());
  697. }
  698. else if ( w == m_PrWgtDir && finished )
  699. {
  700. m_ModuleSceneManager.SelectedObjectSetRot(m_PrWgtDir.GetText().ToFloat());
  701. return true;
  702. }
  703. else if ( w == m_PrWgtDmg && finished )
  704. {
  705. m_ModuleSceneManager.SelectedObjectSetDamage(m_PrWgtDmg.GetText().ToFloat());
  706. return true;
  707. }
  708. else if ( w == m_QuantityEditBox )
  709. {
  710. m_ConfigDebugProfile.SetItemQuantity( GetCurrentPresetName(), GetCurrentItemIndex(), m_QuantityEditBox.GetText().ToInt() );
  711. return true;
  712. }
  713. else if ( w == m_DamageEditBox )
  714. {
  715. m_ConfigDebugProfile.SetItemHealth( GetCurrentPresetName(), GetCurrentItemIndex(), m_DamageEditBox.GetText().ToFloat() );
  716. return true;
  717. }
  718. bool ret = ComponentsOnChange(w, x, y, finished);
  719. return false;
  720. }
  721. override void OnShow()
  722. {
  723. GetGame().GetMission().AddActiveInputExcludes({"menu"});
  724. }
  725. override void OnHide()
  726. {
  727. GetGame().GetMission().RemoveActiveInputExcludes({"menu"},true);
  728. }
  729. //============================================
  730. // OnMouseWheel
  731. //============================================
  732. override bool OnMouseWheel(Widget w, int x, int y, int wheel)
  733. {
  734. super.OnMouseWheel(w, x, y, wheel);
  735. m_ModuleSceneManager.OnMouseWheel(wheel);
  736. return true;
  737. }
  738. //============================================
  739. // OnItemSelected
  740. //============================================
  741. override bool OnItemSelected(Widget w, int x, int y, int row, int column, int oldRow, int oldColumn)
  742. {
  743. super.OnItemSelected(w, x, y, row, column, oldRow, oldColumn);
  744. if ( w == m_ClWgtLbxClassesList )
  745. {
  746. string selected_class_name;
  747. m_ClWgtLbxClassesList.GetItemText( m_ClWgtLbxClassesList.GetSelectedRow(), 0, selected_class_name );
  748. m_ModuleSceneManager.SelectClassName(selected_class_name);
  749. SceneObject obj_selected = m_ModuleSceneManager.GetSelectedSceneObject();
  750. m_SelectedObject = GetCurrentObjectName();
  751. m_SelectedObjectIsPreset = false;
  752. }
  753. else if ( w == m_SlWgtLbxObjectsList )
  754. {
  755. int row_index = m_SlWgtLbxObjectsList.GetSelectedRow();
  756. if ( m_SlObjectsList && row_index > -1 && m_SlObjectsList.Count() > 0 && m_SlObjectsList.Count() > row_index )
  757. {
  758. m_ModuleSceneManager.SelectObject(m_SlObjectsList.GetElement(row_index));
  759. }
  760. }
  761. if( m_PopupScriptPositionManager != NULL )
  762. {
  763. m_PopupScriptPositionManager.OnItemSelected(w, x, y, row, column, oldRow, oldColumn);
  764. }
  765. return true;
  766. }
  767. // Scripted Events
  768. //============================================
  769. // PopupOpen
  770. //============================================
  771. UIPopupScript PopupOpen(int popup_id, Param param)
  772. {
  773. // Open background image (black transparent) under popups
  774. if ( m_OpenedPopups.Count() == 0 )
  775. {
  776. m_WgtPopupsMain.Show(true);
  777. m_WgtPopupsBg.Show(true);
  778. }
  779. else
  780. {
  781. int popup_curr_id = m_OpenedPopups.Get(m_OpenedPopups.Count() - 1);
  782. m_Popups.Get(popup_curr_id).Show(false);
  783. }
  784. m_OpenedPopups.Insert(popup_id);
  785. UIPopupScript popup = m_Popups.Get(popup_id);
  786. popup.Show(true);
  787. popup.OnOpen(param);
  788. return popup;
  789. }
  790. //============================================
  791. // PopupBack
  792. //============================================
  793. UIPopupScript PopupBack()
  794. {
  795. if ( m_OpenedPopups.Count() > 0 )
  796. {
  797. int popup_curr_id = m_OpenedPopups.Get(m_OpenedPopups.Count() - 1);
  798. m_Popups.Get(popup_curr_id).Show(false);
  799. m_Popups.Get(popup_curr_id).OnClose();
  800. m_OpenedPopups.Remove(m_OpenedPopups.Count() - 1);
  801. if ( m_OpenedPopups.Count() > 0 )
  802. {
  803. int ppp_id = m_OpenedPopups.Get(m_OpenedPopups.Count() - 1);
  804. m_Popups.Get(ppp_id).Show(true);
  805. m_Popups.Get(ppp_id).OnOpen(NULL);
  806. return m_Popups.Get(ppp_id);
  807. }
  808. }
  809. m_WgtPopupsMain.Show(false);
  810. m_WgtPopupsBg.Show(false);
  811. return NULL;
  812. }
  813. //============================================
  814. // PopupCloseAll
  815. //============================================
  816. void PopupCloseAll()
  817. {
  818. if ( m_OpenedPopups.Count() > 0 )
  819. {
  820. int popup_curr_id = m_OpenedPopups.Get(m_OpenedPopups.Count() - 1);
  821. m_Popups.Get(popup_curr_id).Show(false);
  822. m_Popups.Get(popup_curr_id).OnClose();
  823. m_OpenedPopups.Clear();
  824. }
  825. }
  826. //============================================
  827. // ToggleVisibility (Show/Hide of editor)
  828. //============================================
  829. void ToggleVisibility()
  830. {
  831. m_WgtRoot.Show( m_ModuleSceneManager.IsOpened() );
  832. }
  833. //============================================
  834. // Refresh
  835. //============================================
  836. override void Refresh()
  837. {
  838. UpdateListObjects();
  839. string class_name = "n/a";
  840. string pos_x = "n/a";
  841. string pos_y = "n/a";
  842. string pos_z = "n/a";
  843. string rot = "n/a";
  844. string hlt = "n/a";
  845. // Clear attachments
  846. for ( int i = 0; i < m_PrWidgetsAttachments.Count(); ++i )
  847. {
  848. m_PrWidgetsAttachments.Get(i).Hide();
  849. }
  850. if ( m_ModuleSceneManager.GetSelectedSceneObject() )
  851. {
  852. SceneObject obj = m_ModuleSceneManager.GetSelectedSceneObject();
  853. vector v = obj.GetPosition();
  854. class_name = obj.GetTypeName();
  855. pos_x = v[0].ToString();
  856. pos_y = v[1].ToString();
  857. pos_z = v[2].ToString();
  858. rot = obj.GetRotation().ToString();
  859. hlt = obj.GetHealth().ToString();
  860. ref TStringArray attachments_slots = obj.GetConfigAttachments();
  861. float prop_h = 0.03;
  862. float prop_count = attachments_slots.Count();
  863. float prop_root_h = prop_h * (prop_count + 1);
  864. float line_h = 1.0 / (prop_count + 1);
  865. m_PrWgtAttRoot.SetSize(1, prop_root_h);
  866. m_PrWgtAttTitle.SetSize(1, line_h);
  867. EntityAI e = m_ModuleSceneManager.GetSelectedSceneObject().GetObject();
  868. map<string, ref TStringArray> attachments_in_slots = GetItemNamesForSlots(attachments_slots);
  869. for ( int j = 0; j < attachments_in_slots.Count(); ++j )
  870. {
  871. TStringArray attachments_in_slot = attachments_in_slots.GetElement(j);
  872. UIPropertyAttachment ui_prop = GetFreeUIPropertyAttchament();
  873. ui_prop.Show(m_ModuleSceneManager.GetSelectedSceneObject().GetObject(), attachments_in_slots.GetKey(j), attachments_in_slot);
  874. ui_prop.SetPos( 0, (1 + j) * line_h );
  875. ui_prop.SetSize( 1, line_h );
  876. }
  877. m_WgtBtnEditInitScript.Enable( true );
  878. }
  879. else
  880. {
  881. m_WgtBtnEditInitScript.Enable( false );
  882. }
  883. m_PrWgtClassName.SetText(class_name);
  884. m_PrWgtPoxX.SetText(pos_x);
  885. m_PrWgtPoxY.SetText(pos_y);
  886. m_PrWgtPoxZ.SetText(pos_z);
  887. m_PrWgtDir.SetText(rot);
  888. m_PrWgtDmg.SetText(hlt);
  889. m_SlWgtLoadedScene.SetText("Loaded Scene: "+m_ModuleSceneManager.SceneGetName());
  890. //Ruler
  891. if ( m_ModuleSceneManager.IsRulerActivated() )
  892. {
  893. m_WgtBtnDeleteRuler.SetColor( 0xFF5DE028 );
  894. }
  895. else
  896. {
  897. m_WgtBtnDeleteRuler.SetColor( 0xFFFFFFFF );
  898. }
  899. }
  900. void SceneEditorCommand( Param params )
  901. {
  902. Param2<int, Param> p = Param2<int, Param>.Cast( params );
  903. int cmd_id = p.param1;
  904. switch ( cmd_id )
  905. {
  906. case PluginSceneManager.SCENE_EDITOR_CMD_REFRESH:
  907. Refresh();
  908. break;
  909. case PluginSceneManager.SCENE_EDITOR_CMD_SAVE:
  910. m_NotifyWgtPanel.SetAlpha(1.0);
  911. m_NotifyFadeTimer.FadeOut(m_NotifyWgtPanel, 2, true);
  912. break;
  913. }
  914. }
  915. //---------------------------------------------------------------------------------
  916. // >> Protected Scope
  917. protected Widget m_WgtRoot;
  918. protected PluginSceneManager m_ModuleSceneManager;
  919. //---------------------------------------------------------------------------------
  920. // >> protected Scope
  921. // Top Panel
  922. protected ButtonWidget m_WgtBtnSceneManager;
  923. protected ButtonWidget m_WgtBtnSceneSettings;
  924. protected ButtonWidget m_WgtBtnSceneSave;
  925. protected ButtonWidget m_WgtBtnEditorSettings;
  926. protected ButtonWidget m_WgtBtnDeleteRuler;
  927. // Popups
  928. protected Widget m_WgtPopupsMain;
  929. protected Widget m_WgtPopupsBg;
  930. protected ref TIntArray m_OpenedPopups;
  931. protected ref map<int, ref UIPopupScript> m_Popups;
  932. // Scene Object List
  933. protected TextWidget m_SlWgtLoadedScene;
  934. protected string m_SlSelectedClass;
  935. protected ref map<int, SceneObject> m_SlObjectsList;
  936. protected TextListboxWidget m_SlWgtLbxObjectsList;
  937. protected EditBoxWidget m_SlWgtEbxFilter;
  938. protected ButtonWidget m_SlWgtSelect;
  939. protected ButtonWidget m_SlWgtFocus;
  940. // Config Class List
  941. protected string m_ClSelectedClass;
  942. protected ref TStringArray m_ClClassesList;
  943. protected EditBoxWidget m_ClWgtEbxFilter;
  944. protected TextListboxWidget m_ClWgtLbxClassesList;
  945. protected ButtonWidget m_ClWgtButtonAddAtt;
  946. // Properties
  947. protected TextWidget m_PrWgtClassName;
  948. protected EditBoxWidget m_PrWgtPoxX;
  949. protected EditBoxWidget m_PrWgtPoxY;
  950. protected EditBoxWidget m_PrWgtPoxZ;
  951. protected EditBoxWidget m_PrWgtDir;
  952. protected EditBoxWidget m_PrWgtDmg;
  953. protected ButtonWidget m_WgtBtnEditInitScript;
  954. protected Widget m_PrWgtAttRoot;
  955. protected Widget m_PrWgtAttTitle;
  956. protected ref array<ref UIPropertyAttachment> m_PrWidgetsAttachments;
  957. // Notify
  958. protected ref WidgetFadeTimer m_NotifyFadeTimer;
  959. protected Widget m_NotifyWgtPanel;
  960. //Other
  961. protected TextListboxWidget m_PresetsTextListbox;
  962. protected TextListboxWidget m_PresetItemsTextListbox;
  963. protected ButtonWidget m_PresetAddItemtButton;
  964. protected ButtonWidget m_PresetRemoveItemButton;
  965. protected ButtonWidget m_SpawnOnGroundButton;
  966. protected ButtonWidget m_SpawnInInventoryButton;
  967. protected ButtonWidget m_SpawnAsAttachmentButton;
  968. protected ButtonWidget m_UpButton;
  969. protected ButtonWidget m_DownButton;
  970. protected ButtonWidget m_PresetNewButton;
  971. protected ButtonWidget m_PresetDeleteButton;
  972. protected ButtonWidget m_PresetRenameButton;
  973. protected ButtonWidget m_PresetSetDefaultButton;
  974. protected ButtonWidget m_CopyToClipboardButton;
  975. protected EditBoxWidget m_DamageEditBox;
  976. protected EditBoxWidget m_QuantityEditBox;
  977. protected EditBoxWidget m_SpawnDistanceEditBox;
  978. protected EditBoxWidget m_ConfigsButton;
  979. protected Widget m_WgtPnlWrapper;
  980. protected ButtonWidget m_WgtBtnLeftPresets;
  981. protected ButtonWidget m_WgtBtnPositionManager;
  982. protected string m_SelectedObject;
  983. protected bool m_SelectedObjectIsPreset;
  984. protected PluginDeveloper m_Developer;
  985. protected UIPopupScriptPositionManager m_PopupScriptPositionManager;
  986. protected PluginConfigDebugProfileFixed m_ConfigDebugProfileFixed;
  987. protected PluginConfigDebugProfile m_ConfigDebugProfile;
  988. //---- Functions
  989. protected void RefreshByLocalProfile();
  990. //--------------------------------------------
  991. // UpdateListObjects
  992. //--------------------------------------------
  993. private void UpdateListObjects()
  994. {
  995. m_SlObjectsList = GetFiltredSceneObjects(m_SlWgtEbxFilter.GetText(), m_SlObjectsList);
  996. m_SlWgtLbxObjectsList.ClearItems();
  997. int row = -1;
  998. SceneObject selected_object = m_ModuleSceneManager.GetSelectedSceneObject();
  999. for ( int i = 0; i < m_SlObjectsList.Count(); ++i )
  1000. {
  1001. SceneObject scene_obj = m_SlObjectsList.GetElement(i);
  1002. if ( selected_object != NULL && selected_object == scene_obj )
  1003. {
  1004. row = i;
  1005. }
  1006. m_SlWgtLbxObjectsList.AddItem(scene_obj.GetTypeName(), NULL, 0);
  1007. }
  1008. m_SlWgtLbxObjectsList.SelectRow(row);
  1009. }
  1010. //--------------------------------------------
  1011. // UpdateListClasses
  1012. //--------------------------------------------
  1013. protected void UpdateListClasses()
  1014. {
  1015. m_ClClassesList = GetFiltredConfigClasses(m_ClWgtEbxFilter.GetText(), m_ClClassesList);
  1016. m_ClWgtLbxClassesList.ClearItems();
  1017. for ( int i = 0; i < m_ClClassesList.Count(); ++i )
  1018. {
  1019. m_ClWgtLbxClassesList.AddItem(m_ClClassesList.Get(i), NULL, 0);
  1020. }
  1021. }
  1022. //--------------------------------------------
  1023. // GetFiltredSceneObjects
  1024. //--------------------------------------------
  1025. protected map<int, SceneObject> GetFiltredSceneObjects( string search_string, map<int, SceneObject> array_ret )
  1026. {
  1027. array<ref SceneObject> scene_objects = m_ModuleSceneManager.GetSceneObjectsAll();
  1028. search_string.ToLower();
  1029. array_ret.Clear();
  1030. if( scene_objects != NULL )
  1031. {
  1032. for ( int i=0; i < scene_objects.Count(); ++i )
  1033. {
  1034. SceneObject sc_obj = scene_objects.Get(i);
  1035. string obj_name = sc_obj.GetTypeName();
  1036. obj_name.ToLower();
  1037. if ( obj_name.Contains(search_string))
  1038. {
  1039. array_ret.Insert(i, sc_obj);
  1040. }
  1041. }
  1042. }
  1043. return array_ret;
  1044. }
  1045. //--------------------------------------------
  1046. // GetFiltredConfigClasses
  1047. //--------------------------------------------
  1048. TStringArray GetFiltredConfigClasses( string search_string, TStringArray array_ret )
  1049. {
  1050. TStringArray searching_in = new TStringArray;
  1051. searching_in.Insert(CFG_VEHICLESPATH);
  1052. searching_in.Insert(CFG_WEAPONSPATH);
  1053. searching_in.Insert(CFG_MAGAZINESPATH);
  1054. array_ret.Clear();
  1055. search_string.ToLower();
  1056. for ( int s = 0; s < searching_in.Count(); ++s )
  1057. {
  1058. string config_path = searching_in.Get(s);
  1059. int objects_count = g_Game.ConfigGetChildrenCount(config_path);
  1060. for (int i = 0; i < objects_count; i++)
  1061. {
  1062. string childName;
  1063. g_Game.ConfigGetChildName(config_path, i, childName);
  1064. int scope = g_Game.ConfigGetInt(config_path + " " + childName + " scope");
  1065. if ( scope == 0 )
  1066. {
  1067. continue;
  1068. }
  1069. string nchName = childName;
  1070. nchName.ToLower();
  1071. if ( nchName.Contains(search_string))
  1072. {
  1073. array_ret.Insert(childName);
  1074. }
  1075. }
  1076. }
  1077. return array_ret;
  1078. }
  1079. //--------------------------------------------
  1080. // PopupClose
  1081. //--------------------------------------------
  1082. private void PopupClose(int popup_id)
  1083. {
  1084. }
  1085. //--------------------------------------------
  1086. // PopupCloseAll
  1087. //--------------------------------------------
  1088. private void PopupHideAll()
  1089. {
  1090. for ( int i = 0; i < m_Popups.Count(); ++i )
  1091. {
  1092. m_Popups.Get(i).Show(false);
  1093. }
  1094. m_WgtPopupsMain.Show(false);
  1095. m_WgtPopupsBg.Show(false);
  1096. }
  1097. //--------------------------------------------
  1098. // ComponentsOnClick
  1099. //--------------------------------------------
  1100. private bool ComponentsOnClick(Widget w, int x, int y, int button)
  1101. {
  1102. for ( int i = 0; i < m_Popups.Count(); ++i )
  1103. {
  1104. if ( m_Popups.Get(i).OnClick(w, x, y, button) )
  1105. {
  1106. return true;
  1107. }
  1108. }
  1109. for ( int j = 0; j < m_PrWidgetsAttachments.Count(); ++j )
  1110. {
  1111. if ( m_PrWidgetsAttachments.Get(j).OnClick(w, x, y, button) )
  1112. {
  1113. return true;
  1114. }
  1115. }
  1116. return false;
  1117. }
  1118. //--------------------------------------------
  1119. // ComponentsOnChange
  1120. //--------------------------------------------
  1121. private bool ComponentsOnChange(Widget w, int x, int y, bool finished)
  1122. {
  1123. for ( int i = 0; i < m_Popups.Count(); ++i )
  1124. {
  1125. if ( m_Popups.Get(i).OnChange(w, x, y, finished) )
  1126. {
  1127. return true;
  1128. }
  1129. }
  1130. return false;
  1131. }
  1132. //--------------------------------------------
  1133. // GetFreeUIPropertyAttchament
  1134. //--------------------------------------------
  1135. UIPropertyAttachment GetFreeUIPropertyAttchament()
  1136. {
  1137. for ( int i = 0; i < m_PrWidgetsAttachments.Count(); ++i )
  1138. {
  1139. UIPropertyAttachment ui_comp = m_PrWidgetsAttachments.Get(i);
  1140. if ( !ui_comp.IsVisible() )
  1141. {
  1142. return ui_comp;
  1143. }
  1144. }
  1145. UIPropertyAttachment ui_prop = new UIPropertyAttachment(m_PrWgtAttRoot);
  1146. m_PrWidgetsAttachments.Insert(ui_prop);
  1147. return ui_prop;
  1148. }
  1149. //--------------------------------------------
  1150. // GetItemNamesForSlots
  1151. //--------------------------------------------
  1152. private map<string, ref TStringArray> GetItemNamesForSlots(TStringArray slots)
  1153. {
  1154. TStringArray searching_in = new TStringArray;
  1155. searching_in.Insert(CFG_VEHICLESPATH);
  1156. searching_in.Insert(CFG_WEAPONSPATH);
  1157. searching_in.Insert(CFG_MAGAZINESPATH);
  1158. map<string, ref TStringArray> array_ret = new map<string, ref TStringArray>;
  1159. for ( int m = 0; m < slots.Count(); ++m )
  1160. {
  1161. array_ret.Insert(slots.Get(m), new TStringArray);
  1162. }
  1163. TStringArray inv_slots = new TStringArray;
  1164. string inv_slot;
  1165. string childName;
  1166. for ( int s = 0; s < searching_in.Count(); ++s )
  1167. {
  1168. string config_path = searching_in.Get(s);
  1169. int objects_count = g_Game.ConfigGetChildrenCount(config_path);
  1170. for (int i = 0; i < objects_count; i++)
  1171. {
  1172. g_Game.ConfigGetChildName(config_path, i, childName);
  1173. g_Game.ConfigGetTextArray(config_path + " " + childName + " inventorySlot", inv_slots);
  1174. if ( inv_slots.Count() > 0 )
  1175. {
  1176. for ( int j = 0; j < inv_slots.Count(); ++j )
  1177. {
  1178. inv_slot = "";
  1179. inv_slot = inv_slots.Get(j);
  1180. for ( int k = 0; k < slots.Count(); ++k )
  1181. {
  1182. string finding_slot_type = slots.Get(k);
  1183. if ( inv_slot == finding_slot_type )
  1184. {
  1185. array_ret.Get(finding_slot_type).Insert(childName);
  1186. }
  1187. }
  1188. }
  1189. }
  1190. else
  1191. {
  1192. inv_slot = "";
  1193. g_Game.ConfigGetText(config_path + " " + childName + " inventorySlot", inv_slot);
  1194. if ( inv_slot != "" )
  1195. {
  1196. for ( int l = 0; l < slots.Count(); ++l )
  1197. {
  1198. string finding_slot_type_2 = slots.Get(l);
  1199. if ( inv_slot == finding_slot_type_2 )
  1200. {
  1201. array_ret.Get(finding_slot_type_2).Insert(childName);
  1202. }
  1203. }
  1204. }
  1205. }
  1206. }
  1207. }
  1208. return array_ret;
  1209. }
  1210. }