From 1d712006df9cfb3ccbc734fd03b6b1d1b946a9af Mon Sep 17 00:00:00 2001 From: Oskar Wiksten Date: Tue, 29 Jan 2013 08:16:14 +0100 Subject: [PATCH] Refactor content editor - Use default values correctly. --- AndorsTrailEdit/controllers.js | 1 + AndorsTrailEdit/datastore.js | 5 +-- AndorsTrailEdit/defaults.js | 1 + AndorsTrailEdit/directives.js | 2 +- AndorsTrailEdit/edit_monster.html | 59 ++++++++++++++++--------------- AndorsTrailEdit/importexport.js | 3 ++ AndorsTrailEdit/model.js | 7 ---- 7 files changed, 39 insertions(+), 39 deletions(-) diff --git a/AndorsTrailEdit/controllers.js b/AndorsTrailEdit/controllers.js index 83e3b1f42..6e509bd9c 100644 --- a/AndorsTrailEdit/controllers.js +++ b/AndorsTrailEdit/controllers.js @@ -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) { diff --git a/AndorsTrailEdit/datastore.js b/AndorsTrailEdit/datastore.js index 55856da83..e8aad827c 100644 --- a/AndorsTrailEdit/datastore.js +++ b/AndorsTrailEdit/datastore.js @@ -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; diff --git a/AndorsTrailEdit/defaults.js b/AndorsTrailEdit/defaults.js index a3477dad6..b0b7f99f3 100644 --- a/AndorsTrailEdit/defaults.js +++ b/AndorsTrailEdit/defaults.js @@ -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: [] } diff --git a/AndorsTrailEdit/directives.js b/AndorsTrailEdit/directives.js index ae9fe47f7..b609d5356 100644 --- a/AndorsTrailEdit/directives.js +++ b/AndorsTrailEdit/directives.js @@ -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 { diff --git a/AndorsTrailEdit/edit_monster.html b/AndorsTrailEdit/edit_monster.html index 7b762ac16..ab44b507e 100644 --- a/AndorsTrailEdit/edit_monster.html +++ b/AndorsTrailEdit/edit_monster.html @@ -16,24 +16,6 @@ -
- - -
-
- - -
Is unique (will not respawn)
@@ -51,6 +33,27 @@ +
+
Show advanced properties
+
+
+ + +
+
+ + +
Has conversation
@@ -106,15 +109,13 @@
Has critical chance
-
-
- - -
-
- - -
+
+ + +
+
+ +
@@ -192,7 +193,7 @@ - +
-
\ No newline at end of file +
diff --git a/AndorsTrailEdit/importexport.js b/AndorsTrailEdit/importexport.js index 8eada04dd..ad5d64d44 100644 --- a/AndorsTrailEdit/importexport.js +++ b/AndorsTrailEdit/importexport.js @@ -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 || {}, _); diff --git a/AndorsTrailEdit/model.js b/AndorsTrailEdit/model.js index 2675ec757..13009665d 100644 --- a/AndorsTrailEdit/model.js +++ b/AndorsTrailEdit/model.js @@ -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' }; } }) };