diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..62c89355 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ \ No newline at end of file diff --git a/__resource.lua b/__resource.lua index 628fd5a4..7ba0b13e 100644 --- a/__resource.lua +++ b/__resource.lua @@ -28,7 +28,6 @@ ui_page 'html/ui.html' files { 'html/ui.html', 'html/pdown.ttf', - 'html/img/cursor.png', 'html/css/app.css', 'html/scripts/app.js' } diff --git a/client/esx_atm_cl.lua b/client/esx_atm_cl.lua index 8b959333..1034b74c 100644 --- a/client/esx_atm_cl.lua +++ b/client/esx_atm_cl.lua @@ -118,7 +118,8 @@ Citizen.CreateThread(function() } }) end) - SetNuiFocus(true) + -- Open UI and display Native Cursor + SetNuiFocus(true, true) end end end diff --git a/html/css/app.css b/html/css/app.css index af32745a..36470206 100644 --- a/html/css/app.css +++ b/html/css/app.css @@ -1,49 +1,58 @@ @font-face { - font-family: pcdown; - src: url('pdown.ttf'); + font-family: pcdown; + src: url('pdown.ttf'); } + body { - font-family: roboto; + font-family: roboto; } + #cursor { position: absolute; z-index: 999999; - display: none; + display: none; } + #menu { - position: absolute; - top: 50%; - left: 50%; + position: absolute; + top: 50%; + left: 50%; } + #menu { - display : flex; - flex-direction: column; - width : 500px; - height : 150px; - margin-top : -75px; - margin-left: -250px; + display: flex; + flex-direction: column; + width: 500px; + height: 150px; + margin-top: -75px; + margin-left: -250px; } + #menu div { - display: flex; - flex-direction: row; + display: flex; + flex-direction: row; } + #deposit_btn { - width : 250px; - height: 50px; - font-size: 2em; + width: 250px; + height: 50px; + font-size: 2em; } + #deposit_amount { - width : 250px; - height : 50px; - font-size: 2em; + width: 250px; + height: 50px; + font-size: 2em; } + #withdraw_btn { - width : 250px; - height: 50px; - font-size: 2em; + width: 250px; + height: 50px; + font-size: 2em; } + #withdraw_amount { - width : 250px; - height : 50px; - font-size: 2em; + width: 250px; + height: 50px; + font-size: 2em; } \ No newline at end of file diff --git a/html/scripts/app.js b/html/scripts/app.js index 46261858..2adc9f82 100644 --- a/html/scripts/app.js +++ b/html/scripts/app.js @@ -1,78 +1,50 @@ -var documentWidth = document.documentElement.clientWidth; -var documentHeight = document.documentElement.clientHeight; +$(window).ready(function () { + // NUI Callback + window.addEventListener('message', function (event) { + let data = event.data; + if (data.showControls) { + $('#container').show(); + $('#menu').hide(); + } + if (data.showMenu) { + $('#container').show(); + $('#menu').show(); + $('#deposit_amount').val(data.player.money); + let bankAmount = 0; + for (let i = 0; i < data.player.accounts.length; i++) + if (data.player.accounts[i].name == 'bank') + bankAmount = data.player.accounts[i].money; + if (bankAmount >= 10000) { + $('#withdraw_amount').val(10000); + } else { + $('#withdraw_amount').val(bankAmount); + } + } -var cursor = document.getElementById("cursor"); -var cursorX = documentWidth / 2; -var cursorY = documentHeight / 2; + if (data.hideAll) { + $('#container').hide(); + } + }); -function UpdateCursorPos() { - cursor.style.left = cursorX; - cursor.style.top = cursorY; -} + document.onkeyup = function (data) { + if (data.which == 27) { + $.post('http://esx_atm/escape', '{}'); + } + }; -function Click(x, y) { - var element = $(document.elementFromPoint(x, y)); - element.focus().click(); -} + $('#container').hide(); -$(document).mousemove(function(event) { - cursorX = event.pageX; - cursorY = event.pageY; - UpdateCursorPos(); + $('#deposit_btn').on('click', function () { + $.post('http://esx_atm/deposit', JSON.stringify({ + amount: $('#deposit_amount').val() + })); + }) + + $('#withdraw_btn').on('click', function () { + $.post('http://esx_atm/withdraw', + JSON.stringify({ + amount: $('#withdraw_amount').val() + }) + ); + }); }); - -window.onload = function(e){ - // NUI Callback - window.addEventListener('message', function(event){ - let data = event.data; - if(data.showControls){ - $('#container').show(); - $('#menu' ).hide(); - $(cursor ).hide(); - } - if(data.showMenu){ - $('#container' ).show(); - $('#menu' ).show(); - $(cursor ).show(); - $('#deposit_amount').val(data.player.money) - let bankAmount = 0; - for(let i=0; i= 10000) - $('#withdraw_amount').val(10000) - else - $('#withdraw_amount').val(bankAmount) - } - - if(data.hideAll){ - $('#container').hide(); - $(cursor ).hide(); - } - if (data.click) { - // Avoid clicking the cursor itself, click 1px to the top/left; - Click(cursorX - 1, cursorY - 1); - } - - }) -} - -document.onkeyup = function (data) { - if (data.which == 27) { - $.post('http://esx_atm/escape', '{}'); - } -}; - -$('#container').hide() - -$('#deposit_btn').click(() => { - $.post('http://esx_atm/deposit', JSON.stringify({ - amount: $('#deposit_amount').val() - })); -}) - -$('#withdraw_btn').click(() => { - $.post('http://esx_atm/withdraw', JSON.stringify({ - amount: $('#withdraw_amount').val() - })); -}) \ No newline at end of file diff --git a/html/ui.html b/html/ui.html index 112567b7..340c5eba 100644 --- a/html/ui.html +++ b/html/ui.html @@ -5,7 +5,6 @@ -