2023-02-28 19:39:34 +08:00
|
|
|
|
///<reference path="../src/types/core.d.ts" />
|
2022-11-14 17:11:23 +08:00
|
|
|
|
function main() {
|
2022-11-13 18:02:05 +08:00
|
|
|
|
//------------------------ 用户修改内容 ------------------------//
|
|
|
|
|
|
2023-02-28 19:39:34 +08:00
|
|
|
|
this.version = '1.0.0'; // 游戏版本号;如果更改了游戏内容建议修改此version以免造成缓存问题。
|
2022-11-13 18:02:05 +08:00
|
|
|
|
|
|
|
|
|
this.useCompress = false; // 是否使用压缩文件
|
2023-04-16 17:30:22 +08:00
|
|
|
|
this.pluginUseCompress = false;
|
2022-11-13 18:02:05 +08:00
|
|
|
|
// 当你即将发布你的塔时,请使用“JS代码压缩工具”将所有js代码进行压缩,然后将这里的useCompress改为true。
|
|
|
|
|
// 请注意,只有useCompress是false时才会读取floors目录下的文件,为true时会直接读取libs目录下的floors.min.js文件。
|
|
|
|
|
// 如果要进行剧本的修改请务必将其改成false。
|
|
|
|
|
|
|
|
|
|
this.bgmRemote = false; // 是否采用远程BGM
|
2022-11-14 17:11:23 +08:00
|
|
|
|
this.bgmRemoteRoot = 'https://h5mota.com/music/'; // 远程BGM的根目录
|
2022-11-13 18:02:05 +08:00
|
|
|
|
|
|
|
|
|
this.isCompetition = false; // 是否是比赛模式
|
|
|
|
|
|
|
|
|
|
this.savePages = 1000; // 存档页数,每页可存5个;默认为1000页5000个存档
|
|
|
|
|
this.criticalUseLoop = 1; // 循环临界的分界
|
|
|
|
|
|
|
|
|
|
//------------------------ 用户修改内容 END ------------------------//
|
|
|
|
|
|
|
|
|
|
this.dom = {
|
2022-11-14 17:11:23 +08:00
|
|
|
|
body: document.body,
|
2024-11-19 22:28:48 +08:00
|
|
|
|
game: document.getElementById('game'),
|
|
|
|
|
gameDraw: document.getElementById('game-draw'),
|
2022-11-14 17:11:23 +08:00
|
|
|
|
gameCanvas: document.getElementsByClassName('gameCanvas'),
|
|
|
|
|
data: document.getElementById('data'),
|
|
|
|
|
inputDiv: document.getElementById('inputDiv'),
|
|
|
|
|
inputMessage: document.getElementById('inputMessage'),
|
|
|
|
|
inputBox: document.getElementById('inputBox'),
|
|
|
|
|
inputYes: document.getElementById('inputYes'),
|
|
|
|
|
inputNo: document.getElementById('inputNo'),
|
|
|
|
|
next: document.getElementById('next')
|
2022-11-13 18:02:05 +08:00
|
|
|
|
};
|
|
|
|
|
this.mode = 'play';
|
|
|
|
|
this.loadList = [
|
2022-11-14 17:11:23 +08:00
|
|
|
|
'loader',
|
|
|
|
|
'control',
|
|
|
|
|
'utils',
|
|
|
|
|
'items',
|
|
|
|
|
'icons',
|
|
|
|
|
'maps',
|
|
|
|
|
'enemys',
|
|
|
|
|
'events',
|
|
|
|
|
'actions',
|
|
|
|
|
'data',
|
|
|
|
|
'ui',
|
|
|
|
|
'core'
|
2022-11-13 18:02:05 +08:00
|
|
|
|
];
|
|
|
|
|
this.pureData = [
|
2022-11-14 17:11:23 +08:00
|
|
|
|
'data',
|
|
|
|
|
'enemys',
|
|
|
|
|
'icons',
|
|
|
|
|
'maps',
|
|
|
|
|
'items',
|
|
|
|
|
'functions',
|
|
|
|
|
'events',
|
|
|
|
|
'plugins'
|
2022-11-13 18:02:05 +08:00
|
|
|
|
];
|
|
|
|
|
this.materials = [
|
2022-11-14 17:11:23 +08:00
|
|
|
|
'animates',
|
|
|
|
|
'enemys',
|
|
|
|
|
'items',
|
|
|
|
|
'npcs',
|
|
|
|
|
'terrains',
|
|
|
|
|
'enemy48',
|
|
|
|
|
'npc48',
|
|
|
|
|
'icons'
|
2022-11-13 18:02:05 +08:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
this.statusBar = {
|
2024-11-19 22:28:48 +08:00
|
|
|
|
image: {},
|
2022-11-14 17:11:23 +08:00
|
|
|
|
icons: {
|
|
|
|
|
floor: 0,
|
|
|
|
|
name: null,
|
|
|
|
|
lv: 1,
|
|
|
|
|
hpmax: 2,
|
|
|
|
|
hp: 3,
|
|
|
|
|
atk: 4,
|
|
|
|
|
def: 5,
|
|
|
|
|
mdef: 6,
|
|
|
|
|
money: 7,
|
|
|
|
|
exp: 8,
|
|
|
|
|
up: 9,
|
|
|
|
|
book: 10,
|
|
|
|
|
fly: 11,
|
|
|
|
|
toolbox: 12,
|
|
|
|
|
keyboard: 13,
|
|
|
|
|
shop: 14,
|
|
|
|
|
save: 15,
|
|
|
|
|
load: 16,
|
|
|
|
|
settings: 17,
|
|
|
|
|
play: 18,
|
|
|
|
|
pause: 19,
|
|
|
|
|
stop: 20,
|
|
|
|
|
speedDown: 21,
|
|
|
|
|
speedUp: 22,
|
|
|
|
|
rewind: 23,
|
|
|
|
|
equipbox: 24,
|
|
|
|
|
mana: 25,
|
|
|
|
|
skill: 26,
|
|
|
|
|
btn1: 27,
|
|
|
|
|
btn2: 28,
|
|
|
|
|
btn3: 29,
|
|
|
|
|
btn4: 30,
|
|
|
|
|
btn5: 31,
|
|
|
|
|
btn6: 32,
|
|
|
|
|
btn7: 33,
|
|
|
|
|
btn8: 34
|
2024-11-19 22:28:48 +08:00
|
|
|
|
}
|
2022-11-14 17:11:23 +08:00
|
|
|
|
};
|
|
|
|
|
this.floors = {};
|
2022-11-13 18:02:05 +08:00
|
|
|
|
this.canvas = {};
|
|
|
|
|
|
2022-11-14 17:11:23 +08:00
|
|
|
|
this.__VERSION__ = '2.10.0';
|
2022-11-13 18:02:05 +08:00
|
|
|
|
this.__VERSION_CODE__ = 510;
|
|
|
|
|
}
|
2023-02-28 18:21:29 +08:00
|
|
|
|
// >>>> body end
|
2022-11-13 18:02:05 +08:00
|
|
|
|
|
2023-04-25 20:50:23 +08:00
|
|
|
|
main.prototype.loadScript = function (src, module) {
|
2023-02-28 19:39:34 +08:00
|
|
|
|
const script = document.createElement('script');
|
|
|
|
|
script.src = src;
|
2023-04-16 17:30:22 +08:00
|
|
|
|
if (module) script.type = 'module';
|
2023-02-28 19:39:34 +08:00
|
|
|
|
document.body.appendChild(script);
|
2023-04-21 11:34:08 +08:00
|
|
|
|
return new Promise((res, rej) => {
|
2023-02-28 19:39:34 +08:00
|
|
|
|
script.addEventListener('load', res);
|
2023-04-21 11:34:08 +08:00
|
|
|
|
script.addEventListener('error', rej);
|
2023-02-28 19:39:34 +08:00
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
main.prototype.init = async function (mode, callback) {
|
2023-01-11 09:45:18 +08:00
|
|
|
|
try {
|
2023-04-20 19:49:38 +08:00
|
|
|
|
const a = {};
|
|
|
|
|
const b = {};
|
2023-01-11 09:45:18 +08:00
|
|
|
|
new Proxy(a, b);
|
2023-02-28 18:21:29 +08:00
|
|
|
|
new Promise(res => res());
|
2023-06-14 19:20:24 +08:00
|
|
|
|
eval('`${0}`');
|
2023-02-28 19:39:34 +08:00
|
|
|
|
} catch {
|
2023-01-11 09:45:18 +08:00
|
|
|
|
alert('浏览器版本过低,无法游玩本塔!');
|
2023-03-04 20:21:12 +08:00
|
|
|
|
alert('建议使用Edge浏览器或Chrome浏览器游玩!');
|
2023-01-11 09:45:18 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-25 20:50:23 +08:00
|
|
|
|
if (main.replayChecking) {
|
|
|
|
|
main.loadSync(mode, callback);
|
|
|
|
|
} else {
|
|
|
|
|
main.loadAsync(mode, callback);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
main.prototype.loadSync = function (mode, callback) {
|
|
|
|
|
main.mode = mode;
|
|
|
|
|
if (main.useCompress) {
|
|
|
|
|
main.loadMod('project', 'project', () => 0);
|
|
|
|
|
} else {
|
|
|
|
|
main.pureData.forEach(v => {
|
|
|
|
|
main.loadMod('project', v, () => 0);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const mainData = data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.main;
|
|
|
|
|
Object.assign(main, mainData);
|
|
|
|
|
|
|
|
|
|
if (main.useCompress) {
|
|
|
|
|
main.loadMod('libs', 'libs', () => 0);
|
|
|
|
|
} else {
|
|
|
|
|
main.loadList.forEach(v => {
|
|
|
|
|
main.loadMod('libs', v, () => 0);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (const name of main.loadList) {
|
|
|
|
|
if (name === 'core') continue;
|
|
|
|
|
core[name] = new window[name]();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
main.loadFloors(() => 0);
|
|
|
|
|
|
|
|
|
|
const coreData = {};
|
|
|
|
|
[
|
|
|
|
|
'dom',
|
|
|
|
|
'statusBar',
|
|
|
|
|
'canvas',
|
|
|
|
|
'images',
|
|
|
|
|
'tilesets',
|
|
|
|
|
'materials',
|
|
|
|
|
'animates',
|
|
|
|
|
'bgms',
|
|
|
|
|
'sounds',
|
|
|
|
|
'floorIds',
|
|
|
|
|
'floors',
|
|
|
|
|
'floorPartitions'
|
|
|
|
|
].forEach(function (t) {
|
|
|
|
|
coreData[t] = main[t];
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
core.initSync(coreData, callback);
|
2024-04-20 19:49:21 +08:00
|
|
|
|
main.loading.emit('coreLoaded');
|
|
|
|
|
main.loading.emit('coreInit');
|
|
|
|
|
core.initStatus.maps = core.maps._initMaps();
|
2023-04-25 20:50:23 +08:00
|
|
|
|
core.resize();
|
|
|
|
|
main.core = core;
|
|
|
|
|
|
|
|
|
|
core.completeAchievement = () => 0;
|
2024-04-20 19:49:21 +08:00
|
|
|
|
|
|
|
|
|
core.plugin = { drawLight: 0 };
|
2023-04-25 20:50:23 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
main.prototype.loadAsync = async function (mode, callback) {
|
2022-11-13 18:02:05 +08:00
|
|
|
|
for (var i = 0; i < main.dom.gameCanvas.length; i++) {
|
2022-11-14 17:11:23 +08:00
|
|
|
|
main.canvas[main.dom.gameCanvas[i].id] =
|
|
|
|
|
main.dom.gameCanvas[i].getContext('2d');
|
2022-11-13 18:02:05 +08:00
|
|
|
|
}
|
|
|
|
|
main.mode = mode;
|
|
|
|
|
|
2023-02-28 19:39:34 +08:00
|
|
|
|
// 加载全塔属性代码
|
|
|
|
|
if (main.useCompress) {
|
|
|
|
|
await main.loadScript(`project/project.min.js?v=${main.version}`);
|
|
|
|
|
} else {
|
|
|
|
|
await Promise.all(
|
|
|
|
|
main.pureData.map(v =>
|
|
|
|
|
main.loadScript(`project/${v}.js?v=${main.version}`)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
const mainData = data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.main;
|
|
|
|
|
Object.assign(main, mainData);
|
2023-02-28 18:21:29 +08:00
|
|
|
|
|
2024-05-03 20:44:43 +08:00
|
|
|
|
// main.importFonts(main.fonts);
|
2022-11-13 18:02:05 +08:00
|
|
|
|
|
2023-02-28 19:39:34 +08:00
|
|
|
|
// 加载核心js代码
|
|
|
|
|
if (main.useCompress) {
|
|
|
|
|
await main.loadScript(`libs/libs.min.js?v=${main.version}`);
|
2023-06-29 20:24:21 +08:00
|
|
|
|
if (main.mode === 'play') main.loading.emit('coreLoaded');
|
2023-02-28 19:39:34 +08:00
|
|
|
|
} else {
|
|
|
|
|
await Promise.all(
|
|
|
|
|
main.loadList.map(v =>
|
2023-06-29 20:24:21 +08:00
|
|
|
|
main.loadScript(`libs/${v}.js?v=${main.version}`).then(() => {
|
|
|
|
|
if (v === 'core' && main.mode === 'play') {
|
2023-06-28 22:48:15 +08:00
|
|
|
|
main.loading.emit('coreLoaded');
|
|
|
|
|
}
|
|
|
|
|
})
|
2023-02-28 19:39:34 +08:00
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
2022-11-13 18:02:05 +08:00
|
|
|
|
|
2023-02-28 19:39:34 +08:00
|
|
|
|
for (const name of main.loadList) {
|
|
|
|
|
if (name === 'core') continue;
|
|
|
|
|
core[name] = new window[name]();
|
|
|
|
|
}
|
2022-11-13 18:02:05 +08:00
|
|
|
|
|
2023-02-28 19:39:34 +08:00
|
|
|
|
// 加载楼层
|
|
|
|
|
main.setMainTipsText('正在加载楼层文件...');
|
|
|
|
|
if (main.useCompress) {
|
|
|
|
|
await main.loadScript(`project/floors.min.js?v=${main.version}`);
|
|
|
|
|
} else {
|
2023-04-21 11:34:08 +08:00
|
|
|
|
await new Promise(res => {
|
|
|
|
|
main.loadScript(
|
2023-02-28 19:39:34 +08:00
|
|
|
|
`/all/__all_floors__.js?v=${
|
|
|
|
|
main.version
|
|
|
|
|
}&id=${main.floorIds.join(',')}`
|
2023-04-21 11:34:08 +08:00
|
|
|
|
).then(
|
|
|
|
|
() => {
|
|
|
|
|
main.supportBunch = true;
|
|
|
|
|
res();
|
|
|
|
|
},
|
|
|
|
|
async () => {
|
|
|
|
|
await Promise.all(
|
|
|
|
|
mainData.floorIds.map(v =>
|
|
|
|
|
main.loadScript(`project/floors/${v}.js`)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
res();
|
|
|
|
|
}
|
2023-02-28 19:39:34 +08:00
|
|
|
|
);
|
2023-04-21 11:34:08 +08:00
|
|
|
|
});
|
2023-02-28 19:39:34 +08:00
|
|
|
|
}
|
2022-11-13 18:02:05 +08:00
|
|
|
|
|
2023-02-28 19:39:34 +08:00
|
|
|
|
// 初始化core
|
|
|
|
|
const coreData = {};
|
|
|
|
|
[
|
|
|
|
|
'dom',
|
|
|
|
|
'statusBar',
|
|
|
|
|
'canvas',
|
|
|
|
|
'images',
|
|
|
|
|
'tilesets',
|
|
|
|
|
'materials',
|
|
|
|
|
'animates',
|
|
|
|
|
'bgms',
|
|
|
|
|
'sounds',
|
|
|
|
|
'floorIds',
|
|
|
|
|
'floors',
|
|
|
|
|
'floorPartitions'
|
|
|
|
|
].forEach(function (t) {
|
|
|
|
|
coreData[t] = main[t];
|
2022-11-13 18:02:05 +08:00
|
|
|
|
});
|
2024-04-20 19:49:21 +08:00
|
|
|
|
if (main.mode === 'play') {
|
|
|
|
|
await core.init(coreData, callback);
|
|
|
|
|
main.loading.emit('coreInit');
|
|
|
|
|
core.initStatus.maps = core.maps._initMaps();
|
|
|
|
|
} else {
|
|
|
|
|
await core.init(coreData, () => {
|
|
|
|
|
callback();
|
|
|
|
|
core.initStatus.maps = core.maps._initMaps();
|
|
|
|
|
});
|
|
|
|
|
main.loading.emit('coreInit');
|
|
|
|
|
}
|
2023-06-28 22:48:15 +08:00
|
|
|
|
|
2023-02-28 19:39:34 +08:00
|
|
|
|
core.resize();
|
|
|
|
|
|
2023-02-28 20:39:39 +08:00
|
|
|
|
main.core = core;
|
|
|
|
|
|
2024-04-20 19:49:21 +08:00
|
|
|
|
if (main.mode === 'editor') return;
|
|
|
|
|
|
2023-02-28 19:39:34 +08:00
|
|
|
|
// 自动放缩最大化
|
2024-04-20 19:49:21 +08:00
|
|
|
|
let auto = Mota.require('var', 'mainSetting').getValue('autoScale', true);
|
2023-08-05 12:12:02 +08:00
|
|
|
|
|
2023-02-28 19:39:34 +08:00
|
|
|
|
if (auto && !core.domStyle.isVertical) {
|
2024-11-19 22:28:48 +08:00
|
|
|
|
const height = window.innerHeight;
|
|
|
|
|
const width = window.innerWidth;
|
|
|
|
|
const maxScale = Math.min(height / core._PY_, width / core._PX_);
|
|
|
|
|
const target = Number((Math.floor(maxScale * 4) / 4).toFixed(2));
|
|
|
|
|
core.domStyle.scale = target - 0.25;
|
|
|
|
|
}
|
|
|
|
|
if (core.domStyle.isVertical) {
|
|
|
|
|
core.domStyle.scale = window.innerWidth / core._PX_;
|
2023-02-28 19:39:34 +08:00
|
|
|
|
}
|
2024-11-19 22:28:48 +08:00
|
|
|
|
Mota.r(() => {
|
|
|
|
|
Mota.require('module', 'Render').MotaOffscreenCanvas2D.refreshAll();
|
|
|
|
|
});
|
2022-11-14 17:11:23 +08:00
|
|
|
|
};
|
2022-11-13 18:02:05 +08:00
|
|
|
|
|
|
|
|
|
////// 加载过程提示 //////
|
2024-11-19 22:28:48 +08:00
|
|
|
|
main.prototype.setMainTipsText = function (text) {};
|
2022-11-13 18:02:05 +08:00
|
|
|
|
|
2024-11-19 22:28:48 +08:00
|
|
|
|
main.prototype.createOnChoiceAnimation = function () {};
|
2022-11-13 18:02:05 +08:00
|
|
|
|
|
|
|
|
|
////// 创建字体 //////
|
2024-11-19 22:28:48 +08:00
|
|
|
|
main.prototype.importFonts = function (fonts) {};
|
2022-11-13 18:02:05 +08:00
|
|
|
|
|
|
|
|
|
main.prototype.listen = function () {
|
|
|
|
|
////// 窗口大小变化时 //////
|
|
|
|
|
window.onresize = function () {
|
|
|
|
|
try {
|
2023-02-28 19:39:34 +08:00
|
|
|
|
core.resize();
|
2022-11-14 17:11:23 +08:00
|
|
|
|
} catch (ee) {
|
|
|
|
|
console.error(ee);
|
|
|
|
|
}
|
|
|
|
|
};
|
2022-11-13 18:02:05 +08:00
|
|
|
|
|
|
|
|
|
////// 在界面上按下某按键时 //////
|
|
|
|
|
main.dom.body.onkeydown = function (e) {
|
|
|
|
|
if (main.editorOpened) return;
|
|
|
|
|
try {
|
2023-02-23 23:10:57 +08:00
|
|
|
|
if (e.keyCode === 27) e.preventDefault();
|
2022-11-13 18:02:05 +08:00
|
|
|
|
if (main.dom.inputDiv.style.display == 'block') return;
|
2023-02-28 19:39:34 +08:00
|
|
|
|
if (core && (core.isPlaying() || core.status.lockControl))
|
|
|
|
|
core.onkeyDown(e);
|
2022-11-14 17:11:23 +08:00
|
|
|
|
} catch (ee) {
|
|
|
|
|
console.error(ee);
|
|
|
|
|
}
|
|
|
|
|
};
|
2022-11-13 18:02:05 +08:00
|
|
|
|
|
|
|
|
|
////// 开始选择时 //////
|
|
|
|
|
main.dom.body.onselectstart = function () {
|
|
|
|
|
return false;
|
2022-11-14 17:11:23 +08:00
|
|
|
|
};
|
2022-11-13 18:02:05 +08:00
|
|
|
|
|
|
|
|
|
////// 鼠标按下时 //////
|
|
|
|
|
main.dom.data.onmousedown = function (e) {
|
|
|
|
|
try {
|
|
|
|
|
e.stopPropagation();
|
2024-11-19 22:28:48 +08:00
|
|
|
|
var loc = core.actions._getClickLoc(e.offsetX, e.offsetY);
|
2022-11-13 18:02:05 +08:00
|
|
|
|
if (loc == null) return;
|
2023-02-28 19:39:34 +08:00
|
|
|
|
core.ondown(loc);
|
2022-11-14 17:11:23 +08:00
|
|
|
|
} catch (ee) {
|
|
|
|
|
console.error(ee);
|
|
|
|
|
}
|
|
|
|
|
};
|
2022-11-13 18:02:05 +08:00
|
|
|
|
|
|
|
|
|
////// 鼠标移动时 //////
|
|
|
|
|
main.dom.data.onmousemove = function (e) {
|
|
|
|
|
try {
|
2024-11-19 22:28:48 +08:00
|
|
|
|
var loc = core.actions._getClickLoc(e.offsetX, e.offsetY);
|
2022-11-13 18:02:05 +08:00
|
|
|
|
if (loc == null) return;
|
2023-02-28 19:39:34 +08:00
|
|
|
|
core.onmove(loc);
|
2022-11-14 17:11:23 +08:00
|
|
|
|
} catch (ee) {
|
|
|
|
|
console.error(ee);
|
|
|
|
|
}
|
|
|
|
|
};
|
2022-11-13 18:02:05 +08:00
|
|
|
|
|
|
|
|
|
////// 鼠标放开时 //////
|
|
|
|
|
main.dom.data.onmouseup = function (e) {
|
|
|
|
|
try {
|
2024-11-19 22:28:48 +08:00
|
|
|
|
var loc = core.actions._getClickLoc(e.offsetX, e.offsetY);
|
2022-11-13 18:02:05 +08:00
|
|
|
|
if (loc == null) return;
|
2023-02-28 19:39:34 +08:00
|
|
|
|
core.onup(loc);
|
2022-11-14 17:11:23 +08:00
|
|
|
|
} catch (ee) {
|
|
|
|
|
console.error(ee);
|
|
|
|
|
}
|
|
|
|
|
};
|
2022-11-13 18:02:05 +08:00
|
|
|
|
|
|
|
|
|
////// 鼠标滑轮滚动时 //////
|
|
|
|
|
main.dom.data.onmousewheel = function (e) {
|
|
|
|
|
try {
|
2023-02-28 19:39:34 +08:00
|
|
|
|
if (e.wheelDelta) core.onmousewheel(Math.sign(e.wheelDelta));
|
|
|
|
|
else if (e.detail) core.onmousewheel(Math.sign(e.detail));
|
2022-11-14 17:11:23 +08:00
|
|
|
|
} catch (ee) {
|
|
|
|
|
console.error(ee);
|
|
|
|
|
}
|
|
|
|
|
};
|
2022-11-13 18:02:05 +08:00
|
|
|
|
|
|
|
|
|
////// 手指在触摸屏开始触摸时 //////
|
|
|
|
|
main.dom.data.ontouchstart = function (e) {
|
|
|
|
|
try {
|
|
|
|
|
e.preventDefault();
|
2023-02-28 19:39:34 +08:00
|
|
|
|
var loc = core.actions._getClickLoc(
|
2022-11-14 17:11:23 +08:00
|
|
|
|
e.targetTouches[0].clientX,
|
2024-11-19 22:28:48 +08:00
|
|
|
|
e.targetTouches[0].clientY,
|
|
|
|
|
true
|
2022-11-14 17:11:23 +08:00
|
|
|
|
);
|
2022-11-13 18:02:05 +08:00
|
|
|
|
if (loc == null) return;
|
|
|
|
|
main.lastTouchLoc = loc;
|
2023-02-28 19:39:34 +08:00
|
|
|
|
core.ondown(loc);
|
2022-11-14 17:11:23 +08:00
|
|
|
|
} catch (ee) {
|
|
|
|
|
console.error(ee);
|
|
|
|
|
}
|
|
|
|
|
};
|
2022-11-13 18:02:05 +08:00
|
|
|
|
|
|
|
|
|
////// 手指在触摸屏上移动时 //////
|
|
|
|
|
main.dom.data.ontouchmove = function (e) {
|
|
|
|
|
try {
|
|
|
|
|
e.preventDefault();
|
2023-02-28 19:39:34 +08:00
|
|
|
|
var loc = core.actions._getClickLoc(
|
2022-11-14 17:11:23 +08:00
|
|
|
|
e.targetTouches[0].clientX,
|
2024-11-19 22:28:48 +08:00
|
|
|
|
e.targetTouches[0].clientY,
|
|
|
|
|
true
|
2022-11-14 17:11:23 +08:00
|
|
|
|
);
|
2022-11-13 18:02:05 +08:00
|
|
|
|
if (loc == null) return;
|
|
|
|
|
main.lastTouchLoc = loc;
|
2023-02-28 19:39:34 +08:00
|
|
|
|
core.onmove(loc);
|
2022-11-14 17:11:23 +08:00
|
|
|
|
} catch (ee) {
|
|
|
|
|
console.error(ee);
|
|
|
|
|
}
|
|
|
|
|
};
|
2022-11-13 18:02:05 +08:00
|
|
|
|
|
|
|
|
|
////// 手指离开触摸屏时 //////
|
|
|
|
|
main.dom.data.ontouchend = function (e) {
|
|
|
|
|
try {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
if (main.lastTouchLoc == null) return;
|
|
|
|
|
var loc = main.lastTouchLoc;
|
|
|
|
|
delete main.lastTouchLoc;
|
2023-02-28 19:39:34 +08:00
|
|
|
|
core.onup(loc);
|
2022-11-13 18:02:05 +08:00
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error(e);
|
|
|
|
|
}
|
2022-11-14 17:11:23 +08:00
|
|
|
|
};
|
2022-11-13 18:02:05 +08:00
|
|
|
|
|
|
|
|
|
window.onblur = function () {
|
2023-02-28 19:39:34 +08:00
|
|
|
|
if (core && core.control) {
|
2022-11-13 18:02:05 +08:00
|
|
|
|
try {
|
2023-02-28 19:39:34 +08:00
|
|
|
|
core.control.checkAutosave();
|
2022-11-14 17:11:23 +08:00
|
|
|
|
} catch (e) {}
|
2022-11-13 18:02:05 +08:00
|
|
|
|
}
|
2022-11-14 17:11:23 +08:00
|
|
|
|
};
|
2022-11-13 18:02:05 +08:00
|
|
|
|
|
|
|
|
|
main.dom.inputYes.onclick = function () {
|
|
|
|
|
main.dom.inputDiv.style.display = 'none';
|
|
|
|
|
var func = core.platform.successCallback;
|
|
|
|
|
core.platform.successCallback = core.platform.errorCallback = null;
|
|
|
|
|
if (func) func(main.dom.inputBox.value);
|
2022-11-14 17:11:23 +08:00
|
|
|
|
};
|
2022-11-13 18:02:05 +08:00
|
|
|
|
|
|
|
|
|
main.dom.inputNo.onclick = function () {
|
|
|
|
|
main.dom.inputDiv.style.display = 'none';
|
|
|
|
|
var func = core.platform.errorCallback;
|
|
|
|
|
core.platform.successCallback = core.platform.errorCallback = null;
|
|
|
|
|
if (func) func(null);
|
2022-11-14 17:11:23 +08:00
|
|
|
|
};
|
|
|
|
|
}; //listen end
|
2022-11-13 18:02:05 +08:00
|
|
|
|
|
2022-11-14 17:11:23 +08:00
|
|
|
|
var main = new main();
|