From e6b4cb9f5816c6ee239233bc85f74ee446a161c2 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Wed, 1 Jul 2026 16:37:45 -0400 Subject: feat: shop system overhauled, gui conversation tree editor overhauled --- internal/admin/static/mobeditor.js | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'internal/admin/static/mobeditor.js') 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 @@ -89,6 +89,24 @@ var MOB_SECTIONS = [ detect: function(d) { return d.talk && d.talk.nodes; }, 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)); }, @@ -197,7 +215,7 @@ function renderCurrent() { function renderMobCard(sec, data) { var collapsed = expandedCards[sec.id] === false; - var h = '
'; + var h = '
'; h += '
'; h += '' + (collapsed ? '▶' : '▼') + ''; h += '' + sec.label + ''; @@ -336,7 +354,7 @@ function renderMobSubtable(sec, st, data) { h += '
'; }); if (!st.single || arr.length === 0) { - h += ''; + h += ''; } h += '
'; 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'); }); } -- cgit v1.2.3