Advertisement
Nuor

ui_pda_relations_tab.script

Nov 26th, 2016
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.20 KB | None | 0 0
  1. UIRelations = nil
  2. class "pda_relations_tab" (CUIScriptWnd)
  3. function pda_relations_tab:__init() super()
  4. self.list = {
  5. "stalker",
  6. "dolg",
  7. "freedom",
  8. "csky",
  9. "ecolog",
  10. "killer",
  11. "army",
  12. "bandit",
  13. "monolith"
  14. }
  15.  
  16. self.color_codes = {
  17. GetARGB(255,255,255,255),
  18. GetARGB(255,255,128,0),
  19. GetARGB(255,0,255,255),
  20. GetARGB(255,0,255,128),
  21. GetARGB(255,0,128,255),
  22. GetARGB(255,255,0,128),
  23. GetARGB(255,128,255,0),
  24. GetARGB(255,255,0,0),
  25. GetARGB(255,0,255,0),
  26. GetARGB(255,0,0,255),
  27. GetARGB(255,128,0,255),
  28. }
  29.  
  30. self.companion_info = {}
  31. self.to_text = true
  32. self._tmr = time_global()
  33.  
  34. self:InitControls()
  35. self:Reset()
  36. end
  37.  
  38. function pda_relations_tab:__finalize() end
  39.  
  40. function pda_relations_tab:InitControls()
  41. self:SetWndRect(Frect():set(0, 0, 1024, 768))
  42.  
  43. local xml = CScriptXmlInit()
  44. xml:ParseFile("pda_relations.xml")
  45.  
  46. xml:InitFrame("frame",self)
  47. xml:InitStatic("center_background", self)
  48. self.tab = xml:InitStatic("tab", self)
  49. xml:InitStatic("tab:caption", self.tab)
  50.  
  51. self.btn = xml:Init3tButton("btn_to_text", self)
  52. self:Register(self.btn, "btn")
  53. self:AddCallback("btn", ui_events.BUTTON_CLICKED, self.btn_to_text, self)
  54.  
  55. -- Relation Matrix
  56. self.relations = {}
  57.  
  58. local is_widescreen = utils.is_widescreen()
  59. local x = is_widescreen and 40 or 55
  60. local c_width = is_widescreen and 75 or 90
  61. local c_height = 35
  62.  
  63. for i=1, #self.list do
  64. x = x + c_width
  65. local iobj = xml:InitTextWnd("tab:faction", self.tab)
  66. iobj:SetWndPos(vector2():set(x,65))
  67. iobj:SetText(game.translate_string(self.list[i]))
  68.  
  69. self.relations[i] = {}
  70. local y = 60
  71. for k=0, #self.list do
  72. y = y + c_height
  73. if (i == 1) then
  74. local kobj = xml:InitTextWnd("tab:faction", self.tab)
  75. kobj:SetWndPos(vector2():set(x - c_width, y))
  76. if k > 0 then
  77. kobj:SetText(game.translate_string(self.list[k]))
  78. else
  79. kobj:SetText(game.translate_string("st_actor_generic_name"))
  80. end
  81. end
  82. self.relations[i][k] = xml:InitTextWnd("tab:cell",self.tab)
  83. self.relations[i][k]:SetWndPos(vector2():set(x,y))
  84. end
  85. end
  86.  
  87. -- Companion ListView
  88. xml:InitFrame("companion_frame",self)
  89. xml:InitStatic("companion_background",self)
  90.  
  91. self.companion_listbox = xml:InitListBox("companion_wnd",self)
  92. self.companion_listbox:SetItemHeight(140)
  93. self:Register(self.companion_listbox, "list_companion")
  94. self:AddCallback("list_companion",ui_events.LIST_ITEM_CLICKED,self.OnSelectCompanionList,self)
  95.  
  96. self.auto_chk = xml:InitCheck("auto_check",self)
  97. self.auto_chk:SetCheck(false)
  98.  
  99. for row=1,4 do
  100. local row_form = ui_companion_row(self,row,xml)
  101. row_form:SetWndSize(vector2():set(740,140))
  102. self.companion_listbox:AddExistingItem(row_form)
  103. end
  104.  
  105. -- Hint Window
  106. self.hint_wnd = xml:InitFrame("hint_wnd:background",self)
  107. self.hint_wnd_text = xml:InitTextWnd("hint_wnd:text",self.hint_wnd)
  108. self.hint_wnd:SetWndPos(vector2():set(-2048,-2048))
  109.  
  110. -- Message Window
  111. self.msg_wnd = xml:InitFrame("hint_wnd:background",self)
  112. self.msg_wnd_text = xml:InitTextWnd("hint_wnd:text",self.msg_wnd)
  113. self.msg_wnd_text:SetTextAlignment(2)
  114.  
  115. self.msg_wnd:SetWndPos(vector2():set(-2048,-2048))
  116. self.msg_wnd:SetColor(GetARGB(255,0,0,0))
  117. end
  118.  
  119. function pda_relations_tab:Update()
  120. CUIScriptWnd.Update(self)
  121. -- option to auto update values
  122. if self.auto_chk:GetCheck() then
  123. local tg = time_global()
  124. if self._tmr < tg then
  125. self._tmr = tg + 2000
  126. self:autoupdate()
  127. end
  128. end
  129.  
  130. -- Warning messages timer
  131. if (self.msg_wnd_timer and time_global() > self.msg_wnd_timer) then
  132. self.msg_wnd_timer = nil
  133. self.msg_wnd:SetWndPos(vector2():set(-2048,-2048))
  134. end
  135.  
  136. if not (self.disabled) then
  137. for i=1, 24 do -- should be row*col from ui_companion_row
  138. if (self.companion_info[i].icon_wnd:IsShown()) then
  139. local pos = GetCursorPosition()
  140. local rect = Frect():set(0,0,0,0)
  141. self.companion_info[i].icon_wnd:GetAbsoluteRect(rect)
  142.  
  143. if (utils.pos_in_rect(pos,rect)) then
  144. self:SetHint(self.companion_info[i].hint,pos)
  145. --FitInRect(self.background,self.rect,0,0)
  146. self.mouse_over_id = i
  147. return
  148. end
  149. end
  150. end
  151. end
  152. self.mouse_over_id = nil
  153. self.hint_wnd:SetWndPos(vector2():set(-2048,-2048))
  154. end
  155.  
  156. function pda_relations_tab:autoupdate()
  157. local id_to_code = {}
  158. local clist = axr_companions.list_actor_squad_by_id()
  159. for i=1,24 do -- should be row*col from ui_companion_row
  160. local se_obj = clist[i] and alife_object(clist[i])
  161. if (se_obj and IsStalker(nil,se_obj:clsid()) and se_obj:alive()) then
  162. local full_name = se_obj:character_name()
  163. local name = string.gsub(full_name,"Junior","Jr.")
  164. name = string.gsub(name,"Senior","Sr.")
  165. name = string.gsub(name,"Master ","M")
  166. name = string.gsub(name,"Private","PVT")
  167. name = string.gsub(name,"Sergeant","SGT")
  168. name = string.gsub(name,"Lieutenant","LT")
  169. name = string.gsub(name,"Captain","CPT")
  170.  
  171. local name = string.len(name) <= 22 and name or string.sub(name, 0, 19) .. "..."
  172.  
  173. self.companion_info[i].id = se_obj.id
  174.  
  175. local st = db.storage[se_obj.id]
  176. local npc = st and st.object
  177.  
  178. local icon_name = npc and npc:character_icon() or se_obj:character_icon()
  179. icon_name = icon_name and icon_name ~= "" and icon_name or "ui\\ui_noise"
  180. self.companion_info[i].icon_wnd:InitTexture(icon_name)
  181. self.companion_info[i].icon_wnd:Show(true)
  182.  
  183. self.companion_info[i].name_wnd:SetText(name)
  184. self.companion_info[i].comm_wnd:SetText(game.translate_string(se_obj:community()))
  185. self.companion_info[i].rank_wnd:SetText(game.translate_string("st_rank_"..ranks.get_se_obj_rank_name(se_obj)).." ("..se_obj:rank()..")")
  186. self.companion_info[i].dist_wnd:SetText(string.format("Distance to: %.2f", se_obj.position:distance_to(db.actor:position())))
  187.  
  188. -- leader and relation status
  189. local squad = se_obj.group_id and se_obj.group_id ~= 65535 and alife_object(se_obj.group_id)
  190. if (squad and squad:commander_id() == se_obj.id) then
  191. self.companion_info[i].leader_wnd:Show(true)
  192. self.companion_info[i].leader_wnd:InitTexture("ui_minimap_squad_leader")
  193. else
  194. self.companion_info[i].leader_wnd:Show(true)
  195. self.companion_info[i].leader_wnd:InitTexture("ui_minimap_point")
  196. end
  197.  
  198. -- Set color code
  199. if not (id_to_code[se_obj.group_id]) then
  200. local n = 1
  201. for k,v in pairs(id_to_code) do
  202. n = n + 1
  203. end
  204. id_to_code[se_obj.group_id] = self.color_codes[n] or self.color_codes[1]
  205. end
  206. self.companion_info[i].leader_wnd:SetTextureColor(id_to_code[se_obj.group_id])
  207.  
  208.  
  209. -- health status
  210. if (npc) then
  211. local hp = math.floor(npc.health*100)
  212. self.companion_info[i].health_wnd:SetText(hp.."%")
  213. if (hp > 70) then
  214. self.companion_info[i].health_wnd:SetTextColor(GetARGB(200, 0, 255, 0))
  215. elseif (hp < 30) then
  216. self.companion_info[i].health_wnd:SetTextColor(GetARGB(200, 255, 0, 0))
  217. else
  218. self.companion_info[i].health_wnd:SetTextColor(GetARGB(200, 255, 255, 255))
  219. end
  220. end
  221.  
  222. -- Hint
  223. local s_move,s_combat,s_gather,s_loot,s_dist,s_stealth,s_arte,s_stalker,s_mutant,s_dismiss,s_tele
  224. local state_str = [[
  225. %c[255,255,215,255]%c[default] %s \n\n
  226. %c[255,215,215,215]States:%c[default] \n
  227. %c[255,160,160,160]Movement:%c[default] %s \n
  228. %c[255,160,160,160]Combat:%c[default] %s \n
  229. %c[255,160,160,160]Pickup items:%c[default] %s \n
  230. %c[255,160,160,160]Loot corpses:%c[default] %s \n
  231. %c[255,160,160,160]Keep distance:%c[default] %s \n
  232. %c[255,160,160,160]Stealth:%c[default] %s \n
  233. %c[255,160,160,160]Dismissable:%c[default] %s \n
  234. %c[255,160,160,160]Level travel:%c[default] %s \n
  235.  
  236. \n%c[255,215,215,215]Statistics:%c[default] \n
  237. %c[255,160,160,160]Stalkers killed:%c[default] %s \n
  238. %c[255,160,160,160]Mutants killed:%c[default] %s \n
  239. %c[255,160,160,160]Artefacts found:%c[default] %s \n
  240. ]]
  241.  
  242. if (alife():has_info(se_obj.id,"npcx_beh_wait")) then
  243. s_move = game.translate_string("st_set_companion_to_wait_state")
  244. elseif (alife():has_info(se_obj.id,"npcx_beh_patrol_mode")) then
  245. s_move = game.translate_string("st_set_companion_to_patrol_state")
  246. else
  247. s_move = game.translate_string("st_set_companion_to_follow_state")
  248. end
  249.  
  250. if (alife():has_info(se_obj.id,"npcx_beh_ignore_actor_enemies") and alife():has_info(se_obj.id,"npcx_beh_ignore_combat")) then
  251. s_combat = game.translate_string("st_set_companion_to_ignore_combat_state")
  252. elseif (alife():has_info(se_obj.id,"npcx_beh_ignore_combat")) then
  253. s_combat = game.translate_string("st_set_companion_to_attack_only_actor_combat_enemy_state")
  254. else
  255. s_combat = game.translate_string("st_set_companion_to_attack_state")
  256. end
  257.  
  258. local can_gather = alife():has_info(se_obj.id,"npcx_beh_gather_items")
  259. local can_loot = alife():has_info(se_obj.id,"npcx_beh_loot_corpses")
  260. s_gather = can_gather and game.translate_string("st_pda_mode_on") or game.translate_string("st_pda_mode_off")
  261. s_loot = can_loot and game.translate_string("st_pda_mode_on") or game.translate_string("st_pda_mode_off")
  262.  
  263. if (npc) then
  264. -- If looting is set false in logic
  265. if (can_gather and st.gather_items and st.gather_items.gather_items_enabled and xr_logic.pick_section_from_condlist(db.actor, npc, st.gather_items.gather_items_enabled) == "false") then
  266. s_gather = game.translate_string("st_pda_mode_disabled")
  267. end
  268. if (can_loot and st.corpse_detection and st.corpse_detection.corpse_detection_enabled and xr_logic.pick_section_from_condlist(db.actor, npc, st.corpse_detection.corpse_detection_enabled) == "false") then
  269. s_loot = game.translate_string("st_pda_mode_disabled")
  270. end
  271. end
  272.  
  273. s_dist = alife():has_info(se_obj.id,"npcx_beh_distance_far") and game.translate_string("st_pda_mode_dist_far") or game.translate_string("st_pda_mode_dist_near")
  274. s_stealth = alife():has_info(se_obj.id,"npcx_beh_substate_stealth") and game.translate_string("st_pda_mode_on") or game.translate_string("st_pda_mode_off")
  275.  
  276. local m_data = alife_storage_manager.get_se_obj_state(se_obj)
  277. if (m_data) then
  278. s_stalker = m_data.stalkers_killed or 0
  279. s_mutant = m_data.mutants_killed or 0
  280. s_arte = m_data.artefacts_found or 0
  281. end
  282.  
  283. s_dismiss = utils.se_obj_load_var(se_obj.id,se_obj:name(),"companion_cannot_dismiss") and game.translate_string("st_pda_mode_false") or game.translate_string("st_pda_mode_true")
  284. s_tele = utils.se_obj_load_var(se_obj.id,se_obj:name(),"companion_cannot_teleport") and game.translate_string("st_pda_mode_disabled") or game.translate_string("st_pda_mode_enabled")
  285.  
  286. state_str = strformat(state_str,full_name,s_move,s_combat,s_gather,s_loot,s_dist,s_stealth,s_dismiss,s_tele,s_stalker,s_mutant,s_arte)
  287. self.companion_info[i].hint = state_str
  288. else
  289. self.companion_info[i].id = nil
  290. self.companion_info[i].icon_wnd:Show(false)
  291. self.companion_info[i].leader_wnd:Show(false)
  292. self.companion_info[i].health_wnd:SetText("")
  293. self.companion_info[i].name_wnd:SetText("")
  294. self.companion_info[i].comm_wnd:SetText("")
  295. self.companion_info[i].rank_wnd:SetText("")
  296. self.companion_info[i].dist_wnd:SetText("")
  297. end
  298. end
  299. end
  300.  
  301. function pda_relations_tab:Reset()
  302. for i=1, #self.list do
  303. for k=0, #self.list do
  304. local comm = self.list[k] or db.actor:character_community()
  305. local r_val = relation_registry.community_relation(comm, self.list[i])
  306. if r_val >= game_relations.FRIENDS then
  307. self.relations[i][k]:SetTextColor(GetARGB(255, 1, 255, 1))
  308. self.relations[i][k]:SetText(game.translate_string("st_goodwill_friendly"))
  309.  
  310. elseif r_val <= game_relations.ENEMIES then
  311. self.relations[i][k]:SetTextColor(GetARGB(255, 255, 1, 1))
  312. self.relations[i][k]:SetText(game.translate_string("st_goodwill_enemy"))
  313.  
  314. else
  315. self.relations[i][k]:SetTextColor(GetARGB(255, 255, 255, 1))
  316. self.relations[i][k]:SetText(game.translate_string("st_goodwill_indifferent"))
  317.  
  318. end
  319.  
  320. if not (self.to_text) then self.relations[i][k]:SetText(tostring(r_val)) end
  321. end
  322. end
  323.  
  324. self:autoupdate()
  325. end
  326.  
  327. function pda_relations_tab:OnSelectCompanionList()
  328. if not (self.mouse_over_id) then
  329. return
  330. end
  331.  
  332. local id = self.companion_info[self.mouse_over_id].id
  333. local npc = id and db.storage[id] and db.storage[id].object
  334. if not (npc) then
  335. return
  336. end
  337.  
  338. self:CreateContextMenu(npc,id)
  339. end
  340.  
  341. function pda_relations_tab:btn_to_text()
  342. self.to_text = not self.to_text
  343. if self.to_text then
  344. self.btn:TextControl():SetText(game.translate_string("pda_table_value_off"))
  345. else
  346. self.btn:TextControl():SetText(game.translate_string("pda_table_value_on"))
  347. end
  348.  
  349. self:Reset()
  350. end
  351.  
  352. function pda_relations_tab:SetMsg(text,tmr)
  353. self.msg_wnd_text:SetText(text)
  354. self.msg_wnd_text:AdjustHeightToText()
  355. self.msg_wnd_text:SetWndSize(vector2():set(820,self.msg_wnd_text:GetHeight()))
  356. self.msg_wnd_text:SetWndPos(vector2():set(0,20))
  357.  
  358. self.msg_wnd:SetWndSize(vector2():set(820,self.msg_wnd_text:GetHeight()+44))
  359. self.msg_wnd:SetWndPos(vector2():set(0,80))
  360.  
  361. self.msg_wnd_timer = time_global() + 1000*tmr
  362. end
  363.  
  364. function pda_relations_tab:SetHint(text,pos)
  365. self.hint_wnd_text:SetText(text)
  366. self.hint_wnd_text:AdjustHeightToText()
  367. self.hint_wnd:SetWndSize(vector2():set(self.hint_wnd:GetWidth(),self.hint_wnd_text:GetHeight()+44))
  368.  
  369. pos.y = pos.y - self.hint_wnd:GetHeight()
  370. pos.x = pos.x - self.hint_wnd:GetWidth()
  371. self.hint_wnd:SetWndPos(pos)
  372. end
  373.  
  374. function pda_relations_tab:CreateContextMenu(npc,id)
  375. local pos = GetCursorPosition()
  376. local se_obj = alife_object(id)
  377. if not (se_obj) then
  378. return
  379. end
  380. local squad = se_obj.group_id and se_obj.group_id ~= 65535 and alife_object(se_obj.group_id)
  381.  
  382. -- Actions
  383. local action_1 = nil -- Main
  384. local action_1__1 = nil -- Trade
  385. local action_1__2 = nil -- Commands
  386. local action_1__2_1 = nil -- Back
  387. local action_1__2_2 = nil -- Movement
  388. local action_1__2_2_1 = nil -- Back
  389. local action_1__2_2_2 = nil -- Follow/Wait
  390. local action_1__2_2_3 = nil -- Far/Near Distance
  391. local action_1__2_3 = nil -- Combat
  392. local action_1__2_3_1 = nil -- Back
  393. local action_1__2_3_2 = nil -- Passive
  394. local action_1__2_3_3 = nil -- Defensive
  395. local action_1__2_3_4 = nil -- Aggressive
  396. local action_1__2_4 = nil -- Looting
  397. local action_1__2_4_1 = nil -- Back
  398. local action_1__2_4_2 = nil -- Gather Items (toggle)
  399. local action_1__2_4_3 = nil -- Loot Corpses (toggle)
  400. local action_1__2_5 = nil -- Stealth
  401.  
  402. -- Action Trees
  403. local action_list_1 = nil
  404. local action_list_1__2 = nil
  405. local action_list_1__2_2 = nil
  406. local action_list_1__2_3 = nil
  407. local action_list_1__2_4 = nil
  408.  
  409. -- Action definitions
  410. action_1 = function()
  411. ui_dyn_msg_box.context_menu(self,pos,action_list_1,"st_pda_action_1__1","st_pda_action_1__2")
  412. end
  413.  
  414. action_1__1 = function()
  415. if not (utils.se_obj_load_var(se_obj.id,se_obj:name(),"companion_cannot_dismiss")) then
  416. npc:use(db.actor)
  417. --npc:start_trade(db.actor)
  418. else
  419. self:SetMsg(game.translate_string("st_pda_cant_trade"),3)
  420. end
  421. end
  422.  
  423. action_1__2 = function()
  424. local st_stealth = npc:has_info("npcx_beh_substate_stealth") and "st_pda_action_1__2_5_on" or "st_pda_action_1__2_5_off"
  425. ui_dyn_msg_box.context_menu(self,pos,action_list_1__2,"st_pda_action_back","st_pda_action_1__2_2","st_pda_action_1__2_3","st_pda_action_1__2_4",st_stealth)
  426. end
  427.  
  428. action_1__2_1 = function()
  429. action_1()
  430. end
  431.  
  432. action_1__2_2 = function()
  433. local st_movement_state = npc:has_info("npcx_beh_wait") and "st_pda_action_1__2_2_2_on" or "st_pda_action_1__2_2_2_off"
  434. local st_distance_state = npc:has_info("npcx_beh_distance_far") and "st_pda_action_1__2_2_3_on" or "st_pda_action_1__2_2_3_off"
  435. ui_dyn_msg_box.context_menu(self,pos,action_list_1__2_2,"st_pda_action_back",st_movement_state,st_distance_state)
  436. end
  437.  
  438. action_1__2_3 = function()
  439. ui_dyn_msg_box.context_menu(self,pos,action_list_1__2_3,"st_pda_action_back","st_pda_action_1__2_3_2","st_pda_action_1__2_3_3","st_pda_action_1__2_3_4")
  440. end
  441.  
  442. action_1__2_4 = function()
  443. local st_gather = npc:has_info("npcx_beh_gather_items") and "st_pda_action_1__2_4_2_on" or "st_pda_action_1__2_4_2_off"
  444. local st_loot = npc:has_info("npcx_beh_loot_corpses") and "st_pda_action_1__2_4_3_on" or "st_pda_action_1__2_4_3_off"
  445. ui_dyn_msg_box.context_menu(self,pos,action_list_1__2_4,"st_pda_action_back",st_gather,st_loot)
  446. end
  447.  
  448. action_1__2_5 = function()
  449. local mode = npc:has_info("npcx_beh_substate_stealth") and 0 or 1
  450. axr_companions.set_companion_squad_stealth_mode(mode,npc,squad)
  451. self:Reset()
  452. end
  453.  
  454. action_1__2_2_1 = function()
  455. action_1__2()
  456. end
  457.  
  458. action_1__2_2_2 = function()
  459. local mode = npc:has_info("npcx_beh_wait") and 2 or 1
  460. axr_companions.set_companion_squad_move_mode(mode,npc,squad)
  461. self:Reset()
  462. end
  463.  
  464. action_1__2_2_3 = function()
  465. local mode = npc:has_info("npcx_beh_distance_far") and 0 or 1
  466. axr_companions.set_companion_squad_distance_mode(mode,npc,squad)
  467. self:Reset()
  468. end
  469.  
  470. action_1__2_3_1 = function()
  471. action_1__2()
  472. end
  473.  
  474. action_1__2_3_2 = function()
  475. axr_companions.set_companion_squad_combat_mode(2,npc,squad)
  476. self:Reset()
  477. end
  478.  
  479. action_1__2_3_3 = function()
  480. axr_companions.set_companion_squad_combat_mode(3,npc,squad)
  481. self:Reset()
  482. end
  483.  
  484. action_1__2_3_4 = function()
  485. axr_companions.set_companion_squad_combat_mode(1,npc,squad)
  486. self:Reset()
  487. end
  488.  
  489. action_1__2_4_1 = function()
  490. action_1__2()
  491. end
  492.  
  493. action_1__2_4_2 = function()
  494. local mode = npc:has_info("npcx_beh_gather_items") and 0 or 1
  495. axr_companions.set_companion_squad_gather_mode(mode,npc,squad)
  496. self:Reset()
  497. end
  498.  
  499. action_1__2_4_3 = function()
  500. local mode = npc:has_info("npcx_beh_loot_corpses") and 0 or 1
  501. axr_companions.set_companion_squad_loot_mode(mode,npc,squad)
  502. self:Reset()
  503. end
  504.  
  505. action_1__2_5 = function()
  506. local mode = npc:has_info("npcx_beh_substate_stealth") and 0 or 1
  507. axr_companions.set_companion_squad_stealth_mode(mode,npc,squad)
  508. self:Reset()
  509. end
  510.  
  511. -- Action List definitions
  512. action_list_1 = {action_1__1,action_1__2}
  513. action_list_1__2 = {action_1__2_1,action_1__2_2,action_1__2_3,action_1__2_4,action_1__2_5}
  514. action_list_1__2_2 = {action_1__2_2_1,action_1__2_2_2,action_1__2_2_3}
  515. action_list_1__2_3 = {action_1__2_3_1,action_1__2_3_2,action_1__2_3_3,action_1__2_3_4}
  516. action_list_1__2_4 = {action_1__2_4_1,action_1__2_4_2,action_1__2_4_3}
  517.  
  518. -- Create Main Context Menu
  519. ui_dyn_msg_box.context_menu(self,pos,action_list_1,"st_pda_action_1__1","st_pda_action_1__2")
  520. end
  521. ---------------------------------------------------------------------------------------------------
  522. --
  523. ---------------------------------------------------------------------------------------------------
  524. class "ui_companion_row" (CUIListBoxItem)
  525. function ui_companion_row:__init(owner,row,xml) super(owner,row,xml)
  526. self:GetTextItem():SetText("")
  527.  
  528. local is_widescreen = utils.is_widescreen()
  529. local x = is_widescreen and 20 or 35
  530. local y = 0
  531. --[[
  532. local wind = {
  533. ["icon_wnd"] = {64,64,0,0,"ui\\ui_noise"},
  534. ["leader_wnd"] = {is_widescreen and 8 or 10,10,0,0,"ui_minimap_squad_leader"},
  535. ["name_wnd"] = {120,22,0,65,GetFontLetterica18Russian()},
  536. ["comm_wnd"] = {120,20,0,90,GetFontLetterica16Russian()},
  537. ["rank_wnd"] = {120,20,0,105,GetFontLetterica16Russian()},
  538. ["health_wnd"] = {50,10,50,55,GetFontSmall()},
  539. ["dist_wnd"] = {120,20,0,120,GetFontLetterica16Russian()},
  540. }
  541. local function add_wnd(element)
  542. for wnd, v in pairs(wind) do
  543. owner.companion_info[element][wnd]:SetWndSize(vector2():set(v[1],v[2]))
  544. owner.companion_info[element][wnd]:SetWndPos(vector2():set(x+v[3],y+v[4]))
  545. if type(v[5]) == "string" then
  546. owner.companion_info[element][wnd]:InitTexture(v[5])
  547. owner.companion_info[element][wnd]:SetStretchTexture(true)
  548. else
  549. owner.companion_info[element][wnd]:SetFont(v[5])
  550. end
  551. end
  552. end
  553. --]]
  554. for i=1,6 do
  555. local n = i+(6*(row-1))
  556. owner.companion_info[n] = {
  557. ["id"] = nil,
  558. ["icon_wnd"] = self:AddIconField(1),
  559. ["leader_wnd"] = self:AddIconField(1),
  560. ["name_wnd"] = self:AddTextField("",1),
  561. ["comm_wnd"] = self:AddTextField("",1),
  562. ["rank_wnd"] = self:AddTextField("",1),
  563. ["health_wnd"] = self:AddTextField("",1),
  564. ["dist_wnd"] = self:AddTextField("",1),
  565. ["hint"] = ""
  566. }
  567.  
  568. -- add_wnd(n)
  569. --
  570. owner.companion_info[n].icon_wnd:InitTexture("ui\\ui_noise")
  571. owner.companion_info[n].icon_wnd:SetStretchTexture(true)
  572. owner.companion_info[n].icon_wnd:SetWndSize(vector2():set(64,64))
  573. owner.companion_info[n].icon_wnd:SetWndPos(vector2():set(x,y))
  574.  
  575. owner.companion_info[n].leader_wnd:InitTexture("ui_minimap_squad_leader")
  576. owner.companion_info[n].leader_wnd:SetStretchTexture(true)
  577. owner.companion_info[n].leader_wnd:SetWndSize(vector2():set(is_widescreen and 8 or 10,10))
  578. owner.companion_info[n].leader_wnd:SetWndPos(vector2():set(x,y))
  579.  
  580. owner.companion_info[n].name_wnd:SetFont(GetFontLetterica18Russian())
  581. owner.companion_info[n].name_wnd:SetWndSize(vector2():set(120,22))
  582. owner.companion_info[n].name_wnd:SetWndPos(vector2():set(x,y+65))
  583.  
  584. owner.companion_info[n].comm_wnd:SetFont(GetFontLetterica16Russian())
  585. owner.companion_info[n].comm_wnd:SetWndSize(vector2():set(120,20))
  586. owner.companion_info[n].comm_wnd:SetWndPos(vector2():set(x,y+90))
  587.  
  588. owner.companion_info[n].rank_wnd:SetFont(GetFontLetterica16Russian())
  589. owner.companion_info[n].rank_wnd:SetWndSize(vector2():set(120,20))
  590. owner.companion_info[n].rank_wnd:SetWndPos(vector2():set(x,y+105))
  591.  
  592. owner.companion_info[n].health_wnd:SetFont(GetFontSmall())
  593. owner.companion_info[n].health_wnd:SetWndSize(vector2():set(50,10))
  594. owner.companion_info[n].health_wnd:SetWndPos(vector2():set(x+50,y+55))
  595.  
  596. owner.companion_info[n].dist_wnd:SetFont(GetFontLetterica16Russian())
  597. owner.companion_info[n].dist_wnd:SetWndSize(vector2():set(120,20))
  598. owner.companion_info[n].dist_wnd:SetWndPos(vector2():set(x,y+120))
  599. --
  600. x = x + (is_widescreen and 125 or 180)
  601. end
  602. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement