From 4a50bf4039e970395957f09c51073f022c26175f Mon Sep 17 00:00:00 2001 From: Misode Date: Thu, 3 Oct 2019 13:22:21 +0200 Subject: [PATCH] Add location position --- index.html | 4 ++-- locales/en.json | 10 ++++++---- locales/ru.json | 10 ++++++---- locales/zh-CN.json | 10 ++++++---- model.js | 7 ++++++- schemas/1.14.json | 24 ++++++++++++++++++++++++ 6 files changed, 50 insertions(+), 15 deletions(-) diff --git a/index.html b/index.html index decb7c33..f521b2d0 100644 --- a/index.html +++ b/index.html @@ -137,9 +137,9 @@ - + - +
diff --git a/locales/en.json b/locales/en.json index 4cebadc6..2f2901a3 100644 --- a/locales/en.json +++ b/locales/en.json @@ -241,6 +241,11 @@ }, "$location": { "position": "Position", + "$position": { + "x": "X", + "y": "Y", + "z": "Z" + }, "biome": "Biome", "feature": "Feature", "dimension": "Dimension" @@ -291,8 +296,5 @@ "tabs": "Tabs", "title": "Loot Table Generator", "true": "True", - "unset": "Unset", - "x": "X", - "y": "Y", - "z": "Z" + "unset": "Unset" } diff --git a/locales/ru.json b/locales/ru.json index eaf91b73..5addb7f4 100644 --- a/locales/ru.json +++ b/locales/ru.json @@ -238,6 +238,11 @@ }, "$location": { "position": "Позиция", + "$position": { + "x": "X", + "y": "Y", + "z": "Z" + }, "biome": "Биом", "feature": "Строение", "dimension": "Измерение" @@ -282,8 +287,5 @@ "tabs": "Табуляция", "title": "Генератор таблицы добычи", "true": "Да", - "unset": "Не задано", - "x": "X", - "y": "Y", - "z": "Z" + "unset": "Не задано" } diff --git a/locales/zh-CN.json b/locales/zh-CN.json index 80787a12..966ed72b 100644 --- a/locales/zh-CN.json +++ b/locales/zh-CN.json @@ -237,6 +237,11 @@ }, "$location": { "position": "位置", + "$position": { + "x": "X 坐标", + "y": "Y 坐标", + "z": "Z 坐标" + }, "biome": "生物群系", "feature": "结构", "dimension": "维度" @@ -281,8 +286,5 @@ "tabs": "Tab 缩进", "title": "战利品表生成器", "true": "是", - "unset": "未指定", - "x": "X 坐标", - "y": "Y 坐标", - "z": "Z 坐标" + "unset": "未指定" } diff --git a/model.js b/model.js index 15d2d60e..14c20ade 100644 --- a/model.js +++ b/model.js @@ -275,6 +275,7 @@ function toggleCollapseObject(el) { function updateField(el) { let path = getPath(el); + console.log(path); let $field = $(el).closest('[data-index]'); let field = path.pop(); let node = getNode(path); @@ -330,7 +331,10 @@ function updateField(el) { if (value.length === 0) { value = ''; } - } else if (type === 'range' || type === 'random') { + } else if (type === 'range' || type === 'random' || type === 'boundary') { + if (type === 'boundary' && node[field] === undefined) { + node[field] = {}; + } value = getRangeValue($field, node[field]); } else if (type === 'checkbox') { value = $(el).prop('checked'); @@ -361,6 +365,7 @@ function updateRangeType(el) { } function getRangeValue($field, data) { + console.log($field, data); if (typeof data === 'object') { if (data.type && data.type.match(/(minecraft:)?binomial/)) { let n = $field.find('.binomial.n').val(); diff --git a/schemas/1.14.json b/schemas/1.14.json index 8a6ec707..36fd7b12 100644 --- a/schemas/1.14.json +++ b/schemas/1.14.json @@ -711,6 +711,30 @@ "type": "object", "color": "dark", "fields": [ + { + "id": "position", + "type": "object", + "translate": "$location.position", + "color": "dark", + "collapse": true, + "fields": [ + { + "id": "x", + "type": "boundary", + "translate": "$location.$position.x" + }, + { + "id": "y", + "type": "boundary", + "translate": "$location.$position.y" + }, + { + "id": "z", + "type": "boundary", + "translate": "$location.$position.z" + } + ] + }, { "id": "biome", "type": "enum",