mirror of
https://github.com/OMGeeky/andors-trail.git
synced 2026-02-23 15:38:29 +01:00
Refactor content editor - Use default values correctly.
This commit is contained in:
@@ -18,6 +18,7 @@ var ATEditor = (function(ATEditor, model, importExport, exampleData) {
|
||||
};
|
||||
$scope.addObj = function(section) {
|
||||
var item = section.addNew();
|
||||
ATEditor.importExport.prepareObjectsForEditor(section, [ item ]);
|
||||
$scope.editObj(section, item);
|
||||
};
|
||||
$scope.clear = function(section) {
|
||||
|
||||
@@ -5,7 +5,6 @@ var ATEditor = (function(ATEditor, _) {
|
||||
nameField: 'name'
|
||||
,idField: 'id'
|
||||
,iconIDField: 'iconID'
|
||||
,newItemTemplate: function() { return {}; }
|
||||
};
|
||||
_.defaults(options, defaultOptions);
|
||||
|
||||
@@ -28,7 +27,9 @@ var ATEditor = (function(ATEditor, _) {
|
||||
return obj[options.nameField];
|
||||
};
|
||||
this.addNew = function() {
|
||||
var obj = options.newItemTemplate();
|
||||
var obj = { };
|
||||
obj[options.idField] = 'new_' + options.id;
|
||||
obj[options.nameField] = 'New ' + options.id;
|
||||
this.ensureUniqueId(obj);
|
||||
items.push(obj);
|
||||
return obj;
|
||||
|
||||
@@ -15,6 +15,7 @@ var ATEditor = (function(ATEditor, _) {
|
||||
,item: {
|
||||
displaytype: 0
|
||||
,hasManualPrice: 0
|
||||
,category: 'other'
|
||||
,equipEffect: { increaseAttackDamage: {}, addedConditions: [] }
|
||||
,useEffect: { increaseCurrentHP: {}, increaseCurrentAP: {}, conditionsSource: [], conditionsTarget: [] }
|
||||
,hitEffect: { increaseCurrentHP: {}, increaseCurrentAP: {}, conditionsSource: [], conditionsTarget: [] }
|
||||
|
||||
@@ -42,7 +42,7 @@ var ATEditor = (function(ATEditor, app, $) {
|
||||
app.directive('ngTileImage', function () {
|
||||
return function(scope, element, attrs) {
|
||||
element.css('display', 'none');
|
||||
scope.$watch(attrs.ngDsFade, function(value) {
|
||||
scope.$watch(attrs.ngTileImage, function(value) {
|
||||
if (value) {
|
||||
element.fadeIn(400);
|
||||
} else {
|
||||
|
||||
@@ -16,24 +16,6 @@
|
||||
<label for="spawnGroup" class="label">Spawngroup:</label>
|
||||
<input class="field" type="text" size="30" id="spawnGroup" ng-model="obj.spawnGroup" class="fieldInput" title="This is a grouping of monster types. Use these tags on spawn areas to spawn random monsters with the same tag. Several monsters may have the same tag." />
|
||||
</div>
|
||||
<div class="fieldWithLabel">
|
||||
<label for="size" class="label">Size:</label>
|
||||
<select class="field" id="size" ng-model="obj.size">
|
||||
<option value="1x1">1x1</option>
|
||||
<option value="1x2">1x2</option>
|
||||
<option value="1x3">1x3</option>
|
||||
<option value="2x1">2x1</option>
|
||||
<option value="2x2">2x2</option>
|
||||
<option value="2x3">2x3</option>
|
||||
<option value="3x1">3x1</option>
|
||||
<option value="3x2">3x2</option>
|
||||
<option value="3x3">3x3</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="fieldWithLabel">
|
||||
<label for="faction" class="label">Faction:</label>
|
||||
<input class="field" type="text" size="30" id="faction" ng-model="obj.faction" class="fieldInput"/>
|
||||
</div>
|
||||
<div class="fieldWithLabel">
|
||||
<div class="label"><input type="checkbox" id="unique" ng-model="obj.isUnique" />Is unique (will not respawn)</div>
|
||||
</div>
|
||||
@@ -51,6 +33,27 @@
|
||||
<option value="8">Ghost</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="fieldWithLabel">
|
||||
<div class="label"><input type="checkbox" id="showAdvanced" ng-model="obj.showAdvanced" />Show advanced properties</div>
|
||||
</div>
|
||||
<div class="fieldWithLabel" ng-ds-fade="obj.showAdvanced">
|
||||
<label for="size" class="label">Size:</label>
|
||||
<select class="field" id="size" ng-model="obj.size">
|
||||
<option value="1x1">1x1</option>
|
||||
<option value="1x2">1x2</option>
|
||||
<option value="1x3">1x3</option>
|
||||
<option value="2x1">2x1</option>
|
||||
<option value="2x2">2x2</option>
|
||||
<option value="2x3">2x3</option>
|
||||
<option value="3x1">3x1</option>
|
||||
<option value="3x2">3x2</option>
|
||||
<option value="3x3">3x3</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="fieldWithLabel" ng-ds-fade="obj.showAdvanced">
|
||||
<label for="faction" class="label">Faction:</label>
|
||||
<input class="field" type="text" size="30" id="faction" ng-model="obj.faction" class="fieldInput"/>
|
||||
</div>
|
||||
<div class="fieldWithLabel">
|
||||
<div class="label"><input type="checkbox" id="hasConversation" ng-model="obj.hasConversation" />Has conversation</div>
|
||||
</div>
|
||||
@@ -106,15 +109,13 @@
|
||||
<div class="fieldWithLabel">
|
||||
<div class="label"><input type="checkbox" id="hasCritical" ng-model="obj.hasCritical" />Has critical chance</div>
|
||||
</div>
|
||||
<div id="hasCriticalDisplay" ng-ds-fade="obj.hasCritical">
|
||||
<div class="fieldWithLabel">
|
||||
<label for="criticalSkill" class="label">Critical skill:</label>
|
||||
<input class="field" type="text" size="5" id="criticalSkill" ng-model="obj.criticalSkill" class="fieldInput integer" />
|
||||
</div>
|
||||
<div class="fieldWithLabel">
|
||||
<label for="criticalMultiplier" class="label">Critical multiplier:</label>
|
||||
<input class="field" type="text" size="5" id="criticalMultiplier" ng-model="obj.criticalMultiplier" class="fieldInput integer" />
|
||||
</div>
|
||||
<div class="fieldWithLabel" ng-ds-fade="obj.hasCritical">
|
||||
<label for="criticalSkill" class="label">Critical skill:</label>
|
||||
<input class="field" type="text" size="5" id="criticalSkill" ng-model="obj.criticalSkill" class="fieldInput integer" />
|
||||
</div>
|
||||
<div class="fieldWithLabel" ng-ds-fade="obj.hasCritical">
|
||||
<label for="criticalMultiplier" class="label">Critical multiplier:</label>
|
||||
<input class="field" type="text" size="5" id="criticalMultiplier" ng-model="obj.criticalMultiplier" class="fieldInput integer" />
|
||||
</div>
|
||||
<div class="fieldWithLabel">
|
||||
<label for="blockChance" class="label">Block chance:</label>
|
||||
@@ -192,7 +193,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<button ng-click="obj.hitEffect.conditionsTarget.push({magnitude:1, duration:1, chance:100})">Add</button>
|
||||
<button ng-click="addCondition(obj.hitEffect.conditionsTarget)">Add</button>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class="endSets"> </div>
|
||||
<div class="endSets"> </div>
|
||||
|
||||
@@ -25,6 +25,7 @@ var ATEditor = (function(ATEditor, _) {
|
||||
o.hasHitEffect = _.toBool(o.hitEffect.increaseCurrentHP.min || o.hitEffect.increaseCurrentAP.min || _.some(o.hitEffect.conditionsSource) || _.some(o.hitEffect.conditionsTarget));
|
||||
o.hasCritical = _.toBool(o.criticalSkill || o.criticalMultiplier);
|
||||
o.hasCombatTraits = _.toBool(o.attackChance || o.attackDamage.min || o.hasCritical || o.blockChance || o.damageResistance || o.hasHitEffect);
|
||||
o.showAdvanced = _.toBool(o.faction || (o.size != '1x1'));
|
||||
};
|
||||
prep.itemcategory = function(o) {
|
||||
};
|
||||
@@ -73,6 +74,7 @@ var ATEditor = (function(ATEditor, _) {
|
||||
delete o.hasUseEffect;
|
||||
delete o.hasHitEffect;
|
||||
delete o.hasKillEffect;
|
||||
delete o.showAdvanced;
|
||||
};
|
||||
unprep.droplist = function(o) {
|
||||
};
|
||||
@@ -160,6 +162,7 @@ var ATEditor = (function(ATEditor, _) {
|
||||
importText: importText
|
||||
,importDataObjects: importDataObjects
|
||||
,exportData: exportData
|
||||
,prepareObjectsForEditor: prepareObjectsForEditor
|
||||
};
|
||||
return ATEditor;
|
||||
})(ATEditor || {}, _);
|
||||
|
||||
@@ -5,41 +5,34 @@ var ATEditor = (function(ATEditor, DataStore, FieldList, _) {
|
||||
name: 'Actor Conditions'
|
||||
,id: 'actorcondition'
|
||||
,iconIDField: 'iconID'
|
||||
,newItemTemplate: function() { return {name: "New Condition", id: 'new_condition' }; }
|
||||
})
|
||||
,quests: new DataStore({
|
||||
name: 'Quests'
|
||||
,id: 'quest'
|
||||
,newItemTemplate: function() { return {name: "New Quest", id: 'new_quest' }; }
|
||||
})
|
||||
,items: new DataStore({
|
||||
name: 'Items'
|
||||
,id: 'item'
|
||||
,iconIDField: 'iconID'
|
||||
,newItemTemplate: function() { return {name: "New Item", id: "new_item", category: 'other' }; }
|
||||
})
|
||||
,droplists: new DataStore({
|
||||
name: 'Droplists'
|
||||
,id: 'droplist'
|
||||
,nameField: 'id'
|
||||
,newItemTemplate: function() { return {id: "new_droplist" }; }
|
||||
})
|
||||
,dialogue: new DataStore({
|
||||
name: 'Dialogue'
|
||||
,id: 'dialogue'
|
||||
,nameField: 'id'
|
||||
,newItemTemplate: function() { return {id: "new_conversation" }; }
|
||||
})
|
||||
,monsters: new DataStore({
|
||||
name: 'Monsters'
|
||||
,id: 'monster'
|
||||
,iconIDField: 'iconID'
|
||||
,newItemTemplate: function() { return {id: "new_monster", name: "New Monster", maxAP: 10, attackCost: 5, moveCost: 5 }; }
|
||||
})
|
||||
,itemCategories: new DataStore({
|
||||
name: 'Item Categories'
|
||||
,id: 'itemcategory'
|
||||
,newItemTemplate: function() { return {id: "new_itemtype", name: 'ItemType' }; }
|
||||
})
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user