Added new 'Reload Costs' tab for ammo, digit display cleanup

This commit is contained in:
Kevin Chang
2015-10-05 20:08:36 -07:00
parent 0e8e9f5cbc
commit 34dd40bcbf
14 changed files with 304 additions and 137 deletions

View File

@@ -39,6 +39,8 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
$scope.retroPredicate = 'netCost';
$scope.costDesc = true;
$scope.costPredicate = 'c.cost';
$scope.ammoDesc = false;
$scope.ammoPredicate = 'ammoName';
$scope.costTab = Persist.getCostTab() || 'costs';
if ($scope.savedCode) {
@@ -306,8 +308,13 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
};
$scope.sortRetrofit = function(key) {
$scope.retroDesc = $scope.retroPredicate == key ? !$scope.retroDesc : $scope.retroDesc;
$scope.retroPredicate = key;
$scope.retroDesc = $scope.retroPredicate == key ? !$scope.retroDesc : $scope.retroDesc;
$scope.retroPredicate = key;
};
$scope.sortAmmo = function(key) {
$scope.ammoDesc = $scope.ammoPredicate == key ? !$scope.ammoDesc : $scope.ammoDesc;
$scope.ammoPredicate = key;
};
/**
@@ -404,6 +411,49 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
}
}
$scope.retrofitTotal = total;
updateAmmoCosts();
}
function updateAmmoCosts() {
var costs = $scope.ammoList = [];
var total = 0, i, l, item;
for (var g in { common: 1, internal: 1, hardpoints: 1}) {
var slotGroup = ship[g];
for (i = 0, l = slotGroup.length; i < l; i++) {
var q = 0;
console.log(slotGroup[i]);
if (slotGroup[i].id) {
//special cases needed for fuel, SCB and AFMU since they don't use standard ammo/clip
if (slotGroup[i].c.grp == 'ft') {
q = slotGroup[i].c.capacity;
slotGroup[i].c.ammocost = 50;
}
if (slotGroup[i].c.grp == 'scb') {
q = slotGroup[i].c.cells;
}
if (slotGroup[i].c.grp == 'am') {
q = slotGroup[i].c.ammo;
}
//calculate ammo costs only if a cost is specified
if (slotGroup[i].c.ammocost > 0) {
if (q == 0) {
q = slotGroup[i].c.clip + slotGroup[i].c.ammo;
}
item = {
ammoClassRating: slotGroup[i].c.class + slotGroup[i].c.rating,
ammoName: slotGroup[i].c.name || slotGroup[i].c.grp,
ammoMax: q,
ammoUnitCost: slotGroup[i].c.ammocost,
ammoTotalCost: q * slotGroup[i].c.ammocost
};
costs.push(item);
total += item.ammoTotalCost;
}
}
}
}
$scope.ammoTotal = total;
}
$scope.updateCostTab = function(tab) {

View File

@@ -8,7 +8,7 @@
<div class="l" ng-if="c.c.maxmass">{{'max mass' | translate}}: {{c.c.maxmass}} <u translate="T"></u></div>
<div class="l" ng-if="c.c.bins">{{c.c.bins}} <u translate="bins"></u></div>
<div class="l" ng-if="c.c.rate">{{'rate' | translate}}: {{c.c.rate}} <u>Kg/s</u>&nbsp;&nbsp;&nbsp;{{'refuel time' | translate}}: {{$r.fTime(fuel * 1000 / c.c.rate)}}</div>
<div class="l" ng-if="c.c.ammo">{{'ammo' | translate}}: {{c.c.ammo}}</div>
<div class="l" ng-if="c.c.ammo">{{'ammo' | translate}}: {{$r.fCrd(c.c.ammo)}}</div>
<div class="l" ng-if="c.c.cells">{{'cells' | translate}}: {{c.c.cells}}</div>
<div class="l" ng-if="c.c.recharge">{{'recharge' | translate}}: {{c.c.recharge}} <u>MJ</u>&nbsp;&nbsp;&nbsp;{{'total' | translate}}: {{c.c.cells * c.c.recharge}} <u>MJ</u></div>
<div class="l" ng-if="c.c.repair">{{'repair' | translate}}: {{c.c.repair}}</div>

View File

@@ -74,12 +74,12 @@
</td>
<td>{{fRound(ship.totalDps)}}</td>
<td>
{{ship.armour}}
{{fCrd(ship.armour)}}
<span ng-if="ship.armourAdded || ship.armourMultiplier > 1">
(<span ng-if="ship.armourMultiplier > 1">{{fRPct(ship.armourMultiplier)}}</span><span ng-if="ship.armourAdded && ship.armourMultiplier > 1">&nbsp;</span><span ng-if="ship.armourAdded">+ {{ship.armourAdded}}</span>)
</span>
</td>
<td>{{fRound(ship.shieldStrength)}} <u translate>MJ</u> <span ng-if="ship.shieldMultiplier > 1 && ship.shieldStrength > 0">({{fRPct(ship.shieldMultiplier)}})</span></td>
<td>{{fCrd(ship.shieldStrength)}} <u translate>MJ</u> <span ng-if="ship.shieldMultiplier > 1 && ship.shieldStrength > 0">({{fRPct(ship.shieldMultiplier)}})</span></td>
<td>{{ship.hullMass}} <u translate>T</u></td>
<td>{{fRound(ship.unladenMass)}} <u translate>T</u></td>
<td>{{fRound(ship.ladenMass)}} <u translate>T</u></td>
@@ -273,8 +273,9 @@
<table class="tabs">
<thead>
<tr>
<th style="width:50%" ng-class="{active: costTab == 'retrofit'}" ng-click="updateCostTab('retrofit')" translate="retrofit costs"></th>
<th style="width:50%" ng-class="{active: costTab == 'costs'}" ng-click="updateCostTab('costs')" translate="costs"></th>
<th style="width:34%" ng-class="{active: costTab == 'ammo'}" ng-click="updateCostTab('ammo')" translate="reload costs"></th>
<th style="width:33%" ng-class="{active: costTab == 'retrofit'}" ng-click="updateCostTab('retrofit')" translate="retrofit costs"></th>
<th style="width:33%" ng-class="{active: costTab == 'costs'}" ng-click="updateCostTab('costs')" translate="costs"></th>
</tr>
</thead>
</table>
@@ -354,6 +355,38 @@
</tr>
</table>
</div>
<div ng-if="costTab == 'ammo'">
<div class="scroll-x">
<table style="width:100%">
<thead>
<tr class="main">
<th colspan="2" class="sortable le" ng-click="sortAmmo('ammoName | translate')" translate="component"></th>
<th colspan="1" class="sortable le" ng-click="sortAmmo('ammoMax | translate')" translate="quantity"></th>
<th colspan="1" class="sortable le" ng-click="sortAmmo('ammoUnitCost | translate')" translate="unit cost"></th>
<th class="sortable le" ng-click="sortAmmo('ammoTotalCost')">
{{'total cost' | translate}} <u class="optional-hide" ng-if="discounts.ammo < 1">-[{{fRPct(1 - discounts.ammo)}}]</u>
</th>
</tr>
</thead>
<tbody>
<tr class="highlight" ng-repeat="item in ammoList | orderBy:ammoPredicate:ammoDesc">
<td style="width:1em;">{{item.ammoClassRating}}</td>
<td class="le shorten cap">{{item.ammoName | translate}}</td>
<td class="ri">{{fCrd(item.ammoMax)}}</td>
<td class="ri">{{fCrd(item.ammoUnitCost)}} <u translate>CR</u></td>
<td class="ri">{{fCrd(item.ammoTotalCost)}} <u translate>CR</u></td>
</tr>
</tbody>
</table>
</div>
<table class="total">
<tr class="ri">
<td class="lbl" translate="total"></td>
<td>{{fCrd(ammoTotal)}} <u translate>CR</u></td>
</tr>
</table>
</div>
</div>
<div class="group third">