mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-25 08:06:51 +00:00
Merge branch 'master' of https://github.com/misode/loot-table into dev/help-tooltips
This commit is contained in:
10
index.html
10
index.html
@@ -11,13 +11,13 @@
|
||||
</script>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<title data-i18n="title"></title>
|
||||
<title data-i18n="title.loot-table"></title>
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="custom.css">
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-expand-md navbar-dark bg-dark">
|
||||
<span class="navbar-brand mb-0 h1" data-i18n="description"></span>
|
||||
<span id="descriptionSpan" class="navbar-brand mb-0 h1" data-i18n="description.loot-table"></span>
|
||||
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
@@ -43,8 +43,8 @@
|
||||
</nav>
|
||||
<div class="container d-none">
|
||||
<div class="row my-4">
|
||||
<div class="col-12 col-lg-7 mb-3 structure-container" data-index="table">
|
||||
<div class="input-group">
|
||||
<div class="col-12 col-lg-7 mb-3 structure-container" data-index="root">
|
||||
<div id="lootTableToolbar" class="input-group d-none mb-3">
|
||||
<button type="button" class="btn btn-success d-block mr-3 float-left" onclick="addComponent(this, 'pools')" data-field="table" data-i18n="pool_add"></button>
|
||||
<div class="input-group-prepend table-type">
|
||||
<span class="input-group-text rounded-left" data-i18n="table.type"></span>
|
||||
@@ -58,7 +58,7 @@
|
||||
<button type="button" class="btn btn-secondary" onclick="showSource()" data-i18n="show_source"></button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="structure" class="loot-table mt-3" data-index="pools">
|
||||
<div id="structure" class="loot-table" data-index="root">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-lg-5 source-container">
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
"condition.thundering": "Thundering",
|
||||
"condition.type": "Condition",
|
||||
"condition.type.alternative": "Alternative",
|
||||
"condition.type.block_state_propery": "Block Properties",
|
||||
"condition.type.block_state_property": "Block Properties",
|
||||
"condition.type.damage_source_properties": "Damage Source",
|
||||
"condition.type.entity_properties": "Entity Properties",
|
||||
"condition.type.entity_scores": "Entity Scores",
|
||||
@@ -75,7 +75,8 @@
|
||||
"damage_source.is_magic": "Magic",
|
||||
"damage_source.is_projectile": "Projectile",
|
||||
"damage_source.source_entity": "Source Entity",
|
||||
"description": "Loot Table Generator for Minecraft",
|
||||
"description.loot-table": "Loot Table Generator for Minecraft",
|
||||
"description.predicate": "Predicate Generator for Minecraft",
|
||||
"dimension.overworld": "Overworld",
|
||||
"dimension.the_end": "The End",
|
||||
"dimension.the_nether": "The Nether",
|
||||
@@ -300,7 +301,8 @@
|
||||
"tabs": "Tabs",
|
||||
"term_add": "Add Term",
|
||||
"term_remove": "Remove Term",
|
||||
"title": "Loot Table Generator",
|
||||
"title.loot-table": "Loot Table Generator",
|
||||
"title.predicate": "Predicate Generator",
|
||||
"true": "True",
|
||||
"unset": "Unset"
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
"condition.thundering": "Гроза",
|
||||
"condition.type": "Условие",
|
||||
"condition.type.alternative": "Выбор",
|
||||
"condition.type.block_state_propery": "Свойства блока",
|
||||
"condition.type.block_state_property": "Свойства блока",
|
||||
"condition.type.damage_source_properties": "Источник урона",
|
||||
"condition.type.entity_properties": "Свойства сущности",
|
||||
"condition.type.entity_scores": "Счёты сущности",
|
||||
@@ -82,7 +82,7 @@
|
||||
"damage_source.is_magic": "Магия",
|
||||
"damage_source.is_projectile": "Снаряд",
|
||||
"damage_source.source_entity": "Сущность-источник урона",
|
||||
"description": "Генератор таблицы добычи для Minecraft",
|
||||
"description.loot-table": "Генератор таблицы добычи для Minecraft",
|
||||
"dimension.overworld": "Обычный мир",
|
||||
"dimension.the_end": "Энд",
|
||||
"dimension.the_nether": "Незер",
|
||||
@@ -298,7 +298,7 @@
|
||||
"tabs": "Табуляция",
|
||||
"term_add": "Добавить выражение",
|
||||
"term_remove": "Удалить выражение",
|
||||
"title": "Генератор таблицы добычи",
|
||||
"title.loot-table": "Генератор таблицы добычи",
|
||||
"true": "Да",
|
||||
"unset": "Не задано"
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
"condition.thundering": "雷雨",
|
||||
"condition.type": "条件",
|
||||
"condition.type.alternative": "析取范式",
|
||||
"condition.type.block_state_propery": "方块属性",
|
||||
"condition.type.block_state_property": "方块属性",
|
||||
"condition.type.damage_source_properties": "伤害源",
|
||||
"condition.type.entity_properties": "实体属性",
|
||||
"condition.type.entity_scores": "实体分数",
|
||||
@@ -82,7 +82,7 @@
|
||||
"damage_source.is_magic": "魔法",
|
||||
"damage_source.is_projectile": "弹射物",
|
||||
"damage_source.source_entity": "根本来源实体",
|
||||
"description": "Minecraft 战利品表生成器",
|
||||
"description.loot-table": "Minecraft 战利品表生成器",
|
||||
"dimension.overworld": "主世界",
|
||||
"dimension.the_end": "末路之地",
|
||||
"dimension.the_nether": "下界",
|
||||
@@ -299,7 +299,7 @@
|
||||
"tabs": "Tab 缩进",
|
||||
"term_add": "添加条件",
|
||||
"term_remove": "移除条件",
|
||||
"title": "战利品表生成器",
|
||||
"title.loot-table": "战利品表生成器",
|
||||
"true": "是",
|
||||
"unset": "未指定"
|
||||
}
|
||||
|
||||
2
model.js
2
model.js
@@ -148,7 +148,7 @@ function copySource(el) {
|
||||
function getPath(el) {
|
||||
let $node = $(el).closest('[data-index]');
|
||||
let index = $node.attr('data-index');
|
||||
if (index === 'table') return [];
|
||||
if (index === 'root') return [];
|
||||
let parent = getPath($node.parent());
|
||||
parent = parent.concat(index.split('.'));
|
||||
return parent;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"root": {
|
||||
"id": "loot-table",
|
||||
"fields": [
|
||||
{
|
||||
"id": "pools",
|
||||
@@ -71,12 +72,12 @@
|
||||
},
|
||||
{
|
||||
"id": "weight",
|
||||
"type": "range",
|
||||
"type": "int",
|
||||
"translate": "entry.weight"
|
||||
},
|
||||
{
|
||||
"id": "quality",
|
||||
"type": "range",
|
||||
"type": "int",
|
||||
"translate": "entry.quality",
|
||||
"luckBased": true
|
||||
},
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"root": {
|
||||
"id": "loot-table",
|
||||
"fields": [
|
||||
{
|
||||
"id": "type",
|
||||
@@ -101,12 +102,12 @@
|
||||
},
|
||||
{
|
||||
"id": "weight",
|
||||
"type": "random",
|
||||
"type": "int",
|
||||
"translate": "entry.weight"
|
||||
},
|
||||
{
|
||||
"id": "quality",
|
||||
"type": "random",
|
||||
"type": "int",
|
||||
"translate": "entry.quality",
|
||||
"luckBased": true
|
||||
},
|
||||
@@ -486,7 +487,7 @@
|
||||
"minecraft:inverted",
|
||||
"minecraft:entity_properties",
|
||||
{
|
||||
"value": "minecraft:block_state_propery",
|
||||
"value": "minecraft:block_state_property",
|
||||
"require": ["minecraft:block"]
|
||||
},
|
||||
{
|
||||
@@ -508,7 +509,7 @@
|
||||
},
|
||||
"minecraft:killed_by_player",
|
||||
{
|
||||
"value": "survives_explosion",
|
||||
"value": "minecraft:survives_explosion",
|
||||
"require": ["minecraft:block"]
|
||||
}
|
||||
]
|
||||
@@ -594,7 +595,7 @@
|
||||
"type": "string",
|
||||
"translate": "condition.block",
|
||||
"require": [
|
||||
"minecraft:block_state_propery"
|
||||
"minecraft:block_state_property"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -605,7 +606,7 @@
|
||||
"type": "string"
|
||||
},
|
||||
"require": [
|
||||
"minecraft:block_state_propery"
|
||||
"minecraft:block_state_property"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,29 +1,41 @@
|
||||
{
|
||||
"root": {
|
||||
"fields": [
|
||||
{
|
||||
"id": "type",
|
||||
"type": "enum",
|
||||
"translate": "table.type",
|
||||
"translateValue": "table.type",
|
||||
"default": "minecraft:generic",
|
||||
"values": [
|
||||
"minecraft:empty",
|
||||
"minecraft:entity",
|
||||
"minecraft:block",
|
||||
"minecraft:chest",
|
||||
"minecraft:fishing",
|
||||
"minecraft:generic"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "pools",
|
||||
"type": "array",
|
||||
"translate": "pool",
|
||||
"values": "pool"
|
||||
}
|
||||
]
|
||||
},
|
||||
"roots": [
|
||||
{
|
||||
"id": "loot-table",
|
||||
"title": "title.loot-table",
|
||||
"description": "description.loot-table",
|
||||
"fields": [
|
||||
{
|
||||
"id": "type",
|
||||
"type": "enum",
|
||||
"translate": "table.type",
|
||||
"translateValue": "table.type",
|
||||
"default": "minecraft:generic",
|
||||
"values": [
|
||||
"minecraft:empty",
|
||||
"minecraft:entity",
|
||||
"minecraft:block",
|
||||
"minecraft:chest",
|
||||
"minecraft:fishing",
|
||||
"minecraft:generic"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "pools",
|
||||
"type": "array",
|
||||
"translate": "pool",
|
||||
"values": "pool"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "predicate",
|
||||
"title": "title.predicate",
|
||||
"description": "description.predicate",
|
||||
"type": "object",
|
||||
"value": "condition"
|
||||
}
|
||||
],
|
||||
"components": [
|
||||
{
|
||||
"id": "pool",
|
||||
@@ -100,12 +112,12 @@
|
||||
},
|
||||
{
|
||||
"id": "weight",
|
||||
"type": "random",
|
||||
"type": "int",
|
||||
"translate": "entry.weight"
|
||||
},
|
||||
{
|
||||
"id": "quality",
|
||||
"type": "random",
|
||||
"type": "int",
|
||||
"translate": "entry.quality",
|
||||
"luckBased": true
|
||||
},
|
||||
@@ -502,7 +514,7 @@
|
||||
"minecraft:reference",
|
||||
"minecraft:entity_properties",
|
||||
{
|
||||
"value": "minecraft:block_state_propery",
|
||||
"value": "minecraft:block_state_property",
|
||||
"require": ["minecraft:block"]
|
||||
},
|
||||
{
|
||||
@@ -524,7 +536,7 @@
|
||||
},
|
||||
"minecraft:killed_by_player",
|
||||
{
|
||||
"value": "survives_explosion",
|
||||
"value": "minecraft:survives_explosion",
|
||||
"require": ["minecraft:block"]
|
||||
}
|
||||
]
|
||||
@@ -618,7 +630,7 @@
|
||||
"type": "string",
|
||||
"translate": "condition.block",
|
||||
"require": [
|
||||
"minecraft:block_state_propery"
|
||||
"minecraft:block_state_property"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -629,7 +641,7 @@
|
||||
"type": "string"
|
||||
},
|
||||
"require": [
|
||||
"minecraft:block_state_propery"
|
||||
"minecraft:block_state_property"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
32
view.js
32
view.js
@@ -9,10 +9,16 @@ i18next.on('initialized', () => {
|
||||
});
|
||||
});
|
||||
|
||||
changeVersion('1.14');
|
||||
changeVersion('1.15');
|
||||
function changeVersion(version) {
|
||||
$.getJSON('schemas/' + version + '.json', json => {
|
||||
structure = json.root;
|
||||
console.log(json);
|
||||
if (json.root) {
|
||||
structure = json.root;
|
||||
} else if (json.roots) {
|
||||
let id = window.location.pathname.replace(/\/$/, '').replace(/^\//, '');
|
||||
structure = json.roots.find(e => e.id === id);
|
||||
}
|
||||
components = json.components;
|
||||
collections = json.collections;
|
||||
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||
@@ -35,19 +41,31 @@ function changeVersion(version) {
|
||||
|
||||
function updateView() {
|
||||
if (structure) {
|
||||
let {out: tableOut, component: $table} = generateTable(table, structure);
|
||||
$('#structure').append($table);
|
||||
let {out: sourceOut, component: $component} = generateSourceAndView(table, structure);
|
||||
$('#structure').removeClass('d-none').html('');
|
||||
$('#descriptionSpan').attr('data-i18n', structure.description);
|
||||
$('title').attr('data-i18n', structure.title);
|
||||
$('#structure').append($component);
|
||||
if (i18next.isInitialized) {
|
||||
$('html').localize();
|
||||
}
|
||||
$('#source').val(JSON.stringify(tableOut, null, indentation));
|
||||
$('#source').val(JSON.stringify(sourceOut, null, indentation));
|
||||
}
|
||||
}
|
||||
|
||||
function generateSourceAndView(data, struct) {
|
||||
if (struct.id === 'loot-table') {
|
||||
$('#lootTableToolbar').removeClass('d-none');
|
||||
$('#structure').attr('data-index', 'pools');
|
||||
return generateTable(data, struct);
|
||||
} else {
|
||||
return generateObject(data, struct, false);
|
||||
}
|
||||
}
|
||||
|
||||
function generateTable(data, struct) {
|
||||
let out = {};
|
||||
let $el = $('<div/>');
|
||||
$('#structure').removeClass('d-none').html('');
|
||||
|
||||
let type = struct.fields.find(e => e.id === 'type');
|
||||
if (type) {
|
||||
@@ -192,7 +210,7 @@ function generateEnum(data, struct) {
|
||||
}
|
||||
for (let value of collection) {
|
||||
if (typeof value === 'object') {
|
||||
if (value.require.includes(correctNamespace(table.type))) {
|
||||
if (structure.id === 'predicate' || value.require.includes(correctNamespace(table.type))) {
|
||||
$el.find('select').append(setValueAndName($('<option/>'), value.value, struct.translateValue));
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user