diff options
Diffstat (limited to 'internal/admin/static/mobeditor.js')
| -rw-r--r-- | internal/admin/static/mobeditor.js | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/internal/admin/static/mobeditor.js b/internal/admin/static/mobeditor.js index a65e578..59eb16c 100644 --- a/internal/admin/static/mobeditor.js +++ b/internal/admin/static/mobeditor.js @@ -90,6 +90,24 @@ var MOB_SECTIONS = [ fields: [] }, { + id: 'shop', label: 'Shop', path: 'shop', + detect: function(d) { return !!d.shop; }, + fields: [ + ['message', 'Greeting', 'text', 'What would you like to buy or sell?'], + ['buy_percentage', 'Buy %', 'number', '40', 'narrow'], + ['change_percentage', 'Change %', 'number', '3', 'narrow'], + ['restock_ticks', 'Restock Ticks', 'number', '', 'narrow'], + ['buys_anything', 'Buys Anything', 'checkbox'], + ], + subtables: [ + {label:'Items', key:'items', addLabel:'+ Add Item', fields:[ + ['item_id', 'Item ID', 'search', '', '', null, 'items'], + ['stock', 'Stock', 'number', '', 'narrow'], + ['restock_ticks', 'Restock Ticks', 'number', '', 'narrow'], + ]} + ] + }, + { id: 'drops', label: 'Drops', path: 'drops', detect: function(d) { return d.drops && (d.drops.remains || (d.drops.loot && d.drops.loot.length > 0)); }, fields: [ @@ -197,7 +215,7 @@ function renderCurrent() { function renderMobCard(sec, data) { var collapsed = expandedCards[sec.id] === false; - var h = '<div class="obj-card" data-card="' + sec.id + '">'; + var h = '<div class="obj-card' + (sec.id === 'talk' ? ' obj-card-full' : '') + '" data-card="' + sec.id + '">'; h += '<div class="obj-card-header" onclick="toggleMobCard(\'' + sec.id + '\')">'; h += '<span class="obj-card-arrow">' + (collapsed ? '▶' : '▼') + '</span>'; h += '<span class="obj-card-label">' + sec.label + '</span>'; @@ -336,7 +354,7 @@ function renderMobSubtable(sec, st, data) { h += '</div>'; }); if (!st.single || arr.length === 0) { - h += '<button class="btn btn-sm obj-sub-add" onclick="addMobSubRow(\'' + sec.id + '\',\'' + st.key + '\')">+ Add Loot</button>'; + h += '<button class="btn btn-sm obj-sub-add" onclick="addMobSubRow(\'' + sec.id + '\',\'' + st.key + '\')">' + esc(st.addLabel || '+ Add') + '</button>'; } h += '</div>'; return h; @@ -374,7 +392,9 @@ function mobAddSection() { if (sec.id === 'drops') { mobData[sec.path] = {remains:'', loot:[]}; } else if (sec.id === 'talk') { - mobData[sec.path] = {nodes:{start:{message:'',options:[]}}}; + mobData[sec.path] = {nodes:{start:{messages:[],options:[]}}}; + } else if (sec.id === 'shop') { + mobData[sec.path] = {buy_percentage:40, change_percentage:3, buys_anything:true, items:[]}; } else { mobData[sec.path] = {}; } @@ -467,7 +487,11 @@ function saveMob() { API.put('/api/mobs/' + encodeURIComponent(mobID), out).then(function(resp) { notify('Mob ' + mobID + ' saved', 'success'); updateUndoBar(); - if (resp && resp._raw) mobData._raw = resp._raw; + if (resp && resp._raw) { + mobData._raw = resp._raw; + var pre = document.querySelector('#tabYaml pre'); + if (pre) pre.textContent = mobData._raw; + } }).catch(function(e) { notify('Save failed: ' + e.message, 'error'); }); } |
