Forged Alliance Forever Forged Alliance Forever Forums 2018-11-13T01:39:33+02:00 /feed.php?f=41&t=16506 2018-11-13T01:39:33+02:00 2018-11-13T01:39:33+02:00 /viewtopic.php?t=16506&p=169494#p169494 <![CDATA[Re: Custom overlays]]> Statistics: Posted by nine2 — 13 Nov 2018, 01:39


]]>
2018-07-28T16:56:22+02:00 2018-07-28T16:56:22+02:00 /viewtopic.php?t=16506&p=166290#p166290 <![CDATA[Custom overlays]]>
I wanna create some customs overlays to draw data and create menus close to the unit mesh.

It works but the refresh rate is too low (delta is 10 ms). So the text is shaking on camera move.
You can compare with the regular green name and health bar that is ok.

object


This is my code. I checked to update on each frame, so i don' know how to fix it. Maybe overlays rendering are hard coded. Any Idea ?

Code:
   overlay = Bitmap(GetFrame(0))
   overlay.Width:Set(100)
   overlay.Height:Set(50)
   overlay.etaText = UIUtil.CreateText(overlay, 'ETA', 10, UIUtil.bodyFont)
   overlay.etaText:SetColor('white')
   overlay.etaText:SetDropShadow(true)
   overlay:SetNeedsFrameUpdate(true)
   overlay.OnFrame = function(self, delta)
      local unit = GetSelectedUnits()
      if unit then
         overlay.pos = unit[1]:GetPosition()
         local worldView = import('/lua/ui/game/worldview.lua').viewLeft
         local pos = worldView:Project(overlay.pos)
         LayoutHelpers.AtLeftTopIn(overlay, worldView, pos.x - overlay.Width() / 2, pos.y - overlay.Height() / 2 + 1)
         LayoutHelpers.AtCenterIn(overlay.etaText, overlay, 15, 0)
         overlay.etaText:SetText('Why is it shaking ?')
      else
         overlay.etaText:SetText('')
      end
   end

Statistics: Posted by Franck83 — 28 Jul 2018, 16:56


]]>