From 458e464f738b033078707ca235e3ad2c20a78e8f Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Wed, 26 Sep 2018 23:39:36 +0800 Subject: [PATCH] editor-tilesets --- _server/data.comment.js | 7 +++++- _server/editor.js | 48 +++++++++++++++++++++++++++++++++++------ _server/editor_mode.js | 8 +++++++ _server/vm.js | 5 +---- editor-mobile.html | 3 +++ editor.html | 3 +++ 6 files changed, 62 insertions(+), 12 deletions(-) diff --git a/_server/data.comment.js b/_server/data.comment.js index 634859e7..3f5089d2 100644 --- a/_server/data.comment.js +++ b/_server/data.comment.js @@ -16,7 +16,12 @@ data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "images": { "_leaf": true, "_type": "textarea", - "_data": "在此存放所有可能使用的图片 \n 图片可以被作为背景图(的一部分),也可以直接用自定义事件进行显示。 \n 图片名不能使用中文,不能带空格或特殊字符;可以直接改名拼音就好 \n 建议对于较大的图片,在网上使用在线的“图片压缩工具(http://compresspng.com/zh/)”来进行压缩,以节省流量 \n 依次向后添加" + "_data": "在此存放所有可能使用的图片(tilesets除外) \n 图片可以被作为背景图(的一部分),也可以直接用自定义事件进行显示。 \n 图片名不能使用中文,不能带空格或特殊字符;可以直接改名拼音就好 \n 建议对于较大的图片,在网上使用在线的“图片压缩工具(http://compresspng.com/zh/)”来进行压缩,以节省流量 \n 依次向后添加" + }, + "tilesets": { + "_leaf": true, + "_type": "textarea", + "_data": "在此存放额外素材的图片名, \n 可以自定导入任意张素材图片,无需PS,无需注册,即可直接在游戏中使用 \n 形式如[\"1.png\", \"2.png\"] ,将需要的素材图片放在images目录下 \n 素材的宽高必须都是32的倍数,且图片上的总图块数不超过1000(即最多有1000个32*32的图块在该图片上)" }, "animates": { "_leaf": true, diff --git a/_server/editor.js b/_server/editor.js index 22a77852..9b1bc7ab 100644 --- a/_server/editor.js +++ b/_server/editor.js @@ -81,7 +81,8 @@ editor.prototype.init = function (callback) { editor.prototype.idsInit = function (maps, icons) { editor.ids = [0]; editor.indexs = []; - var MAX_NUM = 1000; + var MAX_NUM = Math.max.apply(null,Object.keys(maps_90f36752_8815_4be8_b32b_d7fad1d0542e)); + editor.MAX_NUM=MAX_NUM; var getInfoById = function (id) { var block = maps.initBlock(0, 0, id); if (hasOwnProp(block, 'event')) { @@ -89,7 +90,7 @@ editor.prototype.idsInit = function (maps, icons) { } } var point = 0; - for (var i = 0; i < MAX_NUM; i++) { + for (var i = 0; i <= MAX_NUM; i++) { var indexBlock = getInfoById(i); editor.indexs[i] = []; if (indexBlock) { @@ -106,6 +107,21 @@ editor.prototype.idsInit = function (maps, icons) { } } editor.indexs[0] = [0]; + + var startOffset = core.icons.tilesetStartOffset; + for (var i in core.tilesets) { + var imgName = core.tilesets[i]; + var img = core.material.images.tilesets[imgName]; + var width = Math.floor(img.width/32), height = Math.floor(img.height/32); + for (var id=startOffset; id= editor.widthsX[spriter][1] && pos.x < editor.widthsX[spriter][2]) { var ysize = spriter.indexOf('48') === -1 ? 32 : 48; loc.ysize = ysize; - pos.y = ~~(loc.y / loc.ysize); - pos.x = editor.widthsX[spriter][1]; pos.images = editor.widthsX[spriter][0]; + pos.y = ~~(loc.y / loc.ysize); + if(core.tilesets.indexOf(pos.images)==-1)pos.x = editor.widthsX[spriter][1]; var autotiles = core.material.images['autotile']; if (pos.images == 'autotile') { var imNames = Object.keys(autotiles); @@ -773,13 +803,17 @@ editor.prototype.listen = function () { } else { if (hasOwnProp(autotiles, pos.images)) editor.info = {'images': pos.images, 'y': 0}; else if (pos.images == 'terrains') editor.info = {'images': pos.images, 'y': pos.y - 1}; + else if (core.tilesets.indexOf(pos.images)!=-1) editor.info = {'images': pos.images, 'y': pos.y, 'x': pos.x-editor.widthsX[spriter][1]}; else editor.info = {'images': pos.images, 'y': pos.y}; for (var ii = 0; ii < editor.ids.length; ii++) { - if (( editor.info.images == editor.ids[ii].images - && editor.info.y == editor.ids[ii].y ) + if ((core.tilesets.indexOf(pos.images)!=-1 && editor.info.images == editor.ids[ii].images + && editor.info.y == editor.ids[ii].y && editor.info.x == editor.ids[ii].x) || (hasOwnProp(autotiles, pos.images) && editor.info.images == editor.ids[ii].id - && editor.info.y == editor.ids[ii].y)) { + && editor.info.y == editor.ids[ii].y) + || (core.tilesets.indexOf(pos.images)==-1 && editor.info.images == editor.ids[ii].images + && editor.info.y == editor.ids[ii].y ) + ) { editor.info = editor.ids[ii]; break; diff --git a/_server/editor_mode.js b/_server/editor_mode.js index f6649baf..ad0ba74f 100644 --- a/_server/editor_mode.js +++ b/_server/editor_mode.js @@ -320,10 +320,18 @@ editor_mode = function (editor) { if (!core.isset(editor_mode.info.id)) { // document.getElementById('table_a3f03d4c_55b8_4ef6_b362_b345783acd72').innerHTML = ''; document.getElementById('enemyItemTable').style.display = 'none'; + document.getElementById('tilesetsDiv').style.display = 'none'; document.getElementById('newIdIdnum').style.display = 'block'; return; } + if (editor_mode.info.isTile) { + document.getElementById('enemyItemTable').style.display = 'none'; + document.getElementById('tilesetsDiv').style.display = 'block'; + document.getElementById('newIdIdnum').style.display = 'none'; + return; + } document.getElementById('newIdIdnum').style.display = 'none'; + document.getElementById('tilesetsDiv').style.display = 'none'; document.getElementById('enemyItemTable').style.display = 'block'; var objs = []; diff --git a/_server/vm.js b/_server/vm.js index 3ff88ec0..afd49b90 100644 --- a/_server/vm.js +++ b/_server/vm.js @@ -95,10 +95,7 @@ var editArea = new Vue({ var num = mapArray[y][x]; if (num == 0) editor.map[y][x] = 0; - else if (num >= 1000) { - that.error = 3; - editor.map[y][x] = undefined; - } else if (typeof(editor.indexs[num][0]) == 'undefined') { + else if (typeof(editor.indexs[num][0]) == 'undefined') { that.error = 2; editor.map[y][x] = undefined; } else editor.map[y][x] = editor.ids[[editor.indexs[num][0]]]; diff --git a/editor-mobile.html b/editor-mobile.html index 540b256d..5aaa217f 100644 --- a/editor-mobile.html +++ b/editor-mobile.html @@ -92,6 +92,9 @@

图块属性  

+
+

tilesets不允许编辑图块属性

+
diff --git a/editor.html b/editor.html index f70dd9f0..e7b3b937 100644 --- a/editor.html +++ b/editor.html @@ -91,6 +91,9 @@

图块属性  

+
+

tilesets不允许编辑图块属性

+