Custom overlays

Everything about mods can be found here.

Moderator: Morax

Custom overlays

Postby Franck83 » 28 Jul 2018, 16:56

Hi all commanders of modding,

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.




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: Select all
   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
Alliance of Heroes Mod is out ! Try it ! It's in the Mod Vault !
User avatar
Franck83
Evaluator
 
Posts: 538
Joined: 30 Dec 2016, 11:59
Location: France
Has liked: 114 times
Been liked: 122 times
FAF User Name: Franck83

Re: Custom overlays

Postby nine2 » 13 Nov 2018, 01:39

Yeah it sounds like maybe you could fix this by doing the rendering in the sim layer (not ui layer). I have no clue how to do that.
nine2
Councillor - Promotion
 
Posts: 2416
Joined: 16 Apr 2013, 10:10
Has liked: 285 times
Been liked: 515 times
FAF User Name: Anihilnine


Return to Mods & Tools

Who is online

Users browsing this forum: No registered users and 1 guest