#49 WIP "user interaction" dialog
This commit is contained in:
@@ -2742,19 +2742,6 @@ define([
|
||||
}
|
||||
var defaultSystemStatus = Init.systemStatus[ tempKeys[0] ].id;
|
||||
|
||||
// dialog data -------------------------------------------------------------------------------------------------
|
||||
var data = {
|
||||
id: config.systemDialogId,
|
||||
selectClass: config.systemDialogSelectClass
|
||||
};
|
||||
|
||||
// current character log data ----------------------------------------------------------------------------------
|
||||
var currentCharacterLog = Util.getCurrentCharacterLog();
|
||||
|
||||
if(currentCharacterLog !== false){
|
||||
// set current position as "default" system to add
|
||||
data.currentSystem = currentCharacterLog.system;
|
||||
}
|
||||
|
||||
// get current map data -> disable systems that are already on it ----------------------------------------------
|
||||
var mapData = mapContainer.getMapDataFromClient({forceData: true});
|
||||
@@ -2764,6 +2751,25 @@ define([
|
||||
mapSystemIds.push( mapSystems[i].systemId );
|
||||
}
|
||||
|
||||
// dialog data -------------------------------------------------------------------------------------------------
|
||||
var data = {
|
||||
id: config.systemDialogId,
|
||||
selectClass: config.systemDialogSelectClass
|
||||
};
|
||||
|
||||
// set current position as "default" system to add -------------------------------------------------------------
|
||||
var currentCharacterLog = Util.getCurrentCharacterLog();
|
||||
|
||||
if(
|
||||
currentCharacterLog !== false &&
|
||||
mapSystemIds.indexOf( currentCharacterLog.system.id ) === -1
|
||||
){
|
||||
// current system is NOT already on this map
|
||||
// set current position as "default" system to add
|
||||
data.currentSystem = currentCharacterLog.system;
|
||||
}
|
||||
|
||||
|
||||
requirejs(['text!templates/dialog/system.html', 'mustache'], function(template, Mustache) {
|
||||
|
||||
var content = Mustache.render(template, data);
|
||||
|
||||
@@ -224,16 +224,26 @@ define([
|
||||
$(document).triggerMenuEvent('ShowSettingsDialog');
|
||||
}
|
||||
|
||||
// store current map user data (cache)
|
||||
if(data.mapUserData !== undefined){
|
||||
Util.setCurrentMapUserData(data.mapUserData);
|
||||
}
|
||||
|
||||
// start log
|
||||
Util.timeStart(logKeyClientUserData);
|
||||
|
||||
// active character data found
|
||||
mapModule.updateMapModuleData(data);
|
||||
mapModule.updateMapModuleData();
|
||||
|
||||
// log client user data update time
|
||||
duration = Util.timeStop(logKeyClientUserData);
|
||||
Util.log(logKeyClientUserData, {duration: duration, type: 'client', description:'update users'});
|
||||
|
||||
// update system info panels
|
||||
if(data.system){
|
||||
mapModule.updateSystemModuleData(data.system);
|
||||
}
|
||||
|
||||
// get the current update delay (this can change if a user is inactive)
|
||||
var mapUserUpdateDelay = Util.getCurrentTriggerDelay( logKeyServerUserData, 0 );
|
||||
|
||||
|
||||
@@ -192,11 +192,9 @@ define([
|
||||
|
||||
/**
|
||||
* updates only visible/active map module
|
||||
* @param userData
|
||||
* @returns {boolean}
|
||||
*/
|
||||
|
||||
$.fn.updateMapModuleData = function(mapModuleData){
|
||||
$.fn.updateMapModuleData = function(){
|
||||
var mapModule = $(this);
|
||||
|
||||
// get all active map elements for module
|
||||
@@ -205,47 +203,37 @@ define([
|
||||
if(mapElement !== false){
|
||||
var mapId = mapElement.data('id');
|
||||
|
||||
// get user data for each active map
|
||||
var mapUserData = null;
|
||||
|
||||
if(mapModuleData.mapUserData){
|
||||
for(var j = 0; j < mapModuleData.mapUserData.length; j++){
|
||||
|
||||
var tempMapUserData = mapModuleData.mapUserData[j];
|
||||
if(tempMapUserData.config.id === mapId){
|
||||
// map userData found
|
||||
mapUserData = tempMapUserData;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var currentMapUserData = Util.getCurrentMapUserData(mapId);
|
||||
|
||||
// update map with current user data
|
||||
if(mapUserData){
|
||||
mapElement.updateUserData(mapUserData);
|
||||
if(currentMapUserData){
|
||||
mapElement.updateUserData(currentMapUserData);
|
||||
}
|
||||
|
||||
// check if current open system is still the requested info system
|
||||
var currentSystemData = Util.getCurrentSystemData();
|
||||
|
||||
if(
|
||||
currentSystemData &&
|
||||
mapModuleData.system
|
||||
){
|
||||
if(mapModuleData.system.id === currentSystemData.systemData.id){
|
||||
// trigger system update event
|
||||
$(document).trigger('pf:updateSystemModules', [mapModuleData.system]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* update system info panels (below map)
|
||||
* @param systemData
|
||||
*/
|
||||
$.fn.updateSystemModuleData = function(systemData){
|
||||
var mapModule = $(this);
|
||||
|
||||
if(systemData){
|
||||
// check if current open system is still the requested info system
|
||||
var currentSystemData = Util.getCurrentSystemData();
|
||||
|
||||
if(currentSystemData){
|
||||
if(systemData.id === currentSystemData.systemData.id){
|
||||
// trigger system update event
|
||||
$(document).trigger('pf:updateSystemModules', [systemData]);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* load all structure elements into a TabsContent div (tab body)
|
||||
*/
|
||||
|
||||
@@ -1317,6 +1317,48 @@ define([
|
||||
return areaId;
|
||||
};
|
||||
|
||||
/**
|
||||
* set currentMapUserData as "global" variable (count of active pilots)
|
||||
* this function should be called continuously after data change
|
||||
* to keep the data always up2data
|
||||
* @param currentMapUserData
|
||||
*/
|
||||
var setCurrentMapUserData = function(mapUserData){
|
||||
Init.currentMapUserData = mapUserData;
|
||||
|
||||
return getCurrentMapUserData();
|
||||
};
|
||||
|
||||
/**
|
||||
* get currentMapUserData from "global" variable for specific map or all maps
|
||||
* @param mapId
|
||||
* @returns {boolean}
|
||||
*/
|
||||
var getCurrentMapUserData = function(mapId){
|
||||
|
||||
var currentMapUserData = false;
|
||||
|
||||
if( mapId === parseInt(mapId, 10) ){
|
||||
// search for a specific map
|
||||
for(var i = 0; i < Init.currentMapUserData.length; i++){
|
||||
if(Init.currentMapUserData[i].config.id === mapId){
|
||||
currentMapUserData = Init.currentMapUserData[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
// get data for all maps
|
||||
currentMapUserData = Init.currentMapUserData;
|
||||
}
|
||||
|
||||
if(currentMapUserData !== false){
|
||||
// return a fresh (deep) copy of that, in case of further modifications
|
||||
currentMapUserData = $.extend(true, {}, currentMapUserData);
|
||||
}
|
||||
|
||||
return currentMapUserData;
|
||||
};
|
||||
|
||||
/**
|
||||
* set currentMapData as "global" variable
|
||||
* this function should be called continuously after data change
|
||||
@@ -1570,6 +1612,8 @@ define([
|
||||
getAllSignatureNames: getAllSignatureNames,
|
||||
getSignatureTypeIdByName: getSignatureTypeIdByName,
|
||||
getAreaIdBySecurity: getAreaIdBySecurity,
|
||||
setCurrentMapUserData: setCurrentMapUserData,
|
||||
getCurrentMapUserData: getCurrentMapUserData,
|
||||
setCurrentMapData: setCurrentMapData,
|
||||
getCurrentMapData: getCurrentMapData,
|
||||
setCurrentUserData: setCurrentUserData,
|
||||
|
||||
Reference in New Issue
Block a user