Skip to content

Commit

Permalink
Merge branch 'statbarVariantA'
Browse files Browse the repository at this point in the history
going with this option for now: less media and less items on hud is
good.
[postool] was meant to be lightweight
  • Loading branch information
SwissalpS committed Mar 30, 2021
2 parents 88b37fb + 216c814 commit 8c6916f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions huds.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
local HUD_POSITION = { x = postool.hudPosX, y = postool.hudPosY }
local HUD_ALIGNMENT = { x = 1, y = 0 }
local HUD_SCALE = { x = 100, y = 100 }
local HUD_STATBAR_SIZE = { x = 160, y = 18 }

-- hud id map (playername -> { playername = { tIDs = { hud-ids }, tb = { toggles }, ... )
postool.tHudDB = {}
Expand Down Expand Up @@ -142,35 +143,26 @@ postool.rebuildHud = function(oPlayer)
local bAdvTrains = postool.hasAdvancedTrains()
local bMesecons = postool.hasMeseconsDebug()

local iID = tIDs.meseconsUsageBG
local iID = tIDs.meseconsUsageFG
if tb[5] and bMesecons then

if nil == iID then
tIDs.meseconsUsageBG = oPlayer:hud_add({
hud_elem_type = 'statbar',
name = 'postoolMeseconsUsageBG',
position = tPosition,
offset = { x = 0, y = iY -23 },
text = 'mesecons_use_bg.png',
scale = HUD_SCALE,
alignment = HUD_ALIGNMENT,
number = 3
})
tIDs.meseconsUsageFG = oPlayer:hud_add({
hud_elem_type = 'statbar',
name = 'postoolMeseconsUsageFG',
position = tPosition,
offset = { x = 0, y = iY -23 },
offset = { x = -2, y = iY - 27 },
text = 'mesecons_use_fg.png',
scale = HUD_SCALE,
size = { x = 1, y = HUD_STATBAR_SIZE.y },
alignment = HUD_ALIGNMENT,
number = 4
})
tIDs.meseconsPenalty = oPlayer:hud_add({
hud_elem_type = 'text',
name = 'postoolMeseconsPenalty',
position = tPosition,
offset = { x = 0, y = 0 },
offset = { x = 0, y = -16 },
text = 'Initializing...',
scale = HUD_SCALE,
alignment = HUD_ALIGNMENT,
Expand All @@ -183,7 +175,6 @@ postool.rebuildHud = function(oPlayer)
elseif nil ~= iID then

oPlayer:hud_remove(iID)
tIDs.meseconsUsageBG = nil
oPlayer:hud_remove(tIDs.meseconsUsageFG)
tIDs.meseconsUsageFG = nil
oPlayer:hud_remove(tIDs.meseconsPenalty)
Expand Down Expand Up @@ -359,8 +350,10 @@ postool.updateHudMesecons = function(oPlayer)
oPlayer:hud_change(tIDs.meseconsPenalty, 'text', sPenalty)
oPlayer:hud_change(tIDs.meseconsUsageFG, 'text', sTexture)
-- give a minimum to show, so can see red penalty even when no usage
oPlayer:hud_change(tIDs.meseconsUsageFG, 'number', math.max(8, nPercent * 3))

oPlayer:hud_change(tIDs.meseconsUsageFG, 'size', {
x = math.max(8, .01 * nPercent * HUD_STATBAR_SIZE.x),
y = HUD_STATBAR_SIZE.y + math.floor(tCtx.penalty * 16)
})
end -- updateHudMesecons


Expand Down
Binary file removed textures/mesecons_use_bg.png
Binary file not shown.

0 comments on commit 8c6916f

Please sign in to comment.