代码编辑器记录位置 & drawBook pageinfo
This commit is contained in:
parent
14d6a35c62
commit
0a71f34d2e
@ -111,6 +111,8 @@ editor_blockly = function () {
|
||||
|
||||
editor_blockly.id = '';
|
||||
|
||||
var _lastOpenPosition = {};
|
||||
|
||||
editor_blockly.import = function (id_, args) {
|
||||
var thisTr = document.getElementById(id_);
|
||||
if (!thisTr) return false;
|
||||
@ -123,6 +125,8 @@ editor_blockly = function () {
|
||||
editor_blockly.entryType = type;
|
||||
editor_blockly.parse();
|
||||
editor_blockly.show();
|
||||
var _offsetIndex = [editor_blockly.entryType, editor.pos.x, editor.pos.y, editor.currentFloorId].join(":");
|
||||
editor_blockly.workspace.scroll(0, _lastOpenPosition[_offsetIndex] || 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -152,6 +156,9 @@ editor_blockly = function () {
|
||||
}
|
||||
|
||||
editor_blockly.cancel = function () {
|
||||
var _offsetIndex = [editor_blockly.entryType, editor.pos.x, editor.pos.y, editor.currentFloorId].join(":");
|
||||
_lastOpenPosition[_offsetIndex] = editor_blockly.workspace.scrollY;
|
||||
|
||||
editor_blockly.id = '';
|
||||
editor_blockly.hide();
|
||||
}
|
||||
@ -194,6 +201,9 @@ editor_blockly = function () {
|
||||
eval('var obj=' + code);
|
||||
if (this.checkAsync(obj) && confirm("警告!存在不等待执行完毕的事件但却没有用【等待所有异步事件处理完毕】来等待" +
|
||||
"它们执行完毕,这样可能会导致录像检测系统出问题。\n你要返回修改么?")) return;
|
||||
|
||||
var _offsetIndex = [editor_blockly.entryType, editor.pos.x, editor.pos.y, editor.currentFloorId].join(":");
|
||||
_lastOpenPosition[_offsetIndex] = editor_blockly.workspace.scrollY;
|
||||
setvalue(JSON.stringify(obj));
|
||||
}
|
||||
|
||||
|
||||
@ -221,6 +221,8 @@ editor_multi = function () {
|
||||
editor_multi.isString = false;
|
||||
editor_multi.lintAutocomplete = false;
|
||||
|
||||
var lastOffset = {};
|
||||
|
||||
editor_multi.show = function () {
|
||||
if (typeof (selectBox) !== typeof (undefined)) selectBox.isSelected(false);
|
||||
var valueNow = codeEditor.getValue();
|
||||
@ -249,11 +251,13 @@ editor_multi = function () {
|
||||
|
||||
var _format = function () {
|
||||
if (!editor_multi.lintAutocomplete) return;
|
||||
var offset = (codeEditor.getScrollInfo() || {}).top || 0;
|
||||
_setValue(js_beautify(codeEditor.getValue(), {
|
||||
brace_style: "collapse-preserve-inline",
|
||||
indent_with_tabs: true,
|
||||
jslint_happy: true
|
||||
}));
|
||||
codeEditor.scrollTo(0, offset);
|
||||
}
|
||||
|
||||
var _setValue = function (val) {
|
||||
@ -313,10 +317,14 @@ editor_multi = function () {
|
||||
_setValue(tstr || '');
|
||||
}
|
||||
editor_multi.show();
|
||||
codeEditor.scrollTo(0, lastOffset[id_] || 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
editor_multi.cancel = function () {
|
||||
if (editor_multi.id && editor_multi.id != 'callFromBlockly' && editor_multi.id != 'importFile') {
|
||||
lastOffset[editor_multi.id] = (codeEditor.getScrollInfo() || {}).top;
|
||||
}
|
||||
editor_multi.hide();
|
||||
editor_multi.id = '';
|
||||
multiLineArgs = [null, null, null];
|
||||
@ -372,6 +380,7 @@ editor_multi = function () {
|
||||
editor_multi.hide();
|
||||
input.onchange();
|
||||
}
|
||||
lastOffset[editor_multi.id] = (codeEditor.getScrollInfo() || {}).top;
|
||||
// ----- 自动格式化
|
||||
_format();
|
||||
setvalue(codeEditor.getValue() || '');
|
||||
|
||||
@ -759,8 +759,9 @@ actions.prototype._sys_onmousewheel = function (direct) {
|
||||
|
||||
// 怪物手册
|
||||
if (core.status.lockControl && core.status.event.id == 'book') {
|
||||
if (direct == 1) core.ui.drawBook(core.status.event.data - this.HSIZE);
|
||||
if (direct == -1) core.ui.drawBook(core.status.event.data + this.HSIZE);
|
||||
var pageinfo = core.ui._drawBook_pageinfo();
|
||||
if (direct == 1) core.ui.drawBook(core.status.event.data - pageinfo.per_page);
|
||||
if (direct == -1) core.ui.drawBook(core.status.event.data + pageinfo.per_page);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1139,14 +1140,15 @@ actions.prototype._keyUpAction = function (keycode) {
|
||||
|
||||
////// 怪物手册界面的点击操作 //////
|
||||
actions.prototype._clickBook = function (x, y) {
|
||||
var pageinfo = core.ui._drawBook_pageinfo();
|
||||
// 上一页
|
||||
if ((x == this.HSIZE-2 || x == this.HSIZE-3) && y == this.LAST) {
|
||||
core.ui.drawBook(core.status.event.data - this.HSIZE);
|
||||
core.ui.drawBook(core.status.event.data - pageinfo.per_page);
|
||||
return;
|
||||
}
|
||||
// 下一页
|
||||
if ((x == this.HSIZE+2 || x == this.HSIZE+3) && y == this.LAST) {
|
||||
core.ui.drawBook(core.status.event.data + this.HSIZE);
|
||||
core.ui.drawBook(core.status.event.data + pageinfo.per_page);
|
||||
return;
|
||||
}
|
||||
// 返回
|
||||
@ -1164,7 +1166,6 @@ actions.prototype._clickBook = function (x, y) {
|
||||
// 怪物信息
|
||||
var data = core.status.event.data;
|
||||
if (data != null && y < this.LAST) {
|
||||
var pageinfo = core.ui._drawBook_pageinfo();
|
||||
var per_page = pageinfo.per_page, page = parseInt(data / per_page);
|
||||
var u = this.LAST / per_page;
|
||||
for (var i = 0; i < per_page; ++i) {
|
||||
@ -1182,12 +1183,13 @@ actions.prototype._clickBook = function (x, y) {
|
||||
|
||||
////// 怪物手册界面时,按下某个键的操作 //////
|
||||
actions.prototype._keyDownBook = function (keycode) {
|
||||
if (keycode == 37) core.ui.drawBook(core.status.event.data - this.HSIZE);
|
||||
var pageinfo = core.ui._drawBook_pageinfo();
|
||||
if (keycode == 37) core.ui.drawBook(core.status.event.data - pageinfo.per_page);
|
||||
if (keycode == 38) core.ui.drawBook(core.status.event.data - 1);
|
||||
if (keycode == 39) core.ui.drawBook(core.status.event.data + this.HSIZE);
|
||||
if (keycode == 39) core.ui.drawBook(core.status.event.data + pageinfo.per_page);
|
||||
if (keycode == 40) core.ui.drawBook(core.status.event.data + 1);
|
||||
if (keycode == 33) core.ui.drawBook(core.status.event.data - this.HSIZE);
|
||||
if (keycode == 34) core.ui.drawBook(core.status.event.data + this.HSIZE);
|
||||
if (keycode == 33) core.ui.drawBook(core.status.event.data - pageinfo.per_page);
|
||||
if (keycode == 34) core.ui.drawBook(core.status.event.data + pageinfo.per_page);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user