Minor improvements, removed unused assets

This commit is contained in:
ElPumpo
2018-10-17 20:04:22 +02:00
parent df0d9561ef
commit 39c71ce4a9
11 changed files with 90 additions and 113 deletions
+2 -2
View File
@@ -1,2 +1,2 @@
# fxserver-esx_menu_default
FXServer ESX Menu Default
# esx_menu_default
ESX Menu Default
+1 -4
View File
@@ -19,10 +19,7 @@ files {
'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',
'html/fonts/bankgothic.ttf'
}
dependencies {
+5 -26
View File
@@ -1,7 +1,6 @@
ESX = nil
Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(0)
@@ -24,7 +23,6 @@ Citizen.CreateThread(function()
local MenuType = 'default'
local openMenu = function(namespace, name, data)
SendNUIMessage({
action = 'openMenu',
namespace = namespace,
@@ -35,7 +33,6 @@ Citizen.CreateThread(function()
end
local closeMenu = function(namespace, name)
SendNUIMessage({
action = 'closeMenu',
namespace = namespace,
@@ -52,25 +49,20 @@ Citizen.CreateThread(function()
if menu.submit ~= nil then
menu.submit(data, menu)
end
end)
AddEventHandler('esx_menu_default:message:menu_cancel', function(data)
local menu = ESX.UI.Menu.GetOpened(MenuType, data._namespace, data._name)
if menu.cancel ~= nil then
menu.cancel(data, menu)
end
end)
AddEventHandler('esx_menu_default:message:menu_change', function(data)
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
@@ -84,81 +76,68 @@ Citizen.CreateThread(function()
if menu.change ~= nil then
menu.change(data, menu)
end
end)
Citizen.CreateThread(function()
while true do
Wait(0)
Citizen.Wait(10)
if IsControlPressed(0, Keys['ENTER']) and GetLastInputMethod(2) and (GetGameTimer() - GUI.Time) > 150 then
SendNUIMessage({
action = 'controlPressed',
control = 'ENTER'
})
GUI.Time = GetGameTimer()
end
if IsControlPressed(0, Keys['BACKSPACE']) and GetLastInputMethod(2) and (GetGameTimer() - GUI.Time) > 150 then
SendNUIMessage({
action = 'controlPressed',
control = 'BACKSPACE'
})
GUI.Time = GetGameTimer()
end
if IsControlPressed(0, Keys['TOP']) and GetLastInputMethod(2) and (GetGameTimer() - GUI.Time) > 150 then
if IsControlPressed(0, Keys['TOP']) and GetLastInputMethod(2) and (GetGameTimer() - GUI.Time) > 200 then
SendNUIMessage({
action = 'controlPressed',
control = 'TOP'
})
GUI.Time = GetGameTimer()
end
if IsControlPressed(0, Keys['DOWN']) and GetLastInputMethod(2) and (GetGameTimer() - GUI.Time) > 150 then
if IsControlPressed(0, Keys['DOWN']) and GetLastInputMethod(2) and (GetGameTimer() - GUI.Time) > 200 then
SendNUIMessage({
action = 'controlPressed',
control = 'DOWN'
})
GUI.Time = GetGameTimer()
end
if IsControlPressed(0, Keys['LEFT']) and GetLastInputMethod(2) and (GetGameTimer() - GUI.Time) > 150 then
SendNUIMessage({
action = 'controlPressed',
control = 'LEFT'
})
GUI.Time = GetGameTimer()
end
if IsControlPressed(0, Keys['RIGHT']) and GetLastInputMethod(2) and (GetGameTimer() - GUI.Time) > 150 then
SendNUIMessage({
action = 'controlPressed',
control = 'RIGHT'
})
GUI.Time = GetGameTimer()
end
end
end
end)
end)
+48 -47
View File
@@ -1,93 +1,94 @@
@font-face {
font-family: bankgothic;
src: url('../fonts/bankgothic.ttf');
font-family: bankgothic;
src: url('../fonts/bankgothic.ttf');
}
@font-face {
font-family: pcdown;
src: url('../fonts/pdown.ttf');
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;
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%);
left: 40;
top: 50%;
transform: translate(0, -50%);
}
.menu.align-top-left {
left: 40;
top : 40;
left: 40;
top: 40;
}
.menu.align-top {
left: 50%;
top : 40;
transform: translate(-50%, 0);
left: 50%;
top: 40;
transform: translate(-50%, 0);
}
.menu.align-top-right {
right: 10;
top : 40;
right: 10;
top: 40;
}
.menu.align-right {
right: 40;
top : 50%;
transform: translate(0, -50%);
right: 40;
top: 50%;
transform: translate(0, -50%);
}
.menu.align-bottom-right {
right : 40;
bottom: 40;
right: 40;
bottom: 40;
}
.menu.align-bottom {
left : 50%;
bottom: 40;
transform: translate(-50%, 0);
left: 50%;
bottom: 40;
transform: translate(-50%, 0);
}
.menu.align-bottom-left {
left : 40;
bottom: 40;
left: 40;
bottom: 40;
}
.menu.align-center {
left : 50%;
top : 50%;
transform: translate(-50%, -50%);
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.menu .head {
background-color: #506be6;
text-align : center;
height : 40px;
line-height : 40px;
background-color: #506be6;
text-align: center;
height: 40px;
line-height: 40px;
}
.menu .menu-items {
max-height : 600px;
overflow-y : auto;
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;
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;
background-color: #d0d0d0;
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1015 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 272 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 941 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 376 B

+22 -22
View File
@@ -51,7 +51,7 @@
if(data.elements[i].selected)
ESX_MENU.pos[namespace][name] = i;
else
data.elements[i].selected = false
data.elements[i].selected = false;
}
ESX_MENU.focus.push({
@@ -62,7 +62,7 @@
ESX_MENU.render();
$('#menu_' + namespace + '_' + name).find('.menu-item.selected')[0].scrollIntoView();
}
};
ESX_MENU.close = function(namespace, name){
@@ -77,7 +77,7 @@
ESX_MENU.render();
}
};
ESX_MENU.render = function(){
@@ -91,7 +91,7 @@
for(let name in ESX_MENU.opened[namespace]){
let menuData = ESX_MENU.opened[namespace][name];
let view = JSON.parse(JSON.stringify(menuData))
let view = JSON.parse(JSON.stringify(menuData));
for(let i=0; i<menuData.elements.length; i++){
@@ -130,7 +130,7 @@
$(menuContainer).show();
}
};
ESX_MENU.submit = function(namespace, name, data){
SendMessage(ESX_MENU.ResourceName, 'menu_submit', {
@@ -139,14 +139,14 @@
current : data,
elements : ESX_MENU.opened[namespace][name].elements
});
}
};
ESX_MENU.cancel = function(namespace, name){
SendMessage(ESX_MENU.ResourceName, 'menu_cancel', {
_namespace: namespace,
_name : name
});
}
};
ESX_MENU.change = function(namespace, name, data){
SendMessage(ESX_MENU.ResourceName, 'menu_change', {
@@ -155,11 +155,11 @@
current : data,
elements : ESX_MENU.opened[namespace][name].elements
});
}
};
ESX_MENU.getFocused = function(){
return ESX_MENU.focus[ESX_MENU.focus.length - 1];
}
};
window.onData = (data) => {
@@ -228,12 +228,12 @@
for(let i=0; i<menu.elements.length; i++){
if(i == ESX_MENU.pos[focused.namespace][focused.name])
menu.elements[i].selected = true
menu.elements[i].selected = true;
else
menu.elements[i].selected = false
menu.elements[i].selected = false;
}
ESX_MENU.change(focused.namespace, focused.name, elem)
ESX_MENU.change(focused.namespace, focused.name, elem);
ESX_MENU.render();
$('#menu_' + focused.namespace + '_' + focused.name).find('.menu-item.selected')[0].scrollIntoView();
@@ -263,12 +263,12 @@
for(let i=0; i<menu.elements.length; i++){
if(i == ESX_MENU.pos[focused.namespace][focused.name])
menu.elements[i].selected = true
menu.elements[i].selected = true;
else
menu.elements[i].selected = false
menu.elements[i].selected = false;
}
ESX_MENU.change(focused.namespace, focused.name, elem)
ESX_MENU.change(focused.namespace, focused.name, elem);
ESX_MENU.render();
$('#menu_' + focused.namespace + '_' + focused.name).find('.menu-item.selected')[0].scrollIntoView();
@@ -298,7 +298,7 @@
if(elem.value > min){
elem.value--;
ESX_MENU.change(focused.namespace, focused.name, elem)
ESX_MENU.change(focused.namespace, focused.name, elem);
}
ESX_MENU.render();
@@ -335,12 +335,12 @@
if(typeof elem.options != 'undefined' && elem.value < elem.options.length - 1){
elem.value++;
ESX_MENU.change(focused.namespace, focused.name, elem)
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.change(focused.namespace, focused.name, elem);
}
ESX_MENU.render();
@@ -368,12 +368,12 @@
}
}
};
window.onload = function(e){
window.addEventListener('message', (event) => {
onData(event.data)
onData(event.data);
});
}
};
})()
})();
+12 -12
View File
@@ -1,16 +1,16 @@
<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"></script>
<script src="nui://es_extended/html/js/wrapper.js"></script>
<script src="js/mustache.min.js"></script>
<script src="js/app.js"></script>
<head>
<link rel="stylesheet" href="css/app.css" />
</head>
<body>
<div id="menus"></div>
<script src="nui://game/ui/jquery.js"></script>
<script src="nui://es_extended/html/js/wrapper.js"></script>
<script src="js/mustache.min.js"></script>
<script src="js/app.js"></script>
</body>
</body>
</html>