diff --git a/__resource.lua b/__resource.lua new file mode 100644 index 00000000..3774ff9e --- /dev/null +++ b/__resource.lua @@ -0,0 +1,23 @@ +resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937' + +description 'ESX Menu Default' + +client_scripts { + 'client/main.lua' +} + +ui_page { + 'html/ui.html' +} + +files { + 'html/ui.html', + 'html/css/app.css', + 'html/js/mustache.min.js', + 'html/js/app.js', + 'html/fonts/pdown.ttf', + 'html/fonts/bankgothic.ttf', + 'html/img/cursor.png', + 'html/img/keys/enter.png', + 'html/img/keys/return.png', +} \ No newline at end of file diff --git a/client/main.lua b/client/main.lua new file mode 100644 index 00000000..e975e51c --- /dev/null +++ b/client/main.lua @@ -0,0 +1,167 @@ +ESX = nil + +Citizen.CreateThread(function() + + while ESX == nil do + TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) + Citizen.Wait(0) + end + + local Keys = { + ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57, + ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177, + ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18, + ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182, + ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81, + ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70, + ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178, + ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173, + ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118 + } + + local GUI = {} + GUI.Time = 0 + local MenuType = 'default' + + local openMenu = function(namespace, name, data) + + SendNUIMessage({ + action = 'openMenu', + namespace = namespace, + name = name, + data = data, + }) + + end + + local closeMenu = function(namespace, name) + + SendNUIMessage({ + action = 'closeMenu', + namespace = namespace, + name = name, + data = data, + }) + end + + ESX.UI.Menu.RegisterType(MenuType, openMenu, closeMenu) + + RegisterNUICallback('menu_submit', function(data, cb) + local menu = ESX.UI.Menu.GetOpened(MenuType, data._namespace, data._name) + + if menu.submit ~= nil then + menu.submit(data, menu) + end + + cb('OK') + end) + + RegisterNUICallback('menu_cancel', function(data, cb) + + local menu = ESX.UI.Menu.GetOpened(MenuType, data._namespace, data._name) + + if menu.cancel ~= nil then + menu.cancel(data, menu) + end + + cb('OK') + end) + + RegisterNUICallback('menu_change', function(data, cb) + + local menu = ESX.UI.Menu.GetOpened(MenuType, data._namespace, data._name) + + for i=1, #data.elements, 1 do + + menu.setElement(i, 'value', data.elements[i].value) + + if data.elements[i].selected then + menu.setElement(i, 'selected', true) + else + menu.setElement(i, 'selected', false) + end + + end + + if menu.change ~= nil then + menu.change(data, menu) + end + + cb('OK') + end) + + Citizen.CreateThread(function() + while true do + + Wait(0) + + if IsControlPressed(0, Keys['ENTER']) and (GetGameTimer() - GUI.Time) > 150 then + + SendNUIMessage({ + action = 'controlPressed', + control = 'ENTER' + }) + + GUI.Time = GetGameTimer() + + end + + if IsControlPressed(0, Keys['BACKSPACE']) and (GetGameTimer() - GUI.Time) > 150 then + + SendNUIMessage({ + action = 'controlPressed', + control = 'BACKSPACE' + }) + + GUI.Time = GetGameTimer() + + end + + if IsControlPressed(0, Keys['TOP']) and (GetGameTimer() - GUI.Time) > 150 then + + SendNUIMessage({ + action = 'controlPressed', + control = 'TOP' + }) + + GUI.Time = GetGameTimer() + + end + + if IsControlPressed(0, Keys['DOWN']) and (GetGameTimer() - GUI.Time) > 150 then + + SendNUIMessage({ + action = 'controlPressed', + control = 'DOWN' + }) + + GUI.Time = GetGameTimer() + + end + + if IsControlPressed(0, Keys['LEFT']) and (GetGameTimer() - GUI.Time) > 150 then + + SendNUIMessage({ + action = 'controlPressed', + control = 'LEFT' + }) + + GUI.Time = GetGameTimer() + + end + + if IsControlPressed(0, Keys['RIGHT']) and (GetGameTimer() - GUI.Time) > 150 then + + SendNUIMessage({ + action = 'controlPressed', + control = 'RIGHT' + }) + + GUI.Time = GetGameTimer() + + end + + end + end) + +end) \ No newline at end of file diff --git a/config.lua b/config.lua new file mode 100644 index 00000000..81e8ddf6 --- /dev/null +++ b/config.lua @@ -0,0 +1,74 @@ +Config = {} + +Config.accounts = {'bank', 'black_money'} +Config.accountLabels = {'Banque', 'Argent Sale'} +Config.PaycheckInterval = 7 * 60000 +Config.ShowDotAbovePlayer = false +Config.RemoveInventoryItemDelay = 5 * 60000 + +Config.Weapons = { + + {name = 'WEAPON_UNARMED'}, + {name = 'WEAPON_ANIMAL'}, + {name = 'WEAPON_COUGAR'}, + {name = 'WEAPON_KNIFE'}, + {name = 'WEAPON_NIGHTSTICK'}, + {name = 'WEAPON_HAMMER'}, + {name = 'WEAPON_BAT'}, + {name = 'WEAPON_GOLFCLUB'}, + {name = 'WEAPON_CROWBAR'}, + {name = 'WEAPON_PISTOL'}, + {name = 'WEAPON_COMBATPISTOL'}, + {name = 'WEAPON_APPISTOL'}, + {name = 'WEAPON_PISTOL50'}, + {name = 'WEAPON_MICROSMG'}, + {name = 'WEAPON_SMG'}, + {name = 'WEAPON_ASSAULTSMG'}, + {name = 'WEAPON_ASSAULTRIFLE'}, + {name = 'WEAPON_CARBINERIFLE'}, + {name = 'WEAPON_ADVANCEDRIFLE'}, + {name = 'WEAPON_MG'}, + {name = 'WEAPON_COMBATMG'}, + {name = 'WEAPON_PUMPSHOTGUN'}, + {name = 'WEAPON_SAWNOFFSHOTGUN'}, + {name = 'WEAPON_ASSAULTSHOTGUN'}, + {name = 'WEAPON_BULLPUPSHOTGUN'}, + {name = 'WEAPON_STUNGUN'}, + {name = 'WEAPON_SNIPERRIFLE'}, + {name = 'WEAPON_HEAVYSNIPER'}, + {name = 'WEAPON_REMOTESNIPER'}, + {name = 'WEAPON_GRENADELAUNCHER'}, + {name = 'WEAPON_GRENADELAUNCHER_SMOKE'}, + {name = 'WEAPON_RPG'}, + {name = 'WEAPON_PASSENGER_ROCKET'}, + {name = 'WEAPON_AIRSTRIKE_ROCKET'}, + {name = 'WEAPON_STINGER'}, + {name = 'WEAPON_MINIGUN'}, + {name = 'WEAPON_GRENADE'}, + {name = 'WEAPON_STICKYBOMB'}, + {name = 'WEAPON_SMOKEGRENADE'}, + {name = 'WEAPON_BZGAS'}, + {name = 'WEAPON_MOLOTOV'}, + {name = 'WEAPON_FIREEXTINGUISHER'}, + {name = 'WEAPON_PETROLCAN'}, + {name = 'WEAPON_DIGISCANNER'}, + {name = 'WEAPON_BRIEFCASE'}, + {name = 'WEAPON_BRIEFCASE_02'}, + {name = 'WEAPON_BALL'}, + {name = 'WEAPON_FLARE'}, + {name = 'WEAPON_VEHICLE_ROCKET'}, + {name = 'WEAPON_BARBED_WIRE'}, + {name = 'WEAPON_DROWNING'}, + {name = 'WEAPON_DROWNING_IN_VEHICLE'}, + {name = 'WEAPON_BLEEDING'}, + {name = 'WEAPON_ELECTRIC_FENCE'}, + {name = 'WEAPON_EXPLOSION'}, + {name = 'WEAPON_FALL'}, + {name = 'WEAPON_EXHAUSTION'}, + {name = 'WEAPON_HIT_BY_WATER_CANNON'}, + {name = 'WEAPON_RAMMED_BY_CAR'}, + {name = 'WEAPON_RUN_OVER_BY_CAR'}, + {name = 'WEAPON_HELI_CRASH'}, + {name = 'WEAPON_FIRE'} + +} \ No newline at end of file diff --git a/html/css/app.css b/html/css/app.css new file mode 100644 index 00000000..2739eada --- /dev/null +++ b/html/css/app.css @@ -0,0 +1,93 @@ +@font-face { + font-family: bankgothic; + src: url('../fonts/bankgothic.ttf'); +} + +@font-face { + font-family: pcdown; + src: url('../fonts/pdown.ttf'); +} +.menu { + font-family: bankgothic; + min-width : 400px; + color : #fff; + box-shadow : 0px 0px 50px 0px #000; + position : absolute; +} + +.menu.align-left { + left: 40; + top : 50%; + transform: translate(0, -50%); +} + +.menu.align-top-left { + left: 40; + top : 40; +} + +.menu.align-top { + left: 50%; + top : 40; + transform: translate(-50%, 0); +} + +.menu.align-top-right { + right: 10; + top : 40; +} + +.menu.align-right { + right: 40; + top : 50%; + transform: translate(0, -50%); +} + +.menu.align-bottom-right { + right : 40; + bottom: 40; +} + +.menu.align-bottom { + left : 50%; + bottom: 40; + transform: translate(-50%, 0); +} + +.menu.align-bottom-left { + left : 40; + bottom: 40; +} + +.menu.align-center { + left : 50%; + top : 50%; + transform: translate(-50%, -50%); +} + +.menu .head { + background-color: #506be6; + text-align : center; + height : 40px; + line-height : 40px; +} + +.menu .menu-items { + max-height : 600px; + overflow-y : auto; +} + +.menu .menu-items .menu-item { + height : 40px; + display : block; + background-color: #f1f1f1; + box-shadow : inset 1px 0px 0px 1px #b8b8b8; + height : 32px; + line-height : 32px; + color : #3A3A3A; + text-align : center; +} + +.menu .menu-items .menu-item.selected { + background-color: #d0d0d0; +} \ No newline at end of file diff --git a/html/fonts/bankgothic.ttf b/html/fonts/bankgothic.ttf new file mode 100644 index 00000000..f3d8049b Binary files /dev/null and b/html/fonts/bankgothic.ttf differ diff --git a/html/fonts/pdown.ttf b/html/fonts/pdown.ttf new file mode 100644 index 00000000..69c76cf3 Binary files /dev/null and b/html/fonts/pdown.ttf differ diff --git a/html/img/accounts/bank.png b/html/img/accounts/bank.png new file mode 100644 index 00000000..eb36dc8e Binary files /dev/null and b/html/img/accounts/bank.png differ diff --git a/html/img/accounts/black_money.png b/html/img/accounts/black_money.png new file mode 100644 index 00000000..a42f6aa5 Binary files /dev/null and b/html/img/accounts/black_money.png differ diff --git a/html/img/cursor.png b/html/img/cursor.png new file mode 100644 index 00000000..39536f95 Binary files /dev/null and b/html/img/cursor.png differ diff --git a/html/img/keys/enter.png b/html/img/keys/enter.png new file mode 100644 index 00000000..3eb9a1f6 Binary files /dev/null and b/html/img/keys/enter.png differ diff --git a/html/img/keys/return.png b/html/img/keys/return.png new file mode 100644 index 00000000..a3ca125a Binary files /dev/null and b/html/img/keys/return.png differ diff --git a/html/js/app.js b/html/js/app.js new file mode 100644 index 00000000..2ad1336c --- /dev/null +++ b/html/js/app.js @@ -0,0 +1,344 @@ +(function(){ + + let MenuTpl = + '' + + '' + ; + + window.ESX_MENU = {}; + ESX_MENU.ResourceName = 'esx_menu_default'; + ESX_MENU.opened = {}; + ESX_MENU.focus = []; + ESX_MENU.pos = {}; + + ESX_MENU.open = function(namespace, name, data){ + + if(typeof ESX_MENU.opened[namespace] == 'undefined') + ESX_MENU.opened[namespace] = {}; + + if(typeof ESX_MENU.opened[namespace][name] != 'undefined') + ESX_MENU.close(namespace, name); + + if(typeof ESX_MENU.pos[namespace] == 'undefined') + ESX_MENU.pos[namespace] = {}; + + for(let i=0; i { + + switch(data.action){ + + case 'openMenu' : { + ESX_MENU.open(data.namespace, data.name, data.data); + break; + } + + case 'closeMenu' : { + ESX_MENU.close(data.namespace, data.name); + break; + } + + case 'controlPressed' : { + + switch(data.control){ + + case 'ENTER' : { + + let focused = ESX_MENU.getFocused(); + let menu = ESX_MENU.opened[focused.namespace][focused.name]; + let pos = ESX_MENU.pos[focused.namespace][focused.name]; + let elem = menu.elements[pos]; + + if(menu.elements.length > 0) + ESX_MENU.submit(focused.namespace, focused.name, elem); + + break; + } + + case 'BACKSPACE' : { + + let focused = ESX_MENU.getFocused(); + + ESX_MENU.cancel(focused.namespace, focused.name); + + break; + } + + case 'TOP' : { + + let focused = ESX_MENU.getFocused(); + let menu = ESX_MENU.opened[focused.namespace][focused.name]; + let pos = ESX_MENU.pos[focused.namespace][focused.name]; + + if(pos > 0) + ESX_MENU.pos[focused.namespace][focused.name]--; + + let elem = menu.elements[ESX_MENU.pos[focused.namespace][focused.name]]; + + for(let i=0; i 0){ + elem.value--; + ESX_MENU.change(focused.namespace, focused.name, elem) + } + + ESX_MENU.render(); + + break; + } + + default: break; + + } + + $('#menu_' + focused.namespace + '_' + focused.name).find('.menu-item.selected')[0].scrollIntoView(); + + break; + } + + case 'RIGHT' : { + + let focused = ESX_MENU.getFocused(); + let menu = ESX_MENU.opened[focused.namespace][focused.name]; + let pos = ESX_MENU.pos[focused.namespace][focused.name]; + let elem = menu.elements[pos]; + + switch(elem.type){ + + case 'default': break; + + case 'slider' : { + + if(typeof elem.options != 'undefined' && elem.value < elem.options.length - 1){ + elem.value++; + ESX_MENU.change(focused.namespace, focused.name, elem) + } + + if(typeof elem.max != 'undefined' && elem.value < elem.max){ + elem.value++; + ESX_MENU.change(focused.namespace, focused.name, elem) + } + + ESX_MENU.render(); + + break; + } + + default: break; + + } + + $('#menu_' + focused.namespace + '_' + focused.name).find('.menu-item.selected')[0].scrollIntoView(); + + break; + } + + default : break; + + } + + break; + } + + } + + } + + window.onload = function(e){ + window.addEventListener('message', (event) => { + onData(event.data) + }); + } + +})() \ No newline at end of file diff --git a/html/js/mustache.min.js b/html/js/mustache.min.js new file mode 100644 index 00000000..520cfcb9 --- /dev/null +++ b/html/js/mustache.min.js @@ -0,0 +1 @@ +(function defineMustache(global,factory){if(typeof exports==="object"&&exports&&typeof exports.nodeName!=="string"){factory(exports)}else if(typeof define==="function"&&define.amd){define(["exports"],factory)}else{global.Mustache={};factory(global.Mustache)}})(this,function mustacheFactory(mustache){var objectToString=Object.prototype.toString;var isArray=Array.isArray||function isArrayPolyfill(object){return objectToString.call(object)==="[object Array]"};function isFunction(object){return typeof object==="function"}function typeStr(obj){return isArray(obj)?"array":typeof obj}function escapeRegExp(string){return string.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function hasProperty(obj,propName){return obj!=null&&typeof obj==="object"&&propName in obj}var regExpTest=RegExp.prototype.test;function testRegExp(re,string){return regExpTest.call(re,string)}var nonSpaceRe=/\S/;function isWhitespace(string){return!testRegExp(nonSpaceRe,string)}var entityMap={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};function escapeHtml(string){return String(string).replace(/[&<>"'`=\/]/g,function fromEntityMap(s){return entityMap[s]})}var whiteRe=/\s*/;var spaceRe=/\s+/;var equalsRe=/\s*=/;var curlyRe=/\s*\}/;var tagRe=/#|\^|\/|>|\{|&|=|!/;function parseTemplate(template,tags){if(!template)return[];var sections=[];var tokens=[];var spaces=[];var hasTag=false;var nonSpace=false;function stripSpace(){if(hasTag&&!nonSpace){while(spaces.length)delete tokens[spaces.pop()]}else{spaces=[]}hasTag=false;nonSpace=false}var openingTagRe,closingTagRe,closingCurlyRe;function compileTags(tagsToCompile){if(typeof tagsToCompile==="string")tagsToCompile=tagsToCompile.split(spaceRe,2);if(!isArray(tagsToCompile)||tagsToCompile.length!==2)throw new Error("Invalid tags: "+tagsToCompile);openingTagRe=new RegExp(escapeRegExp(tagsToCompile[0])+"\\s*");closingTagRe=new RegExp("\\s*"+escapeRegExp(tagsToCompile[1]));closingCurlyRe=new RegExp("\\s*"+escapeRegExp("}"+tagsToCompile[1]))}compileTags(tags||mustache.tags);var scanner=new Scanner(template);var start,type,value,chr,token,openSection;while(!scanner.eos()){start=scanner.pos;value=scanner.scanUntil(openingTagRe);if(value){for(var i=0,valueLength=value.length;i0?sections[sections.length-1][4]:nestedTokens;break;default:collector.push(token)}}return nestedTokens}function Scanner(string){this.string=string;this.tail=string;this.pos=0}Scanner.prototype.eos=function eos(){return this.tail===""};Scanner.prototype.scan=function scan(re){var match=this.tail.match(re);if(!match||match.index!==0)return"";var string=match[0];this.tail=this.tail.substring(string.length);this.pos+=string.length;return string};Scanner.prototype.scanUntil=function scanUntil(re){var index=this.tail.search(re),match;switch(index){case-1:match=this.tail;this.tail="";break;case 0:match="";break;default:match=this.tail.substring(0,index);this.tail=this.tail.substring(index)}this.pos+=match.length;return match};function Context(view,parentContext){this.view=view;this.cache={".":this.view};this.parent=parentContext}Context.prototype.push=function push(view){return new Context(view,this)};Context.prototype.lookup=function lookup(name){var cache=this.cache;var value;if(cache.hasOwnProperty(name)){value=cache[name]}else{var context=this,names,index,lookupHit=false;while(context){if(name.indexOf(".")>0){value=context.view;names=name.split(".");index=0;while(value!=null&&index")value=this.renderPartial(token,context,partials,originalTemplate);else if(symbol==="&")value=this.unescapedValue(token,context);else if(symbol==="name")value=this.escapedValue(token,context);else if(symbol==="text")value=this.rawValue(token);if(value!==undefined)buffer+=value}return buffer};Writer.prototype.renderSection=function renderSection(token,context,partials,originalTemplate){var self=this;var buffer="";var value=context.lookup(token[1]);function subRender(template){return self.render(template,context,partials)}if(!value)return;if(isArray(value)){for(var j=0,valueLength=value.length;j + + + + + + + + + + + + + + \ No newline at end of file