mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-10 07:05:35 +00:00
SVG sprites, modals, general improvements
This commit is contained in:
@@ -15,10 +15,20 @@ angular.module('app').controller('ComparisonController', ['$rootScope', '$scope'
|
||||
shipId: shipId,
|
||||
buildName: buildName,
|
||||
ship: ship,
|
||||
code: code
|
||||
code: code,
|
||||
pctRetracted: ship.powerRetracted / ship.powerAvailable,
|
||||
pctDeployed: ship.powerDeployed / ship.powerAvailable,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$scope.predicate = 'ship.name';
|
||||
$scope.desc = false;
|
||||
|
||||
$scope.sort = function (key) {
|
||||
$scope.desc = ($scope.predicate == key)? !$scope.desc : $scope.desc;
|
||||
$scope.predicate = key;
|
||||
}
|
||||
|
||||
|
||||
}]);
|
||||
7
app/js/controllers/controller-delete.js
Normal file
7
app/js/controllers/controller-delete.js
Normal file
@@ -0,0 +1,7 @@
|
||||
angular.module('app').controller('DeleteController', ['$scope', 'Persist', function ($scope, Persist) {
|
||||
$scope.deleteAll = function () {
|
||||
Persist.deleteAll();
|
||||
$scope.$parent.dismiss();
|
||||
};
|
||||
|
||||
}]);
|
||||
@@ -25,7 +25,7 @@ angular.module('app')
|
||||
break;
|
||||
default:
|
||||
$rootScope.bodyClass = 'thargoid'; // TODO: create background imag for this
|
||||
$scope.msgPre = "Uh, this is bad..";
|
||||
$scope.msgPre = "Uh, Jameson, we have a problem..";
|
||||
$scope.errorMessage = $p.message;
|
||||
$scope.details = $p.details;
|
||||
}
|
||||
|
||||
7
app/js/controllers/controller-export.js
Normal file
7
app/js/controllers/controller-export.js
Normal file
@@ -0,0 +1,7 @@
|
||||
angular.module('app').controller('ExportController', ['$scope', 'Persist', function ($scope, Persist) {
|
||||
$scope.builds = {
|
||||
builds: Persist.builds
|
||||
// TODO: add comparisons
|
||||
};
|
||||
|
||||
}]);
|
||||
96
app/js/controllers/controller-import.js
Normal file
96
app/js/controllers/controller-import.js
Normal file
@@ -0,0 +1,96 @@
|
||||
angular.module('app').controller('ImportController', ['$scope', 'ShipsDB', 'Ship', 'Persist', 'Serializer', function ($scope, Ships, Ship, Persist, Serializer) {
|
||||
$scope.jsonValid = false;
|
||||
$scope.importData = null;
|
||||
$scope.errorMsg = null;
|
||||
|
||||
$scope.validateJson = function() {
|
||||
var importObj = null;
|
||||
$scope.jsonValid = false;
|
||||
$scope.errorMsg = null;
|
||||
$scope.builds = null;
|
||||
$scope.ships = Ships;
|
||||
|
||||
if(!$scope.importData) return;
|
||||
|
||||
try {
|
||||
importObj = angular.fromJson($scope.importData);
|
||||
} catch (e) {
|
||||
$scope.errorMsg = 'Cannot Parse JSON!';
|
||||
return;
|
||||
}
|
||||
|
||||
if(typeof importObj != 'object') {
|
||||
$scope.errorMsg = 'Must be an object!';
|
||||
return;
|
||||
}
|
||||
|
||||
if ((!importObj.builds || !Object.keys(importObj.builds).length) && (!importObj.comparisons || !Object.keys(importObj.comparisons).length)) {
|
||||
$scope.errorMsg = 'No builds or comparisons in data';
|
||||
return;
|
||||
}
|
||||
|
||||
for (var shipId in importObj.builds) {
|
||||
var shipData = Ships[shipId];
|
||||
if (shipData) {
|
||||
for (buildName in importObj.builds[shipId]) {
|
||||
if (typeof importObj.builds[shipId][buildName] != 'string') {
|
||||
$scope.errorMsg = shipData.properties.name + ' build "' + buildName + '" must be a string!';
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// Actually build the ship with the code to ensure it's valid
|
||||
Serializer.toShip(new Ship(shipId, shipData.properties, shipData.slots), importObj.builds[shipId][buildName]);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
$scope.errorMsg = shipData.properties.name + ' build "' + buildName + '" is not valid!';
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$scope.errorMsg = '"' + shipId + '" is not a valid Ship Id!';
|
||||
return;
|
||||
}
|
||||
$scope.builds = importObj.builds;
|
||||
}
|
||||
|
||||
// Check for comparison object
|
||||
// if (importObj.comparisons)
|
||||
|
||||
$scope.jsonValid = true;
|
||||
};
|
||||
|
||||
$scope.hasBuild = function (shipId, name) {
|
||||
return Persist.getBuild(shipId, name) != null;
|
||||
}
|
||||
|
||||
$scope.process = function() {
|
||||
var builds = $scope.builds;
|
||||
for (var shipId in builds) {
|
||||
for (var buildName in builds[shipId]) {
|
||||
var code = builds[shipId][buildName];
|
||||
// Update builds object such that orginal name retained, but can be renamed
|
||||
builds[shipId][buildName] = {
|
||||
code: code,
|
||||
useName: buildName
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
$scope.processed = true;
|
||||
};
|
||||
|
||||
$scope.import = function() {
|
||||
var builds = $scope.builds;
|
||||
for (var shipId in builds) {
|
||||
for (var buildName in builds[shipId]) {
|
||||
var build = builds[shipId][buildName];
|
||||
var name = build.useName.trim();
|
||||
if (name) {
|
||||
Persist.saveBuild(shipId, name, build.code);
|
||||
}
|
||||
}
|
||||
}
|
||||
$scope.$parent.dismiss();
|
||||
};
|
||||
|
||||
}]);
|
||||
14
app/js/controllers/controller-modal.js
Normal file
14
app/js/controllers/controller-modal.js
Normal file
@@ -0,0 +1,14 @@
|
||||
angular.module('app').controller('ModalController', ['$rootScope','$scope', '$state', function ($rootScope, $scope, $state) {
|
||||
var dismissListener;
|
||||
$scope.dismiss = function() {
|
||||
if ($rootScope.prevState) {
|
||||
var state = $rootScope.prevState;
|
||||
$state.go(state.name, state.params, {location: 'replace', reload: false});
|
||||
} else {
|
||||
$state.go('shipyard');
|
||||
}
|
||||
}
|
||||
|
||||
$scope.$on('close', $scope.dismiss);
|
||||
|
||||
}]);
|
||||
@@ -135,7 +135,7 @@ angular.module('app').controller('OutfitController', ['$rootScope','$scope', '$s
|
||||
}
|
||||
|
||||
// Event listeners
|
||||
$rootScope.$on('keyup', function (e, keyEvent) {
|
||||
$scope.$on('keyup', function (e, keyEvent) {
|
||||
// CTRL + S or CMD + S will override the default and save the build is possible
|
||||
if (keyEvent.keycode == 83 && keyEvent.ctrlKey) {
|
||||
e.preventDefault();
|
||||
@@ -144,12 +144,12 @@ angular.module('app').controller('OutfitController', ['$rootScope','$scope', '$s
|
||||
});
|
||||
|
||||
// Hide any open menu/slot/etc if escape key is pressed
|
||||
$rootScope.$on('escape', function (e, keyEvent) {
|
||||
$scope.$on('escape', function (e, keyEvent) {
|
||||
$scope.selectedSlot = null;
|
||||
$scope.$apply();
|
||||
});
|
||||
// Hide any open menu/slot/etc if the background is clicked
|
||||
$rootScope.$on('close', function (e, keyEvent) {
|
||||
$scope.$on('close', function (e, keyEvent) {
|
||||
$scope.selectedSlot = null;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user