]> www.infradead.org Git - users/mchehab/andors-trail.git/commitdiff
Updated content editor so that it may use the new item categories. The categories...
authorOskar Wiksten <oskar.wiksten@gmail.com>
Sat, 9 Jun 2012 14:23:36 +0000 (16:23 +0200)
committerOskar Wiksten <oskar.wiksten@gmail.com>
Sun, 7 Oct 2012 14:10:39 +0000 (16:10 +0200)
AndorsTrailEdit/AndorsTrailEditor.js
AndorsTrailEdit/Editor_Item.js
AndorsTrailEdit/editor.html
AndorsTrailEdit/translations.html

index 3a146810e449ff963d35ee489bfc858e2242402e..858ab9dd07388f5db2ca3b5d076c44157d62555e 100644 (file)
@@ -29,6 +29,16 @@ var equipConditionsDialog;
 var droplistItemDialog;
 var phraseRewardDialog;
 
+function loadResourceFile(filename, onSuccess) {
+       var url = document.location.href;
+       url = url.substring(0, url.lastIndexOf('/'));
+       url = url.substring(0, url.lastIndexOf('/'));
+       url += "/AndorsTrail/res/" + filename;
+       //var url = "http://andors-trail.googlecode.com/git/AndorsTrail/res/" + filename;
+       $.get(url, function(data) {
+               onSuccess(data);
+       }, 'text');
+}
 
 function openTabForObject(obj, dataStore) {
        tabs.openTabForObject(obj, dataStore.objectTypename, obj[dataStore.nameField]);
@@ -95,8 +105,8 @@ function addExampleModelItems(model) {
 
        model.quests.add({id: "testQuest", name: "Test quest", stages: [ { progress: 10, logText: "Stage 10"} , { progress: 20, logText: "Stage 20", finishesQuest: 1 } ] });
 
-       model.items.add({id: "item0", iconID: "items_weapons:0", name: "Test item", category: 0, baseMarketCost: 51, hasEquipEffect: 1, equip_attackChance: 10, equip_attackDamage_Min: 2, equip_attackDamage_Max: 4, equip_attackCost: 4});
-       model.items.add({id: "dmg_ring1", iconID: "items_jewelry:0", name: "Ring of damage +1", category: 7, baseMarketCost: 62, hasEquipEffect: 1, equip_attackDamage_Min: 1, equip_attackDamage_Max: 1});
+       model.items.add({id: "item0", iconID: "items_weapons:0", name: "Longsword", category: 'lsword', baseMarketCost: 51, hasEquipEffect: 1, equip_attackChance: 10, equip_attackDamage_Min: 2, equip_attackDamage_Max: 4, equip_attackCost: 4});
+       model.items.add({id: "dmg_ring1", iconID: "items_jewelry:0", name: "Ring of damage +1", category: 'ring', baseMarketCost: 62, hasEquipEffect: 1, equip_attackDamage_Min: 1, equip_attackDamage_Max: 1});
 
        model.droplists.add({id: "merchant1", items: [ { itemID: 'dmg_ring1', quantity_Min: 4, quantity_Max: 5, chance: 100 } , { itemID: 'item0', quantity_Min: 1, quantity_Max: 1, chance: 100 } ] } );
 
@@ -165,10 +175,16 @@ function startEditor() {
                        ,nameField: 'name'
                        ,iconField: 'iconID'
                })
+               ,itemCategories: new DataStore({
+                       objectTypename: 'itemcategory'
+                       ,fieldList: new FieldList("[id|name|actionType|inventorySlot|size|];")
+                       ,idField: 'id'
+                       ,nameField: 'name'
+               })
        };
        
        addExampleModelItems(model);
-
+       
        
        
        
@@ -232,6 +248,7 @@ function startEditor() {
        
        tabs = new EditorTabs( $( "#center #tabs" ) );
        
+       
        bindEditorType(model.actorConditions, $( "#tools #actorconditionlist" ), createActorConditionEditor, function() {
                return {name: "New Condition", id: 'new_condition' };
        });
@@ -239,7 +256,7 @@ function startEditor() {
                return {name: "New Quest", id: 'new_quest' };
        });
        bindEditorType(model.items, $( "#tools #itemlist" ), createItemEditor, function() {
-               return {name: "New Item", id: "new_item", category: 31 };
+               return {name: "New Item", id: "new_item", category: 'other' };
        });
        bindEditorType(model.droplists, $( "#tools #droplist" ), createDroplistEditor, function() {
                return {id: "new_droplist" };
@@ -307,5 +324,16 @@ function startEditor() {
                        width: 350,
                        buttons: defaultButtons
                });
+       
+       loadResourceFile( 'values/content_itemcategories.xml', function(data) {
+               var allContent = '';
+               $( data ).find("string").each(function() {
+                       allContent = allContent + $(this).text();
+               });
+               model.itemCategories.deserialize(allContent);
+               model.itemCategories.items.forEach(function(c) {
+                       $("#editItem select#category").append( $("<option>").val(c.id).text(c.name) );
+               });
+       });
 }
 
index 9d60f9099e0aba8e1c2366b223772841427e4138..62289089159c410e5ea320dc8c7050e2a2debff1 100644 (file)
@@ -63,10 +63,13 @@ function createItemEditor(obj) {
        
        
        var itemCostDependsOn = [];
-       var v = function(s) { 
+       var sv = function(s) { 
                var field = $( s, div );
                itemCostDependsOn.push(field);
-               var val = field.val();
+               return field.val();
+       }
+       var v = function(s) { 
+               var val = sv(s);
                if (!val) return 0;
                return parseInt(val);
        }
@@ -81,7 +84,7 @@ function createItemEditor(obj) {
                var costBoostHP = Math.round(0.1*sgn(averageHPBoost)*Math.pow(Math.abs(averageHPBoost), 2) + 3*averageHPBoost);
                var itemUsageCost = costBoostHP;
                
-               var isWeapon = v("#category") == 0;
+               var isWeapon = model.itemCategories.findById(sv("#category")).inventorySlot == 0;
                
                var equip_blockChance = v("#equip_blockChance");
                var equip_attackChance = v("#equip_attackChance");
index 478821a41329f89898dac71b0d0ce5db83d7c95a..4903dbf196eaba217d9d5870cd56df0d77392e23 100644 (file)
                        <div class="fieldWithLabel">\r
                                <label for="category" class="label">Category:</label>\r
                                <select class="field" id="category">\r
-                                       <option value="0">Weapon</option>\r
-                                       <option value="1">Shield</option>\r
-                                       <option value="2">Wearable (head)</option>\r
-                                       <option value="3">Wearable (body)</option>\r
-                                       <option value="4">Wearable (hand)</option>\r
-                                       <option value="5">Wearable (feet)</option>\r
-                                       <option value="6">Wearable (neck)</option>\r
-                                       <option value="7">Wearable (ring)</option>\r
-                                       <option value="20">Potion</option>\r
-                                       <option value="21">Food</option>\r
-                                       <option value="30">Money</option>\r
-                                       <option value="31">Other</option>\r
                                </select>\r
                        </div>\r
                        <div class="fieldWithLabel">\r
index 135a982f6647bd24ad3a5e06ab5bbe2026359ea6..3c1c9d0b8deeee0fc3920d82da939da4576b3b77 100644 (file)
@@ -19,7 +19,7 @@
        <div class="andorsTrailLogo" id="title">\r
                Andor's Trail Translation validator\r
                <span id="version">\r
-                       v0.6.10dev1\r
+                       v0.6.11dev1\r
                </span>\r
        </div>\r
 </div>\r