Guest User

Minimalist

a guest
Jul 30th, 2015
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.36 KB | None | 0 0
  1.  
  2.  
  3. require "engine.class"
  4. local UI = require "engine.ui.Base"
  5. local UISet = require "mod.class.uiset.UISet"
  6. local DebugConsole = require "engine.DebugConsole"
  7. local HotkeysDisplay = require "engine.HotkeysDisplay"
  8. local HotkeysIconsDisplay = require "engine.HotkeysIconsDisplay"
  9. local ActorsSeenDisplay = require "engine.ActorsSeenDisplay"
  10. local LogDisplay = require "engine.LogDisplay"
  11. local LogFlasher = require "engine.LogFlasher"
  12. local FlyingText = require "engine.FlyingText"
  13. local Shader = require "engine.Shader"
  14. local Tooltip = require "mod.class.Tooltip"
  15. local TooltipsData = require "mod.class.interface.TooltipsData"
  16. local Dialog = require "engine.ui.Dialog"
  17. local Map = require "engine.Map"
  18. local FontPackage = require "engine.FontPackage"
  19.  
  20. module(..., package.seeall, class.inherit(UISet, TooltipsData))
  21.  
  22. --renamed copy from paradox
  23. libido_c = {0x2f/255, 0xa0/255, 0xb4/255}
  24. libido_c2 = {0x8f/255, 0x80/255, 0x44/255}
  25. libido_sha = Shader.new("resources2", {require_shader=4, delay_load=true, color1=libido_c, color2=libido_c2, amp=0.8, speed=20000, distort={0.1,0.25}})
  26.  
  27. fshat_libido = {core.display.loadImage("/data/gfx/ui/resources/front_libido.png"):glTexture()}
  28. fshat_libido_dark = {core.display.loadImage("/data/gfx/ui/resources/front_libido_dark.png"):glTexture()}
  29.  
  30.  
  31.  
  32. function _M:showResourceTooltip(x, y, w, h, id, desc, is_first)
  33.     if not game.mouse:updateZone(id, x, y, w, h, nil, self.places.resources.scale) then
  34.         game.mouse:registerZone(x, y, w, h, function(button, mx, my, xrel, yrel, bx, by, event)
  35.             if is_first then
  36.                 if event == "out" then self.mhandle.resources = nil return
  37.                 else self.mhandle.resources = true end
  38.  
  39.                 -- Move handle
  40.                 if not self.locked and bx >= self.mhandle_pos.resources.x and bx <= self.mhandle_pos.resources.x + move_handle[6] and by >= self.mhandle_pos.resources.y and by <= self.mhandle_pos.resources.y + move_handle[7] then
  41.                     if event == "button" and button == "right" then
  42.                         local player = game.player
  43.                         local list = {}
  44.                         if player:knowTalent(player.T_STAMINA_POOL) then list[#list+1] = {name="Stamina", id="stamina"} end
  45.                         if player:knowTalent(player.T_MANA_POOL) then list[#list+1] = {name="Mana", id="mana"} end
  46.                         if player:knowTalent(player.T_SOUL_POOL) then list[#list+1] = {name="Necrotic", id="soul"} end
  47.                         if player:knowTalent(player.T_EQUILIBRIUM_POOL) then list[#list+1] = {name="Equilibrium", id="equilibrium"} end
  48.                         if player:knowTalent(player.T_POSITIVE_POOL) then list[#list+1] = {name="Positive", id="positive"} end
  49.                         if player:knowTalent(player.T_NEGATIVE_POOL) then list[#list+1] = {name="Negative", id="negative"} end
  50.                         if player:knowTalent(player.T_PARADOX_POOL) then list[#list+1] = {name="Paradox", id="paradox"} end
  51.                         if player:knowTalent(player.T_LIBIDO_POOL) then list[#list+1] = {name="Libido", id="libido"} end
  52.                         if player:knowTalent(player.T_VIM_POOL) then list[#list+1] = {name="Vim", id="vim"} end
  53.                         if player:knowTalent(player.T_HATE_POOL) then list[#list+1] = {name="Hate", id="hate"} end
  54.                         if player:knowTalent(player.T_PSI_POOL) then list[#list+1] = {name="Psi", id="psi"} end
  55.                         if player:knowTalent(player.T_FEEDBACK_POOL) then list[#list+1] = {name="Feedback", id="feedback"} end
  56.                         Dialog:listPopup("Display/Hide resources", "Toggle:", list, 300, 300, function(sel)
  57.                             if not sel or not sel.id then return end
  58.                             game.player["_hide_resource_"..sel.id] = not game.player["_hide_resource_"..sel.id]
  59.                         end)
  60.                         return
  61.                     end
  62.                     self:uiMoveResize("resources", button, mx, my, xrel, yrel, bx, by, event, nil, nil, "\nRight click to toggle resources bars visibility")
  63.                     return
  64.                 end
  65.             end
  66.  
  67.             local extra = {log_str=desc}
  68.             game.mouse:delegate(button, mx, my, xrel, yrel, nil, nil, event, "playmap", extra)
  69.         end, nil, id, true, self.places.resources.scale)
  70.     end
  71. end
  72.  
  73. function _M:displayResources(scale, bx, by, a)
  74.     local player = game.player
  75.     if player then
  76.         local orient = self.sizes.resources and self.sizes.resources.orient or "right"
  77.         local x, y = 0, 0
  78.         --------------------libido
  79.         if player:knowTalent(player.T_LIBIDO_POOL) and not player._hide_resource_libido then
  80.             sshat[1]:toScreenFull(x-6, y+8, sshat[6], sshat[7], sshat[2], sshat[3], 1, 1, 1, a)
  81.             bshat[1]:toScreenFull(x, y, bshat[6], bshat[7], bshat[2], bshat[3], 1, 1, 1, a)
  82.             local chance = player:libidoFailChance()
  83.             local s = chance
  84.             if s > 15 then s = 15 end
  85.             s = s / 15
  86.             if libido_sha.shad then
  87.                 libido_sha:setUniform("pivot", math.sqrt(s))
  88.                 libido_sha:setUniform("a", a)
  89.                 libido_sha:setUniform("speed", 10000 - s * 7000)
  90.                 libido_sha.shad:use(true)
  91.             end
  92.             local p = util.bound(600-player:getModifiedLibido(), 0, 300) / 300
  93.             --local p = 1 - chance / 100
  94.             shat[1]:toScreenPrecise(x+49, y+10, shat[6] * p, shat[7], 0, p * 1/shat[4], 0, 1/shat[5], libido_c[1], libido_c[2], libido_c[3], a)
  95.             if libido_sha.shad then libido_sha.shad:use(false) end
  96.  
  97.             local vm = player:getModifiedLibido()
  98.             if not self.res.libido or self.res.libido.vm ~= vm or self.res.libido.vc ~= player.libido or self.res.libido.vr ~= chance then
  99.                 self.res.libido = {
  100.                     hidable = "Libido",
  101.                     vc = player.libido, vr = chance, vm = vm,
  102.                     cur = {core.display.drawStringBlendedNewSurface(font_sha, ("%d (%d)"):format(vm, player.libido), 255, 255, 255):glTexture()},
  103.                     regen={core.display.drawStringBlendedNewSurface(sfont_sha, ("%d%%"):format(chance), 255, 255, 255):glTexture()},
  104.                 }
  105.             end
  106.             local dt = self.res.libido.cur
  107.             dt[1]:toScreenFull(2+x+64, 2+y+10 + (shat[7]-dt[7])/2, dt[6], dt[7], dt[2], dt[3], 0, 0, 0, 0.7 * a)
  108.             dt[1]:toScreenFull(x+64, y+10 + (shat[7]-dt[7])/2, dt[6], dt[7], dt[2], dt[3], 1, 1, 1, a)
  109.             dt = self.res.libido.regen
  110.             dt[1]:toScreenFull(2+x+144, 2+y+10 + (shat[7]-dt[7])/2, dt[6], dt[7], dt[2], dt[3], 0, 0, 0, 0.7 * a)
  111.             dt[1]:toScreenFull(x+144, y+10 + (shat[7]-dt[7])/2, dt[6], dt[7], dt[2], dt[3], 1, 1, 1, a)
  112.  
  113.             local front = fshat_libido
  114.             if chance <= 10 then front = fshat_libido_dark end
  115.             front[1]:toScreenFull(x, y, front[6], front[7], front[2], front[3], 1, 1, 1, a)
  116.             self:showResourceTooltip(bx+x*scale, by+y*scale, fshat[6], fshat[7], "res:libido", self.TOOLTIP_LIBIDO)
  117.             x, y = self:resourceOrientStep(orient, bx, by, scale, x, y, fshat[6], fshat[7])
  118.         elseif game.mouse:getZone("res:libido") then game.mouse:unregisterZone("res:libido") end
  119.  
  120.     end
  121. end
Advertisement
Add Comment
Please, Sign In to add comment