-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
666 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<title>ATLAS - Item Search</title> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/corejs-typeahead/1.3.1/typeahead.bundle.min.js" integrity="sha512-lEb9Vp/rkl9g2E/LdHIMFTqz21+LA79f84gqP75fbimHqVTu6483JG1AwJlWLLQ8ezTehty78fObKupq3HSHPQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.8/clipboard.min.js" integrity="sha512-sIqUEnRn31BgngPmHt2JenzleDDsXwYO+iyvQ46Mw6RL+udAUZj2n/u/PGY80NxRxynO7R9xIGx5LEzw4INWJQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> | ||
<style> | ||
.bs-example { | ||
font-family: sans-serif; | ||
position: relative; | ||
margin: 100px; | ||
} | ||
|
||
.typeahead, | ||
.tt-query, | ||
.tt-hint { | ||
border: 2px solid #CCCCCC; | ||
border-radius: 8px; | ||
font-size: 22px; | ||
/* Set input font size */ | ||
height: 30px; | ||
line-height: 30px; | ||
outline: medium none; | ||
padding: 8px 12px; | ||
width: 396px; | ||
} | ||
|
||
.typeahead { | ||
background-color: #FFFFFF; | ||
} | ||
|
||
.typeahead:focus { | ||
border: 2px solid #0097CF; | ||
} | ||
|
||
.tt-query { | ||
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset; | ||
} | ||
|
||
.tt-hint { | ||
color: #999999; | ||
} | ||
|
||
.tt-menu { | ||
background-color: #FFFFFF; | ||
border: 1px solid rgba(0, 0, 0, 0.2); | ||
border-radius: 8px; | ||
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); | ||
margin-top: 12px; | ||
padding: 8px 0; | ||
width: 422px; | ||
} | ||
|
||
.tt-suggestion { | ||
font-size: 22px; | ||
/* Set suggestion dropdown font size */ | ||
padding: 3px 20px; | ||
} | ||
|
||
.tt-suggestion:hover { | ||
cursor: pointer; | ||
background-color: #0097CF; | ||
color: #FFFFFF; | ||
} | ||
|
||
.tt-dropdown-menu { | ||
max-height: 150px; | ||
overflow-y: auto; | ||
} | ||
|
||
.tt-suggestion p { | ||
margin: 0; | ||
} | ||
|
||
.icon { | ||
display: block; | ||
float: left; | ||
padding-right: 10px; | ||
width: 32px; | ||
height: 32px; | ||
} | ||
|
||
.nl { | ||
display: block; | ||
font-size: 12pt; | ||
} | ||
|
||
.title { | ||
display: block; | ||
font-size: 12pt; | ||
} | ||
|
||
.classname { | ||
display: block; | ||
font-size: 8pt; | ||
} | ||
</style> | ||
|
||
<script> | ||
var className = ""; | ||
$(document).ready(function() { | ||
let bh = new Bloodhound({ | ||
datumTokenizer: function(d) { | ||
let tokens = [d.Name, d.ClassName.slice(0, -2).replace("_", " ")]; | ||
return Bloodhound.tokenizers.whitespace(tokens); | ||
}, | ||
queryTokenizer: Bloodhound.tokenizers.whitespace, | ||
identify: function(obj) { | ||
return obj.Name; | ||
}, | ||
prefetch: { | ||
url: '/json/items.json', | ||
filter: function(list) { | ||
return $.map(list, function(v, k) { | ||
if (!v.ClassName) | ||
return; | ||
v.Name = k | ||
v.ClassName = v.ClassName.slice(0, -2); // Remove _C | ||
return v; | ||
}); | ||
} | ||
} | ||
}); | ||
bh.clearPrefetchCache(); | ||
bh.initialize(true); | ||
$('.typeahead').typeahead({ | ||
hint: true, | ||
highlight: true, | ||
minLength: 1, | ||
}, { | ||
name: 'bh', | ||
source: bh, | ||
limit: 10, | ||
display: function(data) { | ||
return data.Name | ||
}, | ||
templates: { | ||
suggestion: function(data) { | ||
return `<p><img src="/atlasicons/${data.Icon}_32.png" class="icon"><span><span class="title">${data.Name}</span><span class="classname">${data.ClassName}</span></span></p>` | ||
} | ||
}, | ||
}); | ||
}).on('typeahead:selected', function(evt, item) { | ||
className = item.ClassName; | ||
updateItem(); | ||
}); | ||
|
||
function updateItem() { | ||
$('#target').text(`cheat gfi ${className} ${$('#quant').val() ? $('#quant').val() : 0} ${$('#qual').val() ? $('#qual').val() : 0} ${$('#bp').prop('checked') ? 1 : 0}`) | ||
} | ||
</script> | ||
</head> | ||
|
||
<body> | ||
<div> | ||
<input type="text" class="typeahead tt-query" autocomplete="off" spellcheck="false"> | ||
<span class="nl"><input type="checkbox" id="bp" onchange="updateItem()">Blueprint</span> | ||
<span class="nl">Quantity <input type="number" id="quant" value="100" min="0" max="1000" | ||
onchange="updateItem()"></span> | ||
<span class="nl">Quality <input type="number" id="qual" value="0" min="0" max="100000" | ||
onchange="updateItem()"></span> | ||
<pre id="target">cheat gfi</pre> | ||
<button class="btn" data-clipboard-action="copy" data-clipboard-target="#target">Copy</button> | ||
<script> | ||
new ClipboardJS('.btn'); | ||
</script> | ||
</div> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
/* global L */ | ||
|
||
L.Control.AccountService = L.Control.extend({ | ||
options: { | ||
position: 'topleft', | ||
}, | ||
|
||
// hardcode for now | ||
_icons_src: { | ||
Bed: 'Item_SimpleBed_Icon', | ||
Broadsider: 'ICON_Broadsider', | ||
Carrack: 'ICON_Carrack', | ||
Cog: 'ICON_Cog', | ||
Brigantine: 'Item_BrigHull_Icon', | ||
Harrier: 'ICON_Harrier', | ||
Kraken: 'KrakenShipNewIcon', | ||
Turtle: 'Turtleship_Icon', | ||
MortarShip: 'Mortarship_Icon', | ||
Ramming_Galley: 'Galley_Icon', | ||
Galleon: 'Item_GalleonHull_Icon', | ||
Raft: 'Item_Raft_Icon', | ||
Schooner: 'Item_SchoonerHull_Icon', | ||
Sloop: 'Item_SloopHull_Icon', | ||
Sloop_FromNPC: 'Item_SloopHull_Icon', | ||
Submarine: 'Item_Submarine_Icon', | ||
TrampFreighter: 'ICON_Tramp_Freighter', | ||
TurtleShip: 'Turtleship_Icon', | ||
}, | ||
|
||
_icons: {}, | ||
_ships: {}, | ||
_eventSource: {}, | ||
|
||
initialize: function (options) { | ||
L.Util.setOptions(this, options); | ||
for (let i in this._icons_src) { | ||
this._icons[i] = L.icon({ | ||
iconUrl: '/atlasIcons/entities/' + this._icons_src[i] + '_32.png', | ||
iconSize: [30, 30], | ||
iconAnchor: [15, 15], | ||
popupAnchor: [0, -15], | ||
}); | ||
} | ||
}, | ||
|
||
onAdd: function (map) { | ||
let container = L.DomUtil.create('div', 'leaflet-control-zoom leaflet-bar leaflet-control'); | ||
this._map = map; | ||
this._config = map.options.config; | ||
|
||
fetch(this._config.AtlasMapServer + '/s/account', { | ||
dataType: 'json', | ||
}) | ||
.then((r) => { | ||
r.json() | ||
.then((account) => { | ||
this._createButton( | ||
'<img src="icons/logout.svg" height=30 width=30>', | ||
'logout', | ||
'leaflet-control-pin leaflet-bar-part leaflet-bar-part-top-and-bottom', | ||
container, | ||
this._logout, | ||
this, | ||
); | ||
this._startEventListener(map); | ||
}) | ||
.catch((error) => { | ||
this._createButton( | ||
'<img src="icons/steam.svg" height=30 width=30>', | ||
'Login with Steam', | ||
'leaflet-control-pin leaflet-bar-part leaflet-bar-part-top-and-bottom', | ||
container, | ||
this._login, | ||
this, | ||
); | ||
}); | ||
}) | ||
.catch((error) => { | ||
console.log('backend unavailable; not enabling login', error); | ||
}); | ||
return container; | ||
}, | ||
|
||
onRemove: function (map) {}, | ||
_startEventListener: function (map) { | ||
this._eventSource = new EventSource(this._config.AtlasMapServer + '/s/events'); | ||
this._eventSource.onmessage = (event) => { | ||
let d = JSON.parse(event.data); | ||
if (d.EntityType !== undefined) { | ||
this._processEntity(d); | ||
} | ||
}; | ||
}, | ||
|
||
_processEntity: function (d) { | ||
switch (d.EntityType) { | ||
case 'Ship': | ||
case 'ETribeEntityType::Ship': | ||
this._trackShip(d); | ||
break; | ||
|
||
case 'Bed': | ||
case 'ETribeEntityType::Bed': | ||
console.dir(d); // slap bed on map | ||
break; | ||
} | ||
}, | ||
_trackShip: function (d) { | ||
// Get server grid reference. | ||
let duration = 5000, | ||
x = d.ServerId >> 16, | ||
y = d.ServerId & 0xffff, | ||
unrealX = this._map.options.config.GridSize * d.X + this._map.options.config.GridSize * x, | ||
unrealY = this._map.options.config.GridSize * d.Y + this._map.options.config.GridSize * y, | ||
gps = this._map.worldToLeaflet(unrealX, unrealY); | ||
|
||
let ship = this._ships[d.EntityID]; | ||
if (ship === undefined) { | ||
if (this._icons[d.ShipType] !== undefined) { | ||
ship = L.Marker.movingMarker([gps], [duration], {icon: this._icons[d.ShipType], title: d.EntityName }).addTo( | ||
this._map, | ||
); | ||
} else { | ||
ship = L.Marker.movingMarker([gps], [duration]).addTo(this._map); | ||
} | ||
} | ||
|
||
ship.addLatLng(gps, duration); | ||
ship.start(); | ||
this._ships[d.EntityID] = ship; | ||
}, | ||
|
||
_login: function () { | ||
window.location = this._config.AtlasMapServer + '/login'; | ||
}, | ||
|
||
_logout: function () { | ||
window.location = this._config.AtlasMapServer + '/logout'; | ||
}, | ||
|
||
_createButton: function (html, title, className, container, fn, context) { | ||
let link = L.DomUtil.create('a', className, container); | ||
link.innerHTML = html; | ||
link.href = '#'; | ||
link.title = title; | ||
|
||
L.DomEvent.on(link, 'click', L.DomEvent.stopPropagation) | ||
.on(link, 'click', L.DomEvent.preventDefault) | ||
.on(link, 'click', fn, context) | ||
.on(link, 'dbclick', L.DomEvent.stopPropagation); | ||
return link; | ||
}, | ||
|
||
draw: function (grids) { | ||
return this; | ||
}, | ||
}); | ||
|
||
L.control.accountControl = function (options) { | ||
return new L.Control.AccountService(options); | ||
}; | ||
|
||
var accountControl; | ||
L.Map.addInitHook(function () { | ||
if (this.options.config.AtlasMapServer) { | ||
this.accountControl = new L.Control.AccountService(); | ||
accountControl = this.accountControl; | ||
this.addControl(this.accountControl); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.