Druckanzeige: - pressure * (Restluft / capacity). Bei konstantem Volumen ist der Druck proportional zur verbliebenen Gasmenge, die lineare Abbildung stimmt also - Fuelldruck pro Flasche in config/shared.lua, alle bei 300 bar. Dass die grosse Flasche denselben Druck zeigt wie die kleine ist gewollt - in echt macht das Volumen die Laufzeit, nicht der Druck - Unter config.reservePressure (50 bar) rot: in der Tauchpraxis die Schwelle, ab der man den Aufstieg einleitet HUD ausblenden fuer Unterwasser-Screenshots. qbx_core hat selbst keinen HUD-Toggle, es feuert nur hud:client:* an eine separate HUD-Resource - deshalb drei voneinander unabhaengige Wege: - IsHudHidden() folgen, greift bei allem was DisplayHud(false) setzt - eigene Taste, standardmaessig unbelegt - Export setHudVisible(bool) / isHudVisible() fuer andere Resources Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+48
-1
@@ -289,10 +289,20 @@ local function takeOffSuit()
|
||||
end
|
||||
end
|
||||
|
||||
--- Manometer-Anzeige. Bei konstantem Volumen ist der Druck proportional zur
|
||||
--- verbliebenen Gasmenge, deshalb reicht der lineare Anteil an der Füllung.
|
||||
--- @return number bar
|
||||
local function getPressure()
|
||||
if not activeTank or activeTank.capacity <= 0 then return 0 end
|
||||
|
||||
return (activeTank.pressure or 0) * (activeTank.oxygen / activeTank.capacity)
|
||||
end
|
||||
|
||||
--- @param visible boolean
|
||||
local function sendHudState(visible)
|
||||
local oxygen = activeTank and activeTank.oxygen or 0.0
|
||||
local capacity = activeTank and activeTank.capacity or 1
|
||||
local pressure = getPressure()
|
||||
local level = 'ok'
|
||||
|
||||
if oxygen <= dangerThreshold then
|
||||
@@ -307,6 +317,8 @@ local function sendHudState(visible)
|
||||
oxygen = oxygen,
|
||||
capacity = capacity,
|
||||
depth = currentDepth,
|
||||
pressure = pressure,
|
||||
reserve = pressure > 0 and pressure <= config.reservePressure,
|
||||
level = level,
|
||||
deep = currentDepth >= config.deepWarningDepth,
|
||||
hasLamp = true,
|
||||
@@ -314,6 +326,25 @@ local function sendHudState(visible)
|
||||
})
|
||||
end
|
||||
|
||||
--- Manuell ausgeblendet (eigene Taste oder Export)? Unabhängig davon, ob das
|
||||
--- Spiel-HUD gerade sichtbar ist.
|
||||
local hudHidden = false
|
||||
|
||||
--- Blendet das Tauch-HUD aus oder wieder ein, z.B. für Unterwasser-Screenshots.
|
||||
--- Als Export nutzbar, damit HUD- und Screenshot-Resources es mitnehmen können:
|
||||
--- exports.d4rk_divegear:setHudVisible(false)
|
||||
--- @param visible boolean
|
||||
local function setHudVisible(visible)
|
||||
hudHidden = not visible
|
||||
|
||||
if hudHidden then
|
||||
SendNUIMessage({ action = 'state', visible = false })
|
||||
end
|
||||
end
|
||||
|
||||
exports('setHudVisible', setHudVisible)
|
||||
exports('isHudVisible', function() return not hudHidden end)
|
||||
|
||||
--- Pflegt die geglättete Tiefe und schiebt den Zustand ins NUI.
|
||||
--- Läuft auch über Wasser weiter, weil getDecayFactor die Tiefe braucht - nur die
|
||||
--- Anzeige wird ausgeblendet.
|
||||
@@ -325,13 +356,20 @@ local function startHudThread()
|
||||
action = 'labels',
|
||||
air = locale('hud.air'),
|
||||
depth = locale('hud.depth'),
|
||||
pressure = locale('hud.pressure'),
|
||||
lamp = locale('hud.lamp')
|
||||
})
|
||||
|
||||
while currentGear.enabled do
|
||||
currentDepth = currentDepth + (getDepth() - currentDepth) * 0.25
|
||||
|
||||
local visible = config.hudEnabled and activeTank ~= nil and IsPedSwimmingUnderWater(cache.ped)
|
||||
local visible = config.hudEnabled
|
||||
and not hudHidden
|
||||
and activeTank ~= nil
|
||||
and IsPedSwimmingUnderWater(cache.ped)
|
||||
-- Folgt dem Spiel-HUD: alles was DisplayHud(false) setzt, blendet
|
||||
-- damit auch das Tauch-HUD aus.
|
||||
and not (config.hudFollowGameHud and IsHudHidden())
|
||||
|
||||
if visible or wasVisible then
|
||||
sendHudState(visible)
|
||||
@@ -478,6 +516,15 @@ RegisterNetEvent('d4rk_divegear:client:useGear', function()
|
||||
end
|
||||
end)
|
||||
|
||||
lib.addKeybind({
|
||||
name = 'divegear_hud',
|
||||
description = locale('keybind.toggle_hud'),
|
||||
defaultKey = config.hudToggleKey,
|
||||
onPressed = function()
|
||||
setHudVisible(hudHidden)
|
||||
end
|
||||
})
|
||||
|
||||
lib.addKeybind({
|
||||
name = 'divegear_lamp',
|
||||
description = locale('keybind.toggle_lamp'),
|
||||
|
||||
Reference in New Issue
Block a user