Skip to content

Commit

Permalink
Merge pull request #10 from codibez/development
Browse files Browse the repository at this point in the history
[#10]: A long overdue update... HERE IT IS!!

* Use of the original font/style entitled `Chalet Comprimé`
* **FIXED:** variable `vehicleCheck` in the configuration file not being rendered correctly.
* Restricted to a single color customization option for the *current street*
* **ADDED:** A "dynamic" view option that places the HUD on a single line
* **ADDED:** A simpler way to manage the size of the overall HUD with the `scale` variable found in the new `configuration.lua` file.

**I highly recommend** removing your old `streetLabel` folder and perform a fresh installation of this script, as many files have been renamed and entirely removed. If you attempt to merge this update to an existing installation, you very well may run into issues.
  • Loading branch information
codibez authored Apr 4, 2021
2 parents bd569b7 + a2b1b86 commit c1952a3
Show file tree
Hide file tree
Showing 10 changed files with 172 additions and 152 deletions.
41 changes: 21 additions & 20 deletions client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ local directions = {
}

local veh = 0;
local streetHash1, streetHash2, playerDirection;
local hash1, hash2, heading;

Citizen.CreateThread(function()

Expand All @@ -21,12 +21,11 @@ Citizen.CreateThread(function()

SendNUIMessage({
type = 'streetLabel:DATA',
border = config.border,
direction = config.direction,
zone = config.current,
street = config.crossing,
color = config.color,
offsetX = config.position.offsetX,
offsetY = config.position.offsetY
offsetY = config.position.offsetY,
scale = config.scale,
dynamic = config.dynamic
});

while true do
Expand All @@ -37,46 +36,48 @@ Citizen.CreateThread(function()
local zone = GetNameOfZone(coords.x, coords.y, coords.z);
local zoneLabel = GetLabelText(zone);

if(checkForVehicle == false or veh ~= 0) then
if(config.vehicleCheck == false or veh ~= 0) then
local var1, var2 = GetStreetNameAtCoord(coords.x, coords.y, coords.z, Citizen.ResultAsInteger(), Citizen.ResultAsInteger())
streetHash1 = GetStreetNameFromHashKey(var1);
streetHash2 = GetStreetNameFromHashKey(var2);
playerDirection = GetEntityHeading(PlayerPedId());
hash1 = GetStreetNameFromHashKey(var1);
hash2 = GetStreetNameFromHashKey(var2);
heading = GetEntityHeading(PlayerPedId());

for k, v in pairs(directions) do
if (math.abs(playerDirection - v) < 22.5) then
playerDirection = k;
if (math.abs(heading - v) < 22.5) then
heading = k;

if (playerDirection == 1) then
playerDirection = 'N';
if (heading == 1) then
heading = 'N';
break;
end

break;
end
end

local street2 = '';
if (streetHash2 == '') then
local street2;
if (hash2 == '') then
street2 = zoneLabel;
else
street2 = streetHash2..', '..zoneLabel;
street2 = hash2..', '..zoneLabel;
end

SendNUIMessage({
type = 'streetLabel:MSG',
active = true,
direction = playerDirection,
zone = streetHash1,
street = street2
direction = heading,
street = hash1,
zone = street2
});
else
SendNUIMessage({
type = 'streetLabel:MSG',
active = false
});
end

-- Wait for half a second.
Citizen.Wait(500);

end
end)
42 changes: 0 additions & 42 deletions config.lua

This file was deleted.

15 changes: 15 additions & 0 deletions configuration.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
config = {
-- Customization options
color = '#f0c850';

position = {
-- 0:100
offsetX = 17;
offsetY = 2.5;
};

scale = 1.0;

vehicleCheck = false; -- Rather or not to display HUD when player(s) are inside a vehicle
dynamic = false;
}
6 changes: 4 additions & 2 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ version '1.1.0'

-- Client Scripts
client_scripts {
'config.lua',
'configuration.lua',
'client.lua'
}

Expand All @@ -17,5 +17,7 @@ ui_page('html/index.html')
files({
'html/index.html',
'html/listener.js',
'html/style.css'
'html/styles.css',
'html/font-face.css',
'html/dynamic.css'
})
36 changes: 36 additions & 0 deletions html/dynamic.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap');
* { box-sizing: border-box; }
body {
background: transparent;
color: rgb(255,255,255);
font-family: 'Roboto', sans-serif;
font-size: 24px;
height: 100vh; width: 100vw;
overflow: hidden;
position: relative;
text-shadow: 1px 1px 2px rgba(0,0,0,.8);
}

div#container {
position: absolute;

display: flex;
align-items: center;
}

section#compass {
margin: auto 5px;

display: flex;
align-items: center;
}
span.border {
transform: scaleY(1.5);
}
span.border:first-child, span#street{ margin-right: 3px; }
span.border:last-child { margin-left: 3px; }

span#direction {
font-size: 28px;
font-weight: 500; /* Roboto - medium */
}
3 changes: 3 additions & 0 deletions html/font-face.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 11 additions & 12 deletions html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,26 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="viewport" content="width=device-width" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />

<title>Street Label</title>

<link rel="stylesheet" href="style.css" />
<link rel="stylesheet" href="font-face.css" type="text/css" />
<link id="style" rel="stylesheet" href="styles.css" type="text/css" />
<script src="nui://game/ui/jquery.js" type="text/javascript"></script>
<script src="./listener.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<section>
<span id="border">|</span>
<h4 id="direction"></h4>
<span id="border">|</span>
<section id="compass">
<span class="border">|</span>
<span id="direction"></span>
<span class="border">|</span>
</section>

<div>
<p id="zone"></p>
<p id="street"></p>
</div>
<section id="vicinity">
<span id="zone"></span>
<span id="street"></span>
</section>
</div>
</body>
</html>
58 changes: 19 additions & 39 deletions html/listener.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,36 @@ window.onload = (e) => {
};

function onMessageRecieved(event){
let item = event.data;
let item = event.data;

if (item && item.type === 'streetLabel:MSG') {
if (!item.active) {
if (!item.active) {
$("#container").hide();
} else {
$("#container").show();
$("#container").show();

let direction = item.direction;
let zone = item.zone;
let street = item.street;
let zone = item.zone;
let street = item.street;

$('#direction').text(direction);
$('#zone').text(zone);
$('#street').text(street);
$('#zone').text(zone);
$('#street').text(street);
}
}
}

if (item && item.type === 'streetLabel:DATA') {
let container = document.getElementById('container');

/* color customization */
let border = [item.border.r, item.border.g, item.border.b, item.border.a];
let borderDOM = document.querySelectorAll('#border');

let direction = [item.direction.r, item.direction.g, item.direction.b, item.direction.a];
let zone = [item.zone.r, item.zone.g, item.zone.b, item.zone.a];
let street = [item.street.r, item.street.g, item.street.b, item.street.a];

// jQuery #direction to proper color & font-size configuration
$('#direction').css('color', 'rgba('+direction.join(', ')+')');
$('#direction').css('font-size', item.direction.size + 'vw');
if (item.color) { $('#street').css('color', item.color); }
/* Position/Scale HUD according to configuration file */
if (item.offsetX) { container.style.left = item.offsetX + '%'; }
if (item.offsetY) { container.style.bottom = item.offsetY + '%'; }
if (item.scale) { container.style.transform = `scale(${item.scale})`; }

// jQuery #street to proper color & font-size configuration
$('#street').css('color', 'rgba('+street.join(', ')+')');
$('#street').css('font-size', item.street.size + 'vw');

// jQuery #zone to proper color & font-size configuration
$('#zone').css('color', 'rgba('+zone.join(', ')+')');
$('#zone').css('font-size', item.zone.size + 'vw');

for (let i=0; i < borderDOM.length; i++) {
borderDOM[i].style.color = 'rgba('+border.join(', ')+')';
borderDOM[i].style.fontSize = item.border.size + 'vw';
}

/* HUD position */
if (item.offsetX) { container.style.left = item.offsetX + '%' }
if (item.offsetY) { container.style.bottom = item.offsetY + '%' }

/* view */
/* Dynamic stylesheet control */
if (item.dynamic) {
document.getElementById('style').href = 'dynamic.css';
} else {
document.getElementById('style').href = 'styles.css';
}
}
}
37 changes: 0 additions & 37 deletions html/style.css

This file was deleted.

Loading

0 comments on commit c1952a3

Please sign in to comment.