Add files

This commit is contained in:
Jérémie N'gadi
2017-07-31 12:54:38 +02:00
parent 73f0d5dd0e
commit f3300e27cb
14 changed files with 501 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'
description 'ESX Menu Dialog'
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',
}
+134
View File
@@ -0,0 +1,134 @@
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 = 'dialog'
local OpenedMenus = {}
local openMenu = function(namespace, name, data)
OpenedMenus[namespace .. '_' .. name] = true
SendNUIMessage({
action = 'openMenu',
namespace = namespace,
name = name,
data = data,
})
ESX.SetTimeout(200, function()
SetNuiFocus(true, true)
end)
end
local closeMenu = function(namespace, name)
OpenedMenus[namespace .. '_' .. name] = nil
local OpenedMenuCount = 0
SendNUIMessage({
action = 'closeMenu',
namespace = namespace,
name = name,
data = data,
})
for k,v in pairs(OpenedMenus) do
if v == true then
OpenedMenuCount = OpenedMenuCount + 1
end
end
if OpenedMenuCount == 0 then
SetNuiFocus(false)
end
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)
if menu.change ~= nil then
menu.change(data, menu)
end
cb('OK')
end)
Citizen.CreateThread(function()
while true do
Wait(0)
local OpenedMenuCount = 0
for k,v in pairs(OpenedMenus) do
if v == true then
OpenedMenuCount = OpenedMenuCount + 1
end
end
if OpenedMenuCount > 0 then
DisableControlAction(0, 1, true) -- LookLeftRight
DisableControlAction(0, 2, true) -- LookUpDown
DisableControlAction(0, 142, true) -- MeleeAttackAlternate
DisableControlAction(0, 106, true) -- VehicleMouseControlOverride
DisableControlAction(0, 12, true) -- WeaponWheelUpDown
DisableControlAction(0, 14, true) -- WeaponWheelNext
DisableControlAction(0, 15, true) -- WeaponWheelPrev
DisableControlAction(0, 16, true) -- SelectNextWeapon
DisableControlAction(0, 17, true) -- SelectPrevWeapon
end
end
end)
end)
+74
View File
@@ -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'}
}
+87
View File
@@ -0,0 +1,87 @@
@font-face {
font-family: bankgothic;
src: url('../fonts/bankgothic.ttf');
}
@font-face {
font-family: pcdown;
src: url('../fonts/pdown.ttf');
}
#cursor {
position: absolute;
z-index: 999999999;
display: none;
}
#controls {
font-family : pcdown;
font-size : 3em;
color : #FFF;
position : absolute;
bottom : 40;
right : 40;
text-shadow:
-1px -1px 0 #000,
1px -1px 0 #000,
-1px 1px 0 #000,
1px 1px 0 #000
;
}
.controls {
display: none;
}
.dialog {
font-family : bankgothic;
background-color: #fff;
color : #fff;
box-shadow : 0px 0px 50px 0px #000;
position : absolute;
overflow : hidden;
top : 50%;
left : 50%;
width : 600px;
height : 104px;
transform : translate(-50%, -50%);
}
.dialog.big {
height: 200px;
}
.dialog .head {
background-color: #506be6;
text-align : center;
height : 40px;
}
.dialog .head span:before {
content: "";
display: inline-block;
height: 100%;
vertical-align: middle;
}
.dialog input[type="text"] {
width : 100%;
height: 32px;
}
.dialog textarea {
width : 100%;
height: 128px;
}
.dialog button[name="submit"] {
width : 75%;
height: 32px;
}
.dialog button[name="cancel"] {
width : 25%;
height: 32px;
}
Binary file not shown.
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 1015 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 431 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 941 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 376 B

+167
View File
@@ -0,0 +1,167 @@
(function(){
let MenuTpl =
'<div id="menu_{{_namespace}}_{{_name}}" class="dialog {{#isBig}}big{{/isBig}}">' +
'<div class="head"><span>{{title}}</span></div>' +
'{{#isDefault}}<input type="text" name="value"/>{{/isDefault}}' +
'{{#isBig}}<textarea name="value"/>{{/isBig}}' +
'<button type="button" name="submit">Envoyer</button>' +
'<button type="button" name="cancel">Annuler</button>'
'</div>' +
'</div>'
;
window.ESX_MENU = {};
ESX_MENU.ResourceName = 'esx_menu_dialog';
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] = {};
if(typeof data.type == 'undefined')
data.type = 'default';
if(typeof data.align == 'undefined')
data.align = 'top-left';
data._index = ESX_MENU.focus.length;
data._namespace = namespace;
data._name = name;
ESX_MENU.opened[namespace][name] = data;
ESX_MENU.pos [namespace][name] = 0;
ESX_MENU.focus.push({
namespace: namespace,
name : name
});
ESX_MENU.render();
}
ESX_MENU.close = function(namespace, name){
delete ESX_MENU.opened[namespace][name];
for(let i=0; i<ESX_MENU.focus.length; i++){
if(ESX_MENU.focus[i].namespace == namespace && ESX_MENU.focus[i].name == name){
ESX_MENU.focus.splice(i, 1);
break;
}
}
ESX_MENU.render();
}
ESX_MENU.render = function(){
let menuContainer = $('#menus')[0];
$(menuContainer).find('button[name="submit"]').unbind('click');
$(menuContainer).find('button[name="cancel"]').unbind('click');
$(menuContainer).find('[name="value"]') .unbind('input propertychange');
menuContainer.innerHTML = '';
$(menuContainer).hide();
for(let namespace in ESX_MENU.opened){
for(let name in ESX_MENU.opened[namespace]){
let menuData = ESX_MENU.opened[namespace][name];
let view = JSON.parse(JSON.stringify(menuData));
switch(menuData.type){
case 'default' : {
view.isDefault = true;
break;
}
case 'big' : {
view.isBig = true;
break;
}
default : break;
}
let menu = $(Mustache.render(MenuTpl, view))[0];
$(menu).css('z-index', 1000 + view._index);
$(menu).find('button[name="submit"]').click(function() {
ESX_MENU.submit(this.namespace, this.name, this.data);
}.bind({namespace: namespace, name: name, data: menuData}));
$(menu).find('button[name="cancel"]').click(function() {
ESX_MENU.cancel(this.namespace, this.name, this.data);
}.bind({namespace: namespace, name: name, data: menuData}));
$(menu).find('[name="value"]').bind('input propertychange', function(){
this.data.value = $(menu).find('[name="value"]').val();
ESX_MENU.change(this.namespace, this.name, this.data);
}.bind({namespace: namespace, name: name, data: menuData}));
if(typeof menuData.value != 'undefined')
$(menu).find('[name="value"]').val(menuData.value);
menuContainer.appendChild(menu);
}
}
$(menuContainer).show();
}
ESX_MENU.submit = function(namespace, name, data){
$.post('http://' + ESX_MENU.ResourceName + '/menu_submit', JSON.stringify(data));
}
ESX_MENU.cancel = function(namespace, name, data){
$.post('http://' + ESX_MENU.ResourceName + '/menu_cancel', JSON.stringify(data));
}
ESX_MENU.change = function(namespace, name, data){
$.post('http://' + ESX_MENU.ResourceName + '/menu_change', JSON.stringify(data));
}
ESX_MENU.getFocused = function(){
return ESX_MENU.focus[ESX_MENU.focus.length - 1];
}
window.onData = (data) => {
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;
}
}
}
window.onload = function(e){
window.addEventListener('message', (event) => {
onData(event.data)
});
}
})()
+1
View File
File diff suppressed because one or more lines are too long
+15
View File
@@ -0,0 +1,15 @@
<html>
<head>
<link rel="stylesheet" href="css/app.css" />
</head>
<body>
<div id="menus"></div>
<!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> -->
<script src="nui://game/ui/jquery.js" type="text/javascript"></script>
<script src="js/mustache.min.js"></script>
<script src="js/app.js"></script>
</body>
</html>