Advertisement
Guest User

ui_factions.script

a guest
Mar 28th, 2012
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. local comms = {"stalker", "bandit", "military", "dolg", "freedom", "ecolog",
  2. "killer", "monolith", "csky", "trader", "zombied", "arena_enemy"}
  3.  
  4. class "ui_faction" (CUIScriptWnd)
  5. function ui_faction:__init() super()
  6. self.tex = nil
  7. self:InitControls()
  8. end
  9.  
  10. function ui_faction:Update()
  11. CUIScriptWnd.Update(self)
  12. if db.actor and treasure_manager and xr_motivator then
  13. if has_alife_info("ui_car_body") then
  14. if treasure_manager.npc_comm then self.tex = treasure_manager.npc_comm end
  15. if self.tex then
  16. self.textures[self.tex]:Show(true) end
  17. elseif db.actor:is_talking() then
  18. if xr_motivator.npc_community and self.tex ~= xr_motivator.npc_community then
  19. self.tex = xr_motivator.npc_community
  20. end
  21. if self.tex then self.textures[self.tex]:Show(true) end
  22. else
  23. if self.tex then
  24. self.tex = nil
  25. for i = 1, #comms do
  26. self.textures[comms[i]]:Show(false)
  27. end
  28. end
  29. end
  30. end
  31. end
  32.  
  33. function ui_faction:InitControls()
  34. self:Init(0, 0, device().width, device().height)
  35. local xml = CScriptXmlInit()
  36. xml:ParseFile("ui_faction.xml")
  37. self.textures = {}
  38. for i = 1, #comms do
  39. self.textures[comms[i]] = xml:InitStatic("ui_faction_"..comms[i], self)
  40. self.textures[comms[i]]:Show(false)
  41. end
  42. end
  43.  
  44. local HUD = nil
  45. function add_custom_inv()
  46. if HUD == nil then
  47. HUD = ui_faction()
  48. get_hud():AddDialogToRender(HUD)
  49. end
  50. end
  51.  
  52. function remove_custom_inv()
  53. if HUD ~= nil then
  54. get_hud():RemoveDialogToRender(HUD)
  55. HUD = nil
  56. end
  57. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement