Skip to content

Commit 4b712dd

Browse files
committed
feat: add blip controls
Users can now toggle on/off the blips they want.
1 parent b15ccbe commit 4b712dd

File tree

6 files changed

+67
-10
lines changed

6 files changed

+67
-10
lines changed

index.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@
297297
<div id="blip-filter-dropdown" class="custom-menu col-sm-0 col-xs-0 col-md-12 collapse">
298298
<div class="list-group border-0 card text-center text-md-left" style="padding: 8px 0;">
299299

300-
<a class="nav-header">Blip Controls</a>
300+
<a class="nav-header">Blip Controls <small id="toggle-all-blips" class="btn btn-sm btn-info">Toggle all</small></a>
301301

302302
<div id="blip-control-container" class="row">
303303

js/src/alerter.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,8 @@ function createAlert(data, settings){
135135
settings.type = "warning";
136136
}
137137

138-
console.log(JSON.stringify(data));
139-
console.log(JSON.stringify(settings));
140-
141-
var notif = $.notify(data, settings);
142-
143-
return notif; // Incase I need this in future for shit like prgress bars or, if i need to update the alert
138+
//console.log(JSON.stringify(data));
139+
//console.log(JSON.stringify(settings));
140+
141+
return $.notify(data, settings);; // Incase I need this in future for shit like prgress bars or, if i need to update the alert
144142
}

js/src/controls.js

+33
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ function toggleBlips(){
2222

2323
for(var spriteId in _blips){
2424
var blipArray = _blips[spriteId];
25+
//console.log("Disabled (" + spriteId + ")? " + _disabledBlips.includes(spriteId));
26+
27+
if(_disabledBlips.indexOf(spriteId) != -1){
28+
if(_SETTINGS_debug){
29+
console.log("Blip " + spriteId + "'s are disabled..");
30+
}
31+
// If disabled, don't make a marker for it
32+
continue;
33+
}
2534

2635
for(var i in blipArray){
2736
var blip = blipArray[i];
@@ -93,4 +102,28 @@ $(document).ready(function(){
93102

94103
connect();
95104
});
105+
106+
$("#toggle-all-blips").on("click", function(){
107+
// Toggle the classes and add/remove the blipIds from the array
108+
$("#blip-control-container").find("a").each(function(index, ele){
109+
var ele = $(ele);
110+
var blipId = ele.data("blipNumber").toString();
111+
112+
// Toggle blip
113+
if(_disabledBlips.includes(blipId)){
114+
// Already disabled, enable it
115+
_disabledBlips.splice(_disabledBlips.indexOf(blipId), 1);
116+
ele.removeClass("blip-disabled").addClass("blip-enabled");
117+
}else{
118+
// Enabled, disable it
119+
_disabledBlips.push(blipId);
120+
ele.removeClass("blip-enabled").addClass("blip-disabled");
121+
}
122+
});
123+
124+
// Now we can refresh the markers
125+
clearAllMarkers();
126+
toggleBlips();
127+
});
128+
96129
});

js/src/init.js

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var _isConnected = false;
2525
var _trackPlayer = null;
2626
var playerCount = 0;
2727
var _overlays = [];
28+
var _disabledBlips = [];
2829

2930
function globalInit() {
3031
mapInit("map-canvas");

js/src/markers.js

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

222+
var nameToId = {};
223+
222224
var blipCss = `.blip {
223225
background: url("${_MAP_currentUri}${_MAP_iconURL}blips_texturesheet.png");
224226
background-size: ${1024/2}px ${1024/2}px;
@@ -229,13 +231,34 @@ var blipCss = `.blip {
229231

230232
function generateBlipControls(){
231233
for(var blipName in types){
232-
$("#blip-control-container").append(`<a id="blip_${blipName}_link" class="list-group-item d-inline-block collapsed blip-enabled" href="#"><span class="blip blip-${blipName}"></span></a>`);
234+
$("#blip-control-container").append(`<a data-blip-number="${nameToId[blipName]}" id="blip_${blipName}_link" class="blip-button-a list-group-item d-inline-block collapsed blip-enabled" href="#"><span class="blip blip-${blipName}"></span></a>`);
233235

234236
if(_SETTINGS_debug){
235237
console.log("Added ahref for " + blipName);
236238
}
237-
238239
}
240+
241+
// Events
242+
$(".blip-button-a").on("click", function(e){
243+
var ele = $(e.currentTarget);
244+
var blipId = ele.data("blipNumber").toString();
245+
246+
// Toggle blip
247+
if(_disabledBlips.includes(blipId)){
248+
// Already disabled, enable it
249+
_disabledBlips.splice(_disabledBlips.indexOf(blipId), 1);
250+
ele.removeClass("blip-disabled").addClass("blip-enabled");
251+
}else{
252+
// Enabled, disable it
253+
_disabledBlips.push(blipId);
254+
ele.removeClass("blip-enabled").addClass("blip-disabled");
255+
}
256+
257+
// Refresh blips (there's probably a faster way..)
258+
clearAllMarkers();
259+
toggleBlips();
260+
});
261+
239262
}
240263

241264
function generateBlipShit(){
@@ -272,6 +295,8 @@ function generateBlipShit(){
272295
origin: new google.maps.Point( customImageWidth * currentX , customImageHeight * currentY ),
273296
};
274297

298+
nameToId[blipName] = currentId;
299+
275300
// CSS GENERATOR FOR BLIP ICONS IN HTML
276301
// Just add the class "blip blip-<NAME>" to the element for blip icons
277302
// e.g. <span class="blip blip-Standard"> for a Standard blip

utils/config.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Config{
2828

2929
// Set to false to enable the miinified versions of JS and CSS files
3030
// that should speed up content delivery on production websites
31-
public $debug = true;
31+
public $debug = false;
3232

3333
// An array of servers that you want the interface to be available for
3434
public static $servers = array(

0 commit comments

Comments
 (0)