From 8eb1ebbdefa8228662b8fd4640f077c508ce9f3d Mon Sep 17 00:00:00 2001 From: D4rkst3r Date: Sat, 10 Oct 2026 18:41:40 +0200 Subject: [PATCH] fix: Flaschenwahl im d4rk_lib-Design (#158) Co-Authored-By: Claude Opus 5.5 (1M context) --- client/main.lua | 29 ++++++++++++++--------------- locales/de.json | 3 ++- locales/en.json | 3 ++- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/client/main.lua b/client/main.lua index 13e569f..f048666 100644 --- a/client/main.lua +++ b/client/main.lua @@ -193,31 +193,30 @@ end local function chooseTank(tanks) if #tanks == 1 then return tanks[1] end - local selection = promise.new() - local options = {} + -- Im d4rk_lib-Design statt lib.registerContext (d4rk-rp-planung CLAUDE.md + -- "Unser Design, nicht das von ox_lib", 10.10.2026). Beendet wird mit dem + -- Knopf je Flasche oder ESC (= nil); blockiert wie vorher das promise. + local eintraege = {} for i = 1, #tanks do local tank = tanks[i] - options[i] = { - title = tank.label, - description = locale('info.tank_remaining', formatTime(tank.oxygen), + eintraege[i] = { + id = tostring(i), + titel = tank.label, + unterzeile = locale('info.tank_remaining', formatTime(tank.oxygen), math.floor(tank.oxygen / tank.capacity * 100), tank.gas or '?', math.floor(tank.maxDepth or 0)), - icon = 'fa-solid fa-bottle-water', - onSelect = function() selection:resolve(tank) end + symbol = 'wind', + aktionen = { { id = 'waehlen', label = locale('menu.use_tank'), art = 'primaer' } }, } end - lib.registerContext({ - id = 'd4rk_divegear_tanks', - title = locale('menu.choose_tank'), - options = options, - onExit = function() selection:resolve(nil) end + local wahl = exports.d4rk_lib:menu({ + titel = locale('menu.choose_tank'), + eintraege = eintraege, }) - lib.showContext('d4rk_divegear_tanks') - - return Citizen.Await(selection) + return type(wahl) == 'table' and tanks[tonumber(wahl.eintrag) or -1] or nil end lib.callback.register('d4rk_divegear:client:fillTank', function(tanks) diff --git a/locales/de.json b/locales/de.json index b9eee54..3086d98 100644 --- a/locales/de.json +++ b/locales/de.json @@ -35,7 +35,8 @@ "patrone_einsetzen": "Patrone wird eingesetzt..." }, "menu": { - "choose_tank": "Tauchflasche wählen" + "choose_tank": "Tauchflasche wählen", + "use_tank": "Diese Flasche" }, "hud": { "air": "Luft", diff --git a/locales/en.json b/locales/en.json index 8f85334..d73170f 100644 --- a/locales/en.json +++ b/locales/en.json @@ -35,7 +35,8 @@ "patrone_einsetzen": "Inserting cartridge..." }, "menu": { - "choose_tank": "Choose an air tank" + "choose_tank": "Choose an air tank", + "use_tank": "Use this tank" }, "hud": { "air": "Air",