Add version selection

This commit is contained in:
Misode
2019-09-12 19:27:03 +02:00
parent 9fb7f21311
commit 86d5dab3f1
8 changed files with 199 additions and 14 deletions

View File

@@ -10,12 +10,21 @@
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<span class="navbar-brand mb-0 h1" data-i18n="description"></span>
<ul class="navbar-nav">
<li class="nav-item dropdown">
<a id="versionLabel" class="nav-link dropdown-toggle" href="" role="button" data-toggle="dropdown"></a>
<div id="versionList" class="dropdown-menu">
<a class="dropdown-item" onclick="changeVersion('1.13')">1.13</a>
<a class="dropdown-item" onclick="changeVersion('1.14')">1.14</a>
</div>
</li>
</ul>
<ul class="navbar-nav mr-auto">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="" id="navbarDropdownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<a class="nav-link dropdown-toggle" href="" role="button" data-toggle="dropdown">
Language
</a>
<div id="lngList" class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink"></div>
<div id="lngList" class="dropdown-menu"></div>
</li>
</ul>
<span class="float-right"><a href="https://github.com/misode/loot-table" style="color: #ddd;" data-i18n="author"></a></span>

View File

@@ -244,7 +244,7 @@
"condition": "Condition",
"copy": "Copy",
"count": "Count",
"description": "Loot Table Generator for Minecraft 1.14",
"description": "Loot Table Generator for Minecraft",
"dimension": "Dimension",
"direct_entity": "Direct Entity",
"durability": "Durability",

View File

@@ -244,7 +244,7 @@
"condition": "Условие",
"copy": "Скопировать",
"count": "Количество",
"description": "Генератор таблицы добычи для Minecraft 1.14",
"description": "Генератор таблицы добычи для Minecraft",
"dimension": "Измерение",
"direct_entity": "Сущность-причина урона",
"durability": "Прочность",

View File

@@ -244,7 +244,7 @@
"condition": "条件",
"copy": "复制",
"count": "数量",
"description": "适用于 Minecraft 1.14 的战利品表生成器",
"description": "适用于 Minecraft 的战利品表生成器",
"dimension": "维度",
"direct_entity": "直接来源实体",
"durability": "耐久度",

View File

@@ -236,7 +236,6 @@ function updateRangeType(el) {
let $field = $(el).closest('[data-field]');
let field = $field.attr('data-field');
let type = $(el).attr('value');
console.log('update range type!!', type, field);
if (type === 'range') {
setField(getParent(el), field, {});
} else if (type === 'binomial') {
@@ -248,9 +247,7 @@ function updateRangeType(el) {
}
function getRangeValue($field, data) {
console.log(data);
if (typeof data === 'object') {
console.log('object');
if (data.type && data.type.match(/(minecraft:)?binomial/)) {
let n = $field.find('.binomial.n').val();
let p = $field.find('.binomial.p').val();
@@ -267,7 +264,6 @@ function getRangeValue($field, data) {
else delete data.max;
}
} else {
console.log('else');
data = parseFloat($field.find('.exact').val());
if (isNaN(data)) {
data = '';

176
schemas/1.13.json Normal file
View File

@@ -0,0 +1,176 @@
{
"root": {
"fields": [
{
"id": "pools",
"type": "array",
"values": "pool"
}
]
},
"components": [
{
"id": "pool",
"type": "object",
"color": "success",
"default": {
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:stone"
}
]
},
"fields": [
{
"id": "rolls",
"type": "range",
"default": 1
},
{
"id": "bonus_rolls",
"type": "range",
"default": 1,
"luck_based": true
},
{
"id": "entries",
"type": "array",
"values": "entry",
"button": "header"
},
{
"id": "conditions",
"type": "array",
"values": "condition",
"button": "header"
}
]
},
{
"id": "entry",
"type": "object",
"color": "light",
"default": {
"type": "minecraft:item",
"name": "minecraft:stone"
},
"fields": [
{
"id": "type",
"type": "enum",
"source": "entry",
"values": [
"minecraft:empty",
"minecraft:item",
"minecraft:loot_table"
],
"default": "minecraft:item"
},
{
"id": "name",
"type": "string",
"default": "minecraft:stone",
"require": [
"minecraft:item",
"minecraft:loot_table"
]
},
{
"id": "functions",
"type": "array",
"values": "function",
"button": "header"
},
{
"id": "conditions",
"type": "array",
"values": "condition",
"button": "header"
}
]
},
{
"id": "function",
"type": "object",
"color": "secondary",
"default": {
"function": "minecraft:set_count",
"count": 2
},
"fields": [
{
"id": "function",
"type": "enum",
"source": "function",
"values": [
"minecraft:set_count",
"minecraft:set_data",
"minecraft:set_damage",
"minecraft:set_nbt",
"minecraft:set_attributes",
"minecraft:enchant_randomly",
"minecraft:enchant_with_levels",
"minecraft:looting_enchant",
"minecraft:furnace_smelt"
],
"default": "set_count"
},
{
"id": "count",
"type": "range",
"require": [
"minecraft:set_count"
]
},
{
"id": "data",
"type": "range",
"require": [
"minecraft:set_data"
]
},
{
"id": "damage",
"type": "range",
"require": [
"minecraft:set_damage"
]
},
{
"id": "tag",
"type": "string",
"require": [
"minecraft:set_nbt"
]
},
{
"id": "levels",
"type": "range",
"require": [
"minecraft:enchant_with_levels"
]
},
{
"id": "conditions",
"type": "array",
"values": "condition",
"button": "header"
}
]
},
{
"id": "condition",
"type": "object",
"color": "info",
"default": {
"condition": "minecraft:random_chance",
"chance": 0.5
},
"fields": [
]
}
]
}

14
view.js
View File

@@ -1,11 +1,15 @@
let structure;
let components;
$.getJSON('structure.json', json => {
structure = json.root;
components = json.components;
invalidated();
});
changeVersion('1.14');
function changeVersion(version) {
$.getJSON('schemas/' + version + '.json', json => {
$('#versionLabel').text(version);
structure = json.root;
components = json.components;
invalidated();
});
}
function invalidated() {
if (structure) {