mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-10 07:05:35 +00:00
Bug fixes, component ordering
This commit is contained in:
@@ -5,12 +5,12 @@ angular.module('app').directive('componentSelect', function() {
|
||||
function appendGroup(list, opts, cid, mass) {
|
||||
var prevClass = null, prevRating = null;
|
||||
var count = Object.keys(opts).length;
|
||||
for (id in opts) {
|
||||
var o = opts[id];
|
||||
for (var i = 0; i < opts.length; i++) {
|
||||
var o = opts[i];
|
||||
list.push('<li class="', o.name? 'lc' : 'c');
|
||||
if(o.class != prevClass && count > 6) list.push(' cl');
|
||||
if (cid == id) list.push(' active');
|
||||
list.push((o.maxmass && mass > o.maxmass)? ' disabled"' : '" cpid="', id, '">', o.class, o.rating);
|
||||
if (cid == o.id) list.push(' active');
|
||||
list.push((o.maxmass && mass > o.maxmass)? ' disabled"' : '" cpid="', o.id, '">', o.class, o.rating);
|
||||
if(o.mode) {
|
||||
list.push('/' + o.mode);
|
||||
if(o.missile) {
|
||||
|
||||
@@ -36,7 +36,7 @@ angular.module('shipyard').factory('ComponentSet', ['lodash', function (_) {
|
||||
var o = this.hpClass[c] = {};
|
||||
for(var key in this.hardpoints) {
|
||||
var data = filter(this.hardpoints[key], c, c? 1 : 0, this.mass);
|
||||
if(Object.keys(data).length) { // If group is not empty
|
||||
if(data.length) { // If group is not empty
|
||||
o[key] = data;
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,7 @@ angular.module('shipyard').factory('ComponentSet', ['lodash', function (_) {
|
||||
var o = this.intClass[c] = {};
|
||||
for(var key in this.internal) {
|
||||
var data = filter(this.internal[key], c, 0, this.mass);
|
||||
if(Object.keys(data).length) { // If group is not empty
|
||||
if(data.length) { // If group is not empty
|
||||
o[key] = data;
|
||||
}
|
||||
}
|
||||
@@ -58,13 +58,9 @@ angular.module('shipyard').factory('ComponentSet', ['lodash', function (_) {
|
||||
};
|
||||
|
||||
function filter (data, maxClass, minClass, mass) {
|
||||
var set = {};
|
||||
_.forEach(data, function (c,id) {
|
||||
if (c.class <= maxClass && c.class >= minClass && (c.maxmass === undefined || mass <= c.maxmass) ) {
|
||||
set[id] = c;
|
||||
}
|
||||
return _.filter(data, function (c) {
|
||||
return c.class <= maxClass && c.class >= minClass && (c.maxmass === undefined || mass <= c.maxmass)
|
||||
});
|
||||
return set;
|
||||
}
|
||||
|
||||
return ComponentSet;
|
||||
|
||||
@@ -10,17 +10,27 @@ angular.module('shipyard').service('Components', ['lodash', 'ComponentSet', func
|
||||
};
|
||||
|
||||
this.hardpoints = function(id) {
|
||||
var c = _.find(C.hardpoints, function(o) {
|
||||
return o[id];
|
||||
})
|
||||
return c[id];
|
||||
for (var n in C.hardpoints) {
|
||||
var group = C.hardpoints[n];
|
||||
for (var i = 0; i < group.length; i++) {
|
||||
if (group[i].id == id) {
|
||||
return group[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
this.internal = function(id) {
|
||||
var c = _.find(C.internal, function(o) {
|
||||
return o[id];
|
||||
})
|
||||
return c[id];
|
||||
for (var n in C.internal) {
|
||||
var group = C.internal[n];
|
||||
for (var i = 0; i < group.length; i++) {
|
||||
if (group[i].id == id) {
|
||||
return group[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
this.bulkheads = function(shipId, bulkheadsId) {
|
||||
|
||||
Reference in New Issue
Block a user