Skip to content

Commit b0d64aa

Browse files
committed
feat: add dynamic blip CSS
Blip images for use in HTML is dynamically created in the generateBlipShit function in "markers.js". Since there's a load of blips, I felt dynamically creating them would be better than sitting down for two hours and manually putting them in. It doesn't take into account the other marker types (yet).
1 parent e24c1a5 commit b0d64aa

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

index.php

+2
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@
8888
var _MAP_tileURL = "<?php echo $config->mapTileUrl; ?>";
8989
var _MAP_iconURL = "<?php echo $config->mapIconUrl; ?>";
9090

91+
var _MAP_currentUri = "<?php echo $_SERVER["REQUEST_URI"]; ?>";
92+
9193
// Sets whether it should showSets whether it should show Atlas map (WARNING: REQUIRES "atlas" TILE DIRECTORY)
9294
var _MAP_atlasMap = <?php echo json_encode($config->atlasEnabled); ?>;
9395

js/src/markers.js

+24-1
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,19 @@ var types = {
219219
DollarSignSquared : {id: 434}
220220
};
221221

222+
var blipCss = `.blip {
223+
background: url("${_MAP_currentUri}${_MAP_iconURL}blips_texturesheet.png");
224+
background-size: ${1024/2}px ${1024/2}px;
225+
display: inline-block;
226+
width: ${customImageWidth}px;
227+
height: ${customImageHeight}px;
228+
}`;
222229
function generateBlipShit(){
223230
var currentX = 0, currentY = 0, currentId = 0;
231+
232+
var previousLeft = 0, previousTop = 0;
233+
var linePadding = 0;
234+
224235
for(var blipName in types){
225236
var blip = types[blipName];
226237

@@ -248,7 +259,19 @@ function generateBlipShit(){
248259
scaledSize: new google.maps.Size( 1024/2,1024/2 ),
249260
origin: new google.maps.Point( customImageWidth * currentX , customImageHeight * currentY ),
250261
};
262+
263+
// CSS GENERATOR FOR BLIP ICONS IN HTML
264+
// Just add the class "blip blip-<NAME>" to the element for blip icons
265+
// e.g. <span class="blip blip-Standard"> for a Standard blip
266+
var left = (currentX * customImageWidth) + linePadding; // 0 = padding between images
267+
var top = (currentY * customImageHeight) + linePadding; // 0 = padding
268+
269+
// For styling spans and shit
270+
blipCss += `.blip-${blipName} { background-position: -${left}px -${top}px }
271+
`;
251272
}
273+
274+
$("head").append(`<style>${blipCss}</style>`);
252275
}
253276

254-
generateBlipShit();
277+
setTimeout(generateBlipShit, 50);

js/src/socket.js

-3
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,6 @@ function getPlayerInfoHtml(plr) {
301301

302302
function doPlayerUpdate(players) {
303303

304-
//Quickly sort the names, alphabetical order
305-
players.sort();
306-
307304
if (_SETTINGS_debug) {
308305
console.log(players);
309306
}

utils/minifier.php

-2
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,4 @@ public static function printLastJs($debug){
114114
}
115115
}
116116

117-
118-
119117
?>

0 commit comments

Comments
 (0)