Merge remote-tracking branch 'refs/remotes/ckcz123/v2.x' into v2.x

This commit is contained in:
YouWei Zhao 2019-08-22 13:26:03 +08:00
commit 83d9779269
115 changed files with 4592 additions and 995 deletions

View File

@ -1,4 +1,4 @@
附录API列表V2.6版)
附录API列表V2.6.3版)
这里将列出所有被转发到core的API没有被转发的函数此处不会列出请自行在代码中查看。
@ -56,7 +56,6 @@ core.platform.isPC (是否是电脑端)
core.platform.isAndroid (是否是安卓端)
core.platform.isIOS 是否是iOS端
core.platform.useLocalForage (是否开启了新版存档)
core.platform.extendKeyBoard (是否开启了拓展键盘)
core.domStyle
@ -1742,7 +1741,7 @@ id可选为同时绘制的图标ID如果不为null则会同时绘制该图
core.drawText(content, callback)
绘制一段文字。contents为一个字符串或一个字符串数组callback为全部绘制完毕的回调。
支持所有的文字效果(如\n${}\r\\i等也支持\t和\b的语法。
支持所有的文字效果(如\n${}\r\\i\\c\\d\\e等),也支持\t和\b的语法。
如果当前在事件处理中或录像回放中则会自动转成core.insertAction处理。
不建议使用该函数如有绘制文字的需求请尽量使用core.insertAction()插入剧情文本事件。
@ -1767,7 +1766,7 @@ posInfo如果不为null则是一个含position, px和py的对象表示一个
core.drawTextContent(ctx, content, config)
根据配置在某个画布上绘制一段文字。此函数会被core.drawTextBox()所调用。
ctx为画布名或画布本身如果不设置则会忽略该函数。
content为要绘制的文字内容支持所有的文字效果如\n${}\r\\i等但不支持支持\t和\b的语法。
content为要绘制的文字内容支持所有的文字效果如\n${}\r\\i\\c\\d\\e等),但不支持支持\t和\b的语法。
config为绘制的配置项目前可以包括如下几项
- left, top在该画布上绘制的左上角像素位置不设置默认为(0,0)。
> 该函数绘制时会将textBaseline设置为'top',因此只需要考虑第一个字的左上角位置。
@ -1782,7 +1781,7 @@ config为绘制的配置项目前可以包括如下几项
core.drawTextBox(content, showAll)
绘制一个对话框。content为一个字符串或一个字符串数组。
支持所有的文字效果(如\n${}\r\\i等也支持\t和\b的语法。
支持所有的文字效果(如\n${}\r\\i\\c\\d\\e等),也支持\t和\b的语法。
该函数将使用用户在剧情文本设置中的配置项进行绘制。
实际执行时会计算文本框宽度并绘制背景绘制标题和头像再调用core.drawTextContent()绘制正文内容。
showAll可选如果为true则不会使用打字机效果而全部显示主要用于打字机效果的点击显示全部。
@ -1790,7 +1789,7 @@ showAll可选如果为true则不会使用打字机效果而全部显示
core.drawScrollText(content, time, lineHeight, callback)
绘制一个滚动字幕。content为绘制内容time为总时间默认为5000lineHeight为行距比例默认为1.4)。
滚动字幕将绘制在UI上支持所有的文字效果如\n${}\r\\i等但不支持\t和\b效果。
滚动字幕将绘制在UI上支持所有的文字效果如\n${}\r\\i\\c\\d\\e等),但不支持\t和\b效果。
可以通过剧情文本设置中的align控制是否居中绘制offset控制其距离左边的偏移量。
@ -1802,7 +1801,7 @@ core.textImage(content, lineHeight)
core.drawChoices(content, choices)
绘制一个选项框。
content可选为选项上方的提示文字支持所有的文字效果如\n${}\r\\i等也支持\t效果。
content可选为选项上方的提示文字支持所有的文字效果如\n${}\r\\i\\c\\d\\e等),也支持\t效果。
choices必选为要绘制的选项内容是一个列表。其中的每一项
- 可以是一个字符串,表示选项文字,将使用剧情文本设置中的正文颜色来绘制,仅支持${}表达式计算。
- 或者是一个包含text, color和icon的对象。
@ -1872,8 +1871,11 @@ core.ui.relocateCanvas(name, x, y)
重新定位一个自定义画布。x和y为画布的左上角坐标。
core.ui.resizeCanvas(name, width, height)
重新设置一个自定义画布的大小。width和height为新设置的宽高。此操作会清空画布。
core.ui.resizeCanvas(name, width, height, styleOnly)
重新设置一个自定义画布的大小。width和height为新设置的宽高。
styleOnly控制是否只修改画布的显示大小而不修改画布的内部大小
如果styleOnly为true则只修改其显示大小即canvas.style.width
否则,则会同时修改画布的显示大小和内部大小并清空画布内容。
core.ui.deleteCanvas(name)

View File

@ -55,6 +55,39 @@ HTML5 canvas制作的魔塔样板支持全平台游戏
## 更新说明
### 2019.7.24 V2.6.3
* [x] 标题界面大幅美化,增加闪烁光标,支持键盘开始游戏
* [x] 事件编辑器支持自动补全能对flag和API列表等进行补全
* [x] 剧情文本中\\c修改字体大小\\d和\\e切换粗体和斜体
* [x] 事件:设置视角&移动视角
* [x] 可以指定显示选择项的出现条件并动态生成
* [x] 楼层传送器的平面传送模式(哪里离开飞回到哪里)
* [x] UI绘制事件增添绘制圆和绘制圆边框
* [x] 所有的UI绘制事件均可以双击预览
* [x] 播放BGM事件可以一直持续播放直到下次调用
* [x] \f立绘支持alpha值
* [x] 支持在脚本编辑中直接flags.xxx调用自定义变量
* [x] 首次获得道具将给予提示
* [x] 等待用户操作支持滚轮视为PgUp和PgDn
* [x] 脚本编辑器语法错误将禁止保存
* [x] 录像播放时B键查看数据统计
* [x] 所有已知bug的修复大量细节优化
### 2019.6.7 V2.6.2
* [x] 可以拖动地图上的图块和事件,复制剪切和跨楼层粘贴
* [x] 新增事件的地图选点功能,可以在地图上选择落点
* [x] 现在素材区可以进行折叠与自动换列了
* [x] 新增UI绘制系列事件并且可以进行预览
* [x] 显示文本事件的标题解析
* [x] 新增常用工具:额外素材合并工具
* [x] 进一步提升24倍速的播放速度
* [x] 楼层转换增加对称点
* [x] 增加编辑器快捷键说明H键查看
* [x] 文档-事件增加事件编辑器截图
* [x] 大量细节优化所有已知的Bug修复
### 2019.5.2 V2.6.1
* [x] 区域优化的录像播放功能R键使用

View File

@ -1,6 +1,6 @@
# V2.0版本介绍
?> 目前版本**v2.6.1**,上次更新时间:* {docsify-updated} *
?> 目前版本**v2.6.3*,上次更新时间:* {docsify-updated} *
目前样板已经更新到V2.0版本以上本章将对V2.0的一些内容进行介绍。

View File

@ -1,6 +1,6 @@
# 附录API列表
?> 目前版本**v2.6.1**,上次更新时间:* {docsify-updated} *
?> 目前版本**v2.6.3**,上次更新时间:* {docsify-updated} *
这里将列出所有被转发到core的API没有被转发的函数此处不会列出请自行在代码中查看。
@ -57,7 +57,6 @@ core.platform.isPC (是否是电脑端)
core.platform.isAndroid (是否是安卓端)
core.platform.isIOS 是否是iOS端
core.platform.useLocalForage (是否开启了新版存档)
core.platform.extendKeyBoard (是否开启了拓展键盘)
core.domStyle
@ -952,10 +951,11 @@ core.startEvents(list, x, y, callback)
此函数将调用core.setEvents然后停止勇士再执行core.doAction()。
core.doAction()
core.doAction(keepUI)
执行下一个自定义事件。
此函数将检测事件列表是否全部执行完毕,如果是则执行回调函数。
否则将从事件列表中弹出下一个事件并调用core.doEvent进行执行。
如果keepUI为true则不会清掉UI层和selector适合于自己用脚本的绘制。
core.insertAction(action, x, y, callback, addToLast)
@ -1615,9 +1615,10 @@ core.clearMap(name)
该函数的name也可以是'all',若为'all'则为清空所有系统画布。
core.fillText(name, text, x, y, style, font)
core.fillText(name, text, x, y, style, font, maxWidth)
在某个画布上绘制一段文字。
text为要绘制的文本x,y为要绘制的坐标style可选为绘制的样式font可选为绘制的字体。下同
如果maxWidth不为null则视为文字最大宽度如果超过此宽度则会自动放缩文字直到自适应为止。
请注意textAlign和textBaseline将决定绘制的左右对齐和上下对齐方式。
具体可详见core.setTextAlign()和core.setTextBaseline()函数。
@ -1693,6 +1694,13 @@ core.drawImage(name, image, x, y, w, h, x1, y1, w1, h1)
http://www.w3school.com.cn/html5/canvas_drawimage.asp
这里的image允许传一个图片画布。也允许传递图片名将从你导入的图片中获取图片内容。
core.drawIcon(name, id, x, y, w, h)
在一张画布上绘制一个图标。
id为注册过的图标ID也可以使用状态栏的图标ID例如lv, hp, up, save, settings等。
x和y为绘制的左上角坐标w和h可选为绘制的宽高如果不填或null则使用该图标的默认宽高。
// ------ 具体的某个UI界面的绘制 ------ //
core.closePanel()
结束一切事件和UI绘制关闭UI窗口返回游戏。
@ -1712,7 +1720,7 @@ id可选为同时绘制的图标ID如果不为null则会同时绘制该图
core.drawText(content, callback)
绘制一段文字。contents为一个字符串或一个字符串数组callback为全部绘制完毕的回调。
支持所有的文字效果(如\n${}\r\\i等也支持\t和\b的语法。
支持所有的文字效果(如\n${}\r\\i\\c\\d\\e等),也支持\t和\b的语法。
如果当前在事件处理中或录像回放中则会自动转成core.insertAction处理。
不建议使用该函数如有绘制文字的需求请尽量使用core.insertAction()插入剧情文本事件。
@ -1737,7 +1745,8 @@ posInfo如果不为null则是一个含position, px和py的对象表示一个
core.drawTextContent(ctx, content, config)
根据配置在某个画布上绘制一段文字。此函数会被core.drawTextBox()所调用。
ctx为画布名或画布本身如果不设置则会忽略该函数。
content为要绘制的文字内容支持所有的文字效果如\n${}\r\\i等但不支持支持\t和\b的语法。
content为要绘制的文字内容支持所有的文字效果如\n${}\r\\i\\c\\d\\e等
,但不支持支持\t和\b的语法。
config为绘制的配置项目前可以包括如下几项
- left, top在该画布上绘制的左上角像素位置不设置默认为(0,0)。
> 该函数绘制时会将textBaseline设置为'top',因此只需要考虑第一个字的左上角位置。
@ -1746,13 +1755,13 @@ config为绘制的配置项目前可以包括如下几项
- bold是否粗体。如果不设置默认为false。
- align文字对齐方式仅在maxWidth设置时有效默认为'left'。
- fontSize字体大小如果不设置则使用剧情文本设置中的正文字体大小。
- lineHeight绘制的行距值如果不设置则使用fontSize*1.3即1.3行距)。
- lineHeight绘制的行距值如果不设置则使用fontSize*1.3即1.3行距)。
- time打字机效果。若不为0则会逐个字进行绘制并设置core.status.event.interval定时器。
core.drawTextBox(content, showAll)
绘制一个对话框。content为一个字符串或一个字符串数组。
支持所有的文字效果(如\n${}\r\\i等也支持\t和\b的语法。
支持所有的文字效果(如\n${}\r\\i\\c\\d\\e等),也支持\t和\b的语法。
该函数将使用用户在剧情文本设置中的配置项进行绘制。
实际执行时会计算文本框宽度并绘制背景绘制标题和头像再调用core.drawTextContent()绘制正文内容。
showAll可选如果为true则不会使用打字机效果而全部显示主要用于打字机效果的点击显示全部。
@ -1760,7 +1769,7 @@ showAll可选如果为true则不会使用打字机效果而全部显示
core.drawScrollText(content, time, lineHeight, callback)
绘制一个滚动字幕。content为绘制内容time为总时间默认为5000lineHeight为行距比例默认为1.4)。
滚动字幕将绘制在UI上支持所有的文字效果如\n${}\r\\i等但不支持\t和\b效果。
滚动字幕将绘制在UI上支持所有的文字效果如\n${}\r\\i\\c\\d\\e等),但不支持\t和\b效果。
可以通过剧情文本设置中的align控制是否居中绘制offset控制其距离左边的偏移量。
@ -1772,7 +1781,7 @@ core.textImage(content, lineHeight)
core.drawChoices(content, choices)
绘制一个选项框。
content可选为选项上方的提示文字支持所有的文字效果如\n${}\r\\i等也支持\t效果
content可选为选项上方的提示文字支持所有的文字效果如\n${}\r\\i\\c\\d\\e等),也支持\t。
choices必选为要绘制的选项内容是一个列表。其中的每一项
- 可以是一个字符串,表示选项文字,将使用剧情文本设置中的正文颜色来绘制,仅支持${}表达式计算。
- 或者是一个包含text, color和icon的对象。
@ -1842,8 +1851,11 @@ core.ui.relocateCanvas(name, x, y)
重新定位一个自定义画布。x和y为画布的左上角坐标。
core.ui.resizeCanvas(name, width, height)
重新设置一个自定义画布的大小。width和height为新设置的宽高。此操作会清空画布。
core.ui.resizeCanvas(name, width, height, styleOnly)
重新设置一个自定义画布的大小。width和height为新设置的宽高。
styleOnly控制是否只修改画布的显示大小而不修改画布的内部大小
如果styleOnly为true则只修改其显示大小即canvas.style.width
否则,则会同时修改画布的显示大小和内部大小并清空画布内容。
core.ui.deleteCanvas(name)

View File

@ -1,6 +1,6 @@
# 元件说明
?> 目前版本**v2.6.1**,上次更新时间:* {docsify-updated} *
?> 目前版本**v2.6.3**,上次更新时间:* {docsify-updated} *
在本章中,将对样板里的各个元件进行说明。各个元件主要包括道具、门、怪物、楼梯等等。
@ -282,10 +282,13 @@ floorId指定的是目标楼层的唯一标识符ID
- 使用`${}`来计算一个表达式的值,如`${status:atk+status:def}`。
- 使用`\f[...]`来同时插入一张立绘图,如`\f[1.png,100,200]`。
- 使用`\\i[...]`来在对话框中绘制一个图标,如`\\i[fly]`。
- 使用`\\c[...]`来修改字体大小,如`\\b[16]`。
- 使用`\\d`来加粗或者取消粗体。
- 使用`\\e`来加斜体或取消斜体。
从V2.5.2开始,也允许绘制一张头像图在对话框中,只要通过`\t[1.png]`或`\t[标题,1.png]`的写法。
**使用`\\i[...]`绘制图标请注意:在事件块中,允许只写一个反斜杠`\i`,系统会自动转义成`\\i`;但是在脚本中必须两个反斜杠都写上!**
**使用`\\i,\\c,\\d,\\e`时请注意:在事件块中,允许只写一个反斜杠`\`,系统会自动转义成`\\`;但是在脚本中必须两个反斜杠都写上!**
详细信息请参见[剧情文本控制](event#text显示一段文字剧情)中的说明。

View File

@ -1,6 +1,6 @@
# 事件
?> 目前版本**v2.6.1**,上次更新时间:* {docsify-updated} *
?> 目前版本**v2.6.3**,上次更新时间:* {docsify-updated} *
本章内将对样板所支持的事件进行介绍。
@ -24,7 +24,7 @@
它能通过拖动、复制粘贴等方式帮助你快速生成事件列表,而不用手动打大量字符。
下述所说的都是在事件编辑器右边所展示的,该事件的代码化写法。
下述所说的都是在事件编辑器右边所展示的,该事件的代码化写法;部分增加了可视化事件编辑器的截图示意(感谢秋橙的制作)
强烈建议要对每个事件的写法进行了解,因为在脚本编辑,`insertAction`等地方需要插入自定义事件时,还是很有必要的。
@ -154,6 +154,8 @@
]
```
![](img/events/1.jpg)
该项可以简写成直接的字符串的形式,即下面这种方式也是可以的:
``` js
@ -188,7 +190,9 @@
从V2.5.2以后,新增了绘制大头像的功能。绘制大头像图的基本写法是`\t[1.png]`或者`\t[标题,1.png]`。
从V2.6开始所有图块都允许只写ID对于非怪物则没有标题。
从V2.6开始所有图块都允许只写ID对于非怪物则仅当图块属性中设置了name才有标题否则不显示标题
另外注意的是名字可以用null从而只显示动画而不显示标题。
``` js
[
@ -202,10 +206,13 @@
"\t[1.png]绘制1.png这个头像图",
"\t[标题,1.png]同时绘制标题和1.png这个头像图",
"\t[sword1]获得铁剑,没有标题",
"\t[man]没有标题的npc动画"
"\t[man]没有标题的npc动画",
"\t[null,greenSlime]只绘制怪物动画而不显示标题"
]
```
![](img/events/2.jpg)
!> 大头像的头像图需要在全塔属性中注册且必须是png格式不可以用jpg或者其他格式请自行转换。
除此以外,我们还能实现“对话框效果”,只要有`\b[...]`就可以。
@ -231,9 +238,7 @@
]
```
从V2.6开始,`\b`提供了更多功能,包括:
- `\b[hero]`
![](img/events/3.jpg)
!> `\t[...]`必须在`\b[...]`前面!不然两者都无法正常显示。
@ -247,10 +252,14 @@
]
```
![](img/events/4.jpg)
从V2.5.3以后,也可以使用`\f[...]`来同时绘制一张图片。
其基本写法是`\f[img,x,y]`,或者`\f[img,x,y,w,h]`,或者`\f[img,sx,sy,sw,sh,x,y,w,h]`。
从V2.6.3开始也可以在最后加上alpha值即`\f[img,sx,sy,sw,sh,x,y,w,h,alpha]`。
需要注意的是这个图片是绘制在UI层上的下一个事件执行时即会擦除同时如果使用了\t的图标动画效果重叠的地方也会被图标动画给覆盖掉。
``` js
@ -258,10 +267,13 @@
"\t[勇士]\b[up,hero]\f[1.png,100,100]以(100,100)为左上角绘制1.png图片",
"\t[hero]\f[1.png,100,100]\f[2.png,300,300]同时绘制了两张图片",
"\f[1.png,100,100,300,300]也可以填写宽高,这样会把图片强制进行放缩到指定的宽高值",
"\f[1.png,64,64,128,128,100,100,128,128]裁剪1.png上以(64,64)开始的128x128图片并绘制到画布的(100,100)处"
"\f[1.png,64,64,128,128,100,100,128,128]裁剪1.png上以(64,64)开始的128x128图片并绘制到画布的(100,100)处",
"\f[1.png,64,64,128,128,100,100,128,128,0.5]同上不透明度0.5",
]
```
![](img/events/5.jpg)
从V2.5.5以后,也可以使用`\\i[...]`来在对话框中绘制一个图标。
这里可以使用一个合法ID32x48图块除外或使用一个系统图标`core.statusBar.icons`中的内容)。
@ -273,10 +285,24 @@
]
```
![](img/events/6.jpg)
**可以在控制台中输入`core.statusBar.icons`以查看所有的系统图标定义。**
!> 注意,在事件块中,允许只写一个反斜杠`\i`,系统会自动转义成`\\i`;但是在脚本中必须两个反斜杠都写上!
从V2.6.3开始,也可以使用`\\c[...]`来切换当前字体,`\\d`来加粗或取消粗体,`\\e`来加斜体或取消斜体。
``` js
[
"这是原始字体,\\c[20]使用20号字体\\c[10]使用10号字体",
"\\c如果不加中括号则切换回原始字体。",
"\\d这是粗体\\d取消粗体\\e加斜体\\e取消斜体"
]
```
!> 注意,在事件块中,允许只写一个反斜杠`\c`,系统会自动转义成`\\c`;但是在脚本中必须两个反斜杠都写上!`\d`和`\e`同理。
另外值得一提的是,我们是可以在文字中计算一个表达式的值的。只需要将表达式用 `${ }`整个括起来就可以。
``` js
@ -299,6 +325,8 @@
]
```
![](img/events/7.jpg)
- `status:xxx` 获取勇士属性时只能使用如下几个hp生命值atk攻击力def防御力mdef魔防值money金币experience经验x勇士的横坐标y勇士的纵坐标direction勇士的方向
- `item:xxx` 中的xxx为道具ID。所有道具的ID定义在items.js中请自行查看。例如`item:centerFly` 代表中心对称飞行器的个数。
- `flag:xxx` 中的xxx为一个自定义的变量/Flag支持中文如果没有对其进行赋值则默认值为0。
@ -314,6 +342,8 @@
]
```
![](img/events/8.jpg)
text为文本正文内容和上面的写法完全一致。
time为可选项代表该自动文本的时间。可以不指定不指定默认为3000毫秒。
@ -334,6 +364,8 @@ time为可选项代表该自动文本的时间。可以不指定不指定
]
```
![](img/events/9.jpg)
text为正文文本内容。可以使用`${ }`来计算表达式的值,且使用`\n`手动换行。系统不会对滚动剧情文本进行自动换行。
time为可选项代表总的滚动时间。默认为5000毫秒。
@ -359,6 +391,8 @@ async可选如果为true则会异步执行即不等待当前事件执行
]
```
![](img/events/10.jpg)
title为可选项如果设置则为一个RGB三元组或RGBA四元组表示标题名字颜色。 默认值:`[255,215,0,1]`
text为可选项如果设置则为一个RGB三元组或RGBA四元组表示正文颜色。 默认值:`[255,255,255,1]`
@ -389,6 +423,8 @@ time为可选项表示文字添加的速度。若此项设置为0将直接全
]
```
![](img/events/11.jpg)
text必填为显示的内容支持`${}`的表达式计算。
icon是可选的如果设置则会绘制图标其可以是一个有效的ID或者`core.statusBar.icons`中的系统图标。
@ -403,6 +439,8 @@ icon是可选的如果设置则会绘制图标其可以是一个有效的I
]
```
![](img/events/12.jpg)
这个事件将在运行时被游戏跳过。
### setValue设置勇士的某个属性、道具个数或某个变量/Flag的值
@ -436,6 +474,8 @@ value是一个表达式将通过这个表达式计算出的结果赋值给nam
]
```
![](img/events/13.jpg)
另外注意一点的是如果hp被设置成了0或以下将触发lose事件直接死亡。
### addValue增减勇士的某个属性、道具个数或某个变量/Flag的值
@ -455,6 +495,8 @@ value是一个表达式将通过这个表达式计算出的结果赋值给nam
]
```
![](img/events/14.jpg)
### setFloor设置楼层属性
使用`{"type":"setFloor"}`可以设置某层楼的楼层属性。
@ -471,6 +513,8 @@ value是一个表达式将通过这个表达式计算出的结果赋值给nam
]
```
![](img/events/15.jpg)
name为必填项代表要修改的楼层属性和楼层属性中的一一对应。
floorId为可选项代表要修改的楼层ID可以省略代表当前楼层。
@ -489,6 +533,8 @@ value为必填项代表要修改到的数值。其应该和楼层属性中的
]
```
![](img/events/16.jpg)
name必填项代表要修改的全局属性。
value为必填项代表要修改到的结果。此项无需再手动加单引号。
@ -503,6 +549,8 @@ value为必填项代表要修改到的结果。此项无需再手动加单引
]
```
![](img/events/17.jpg)
name必填项代表要修改的全局数值其和全塔属性中的values一一对应。
value为必填项代表要修改到的结果。该项必须是个数值。
@ -517,6 +565,8 @@ value为必填项代表要修改到的结果。该项必须是个数值。
]
```
![](img/events/18.jpg)
name必填项代表要修改的系统开关其是全塔属性中的flags中的一部分。
value为必填项只能为true或false代表要修改到的结果。
@ -537,6 +587,8 @@ value为必填项只能为true或false代表要修改到的结果。
]
```
![](img/events/19.jpg)
show事件需要用loc指定目标点的坐标可以简单的写[x,y]代表一个点,也可以写个二维数组[[x1,y1],[x2,y2],...]来同时显示多个点。
从V2.2开始loc也可以用变量来代替例如 `"loc": ["flag:x", "flag:y"]`。下同。
@ -575,6 +627,8 @@ NPC对话事件结束后如果需要NPC消失也需要调用 `{"type": "hide"}`
]
```
![](img/events/20.jpg)
### trigger立即触发另一个地点的事件
`{"type":"trigger"}` 会立刻触发当层另一个地点的自定义事件。
@ -588,6 +642,8 @@ NPC对话事件结束后如果需要NPC消失也需要调用 `{"type": "hide"}`
]
```
![](img/events/21.jpg)
其后面带有loc选项代表另一个地点的坐标。
keep可选如果此项为true则不会结束当前的事件列表否则会中断当前的事件流。
@ -613,6 +669,8 @@ keep可选如果此项为true则不会结束当前的事件列表否则会
]
```
![](img/events/22.jpg)
`insert`的写法有两种,可以写`name`,或者`loc`。
- 如果写了`"name": "xxx"`,则会去公共事件列表中找寻对应的事件,并执行。
@ -650,6 +708,8 @@ revisit和trigger完全相同只不过是立刻触发的还是本地点的事
]
```
![](img/events/23.jpg)
revisit其实是trigger的简写只不过是loc固定为当前点。
revisit常常使用在一些商人之类的地方当用户购买物品后不是离开而是立刻重新访问重新进入购买页面。
@ -669,6 +729,8 @@ revisit常常使用在一些商人之类的地方当用户购买物品后不
]
```
![](img/events/24.jpg)
### setBlock设置某个图块
我们可以采用 `{"type": "setBlock"}` 来改变某个地图块。
@ -682,6 +744,8 @@ revisit常常使用在一些商人之类的地方当用户购买物品后不
]
```
![](img/events/25.jpg)
floorId为可选的表示要更改的目标楼层。如果忽略此项则默认为当前楼层。
loc为可选的表示要更改地图块的坐标。如果忽略此项则默认为当前事件点。
@ -712,6 +776,8 @@ number为**要更改到的数字**,有关“数字”的定义详见参见[素
]
```
![](img/events/26.jpg)
loc为要隐藏的贴图的左上角坐标可以简单的写[x,y]代表一个点,也可以写个二维数组[[x1,y1],[x2,y2],...]来同时显示多个点。
如果同时存在若干个贴图都是是该坐标为左上角,则这些贴图全部会被隐藏。
@ -744,6 +810,8 @@ floorId为目标点的楼层如果是当前楼层可以忽略不写。
]
```
![](img/events/27.jpg)
name为必选的且只能是`bg`和`fg`之一,分别代表背景图层和前景图层。
loc为要隐藏的贴图的左上角坐标可以简单的写[x,y]代表一个点,也可以写个二维数组[[x1,y1],[x2,y2],...]来同时显示多个点。
@ -774,6 +842,8 @@ floorId为目标点的楼层如果是当前楼层可以忽略不写。
]
```
![](img/events/28.jpg)
name为必选的且只能是`bg`和`fg`之一,分别代表背景层和前景层。
floorId为可选的表示要更改的目标楼层。如果忽略此项则默认为当前楼层。
@ -794,6 +864,8 @@ loc为可选的表示要更改地图块的坐标。如果忽略此项
]
```
![](img/events/29.jpg)
name是可选的代表目标行走图的文件名。
!> **目标行走图必须在全塔属性的this.images中被定义过且宽度必须是128像素高度不限。**
@ -816,6 +888,14 @@ name是可选的代表目标行走图的文件名。
使用`{"type": "showStatusBar"}`会重新显示状态栏。
### hideHero隐藏勇士
使用`{"type": "hideHero"}`可以隐藏勇士。
### showHero显示勇士
使用`{"type": "showHero"}`会重新显示勇士。
### updateEnemys更新怪物数据
使用 `{"type": "updateEnemys"}` 可以动态修改怪物数据。
@ -836,6 +916,8 @@ name是可选的代表目标行走图的文件名。
]
```
![](img/events/30.jpg)
默认的等待事件可以被Ctrl跳过下面两种情况下不可呗跳过
- 加上`"noSkip": true`后
- 当前存在尚未执行完毕的异步事件。
@ -851,6 +933,8 @@ name是可选的代表目标行走图的文件名。
],
```
![](img/events/31.jpg)
从V2.6开始,有两种写法:
- 写id则视为和空降怪物进行强制战斗不会执行一些战后事件也不会隐藏任何点。
- 写loc可选不填默认当前点则视为和某点怪物进行强制战斗会隐藏该点并且插入该点战后事件执行。
@ -871,6 +955,8 @@ name是可选的代表目标行走图的文件名。
]
```
![](img/events/32.jpg)
loc指定门的坐标floorId指定门所在的楼层ID。如果是当前层则可以忽略floorId选项。
如果loc所在的点是一个墙壁则作为暗墙来开启。
@ -896,6 +982,8 @@ async可选如果为true则会异步执行即不等待当前事件执行
]
```
![](img/events/33.jpg)
id为你要关门的ID需要是一个合法的门系统默认只支持如下几种
```
@ -924,6 +1012,8 @@ changeFloor的事件写法大致如下。
]
```
![](img/events/34.jpg)
可以看到,与上面的楼梯、传送门的写法十分类似。
但是相比那个而言不支持stair楼梯位置只能写坐标没有穿透选项。
@ -948,6 +1038,8 @@ time为可选的指定的话将作为楼层切换动画的时间。
]
```
![](img/events/35.jpg)
### useItem使用道具
调用`{"type": "useItem"}`可以使用一个道具。
@ -960,6 +1052,8 @@ time为可选的指定的话将作为楼层切换动画的时间。
]
```
![](img/events/36.jpg)
使用道具事件会消耗对应的道具。
如果当前不可使用该道具(如没有,或者达不到使用条件),则会进行提示并跳过本事件。
@ -996,7 +1090,7 @@ name所指定的图片必须存在在全塔属性中的images中被定义过
``` js
[
{"type": "unfollow", "name": "npc.png"}, // 将 npc.png 这个行走图取消跟随
{"type": "follow"}, // 取消所有跟随
{"type": "unfollow"}, // 取消所有跟随
]
```
@ -1029,6 +1123,8 @@ async可选如果为true则会异步执行即不等待当前事件执行
]
```
![](img/events/37.jpg)
name为动画名**请确保动画在全塔属性中的animates中被定义过。**
loc为动画的位置可以是`[x,y]`表示在(x,y)点显示,也可以是字符串`"hero"`表示在勇士点显示。
@ -1052,6 +1148,8 @@ loc可忽略如果忽略则显示为事件当前点。
]
```
![](img/events/38.jpg)
code为图片编号如果两张图片重叠编号较大会覆盖编号较小的。该值需要在1~50之间。
image为图片名。**请确保图片在全塔属性中的images中被定义过。**
@ -1138,6 +1236,8 @@ loc为动图左上角坐标以像素为单位进行计算。
]
```
![](img/events/39.jpg)
code为图片编号。该值需要在1~50之间。
to为终点图片左上角坐标以像素为单位进行计算不填写则视为当前图片位置。
@ -1160,6 +1260,8 @@ async可选如果为true则会异步执行即不等待当前事件执行
]
```
![](img/events/40.jpg)
color为需要更改画面色调的颜色。它是一个数组分别指定目标颜色的R,G,B,A值。
- 常见RGB颜色 纯黑[0,0,0],纯白[255,255,255],纯红[255,0,0],等等。
- 第四元为Alpha值即不透明度为一个0到1之间的数。可以不指定则默认为Alpha=1
@ -1227,6 +1329,8 @@ level为天气的强度等级在1-10之间。1级为最弱10级为最强
]
```
![](img/events/41.jpg)
time选项必须指定为每移动一步所需要用到的时间。
loc为需要移动的事件位置。可以省略如果省略则移动本事件。
@ -1257,6 +1361,8 @@ keep为一个可选项代表该事件移动完毕后是否消失。如果该
}
```
![](img/events/42.jpg)
在移动的到达点指定一个事件然后move事件中指定"keep":true然后就可以触发目标点的事件了。
async可选如果为true则会异步执行即不等待当前事件执行完毕立刻执行下一个事件
@ -1335,6 +1441,8 @@ async可选如果为true则会异步执行即不等待当前事件执行
目前支持mp3/ogg/wav等多种格式的音乐播放。
从V2.6.3开始还提供了keep项。如果此项为真则会记录该bgm并且持续到下次调用本事件位置楼层切换不改变bgm读档也有效
有关BGM播放的详细说明参见[背景音乐](element#背景音乐)
### pauseBgm暂停背景音乐
@ -1381,6 +1489,8 @@ async可选如果为true则会异步执行即不等待当前事件执行
使用方法: `{"type": "setVolume", "value": 90, "time": 500, "async": true}`
![](img/events/43.jpg)
value为音量大小在0到100之间默认为100。设置后BGM将使用该音量进行播放。SE的音量大小不会发生改变。
可以设置time为音量渐变时间。
@ -1440,6 +1550,8 @@ async可选如果为true则会异步执行即不等待当前事件执行
]
```
![](img/events/44.jpg)
text为提示文字可以在这里给输入提示文字。这里同样可以使用${ }来计算表达式的值。
当执行input事件时将显示一个弹窗并提示用户输入一个内容。
@ -1459,6 +1571,8 @@ text为提示文字可以在这里给输入提示文字。这里同样可以
]
```
![](img/events/45.jpg)
text为提示文字可以在这里给输入提示文字。这里同样可以使用${ }来计算表达式的值。
当执行input2事件时将显示一个弹窗并提示用户输入一个内容。
@ -1510,6 +1624,8 @@ text为提示文字可以在这里给输入提示文字。这里同样可以
]
```
![](img/events/46.jpg)
需要额外注意的几点:
- 给定的表达式condition一般需要返回true或false。
@ -1575,6 +1691,8 @@ nobreak是可选的如果设置则在当前条件满足并插入事件后
]
```
![](img/events/47.jpg)
需要额外注意的几点:
- 各个条件分支的判断是顺序执行的,因此若多个分支的条件都满足,将只执行最靠前的分支。
@ -1603,6 +1721,7 @@ nobreak是可选的如果设置则在当前条件满足并插入事件后
]
```
![](img/events/48.jpg)
### choices给用户提供选项
@ -1708,12 +1827,16 @@ yes和no均为必填项即用户点击确认或取消后执行的事件。
]
```
![](img/events/49.jpg)
### dowhile后置条件循环
`type:dowhile`可以制作一个后置条件循环。
其写法与参数和`type:while`完全一致不过与其不同的是会先执行一次事件列表再对条件进行判定就和C/C++中的 `do {...} while (...);` 语法一样。
![](img/events/50.jpg)
### break跳出循环
使用 `{"type": "break"}` 可以跳出当前循环。
@ -1743,6 +1866,8 @@ yes和no均为必填项即用户点击确认或取消后执行的事件。
]
```
![](img/events/51.jpg)
!> 如果continue事件不在任何循环中被执行则和exit等价即会立刻结束当前事件
### wait等待用户操作
@ -1782,6 +1907,8 @@ yes和no均为必填项即用户点击确认或取消后执行的事件。
]
```
![](img/events/52.jpg)
### waitAsync等待所有异步事件执行完毕
上面有很多很多的异步事件(也就是执行时不等待执行完毕)。
@ -1795,6 +1922,290 @@ yes和no均为必填项即用户点击确认或取消后执行的事件。
该事件会进行等待,直到所有可能的异步事件(异步动画除外)执行完毕。
### previewUIUI绘制并预览
此项可在地图编辑器中预览UI界面的绘制效果。
在编辑器中将会把此项包含的所有UI绘制事件进行绘制从而可以进行预览。
值得注意的是在游戏中UI绘制事件都是绘制在uievent层上的。
### clearMap清除画布
UI绘制事件。
`{"type": "clearMap"}`可以清除`uievent`画布的内容。
```js
[
{"type": "clearMap", "x": 0, "y": 0, "width": "flag:width", "height": 416}, // 清除画布的一部分
{"type": "clearMap"}, // 清空并删除画布
]
```
x, y, width, height均可选表示要清除的坐标和长宽。也可以使用`flag:xxx`。
如果存在某一项不填则会清空全部画布并删除。
### setAttribute设置画布属性
UI绘制事件。
此项可以设置`uievent`画布的各项属性。
```js
[
{"type": "setAttribute", "font": "17px Verdana", "fillStyle": [255,0,0,1]},
]
```
可以选择性的设置如下几项内容:
- `font`:字体,必须是`[italic] [bold] 14px Verdana`这种形式
- `fillStyle`填充样式必须是三元组RGB或四元组RGBA
- `strokeStyle`边框样式必须是三元组RGB或者四元组RGBA
- `lineWidth`:线宽度,必须是正整数
- `alpha`不透明度必须是0到1之间的浮点数
- `align`:对齐方式,只能是`left`, `center`, `right`,分别代表左对齐,居中和右对齐
- `baseline`:基准线,只能是`top`, `middle`, `alphabetic`, `bottom`,分别代表顶部,居中,标准值和底部。
- `z`画布的z值必须是正整数。初始创建时画布的z值是135。请注意闪烁光标所在画布的z值永远比该画布大1。
### fillText绘制文本
UI绘制事件。
此项可以绘制一行文本。
```js
[
{"type": "fillText", "text""要绘制的文本", "x": 10, "y": 20, "maxWidth": 50}
]
```
text必填为要绘制的文本支持`${}`的写法,不支持一切转义字符或换行符。
x和y必填为要绘制的左上角坐标。请使用`setAttribute`来设置绘制的对齐方式和基准线。
style可选如果设置需要是三元组RGB或四元组RBGA代表绘制样式。
font可选如果设置则是要绘制的字体。
maxWidth可选如果设置且不为0则代表要绘制的最大宽度超过此宽度会自动放缩。
### fillBoldText绘制描边文本
UI绘制事件。
此项可以绘制一行描边文本。
```js
[
{"type": "fillText", "text""要绘制的描边文本", "x": 10, "y": 20, "style": [255,0,0,1]}
]
```
text必填为要绘制的文本支持`${}`的写法,不支持一切转义字符或换行符。
x和y必填为要绘制的左上角坐标。请使用`setAttribute`来设置绘制的对齐方式和基准线。
style可选如果设置需要是三元组RGB或四元组RBGA代表绘制样式。
font可选如果设置则是要绘制的字体。
### drawTextContent绘制多行文本
UI绘制事件。
此项可以绘制多行文本。
```js
[
{"type": "drawTextContent", "text""要绘制的多行文本", "left": 10, "top": 20, "maxWidth": 100}
]
```
text必填为要绘制的文本支持所有的文字效果如\n${}\r\\i\\c\\d\\e等但不支持支持\t和\b的语法。
left和top必填为要绘制的起始像素坐标。实际绘制时会将textBaseline设置为'top',因此只需要考虑第一个字的左上角位置。
maxWidth可选为单行最大宽度超过此宽度将自动换行不设置不会自动换行。
color可选表示绘制时的颜色为三元组RGB或四元组RGBA。如果不设置则使用剧情文本设置中的正文颜色。
bold可选是否粗体。如果不设置默认为false。
align可选文字对齐方式仅在maxWidth设置时有效默认为'left'。
fontSize可选为字体大小如果不设置则使用剧情文本设置中的正文字体大小。
lineHeight可选绘制的行距值如果不设置则使用fontSize*1.3即1.3倍行距)。
此项不支持字体样式的设置,使用的是全塔属性中的全局字体;如有需要请使用“设置全局属性”事件来设置字体样式。
### fillRect绘制矩形
UI绘制事件。此项可以绘制一个矩形。
```js
[
{"type": "fillRect", "x": 100, "y": 100, "width": 120, "height": 120, "style": [255,0,0,1]}
]
```
x, y, width, height必填为要绘制的起点坐标和宽高也可以用`flag:xxx`。
color可选表示绘制时的颜色为三元组RGB或四元组RGBA。
### strokeRect绘制矩形边框
UI绘制事件。此项可以绘制一个矩形边框。
```js
[
{"type": "strokeRect", "x": 100, "y": 100, "width": 120, "height": 120, "style": [255,0,0,1], "lineWidth": 4}
]
```
x, y, width, height必填为要绘制的起点坐标和宽高也可以用`flag:xxx`。
style可选表示绘制时的颜色为三元组RGB或四元组RGBA。
lineWidth可选表示边框的线宽。
### drawLine绘制线段
UI绘制事件。此事件可以绘制一个函数。
```js
[
{"type": "drawLine", "x1": 0, "y1": 0, "x2": "flag:x", "y2": 200, "style": [255,0,0,1]}
]
```
x1, y1, x2, x2必填为要绘制的起点和终点坐标也可以用`flag:xxx`的写法。
style可选表示绘制时的颜色为三元组RGB或四元组RGBA。
lineWidth可选表示边框的线宽。
### drawArrow绘制箭头
UI绘制事件。此事件可以绘制一个箭头。
参数和写法与`drawLine`完全一致,只不过是会多画一个箭头标记。
### fillPolygon绘制多边形
UI绘制事件。此事件可以绘制一个多边形。
```js
[
{"type": "fillPolygon", "nodes": [[0,0],[0,100],[100,0]], "style": [255,0,0,1]}
]
```
nodes必填为一个二维数组其中每一项都是多边形一个顶点坐标。与显示/隐藏事件写法相同)
style可选表示绘制时的颜色为三元组RGB或四元组RGBA。
### strokePolygon绘制多边形边框
UI绘制事件。此事件可以绘制一个多边形边框。
参数列表和`fillPolygon`基本相同,不过多了一个`lineWidth`表示的绘制线宽。
### fillCircle绘制圆
UI绘制事件。此项可以绘制一个圆。
```js
[
{"type": "fillCircle", "x": 100, "y": 100, "r": 10, "style": [255,0,0,1]}
]
```
x, y, r必填为要绘制的圆心和半径也可以用`flag:xxx`。
color可选表示绘制时的颜色为三元组RGB或四元组RGBA。
### strokeCircle绘制圆边框
UI绘制事件。此项可以绘制一个圆边框。
参数列表和`fillCircle`基本相同,不过多了一个`lineWidth`表示的绘制线宽。
### drawImage绘制图片
UI绘制事件。此事件可以绘制一个图片。
```js
[
{"type": "drawImage", "image": "bg.jpg", "x": 0, "y": 0}, // 在(0,0)绘制bg.jpg
{"type": "drawImage", "image": "bg.jpg", "x": 0, "y": 0, "w": 100, "h": 100}, // 在(0,0)绘制bg.jpg且放缩到100x100
// 裁剪并放缩图片
{"type": "drawImage", "image": "bg.jpg", "x": 0, "y": 0, "w": 100, "h": 100, "x1": 0, "y1": 0, "w1": 100, "h1": 100}
]
```
image必填为图片名。图片必须在全塔属性中被注册过。
此函数有三种写法:
- 只写x和y表示要绘制到的位置。
- 写x, y, w, h表示要绘制到的位置且将图片放缩到指定宽高。
- 写x, y, w, h, x1, y1, w1, h1从原始图片上裁剪[x,y,w,h]的图片,并绘制画布上的[x1,y1,w1,h1]
可以查看下面的文档以了解各项参数的信息:
http://www.w3school.com.cn/html5/canvas_drawimage.asp
### drawIcon绘制图标
UI绘制事件。此事件可以绘制一个图标。
```js
[
{"type": "drawIcon", "id": "yellowKey", "x": 100, "y": 100}, // 在(100,100)绘制黄钥匙
]
```
id必填为要绘制的图标ID。可以是一个注册过的图标ID也可以使用状态栏的图标ID例如lv, hp, up, save, settings等。
x, y必填为要绘制的左上角坐标。width和height可选如果设置则会将图标放缩成对应的宽高。
### drawBackground绘制背景图
UI绘制事件。此事件可以绘制一个背景图。
```js
[
{"type": "drawBackground", "background": "winskin.png", "x": 0, "y": 0, "width": 100, "height": 100},
]
```
background必填为要绘制的背景图内容。其可以是一个三元组RGB或四元组RGBA纯色绘制或一个WindowSkin的图片名。
x, y, width, height必填分别为要绘制的起点坐标和长宽。
可以使用“设置画布属性”来设置不透明度和纯色绘制时的边框颜色。
### drawSelector绘制闪烁光标
UI绘制事件。此事件可以绘制闪烁光标。
```js
[
{"type": "drawSelector", "image": "winskin.png", "x": 0, "y": 0, "width": 100, "height": 100},
{"type": "drawSelector"} // 清除闪烁光标
]
```
image为要绘制的WindowSkin图片名如果不填则视为“清除闪烁光标”。
x, y, width, height分别为要绘制的起点坐标和长宽。
请注意,同时只会有一个闪烁光标存在,如果创建多个则后者会替换前者。
闪烁光标将会一直存在即使事件流结束;请使用本事件并不填`image`来清除闪烁光标。
### function: 自定义JS脚本
上述给出了这么多事件,但有时候往往不能满足需求,这时候就需要执行自定义脚本了。
@ -1835,7 +2246,7 @@ core.insertAction([
从V2.5.3开始,针对每个事件都提供了独立开关。
独立开关的写法是`switch:A`, `switch:A`直到`switch:Z`共计26个不过样板中的值块默认只提供前6个
独立开关的写法是`switch:A`, `switch:A`直到`switch:Z`共计26个。
独立开关算是特殊的flag它在事件中使用时会和事件的楼层及坐标进行绑定换句话说每个事件对应的`switch:A`都是不同的。
@ -1846,6 +2257,8 @@ core.insertAction([
通过独立开关的方式我们无需对某些NPC的对话都设立单独的互不重复flag只需要关注该事件自身的逻辑即可。
![](img/events/53.jpg)
## 同一个点的多事件处理
我们可以发现,就目前而且,每个点的事件是和该点进行绑定,并以该点坐标作为唯一索引来查询。
@ -1890,6 +2303,8 @@ core.insertAction([
}
```
![](img/events/54.jpg)
### 获得圣水后变成墙
这个例子要求获得圣水时不前进(也就是不能走到圣水地方),然后把圣水位置变成墙。
@ -1917,6 +2332,8 @@ core.insertAction([
}
```
![](img/events/55.jpg)
总之,记住如下两点:
- 可以使用setBlock来更改一个图块。
@ -2098,11 +2515,13 @@ if (core.flags.enableAddPoint && point > 0) {
]
```
![](img/events/56.jpg)
`id`, `textInList`, `mustEnable`和上述完全相同。
`commonEvent`为公共事件名,即选择此项时要执行的公共事件。
`args`为向该公共事件传递的参数,参见[type:insert](#insert插入公共事件或另一个地点的事件并执行)的说明。
`args`可选,为向该公共事件传递的参数,参见[type:insert](#insert插入公共事件或另一个地点的事件并执行)的说明。
## 系统引发的自定义事件
@ -2140,6 +2559,8 @@ if (core.flags.enableAddPoint && point > 0) {
},
```
![](img/events/60.jpg)
!> 多个机关门请分别设置开门变量如door1, door2等等。请勿存在两个机关门用相同的变量
除此以外,每层楼还提供了`firstArrive`和`eachArrive`事件,分别为首次到达该楼层和每次到达该楼层时执行的事件。
@ -2259,6 +2680,8 @@ if (core.flags.enableAddPoint && point > 0) {
}
```
![](img/events/57.jpg)
另外从V2.6开始,脚本编辑中提供了战前事件`beforeBattle`,这里不再详细展开,如有需求可自行前往研究。
## 经验升级(进阶/境界塔)
@ -2288,6 +2711,8 @@ if (core.flags.enableAddPoint && point > 0) {
]
```
![](img/events/58.jpg)
`levelUp`是一个数组,里面分别定义了每个等级的信息。里面每一项有三个参数`need`, `title`, `effect`
- `need` 该等级所需要的经验值可以是个表达式。请确保数组中的need依次递增。
- `title` 该等级的名称,比如“佣兵下级”等。该项可以忽略,以使用系统默认的等级。该项将显示在状态栏中。
@ -2341,6 +2766,8 @@ if (core.flags.enableAddPoint && point > 0) {
]
```
![](img/events/59.jpg)
==========================================================================================
[继续阅读下一章:个性化](personalization)

BIN
_docs/img/events/1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
_docs/img/events/10.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

BIN
_docs/img/events/11.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
_docs/img/events/12.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
_docs/img/events/13.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

BIN
_docs/img/events/14.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

BIN
_docs/img/events/15.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

BIN
_docs/img/events/16.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
_docs/img/events/17.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
_docs/img/events/18.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
_docs/img/events/19.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

BIN
_docs/img/events/2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

BIN
_docs/img/events/20.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
_docs/img/events/21.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
_docs/img/events/22.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

BIN
_docs/img/events/23.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
_docs/img/events/24.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
_docs/img/events/25.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
_docs/img/events/26.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
_docs/img/events/27.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
_docs/img/events/28.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

BIN
_docs/img/events/29.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
_docs/img/events/3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

BIN
_docs/img/events/30.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
_docs/img/events/31.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
_docs/img/events/32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
_docs/img/events/33.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
_docs/img/events/34.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
_docs/img/events/35.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
_docs/img/events/36.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
_docs/img/events/37.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

BIN
_docs/img/events/38.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

BIN
_docs/img/events/39.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

BIN
_docs/img/events/4.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
_docs/img/events/40.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
_docs/img/events/41.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
_docs/img/events/42.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

BIN
_docs/img/events/43.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
_docs/img/events/44.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
_docs/img/events/45.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
_docs/img/events/46.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
_docs/img/events/47.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

BIN
_docs/img/events/48.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
_docs/img/events/49.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

BIN
_docs/img/events/5.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
_docs/img/events/50.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
_docs/img/events/51.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

BIN
_docs/img/events/52.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

BIN
_docs/img/events/53.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
_docs/img/events/54.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
_docs/img/events/55.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

BIN
_docs/img/events/56.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
_docs/img/events/57.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
_docs/img/events/58.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
_docs/img/events/59.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
_docs/img/events/6.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
_docs/img/events/60.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
_docs/img/events/7.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
_docs/img/events/8.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
_docs/img/events/9.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -1,6 +1,6 @@
# HTML5 魔塔样板说明文档
?> 目前版本**v2.6.1**,上次更新时间:* {docsify-updated} *
?> 目前版本**v2.6.3**,上次更新时间:* {docsify-updated} *
众所周知魔塔的趋势是向移动端发展贴吧中也常常能见到“求手机魔塔”的帖子。然而现有的工具中NekoRPG有着比较大的局限性游戏感较差更是完全没法在iOS上运行。而一些APP的魔塔虽然可用但是必须要下载安装对于Android和iOS还必须开发不同的版本非常麻烦。

View File

@ -1,6 +1,6 @@
# 个性化
?> 目前版本**v2.6.1**,上次更新时间:* {docsify-updated} *
?> 目前版本**v2.6.3**,上次更新时间:* {docsify-updated} *
有时候只靠样板本身可能是不够的。我们需要一些个性化、自定义的素材,道具效果,怪物属性,等等。
@ -22,6 +22,7 @@ HTML5魔塔是使用画布canvas来绘制存在若干个图层它们
- paint**[D]**绘图层主要用来进行绘图模式。z-index: 95)
- curtain色调层用来控制当前楼层的画面色调 (z-index: 125)
- image1\~50**[D]**图片层用来绘制图片等操作。z-index: 100+code, 101~150
- uievent**[D]**自定义UI绘制层用来进行自定义UI绘制等操作。z-index135可以通过事件设置该值
- uiUI层用来绘制一切UI窗口如剧情文本、怪物手册、楼传器、系统菜单等等 (z-index: 140)
- data数据层用来绘制一些顶层的或更新比较快的数据如左上角的提示战斗界面中数据的变化等等。 (z-index: 170)
@ -29,6 +30,8 @@ HTML5魔塔是使用画布canvas来绘制存在若干个图层它们
色调层的z-index是25ui层的z-index是140因此图片编号在1~24的将被色调层遮挡25~40的将被ui层遮挡41~50的将遮挡UI层。
uievent层为自定义UI绘制所在的层其z值初始是135可以通过事件设置自定义绘制的闪烁光标所在层的z值永远比该值大1。
### 动态创建canvas
从V2.5.3开始可以在H5样板中任意动态创建canvas并进行使用。
@ -559,8 +562,6 @@ core.statusBar.speed.innerHTML = core.getFlag('speed', 0);
如果flag:skill不为0则代表当前处于某个技能开启状态且状态栏显示flag:skillName值。伤害计算函数中只需要对flag:skill进行处理即可。
!> 关于魔力上限样板中默认没有提供status:manamax
### 状态栏的显示
从V2.5开始,魔力值和技能名的状态栏项目已经被添加,可以直接使用。

View File

@ -1,6 +1,6 @@
# 脚本
?> 目前版本**v2.6.1**,上次更新时间:* {docsify-updated} *
?> 目前版本**v2.6.3**,上次更新时间:* {docsify-updated} *
在V2.6版本中,基本对整个项目代码进行了重写,更加方便造塔者的使用和复写函数。

View File

@ -1,6 +1,6 @@
# 快速上手
?> 目前版本**v2.6.1**,上次更新时间:* {docsify-updated} *
?> 目前版本**v2.6.3**,上次更新时间:* {docsify-updated} *
在这一节中,将详细介绍做一部塔的流程。现在,让我们来做一部单层塔!

File diff suppressed because it is too large Load Diff

View File

@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) 2014 Peter Dematté
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -262,10 +262,6 @@ body {
position: absolute;
}
.egameCanvas {
position: absolute;
}
.gameCanvas {
position: absolute;
}
@ -287,6 +283,13 @@ body {
0 0 0 3px #000;
}
#iconExpandBtn {
position: absolute;
left: 10px;
bottom: 30px;
display: none;
}
.warnText {
color: #D50000;
font-weight: 700;
@ -459,3 +462,87 @@ table.row td {
top: 6px;
background-image:url('data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIGJhc2VQcm9maWxlPSJmdWxsIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4bWxuczpldj0iaHR0cDovL3d3dy53My5vcmcvMjAwMS94bWwtZXZlbnRzIj4KPGc%2BCgk8cG9seWdvbiBmaWxsPSIjNjY2IiBwb2ludHM9IjkuMjA3LDYuMTI2IDcuNzkzLDcuNTQxIDExLjc5MywxMS41NDEgMTMuMjA3LDEwLjEyNiIgLz4KCTxwYXRoIGZpbGw9IiM2NjYiIGQ9Ik01LjkxNywyYzEuNjA4LDAsMi45MTcsMS4zMDgsMi45MTcsMi45MTdTNy41MjUsNy44MzMsNS45MTcsNy44MzNTMyw2LjUyNSwzLDQuOTE3UzQuMzA4LDIsNS45MTcsMgoJCSBNNS45MTcsMEMzLjIwMSwwLDEsMi4yMDEsMSw0LjkxN3MyLjIwMSw0LjkxNyw0LjkxNyw0LjkxN3M0LjkxNy0yLjIwMSw0LjkxNy00LjkxN0MxMC44MzMsMi4yMDEsOC42MzIsMCw1LjkxNywwTDUuOTE3LDB6IiAvPgo8L2c%2BCjwvc3ZnPgo%3D');
}
#uieventDiv {
display: none;
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
background: rgba(127,127,127,0.6);
z-index: 2000
}
#uieventDialog {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -60%);
background: white;
width: 436px;
}
#uieventHead {
margin: 10px 20px;
}
#uieventTitle {
font-weight: bold;
}
#uieventNo {
float: right;
}
#uieventYes {
display: none;
float: right;
margin-right: 15px;
}
#uieventBody {
width: 416px;
height: 416px;
position: relative;
margin-left: 10px;
margin-bottom: 5px;
overflow: hidden;
}
#uievent {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
}
#selectPoint {
display: none;
margin-left: 10px;
margin-bottom: 10px;
}
#selectPointFloor {
margin-right: 10px;
}
#selectPointButtons {
display: inline;
}
#selectPointBox {
position: absolute;
z-index: 75;
width: 26px;
height: 26px;
margin: 3px 0 0 3px;
padding: 0;
/* display: none; */
box-sizing: border-box;
background-color: rgba(255, 255, 255, 0.0);
border: 1px solid #000;
box-shadow: 0 0 0 2px #fff,
0 0 0 3px #000;
}

View File

@ -247,10 +247,6 @@ body {
position: absolute;
}
.egameCanvas {
position: absolute;
}
.gameCanvas {
position: absolute;
}
@ -272,6 +268,13 @@ body {
0 0 0 3px #000;
}
#iconExpandBtn {
position: absolute;
left: 10px;
bottom: 30px;
display: none;
}
.warnText {
color: #D50000;
font-weight: 700;
@ -433,7 +436,7 @@ div.row .rowtd .rowtext{
font: normal 2.5vw Arial, sans-serif;
list-style: none;
margin: 0;
padding: 4px 7em 4px 28px;
padding: 4px 7em 4px 4px;
white-space: nowrap;
/* padding-left: 12px; */
@ -483,3 +486,87 @@ div.row .rowtd .rowtext{
border-radius: 3px;
width: 90px;
}
#uieventDiv {
display: none;
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
background: rgba(127,127,127,0.6);
z-index: 2000
}
#uieventDialog {
position: fixed;
top: 50%;
left: 0;
transform: translateY(-50%);
background: white;
width: 100vw;
}
#uieventHead {
margin: 10px 20px;
}
#uieventTitle {
font-weight: bold;
}
#uieventNo {
float: right;
}
#uieventYes {
display: none;
float: right;
margin-right: 15px;
}
#uieventBody {
width: 100vw;
height: 100vw;
position: relative;
margin-left: 0;
margin-bottom: 5px;
overflow: hidden;
}
#uievent {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
}
#selectPoint {
display: none;
margin-left: 10px;
margin-bottom: 10px;
}
#selectPointFloor {
margin-right: 10px;
}
#selectPointButtons {
display: inline;
}
#selectPointBox {
position: absolute;
z-index: 75;
width: 26px;
height: 26px;
margin: 3px 0 0 3px;
padding: 0;
/* display: none; */
box-sizing: border-box;
background-color: rgba(255, 255, 255, 0.0);
border: 1px solid #000;
box-shadow: 0 0 0 2px #fff,
0 0 0 3px #000;
}

View File

@ -98,6 +98,12 @@ editor.prototype.init = function (callback) {
editor_multi = editor_multi();
editor_blockly = editor_blockly();
// --- 所有用到的flags
editor.used_flags = {};
for (var floorId in editor.main.floors) {
editor.addUsedFlags(JSON.stringify(editor.main.floors[floorId]));
}
if (editor.useCompress == null) editor.useCompress = useCompress;
if (Boolean(callback)) callback();
@ -144,14 +150,15 @@ editor.prototype.changeFloor = function (floorId, callback) {
}
editor.preMapData = null;
core.changeFloor(floorId, null, {"x": 0, "y": 0, "direction": "up"}, null, function () {
core.bigmap.offsetX=0;
core.bigmap.offsetY=0;
editor.moveViewport(0,0);
editor.game.fetchMapFromCore();
editor.updateMap();
editor_mode.floor();
editor.drawEventBlock();
editor.viewportLoc = editor.viewportLoc || {};
var loc = editor.viewportLoc[floorId] || [], x = loc[0] || 0, y = loc[1] || 0;
editor.setViewport(x, y);
if (callback) callback();
});
}
@ -256,14 +263,19 @@ editor.prototype.updateMap = function () {
}
editor.prototype.moveViewport=function(x,y){
core.bigmap.offsetX = core.clamp(core.bigmap.offsetX+32*x, 0, 32*core.bigmap.width-core.__PIXELS__);
core.bigmap.offsetY = core.clamp(core.bigmap.offsetY+32*y, 0, 32*core.bigmap.height-core.__PIXELS__);
editor.prototype.setViewport=function (x, y) {
core.bigmap.offsetX = core.clamp(x, 0, 32*core.bigmap.width-core.__PIXELS__);
core.bigmap.offsetY = core.clamp(y, 0, 32*core.bigmap.height-core.__PIXELS__);
editor.viewportLoc[editor.currentFloorId] = [core.bigmap.offsetX, core.bigmap.offsetY];
core.control.updateViewport();
editor.buildMark();
editor.drawPosSelection();
}
editor.prototype.moveViewport=function(x,y){
editor.setViewport(core.bigmap.offsetX+32*x, core.bigmap.offsetY+32*y);
}
/////////// 界面交互相关 ///////////
editor.prototype.drawInitData = function (icons) {
@ -272,6 +284,9 @@ editor.prototype.drawInitData = function (icons) {
var maxHeight = 700;
var sumWidth = 0;
editor.widthsX = {};
editor.folded = core.getLocalStorage('folded', false);
// editor.folded = true;
editor.foldPerCol = 50;
// var imgNames = Object.keys(images); //还是固定顺序吧;
var imgNames = ["terrains", "animates", "enemys", "enemy48", "items", "npcs", "npc48", "autotile"];
@ -282,20 +297,21 @@ editor.prototype.drawInitData = function (icons) {
for (var im in autotiles) {
tempy += autotiles[im].height;
}
editor.widthsX[img] = [img, sumWidth / 32, (sumWidth + 3 * 32) / 32, tempy];
sumWidth += 3 * 32;
var tempx = editor.folded ? 32 : 3 * 32;
editor.widthsX[img] = [img, sumWidth / 32, (sumWidth + tempx) / 32, tempy];
sumWidth += tempx;
maxHeight = Math.max(maxHeight, tempy);
continue;
}
if (img == 'terrains') {
editor.widthsX[img] = [img, sumWidth / 32, (sumWidth + images[img].width) / 32, images[img].height + 32*2]
sumWidth += images[img].width;
maxHeight = Math.max(maxHeight, images[img].height + 32*2);
continue;
var width = images[img].width, height = images[img].height, mh = height;
if (editor.folded) {
var per_height = (img == 'enemy48' || img == 'npc48' ? 48 : 32);
width = Math.ceil(height / per_height / editor.foldPerCol) * 32;
if (width > 32) mh = per_height * editor.foldPerCol;
}
editor.widthsX[img] = [img, sumWidth / 32, (sumWidth + images[img].width) / 32, images[img].height];
sumWidth += images[img].width;
maxHeight = Math.max(maxHeight, images[img].height);
editor.widthsX[img] = [img, sumWidth / 32, (sumWidth + width) / 32, height];
sumWidth += width;
maxHeight = Math.max(maxHeight, mh + 64);
}
var tilesets = images.tilesets;
for (var ii in core.tilesets) {
@ -312,82 +328,75 @@ editor.prototype.drawInitData = function (icons) {
if (fullWidth > edata.width) edata.style.width = (edata.width = fullWidth) / ratio + 'px';
edata.style.height = (edata.height = fullHeight) / ratio + 'px';
*/
var iconImages = document.getElementById('iconImages');
iconImages.style.width = (iconImages.width = fullWidth) / ratio + 'px';
iconImages.style.height = (iconImages.height = fullHeight) / ratio + 'px';
var dc = {drawImage:function(){
var image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight;
var a=Array.prototype.slice.call(arguments)
if(arguments.length==3){
// [image, dx, dy]=arguments
// [sx, sy, sWidth, sHeight, dWidth, dHeight]=[0,0,image.width,image.height,image.width,image.height]
image=a[0]
a=[a[0],0,0,image.width,image.height,a[1],a[2],image.width,image.height]
}
if(arguments.length==5){
// [image, dx, dy, dWidth, dHeight]=arguments
// [sx, sy, sWidth, sHeight]=[0,0,image.width,image.height]
image=a[0]
a=[a[0],0,0,image.width,image.height,a[1],a[2],a[3],a[4]]
}
if(arguments.length==9){
// [image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight]=arguments
}
image=a[0];
sx=a[1];
sy=a[2];
sWidth=a[3];
sHeight=a[4];
dx=a[5];
dy=a[6];
dWidth=a[7];
dHeight=a[8];
//放弃对 dWidth, dHeight 的支持, 始终画一样大的
var dimg=new Image()
dimg.src = image.src;
dimg.style.clip=['rect(',sy,'px,',sx+sWidth,'px,',sy+sHeight,'px,',sx,'px)'].join('')
dimg.style.top=dy-sy+'px'
dimg.style.left=dx-sx+'px'
dimg.width=image.width/ratio
dimg.height=image.height/ratio
iconImages.appendChild(dimg)
}}
// var dc = edata.getContext('2d');
var nowx = 0;
var nowy = 0;
var drawImage = function (image, x, y) {
image.style.left = x + 'px';
image.style.top = y + 'px';
iconImages.appendChild(image);
}
var nowx = 0, nowy = 0;
for (var ii = 0; ii < imgNames.length; ii++) {
var img = imgNames[ii];
if (img == 'terrains') {
(function(image,dc,nowx){
(function(image,nowx){
if (image.complete) {
dc.drawImage(image, nowx, 32);
drawImage(image, nowx, 32);
core.material.images.airwall = image;
delete(editor.airwallImg);
} else image.onload = function () {
dc.drawImage(image, nowx, 32);
drawImage(image, nowx, 32);
core.material.images.airwall = image;
delete(editor.airwallImg);
editor.updateMap();
}
})(editor.airwallImg,dc,nowx);
dc.drawImage(images[img], nowx, 32*2);
nowx += images[img].width;
})(editor.airwallImg,nowx);
if (editor.folded) {
// --- 单列 & 折行
var subimgs = core.splitImage(images[img], 32, editor.foldPerCol * 32);
var frames = images[img].width / 32;
for (var i = 0; i < subimgs.length; i+=frames) {
drawImage(subimgs[i], nowx, i==0?2*32:0);
nowx += 32;
}
}
else {
drawImage(images[img], nowx, 32*2);
nowx += images[img].width;
}
continue;
}
if (img == 'autotile') {
var autotiles = images[img];
var tempx = editor.folded ? 32 : 96;
for (var im in autotiles) {
dc.drawImage(autotiles[im], 0, 0, 96, 128, nowx, nowy, 96, 128);
var subimgs = core.splitImage(autotiles[im], tempx, autotiles[im].height);
drawImage(subimgs[0], nowx, nowy);
nowy += autotiles[im].height;
}
nowx += 3 * 32;
nowx += tempx;
continue;
}
dc.drawImage(images[img], nowx, 0)
nowx += images[img].width;
if (editor.folded) {
// --- 单列 & 折行
var per_height = img.endsWith('48') ? 48 : 32;
var subimgs = core.splitImage(images[img], 32, editor.foldPerCol * per_height);
var frames = images[img].width / 32;
for (var i = 0; i < subimgs.length; i+=frames) {
drawImage(subimgs[i], nowx, 0);
nowx += 32;
}
}
else {
drawImage(images[img], nowx, 0);
nowx += images[img].width;
}
}
for (var ii in core.tilesets) {
var img = core.tilesets[ii];
dc.drawImage(tilesets[img], nowx, 0)
drawImage(tilesets[img], nowx, 0);
nowx += tilesets[img].width;
}
//editor.mapInit();
@ -461,8 +470,12 @@ editor.prototype.setSelectBoxFromInfo=function(thisevent){
pos.x=editor.widthsX[thisevent.images][1];
pos.y=thisevent.y;
if(thisevent.x)pos.x+=thisevent.x;
if(thisevent.images=='terrains')pos.y+=2;
ysize = thisevent.images.endsWith('48') ? 48 : 32;
if (editor.folded && core.tilesets.indexOf(thisevent.images)==-1) {
pos.x += Math.floor(pos.y / editor.foldPerCol);
pos.y %= editor.foldPerCol;
}
if(pos.x == 0) pos.y+=2;
}
var dataSelection = document.getElementById('dataSelection');
dataSelection.style.left = pos.x * 32 + 'px';
@ -484,4 +497,129 @@ editor.prototype.mobile_listen=function(){
// 移动至 editor_unsorted_1.js
}
editor.prototype.copyFromPos = function (pos) {
var fields = Object.keys(editor.file.comment._data.floors._data.loc._data);
pos = pos || editor.pos;
var map = core.clone(editor.map[pos.y][pos.x]);
var events = {};
fields.forEach(function(v){
events[v] = core.clone(editor.currentFloorData[v][pos.x+','+pos.y]);
})
return {map: map, events: events};
}
editor.prototype.pasteToPos = function (info, pos) {
if (info == null) return;
var fields = Object.keys(editor.file.comment._data.floors._data.loc._data);
pos = pos || editor.pos;
editor.map[pos.y][pos.x] = core.clone(info.map);
fields.forEach(function(v){
if (info.events[v] == null) delete editor.currentFloorData[v][pos.x+","+pos.y];
else editor.currentFloorData[v][pos.x+","+pos.y] = core.clone(info.events[v]);
});
}
editor.prototype.movePos = function (startPos, endPos, callback) {
if (!startPos || !endPos) return;
if (startPos.x == endPos.x && startPos.y == endPos.y) return;
var copyed = editor.copyFromPos(startPos);
editor.pasteToPos({map:0, events: {}}, startPos);
editor.pasteToPos(copyed, endPos);
editor.updateMap();
editor.file.saveFloorFile(function (err) {
if (err) {
printe(err);
throw(err)
}
;printf('移动事件成功');
editor.drawPosSelection();
if (callback) callback();
});
}
editor.prototype.exchangePos = function (startPos, endPos, callback) {
if (!startPos || !endPos) return;
if (startPos.x == endPos.x && startPos.y == endPos.y) return;
var startInfo = editor.copyFromPos(startPos);
var endInfo = editor.copyFromPos(endPos);
editor.pasteToPos(startInfo, endPos);
editor.pasteToPos(endInfo, startPos);
editor.updateMap();
editor.file.saveFloorFile(function (err) {
if (err) {
printe(err);
throw(err)
}
;printf('交换事件成功');
editor.drawPosSelection();
if (callback) callback();
});
}
editor.prototype.moveBgFg = function (startPos, endPos, name, callback) {
if (!startPos || !endPos || ["bgmap","fgmap"].indexOf(name)<0) return;
if (startPos.x == endPos.x && startPos.y == endPos.y) return;
editor[name][endPos.y][endPos.x] = editor[name][startPos.y][startPos.x];
editor[name][startPos.y][startPos.x] = 0;
editor.updateMap();
editor.file.saveFloorFile(function (err) {
if (err) {
printe(err);
throw(err)
}
;printf('移动图块成功');
editor.drawPosSelection();
if (callback) callback();
});
}
editor.prototype.exchangeBgFg = function (startPos, endPos, name, callback) {
if (!startPos || !endPos || ["bgmap","fgmap"].indexOf(name)<0) return;
if (startPos.x == endPos.x && startPos.y == endPos.y) return;
var value = editor[name][endPos.y][endPos.x];
editor[name][endPos.y][endPos.x] = editor[name][startPos.y][startPos.x];
editor[name][startPos.y][startPos.x] = value;
editor.updateMap();
editor.file.saveFloorFile(function (err) {
if (err) {
printe(err);
throw(err)
}
;printf('交换图块成功');
editor.drawPosSelection();
if (callback) callback();
});
}
editor.prototype.clearPos = function (clearPos, pos, callback) {
var fields = Object.keys(editor.file.comment._data.floors._data.loc._data);
pos = pos || editor.pos;
editor.hideMidMenu();
editor.preMapData = null;
editor.info = 0;
editor_mode.onmode('');
if (clearPos)
editor.map[pos.y][pos.x]=editor.info;
editor.updateMap();
fields.forEach(function(v){
delete editor.currentFloorData[v][pos.x+','+pos.y];
})
editor.file.saveFloorFile(function (err) {
if (err) {
printe(err);
throw(err)
}
;printf(clearPos?'清空该点和事件成功':'只清空该点事件成功');
editor.drawPosSelection();
if (callback) callback();
});
}
editor.prototype.addUsedFlags = function (s) {
s.replace(/flag:([a-zA-Z0-9_\u4E00-\u9FCC]+)/g, function (s0, s1) {
editor.used_flags[s1] = true; return s0;
});
}
editor = new editor();

View File

@ -76,9 +76,9 @@ editor_blockly = function () {
MotaActionBlocks['confirm_s'].xmlText(),
MotaActionBlocks['choices_s'].xmlText([
'选择剑或者盾','流浪者','man',MotaActionBlocks['choicesContext'].xmlText([
'剑','','',null,MotaActionFunctions.actionParser.parseList([{"type": "openDoor", "loc": [3,3]}]),
'剑','','',null,'',MotaActionFunctions.actionParser.parseList([{"type": "openDoor", "loc": [3,3]}]),
MotaActionBlocks['choicesContext'].xmlText([
'盾','','',null,MotaActionFunctions.actionParser.parseList([{"type": "openDoor", "loc": [9,3]}]),
'盾','','',null,'',MotaActionFunctions.actionParser.parseList([{"type": "openDoor", "loc": [9,3]}]),
])
])
]),
@ -150,8 +150,12 @@ editor_blockly = function () {
MotaActionBlocks['waitAsync_s'].xmlText(),
MotaActionBlocks['vibrate_s'].xmlText(),
MotaActionBlocks['animate_s'].xmlText(),
MotaActionBlocks['setViewport_s'].xmlText(),
MotaActionBlocks['moveViewport_s'].xmlText(),
MotaActionBlocks['showStatusBar_s'].xmlText(),
MotaActionBlocks['hideStatusBar_s'].xmlText(),
MotaActionBlocks['showHero_s'].xmlText(),
MotaActionBlocks['hideHero_s'].xmlText(),
MotaActionBlocks['setCurtain_0_s'].xmlText(),
MotaActionBlocks['setCurtain_1_s'].xmlText(),
MotaActionBlocks['screenFlash_s'].xmlText(),
@ -169,6 +173,29 @@ editor_blockly = function () {
MotaActionBlocks['autoSave_s'].xmlText(),
MotaActionBlocks['callLoad_s'].xmlText(),
],
'UI绘制':[
MotaActionBlocks['previewUI_s'].xmlText(),
MotaActionBlocks['clearMap_s'].xmlText(),
MotaActionBlocks['clearMap_1_s'].xmlText(),
MotaActionBlocks['setAttribute_s'].xmlText(),
MotaActionBlocks['fillText_s'].xmlText(),
MotaActionBlocks['fillBoldText_s'].xmlText(),
MotaActionBlocks['drawTextContent_s'].xmlText(),
MotaActionBlocks['fillRect_s'].xmlText(),
MotaActionBlocks['strokeRect_s'].xmlText(),
MotaActionBlocks['drawLine_s'].xmlText(),
MotaActionBlocks['drawArrow_s'].xmlText(),
MotaActionBlocks['fillPolygon_s'].xmlText(),
MotaActionBlocks['strokePolygon_s'].xmlText(),
MotaActionBlocks['fillCircle_s'].xmlText(),
MotaActionBlocks['strokeCircle_s'].xmlText(),
MotaActionBlocks['drawImage_s'].xmlText(),
MotaActionBlocks['drawImage_1_s'].xmlText(),
MotaActionBlocks['drawIcon_s'].xmlText(),
MotaActionBlocks['drawBackground_s'].xmlText(),
MotaActionBlocks['drawSelector_s'].xmlText(),
MotaActionBlocks['drawSelector_1_s'].xmlText(),
],
'原生脚本':[
MotaActionBlocks['function_s'].xmlText(),
MotaActionBlocks['unknown_s'].xmlText(),
@ -366,7 +393,7 @@ function omitedcheckUpdateFunction(event) {
}
}
try {
var code = Blockly.JavaScript.workspaceToCode(workspace).replace(/\\\\i/g, '\\\\\\\\i');
var code = Blockly.JavaScript.workspaceToCode(workspace).replace(/\\\\(i|c|d|e)/g, '\\\\\\\\$1');
codeAreaHL.setValue(code);
} catch (error) {
codeAreaHL.setValue(String(error));
@ -509,8 +536,7 @@ function omitedcheckUpdateFunction(event) {
MotaActionFunctions.parse(
eval('obj=' + codeAreaHL.getValue().replace(/[<>&]/g, function (c) {
return {'<': '&lt;', '>': '&gt;', '&': '&amp;'}[c];
}).replace(/\\r/g, '\\\\r').replace(/\\f/g, '\\\\f')
.replace(/\\i/,'\\\\i')),
}).replace(/\\(r|f|i|c|d|e)/g,'\\\\$1')),
document.getElementById('entryType').value
);
}
@ -584,14 +610,44 @@ function omitedcheckUpdateFunction(event) {
return;
}
var code = Blockly.JavaScript.workspaceToCode(editor_blockly.workspace);
code = code.replace(/\\i/g, '\\\\i');
code = code.replace(/\\(i|c|d|e)/g, '\\\\$1');
eval('var obj=' + code);
setvalue(JSON.stringify(obj));
}
var previewBlock = function (b) {
var types = [
"previewUI_s", "clearMap_s", "clearMap_1_s", "setAttribute_s", "fillText_s",
"fillBoldText_s", "drawTextContent_s", "fillRect_s", "strokeRect_s", "drawLine_s",
"drawArrow_s", "fillPolygon_s", "strokePolygon_s", "fillCircle_s", "strokeCircle_s",
"drawImage_s", "drawImage_1_s", "drawIcon_s", "drawBackground_s", "drawSelector_s", "drawSelector_1_s"
];
if (b && types.indexOf(b.type)>=0) {
try {
var code = "[" + Blockly.JavaScript.blockToCode(b).replace(/\\(i|c|d|e)/g, '\\\\$1') + "]";
eval("var obj="+code);
// console.log(obj);
if (obj.length > 0 && b.type.startsWith(obj[0].type)) {
if (b.type == 'previewUI_s')
uievent.previewUI(obj[0].action);
else uievent.previewUI([obj[0]]);
}
} catch (e) {main.log(e);}
return true;
}
return false;
}
editor_blockly.doubleClickBlock = function (blockId) {
var b = editor_blockly.workspace.getBlockById(blockId);
//console.log(b);
if (previewBlock(b)) return;
if (b && b.type in selectPointBlocks) { // selectPoint
this.selectPoint();
return;
}
var textStringDict = {
'text_0_s': 'EvalString_0',
'text_1_s': 'EvalString_2',
@ -603,6 +659,7 @@ function omitedcheckUpdateFunction(event) {
'function_s': 'RawEvalString_0',
'shopsub': 'EvalString_3',
'confirm_s': 'EvalString_0',
'drawTextContent_s': 'EvalString_0',
}
var f = b ? textStringDict[b.type] : null;
if (f) {
@ -650,40 +707,26 @@ function omitedcheckUpdateFunction(event) {
// Index from 1 - 9
editor_blockly.openToolbox = function(index) {
// var element = document.getElementById(':'+index);
// if (element == null || element.getAttribute("aria-selected")=="true") return;
// element.click();
editor_blockly.workspace.toolbox_.tree_.setSelectedItem(editor_blockly.workspace.toolbox_.tree_.children_[index-1]);
if (index < 0) index += editor_blockly.workspace.toolbox_.tree_.children_.length;
editor_blockly.workspace.toolbox_.tree_.setSelectedItem(editor_blockly.workspace.toolbox_.tree_.children_[index]);
}
editor_blockly.reopenToolbox = function(index) {
// var element = document.getElementById(':'+index);
// if (element == null) return;
// if (element.getAttribute("aria-selected")=="true") element.click();
// element.click();
editor_blockly.workspace.toolbox_.tree_.setSelectedItem(editor_blockly.workspace.toolbox_.tree_.children_[index-1]);
editor_blockly.workspace.getFlyout_().show(editor_blockly.workspace.toolbox_.tree_.children_[index-1].blocks);
if (index < 0) index += editor_blockly.workspace.toolbox_.tree_.children_.length;
editor_blockly.workspace.toolbox_.tree_.setSelectedItem(editor_blockly.workspace.toolbox_.tree_.children_[index]);
editor_blockly.workspace.getFlyout_().show(editor_blockly.workspace.toolbox_.tree_.children_[index].blocks);
}
editor_blockly.closeToolbox = function() {
/*
for (var i=1; i<=10; i++) {
var element = document.getElementById(':'+i);
if (element && element.getAttribute("aria-selected")=="true") {
element.click();
return;
}
}
*/
editor_blockly.workspace.toolbox_.clearSelection();
}
var searchInput = document.getElementById("searchBlock");
searchInput.onfocus = function () {
editor_blockly.reopenToolbox(10);
editor_blockly.reopenToolbox(-1);
}
searchInput.oninput = function () {
editor_blockly.reopenToolbox(10);
editor_blockly.reopenToolbox(-1);
}
editor_blockly.searchBlock = function (value) {
@ -708,6 +751,290 @@ function omitedcheckUpdateFunction(event) {
return results.length == 0 ? editor_blockly.lastUsedType : results;
}
// ------ select point ------
// id: [x, y, floorId, forceFloor]
var selectPointBlocks = {
"changeFloor_m": ["Number_0", "Number_1", "IdString_0", true],
"jumpHero_s": ["PosString_0", "PosString_1"],
"changeFloor_s": ["PosString_0", "PosString_1", "IdString_0", true],
"changePos_0_s": ["PosString_0", "PosString_1"],
"battle_1_s": ["PosString_0", "PosString_1"],
"openDoor_s": ["PosString_0", "PosString_1", "IdString_0"],
"closeDoor_s": ["PosString_0", "PosString_1"],
"show_s": ["EvalString_0", "EvalString_1", "IdString_0"],
"hide_s": ["EvalString_0", "EvalString_1", "IdString_0"],
"setBlock_s": ["EvalString_1", "EvalString_2", "IdString_0"],
"move_s": ["PosString_0", "PosString_1"],
"jump_s": ["PosString_2", "PosString_3"], // 跳跃暂时只考虑终点
"showBgFgMap_s": ["EvalString_0", "EvalString_1", "IdString_0"],
"hideBgFgMap_s": ["EvalString_0", "EvalString_1", "IdString_0"],
"setBgFgBlock_s": ["PosString_0", "PosString_1", "IdString_0"],
"showFloorImg_s": ["EvalString_0", "EvalString_1", "IdString_0"],
"hideFloorImg_s": ["EvalString_0", "EvalString_1", "IdString_0"],
"trigger_s": ["PosString_0", "PosString_1"],
"insert_2_s": ["PosString_0", "PosString_1", "IdString_0"],
"animate_s": ["EvalString_0", "EvalString_0"],
"setViewport_s": ["PosString_0", "PosString_1"]
}
editor_blockly.selectPoint = function () {
var block = Blockly.selected, arr = null;
var floorId = editor.currentFloorId, pos = editor.pos, x = pos.x, y = pos.y;
if (block != null && block.type in selectPointBlocks) {
arr = selectPointBlocks[block.type];
var xv = parseInt(block.getFieldValue(arr[0])), yv = parseInt(block.getFieldValue(arr[1]));
if (block.type == 'animate_s') {
var v = block.getFieldValue(arr[0]).split(",");
xv = parseInt(v[0]); yv = parseInt(v[1]);
}
if (!isNaN(xv)) x = xv;
if (!isNaN(yv)) y = yv;
if (arr[2] != null) floorId = block.getFieldValue(arr[2]) || floorId;
}
uievent.selectPoint(floorId, x, y, arr && arr[2] == null, function (fv, xv, yv) {
if (!arr) return;
if (arr[2] != null) {
if (fv != editor.currentFloorId) block.setFieldValue(fv, arr[2]);
else block.setFieldValue(arr[3] ? fv : "", arr[2]);
}
if (block.type == 'animate_s') {
block.setFieldValue(xv+","+yv, arr[0]);
}
else {
block.setFieldValue(xv+"", arr[0]);
block.setFieldValue(yv+"", arr[1]);
}
if (block.type == 'changeFloor_m') {
block.setFieldValue("floorId", "Floor_List_0");
block.setFieldValue("loc", "Stair_List_0");
}
});
}
editor_blockly.getAutoCompletions = function (content) {
// --- content为当前框中输入内容将返回一个列表为后续所有可补全内容
// 检查 flag:xxxitem:xxx和flag:xxx
var index = content.lastIndexOf(":");
if (index >= 0) {
var before = content.substring(0, index), token = content.substring(index+1);
if (/^[a-zA-Z0-9_\u4E00-\u9FCC]*$/.test(token)) {
if (before.endsWith("status")) {
return Object.keys(core.status.hero).filter(function (one) {
return one != token && one.startsWith(token);
}).sort();
}
else if (before.endsWith("item")) {
return Object.keys(core.material.items).filter(function (one) {
return one != token && one.startsWith(token);
}).sort();
}
else if (before.endsWith("flag")) {
return Object.keys(editor.used_flags || {}).filter(function (one) {
return one != token && one.startsWith(token);
}).sort();
}
}
}
// 提供 core.xxx 的补全
index = content.lastIndexOf("core.");
if (index >= 0) {
var s = content.substring(index + 5);
if (/^[\w.]*$/.test(s)) {
var tokens = s.split(".");
var now = core, prefix = tokens[tokens.length - 1];
for (var i = 0; i < tokens.length - 1; ++i) {
now = now[tokens[i]];
if (now == null) break;
}
if (now != null) {
var candidates = [];
for (var i in now) {
candidates.push(i);
}
return candidates.filter(function (one) {
return one != prefix && one.startsWith(prefix);
}).sort();
}
}
}
return [];
}
editor_blockly.completeItems = [];
return editor_blockly;
}
//editor_blockly=editor_blockly();
// --- modify Blockly
Blockly.FieldColour.prototype.createWidget_ = function() {
Blockly.WidgetDiv.hide();
// console.log('here')
var self=this;
var pb=self.sourceBlock_
var args = MotaActionBlocks[pb.type].args
var targetf=args[args.indexOf(self.name)-1]
var getValue=function(){
// return self.getValue() // css颜色
var f = pb.getFieldValue(targetf);
if (/^(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d),(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d),(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(,0(\.\d+)?|,1)?$/.test(f)) {
return f;
}
return "";
// 也可以用 pb.getFieldValue(targetf) 获得颜色块左边的域的内容
}
var setValue=function(newValue){ // css颜色
self.setValue(newValue)
var c=new Colors();
c.setColor(newValue)
var rgbatext = [c.colors.webSmart.r,c.colors.webSmart.g,c.colors.webSmart.b,c.colors.alpha].join(",");
pb.setFieldValue(rgbatext, targetf) // 放在颜色块左边的域中
}
setTimeout(function () {
document.getElementById("colorPicker").value = getValue();
window.jsColorPicker.confirm = setValue;
// 设置位置
triggerColorPicker(Blockly.WidgetDiv.DIV.style.left, Blockly.WidgetDiv.DIV.style.top);
});
return document.createElement('table');
};
Blockly.FieldTextInput.prototype.showInlineEditor_ = function(quietInput) {
Blockly.WidgetDiv.show(this, this.sourceBlock_.RTL, this.widgetDispose_());
var div = Blockly.WidgetDiv.DIV;
// Create the input.
var htmlInput =
goog.dom.createDom(goog.dom.TagName.INPUT, 'blocklyHtmlInput');
htmlInput.setAttribute('spellcheck', this.spellcheck_);
var fontSize =
(Blockly.FieldTextInput.FONTSIZE * this.workspace_.scale) + 'pt';
div.style.fontSize = fontSize;
htmlInput.style.fontSize = fontSize;
Blockly.FieldTextInput.htmlInput_ = htmlInput;
div.appendChild(htmlInput);
htmlInput.value = htmlInput.defaultValue = this.text_;
htmlInput.oldValue_ = null;
// console.log('here')
var self=this;
var pb=self.sourceBlock_
var args = MotaActionBlocks[pb.type].args
var targetf=args[args.indexOf(self.name)+1]
// ------ colour
if(targetf && targetf.slice(0,7)==='Colour_'){
var inputDom = htmlInput;
// var getValue=function(){ // 获得自己的字符串
// return pb.getFieldValue(self.name);
// }
var setValue = function(newValue){ // 设置右边颜色块的css颜色
pb.setFieldValue(newValue, targetf)
}
// 给inputDom绑事件
inputDom.oninput=function(){
var value=inputDom.value
if(/[0-9 ]+,[0-9 ]+,[0-9 ]+(,[0-9. ]+)?/.test(value)){
setValue('rgba('+value+')')
}
}
}
else {
htmlInput.onkeydown = function (e) {
if (e.keyCode == 13 && awesomplete.opened && awesomplete.selected) {
e.stopPropagation();
e.stopImmediatePropagation();
e.preventDefault();
awesomplete.select();
return false;
}
}
// --- awesomplete
var awesomplete = new Awesomplete(htmlInput, {
minChars: 4,
maxItems: 12,
autoFirst: true,
replace: function (text) {
text = text.toString();
var value = this.input.value, index = this.input.selectionEnd;
if (index == null) index = value.length;
if (index < awesomplete.prefix.length) index = awesomplete.prefix.length;
var str = value.substring(0, index - awesomplete.prefix.length) + text + value.substring(index);
this.input.value = str;
pb.setFieldValue(str, self.name);
index += text.length - awesomplete.prefix.length;
this.input.setSelectionRange(index, index);
editor_blockly.completeItems = editor_blockly.completeItems.filter(function (x) {
return x != text;
});
editor_blockly.completeItems.unshift(text);
},
filter: function () {return true;},
item: function (text, input) {
var li = document.createElement("li");
li.setAttribute("role", "option");
li.setAttribute("aria-selected", "false");
input = awesomplete.prefix.trim();
if (input != "") text = text.replace(new RegExp("^"+input, "i"), "<mark>$&</mark>");
li.innerHTML = text;
return li;
},
sort: function (a, b) {
a = a.toString(); b = b.toString();
var ia = editor_blockly.completeItems.indexOf(a), ib = editor_blockly.completeItems.indexOf(b);
if (ia < 0) ia = editor_blockly.completeItems.length;
if (ib < 0) ib = editor_blockly.completeItems.length;
if (ia != ib) return ia - ib;
if (a.length != b.length) return a.length - b.length;
return a < b ? -1 : 1;
}
});
htmlInput.oninput = function () {
var value = htmlInput.value, index = htmlInput.selectionEnd;
if (index == null) index = value.length;
value = value.substring(0, index);
// cal prefix
awesomplete.prefix = "";
for (var i = index - 1; i>=0; i--) {
var c = value.charAt(i);
if (!/^[a-zA-Z0-9_\u4E00-\u9FCC]$/.test(c)) {
awesomplete.prefix = value.substring(i+1);
break;
}
}
var list = editor_blockly.getAutoCompletions(value);
awesomplete.list = list;
awesomplete.ul.style.marginLeft = getCaretCoordinates(htmlInput, htmlInput.selectionStart).left -
htmlInput.scrollLeft - 20 + "px";
awesomplete.evaluate();
}
awesomplete.container.style.width = "100%";
window.awesomplete = awesomplete;
}
if (!quietInput) {
htmlInput.focus();
htmlInput.select();
}
this.validate_();
this.resizeEditor_();
this.bindEvents_(htmlInput);
};

View File

@ -15,13 +15,15 @@ editor_file = function (editor, callback) {
var filename = 'project/floors/' + editor.currentFloorId + '.js';
var datastr = ['main.floors.', editor.currentFloorId, '=\n'];
for(var ii=0,name;name=['map','bgmap','fgmap'][ii];ii++){
var mapArray=editor[name].map(function (v) {
return v.map(function (v) {
return v.idnum || v || 0
})
});
editor.currentFloorData[name]=mapArray;
if (core.floorIds.indexOf(editor.currentFloorId) >= 0) {
for(var ii=0,name;name=['map','bgmap','fgmap'][ii];ii++){
var mapArray=editor[name].map(function (v) {
return v.map(function (v) {
return v.idnum || v || 0
})
});
editor.currentFloorData[name]=mapArray;
}
}
// format 更改实现方式以支持undefined删除
@ -39,6 +41,7 @@ editor_file = function (editor, callback) {
datastr = datastr.join('');
alertWhenCompress();
fs.writeFile(filename, encode(datastr), 'base64', function (err, data) {
editor.addUsedFlags(datastr);
callback(err);
});
}
@ -56,8 +59,8 @@ editor_file = function (editor, callback) {
title = "主塔 "+name+" 层";
}
var width = parseInt(document.getElementById('newMapsWidth').value);
var height = parseInt(document.getElementById('newMapsHeight').value);
var width = parseInt(document.getElementById('newMapWidth').value);
var height = parseInt(document.getElementById('newMapHeight').value);
var row = [], map = [];
for (var i=0;i<width;i++) row.push(0);
for (var i=0;i<height;i++) map.push(row);

View File

@ -57,7 +57,7 @@ editor_mode = function (editor) {
printe(objs_.slice(-1)[0]);
throw(objs_.slice(-1)[0])
}
;printf('修改成功');
;printf('修改成功' + (data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.firstData.name == 'template' ? '\n\n请注意全塔属性的name尚未修改请及时予以设置' : ''));
}
switch (mode) {
case 'loc':
@ -114,8 +114,7 @@ editor_mode = function (editor) {
editor.drawEventBlock();
if (editor_mode[mode]) editor_mode[mode]();
document.getElementById('editModeSelect').value = mode;
var tips = tip_in_showMode;
if (!selectBox.isSelected()) printf('tips: ' + tips[~~(tips.length * Math.random())]);
if (!selectBox.isSelected()) tip.showHelp();
}
editor_mode.prototype.loc = function (callback) {

View File

@ -81,6 +81,12 @@ editor_multi = function () {
_format();
}
editor_multi.hasError = function () {
if (!editor_multi.lintAutocomplete) return false;
return JSHINT.errors.filter(function (e) {
return e.code.startsWith("E")
}).length > 0;
}
editor_multi.import = function (id_, args) {
var thisTr = document.getElementById(id_);
@ -94,6 +100,8 @@ editor_multi = function () {
editor_multi.lintAutocomplete = false;
if (args.lint === true) editor_multi.lintAutocomplete = true;
if (field.indexOf('Effect') !== -1) editor_multi.lintAutocomplete = true;
if ((!input.value || input.value == 'null') && editor_mode.mode == 'plugins')
input.value = '"function () {\\n\\t// 在此增加新插件\\n\\t\\n}"';
if (input.value.slice(0, 1) === '"' || args.string) {
editor_multi.isString = true;
codeEditor.setValue(JSON.parse(input.value) || '');
@ -124,6 +132,11 @@ editor_multi = function () {
}
editor_multi.confirm = function () {
if (editor_multi.hasError()) {
alert("当前好像存在严重的语法错误,请处理后再保存。\n严重的语法错误可能会导致整个编辑器的崩溃。");
return;
}
if (!editor_multi.id) {
editor_multi.id = '';
return;

View File

@ -104,6 +104,7 @@ editor.constructor.prototype.listen=function () {
holdingPath = 0;
stepPostfix = [];
uc.clearRect(0, 0, core.__PIXELS__, core.__PIXELS__);
startPos = endPos = null;
}//用于鼠标移出canvas时的自动清除状态
eui.oncontextmenu=function(e){e.preventDefault()}
@ -116,12 +117,13 @@ editor.constructor.prototype.listen=function () {
return;
}
var startPos=null, endPos=null;
eui.onmousedown = function (e) {
if (e.button==2){
var loc = eToLoc(e);
var pos = locToPos(loc,true);
editor.showMidMenu(e.clientX,e.clientY);
return;
return false;
}
if (!selectBox.isSelected()) {
var loc = eToLoc(e);
@ -130,34 +132,58 @@ editor.constructor.prototype.listen=function () {
editor_mode.onmode('loc');
//editor_mode.loc();
//tip.whichShow(1);
tip.showHelp(6);
startPos = pos;
uc.strokeStyle = '#FF0000';
uc.lineWidth = 3;
if(editor.isMobile)editor.showMidMenu(e.clientX,e.clientY);
return;
return false;
}
holdingPath = 1;
mouseOutCheck = 2;
setTimeout(clear1);
e.stopPropagation();
uc.clearRect(0, 0, core.__PIXELS__, core.__PIXELS__);
var loc = eToLoc(e);
var pos = locToPos(loc,true);
stepPostfix = [];
stepPostfix.push(pos);
fillPos(pos);
return false;
}
eui.onmousemove = function (e) {
if (!selectBox.isSelected()) {
if (startPos == null) return;
//tip.whichShow(1);
return;
var loc = eToLoc(e);
var pos = locToPos(loc,true);
if (endPos != null && endPos.x == pos.x && endPos.y == pos.y) return;
if (endPos != null) {
uc.clearRect(Math.min(32 * startPos.x - core.bigmap.offsetX, 32 * endPos.x - core.bigmap.offsetX),
Math.min(32 * startPos.y - core.bigmap.offsetY, 32 * endPos.y - core.bigmap.offsetY),
(Math.abs(startPos.x - endPos.x) + 1) * 32, (Math.abs(startPos.y - endPos.y) + 1) * 32)
}
endPos = pos;
if (startPos != null) {
if (startPos.x != endPos.x || startPos.y != endPos.y) {
core.drawArrow('eui',
32 * startPos.x + 16 - core.bigmap.offsetX, 32 * startPos.y + 16 - core.bigmap.offsetY,
32 * endPos.x + 16 - core.bigmap.offsetX, 32 * endPos.y + 16 - core.bigmap.offsetY);
}
}
// editor_mode.onmode('nextChange');
// editor_mode.onmode('loc');
//editor_mode.loc();
//tip.whichShow(1);
// tip.showHelp(6);
return false;
}
if (holdingPath == 0) {
return;
return false;
}
mouseOutCheck = 2;
e.stopPropagation();
var loc = eToLoc(e);
var pos = locToPos(loc,true);
var pos0 = stepPostfix[stepPostfix.length - 1]
@ -176,15 +202,22 @@ editor.constructor.prototype.listen=function () {
stepPostfix.push(pos);
fillPos(pos);
}
return false;
}
eui.onmouseup = function (e) {
if (!selectBox.isSelected()) {
//tip.whichShow(1);
return;
// editor.movePos(startPos, endPos);
if (editor.layerMod == 'map')
editor.exchangePos(startPos, endPos);
else
editor.exchangeBgFg(startPos, endPos, editor.layerMod);
startPos = endPos = null;
uc.clearRect(0, 0, core.__PIXELS__, core.__PIXELS__);
return false;
}
holdingPath = 0;
e.stopPropagation();
if (stepPostfix && stepPostfix.length) {
editor.preMapData = JSON.parse(JSON.stringify({map:editor.map,fgmap:editor.fgmap,bgmap:editor.bgmap}));
if(editor.brushMod!=='line'){
@ -227,6 +260,7 @@ editor.constructor.prototype.listen=function () {
stepPostfix = [];
uc.clearRect(0, 0, core.__PIXELS__, core.__PIXELS__);
}
return false;
}
/*
@ -248,7 +282,6 @@ editor.constructor.prototype.listen=function () {
*/
document.getElementById('mid').onmousewheel = function (e) {
e.preventDefault();
var wheel = function (direct) {
var index=editor.core.floorIds.indexOf(editor.currentFloorId);
var toId = editor.currentFloorId;
@ -274,6 +307,7 @@ editor.constructor.prototype.listen=function () {
catch (ee) {
console.log(ee);
}
return false;
}
editor.preMapData = null;
@ -283,8 +317,21 @@ editor.constructor.prototype.listen=function () {
};
var reDo = null;
var shortcut = core.getLocalStorage('shortcut',{48: 0, 49: 0, 50: 0, 51: 0, 52: 0, 53: 0, 54: 0, 55: 0, 56: 0, 57: 0});
var copyedInfo = null;
document.body.onkeydown = function (e) {
// UI预览 & 地图选点
if (uievent && uievent.isOpen) {
e.preventDefault();
if (e.keyCode == 27) uievent.close();
else if (e.keyCode == 13) uievent.confirm();
else if (e.keyCode==87) uievent.move(0,-1)
else if (e.keyCode==65) uievent.move(-1,0)
else if (e.keyCode==83) uievent.move(0,1);
else if (e.keyCode==68) uievent.move(1,0);
return;
}
// 监听Ctrl+S保存
if (e.ctrlKey && e.keyCode == 83) {
e.preventDefault();
@ -318,6 +365,7 @@ editor.constructor.prototype.listen=function () {
reDo = JSON.parse(JSON.stringify(currDrawData));
currDrawData = {pos: [], info: {}};
editor.preMapData = null;
return;
}
//Ctrl+y 重做一步redo
if (e.keyCode == 89 && e.ctrlKey && reDo && reDo.pos.length && selectBox.isSelected()) {
@ -328,34 +376,27 @@ editor.constructor.prototype.listen=function () {
editor.updateMap();
currDrawData = JSON.parse(JSON.stringify(reDo));
reDo = null;
return;
}
// PGUP和PGDOWN切换楼层
if (e.keyCode==33) {
if (e.keyCode==33 || e.keyCode==34) {
e.preventDefault();
var index=editor.core.floorIds.indexOf(editor.currentFloorId);
if (index<editor.core.floorIds.length-1) {
var toId = editor.core.floorIds[index+1];
editor_mode.onmode('nextChange');
editor_mode.onmode('floor');
document.getElementById('selectFloor').value = toId;
editor.changeFloor(toId);
}
}
if (e.keyCode==34) {
e.preventDefault();
var index=editor.core.floorIds.indexOf(editor.currentFloorId);
if (index>0) {
var toId = editor.core.floorIds[index-1];
var nextIndex = index + (e.keyCode==33?1:-1);
if (nextIndex>=0 && nextIndex<editor.core.floorIds.length) {
var toId = editor.core.floorIds[nextIndex];
editor_mode.onmode('nextChange');
editor_mode.onmode('floor');
document.getElementById('selectFloor').value = toId;
editor.changeFloor(toId);
}
return;
}
//ctrl + 0~9 切换到快捷图块
if (e.ctrlKey && [48, 49, 50, 51, 52, 53, 54, 55, 56, 57].indexOf(e.keyCode) !== -1){
editor.setSelectBoxFromInfo(JSON.parse(JSON.stringify(shortcut[e.keyCode]||0)));
return;
}
//alt + 0~9 改变快捷图块
if (e.altKey && [48, 49, 50, 51, 52, 53, 54, 55, 56, 57].indexOf(e.keyCode) !== -1){
@ -364,21 +405,104 @@ editor.constructor.prototype.listen=function () {
shortcut[e.keyCode]=JSON.parse(infoToSave);
printf('已保存该快捷图块, ctrl + '+(e.keyCode-48)+' 使用.')
core.setLocalStorage('shortcut',shortcut);
return;
}
var focusElement = document.activeElement;
if (!focusElement || focusElement.tagName.toLowerCase()=='body') {
// wasd平移大地图
if (e.keyCode==87)
editor.moveViewport(0,-1)
else if (e.keyCode==65)
editor.moveViewport(-1,0)
else if (e.keyCode==83)
editor.moveViewport(0,1);
else if (e.keyCode==68)
editor.moveViewport(1,0);
// Ctrl+C, Ctrl+X, Ctrl+V
if (e.ctrlKey && e.keyCode == 67 && !selectBox.isSelected()) {
e.preventDefault();
copyedInfo = editor.copyFromPos();
printf('该点事件已复制');
return;
}
if (e.ctrlKey && e.keyCode == 88 && !selectBox.isSelected()) {
e.preventDefault();
copyedInfo = editor.copyFromPos();
editor.clearPos(true, null, function () {
printf('该点事件已剪切');
})
return;
}
if (e.ctrlKey && e.keyCode == 86 && !selectBox.isSelected()) {
e.preventDefault();
if (!copyedInfo) {
printe("没有复制的事件");
return;
}
editor.pasteToPos(copyedInfo);
editor.updateMap();
editor.file.saveFloorFile(function (err) {
if (err) {
printe(err);
throw(err)
}
;printf('粘贴事件成功');
editor.drawPosSelection();
});
return;
}
// DELETE
if (e.keyCode == 46 && !selectBox.isSelected()) {
editor.clearPos(true);
return;
}
// ESC
if (e.keyCode == 27) {
if (selectBox.isSelected()) {
editor_mode.onmode('');
editor.file.saveFloorFile(function (err) {
if (err) {
printe(err);
throw(err)
}
;printf('地图保存成功');
});
}
selectBox.isSelected(false);
editor.info = {};
return;
}
switch (e.keyCode) {
// WASD
case 87: editor.moveViewport(0,-1); break;
case 65: editor.moveViewport(-1,0); break;
case 83: editor.moveViewport(0,1); break;
case 68: editor.moveViewport(1,0); break;
// Z~.
case 90: editor_mode.change('map'); break; // Z
case 88: editor_mode.change('loc'); break; // X
case 67: editor_mode.change('enemyitem'); break; // C
case 86: editor_mode.change('floor'); break; // V
case 66: editor_mode.change('tower'); break; // B
case 78: editor_mode.change('functions'); break; // N
case 77: editor_mode.change('appendpic'); break; // M
case 188: editor_mode.change('commonevent'); break; // ,
case 190: editor_mode.change('plugins'); break; // .
// H
case 72: editor.showHelp(); break;
}
return;
}
}
editor.showHelp = function () {
alert(
"快捷操作帮助:\n" +
"ESC / 点击空白处:自动保存当前修改" +
"WASD / 长按箭头:平移大地图\n" +
"PgUp, PgDn / 鼠标滚轮:上下切换楼层\n" +
"Z~.(键盘的第三排):快捷切换标签\n" +
"双击地图:选中对应点的素材\n" +
"右键地图:弹出菜单栏\n" +
"Alt+0~9保存当前使用的图块\n" +
"Ctrl+0~9选中保存的图块\n" +
"Ctrl+Z / Ctrl+Y撤销/重做上次绘制\n" +
"Ctrl+S事件与脚本编辑器的保存并退出\n" +
"双击事件编辑器:长文本编辑/脚本编辑/地图选点/UI绘制预览"
);
}
var getScrollBarHeight = function () {
var outer = document.createElement("div");
outer.style.visibility = "hidden";
@ -405,11 +529,22 @@ editor.constructor.prototype.listen=function () {
}
var scrollBarHeight = getScrollBarHeight();
var iconExpandBtn = document.getElementById('iconExpandBtn');
iconExpandBtn.style.display = 'block';
iconExpandBtn.innerText = editor.folded ? "展开" : "折叠";
iconExpandBtn.onclick = function () {
if (confirm(editor.folded ? "你想要展开素材吗?\n展开模式下将显示全素材内容。"
: ("你想要折叠素材吗?\n折叠模式下每个素材将仅显示单列并且每"+editor.foldPerCol+"个自动换列。"))) {
core.setLocalStorage('folded', !editor.folded);
window.location.reload();
}
}
var dataSelection = document.getElementById('dataSelection');
var iconLib=document.getElementById('iconLib');
iconLib.onmousedown = function (e) {
e.stopPropagation();
if (!editor.isMobile && e.clientY>=((core.__SIZE__==13?630:655) - scrollBarHeight)) return;
if (!editor.isMobile && e.clientY>=iconLib.offsetHeight - scrollBarHeight) return;
var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
var loc = {
@ -421,11 +556,11 @@ editor.constructor.prototype.listen=function () {
var pos = locToPos(loc);
for (var spriter in editor.widthsX) {
if (pos.x >= editor.widthsX[spriter][1] && pos.x < editor.widthsX[spriter][2]) {
var ysize = spriter.indexOf('48') === -1 ? 32 : 48;
var ysize = spriter.endsWith('48') ? 48 : 32;
loc.ysize = ysize;
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];
if(!editor.folded && 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);
@ -439,8 +574,15 @@ editor.constructor.prototype.listen=function () {
}
}
}
} else if ((pos.y + 1) * ysize > editor.widthsX[spriter][3])
pos.y = ~~(editor.widthsX[spriter][3] / ysize) - 1;
}
else {
var height = editor.widthsX[spriter][3], col = height / ysize;
if (editor.folded && core.tilesets.indexOf(pos.images)==-1) {
col = (pos.x == editor.widthsX[spriter][2] - 1) ? ((col - 1) % editor.foldPerCol + 1) : editor.foldPerCol;
}
if (spriter == 'terrains' && pos.x == editor.widthsX[spriter][1]) col += 2;
pos.y = Math.min(pos.y, col - 1);
}
selectBox.isSelected(true);
// console.log(pos,core.material.images[pos.images].height)
@ -454,10 +596,16 @@ editor.constructor.prototype.listen=function () {
} else if(pos.x == 0 && pos.y == 1){
editor.info = editor.ids[editor.indexs[17]];
} else {
if (Object.prototype.hasOwnProperty.call(autotiles, pos.images)) editor.info = {'images': pos.images, 'y': 0};
else if (pos.images == 'terrains') editor.info = {'images': pos.images, 'y': pos.y - 2};
if (autotiles[pos.images]) editor.info = {'images': pos.images, 'y': 0};
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};
else {
var y = pos.y;
if (editor.folded) {
y += editor.foldPerCol * (pos.x-editor.widthsX[spriter][1]);
}
if (pos.images == 'terrains' && pos.x == 0) y -= 2;
editor.info = {'images': pos.images, 'y': y}
}
for (var ii = 0; ii < editor.ids.length; ii++) {
if ((core.tilesets.indexOf(pos.images)!=-1 && editor.info.images == editor.ids[ii].images
@ -484,10 +632,13 @@ editor.constructor.prototype.listen=function () {
var midMenu=document.getElementById('midMenu');
midMenu.oncontextmenu=function(e){e.preventDefault()}
editor.lastRightButtonPos=[{x:0,y:0},{x:0,y:0}];
editor.lastCopyedInfo = [null, null];
editor.showMidMenu=function(x,y){
editor.lastRightButtonPos=JSON.parse(JSON.stringify(
[editor.pos,editor.lastRightButtonPos[0]]
));
// --- copy
editor.lastCopyedInfo = [editor.copyFromPos(), editor.lastCopyedInfo[0]];
var locStr='('+editor.lastRightButtonPos[1].x+','+editor.lastRightButtonPos[1].y+')';
var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
@ -502,6 +653,10 @@ editor.constructor.prototype.listen=function () {
addFloorEvent.style.display='block';
addFloorEvent.children[0].innerHTML='绑定下楼事件';
}
else if (['leftPortal','rightPortal','downPortal','upPortal'].indexOf(thisevent.id)>=0) {
addFloorEvent.style.display='block';
addFloorEvent.children[0].innerHTML='绑定楼传事件';
}
else addFloorEvent.style.display='none';
chooseThis.children[0].innerHTML='选中此点'+'('+editor.pos.x+','+editor.pos.y+')'
@ -524,20 +679,27 @@ editor.constructor.prototype.listen=function () {
editor.hideMidMenu();
e.stopPropagation();
var thisevent = editor.map[editor.pos.y][editor.pos.x];
var loc = editor.pos.x+","+editor.pos.y;
if (thisevent.id=='upFloor') {
editor.currentFloorData.changeFloor[editor.pos.x+","+editor.pos.y] = {"floorId": ":next", "stair": "downFloor"};
editor.currentFloorData.changeFloor[loc] = {"floorId": ":next", "stair": "downFloor"};
}
else if (thisevent.id=='downFloor') {
editor.currentFloorData.changeFloor[editor.pos.x+","+editor.pos.y] = {"floorId": ":before", "stair": "upFloor"};
editor.currentFloorData.changeFloor[loc] = {"floorId": ":before", "stair": "upFloor"};
}
else if (thisevent.id=='leftPortal' || thisevent.id=='rightPortal') {
editor.currentFloorData.changeFloor[loc] = {"floorId": ":next", "stair": ":symmetry_x"}
}
else if (thisevent.id=='upPortal' || thisevent.id=='downPortal') {
editor.currentFloorData.changeFloor[loc] = {"floorId": ":next", "stair": ":symmetry_y"}
}
editor.file.saveFloorFile(function (err) {
if (err) {
printe(err);
throw(err)
}
;printf('添加楼梯事件成功');
editor.drawPosSelection();
editor_mode.showMode('loc');
printf('添加楼梯事件成功');
});
}
@ -562,8 +724,6 @@ editor.constructor.prototype.listen=function () {
editor.setSelectBoxFromInfo(thisevent);
}
var fields = Object.keys(editor.file.comment._data.floors._data.loc._data);
var copyLoc = document.getElementById('copyLoc');
copyLoc.onmousedown = function(e){
editor.hideMidMenu();
@ -571,22 +731,10 @@ editor.constructor.prototype.listen=function () {
editor.preMapData = null;
reDo = null;
editor_mode.onmode('');
var now = editor.pos;
var last = editor.lastRightButtonPos[1];
var lastevent = editor.map[last.y][last.x];
var lastinfo = 0;
if(lastevent==0){
lastinfo = 0;
} else {
var ids=editor.indexs[lastevent.idnum];
ids=ids[0]?ids[0]:ids;
lastinfo=editor.ids[ids];
}
editor.map[now.y][now.x]=lastinfo;
var now = editor.pos, last = editor.lastRightButtonPos[1];
if (now.x == last.x && now.y == last.y) return;
editor.pasteToPos(editor.lastCopyedInfo[1]);
editor.updateMap();
fields.forEach(function(v){
editor.currentFloorData[v][now.x+','+now.y]=editor.currentFloorData[v][last.x+','+last.y]
})
editor.file.saveFloorFile(function (err) {
if (err) {
printe(err);
@ -603,79 +751,22 @@ editor.constructor.prototype.listen=function () {
e.stopPropagation();
editor.preMapData = null;
reDo = null;
var thisevent = editor.map[editor.pos.y][editor.pos.x];
if(thisevent==0){
editor.info = 0;
} else {
var ids=editor.indexs[thisevent.idnum];
ids=ids[0]?ids[0]:ids;
editor.info=editor.ids[ids];
}
editor_mode.onmode('');
var now = editor.pos;
var last = editor.lastRightButtonPos[1];
var lastevent = editor.map[last.y][last.x];
var lastinfo = 0;
if(lastevent==0){
lastinfo = 0;
} else {
var ids=editor.indexs[lastevent.idnum];
ids=ids[0]?ids[0]:ids;
lastinfo=editor.ids[ids];
}
editor.map[last.y][last.x]=editor.info;
editor.map[now.y][now.x]=lastinfo;
editor.updateMap();
fields.forEach(function(v){
var temp_atsfcytaf=editor.currentFloorData[v][now.x+','+now.y];
editor.currentFloorData[v][now.x+','+now.y]=editor.currentFloorData[v][last.x+','+last.y];
editor.currentFloorData[v][last.x+','+last.y]=temp_atsfcytaf;
})
editor.file.saveFloorFile(function (err) {
if (err) {
printe(err);
throw(err)
}
;printf('两位置的事件已互换');
editor.drawPosSelection();
});
}
var _clearPoint = function (clearPoint) {
editor.hideMidMenu();
editor.preMapData = null;
reDo = null;
editor.info = 0;
editor_mode.onmode('');
var now = editor.pos;
if (clearPoint)
editor.map[now.y][now.x]=editor.info;
editor.updateMap();
fields.forEach(function(v){
delete editor.currentFloorData[v][now.x+','+now.y];
})
editor.file.saveFloorFile(function (err) {
if (err) {
printe(err);
throw(err)
}
;printf(clearPoint?'清空该点和事件成功':'只清空该点事件成功');
editor.drawPosSelection();
});
editor.exchangePos(editor.pos, editor.lastRightButtonPos[1]);
}
var clearEvent = document.getElementById('clearEvent');
clearEvent.onmousedown = function (e) {
e.stopPropagation();
_clearPoint(false);
reDo = null;
editor.clearPos(false);
}
var clearLoc = document.getElementById('clearLoc');
clearLoc.onmousedown = function(e){
e.stopPropagation();
_clearPoint(true);
reDo = null;
editor.clearPos(true);
}
var brushMod=document.getElementById('brushMod');
@ -689,8 +780,14 @@ editor.constructor.prototype.listen=function () {
}
var brushMod3=document.getElementById('brushMod3');
if(brushMod3)brushMod3.onchange=function(){
editor.brushMod=brushMod3.value;
if(brushMod3) {
brushMod3.onchange=function(){
// tip.showHelp(5)
tip.isSelectedBlock(false)
tip.msgs[11] = String('tileset贴图模式下可以按选中tileset素材并在地图上拖动来一次绘制一个区域');
tip.whichShow(12);
editor.brushMod=brushMod3.value;
}
}
var bgc = document.getElementById('bg'), fgc = document.getElementById('fg'),
@ -737,10 +834,31 @@ editor.constructor.prototype.listen=function () {
}
var viewportButtons=document.getElementById('viewportButtons');
var pressTimer = null;
for(var ii=0,node;node=viewportButtons.children[ii];ii++){
(function(x,y){
node.onclick=function(){
editor.moveViewport(x,y);
var move = function () {
editor.moveViewport(x, y);
}
node.onmousedown = function () {
clearTimeout(pressTimer);
pressTimer = setTimeout(function () {
pressTimer = -1;
var f = function () {
if (pressTimer != null) {
move();
setTimeout(f, 150);
}
}
f();
}, 500);
};
node.onmouseup = function () {
if (pressTimer > 0) {
clearTimeout(pressTimer);
move();
}
pressTimer = null;
}
})([-1,0,0,1][ii],[0,-1,1,0][ii]);
}

View File

@ -568,11 +568,14 @@ editor_unsorted_2_wrapper=function(editor_mode){
});
}
editor_mode.change = function (value) {
editor_mode.onmode('nextChange');
editor_mode.onmode(value);
if(editor.isMobile)editor.showdataarea(false);
}
var editModeSelect = document.getElementById('editModeSelect');
editModeSelect.onchange = function () {
editor_mode.onmode('nextChange');
editor_mode.onmode(editModeSelect.value);
if(editor.isMobile)editor.showdataarea(false);
editor_mode.change(editModeSelect.value);
}
editor_mode.checkUnique = function (thiseval) {

View File

@ -206,13 +206,20 @@ printf = function (str_, type) {
printe = function (str_) {
printf(str_, 'error')
}
tip_in_showMode = [
'涉及图片的更改需要F5刷新浏览器来生效',
'文本域可以通过双击,在文本编辑器或事件编辑器中编辑',
'事件编辑器中的显示文本和自定义脚本的方块也可以双击',
"画出的地图要点击\"保存地图\"才会写入到文件中",
];
tip=document.getElementById('tip')
tip.showHelp = function(value) {
var tips = [
'表格的文本域可以双击进行编辑',
'双击地图可以选中素材,右键可以弹出菜单',
'双击事件编辑器的图块可以进行长文本编辑/脚本编辑/地图选点/UI绘制预览等操作',
'ESC或点击空白处可以自动保存当前修改',
'H键可以打开操作帮助哦',
'tileset贴图模式下可以按选中tileset素材并在地图上拖动来一次绘制一个区域',
'可以拖动地图上的图块和事件或按Ctrl+C, Ctrl+X和Ctrl+V进行复制剪切和粘贴Delete删除'
];
if (value == null) value = Math.floor(Math.random() * tips.length);
printf('tips: ' + tips[value])
}
tip._infos= {}
tip.infos=function(value){
if(value!=null){
@ -367,3 +374,201 @@ selectBox.isSelected=function(value){
return selectBox._isSelected
}
// ------ UI预览 & 地图选点相关 ------ //
uievent = {
elements: {},
values: {},
isOpen: false,
mode: ""
};
uievent.elements.div = document.getElementById('uieventDiv');
uievent.elements.title = document.getElementById('uieventTitle');
uievent.elements.yes = document.getElementById('uieventYes');
uievent.elements.no = document.getElementById('uieventNo');
uievent.elements.selectBackground = document.getElementById('uieventBackground');
uievent.elements.selectPoint = document.getElementById('selectPoint');
uievent.elements.selectFloor = document.getElementById('selectPointFloor');
uievent.elements.selectPointBox = document.getElementById('selectPointBox');
uievent.elements.body = document.getElementById('uieventBody');
uievent.elements.selectPointButtons = document.getElementById('selectPointButtons');
uievent.confirm = function () {
var callback = uievent.values.callback, floorId = uievent.values.floorId,
x = uievent.values.x, y = uievent.values.y;
uievent.close();
if (callback) {
callback(floorId, x, y);
}
}
uievent.elements.yes.onclick = uievent.confirm;
uievent.close = function () {
uievent.isOpen = false;
uievent.elements.div.style.display = 'none';
uievent.values = {};
}
uievent.elements.no.onclick = uievent.close;
uievent.elements.selectBackground.onchange = function () {
uievent.drawPreviewUI();
}
uievent.drawPreviewUI = function () {
core.setAlpha('uievent', 1);
core.clearMap('uievent');
// 绘制UI
var background = uievent.elements.selectBackground.value;
if (background == 'thumbnail') {
core.drawThumbnail(editor.currentFloorId, null, {}, 'uievent');
}
else {
core.fillRect('uievent', 0, 0, core.__PIXELS__, core.__PIXELS__, background);
}
if (uievent.values.list instanceof Array) {
uievent.values.list.forEach(function (data) {
var type = data.type;
if (!type || !core.ui["_uievent_"+type]) return;
core.ui["_uievent_"+type](data);
})
}
}
uievent.previewUI = function (list) {
uievent.isOpen = true;
uievent.elements.div.style.display = 'block';
uievent.mode = 'previewUI';
uievent.elements.selectPoint.style.display = 'none';
uievent.elements.yes.style.display = 'none';
uievent.elements.title.innerText = 'UI绘制预览';
uievent.elements.selectBackground.style.display = 'inline';
uievent.elements.selectBackground.value = 'thumbnail';
uievent.elements.selectPointBox.style.display = 'none';
uievent.values.list = list;
uievent.drawPreviewUI();
}
uievent.selectPoint = function (floorId, x, y, hideFloor, callback) {
uievent.values.hideFloor = hideFloor;
uievent.values.callback = callback;
uievent.values.size = editor.isMobile ? window.innerWidth / core.__SIZE__ : 32;
uievent.elements.selectPointBox.style.width = (uievent.values.size - 6) + "px";
uievent.elements.selectPointBox.style.height = (uievent.values.size - 6) + "px";
uievent.isOpen = true;
uievent.elements.div.style.display = 'block';
uievent.mode = 'selectPoint';
uievent.elements.selectPoint.style.display = 'block';
uievent.elements.yes.style.display = 'inline';
uievent.elements.selectBackground.style.display = 'none';
uievent.elements.selectFloor.style.display = hideFloor ? 'none': 'inline';
uievent.elements.selectPointBox.style.display = 'block';
// Append children
var floors = "";
core.floorIds.forEach(function (f) {
floors += "<option value="+f+">"+f+"</option>";
})
uievent.elements.selectFloor.innerHTML = floors;
this.setPoint(floorId || editor.currentFloorId, core.calValue(x) || 0, core.calValue(y) || 0);
}
uievent.updateSelectPoint = function (redraw) {
uievent.elements.title.innerText = '地图选点 ('+uievent.values.x+","+uievent.values.y+')';
if (redraw) {
core.setAlpha('uievent', 1);
core.clearMap('uievent');
core.drawThumbnail(uievent.values.floorId, null, null,
{ctx: 'uievent', centerX: uievent.values.left + core.__HALF_SIZE__,
centerY: uievent.values.top + core.__HALF_SIZE__});
}
uievent.elements.selectPointBox.style.left = uievent.values.size * (uievent.values.x - uievent.values.left) + "px";
uievent.elements.selectPointBox.style.top = uievent.values.size * (uievent.values.y - uievent.values.top) + "px";
}
uievent.setPoint = function (floorId, x, y) {
if (core.floorIds.indexOf(floorId) == -1) floorId = editor.currentFloorId;
uievent.values.floorId = floorId;
uievent.elements.selectFloor.value = floorId;
uievent.values.x = x != null ? x : ( uievent.values.x || 0);
uievent.values.y = y != null ? y : ( uievent.values.y || 0);
uievent.values.width = core.floors[uievent.values.floorId].width || core.__SIZE__;
uievent.values.height = core.floors[uievent.values.floorId].height || core.__SIZE__;
uievent.values.left = core.clamp(uievent.values.x - core.__HALF_SIZE__, 0, uievent.values.width - core.__SIZE__);
uievent.values.top = core.clamp(uievent.values.y - core.__HALF_SIZE__, 0, uievent.values.height - core.__SIZE__);
uievent.updateSelectPoint(true);
}
uievent.elements.selectFloor.onchange = function () {
uievent.setPoint(uievent.elements.selectFloor.value);
}
uievent.elements.selectPointBox.onclick = function (e) {
e.stopPropagation();
}
uievent.elements.body.onclick = function (e) {
if (uievent.mode != 'selectPoint') return;
uievent.values.x = uievent.values.left + Math.floor(e.offsetX / uievent.values.size);
uievent.values.y = uievent.values.top + Math.floor(e.offsetY / uievent.values.size);
uievent.updateSelectPoint(false);
}
uievent.move = function (dx, dy) {
if (uievent.mode != 'selectPoint') return;
uievent.values.left = core.clamp(uievent.values.left + dx, 0, uievent.values.width - core.__SIZE__);
uievent.values.top = core.clamp(uievent.values.top + dy, 0, uievent.values.height - core.__SIZE__);
this.updateSelectPoint(true);
};
(function() {
var viewportButtons = uievent.elements.selectPointButtons;
var pressTimer = null;
for(var ii=0,node;node=viewportButtons.children[ii];ii++){
(function(x,y){
var move = function () {
uievent.move(x, y);
}
node.onmousedown = function () {
clearTimeout(pressTimer);
pressTimer = setTimeout(function () {
pressTimer = -1;
var f = function () {
if (pressTimer != null) {
move();
setTimeout(f, 150);
}
}
f();
}, 500);
};
node.onmouseup = function () {
if (pressTimer > 0) {
clearTimeout(pressTimer);
move();
}
pressTimer = null;
}
})([-1,0,0,1][ii],[0,-1,1,0][ii]);
}
})();
uievent.elements.div.onmousewheel = function (e) {
if (uievent.mode != 'selectPoint' || uievent.values.hideFloor) return;
var index = core.floorIds.indexOf(uievent.values.floorId);
try {
if (e.wheelDelta)
index+=Math.sign(e.wheelDelta);
else if (e.detail)
index+=Math.sign(e.detail);
} catch (ee) { main.log(ee); }
index = core.clamp(index, 0, core.floorIds.length - 1);
uievent.setPoint(core.floorIds[index]);
}

View File

@ -225,6 +225,12 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"_range": "false",
"_data": "图块类别"
},
"name": {
"_leaf": true,
"_type": "textarea",
"_string": true,
"_data": "图块名称"
},
"trigger": {
"_leaf": true,
"_type": "select",

View File

@ -63,6 +63,12 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"_string": true,
"_data": "标题样式:可以改变颜色,也可以写\"display: none\"来隐藏标题"
},
"startButtonsStyle": {
"_leaf": true,
"_type": "textarea",
"_string": true,
"_data": "标题界面按钮的样式caret-color指的是当前选中项的边框颜色"
},
"levelChoose": {
"_leaf": true,
"_type": "textarea",
@ -515,7 +521,13 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"_leaf": true,
"_type": "checkbox",
"_bool": "bool",
"_data": "是否需要在楼梯边使用传送器"
"_data": "传送器是否需要在楼梯边使用如果flyRecordPosition开启则此项对箭头也有效。"
},
"flyRecordPosition": {
"_leaf": true,
"_type": "checkbox",
"_bool": "bool",
"_data": "传送器平面塔模式;此模式下楼层传送器将飞到上次离开该楼层的位置。"
},
"pickaxeFourDirections": {
"_leaf": true,
@ -542,11 +554,17 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"_data": "如果此项为true则视为钥匙盒红黄蓝钥匙+1若为false则视为大黄门钥匙"
},
"steelDoorWithoutKey": {
"_left": true,
"_leaf": true,
"_type": "checkbox",
"_bool": "bool",
"_data": "铁门是否不需要钥匙开启。如果此项为true则无需钥匙也可以开铁门。"
},
"itemFirstText": {
"_leaf": true,
"_type": "checkbox",
"_bool": "bool",
"_data": "首次获得道具是否提示"
},
"equipment": {
"_leaf": true,
"_type": "checkbox",
@ -685,6 +703,12 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"_bool": "bool",
"_data": "是否在经过领域/夹击/路障等伤害后禁用快捷商店。"
},
"blurFg": {
"_leaf": true,
"_type": "checkbox",
"_bool": "bool",
"_data": "是否虚化前景层;如果此项开启,则在游戏中事件层有东西(如宝石等)时虚化前景层。"
},
"checkConsole": {
"_leaf": true,
"_type": "checkbox",

60
_server/thirdparty/LICENSE.md vendored Normal file
View File

@ -0,0 +1,60 @@
/* jsColor */
The MIT License (MIT)
Copyright (c) 2014 Peter Dematté
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
/* awesomplete */
The MIT License (MIT)
Copyright (c) 2015 Lea Verou
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
/* caret-position */
The MIT License (MIT)
Copyright (c) 2015 Jonathan Ong me@jongleberry.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

104
_server/thirdparty/awesomplete.css vendored Normal file
View File

@ -0,0 +1,104 @@
.awesomplete [hidden] {
display: none;
}
.awesomplete .visually-hidden {
position: absolute;
clip: rect(0, 0, 0, 0);
}
.awesomplete {
display: inline-block;
position: relative;
}
.awesomplete > input {
display: block;
}
.awesomplete > ul {
position: absolute;
left: 0;
z-index: 1;
box-sizing: border-box;
list-style: none;
padding: 0;
margin: 0;
background: #fff;
}
.awesomplete > ul:empty {
display: none;
}
.awesomplete > ul {
border-radius: .3em;
margin: .8em 0 0;
background: hsla(0,0%,100%,.9);
background: linear-gradient(to bottom right, white, hsla(0,0%,100%,.8));
border: 1px solid rgba(0,0,0,.3);
box-shadow: .05em .2em .6em rgba(0,0,0,.2);
text-shadow: none;
}
@supports (transform: scale(0)) {
.awesomplete > ul {
transition: .3s cubic-bezier(.4,.2,.5,1.4);
transform-origin: 1.43em -.43em;
}
.awesomplete > ul[hidden],
.awesomplete > ul:empty {
opacity: 0;
transform: scale(0);
display: block;
transition-timing-function: ease;
}
}
/* Pointer */
.awesomplete > ul:before {
content: "";
position: absolute;
top: -.43em;
left: 1em;
width: 0; height: 0;
padding: .4em;
background: white;
border: inherit;
border-right: 0;
border-bottom: 0;
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
.awesomplete > ul > li {
position: relative;
padding: .2em .5em;
cursor: pointer;
word-break: keep-all;
}
.awesomplete > ul > li:hover {
background: hsl(200, 40%, 80%);
color: black;
}
.awesomplete > ul > li[aria-selected="true"] {
background: hsl(205, 40%, 40%);
color: white;
}
.awesomplete mark {
background: hsl(65, 100%, 50%);
}
.awesomplete li:hover mark {
background: hsl(68, 100%, 41%);
}
.awesomplete li[aria-selected="true"] mark {
background: hsl(86, 100%, 21%);
color: inherit;
}
/*# sourceMappingURL=awesomplete.css.map */

3
_server/thirdparty/awesomplete.min.js vendored Normal file

File diff suppressed because one or more lines are too long

155
_server/thirdparty/caret-position.js vendored Normal file
View File

@ -0,0 +1,155 @@
/* jshint browser: true */
(function () {
// We'll copy the properties below into the mirror div.
// Note that some browsers, such as Firefox, do not concatenate properties
// into their shorthand (e.g. padding-top, padding-bottom etc. -> padding),
// so we have to list every single property explicitly.
var properties = [
'direction', // RTL support
'boxSizing',
'width', // on Chrome and IE, exclude the scrollbar, so the mirror div wraps exactly as the textarea does
'height',
'overflowX',
'overflowY', // copy the scrollbar for IE
'borderTopWidth',
'borderRightWidth',
'borderBottomWidth',
'borderLeftWidth',
'borderStyle',
'paddingTop',
'paddingRight',
'paddingBottom',
'paddingLeft',
// https://developer.mozilla.org/en-US/docs/Web/CSS/font
'fontStyle',
'fontVariant',
'fontWeight',
'fontStretch',
'fontSize',
'fontSizeAdjust',
'lineHeight',
'fontFamily',
'textAlign',
'textTransform',
'textIndent',
'textDecoration', // might not make a difference, but better be safe
'letterSpacing',
'wordSpacing',
'tabSize',
'MozTabSize'
];
var isBrowser = (typeof window !== 'undefined');
var isFirefox = (isBrowser && window.mozInnerScreenX != null);
function getCaretCoordinates(element, position, options) {
if (!isBrowser) {
throw new Error('textarea-caret-position#getCaretCoordinates should only be called in a browser');
}
var debug = options && options.debug || false;
if (debug) {
var el = document.querySelector('#input-textarea-caret-position-mirror-div');
if (el) el.parentNode.removeChild(el);
}
// The mirror div will replicate the textarea's style
var div = document.createElement('div');
div.id = 'input-textarea-caret-position-mirror-div';
document.body.appendChild(div);
var style = div.style;
var computed = window.getComputedStyle ? window.getComputedStyle(element) : element.currentStyle; // currentStyle for IE < 9
var isInput = element.nodeName === 'INPUT';
// Default textarea styles
style.whiteSpace = 'nowrap';
if (!isInput)
style.wordWrap = 'break-word'; // only for textarea-s
// Position off-screen
style.position = 'absolute'; // required to return coordinates properly
if (!debug)
style.visibility = 'hidden'; // not 'display: none' because we want rendering
// Transfer the element's properties to the div
properties.forEach(function (prop) {
if (isInput && prop === 'lineHeight') {
// Special case for <input>s because text is rendered centered and line height may be != height
if (computed.boxSizing === "border-box") {
var height = parseInt(computed.height);
var outerHeight =
parseInt(computed.paddingTop) +
parseInt(computed.paddingBottom) +
parseInt(computed.borderTopWidth) +
parseInt(computed.borderBottomWidth);
var targetHeight = outerHeight + parseInt(computed.lineHeight);
if (height > targetHeight) {
style.lineHeight = height - outerHeight + "px";
} else if (height === targetHeight) {
style.lineHeight = computed.lineHeight;
} else {
style.lineHeight = 0;
}
} else {
style.lineHeight = computed.height;
}
} else {
style[prop] = computed[prop];
}
});
if (isFirefox) {
// Firefox lies about the overflow property for textareas: https://bugzilla.mozilla.org/show_bug.cgi?id=984275
if (element.scrollHeight > parseInt(computed.height))
style.overflowY = 'scroll';
} else {
style.overflow = 'hidden'; // for Chrome to not render a scrollbar; IE keeps overflowY = 'scroll'
}
div.textContent = element.value.substring(0, position);
// The second special handling for input type="text" vs textarea:
// spaces need to be replaced with non-breaking spaces - http://stackoverflow.com/a/13402035/1269037
if (isInput)
div.textContent = div.textContent.replace(/\s/g, '\u00a0');
var span = document.createElement('span');
// Wrapping must be replicated *exactly*, including when a long word gets
// onto the next line, with whitespace at the end of the line before (#7).
// The *only* reliable way to do that is to copy the *entire* rest of the
// textarea's content into the <span> created at the caret position.
// For inputs, just '.' would be enough, but no need to bother.
span.textContent = element.value.substring(position) || '.'; // || because a completely empty faux span doesn't render at all
div.appendChild(span);
var coordinates = {
top: span.offsetTop + parseInt(computed['borderTopWidth']),
left: span.offsetLeft + parseInt(computed['borderLeftWidth']),
height: parseInt(computed['lineHeight'])
};
if (debug) {
span.style.backgroundColor = '#aaa';
} else {
document.body.removeChild(div);
}
return coordinates;
}
if (typeof module != 'undefined' && typeof module.exports != 'undefined') {
module.exports = getCaretCoordinates;
} else if(isBrowser) {
window.getCaretCoordinates = getCaretCoordinates;
}
}());

View File

@ -1,3 +1,5 @@
// ------ ColorPicker ------ //
(function (window) {
window.jsColorPicker = function(selectors, config) {
var renderCallback = function(colors, mode) {
@ -254,7 +256,7 @@
})(this);
// Added
var colors = jsColorPicker('input.color', {
jsColorPicker('input.color', {
customBG: '#222',
readOnly: false,
// patch: false,
@ -303,85 +305,5 @@ function triggerColorPicker(left, top) {
}
}
Blockly.FieldColour.prototype.createWidget_ = function() {
Blockly.WidgetDiv.hide();
// ------ AutoCompletion ------
// console.log('here')
var self=this;
var pb=self.sourceBlock_
var args = MotaActionBlocks[pb.type].args
var targetf=args[args.indexOf(self.name)-1]
var getValue=function(){
// return self.getValue() // css颜色
return pb.getFieldValue(targetf);
// 也可以用 pb.getFieldValue(targetf) 获得颜色块左边的域的内容
}
var setValue=function(newValue){ // css颜色
self.setValue(newValue)
var c=new Colors();
c.setColor(newValue)
var rgbatext = [c.colors.webSmart.r,c.colors.webSmart.g,c.colors.webSmart.b,c.colors.alpha].join(",");
pb.setFieldValue(rgbatext, targetf) // 放在颜色块左边的域中
}
setTimeout(function () {
document.getElementById("colorPicker").value = getValue();
window.jsColorPicker.confirm = setValue;
// 设置位置
triggerColorPicker(Blockly.WidgetDiv.DIV.style.left, Blockly.WidgetDiv.DIV.style.top);
});
return document.createElement('table');
};
Blockly.FieldTextInput.prototype.showInlineEditor_ = function(quietInput) {
Blockly.WidgetDiv.show(this, this.sourceBlock_.RTL, this.widgetDispose_());
var div = Blockly.WidgetDiv.DIV;
// Create the input.
var htmlInput =
goog.dom.createDom(goog.dom.TagName.INPUT, 'blocklyHtmlInput');
htmlInput.setAttribute('spellcheck', this.spellcheck_);
var fontSize =
(Blockly.FieldTextInput.FONTSIZE * this.workspace_.scale) + 'pt';
div.style.fontSize = fontSize;
htmlInput.style.fontSize = fontSize;
Blockly.FieldTextInput.htmlInput_ = htmlInput;
div.appendChild(htmlInput);
htmlInput.value = htmlInput.defaultValue = this.text_;
htmlInput.oldValue_ = null;
this.validate_();
this.resizeEditor_();
if (!quietInput) {
htmlInput.focus();
htmlInput.select();
}
// console.log('here')
var self=this;
var pb=self.sourceBlock_
var args = MotaActionBlocks[pb.type].args
var targetf=args[args.indexOf(self.name)+1]
if(targetf && targetf.slice(0,7)==='Colour_'){
var inputDom = htmlInput;
// var getValue=function(){ // 获得自己的字符串
// return pb.getFieldValue(self.name);
// }
var setValue = function(newValue){ // 设置右边颜色块的css颜色
pb.setFieldValue(newValue, targetf)
}
// 给inputDom绑事件
inputDom.oninput=function(){
var value=inputDom.value
if(/[0-9 ]+,[0-9 ]+,[0-9 ]+(,[0-9. ]+)?/.test(value)){
setValue('rgba('+value+')')
}
}
}
this.bindEvents_(htmlInput);
};

View File

@ -1 +0,0 @@
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(0,function(){"use strict";function e(){}function n(e,n){for(;3===e._state;)e=e._value;0!==e._state?(e._handled=!0,f._immediateFn(function(){var i=1===e._state?n.onFulfilled:n.onRejected;if(null!==i){var r;try{r=i(e._value)}catch(e){return void o(n.promise,e)}t(n.promise,r)}else(1===e._state?t:o)(n.promise,e._value)})):e._deferreds.push(n)}function t(e,n){try{if(n===e)throw new TypeError("A promise cannot be resolved with itself.");if(n&&("object"==typeof n||"function"==typeof n)){var t=n.then;if(n instanceof f)return e._state=3,e._value=n,void i(e);if("function"==typeof t)return void r(function(e,n){return function(){e.apply(n,arguments)}}(t,n),e)}e._state=1,e._value=n,i(e)}catch(n){o(e,n)}}function o(e,n){e._state=2,e._value=n,i(e)}function i(e){2===e._state&&0===e._deferreds.length&&f._immediateFn(function(){e._handled||f._unhandledRejectionFn(e._value)});for(var t=0,o=e._deferreds.length;o>t;t++)n(e,e._deferreds[t]);e._deferreds=null}function r(e,n){var i=!1;try{e(function(e){i||(i=!0,t(n,e))},function(e){i||(i=!0,o(n,e))})}catch(e){if(i)return;i=!0,o(n,e)}}function f(e){if(!(this instanceof f))throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],r(e,this)}var u=setTimeout,c=f.prototype;c.catch=function(e){return this.then(null,e)},c.then=function(t,o){var i=new this.constructor(e);return n(this,new function(e,n,t){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof n?n:null,this.promise=t}(t,o,i)),i},f.all=function(e){return new f(function(n,t){function o(e,f){try{if(f&&("object"==typeof f||"function"==typeof f)){var u=f.then;if("function"==typeof u)return void u.call(f,function(n){o(e,n)},t)}i[e]=f,0==--r&&n(i)}catch(e){t(e)}}if(!e||void 0===e.length)throw new TypeError("Promise.all accepts an array");var i=Array.prototype.slice.call(e);if(0===i.length)return n([]);for(var r=i.length,f=0;i.length>f;f++)o(f,i[f])})},f.resolve=function(e){return e&&"object"==typeof e&&e.constructor===f?e:new f(function(n){n(e)})},f.reject=function(e){return new f(function(n,t){t(e)})},f.race=function(e){return new f(function(n,t){for(var o=0,i=e.length;i>o;o++)e[o].then(n,t)})},f._immediateFn="function"==typeof setImmediate&&function(e){setImmediate(e)}||function(e){u(e,0)},f._unhandledRejectionFn=function(e){void 0!==console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)};var a=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==a)return a;throw Error("unable to locate global object")}();a.Promise||(a.Promise=f)});

File diff suppressed because one or more lines are too long

View File

@ -5,6 +5,7 @@
<meta name="viewport" content="width=device-width,minimum-scale=1,maximum-scale=1,initial-scale=1,user-scalable=no" />
<link href="_server/css/editor_mobile.css" rel="stylesheet">
<link href="_server/CodeMirror/codemirror.css" rel="stylesheet">
<link href="_server/thirdparty/awesomplete.css" rel="stylesheet">
<link href="_server/css/editor_mode_mobile.css" rel="stylesheet">
</head>
<body>
@ -216,6 +217,7 @@
<input class="color" id="colorPicker" value="255,215,0,1"/>
<button onclick="confirmColor()">确定</button>
</div>
<button class="cpPanel" onclick="editor_blockly.selectPoint()">选点</button>
<xml id="toolbox" style="display:none">
</xml>
</h3>
@ -296,7 +298,7 @@
<canvas class='gameCanvas' id='event2' width='416' height='416'></canvas>
<canvas class='gameCanvas' id='fg' width='416' height='416'></canvas>
<canvas class='gameCanvas' id='efg' width='416' height='416'></canvas>
<canvas class='egameCanvas' id='eui' width='416' height='416' style='z-index:100'></canvas>
<canvas class='gameCanvas' id='eui' width='416' height='416' style='z-index:100'></canvas>
</div>
</div>
@ -307,6 +309,7 @@
<div id='dataSelection' style="display:none"></div>
</div>
</div>
<button id="iconExpandBtn"></button>
</div>
<div id="down">
<div style="margin:0.5rem">
@ -512,9 +515,10 @@
<canvas class='gameCanvas' id='curtain' width='416' height='416'></canvas>
<canvas class='gameCanvas' id='ui' width='416' height='416'></canvas>
<canvas class='gameCanvas' id='data' width='416' height='416'>此浏览器不支持HTML5</canvas>
<div id="next"></div>
</div>
</div>
<div id='inputBackground' style='display: none'>
<div id='inputDiv' style='display: none'>
<div id='inputDialog'>
<p id="inputMessage">请输入文字...</p>
<input id='inputBox' type="text"/>
@ -522,6 +526,35 @@
<button id='inputNo'>取消</button>
</div>
</div>
<!-- UI预览 & 地图选点 -->
<div id='uieventDiv' style='display: none'>
<div id='uieventDialog'>
<div id="uieventHead">
<span id="uieventTitle"></span>
<select id="uieventBackground" style="margin-left: 20px">
<option value="thumbnail" selected>缩略图</option>
<option value="#000000">黑色</option>
<option value="#FFFFFF">白色</option>
</select>
<button id="uieventNo">关闭</button>
<button id="uieventYes">确定</button>
</div>
<hr style="clear: both; margin-top: 0"/>
<div id='uieventBody'>
<canvas class='gameCanvas' id='uievent' width='416' height='416'></canvas>
<div id="selectPointBox"></div>
</div>
<div id="selectPoint">
<select id="selectPointFloor"></select>
<div id="selectPointButtons">
<input type="button" value="←"/>
<input type="button" value="↑"/>
<input type="button" value="↓"/>
<input type="button" value="→"/>
</div>
</div>
</div>
</div>
<!-- */</script> -->
<!-- =========================================================== -->
@ -567,9 +600,11 @@
<script src="_server/CodeMirror/jshint.min.js"></script>
<script src="_server/CodeMirror/beautify.min.js"></script>
<script src="_server/CodeMirror/codeMirror.plugin.min.js"></script>
<!-- colorPicker -->
<script type="text/javascript" src="_server/colorPicker/color.all.min.js"></script>
<script type="text/javascript" src="_server/colorPicker/jsColor.js"></script>
<!-- thirdparty -->
<script src="_server/thirdparty/color.all.min.js"></script>
<script src="_server/thirdparty/awesomplete.min.js"></script>
<script src="_server/thirdparty/caret-position.js"></script>
<script src="_server/thirdparty/jsColor.js"></script>
</body>
</html>

View File

@ -4,6 +4,7 @@
<meta charset="utf-8">
<link href="_server/css/editor.css" rel="stylesheet">
<link href="_server/CodeMirror/codemirror.css" rel="stylesheet">
<link href="_server/thirdparty/awesomplete.css" rel="stylesheet">
<link href="_server/css/editor_mode.css" rel="stylesheet">
</head>
<body>
@ -211,6 +212,7 @@
<input class="color" id="colorPicker" value="255,215,0,1"/>
<button onclick="confirmColor()">确定</button>
</div>
<button class="cpPanel" onclick="editor_blockly.selectPoint()" style="margin-left:5px">地图选点</button>
</div>
<xml id="toolbox" style="display:none">
</xml>
@ -292,7 +294,7 @@
<canvas class='gameCanvas' id='event2' width='416' height='416'></canvas>
<canvas class='gameCanvas' id='fg' width='416' height='416'></canvas>
<canvas class='gameCanvas' id='efg' width='416' height='416'></canvas>
<canvas class='egameCanvas' id='eui' width='416' height='416' style='z-index:100'></canvas>
<canvas class='gameCanvas' id='eui' width='416' height='416' style='z-index:100'></canvas>
</div>
<div class="tools">
<div id="tip">
@ -351,6 +353,7 @@
<div id='dataSelection' style="display:none"></div>
</div>
</div>
<button id="iconExpandBtn"></button>
</div>
<div id="menuDiv">
<div id="midMenu" style="display:none">
@ -495,9 +498,10 @@
<canvas class='gameCanvas' id='curtain' width='416' height='416'></canvas>
<canvas class='gameCanvas' id='ui' width='416' height='416'></canvas>
<canvas class='gameCanvas' id='data' width='416' height='416'>此浏览器不支持HTML5</canvas>
<div id="next"></div>
</div>
</div>
<div id='inputBackground' style='display: none'>
<div id='inputDiv' style='display: none'>
<div id='inputDialog'>
<p id="inputMessage">请输入文字...</p>
<input id='inputBox' type="text"/>
@ -505,6 +509,37 @@
<button id='inputNo'>取消</button>
</div>
</div>
<!-- UI预览 & 地图选点 -->
<div id='uieventDiv' style='display: none'>
<div id='uieventDialog'>
<div id="uieventHead">
<span id="uieventTitle"></span>
<select id="uieventBackground" style="margin-left: 20px">
<option value="thumbnail" selected>缩略图</option>
<option value="#000000">黑色</option>
<option value="#FFFFFF">白色</option>
</select>
<button id="uieventNo">关闭</button>
<button id="uieventYes">确定</button>
</div>
<hr style="clear: both; margin-top: 0"/>
<div id='uieventBody'>
<canvas class='gameCanvas' id='uievent' width='416' height='416'></canvas>
<div id="selectPointBox"></div>
</div>
<div id="selectPoint">
<select id="selectPointFloor"></select>
<div id="selectPointButtons">
<input type="button" value="←"/>
<input type="button" value="↑"/>
<input type="button" value="↓"/>
<input type="button" value="→"/>
</div>
</div>
</div>
</div>
<!-- */</script> -->
<!-- =========================================================== -->
@ -549,9 +584,11 @@
<script src="_server/CodeMirror/jshint.min.js"></script>
<script src="_server/CodeMirror/beautify.min.js"></script>
<script src="_server/CodeMirror/codeMirror.plugin.min.js"></script>
<!-- colorPicker -->
<script type="text/javascript" src="_server/colorPicker/color.all.min.js"></script>
<script type="text/javascript" src="_server/colorPicker/jsColor.js"></script>
<!-- thirdparty -->
<script src="_server/thirdparty/color.all.min.js"></script>
<script src="_server/thirdparty/awesomplete.min.js"></script>
<script src="_server/thirdparty/caret-position.js"></script>
<script src="_server/thirdparty/jsColor.js"></script>
</body>
</html>

View File

@ -147,12 +147,13 @@
<canvas class='gameCanvas' id='curtain' width='416' height='416'></canvas>
<canvas class='gameCanvas' id='ui' width='416' height='416'></canvas>
<canvas class='gameCanvas' id='data' width='416' height='416'>此浏览器不支持HTML5</canvas>
<div id="next"></div>
</div>
</div>
<div id='inputDiv'>
<div id='inputDialog'>
<p id="inputMessage">请输入文字...</p>
<input id='inputBox' type="text"/>
<input id='inputBox' type="text" autocomplete="off"/>
<button id='inputYes'>确定</button>
<button id='inputNo'>取消</button>
</div>

View File

@ -112,8 +112,8 @@ actions.prototype.doRegisteredAction = function (action) {
}
actions.prototype._checkReplaying = function () {
if (core.isReplaying() && core.status.event.id != 'save'
&& (core.status.event.id || "").indexOf('book') != 0 && core.status.event.id != 'viewMaps')
if (core.isReplaying() &&
['save','book','book-detail','viewMaps','toolbox','equipbox','text'].indexOf(core.status.event.id)<0)
return true;
return false;
}
@ -137,6 +137,7 @@ actions.prototype._sys_onkeyDown = function (e) {
return;
}
}
if (e.preventDefault) e.preventDefault();
core.status.holdingKeys.push(e.keyCode);
this.pressKey(e.keyCode);
} else {
@ -170,6 +171,12 @@ actions.prototype._sys_onkeyUp_replay = function (e) {
core.viewMapReplay();
else if (e.keyCode == 78) // N
core.stepReplay();
else if (e.keyCode == 84) // T
core.toolboxReplay();
else if (e.keyCode == 81) // Q
core.equipboxReplay();
else if (e.keyCode == 66) // B
core.drawStatistics();
else if (e.keyCode >= 49 && e.keyCode <= 51) // 1-3
core.setReplaySpeed(e.keyCode - 48);
else if (e.keyCode == 52) // 4
@ -192,6 +199,7 @@ actions.prototype._sys_onkeyUp = function (e) {
break;
}
}
if (e.preventDefault) e.preventDefault();
this.keyUp(e.keyCode, e.altKey);
} else {
if (e.keyCode == 17) core.status.ctrlDown = false;
@ -712,6 +720,16 @@ actions.prototype._sys_onmousewheel = function (direct) {
return;
}
// wait事件
if (core.status.lockControl && core.status.event.id == 'action' && core.status.event.data.type == 'wait') {
core.setFlag('type', 0);
var keycode = direct == 1 ? 33 : 34;
core.setFlag('keycode', keycode);
core.status.route.push("input:" + keycode);
core.doAction();
return;
}
}
////// 长按Ctrl键时 //////
@ -1253,7 +1271,7 @@ actions.prototype._clickShop = function (x, y) {
actions.prototype._keyDownShop = function (keycode) {
// 商店界面长按空格连续购买
if (keycode == 32) {
if (keycode == 32 && core.status.event.selection != core.status.event.data.shop.choices.length) {
this._selectChoices(core.status.event.data.shop.choices.length + 1, keycode, this._clickShop);
return;
}
@ -1266,7 +1284,7 @@ actions.prototype._keyUpShop = function (keycode) {
core.events._exitShop();
return;
}
if (keycode != 32) {
if (keycode != 32 || core.status.event.selection == core.status.event.data.shop.choices.length) {
this._selectChoices(core.status.event.data.shop.choices.length + 1, keycode, this._clickShop);
return;
}
@ -1317,7 +1335,10 @@ actions.prototype._clickToolbox = function (x, y) {
// 装备栏
if (x >= this.LAST - 2 && y == 0) {
core.ui.closePanel();
core.openEquipbox();
if (core.isReplaying())
core.equipboxReplay();
else
core.openEquipbox();
return;
}
if (x >= this.LAST - 2 && y == this.LAST) {
@ -1376,6 +1397,7 @@ actions.prototype._clickToolboxIndex = function (index) {
if (select >= items.length) return;
var itemId = items[select];
if (itemId == core.status.event.data.selectId) {
if (core.isReplaying()) return;
core.events.tryUseItem(itemId);
}
else {
@ -1478,7 +1500,10 @@ actions.prototype._keyDownToolbox = function (keycode) {
actions.prototype._keyUpToolbox = function (keycode) {
if (keycode == 81) {
core.ui.closePanel();
core.openEquipbox();
if (core.isReplaying())
core.equipboxReplay();
else
core.openEquipbox();
return;
}
if (keycode == 84 || keycode == 27 || keycode == 88) {
@ -1498,7 +1523,10 @@ actions.prototype._clickEquipbox = function (x, y) {
// 道具栏
if (x >= this.LAST - 2 && y == 0) {
core.ui.closePanel();
core.openToolbox();
if (core.isReplaying())
core.toolboxReplay();
else
core.openToolbox();
return;
}
// 返回
@ -1547,6 +1575,7 @@ actions.prototype._clickEquipboxIndex = function (index) {
if (index < this.LAST) {
if (index >= core.status.globalAttribute.equipName.length) return;
if (index == core.status.event.selection && core.status.hero.equipment[index]) {
if (core.isReplaying()) return;
core.unloadEquip(index);
core.status.route.push("unEquip:" + index);
}
@ -1554,6 +1583,7 @@ actions.prototype._clickEquipboxIndex = function (index) {
else {
var equips = Object.keys(core.status.hero.items.equips || {}).sort();
if (index == core.status.event.selection) {
if (core.isReplaying()) return;
var equipId = equips[index - this.LAST + (core.status.event.data.page - 1) * this.LAST];
core.loadEquip(equipId);
core.status.route.push("equip:" + equipId);
@ -1645,7 +1675,10 @@ actions.prototype._keyUpEquipbox = function (keycode, altKey) {
}
if (keycode == 84) {
core.ui.closePanel();
core.openToolbox();
if (core.isReplaying())
core.toolboxReplay();
else
core.openToolbox();
return;
}
if (keycode == 81 || keycode == 27 || keycode == 88) {
@ -1838,6 +1871,11 @@ actions.prototype._keyUpSL = function (keycode) {
this._clickSL(this.LAST, this.LAST);
return;
}
if (keycode >= 48 && keycode <= 57) {
if (keycode == 48) keycode = 58;
core.ui.drawSLPanel((keycode - 49) * 1000 + 1);
return;
}
if (keycode == 13 || keycode == 32 || keycode == 67) {
if (offset == 0)
core.doSL("autoSave", core.status.event.id);
@ -1896,8 +1934,6 @@ actions.prototype._clickSwitchs = function (x, y) {
case 7:
return this._clickSwitchs_clickMove();
case 8:
return this._clickSwitchs_ExtendKeyboard();
case 9:
core.status.event.selection = 0;
core.ui.drawSettings();
break;
@ -1962,13 +1998,6 @@ actions.prototype._clickSwitchs_clickMove = function () {
core.ui.drawSwitchs();
}
actions.prototype._clickSwitchs_ExtendKeyboard = function () {
core.platform.extendKeyboard = !core.platform.extendKeyboard;
core.setLocalStorage('extendKeyboard', core.platform.extendKeyboard);
core.updateStatusBar();
core.ui.drawSwitchs();
}
////// 系统设置界面时,放开某个键的操作 //////
actions.prototype._keyUpSwitchs = function (keycode) {
if (keycode == 27 || keycode == 88) {
@ -2078,13 +2107,7 @@ actions.prototype._clickSyncSave_readFile = function () {
}
actions.prototype._clickSyncSave_replay = function () {
if (core.hasFlag('debug')) {
core.drawText("\t[系统提示]调试模式下无法回放录像");
}
else {
core.status.event.selection = 0;
core.ui.drawReplay();
}
core.ui.drawReplay();
}
////// 同步存档界面时,放开某个键的操作 //////
@ -2311,7 +2334,7 @@ actions.prototype._clickReplay_replayRemain = function () {
}
actions.prototype._clickReplay_download = function () {
if (core.hasFlag('debug')) return core.drawText("\t[系统提示]调试模式下无法下载录像");
// if (core.hasFlag('debug')) return core.drawText("\t[系统提示]调试模式下无法下载录像");
core.download(core.firstData.name + "_" + core.formatDate2() + ".h5route", JSON.stringify({
'name': core.firstData.name,
'hard': core.status.hard,

View File

@ -19,7 +19,6 @@ control.prototype._init = function () {
this.registerAnimationFrame("totalTime", false, this._animationFrame_totalTime);
this.registerAnimationFrame("autoSave", true, this._animationFrame_autoSave);
this.registerAnimationFrame("globalAnimate", true, this._animationFrame_globalAnimate);
this.registerAnimationFrame("selector", false, this._animationFrame_selector);
this.registerAnimationFrame("animate", true, this._animationFrame_animate);
this.registerAnimationFrame("heroMoving", true, this._animationFrame_heroMoving);
this.registerAnimationFrame("weather", true, this._animationFrame_weather);
@ -151,19 +150,6 @@ control.prototype._animationFrame_globalAnimate = function (timestamp) {
core.animateFrame.globalTime = timestamp;
}
control.prototype._animationFrame_selector = function (timestamp) {
if (timestamp - core.animateFrame.selectorTime <= 20 || !core.dymCanvas._selector) return;
var opacity = parseFloat(core.dymCanvas._selector.canvas.style.opacity);
if (core.animateFrame.selectorUp)
opacity += 0.02;
else
opacity -= 0.02;
if (opacity > 0.95 || opacity < 0.55)
core.animateFrame.selectorUp = !core.animateFrame.selectorUp;
core.setOpacity("_selector", opacity);
core.animateFrame.selectorTime = timestamp;
}
control.prototype._animationFrame_animate = function (timestamp) {
if (timestamp - core.animateFrame.animateTime < 50 || !core.status.animateObjs || core.status.animateObjs.length == 0) return;
core.clearMap('animate');
@ -333,6 +319,8 @@ control.prototype._showStartAnimate_resetDom = function () {
control.prototype._showStartAnimate_finished = function (start, callback) {
core.dom.startTop.style.display = 'none';
core.dom.startButtonGroup.style.display = 'block';
main.selectedButton = null;
main.selectButton(0);
if (start) core.startGame();
if (callback) callback();
}
@ -566,6 +554,12 @@ control.prototype.setAutoHeroMove = function (steps) {
////// 设置行走的效果动画 //////
control.prototype.setHeroMoveInterval = function (callback) {
if (core.status.heroMoving > 0) return;
if (core.status.replay.speed == 24) {
core.moveOneStep(core.nextX(), core.nextY());
if (callback) callback();
return;
}
core.status.heroMoving=1;
var toAdd = 1;
@ -741,25 +735,28 @@ control.prototype.turnHero = function(direction) {
}
////// 瞬间移动 //////
control.prototype.moveDirectly = function (destX, destY) {
return this.controldata.moveDirectly(destX, destY);
control.prototype.moveDirectly = function (destX, destY, ignoreSteps) {
return this.controldata.moveDirectly(destX, destY, ignoreSteps);
}
////// 尝试瞬间移动 //////
control.prototype.tryMoveDirectly = function (destX, destY) {
if (this.nearHero(destX, destY)) return false;
var canMoveArray = core.maps.generateMovableArray();
var testMove = function (dx, dy, dir) {
if (dx<0 || dx>=core.bigmap.width|| dy<0 || dy>=core.bigmap.height) return false;
if (dir && !core.inArray(canMoveArray[dx][dy],dir)) return false;
if (core.control.moveDirectly(dx, dy)) {
var dirs = [[destX,destY],[destX-1,destY,"right"],[destX,destY-1,"down"],[destX,destY+1,"up"],[destX+1,destY,"left"]];
var canMoveDirectlyArray = core.canMoveDirectlyArray(dirs);
for (var i = 0; i < dirs.length; ++i) {
var d = dirs[i], dx = d[0], dy = d[1], dir = d[2];
if (dx<0 || dx>=core.bigmap.width|| dy<0 || dy>=core.bigmap.height) continue;
if (dir && !core.inArray(canMoveArray[dx][dy],dir)) continue;
if (canMoveDirectlyArray[i]<0) continue;
if (core.control.moveDirectly(dx, dy, canMoveDirectlyArray[i])) {
if (dir) core.moveHero(dir, function() {});
return true;
}
return false;
}
return testMove(destX,destY) || testMove(destX-1, destY, "right") || testMove(destX,destY-1,"down")
|| testMove(destX,destY+1,"up") || testMove(destX+1,destY,"left");
return false;
}
////// 绘制勇士 //////
@ -775,13 +772,16 @@ control.prototype.drawHero = function (status, offset) {
core.clearAutomaticRouteNode(x+dx, y+dy);
core.clearMap('hero');
this._drawHero_getDrawObjs(direction, x, y, status, offset).forEach(function (block) {
core.drawImage('hero', block.img, block.heroIcon[block.status]*block.width,
block.heroIcon.loc * block.height, block.width, block.height,
block.posx+(32-block.width)/2, block.posy+32-block.height, block.width, block.height);
});
if (!core.hasFlag('hideHero')) {
this._drawHero_getDrawObjs(direction, x, y, status, offset).forEach(function (block) {
core.drawImage('hero', block.img, block.heroIcon[block.status]*block.width,
block.heroIcon.loc * block.height, block.width, block.height,
block.posx+(32-block.width)/2, block.posy+32-block.height, block.width, block.height);
});
}
core.control.updateViewport();
core.setGameCanvasTranslate('hero', 0, 0);
}
control.prototype._drawHero_getDrawObjs = function (direction, x, y, status, offset) {
@ -855,6 +855,48 @@ control.prototype.updateViewport = function() {
core.relocateCanvas('route', core.status.automaticRoute.offsetX - core.bigmap.offsetX, core.status.automaticRoute.offsetY - core.bigmap.offsetY);
}
////// 设置视野范围 //////
control.prototype.setViewport = function (x, y) {
core.bigmap.offsetX = core.clamp(x, 0, 32 * core.bigmap.width - core.__PIXELS__);
core.bigmap.offsetY = core.clamp(y, 0, 32 * core.bigmap.height - core.__PIXELS__);
this.updateViewport();
// ------ hero层也需要
var hero_x = core.clamp((core.getHeroLoc('x') - core.__HALF_SIZE__) * 32, 0, 32*core.bigmap.width-core.__PIXELS__);
var hero_y = core.clamp((core.getHeroLoc('y') - core.__HALF_SIZE__) * 32, 0, 32*core.bigmap.height-core.__PIXELS__);
core.control.setGameCanvasTranslate('hero', hero_x - core.bigmap.offsetX, hero_y - core.bigmap.offsetY);
}
////// 移动视野范围 //////
control.prototype.moveViewport = function (steps, time, callback) {
time = time || core.values.moveSpeed || 300;
var step = 0, moveSteps = (steps||[]).filter(function (t) {
return ['up','down','left','right'].indexOf(t)>=0;
});
var animate=window.setInterval(function() {
if (moveSteps.length==0) {
delete core.animateFrame.asyncId[animate];
clearInterval(animate);
if (callback) callback();
}
else {
if (core.control._moveViewport_moving(++step, moveSteps))
step = 0;
}
}, time / 16 / core.status.replay.speed);
core.animateFrame.asyncId[animate] = true;
}
control.prototype._moveViewport_moving = function (step, moveSteps) {
var direction = moveSteps[0], scan = core.utils.scan[direction];
core.setViewport(core.bigmap.offsetX + 2 * scan.x, core.bigmap.offsetY + 2 * scan.y);
if (step == 16) {
moveSteps.shift();
return true;
}
return false;
}
////// 获得勇士面对位置的x坐标 //////
control.prototype.nextX = function(n) {
if (n == null) n = 1;
@ -919,7 +961,7 @@ control.prototype.checkBlock = function () {
if (damage) {
core.status.hero.hp -= damage;
core.drawTip("受到"+(core.status.checkBlock.type[loc]||"伤害")+damage+"点");
this._checkBlock_soundAndAnimate(x, y);
core.drawAnimate("zone", x, y);
this._checkBlock_disableQuickShop();
core.status.hero.statistics.extraDamage += damage;
if (core.status.hero.hp <= 0) {
@ -933,11 +975,6 @@ control.prototype.checkBlock = function () {
this._checkBlock_ambush(core.status.checkBlock.ambush[loc]);
}
control.prototype._checkBlock_soundAndAnimate = function (x,y) {
core.playSound('zone.mp3');
core.drawAnimate("zone", x, y);
}
control.prototype._checkBlock_disableQuickShop = function () {
// 禁用快捷商店
if (core.flags.disableShopOnDamage) {
@ -1197,10 +1234,11 @@ control.prototype.bookReplay = function () {
if (core.isMoving() || core.status.replay.animate
|| (core.status.event.id && core.status.event.id != 'viewMaps'))
return core.drawTip("请等待当前事件的处理结束");
if (!core.hasItem('book')) return core.drawTip('你没有怪物手册');
// 从“浏览地图”页面打开
if (core.status.event.id=='viewMaps')
core.status.event.selection = core.status.event.data;
core.status.event.ui = core.status.event.data;
core.lockControl();
core.status.event.id='book';
@ -1219,6 +1257,28 @@ control.prototype.viewMapReplay = function () {
core.ui.drawMaps();
}
control.prototype.toolboxReplay = function () {
if (!core.isPlaying() || !core.isReplaying()) return;
if (!core.status.replay.pausing) return core.drawTip("请先暂停录像");
if (core.isMoving() || core.status.replay.animate || core.status.event.id)
return core.drawTip("请等待当前事件的处理结束");
core.lockControl();
core.status.event.id='toolbox';
core.ui.drawToolbox();
}
control.prototype.equipboxReplay = function () {
if (!core.isPlaying() || !core.isReplaying()) return;
if (!core.status.replay.pausing) return core.drawTip("请先暂停录像");
if (core.isMoving() || core.status.replay.animate || core.status.event.id)
return core.drawTip("请等待当前事件的处理结束");
core.lockControl();
core.status.event.id='equipbox';
core.ui.drawEquipbox();
}
////// 是否正在播放录像 //////
control.prototype.isReplaying = function () {
return (core.status.replay||{}).replaying;
@ -1286,7 +1346,7 @@ control.prototype._replay_finished = function () {
control.prototype._replay_save = function () {
core.status.replay.steps++;
if (core.status.replay.steps%50==0) {
if (core.status.replay.steps%40==1) {
if (core.status.replay.save.length == 30)
core.status.replay.save.shift();
core.status.replay.save.push({"data": core.saveData(), "replay": {
@ -1325,6 +1385,7 @@ control.prototype._replay_error = function (action) {
}
control.prototype.__replay_getTimeout = function () {
if (core.status.replay.speed == 24) return 0;
return 750 / Math.max(1, core.status.replay.speed);
}
@ -1982,7 +2043,7 @@ control.prototype.unLockControl = function () {
////// 开启debug模式 //////
control.prototype.debug = function() {
core.setFlag('debug', true);
core.drawText("\t[调试模式开启]此模式下按住Ctrl键或Ctrl+Shift键可以穿墙并忽略一切事件。\n同时,录像将失效,也无法上传成绩。");
core.drawText("\t[调试模式开启]此模式下按住Ctrl键或Ctrl+Shift键可以穿墙并忽略一切事件。\n此模式下将无法上传成绩。");
}
// ------ 天气色调BGM ------ //
@ -2309,6 +2370,7 @@ control.prototype._updateStatusBar_setToolboxIcon = function () {
}
control.prototype.showStatusBar = function () {
if (main.mode == 'editor') return;
if (core.domStyle.showStatusBar) return;
var statusItems = core.dom.status;
core.domStyle.showStatusBar = true;
@ -2321,9 +2383,12 @@ control.prototype.showStatusBar = function () {
}
control.prototype.hideStatusBar = function (showToolbox) {
if (main.mode == 'editor') return;
// 如果原本就是隐藏的,则先显示
if (!core.domStyle.showStatusBar)
this.showStatusBar();
if (core.isReplaying()) showToolbox = true;
var statusItems = core.dom.status, toolItems = core.dom.tools;
core.domStyle.showStatusBar = false;
@ -2431,7 +2496,7 @@ control.prototype.setToolbarButton = function (useButton) {
}
if (useButton == null) useButton = core.domStyle.toolbarBtn;
if (!core.domStyle.isVertical || !core.platform.extendKeyboard) useButton = false;
if (!core.domStyle.isVertical || core.isReplaying()) useButton = false;
core.domStyle.toolbarBtn = useButton;
if (useButton) {
@ -2614,6 +2679,11 @@ control.prototype._resize_canvas = function (obj) {
canvas.style.left = parseFloat(canvas.getAttribute("_left")) * core.domStyle.scale + "px";
canvas.style.top = parseFloat(canvas.getAttribute("_top")) * core.domStyle.scale + "px";
}
// resize next
main.dom.next.style.width = main.dom.next.style.height = 5 * core.domStyle.scale + "px";
main.dom.next.style.borderBottomWidth = main.dom.next.style.borderRightWidth = 4 * core.domStyle.scale + "px";
}
control.prototype._resize_statusBar = function (obj) {

View File

@ -72,7 +72,6 @@ function core() {
'isChrome': false, // 是否是Chrome
'supportCopy': false, // 是否支持复制到剪切板
'useLocalForage': true,
'extendKeyboard': false,
'fileInput': null, // FileInput
'fileReader': null, // 是否支持FileReader
@ -278,14 +277,13 @@ core.prototype._init_platform = function () {
}
});
core.platform.string = core.platform.isPC ? "PC" : core.platform.isAndroid ? "Android" : core.platform.isIOS ? "iOS" : "";
core.platform.supportCopy = document.queryCommandSupported || document.queryCommandSupported("copy");
core.platform.supportCopy = document.queryCommandSupported && document.queryCommandSupported("copy");
var chrome = /Chrome\/(\d+)\./i.exec(navigator.userAgent);
if (chrome && parseInt(chrome[1]) >= 50) core.platform.isChrome = true;
core.platform.isSafari = /Safari/i.test(navigator.userAgent) && !/Chrome/i.test(navigator.userAgent);
core.platform.isQQ = /QQ/i.test(navigator.userAgent);
core.platform.isWeChat = /MicroMessenger/i.test(navigator.userAgent);
this._init_checkLocalForage();
core.platform.extendKeyboard = core.getLocalStorage("extendKeyboard", false);
if (window.FileReader) {
core.platform.fileReader = new FileReader();
core.platform.fileReader.onload = function () {

View File

@ -434,7 +434,7 @@ events.prototype._openDoor_animate = function (id, x, y, callback) {
return;
}
core.drawImage('event', core.material.images.animates, 32 * state, 32 * door, 32, 32, 32 * x, 32 * y, 32, 32);
}, speed / Math.max(core.status.replay.speed, 1));
}, core.status.replay.speed == 24 ? 1 : speed / Math.max(core.status.replay.speed, 1));
core.animateFrame.asyncId[animate] = true;
}
@ -458,6 +458,24 @@ events.prototype.getItem = function (id, num, x, y, callback) {
if (num > 1) text += "x" + num;
if (itemCls === 'items') text += core.items.getItemEffectTip(id);
core.drawTip(text, id);
// --- 首次获得道具的提示
if (!core.hasFlag("__itemHint__")) core.setFlag("__itemHint__", []);
var itemHint = core.getFlag("__itemHint__");
if (core.flags.itemFirstText && itemHint.indexOf(id) < 0 && itemCls != 'items') {
var hint = core.material.items[id].text || "该道具暂无描述";
try {
hint = core.replaceText(hint);
} catch (e) {}
core.insertAction("\t["+core.material.items[id].name+","+id+"]" + hint + "\n"
+ (itemCls == 'keys' || id == 'greenKey' || id == 'steelKey' ? "(钥匙类道具,遇到对应的门时自动打开)"
: itemCls == 'tools' ? "消耗类道具请按T在道具栏使用"
: itemCls == 'constants' ? "永久类道具请按T在道具栏使用"
: itemCls == 'equips' ? "装备类道具请按Q在装备栏进行装备" : ""))
itemHint.push(id);
}
core.updateStatusBar();
this.afterGetItem(id, x, y, callback);
@ -510,6 +528,8 @@ events.prototype.changeFloor = function (floorId, stair, heroLoc, time, callback
core.stopAutomaticRoute();
core.clearContinueAutomaticRoute();
core.status.replay.animate = true;
clearInterval(core.interval.onDownInterval);
core.interval.onDownInterval = 'tmp';
this._changeFloor_beforeChange(info, callback);
}
@ -548,8 +568,19 @@ events.prototype._changeFloor_getHeroLoc = function (floorId, stair, heroLoc) {
if (!heroLoc)
heroLoc = core.clone(core.status.hero.loc);
if (stair) {
// --- 对称
if (stair == ':now')
heroLoc = core.clone(core.status.hero.loc);
else if (stair == ':symmetry') {
heroLoc.x = core.bigmap.width - 1 - core.getHeroLoc('x');
heroLoc.y = core.bigmap.height - 1 - core.getHeroLoc('y');
}
else if (stair == ':symmetry_x')
heroLoc.x = core.bigmap.width - 1 - core.getHeroLoc('x');
else if (stair == ':symmetry_y')
heroLoc.y = core.bigmap.height - 1 - core.getHeroLoc('y');
// 检查该层地图的 upFloor & downFloor
if (core.status.maps[floorId][stair]) {
else if (core.status.maps[floorId][stair]) {
heroLoc.x = core.status.maps[floorId][stair][0];
heroLoc.y = core.status.maps[floorId][stair][1];
}
@ -759,7 +790,7 @@ events.prototype.doEvent = function (data, x, y, prefix) {
}
if (this["_action_" + type]) return this["_action_" + type](data, x, y, prefix);
core.insertAction("未知的自定义事件: " + type + "");
core.doAction();
setTimeout(core.doAction);
}
events.prototype.setEvents = function (list, x, y, callback) {
@ -783,16 +814,18 @@ events.prototype.startEvents = function (list, x, y, callback) {
// 停止勇士
core.waitHeroToStop(function () {
core.lockControl();
core.doAction();
setTimeout(core.doAction);
});
}
////// 执行当前自定义事件列表中的下一个事件 //////
events.prototype.doAction = function () {
// 清空boxAnimate和UI层
core.clearUI();
clearInterval(core.status.event.interval);
core.status.event.interval = null;
events.prototype.doAction = function (keepUI) {
if (!keepUI) {
// 清空boxAnimate和UI层
core.clearUI();
clearInterval(core.status.event.interval);
core.status.event.interval = null;
}
// 判定是否执行完毕
if (this._doAction_finishEvents()) return;
// 当前点坐标和前缀
@ -830,7 +863,7 @@ events.prototype._popEvents = function (current, prefix) {
else {
core.status.event.data.list.shift(); // remove stack
}
core.doAction();
setTimeout(core.doAction);
return true;
}
return false;
@ -875,7 +908,7 @@ events.prototype.recoverEvents = function (data) {
core.status.event.id = 'action';
core.status.event.data = data;
setTimeout(function () {
core.doAction();
setTimeout(core.doAction);
}, 30);
return true;
}
@ -886,7 +919,7 @@ events.prototype.recoverEvents = function (data) {
events.prototype.__action_checkReplaying = function () {
if (core.isReplaying()) {
core.doAction();
setTimeout(core.doAction);
return true;
}
return false;
@ -914,7 +947,7 @@ events.prototype.__action_doAsyncFunc = function (isAsync, func) {
var parameters = Array.prototype.slice.call(arguments, 2);
if (isAsync) {
func.apply(this, parameters);
core.doAction();
setTimeout(core.doAction);
}
else {
func.apply(this, parameters.concat(core.doAction));
@ -938,7 +971,7 @@ events.prototype._action_scrollText = function (data, x, y, prefix) {
}
events.prototype._action_comment = function (data, x, y, prefix) {
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_setText = function (data, x, y, prefix) {
@ -959,12 +992,12 @@ events.prototype._action_setText = function (data, x, y, prefix) {
}
});
core.setFlag('textAttribute', core.status.textAttribute);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_tip = function (data, x, y, prefix) {
core.drawTip(core.replaceText(data.text), data.icon);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_show = function (data, x, y, prefix) {
@ -976,7 +1009,7 @@ events.prototype._action_show = function (data, x, y, prefix) {
data.loc.forEach(function (t) {
core.showBlock(t[0], t[1], data.floorId);
});
core.doAction();
setTimeout(core.doAction);
}
}
@ -992,14 +1025,16 @@ events.prototype._action_hide = function (data, x, y, prefix) {
data.loc.forEach(function (t) {
core.removeBlock(t[0], t[1], data.floorId)
});
core.doAction();
setTimeout(core.doAction);
}
}
events.prototype._action_setBlock = function (data, x, y, prefix) {
var loc = this.__action_getLoc(data.loc, x, y, prefix);
core.setBlock(data.number, loc[0], loc[1], data.floorId);
core.doAction();
data.loc = this.__action_getLoc2D(data.loc, x, y, prefix);
data.loc.forEach(function (t) {
core.setBlock(data.number, t[0], t[1], data.floorId);
});
setTimeout(core.doAction);
}
events.prototype._action_showFloorImg = function (data, x, y, prefix) {
@ -1019,19 +1054,21 @@ events.prototype._action_hideBgFgMap = function (data, x, y, prefix) {
}
events.prototype._action_setBgFgBlock = function (data, x, y, prefix) {
var loc = this.__action_getLoc(data.loc, x, y, prefix);
core.setBgFgBlock(data.name, data.number, loc[0], loc[1], data.floorId);
core.doAction();
data.loc = this.__action_getLoc2D(data.loc, x, y, prefix);
data.loc.forEach(function (t) {
core.setBgFgBlock(data.name, data.number, t[0], t[1], data.floorId);
});
setTimeout(core.doAction);
}
events.prototype._action_follow = function (data, x, y, prefix) {
this.follow(data.name);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_unfollow = function (data, x, y, prefix) {
this.unfollow(data.name);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_animate = function (data, x, y, prefix) {
@ -1040,6 +1077,21 @@ events.prototype._action_animate = function (data, x, y, prefix) {
this.__action_doAsyncFunc(data.async, core.drawAnimate, data.name, data.loc[0], data.loc[1]);
}
events.prototype._action_setViewport = function (data, x, y, prefix) {
if (data.loc == null) {
core.drawHero();
}
else {
var loc = this.__action_getLoc(data.loc, x, y, prefix);
core.setViewport(32 * loc[0], 32 * loc[1]);
}
setTimeout(core.doAction);
}
events.prototype._action_moveViewport = function (data, x, y, prefix) {
this.__action_doAsyncFunc(data.async, core.moveViewport, data.steps, data.time);
}
events.prototype._action_move = function (data, x, y, prefix) {
var loc = this.__action_getLoc(data.loc, x, y, prefix);
this.__action_doAsyncFunc(data.async, core.moveBlock, loc[0], loc[1], data.steps, data.time, data.keep);
@ -1073,7 +1125,7 @@ events.prototype._action_changePos = function (data, x, y, prefix) {
core.setHeroLoc('y', loc[1]);
if (data.direction) core.setHeroLoc('direction', data.direction);
core.drawHero();
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_showImage = function (data, x, y, prefix) {
@ -1086,7 +1138,7 @@ events.prototype._action_showTextImage = function (data, x, y, prefix) {
var loc = this.__action_getLoc(data.loc, 0, 0, prefix);
if (core.isReplaying()) data.time = 0;
this.__action_doAsyncFunc(data.async || data.time == 0, core.showImage,
data.code, core.ui.textImage(data.text), loc[0], loc[1], 100, 100, data.opacity, data.time);
data.code, core.ui.textImage(data.text), null, loc, data.opacity, data.time);
}
events.prototype._action_hideImage = function (data, x, y, prefix) {
@ -1097,7 +1149,7 @@ events.prototype._action_hideImage = function (data, x, y, prefix) {
events.prototype._action_showGif = function (data, x, y, prefix) {
var loc = this.__action_getLoc(data.loc, 0, 0, prefix);
this.showGif(data.name, loc[0], loc[1]);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_moveImage = function (data, x, y, prefix) {
@ -1113,12 +1165,12 @@ events.prototype._action_setCurtain = function (data, x, y, prefix) {
if (data.async) {
core.setCurtain(data.color, data.time);
core.setFlag('__color__', data.color || null);
core.doAction();
setTimeout(core.doAction);
}
else {
core.setCurtain(data.color, data.time, function () {
core.setFlag('__color__', data.color || null);
core.doAction();
setTimeout(core.doAction);
});
}
}
@ -1132,7 +1184,7 @@ events.prototype._action_setWeather = function (data, x, y, prefix) {
if (data.name == 'rain' || data.name == 'snow' || data.name == 'fog')
core.setFlag('__weather__', [data.name, data.level]);
else core.removeFlag('__weather__');
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_openDoor = function (data, x, y, prefix) {
@ -1143,7 +1195,7 @@ events.prototype._action_openDoor = function (data, x, y, prefix) {
}
else {
core.removeBlock(loc[0], loc[1], floorId);
core.doAction();
setTimeout(core.doAction);
}
}
@ -1159,7 +1211,7 @@ events.prototype._action_useItem = function (data, x, y, prefix) {
}
else {
core.drawTip("当前无法使用" + ((core.material.items[data.id] || {}).name || "未知道具"));
core.doAction();
setTimeout(core.doAction);
}
}
@ -1169,12 +1221,12 @@ events.prototype._action_openShop = function (data, x, y, prefix) {
if (!core.isReplaying())
this.openShop(data.id);
if (core.status.event.id == 'action')
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_disableShop = function (data, x, y, prefix) {
this.disableQuickShop(data.id);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_battle = function (data, x, y, prefix) {
@ -1200,7 +1252,7 @@ events.prototype._action_trigger = function (data, x, y, prefix) {
return;
}
}
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_insert = function (data, x, y, prefix) {
@ -1225,43 +1277,44 @@ events.prototype._action_insert = function (data, x, y, prefix) {
var event = (core.floors[floorId][which]||[])[loc[0] + "," + loc[1]];
if (event) this.insertAction(event.data || event);
}
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_playBgm = function (data, x, y, prefix) {
core.playBgm(data.name);
core.doAction();
core.setFlag("__bgm__", data.keep ? data.name : null);
setTimeout(core.doAction);
}
events.prototype._action_pauseBgm = function (data, x, y, prefix) {
core.pauseBgm();
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_resumeBgm = function (data, x, y, prefix) {
core.resumeBgm();
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_loadBgm = function (data, x, y, prefix) {
core.loadBgm(data.name);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_freeBgm = function (data, x, y, prefix) {
core.freeBgm(data.name);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_playSound = function (data, x, y, prefix) {
if (data.stop) core.stopSound();
core.playSound(data.name);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_stopSound = function (data, x, y, prefix) {
core.stopSound();
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_setVolume = function (data, x, y, prefix) {
@ -1272,7 +1325,7 @@ events.prototype._action_setVolume = function (data, x, y, prefix) {
events.prototype._action_setValue = function (data, x, y, prefix) {
this.setValue(data.name, data.value, prefix);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_setValue2 = function (data, x, y, prefix) {
@ -1281,32 +1334,32 @@ events.prototype._action_setValue2 = function (data, x, y, prefix) {
events.prototype._action_addValue = function (data, x, y, prefix) {
this.addValue(data.name, data.value, prefix);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_setFloor = function (data, x, y, prefix) {
this.setFloorInfo(data.name, data.value, data.floorId, prefix);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_setGlobalAttribute = function (data, x, y, prefix) {
this.setGlobalAttribute(data.name, data.value);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_setGlobalValue = function (data, x, y, prefix) {
core.values[data.name] = data.value;
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_setGlobalFlag = function (data, x, y, prefix) {
this.setGlobalFlag(data.name, data.value);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_setHeroIcon = function (data, x, y, prefix) {
this.setHeroIcon(data.name);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_input = function (data, x, y, prefix) {
@ -1314,7 +1367,7 @@ events.prototype._action_input = function (data, x, y, prefix) {
value = Math.abs(parseInt(value) || 0);
core.status.route.push("input:" + value);
core.setFlag("input", value);
core.doAction();
setTimeout(core.doAction);
});
}
@ -1323,7 +1376,7 @@ events.prototype._action_input2 = function (data, x, y, prefix) {
value = value || "";
core.status.route.push("input2:" + core.encodeBase64(value));
core.setFlag("input", value);
core.doAction();
setTimeout(core.doAction);
});
}
@ -1353,7 +1406,7 @@ events.prototype._action_if = function (data, x, y, prefix) {
core.events.insertAction(data["true"])
else
core.events.insertAction(data["false"])
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_switch = function (data, x, y, prefix) {
@ -1368,10 +1421,15 @@ events.prototype._action_switch = function (data, x, y, prefix) {
}
}
core.insertAction(list);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_choices = function (data, x, y, prefix) {
data.choices = data.choices.filter(function (x) {
if (x.condition == null || x.condition == '') return true;
try { return core.calValue(x.condition, prefix); } catch (e) { return true; }
})
if (data.choices.length == 0) return this.doAction();
if (core.isReplaying()) {
var action = core.status.replay.toReplay.shift(), index;
// --- 忽略可能的turn事件
@ -1381,8 +1439,8 @@ events.prototype._action_choices = function (data, x, y, prefix) {
setTimeout(function () {
core.status.route.push("choices:" + index);
core.insertAction(data.choices[index].action);
core.doAction();
}, 750 / Math.max(1, core.status.replay.speed))
setTimeout(core.doAction);
}, core.status.replay.speed == 24 ? 1 : 750 / Math.max(1, core.status.replay.speed))
}
else {
core.control._replay_error(action);
@ -1404,8 +1462,8 @@ events.prototype._action_confirm = function (data, x, y, prefix) {
core.status.route.push("choices:" + index);
if (index == 0) core.insertAction(data.yes);
else core.insertAction(data.no);
core.doAction();
}, 750 / Math.max(1, core.status.replay.speed))
setTimeout(core.doAction);
}, core.status.replay.speed == 24 ? 1 : 750 / Math.max(1, core.status.replay.speed))
}
else {
core.control._replay_error(action);
@ -1424,19 +1482,19 @@ events.prototype._action_while = function (data, x, y, prefix) {
{"todo": core.clone(data.data), "total": core.clone(data.data), "condition": data.condition}
);
}
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_dowhile = function (data, x, y, prefix) {
core.unshift(core.status.event.data.list,
{"todo": core.clone(data.data), "total": core.clone(data.data), "condition": data.condition}
);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_break = function (data, x, y, prefix) {
core.status.event.data.list.shift();
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_continue = function (data, x, y, prefix) {
@ -1446,7 +1504,7 @@ events.prototype._action_continue = function (data, x, y, prefix) {
else {
core.status.event.data.list.shift();
}
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_win = function (data, x, y, prefix) {
@ -1471,28 +1529,40 @@ events.prototype._action_function = function (data, x, y, prefix) {
main.log(e);
}
if (!data.async)
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_update = function (data, x, y, prefix) {
core.updateStatusBar();
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_showStatusBar = function (data, x, y, prefix) {
core.showStatusBar();
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_hideStatusBar = function (data, x, y, prefix) {
core.hideStatusBar(data.toolbox);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_showHero = function (data, x, y, prefix) {
core.removeFlag('hideHero');
core.drawHero();
setTimeout(core.doAction);
}
events.prototype._action_hideHero = function (data, x, y, prefix) {
core.setFlag('hideHero', true);
core.drawHero();
setTimeout(core.doAction);
}
events.prototype._action_updateEnemys = function (data, x, y, prefix) {
core.enemys.updateEnemys();
core.updateStatusBar();
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_vibrate = function (data, x, y, prefix) {
@ -1502,7 +1572,7 @@ events.prototype._action_vibrate = function (data, x, y, prefix) {
events.prototype._action_sleep = function (data, x, y, prefix) {
core.timeout.sleepTimeout = setTimeout(function () {
core.timeout.sleepTimeout = null;
core.doAction();
setTimeout(core.doAction);
}, core.isReplaying() ? Math.min(data.time, 20) : data.time);
}
@ -1519,7 +1589,7 @@ events.prototype._action_wait = function (data, x, y, prefix) {
core.stopReplay();
core.insertAction(["录像文件出错,请在控制台查看报错信息。", {"type": "exit"}]);
}
core.doAction();
setTimeout(core.doAction);
return;
}
}
@ -1551,7 +1621,7 @@ events.prototype._action_waitAsync = function (data, x, y, prefix) {
var test = window.setInterval(function () {
if (!core.hasAsync()) {
clearInterval(test);
core.doAction();
setTimeout(core.doAction);
}
}, 50);
}
@ -1560,12 +1630,12 @@ events.prototype._action_revisit = function (data, x, y, prefix) {
var block = core.getBlock(x, y);
if (block != null && block.block.event.trigger == 'action')
this.setEvents(block.block.event.data);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_callBook = function (data, x, y, prefix) {
if (core.isReplaying() || !core.hasItem('book')) {
core.doAction();
setTimeout(core.doAction);
}
else {
var e = core.clone(core.status.event.data);
@ -1578,7 +1648,7 @@ events.prototype._action_callBook = function (data, x, y, prefix) {
events.prototype._action_callSave = function (data, x, y, prefix) {
if (core.isReplaying() || core.hasFlag("__events__")) {
core.removeFlag("__events__");
core.doAction();
setTimeout(core.doAction);
}
else {
var e = core.clone(core.status.event.data);
@ -1590,8 +1660,8 @@ events.prototype._action_callSave = function (data, x, y, prefix) {
events.prototype._action_autoSave = function (data, x, y, prefix) {
core.autosave();
core.drawTip("已自动存档");
core.doAction();
if (!data.nohint) core.drawTip("已自动存档");
setTimeout(core.doAction);
}
events.prototype._action_callLoad = function (data, x, y, prefix) {
@ -1604,7 +1674,97 @@ events.prototype._action_callLoad = function (data, x, y, prefix) {
events.prototype._action_exit = function (data, x, y, prefix) {
this.setEvents([]);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_previewUI = function (data, x, y, prefix) {
this.insertAction(data.action);
setTimeout(core.doAction);
}
events.prototype._action_clearMap = function (data, x, y, prefix) {
core.ui._uievent_clearMap(data);
setTimeout(core.doAction);
}
events.prototype._action_fillText = function (data, x, y, prefix) {
core.ui._uievent_fillText(data);
setTimeout(core.doAction);
}
events.prototype._action_fillBoldText = function (data, x, y, prefix) {
core.ui._uievent_fillBoldText(data);
setTimeout(core.doAction);
}
events.prototype._action_fillRect = function (data, x, y, prefix) {
core.ui._uievent_fillRect(data);
setTimeout(core.doAction);
}
events.prototype._action_fillPolygon = function (data, x, y, prefix) {
core.ui._uievent_fillPolygon(data);
setTimeout(core.doAction);
}
events.prototype._action_strokeRect = function (data, x, y, prefix) {
core.ui._uievent_strokeRect(data);
setTimeout(core.doAction);
}
events.prototype._action_strokePolygon = function (data, x, y, prefix) {
core.ui._uievent_strokePolygon(data);
setTimeout(core.doAction);
}
events.prototype._action_fillCircle = function (data, x, y, prefix) {
core.ui._uievent_fillCircle(data);
setTimeout(core.doAction);
}
events.prototype._action_strokeCircle = function (data, x, y, prefix) {
core.ui._uievent_strokeCircle(data);
setTimeout(core.doAction);
}
events.prototype._action_drawLine = function (data, x, y, prefix) {
core.ui._uievent_drawLine(data);
setTimeout(core.doAction);
}
events.prototype._action_drawArrow = function (data, x, y, prefix) {
core.ui._uievent_drawArrow(data);
setTimeout(core.doAction);
}
events.prototype._action_setAttribute = function (data, x, y, prefix) {
core.ui._uievent_setAttribute(data);
setTimeout(core.doAction);
}
events.prototype._action_drawImage = function (data, x, y, prefix) {
core.ui._uievent_drawImage(data);
setTimeout(core.doAction);
}
events.prototype._action_drawIcon = function (data, x, y, prefix) {
core.ui._uievent_drawIcon(data);
setTimeout(core.doAction);
}
events.prototype._action_drawSelector = function (data, x, y, prefix) {
core.ui._uievent_drawSelector(data);
setTimeout(core.doAction);
}
events.prototype._action_drawBackground = function (data, x, y, prefix) {
core.ui._uievent_drawBackground(data);
setTimeout(core.doAction);
}
events.prototype._action_drawTextContent = function (data, x, y, prefix) {
core.ui._uievent_drawTextContent(data);
setTimeout(core.doAction);
}
// ------ 点击状态栏图标所进行的一些操作 ------ //
@ -1693,6 +1853,25 @@ events.prototype.openToolbox = function (fromUserAction) {
////// 点击快捷商店按钮时的打开操作 //////
events.prototype.openQuickShop = function (fromUserAction) {
if (core.isReplaying()) return;
if (Object.keys(core.status.shops).length == 0) {
core.drawTip("本塔没有快捷商店!");
return;
}
// --- 如果只有一个商店,则直接打开之
if (Object.keys(core.status.shops).length == 1) {
var shopId = Object.keys(core.status.shops)[0];
if (core.status.event.id != null || !this._checkStatus('shop', false)) return;
var reason = core.events.canUseQuickShop(shopId);
if (!core.flags.enableDisabledShop && reason) {
core.drawText(reason);
return;
}
core.events.openShop(shopId, true);
return;
}
if (!this._checkStatus('selectShop', fromUserAction)) return;
core.ui.drawQuickShop();
}
@ -1842,7 +2021,7 @@ events.prototype.doEffect = function (effect, need, times) {
////// 设置楼层属性 //////
events.prototype.setFloorInfo = function (name, value, floorId, prefix) {
floorId = floorId || data.floorId;
floorId = floorId || core.status.floorId;
core.status.maps[floorId][name] = core.calValue(value, prefix);
core.updateStatusBar();
}
@ -1869,12 +2048,14 @@ events.prototype.setGlobalFlag = function (name, value) {
core.flags[name] = value;
core.setFlag("globalFlags", flags);
core.resize();
if (name == 'blurFg')
core.drawMap();
}
events.prototype.closeDoor = function (x, y, id, callback) {
id = id || "";
if (!(id.endsWith("Door") || id.endsWith("Wall"))
|| !core.material.icons.animates[id] || core.getBlock(x, y) != null) {
|| core.material.icons.animates[id] == null || core.getBlock(x, y) != null) {
if (callback) callback();
return;
}
@ -1893,7 +2074,7 @@ events.prototype.closeDoor = function (x, y, id, callback) {
}
core.clearMap('event', 32 * x, 32 * y, 32, 32);
core.drawImage('event', core.material.images.animates, 32 * (4-state), 32 * door, 32, 32, 32 * x, 32 * y, 32, 32);
}, speed / Math.max(core.status.replay.speed, 1));
}, core.status.replay.speed == 24 ? 1 : speed / Math.max(core.status.replay.speed, 1));
core.animateFrame.asyncId[animate] = true;
}
@ -2101,7 +2282,7 @@ events.prototype.eventMoveHero = function(steps, time, callback) {
if (core.events._eventMoveHero_moving(++step, moveSteps))
step = 0;
}
}, time / 8 / core.status.replay.speed);
}, core.status.replay.speed == 24 ? 1 : time / 8 / core.status.replay.speed);
core.animateFrame.asyncId[animate] = true;
}
@ -2185,6 +2366,7 @@ events.prototype.openShop = function (shopId, needVisited) {
if (!core.flags.enableDisabledShop || shop.commonEvent) {
if (shop.times == 0) core.drawTip("该项尚未开启");
else core.drawTip("该项已失效");
core.ui.closePanel();
return;
}
else {

View File

@ -125,10 +125,8 @@ items.prototype._afterUseItem = function (itemId) {
if (core.status.hero.items[itemCls][itemId] <= 0)
delete core.status.hero.items[itemCls][itemId];
if (!core.status.event.id) {
core.status.event.data = null;
if (!core.status.event.id)
core.status.event.ui = null;
}
core.updateStatusBar();
}
@ -354,7 +352,7 @@ items.prototype._realLoadEquip = function (type, loadId, unloadId, callback) {
}
// --- 音效
core.playSound('equip.mp3');
this._realLoadEquip_playSound();
// --- 实际换装
this._loadEquipEffect(loadId, unloadId, loadPercentage == null ? unloadPercentage : loadPercentage);
@ -371,6 +369,12 @@ items.prototype._realLoadEquip = function (type, loadId, unloadId, callback) {
if (callback) callback();
}
items.prototype._realLoadEquip_playSound = function () {
if (core.hasFlag("__quickLoadEquip__")) return;
core.stopSound();
core.playSound('equip.mp3');
}
////// 保存装备 //////
items.prototype.quickSaveEquip = function (index) {
var saveEquips = core.getFlag("saveEquips", []);
@ -393,20 +397,30 @@ items.prototype.quickLoadEquip = function (index) {
if (v && !this.canEquip(v, true))
return;
}
core.setFlag("__quickLoadEquip__", true);
// 快速换装
var toEquip = [];
for (var i = 0; i < equipSize; i++) {
var now = core.status.hero.equipment[i];
if (now) {
this.unloadEquip(i);
core.status.route.push("unEquip:" + i);
// --- 只考虑diff的装备
var to = current[i];
if (now != to) {
toEquip.push(to || null);
if (now) {
this.unloadEquip(i);
core.status.route.push("unEquip:" + i);
}
}
}
for (var i = 0; i < equipSize; i++) {
var to = current[i];
for (var i in toEquip) {
var to = toEquip[i];
if (to) {
this.loadEquip(to);
core.status.route.push("equip:" + to);
}
}
core.removeFlag("__quickLoadEquip__");
this._realLoadEquip_playSound();
core.drawTip("成功换上" + index + "号套装");
}

Some files were not shown because too many files have changed in this diff Show More