mirror of
https://github.com/webbukkit/dynmap.git
synced 2025-02-26 00:31:44 +01:00
Added initial work for 'componentizing' client-side.
This commit is contained in:
parent
15a8e03e9e
commit
2be0cd3671
@ -80,6 +80,10 @@ web:
|
|||||||
quitmessage: "%playername% quit"
|
quitmessage: "%playername% quit"
|
||||||
spammessage: "You may only chat once every %interval% seconds."
|
spammessage: "You may only chat once every %interval% seconds."
|
||||||
|
|
||||||
|
components:
|
||||||
|
- type: testcomponent
|
||||||
|
- type: testcomponent
|
||||||
|
|
||||||
defaultworld: world
|
defaultworld: world
|
||||||
worlds:
|
worlds:
|
||||||
- title: World
|
- title: World
|
||||||
@ -121,7 +125,6 @@ web:
|
|||||||
# title: Cave
|
# title: Cave
|
||||||
# name: cave
|
# name: cave
|
||||||
# prefix: ct
|
# prefix: ct
|
||||||
|
|
||||||
# Enables debugging.
|
# Enables debugging.
|
||||||
#debuggers:
|
#debuggers:
|
||||||
# - class: org.dynmap.debug.LogDebugger
|
# - class: org.dynmap.debug.LogDebugger
|
||||||
|
@ -1,9 +1,29 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
//if (!console) console = { log: function() {} };
|
//if (!console) console = { log: function() {} };
|
||||||
|
|
||||||
|
var componentconstructors = {};
|
||||||
var maptypes = {};
|
var maptypes = {};
|
||||||
var clocks = {};
|
var clocks = {};
|
||||||
|
|
||||||
|
componentconstructors['testcomponent'] = function(dynmap, configuration) {
|
||||||
|
return {
|
||||||
|
dynmap: dynmap,
|
||||||
|
initialize: function() {
|
||||||
|
console.log('initialize');
|
||||||
|
$(dynmap).bind('worldchanged', function() { console.log('worldchanged'); });
|
||||||
|
$(dynmap).bind('mapchanged', function() { console.log('mapchanged'); });
|
||||||
|
$(dynmap).bind('zoomchanged', function() { console.log('zoomchanged'); });
|
||||||
|
$(dynmap).bind('worldupdating', function() { console.log('worldupdating'); });
|
||||||
|
$(dynmap).bind('worldupdate', function() { console.log('worldupdate'); });
|
||||||
|
$(dynmap).bind('worldupdated', function() { console.log('worldupdated'); });
|
||||||
|
$(dynmap).bind('worldupdatefailed', function() { console.log('worldupdatefailed'); });
|
||||||
|
$(dynmap).bind('playeradded', function() { console.log('playeradded'); });
|
||||||
|
$(dynmap).bind('playerremoved', function() { console.log('playerremoved'); });
|
||||||
|
$(dynmap).bind('playerupdated', function() { console.log('playerupdated'); });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
function splitArgs(s) {
|
function splitArgs(s) {
|
||||||
var r = s.split(' ');
|
var r = s.split(' ');
|
||||||
delete arguments[0];
|
delete arguments[0];
|
||||||
@ -54,6 +74,7 @@ function DynMap(options) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
DynMap.prototype = {
|
DynMap.prototype = {
|
||||||
|
components: [],
|
||||||
worlds: {},
|
worlds: {},
|
||||||
registeredTiles: [],
|
registeredTiles: [],
|
||||||
players: {},
|
players: {},
|
||||||
@ -107,18 +128,21 @@ DynMap.prototype = {
|
|||||||
|
|
||||||
map.zoom_changed = function() {
|
map.zoom_changed = function() {
|
||||||
me.maptype.updateTileSize(me.map.zoom);
|
me.maptype.updateTileSize(me.map.zoom);
|
||||||
|
$(me).trigger('zoomchanged');
|
||||||
};
|
};
|
||||||
|
|
||||||
google.maps.event.addListener(map, 'dragstart', function(mEvent) {
|
google.maps.event.addListener(map, 'dragstart', function(mEvent) {
|
||||||
me.followPlayer(null);
|
me.followPlayer(null);
|
||||||
});
|
});
|
||||||
// TODO: Enable hash-links.
|
// TODO: Enable hash-links.
|
||||||
/*google.maps.event.addListener(map, 'zoom_changed', function() {
|
/*
|
||||||
|
google.maps.event.addListener(map, 'zoom_changed', function() {
|
||||||
me.updateLink();
|
me.updateLink();
|
||||||
});
|
});
|
||||||
google.maps.event.addListener(map, 'center_changed', function() {
|
google.maps.event.addListener(map, 'center_changed', function() {
|
||||||
me.updateLink();
|
me.updateLink();
|
||||||
});*/
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
// Sidebar
|
// Sidebar
|
||||||
var sidebar = me.sidebar = $('<div/>')
|
var sidebar = me.sidebar = $('<div/>')
|
||||||
@ -286,6 +310,13 @@ DynMap.prototype = {
|
|||||||
|
|
||||||
me.selectMap(me.defaultworld.defaultmap);
|
me.selectMap(me.defaultworld.defaultmap);
|
||||||
|
|
||||||
|
$.each(me.options.components, function(index, configuration) {
|
||||||
|
me.components.push(componentconstructors[configuration.type](me, configuration));
|
||||||
|
});
|
||||||
|
$.each(me.components, function(index, component) {
|
||||||
|
component.initialize();
|
||||||
|
});
|
||||||
|
|
||||||
setTimeout(function() { me.update(); }, me.options.updaterate);
|
setTimeout(function() { me.update(); }, me.options.updaterate);
|
||||||
},
|
},
|
||||||
selectMap: function(map, completed) {
|
selectMap: function(map, completed) {
|
||||||
@ -302,11 +333,11 @@ DynMap.prototype = {
|
|||||||
me.maptype.updateTileSize(me.map.zoom);
|
me.maptype.updateTileSize(me.map.zoom);
|
||||||
window.setTimeout(function() {
|
window.setTimeout(function() {
|
||||||
me.map.setMapTypeId(map.world.name + '.' + map.name);
|
me.map.setMapTypeId(map.world.name + '.' + map.name);
|
||||||
if (completed) {
|
|
||||||
if (worldChanged) {
|
if (worldChanged) {
|
||||||
$(me).trigger('worldchanged');
|
$(me).trigger('worldchanged');
|
||||||
}
|
}
|
||||||
$(me).trigger('mapchanged');
|
$(me).trigger('mapchanged');
|
||||||
|
if (completed) {
|
||||||
completed();
|
completed();
|
||||||
}
|
}
|
||||||
}, 1);
|
}, 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user