Skip to content

Commit

Permalink
Component checking
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanBluth committed Mar 14, 2016
1 parent 5dfe58e commit dfb2f97
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 5 deletions.
59 changes: 54 additions & 5 deletions static/js/scenarioEditor/assetView/assetView.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ angular.module('scenarioEditor.assetView', ['ngRoute', 'scenarioServices'])

$scope.joints = {};

$scope.pendingComponentErrors = [];

var dropzonesProcessed = 0;


Expand Down Expand Up @@ -162,7 +164,7 @@ angular.module('scenarioEditor.assetView', ['ngRoute', 'scenarioServices'])
$scope.$emit('showMessage', ['Invalid asset mode - ' + $scope.mode, 'danger']);
}
});

// END EDIT VIEW

$scope.componentTypes = [{
Expand Down Expand Up @@ -269,8 +271,14 @@ angular.module('scenarioEditor.assetView', ['ngRoute', 'scenarioServices'])
errors.push('Name is required');
valid = false;
}

for(var i = 0; i < $scope.pendingComponentErrors.length; i++){
errors.push($scope.pendingComponentErrors[i]);
}

$scope.pendingComponentErrors = [];

if (valid) {
if (errors.length == 0) {
// Tell the app controller to block the ui
switch ($scope.selectedAsset.id) {
case $scope.CONST.ASSET_TYPES.CHARACTER_COMPONENT :
Expand Down Expand Up @@ -612,7 +620,8 @@ angular.module('scenarioEditor.assetView', ['ngRoute', 'scenarioServices'])
components: "=",
componentType: "=",
componentScale: "=",
joints: "="
joints: "=",
pendingErrors: "="
},

transclude: true,
Expand Down Expand Up @@ -924,8 +933,48 @@ angular.module('scenarioEditor.assetView', ['ngRoute', 'scenarioServices'])
};
break;
}



$scope.pendingErrors = [];

var compLeft = null;
var compLeftVal = "";

for(var i = 0; i < outJoints.length; i++){
var comp = outJoints[i].item(1);
if(comp.getText().indexOf('Left') != -1){
var st = comp.getText().split("-")[1];
st = st.trim();
st = st.split(" ")[1];
compLeft = outJoints[i];
compLeftVal = st;
}
}

var compRight = null;
for(var i = 0; i < outJoints.length; i++){
var comp = outJoints[i].item(1);
if(comp.getText().indexOf('Right') != -1 && comp.getText().indexOf(compLeftVal) != -1){
compRight = outJoints[i];
}
}

if(compLeft != null && compRight != null){
if(compLeft.left > compRight.left){
$scope.pendingErrors.push("Left joint is to the right of right joint");
}
}

for(var i = 0; i < outJoints.length; i++){
if(outJoints.top == 50){
$scope.pendingErrors.push("Not all joints have been set");
break;
}
}

if(inJointGroup.top == 50){
$scope.pendingErrors.push("Not all joints have been set");
}

$scope.joints = converted;

// Since we're in a watch we need to run an apply
Expand Down
1 change: 1 addition & 0 deletions templates/scenarioEditor/assetView/assetView.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ <h1>Assets</h1>
<span>Component Scale : </span>
<input type="number" ng-model="componentScale" step="0.1" min=0.1/>
<component-builder class="padded-top-bottom-10" joints="joints" components="componentImages"
pending-errors="pendingComponentErrors"
component-type="selectedComponentType"
component-scale="componentScale"></component-builder>
</div>
Expand Down

0 comments on commit dfb2f97

Please sign in to comment.