Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
185 changes: 101 additions & 84 deletions client/cursor.lua
Original file line number Diff line number Diff line change
@@ -1,85 +1,102 @@
local scale = 1.5
local screenWidth = math.floor(1920 / scale)
local screenHeight = math.floor(1080 / scale)
shouldDraw = false

local scale = 1.5;
local screenWidth = math.floor(1920 / scale);
local screenHeight = math.floor(1080 / scale);
shouldDraw = false;
function SetInteractScreen(bool)
if (not shouldDraw and bool) then
shouldDraw = bool
Citizen.CreateThread(function ()
-- Create screen
local nX = 0
local nY = 0

local w, h = screenWidth, screenHeight

local minX, maxX = ((w - (w / 2)) / 2), (w - (w / 4))
local totalX = minX - maxX

local minY, maxY = ((h - (h / 2)) / 2), (h - (h / 4))
local totalY = minY - maxY

RequestTextureDictionary('fib_pc')

-- Update controls while active
while shouldDraw do
nX = GetControlNormal(0, 239) * screenWidth
nY = GetControlNormal(0, 240) * screenHeight
DisableControlAction(0, 1, true) -- Disable looking horizontally
DisableControlAction(0, 2, true) -- Disable looking vertically
DisablePlayerFiring(PlayerPedId(), true) -- Disable weapon firing
DisableControlAction(0, 142, true) -- Disable aiming
DisableControlAction(0, 106, true) -- Disable in-game mouse controls
-- Update mouse position when changed
DrawSprite("ptelevision_b_dict", "ptelevision_b_txd", 0.5, 0.5, 0.5, 0.5, 0.0, 255, 255, 255, 255)
if nX ~= mX or nY ~= mY then
mX = nX; mY = nY
local duiX = -screenWidth * ((mX - minX) / totalX)
local duiY = -screenHeight * ((mY - minY) / totalY)
BlockWeaponWheelThisFrame()
if not (mX > 325) then
mX = 325
end
if not (mX < 965) then
mX = 965
end
if not (mY > 185) then
mY = 185
end
if not (mY < 545) then
mY = 545
end
SendDuiMouseMove(duiObj, math.floor(duiX), math.floor(duiY))
end
DrawSprite('fib_pc', 'arrow', mX / screenWidth, mY / screenHeight, 0.005, 0.01, 0.0, 255, 255, 255, 255)

-- Send scroll and click events to dui

if IsControlPressed(0, 177) then
SetInteractScreen(false)
OpenTVMenu()
end -- scroll up
if IsControlPressed(0, 172) then
SendDuiMouseWheel(duiObj, 10, 0) end -- scroll up
if IsControlPressed(0, 173) then
SendDuiMouseWheel(duiObj, -10, 0) end -- scroll down

if IsDisabledControlJustPressed(0, 24) then
SendDuiMouseDown(duiObj, 'left')
elseif IsDisabledControlJustReleased(0, 24) then
SendDuiMouseUp(duiObj, 'left')
SendDuiMouseUp(duiObj, "right")
end
if IsDisabledControlJustPressed(0, 25) then
SendDuiMouseDown(duiObj, "right")
elseif IsDisabledControlJustReleased(0, 24) then
SendDuiMouseUp(duiObj, "right")
end

Wait(0)
end
end)
else
shouldDraw = bool
end
end
if not shouldDraw and bool then
shouldDraw = bool;
Citizen.CreateThread(function()
local nX = 0;
local nY = 0;
local w, h = screenWidth, screenHeight;
local minX, maxX = (w - w / 2) / 2, w - w / 4;
local totalX = minX - maxX;
local minY, maxY = (h - h / 2) / 2, h - h / 4;
local totalY = minY - maxY;
RequestTextureDictionary("fib_pc");
while shouldDraw do
nX = GetControlNormal(0, 239) * screenWidth;
nY = GetControlNormal(0, 240) * screenHeight;
DisableControlAction(0, 1, true);
DisableControlAction(0, 2, true);
DisablePlayerFiring(PlayerPedId(), true);
DisableControlAction(0, 142, true);
DisableControlAction(0, 106, true);
DrawSprite("ptelevision_b_dict", "ptelevision_b_txd", 0.5, 0.5, 0.5, 0.5, 0, 255, 255, 255, 255);
if nX ~= mX or nY ~= mY then
mX = nX;
mY = nY;
local duiX = (-screenWidth) * ((mX - minX) / totalX);
local duiY = (-screenHeight) * ((mY - minY) / totalY);
BlockWeaponWheelThisFrame();
if not (mX > 325) then
mX = 325;
end;
if not (mX < 965) then
mX = 965;
end;
if not (mY > 185) then
mY = 185;
end;
if not (mY < 545) then
mY = 545;
end;
if not duiObj then
print("No Dui Object found.");
else
SendDuiMouseMove(duiObj, math.floor(duiX), math.floor(duiY));
end;
end;
DrawSprite("fib_pc", "arrow", mX / screenWidth, mY / screenHeight, 0.005, 0.01, 0, 255, 255, 255, 255);
if IsControlPressed(0, 177) then
SetInteractScreen(false);
OpenTVMenu();
end;
if IsControlPressed(0, 172) then
if not duiObj then
print("No Dui Object found.");
else
SendDuiMouseWheel(duiObj, 10, 0);
end;
end;
if IsControlPressed(0, 173) then
if not duiObj then
print("No Dui Object found.");
else
SendDuiMouseWheel(duiObj, -10, 0);
end;
end;
if IsDisabledControlJustPressed(0, 24) then
if not duiObj then
print("No Dui Object found.");
else
SendDuiMouseDown(duiObj, "left");
end;
elseif IsDisabledControlJustReleased(0, 24) then
if not duiObj then
print("No Dui Object found.");
else
SendDuiMouseUp(duiObj, "left");
SendDuiMouseUp(duiObj, "right");
end;
end;
if IsDisabledControlJustPressed(0, 25) then
if not duiObj then
print("No Dui Object found.");
else
SendDuiMouseDown(duiObj, "right");
end;
elseif IsDisabledControlJustReleased(0, 25) then
if not duiObj then
print("No Dui Object found.");
else
SendDuiMouseUp(duiObj, "right");
end;
end;
Wait(0);
end;
end);
else
shouldDraw = bool;
end;
end;
65 changes: 33 additions & 32 deletions client/dui.lua
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
function CreateNamedRenderTargetForModel(name, model)
local handle = 0
local handle = 0;
if not IsNamedRendertargetRegistered(name) then
RegisterNamedRendertarget(name, 0)
end
RegisterNamedRendertarget(name, 0);
end;
if not IsNamedRendertargetLinked(model) then
LinkNamedRendertarget(model)
end
LinkNamedRendertarget(model);
end;
if IsNamedRendertargetRegistered(name) then
handle = GetNamedRendertargetRenderId(name)
end
return handle
end

handle = GetNamedRendertargetRenderId(name);
end;
return handle;
end;
function RequestTextureDictionary(dict)
RequestStreamedTextureDict(dict)
while not HasStreamedTextureDictLoaded(dict) do Wait(0) end
return dict
end

RequestStreamedTextureDict(dict);
while not HasStreamedTextureDictLoaded(dict) do
Wait(0);
end;
return dict;
end;
function LoadModel(model)
if not IsModelInCdimage(model) then return end
RequestModel(model)
while not HasModelLoaded(model) do Wait(0) end
return model
end

if not IsModelInCdimage(model) then
return;
end;
RequestModel(model);
while not HasModelLoaded(model) do
Wait(0);
end;
return model;
end;
function RenderScaleformTV(renderTarget, scaleform, entity)
SetTextRenderId(renderTarget) -- set render target
Set_2dLayer(4)
SetScriptGfxDrawBehindPausemenu(1)
--DrawRect(0.5, 0.5, 1.0, 0.5, 255, 0, 0, 255); -- WOAH!
local coords = GetEntityCoords(entity)
local rot = GetEntityRotation(entity)
DrawSprite("ptelevision_b_dict", "ptelevision_b_txd", 0.5, 0.5, 1.0, 1.0, 0.0, 255, 255, 255, 255)
SetTextRenderId(GetDefaultScriptRendertargetRenderId()) -- reset
SetScriptGfxDrawBehindPausemenu(0)
end

SetTextRenderId(renderTarget);
Set_2dLayer(4);
SetScriptGfxDrawBehindPausemenu(1);
local coords = GetEntityCoords(entity);
local rot = GetEntityRotation(entity);
DrawSprite("ptelevision_b_dict", "ptelevision_b_txd", 0.5, 0.5, 1, 1, 0, 255, 255, 255, 255);
SetTextRenderId(GetDefaultScriptRendertargetRenderId());
SetScriptGfxDrawBehindPausemenu(0);
end;
Loading