mirror of
https://gitlab.com/Oreolek/cloak-salet.git
synced 2024-05-14 15:08:29 +03:00
Automap
This commit is contained in:
parent
33fd0a9072
commit
e1bd54a2d6
|
@ -201,18 +201,30 @@ sysroom "map",
|
|||
nodes: []
|
||||
}
|
||||
edges = []
|
||||
rooms = []
|
||||
globx = 1
|
||||
globy = 1
|
||||
deltas = [
|
||||
# [1, 0], # looks bad on our map
|
||||
[0, 1],
|
||||
[-1, 0],
|
||||
[0, -1],
|
||||
]
|
||||
for name, room of salet.rooms
|
||||
if room.canSave == false or name == "start"
|
||||
continue
|
||||
data.nodes.push({
|
||||
"id": name
|
||||
"label": room.title()
|
||||
"size": 5
|
||||
"color": "#000"
|
||||
"x": Math.random()*10
|
||||
"y": Math.random()*10
|
||||
})
|
||||
if rooms.indexOf(name) == -1
|
||||
data.nodes.push({
|
||||
"id": name
|
||||
"label": room.title()
|
||||
"size": 5
|
||||
"color": "#000"
|
||||
"x": globx
|
||||
"y": globy
|
||||
})
|
||||
rooms.push(name)
|
||||
if room.ways? and room.ways.length > 0
|
||||
delta = 0
|
||||
for way in room.ways
|
||||
id = "edge_"+name+"_"+way
|
||||
# we don't want to display a two-way link twice
|
||||
|
@ -225,6 +237,19 @@ sysroom "map",
|
|||
"size": 1
|
||||
"color": "#ccc"
|
||||
})
|
||||
if rooms.indexOf(way) == -1
|
||||
data.nodes.push({
|
||||
"id": way
|
||||
"label": salet.rooms[way].title()
|
||||
"size": 5
|
||||
"color": "#000"
|
||||
"x": globx + deltas[delta][0]
|
||||
"y": globy + deltas[delta][1]
|
||||
})
|
||||
rooms.push(way)
|
||||
delta++
|
||||
globx = globx + 2
|
||||
globy = globy + 2
|
||||
console.log data
|
||||
s = new sigma({
|
||||
graph: data,
|
||||
|
|
Loading…
Reference in a new issue