From f154b45076982f8c1074d239a906f5893630ca13 Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Sat, 21 Jun 2025 22:34:03 +0100 Subject: [PATCH] Enhance built in ui_modules to support RedM --- shared/make/progressBars.lua | 128 ++----------- ui_modules/notifications.lua | 172 ++++++++++++++++-- ui_modules/progressbar.lua | 344 +++++++++++++++++++++++++++++++++++ ui_modules/skillcheck.lua | 12 +- 4 files changed, 528 insertions(+), 128 deletions(-) create mode 100644 ui_modules/progressbar.lua diff --git a/shared/make/progressBars.lua b/shared/make/progressBars.lua index 4459bc8..2b829b3 100644 --- a/shared/make/progressBars.lua +++ b/shared/make/progressBars.lua @@ -125,13 +125,14 @@ function progressBar(data) elseif Config.System.ProgressBar == "red" then -- Currently only uses jim-redui if you choose this option - if exports["jim-redui"]:progressBar({ + if exports["jim_bridge"]:redProgressBar({ label = data.label, time = debugMode and 1000 or data.time, dict = data.dict, anim = data.anim, flag = data.flag or 32, task = data.task, + disableMovement = true, cancel = true, }) then result = true @@ -140,73 +141,21 @@ function progressBar(data) end elseif Config.System.ProgressBar == "gta" then - loadTextureDict("timerbars") - if inProgress then return false end - inProgress = true - local wait = debugMode and 1000 or data.time - local endTime = GetGameTimer() + wait - local ped = PlayerPedId() - - -- Setup Animation/Task if specified - if data.dict then - playAnim(data.dict, data.anim, -1, data.flag or 32) - elseif data.task then - TaskStartScenarioInPlace(ped, data.task, -1, true) + if exports["jim_bridge"]:gtaProgressBar({ + label = data.label, + time = debugMode and 1000 or data.time, + dict = data.dict, + anim = data.anim, + flag = data.flag or 32, + task = data.task, + disableMovement = true, + cancel = true, + }) then + result = true + else + result = false end - -- Progress bar rendering loop - CreateThread(function() - while GetGameTimer() < endTime and inProgress do - Wait(0) - local elapsed = GetGameTimer() - local percentage = ((elapsed - (endTime - wait)) / wait) * 100 - - -- Convert to segmented progress (assuming 5 segments here) - local segments = 5 -- Number of segments in the bar - local segmentProgress = {} - local progressPerSegment = 100 / segments - - for i = 1, segments do - local segmentStart = (i - 1) * progressPerSegment - local segmentEnd = i * progressPerSegment - if percentage >= segmentEnd then - segmentProgress[i] = 100 - elseif percentage <= segmentStart then - segmentProgress[i] = 0 - else - segmentProgress[i] = ((percentage - segmentStart) / progressPerSegment) * 100 - end - end - - percentage = percentage >= 100 and 100 or percentage - -- Draw your segmented progress bar - ShowGTAProgressBar(segmentProgress, data.label, ("%.0f%%"):format(percentage)) - - -- Controls to disable during progress - DisablePlayerFiring(ped, true) - DisableControlAction(0, 25, true) -- Disable aim - DisableControlAction(0, 21, true) -- Disable sprint - DisableControlAction(0, 30, true) -- Disable move left/right - DisableControlAction(0, 31, true) -- Disable move forward/back - DisableControlAction(0, 36, true) -- Disable stealth - - if data.cancel and (IsControlJustReleased(0, 202) or IsControlJustReleased(0, 177) or IsControlJustReleased(0, 73)) then - inProgress = false - end - end - end) - - -- Wait for completion or cancel - while GetGameTimer() < endTime and inProgress do - Wait(100) - end - - -- Cleanup animations/tasks - if data.dict then stopAnim(data.dict, data.anim, ped) end - ClearPedTasks(ped) - - result = inProgress - inProgress = false end while result == nil do @@ -235,51 +184,6 @@ function progressBar(data) return result end -function ShowGTAProgressBar(currentProg, title, level) - local loc = vec2(0.37, 0.90) - local size = vec2(0.3, 0.03) - - -- Draw background box - DrawSprite("timerbars", "all_black_bg", loc.x +0.028, loc.y-0.01, 0.15, 0.07, 0.0, 255, 255, 255, 255) - DrawSprite("timerbars", "all_black_bg", loc.x +0.170, loc.y-0.01, 0.15, 0.07, 180.0, 255, 255, 255, 255) - - SetTextFont(0) - SetTextProportional(1) - SetTextScale(0.35, 0.35) - SetTextColour(255, 255, 255, 255) - SetTextDropshadow(0, 0, 0, 0, 255) - SetTextDropShadow() - SetTextOutline() - SetTextEntry("STRING") - AddTextComponentString(title) - DrawText(loc.x - size.x / 4 + 0.074, loc.y - 0.034) -- Adjust text position - - SetTextFont(0) - SetTextProportional(1) - SetTextScale(0.35, 0.25) - SetTextColour(255, 255, 255, 255) - SetTextEntry("STRING") - AddTextComponentString(level) - DrawText(loc.x - size.x / 4 + 0.246, loc.y - 0.030) -- Right-aligned additional text - - local segmentWidth = (size.x + 0.05) / (#currentProg * 2) -- Divide the total width by 18 (9 segments * 2 gaps for each) - local gap = segmentWidth / #currentProg -- Smaller gap between segments - - for i = 1, #currentProg do - local segmentX = (loc.x - size.x / 4 ) + 0.075 + (i - 1) * (segmentWidth + gap) - local fillPercentage = currentProg[i] - local progressBarWidth = segmentWidth * (fillPercentage / 100) - - -- Semi-transparent background for each segment - DrawRect(segmentX + segmentWidth / 2, loc.y, segmentWidth, size.y / 3.4, 100, 100, 100, 255) - - -- Filling progress for each segment - if progressBarWidth > 0 then - DrawRect(segmentX + progressBarWidth / 2, loc.y, progressBarWidth, size.y / 3.4, 93, 182, 229, 255) -- Blue progress - end - end -end - --- Stops the current progress bar. --- --- This function cancels the progress bar based on the configured progress bar system, handling any necessary cleanup. @@ -289,7 +193,7 @@ function stopProgressBar() elseif Config.System.ProgressBar == "qb" then TriggerEvent("progressbar:client:cancel") elseif Config.System.ProgressBar == "gta" or Config.System.ProgressBar == "red" then - inProgress = false + exports["jim_bridge"]:stopProgressBar() end end diff --git a/ui_modules/notifications.lua b/ui_modules/notifications.lua index 4b54433..3df06dc 100644 --- a/ui_modules/notifications.lua +++ b/ui_modules/notifications.lua @@ -2,13 +2,15 @@ local notifications = {} local spacing = 60 -- vertical spacing between notifications local activeDrawing = false -- flag for drawing loop state -if not HasStreamedTextureDictLoaded("timerbars") then - while not HasStreamedTextureDictLoaded("timerbars") do - RequestStreamedTextureDict("timerbars") - Wait(5) - end +local function loadTextureDict(dict) + if not HasStreamedTextureDictLoaded(dict) then + while not HasStreamedTextureDictLoaded(dict) do RequestStreamedTextureDict(dict) Wait(5) end + end end + +--- GTA Section --- + local notifTypes = { success = "✔️", error = "❌", @@ -35,12 +37,13 @@ function gtaNotify(title, message, emoji, src) -- This allows it to be silent until the first notifcation is called, then the loop starts if not activeDrawing then activeDrawing = true - StartDrawingLoop() + StartGTADrawingLoop() end end -- Drawing loop as a separate controlled thread -function StartDrawingLoop() +function StartGTADrawingLoop() + --loadTextureDict("timerbars") CreateThread(function() while #notifications > 0 do local currentTime = GetGameTimer() @@ -87,14 +90,14 @@ function StartDrawingLoop() if not notif.title or notif.title == "" then moveMessage = true else - drawNotiText(8, 0.4, vec2(0.75, 0.975), notif.title, vec2(posX, posY)) + drawGTANotiText(8, 0.4, vec2(0.75, 0.975), notif.title, vec2(posX, posY)) end -- Message text - drawNotiText(4, 0.3, vec2(0.75, 0.975), notif.message, vec2(posX, posY + (moveMessage and 0.015 or 0.03))) + drawGTANotiText(4, 0.3, vec2(0.75, 0.975), notif.message, vec2(posX, posY + (moveMessage and 0.015 or 0.03))) -- Emoji - drawNotiText(0, 0.3, vec2(0.75, 0.995), notif.emoji, vec2(posX, posY + 0.015)) + drawGTANotiText(0, 0.3, vec2(0.75, 0.995), notif.emoji, vec2(posX, posY + 0.015)) ::continue:: end @@ -104,7 +107,7 @@ function StartDrawingLoop() end) end -function drawNotiText(font, scale, wrap, string, pos) +function drawGTANotiText(font, scale, wrap, string, pos) SetTextFont(font) SetTextScale(scale, scale) SetTextWrap(wrap.x, wrap.y) @@ -116,5 +119,148 @@ function drawNotiText(font, scale, wrap, string, pos) DrawText(pos.x, pos.y) end -RegisterNetEvent("jim-bridge:Notify", gtaNotify) -exports("Notify", gtaNotify) \ No newline at end of file + +------------------ +-- REDM SECTION -- +------------------ +--- +--- +local REDMnotifTypes = { + success = vec3(0, 150, 0), + error = vec3(150, 0, 0), + warning = vec3(0, 150, 150), + police = vec3(0, 0, 150), + ambulance = vec3(0, 0, 150), +} + +function redNotify(title, message, style) + local notif = { + title = title and CreateVarString(10, "LITERAL_STRING", title) or nil, + message = message and CreateVarString(10, "LITERAL_STRING", message) or nil, + state = "enter", + startTime = GetGameTimer(), + style = REDMnotifTypes[style] or vec3(0, 0, 0), + progress = 0, + holdTime = 8000, + slideDuration = 100, + currentOffset = 0, + } + table.insert(notifications, notif) + + -- Activate drawing loop if not already running + if not activeDrawing then + activeDrawing = true + StartREDMDrawingLoop() + end +end + +-- Drawing loop as a separate controlled thread +function StartREDMDrawingLoop() + CreateThread(function() + loadTextureDict("generic_textures") + while #notifications > 0 do + local currentTime = GetGameTimer() + + -- Update notifications vertical offset + for i, notif in ipairs(notifications) do + local target = (#notifications - i) * spacing + notif.currentOffset += (target - notif.currentOffset) * 0.1 + end + + for i = #notifications, 1, -1 do + local notif = notifications[i] + + if notif.state == "enter" then + local elapsed = currentTime - notif.startTime + notif.progress = math.min(elapsed / notif.slideDuration, 1.0) + if notif.progress >= 1.0 then + notif.state = "hold" + notif.holdStart = currentTime + end + elseif notif.state == "hold" then + if currentTime - notif.holdStart >= notif.holdTime then + notif.state = "exit" + notif.exitStart = currentTime + end + elseif notif.state == "exit" then + local elapsed = currentTime - notif.exitStart + notif.progress = 1.0 - math.min(elapsed / notif.slideDuration, 1.0) + if notif.progress <= 0 then + table.remove(notifications, i) + goto continue + end + end + + local startX, targetX = 1.0, 0.8 + local posX = startX - (startX - targetX) * notif.progress + local posY = 0.05 + (notif.currentOffset / 1080) + + -- Background sprite + DrawSprite("generic_textures", "inkroller_1a", posX + 0.09, posY + 0.025, 0.2, 0.053, 180.0, notif.style.x, notif.style.y, notif.style.z, 150) + + -- Title text + local moveMessage = false + if not notif.title or notif.title == "" then + moveMessage = true + else + drawREDMNotiText(1, 0.4, vec2(0.75, 0.975), notif.title, vec2(posX, posY)) + end + + -- Message text + drawREDMNotiText(6, 0.3, vec2(0.75, 0.975), notif.message, vec2(posX, posY + (moveMessage and 0.0145 or 0.025))) + + ::continue:: + end + Wait(0) + end + activeDrawing = false -- No notifications left, pause drawing + end) +end + +function drawREDMNotiText(font, scale, wrap, string, pos) + SetTextFontForCurrentCommand(font) + SetTextScale(scale, scale) + SetTextColor(255, 255, 255, 255) + SetTextWrap(wrap.x, wrap.y) + SetTextJustification(2) + SetTextDropshadow(1, 0, 0, 0, 200) + DisplayText(string, pos.x, pos.y) +end + +-- Exports -- +-- Example: +-- TriggerEvent("jim_bridge:Notify", nil, "Short test message", "success") +-- +-- exports["jim_bridge"]:Notify(nil, "Short test message", "success") +-- + +RegisterNetEvent("jim_bridge:RedNotify", redNotify) +RegisterNetEvent("jim_bridge:GTANotify", gtaNotify) + +RegisterNetEvent("jim_bridge:Notify", function(...) + if GetCurrentGameName() == "rdr3" then + redNotify(...) + else + gtaNotify(...) + end +end) + +function Notify(...) + if GetCurrentGameName() == "rdr3" then + redNotify(...) + else + gtaNotify(...) + end +end + +exports("Notify", Notify) + +-- Example testing notifications (can remove after testing) +--CreateThread(function() +-- TriggerEvent("jim_bridge:Notify", nil, "Short test message", "success") +-- Wait(3000) +-- TriggerEvent("jim_bridge:Notify", "Error!", "This is a longer example message to show stacking.", "error") +-- Wait(3000) +-- TriggerEvent("jim_bridge:Notify", "Test!", "This notification has to 'type' set.", nil ) +-- Wait(4000) +--end) \ No newline at end of file diff --git a/ui_modules/progressbar.lua b/ui_modules/progressbar.lua new file mode 100644 index 0000000..59d7600 --- /dev/null +++ b/ui_modules/progressbar.lua @@ -0,0 +1,344 @@ +local inProgress = false + +local function loadTextureDict(dict) + if not HasStreamedTextureDictLoaded(dict) then + while not HasStreamedTextureDictLoaded(dict) do RequestStreamedTextureDict(dict) Wait(5) end + end +end + +function redProgressBar(data) + local ped = PlayerPedId() + + local result = nil + + loadTextureDict("generic_textures") + if inProgress then return false end + inProgress = true + local wait = debugMode and 1000 or data.time + local endTime = GetGameTimer() + wait + + LocalPlayer.state:set("inv_busy", true, true) + TriggerEvent('inventory:client:busy:status', true) + TriggerEvent('canUseInventoryAndHotbar:toggle', not true) + + -- Setup Animation/Task if specified + if data.dict then + playAnim(data.dict, data.anim, -1, data.flag or 32) + elseif data.task then + TaskStartScenarioInPlace(ped, data.task, -1, true) + end + + -- Progress bar rendering loop + CreateThread(function() + while GetGameTimer() < endTime and inProgress do + Wait(0) + local elapsed = GetGameTimer() + local percentage = ((elapsed - (endTime - wait)) / wait) * 100 + + -- Convert to segmented progress (assuming 5 segments here) + local segments = 1 -- Number of segments in the bar + local segmentProgress = {} + local progressPerSegment = 100 / segments + + for i = 1, segments do + local segmentStart = (i - 1) * progressPerSegment + local segmentEnd = i * progressPerSegment + if percentage >= segmentEnd then + segmentProgress[i] = 100 + elseif percentage <= segmentStart then + segmentProgress[i] = 0 + else + segmentProgress[i] = ((percentage - segmentStart) / progressPerSegment) * 100 + end + end + + percentage = percentage >= 100 and 100 or percentage + -- Draw your segmented progress bar + ShowRedProgressBar(segmentProgress, data.label, ("%.0f%%"):format(percentage)) + + -- Controls to disable during progress + if data.disableMouse then + DisableControlAction(0, `INPUT_LOOK_LR`, true) + DisableControlAction(0, `INPUT_LOOK_UD`, true) + DisableControlAction(0, `INPUT_VEH_MOUSE_CONTROL_OVERRIDE`, true) + end + + if data.disableMovement then + DisableControlAction(0, `INPUT_MOVE_LR`, true) + DisableControlAction(0, `INPUT_MOVE_UD`, true) + DisableControlAction(0, `INPUT_DUCK`, true) + DisableControlAction(0, `INPUT_SPRINT`, true) + end + + if data.disableCarMovement then + DisableControlAction(0, `INPUT_VEH_MOVE_LEFT_ONLY`, true) + DisableControlAction(0, `INPUT_VEH_MOVE_RIGHT_ONLY`, true) + DisableControlAction(0, `INPUT_VEH_ACCELERATE`, true) + DisableControlAction(0, `INPUT_VEH_BRAKE`, true) + DisableControlAction(0, `INPUT_VEH_EXIT`, true) + end + + if data.disableCombat then + DisablePlayerFiring(PlayerId(), true) + DisableControlAction(0, `INPUT_ATTACK`, true) + DisableControlAction(0, `INPUT_AIM`, true) + DisableControlAction(0, `INPUT_OPEN_WHEEL_MENU`, true) + DisableControlAction(0, `INPUT_DETONATE`, true) + DisableControlAction(0, `INPUT_THROW_GRENADE`, true) + DisableControlAction(0, `INPUT_MELEE_ATTACK`, true) + DisableControlAction(0, `INPUT_MELEE_GRAPPLE_ATTACK`, true) + end + + if data.cancel and ( + IsControlJustReleased(0, `INPUT_FRONTEND_RS`) or + IsControlJustReleased(0, `INPUT_SWITCH_SHOULDER`) or + IsControlJustReleased(0, `INPUT_GAME_MENU_TAB_RIGHT_SECONDARY`) or + IsControlJustReleased(0, `INPUT_FRONTEND_CANCEL`) or + IsControlJustReleased(0, `INPUT_GAME_MENU_CANCEL`) or + IsControlJustReleased(0, `INPUT_FRONTEND_RRIGHT`) or + IsControlJustReleased(0, `INPUT_QUIT`) or + IsControlJustReleased(0, `INPUT_MINIGAME_QUIT`) + ) then + inProgress = false + end + end + end) + + -- Wait for completion or cancel + while GetGameTimer() < endTime and inProgress do + Wait(100) + end + + -- Cleanup animations/tasks + if data.dict then + stopAnim(data.dict, data.anim, ped) + end + if data.task then + ClearPedTasks(ped) + end + + result = inProgress + inProgress = false + + while result == nil do Wait(10) end + + -- Cleanup + FreezeEntityPosition(ped, false) + + LocalPlayer.state:set("inv_busy", false, true) + TriggerEvent('inventory:client:busy:status', false) + TriggerEvent('canUseInventoryAndHotbar:toggle', not false) + + return result +end + +function ShowRedProgressBar(currentProg, title, level) + local loc = vec2(0.40, 0.90) + local size = vec2(0.3, 0.03) + + -- Draw background box + DrawSprite("generic_textures", "inkroller_1a", loc.x+0.1, loc.y-0.01, 0.25, 0.07, 180.0, 0, 0, 0, 200) + + SetTextFontForCurrentCommand(6) + SetTextScale(0.35, 0.35) + SetTextColor(255, 255, 255, 255) + SetTextDropshadow(1, 0, 0, 0, 200) + BgDisplayText(title, loc.x - size.x / 4 + 0.074, loc.y - 0.034) + + SetTextFontForCurrentCommand(1) + SetTextScale(0.35, 0.35) + SetTextColor(255, 255, 255, 255) + SetTextDropshadow(1, 0, 0, 0, 200) + BgDisplayText(level, loc.x - size.x / 4 + 0.246, loc.y - 0.030) + + local segmentWidth = (size.x + 0.05) / (#currentProg * 2) -- Divide the total width by 18 (9 segments * 2 gaps for each) + local gap = segmentWidth / #currentProg -- Smaller gap between segments + + for i = 1, #currentProg do + local segmentX = (loc.x - size.x / 4 ) + 0.075 + (i - 1) * (segmentWidth + gap) + local fillPercentage = currentProg[i] + local progressBarWidth = segmentWidth * (fillPercentage / 100) + + -- Semi-transparent background for each segment + DrawRect(segmentX + segmentWidth / 2, loc.y, segmentWidth, size.y / 3.4, 100, 100, 100, 255) + + -- Filling progress for each segment + if progressBarWidth > 0 then + DrawRect(segmentX + progressBarWidth / 2, loc.y, progressBarWidth, size.y / 3.4, 255, 0, 0, 200) -- Blue progress + end + end +end + +function gtaProgressBar(data) + local ped = PlayerPedId() + + local result = nil + + loadTextureDict("timerbars") + if inProgress then return false end + inProgress = true + local wait = debugMode and 1000 or data.time + local endTime = GetGameTimer() + wait + + -- Setup Animation/Task if specified + if data.dict then + playAnim(data.dict, data.anim, -1, data.flag or 32) + elseif data.task then + TaskStartScenarioInPlace(ped, data.task, -1, true) + end + + -- Progress bar rendering loop + CreateThread(function() + while GetGameTimer() < endTime and inProgress do + Wait(0) + local elapsed = GetGameTimer() + local percentage = ((elapsed - (endTime - wait)) / wait) * 100 + + -- Convert to segmented progress (assuming 5 segments here) + local segments = 1 -- Number of segments in the bar + local segmentProgress = {} + local progressPerSegment = 100 / segments + + for i = 1, segments do + local segmentStart = (i - 1) * progressPerSegment + local segmentEnd = i * progressPerSegment + if percentage >= segmentEnd then + segmentProgress[i] = 100 + elseif percentage <= segmentStart then + segmentProgress[i] = 0 + else + segmentProgress[i] = ((percentage - segmentStart) / progressPerSegment) * 100 + end + end + + percentage = percentage >= 100 and 100 or percentage + -- Draw your segmented progress bar + ShowGTAProgressBar(segmentProgress, data.label, ("%.0f%%"):format(percentage)) + + -- Controls to disable during progress + DisablePlayerFiring(ped, true) + DisableControlAction(0, 25, true) -- Disable aim + DisableControlAction(0, 21, true) -- Disable sprint + DisableControlAction(0, 30, true) -- Disable move left/right + DisableControlAction(0, 31, true) -- Disable move forward/back + DisableControlAction(0, 36, true) -- Disable stealth + + if data.cancel and (IsControlJustReleased(0, 202) or IsControlJustReleased(0, 177) or IsControlJustReleased(0, 73)) then + inProgress = false + end + end + end) + + -- Wait for completion or cancel + while GetGameTimer() < endTime and inProgress do + Wait(100) + end + + -- Cleanup animations/tasks + if data.dict then + stopAnim(data.dict, data.anim, ped) + end + if data.task then + ClearPedTasks(ped) + end + + result = inProgress + inProgress = false + + while result == nil do Wait(10) end + + -- Cleanup + FreezeEntityPosition(ped, false) + + LocalPlayer.state:set("inv_busy", false, true) + TriggerEvent('inventory:client:busy:status', false) + TriggerEvent('canUseInventoryAndHotbar:toggle', not false) + + return result +end + +function ShowGTAProgressBar(currentProg, title, level) + local loc = vec2(0.37, 0.90) + local size = vec2(0.3, 0.03) + + -- Draw background box + DrawSprite("timerbars", "all_black_bg", loc.x +0.028, loc.y-0.01, 0.15, 0.07, 0.0, 255, 255, 255, 255) + DrawSprite("timerbars", "all_black_bg", loc.x +0.170, loc.y-0.01, 0.15, 0.07, 180.0, 255, 255, 255, 255) + + SetTextFont(0) + SetTextProportional(1) + SetTextScale(0.35, 0.35) + SetTextColour(255, 255, 255, 255) + SetTextDropshadow(0, 0, 0, 0, 255) + SetTextDropShadow() + SetTextOutline() + SetTextEntry("STRING") + AddTextComponentString(title) + DrawText(loc.x - size.x / 4 + 0.074, loc.y - 0.034) -- Adjust text position + + SetTextFont(0) + SetTextProportional(1) + SetTextScale(0.35, 0.25) + SetTextColour(255, 255, 255, 255) + SetTextEntry("STRING") + AddTextComponentString(level) + DrawText(loc.x - size.x / 4 + 0.246, loc.y - 0.030) -- Right-aligned additional text + + local segmentWidth = (size.x + 0.05) / (#currentProg * 2) -- Divide the total width by 18 (9 segments * 2 gaps for each) + local gap = segmentWidth / #currentProg -- Smaller gap between segments + + for i = 1, #currentProg do + local segmentX = (loc.x - size.x / 4 ) + 0.075 + (i - 1) * (segmentWidth + gap) + local fillPercentage = currentProg[i] + local progressBarWidth = segmentWidth * (fillPercentage / 100) + + -- Semi-transparent background for each segment + DrawRect(segmentX + segmentWidth / 2, loc.y, segmentWidth, size.y / 3.4, 100, 100, 100, 255) + + -- Filling progress for each segment + if progressBarWidth > 0 then + DrawRect(segmentX + progressBarWidth / 2, loc.y, progressBarWidth, size.y / 3.4, 93, 182, 229, 255) -- Blue progress + end + end +end + +function stopProgressBar() inProgress = false end +function isProgressBar() return inProgress end + +function progressBar(...) + if GetCurrentGameName() == "rdr3" then + return redProgressBar(...) + else + return gtaProgressBar(...) + end +end + +exports("progressBar", function(...) + return progressBar(...) +end) +exports("gtaProgressBar", function(...) + return gtaProgressBar(...) +end) +exports("redProgressBar", function(...) + return redProgressBar(...) +end) + +exports("stopProgressBar", stopProgressBar) +exports("isProgressBar", isProgressBar) + +--RegisterCommand("testprog", function() +-- print("test") +-- if progressBar({ +-- label = "Processing...", +-- time = 10000, +-- disableMovement = true, +-- --dict = "amb@world_human_hang_out_street@female_hold_arm@base", +-- --anim = "base", +-- --flag = 49, +-- cancel = true, +-- }) then +-- Notify("Success!", "Short test message", "success") +-- else +-- Notify("Error!", "This is a longer example message to show stacking.", "error") +-- end +--end) \ No newline at end of file diff --git a/ui_modules/skillcheck.lua b/ui_modules/skillcheck.lua index d2fbf30..6eaa396 100644 --- a/ui_modules/skillcheck.lua +++ b/ui_modules/skillcheck.lua @@ -79,7 +79,7 @@ function gtaSkillCheck() -- Draw stationary cursor at result position DrawRect(x - width / 2 + cursorPos * width, y, 0.002, height + 0.01, 255, 255, 255, 255) -- Display result text - drawSuccessText(x, y, result and "Success" or "Failed", result and 114 or 228, result and 204 or 52, result and 144 or 52) + drawGTASuccessText(x, y, result and "Success" or "Failed", result and 114 or 228, result and 204 or 52, result and 144 or 52) end if result then successes += 1 @@ -94,7 +94,7 @@ function gtaSkillCheck() return successes == barsRequired end -function drawSuccessText(x, y, text, r, g, b) +function drawGTASuccessText(x, y, text, r, g, b) SetTextFont(8) SetTextScale(0.45, 0.45) SetTextColour(r, g, b, 255) @@ -118,4 +118,10 @@ function createScaleBars(x, y, width, height) DrawRect(x, y, width, height, 100, 100, 100, 255) end -exports("skillCheck", gtaSkillCheck) \ No newline at end of file +exports("skillCheck", function(...) + if GetCurrentGameName() == "rdr3" then + --redSkillCheck(...) + else + gtaSkillCheck(...) + end +end) \ No newline at end of file