Advertisement
Guest User

ui_faction_loot

a guest
Mar 27th, 2012
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.33 KB | None | 0 0
  1. class "ui_faction_loot" (CUIScriptWnd)
  2.  
  3. function ui_faction_loot:__init() super()
  4.   self:InitControls()
  5. end
  6.  
  7. function ui_faction_loot:InitControls()
  8.   self:Init(0, 0, device().width, device().height)
  9.  
  10.   self.overlay = CUIStatic()
  11.   self.overlay:SetAutoDelete(true)
  12.     -- replace x, y with position of overlay texture (position on hud)
  13.     -- and w, h with overlay texture's width and height, respectively
  14.     -- you can use device().width instead of w if you want to set screen's
  15.     -- width as a texture width
  16.   self.overlay:Init(510, 673, 60, 60)
  17.   self.overlay:InitTexture("ui\\ui_faction_empty")
  18.   self.overlay:SetStretchTexture(true) -- to stretch texture based on w, h
  19.   self.overlay:Show(false)
  20.   self:AttachChild(self.overlay)
  21.  
  22.   self.hud_stage = "no"
  23. end
  24.  
  25. --initialize and display overlay textures
  26. function ui_faction_loot:display_texture(idx)
  27.     if self.hud_stage ~= idx then
  28.         self.overlay:InitTexture("ui\\ui_faction_" .. idx)
  29.         self.overlay:Show(true)
  30.         self.hud_stage = idx
  31.     end
  32. end
  33.  
  34. function ui_faction_loot:Update()
  35.     CUIScriptWnd.Update(self)
  36.         local faction = "none"
  37.         if db.actor then
  38.             if has_alife_info("ui_car_body") then
  39.                 if treasure_manager and treasure_manager.npc_community_loot then
  40.                     faction = treasure_manager.npc_community_loot or "none"
  41.                 else
  42.                     faction = "none"
  43.                 end
  44.             end
  45.         if faction == "stalker" then
  46.             self:display_texture("stalker")
  47.         elseif faction == "trader" then
  48.             self:display_texture("stalker")
  49.         elseif faction == "bandit" then
  50.             self:display_texture("bandit")
  51.         elseif faction == "military" then
  52.             self:display_texture("military")
  53.         elseif faction == "dolg" then
  54.             self:display_texture("dolg")
  55.         elseif faction == "freedom" then
  56.             self:display_texture("freedom")
  57.         elseif faction == "ecolog" then
  58.             self:display_texture("ecolog")
  59.         elseif faction == "killer" then
  60.             self:display_texture("killer")
  61.         elseif faction == "monolith" then
  62.             self:display_texture("monolith")
  63.         elseif faction == "csky" then
  64.             self:display_texture("csky")
  65.         else
  66.             self:display_texture("empty")
  67.         end
  68.     end
  69. end
  70.  
  71. local HUD = nil
  72.  
  73. function add_custom_inv()
  74.   if HUD == nil then
  75.     HUD = ui_faction_loot()
  76.     get_hud():AddDialogToRender(HUD)
  77.   end
  78. end
  79.  
  80. function remove_custom_inv()
  81.   if HUD ~= nil then
  82.     get_hud():RemoveDialogToRender(HUD)
  83.     HUD = nil
  84.   end
  85. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement