fix:微调格式
This commit is contained in:
parent
7828113a5a
commit
32a5208cdf
@ -1155,22 +1155,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
this.getAllTickers = () => { };
|
||||
return;
|
||||
}
|
||||
// core.plugin.animate = {
|
||||
// Animation: j,
|
||||
// AnimationBase: F,
|
||||
// Ticker: I,
|
||||
// Transition: O,
|
||||
// bezier: q,
|
||||
// bezierPath: H,
|
||||
// circle: D,
|
||||
// hyper: G,
|
||||
// inverseTrigo: N,
|
||||
// linear: Y,
|
||||
// power: C,
|
||||
// shake: B,
|
||||
// sleep: R,
|
||||
// trigo: U,
|
||||
// }
|
||||
|
||||
// 保存所有Ticker的引用
|
||||
const tickersMap = new Map();
|
||||
|
||||
@ -1719,7 +1704,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
trigo: U,
|
||||
}
|
||||
|
||||
},
|
||||
},
|
||||
"drawItemDetail": function () {
|
||||
/* 宝石血瓶左下角显示数值
|
||||
* 需要将 变量:itemDetail改为true才可正常运行
|
||||
@ -1937,7 +1922,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
|
||||
const ctxName = 'globalAnimate';
|
||||
|
||||
if (!core.isReplaying() && Ticker) {
|
||||
if (!core.isReplaying()) {
|
||||
const ticker = new Ticker();
|
||||
ticker.add(() => {
|
||||
const ctx = core.getContextByName(ctxName);
|
||||
@ -2230,124 +2215,6 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
ani.all().then(() => { ani.ticker.destroy(); });
|
||||
}
|
||||
},
|
||||
"Menu": function () {
|
||||
// 本插件定义了一些用于绘制的基类
|
||||
class ButtonBase {
|
||||
constructor(x, y, w, h) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.w = w;
|
||||
this.h = h;
|
||||
this.disable = false;
|
||||
|
||||
/** 所在的Menu,用于触发重绘等事件 */
|
||||
this.menu;
|
||||
|
||||
this.draw = (ctx) => { };
|
||||
this.event = (x, y, px, py) => { };
|
||||
this.status;
|
||||
}
|
||||
}
|
||||
|
||||
class MenuBase {
|
||||
constructor(name) {
|
||||
this.name = name;
|
||||
this.btnList = new Map();
|
||||
this.keyEvent = () => { };
|
||||
this.clickEvent = (x, y, px, py) => {
|
||||
this.btnList.forEach((btn) => {
|
||||
if (btn.disable) return;
|
||||
if (px >= btn.x && px <= btn.x + btn.w && py > btn.y && py <= btn.y + btn.h) {
|
||||
btn.event(x, y, px, py);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
initBtnList(arr) {
|
||||
this.btnList = new Map(arr);
|
||||
this.btnList.forEach((button) => {
|
||||
button.menu = this;
|
||||
})
|
||||
}
|
||||
|
||||
drawButtonContent() {
|
||||
this.btnList.forEach((button) => {
|
||||
if (!button.disable) button.draw(this.name);
|
||||
})
|
||||
}
|
||||
|
||||
drawContent() {
|
||||
core.createCanvas(this.name, 0, 0, core.__PIXELS__, core.__PIXELS__, 136);
|
||||
this.drawButtonContent(this.name);
|
||||
}
|
||||
|
||||
beginListen() {
|
||||
core.registerAction('keyDown', this.name, this.keyEvent, 100);
|
||||
core.registerAction('ondown', this.name, this.clickEvent, 100);
|
||||
|
||||
}
|
||||
|
||||
endListen() {
|
||||
core.unregisterAction('keyDown', this.name);
|
||||
core.unregisterAction('ondown', this.name);
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.endListen();
|
||||
core.deleteCanvas(this.name);
|
||||
}
|
||||
|
||||
init() {
|
||||
this.beginListen();
|
||||
this.drawContent();
|
||||
}
|
||||
}
|
||||
class MenuPage extends MenuBase {
|
||||
constructor(pageList, currPage, ctx) {
|
||||
super(ctx);
|
||||
/**
|
||||
* 当前页面列表
|
||||
* @type {Array<MenuBase>}
|
||||
*/
|
||||
this.pageList = pageList;
|
||||
/**
|
||||
* 当前页的序号
|
||||
* @type {number}
|
||||
*/
|
||||
this.currPage = currPage | 0;
|
||||
}
|
||||
|
||||
initOnePage(index) {
|
||||
if (!core.isset(index)) index = this.currPage;
|
||||
this.pageList[index].init();
|
||||
}
|
||||
|
||||
changePage(num) {
|
||||
if (num !== this.currPage) {
|
||||
const beforeMenu = this.pageList[this.currPage];
|
||||
beforeMenu.clear();
|
||||
}
|
||||
this.currPage = num;
|
||||
this.initOnePage();
|
||||
}
|
||||
|
||||
pageDown() {
|
||||
if (this.currPage > 0) this.changePage(this.currPage - 1);
|
||||
}
|
||||
|
||||
pageUp() {
|
||||
if (this.currPage < this.pageList.length - 1) this.changePage(this.currPage + 1);
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.pageList.forEach((page) => page.clear());
|
||||
super.clear();
|
||||
}
|
||||
}
|
||||
|
||||
this.MenuBase = { ButtonBase, MenuBase, MenuPage };
|
||||
},
|
||||
"scrollingText": function () {
|
||||
// 本插件用于绘制在线留言
|
||||
|
||||
@ -2537,6 +2404,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
|
||||
},
|
||||
"newBackpackLook": function () {
|
||||
// 这个插件有点离谱 参数过多还不如硬编码
|
||||
// 注:///// *** 裹起来的区域: 该区域内参数可以随意更改调整ui绘制 不会影响总体布局
|
||||
// 请尽量修改该区域而不是其他区域 修改的时候最好可以对照现有ui修改
|
||||
|
||||
@ -2814,6 +2682,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
itemName = item.name,
|
||||
itemText = item.text;
|
||||
itemText = core.replaceText(itemText);
|
||||
if (!itemText) itemText = '该道具无描述。'
|
||||
/* 一个根据道具id修改道具名字(右栏)的例子
|
||||
* if (item.id == "xxx") itemNameColor = "red";
|
||||
*/
|
||||
@ -2991,6 +2860,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
var tx = (x + x + lineWidth / 2 + width) / 2,
|
||||
ty = y + height + lineWidth / 2 * 3 + space;
|
||||
core.fillText(ctx, name, tx, ty, color, font);
|
||||
|
||||
core.setAlpha(ctx, 1);
|
||||
|
||||
core.setTextBaseline(ctx, "alphabetic");
|
||||
core.setTextAlign("left");
|
||||
}
|
||||
@ -3076,16 +2948,16 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
|
||||
function getSelectedItem() {
|
||||
var info = core.status.thisUIEventInfo;
|
||||
if (!(info && info.select.id && core.status.event.id == "toolbox")) {
|
||||
if (!(info && info.select.id && ["toolbox", "equipbox"].includes(core.status.event.id))) {
|
||||
core.drawFailTip('发生了未知错误!');
|
||||
return;
|
||||
}
|
||||
return info.select.id;
|
||||
}
|
||||
|
||||
function batchUse(item,count){
|
||||
function batchUse(item, count) {
|
||||
try {
|
||||
const itemCount = core.itemCount(id);
|
||||
const itemCount = core.itemCount(item);
|
||||
if (eval(core.material.items[item].noBatchUse)) {
|
||||
core.drawFailTip('该道具不能被批量使用!');
|
||||
return;
|
||||
@ -3096,8 +2968,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
if (core.canUseItem(item)) core.useItem(item);
|
||||
else return;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
core.drawFailTip('批量使用时出现未知错误!');
|
||||
}
|
||||
@ -3147,18 +3018,19 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
core.fillText(ctx, text, x + r, y + lineWidth / 2 + 2, style, font);
|
||||
|
||||
var todo = function () {
|
||||
//debugger;
|
||||
var id = getSelectedItem();
|
||||
let hideInfo = core.getFlag('hideInfo', {});
|
||||
console.log(id);
|
||||
if (hideInfo.hasOwnProperty(id)) {
|
||||
hideInfo[id] = !hideInfo[id];
|
||||
core.setFlag('hideInfo', hideInfo);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
hideInfo[id] = !core.material.items[id].hideInToolbox;
|
||||
core.setFlag('hideInfo', hideInfo);
|
||||
}
|
||||
core.plugin.drawToolbox();
|
||||
if (core.status.event.id === 'toolbox') core.plugin.drawToolbox();
|
||||
else if (core.status.event.id === 'equipbox') core.plugin.drawEquipbox();
|
||||
}
|
||||
core.addUIEventListener(x, y, w, h, todo);
|
||||
}
|
||||
@ -3171,8 +3043,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
list = list.concat(Object.keys(core.status.hero.items[name])); // 获取'constants'和'tools'整体的列表
|
||||
}
|
||||
if (!showHide) list = list.filter(function (id) {
|
||||
const hideInfo = core.getFlag('hideInfo',{});
|
||||
//if (id === 'yellowKey') debugger;
|
||||
const hideInfo = core.getFlag('hideInfo', {});
|
||||
if (hideInfo.hasOwnProperty(id)) return !hideInfo[id];
|
||||
else return !core.material.items[id].hideInToolbox;
|
||||
})
|
||||
@ -3207,13 +3078,12 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
if (core.hasFlag('showHideItem')) {
|
||||
core.fillRect(ctx, x + border, y + border, squareSize - 2 * border, squareSize - 2 * border, 'lime');
|
||||
}
|
||||
// core.strokeRect(ctx, x, y, w, h, style);
|
||||
core.fillText(ctx, text, x + squareSize + 2, y + 4, style, font);
|
||||
|
||||
var todo = function () {
|
||||
core.setFlag('showHideItem', !core.getFlag('showHideItem', false));
|
||||
core.plugin.drawToolbox();
|
||||
//core.useSelectItemInBox();
|
||||
if (core.status.event.id === 'toolbox') core.plugin.drawToolbox();
|
||||
else if (core.status.event.id === 'equipbox') core.plugin.drawEquipbox();
|
||||
}
|
||||
core.addUIEventListener(x, y, w, h, todo);
|
||||
}
|
||||
@ -3270,26 +3140,6 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
return core.refreshBox();
|
||||
}
|
||||
|
||||
// core.ui.getToolboxItems = function (cls) {
|
||||
// var list = Object.keys(core.status.hero.items[cls] || {});
|
||||
// if (cls == "all") {
|
||||
// for (var name in core.status.hero.items) {
|
||||
// if (name == "equips") continue;
|
||||
// list = list.concat(Object.keys(core.status.hero.items[name]));
|
||||
// }
|
||||
// return list.filter(function (id) {
|
||||
// return !core.material.items[id].hideInToolbox;
|
||||
// }).sort();
|
||||
// }
|
||||
|
||||
// if (this.uidata.getToolboxItems) {
|
||||
// return this.uidata.getToolboxItems(cls);
|
||||
// }
|
||||
// return list.filter(function (id) {
|
||||
// return !core.material.items[id].hideInToolbox;
|
||||
// }).sort();
|
||||
// }
|
||||
|
||||
this.useSelectItemInBox = function () {
|
||||
var info = core.status.thisUIEventInfo;
|
||||
if (!info) return;
|
||||
@ -3714,7 +3564,119 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
// 自绘设置界面
|
||||
// 请保持本插件在所有插件的最下方
|
||||
|
||||
const { ButtonBase, MenuBase, MenuPage } = this.MenuBase;
|
||||
class ButtonBase {
|
||||
constructor(x, y, w, h) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.w = w;
|
||||
this.h = h;
|
||||
this.disable = false;
|
||||
|
||||
/** 所在的Menu,用于触发重绘等事件 */
|
||||
this.menu;
|
||||
|
||||
this.draw = (ctx) => { };
|
||||
this.event = (x, y, px, py) => { };
|
||||
this.status;
|
||||
}
|
||||
}
|
||||
|
||||
class MenuBase {
|
||||
constructor(name) {
|
||||
this.name = name;
|
||||
this.btnList = new Map();
|
||||
this.keyEvent = () => { };
|
||||
this.clickEvent = (x, y, px, py) => {
|
||||
this.btnList.forEach((btn) => {
|
||||
if (btn.disable) return;
|
||||
if (px >= btn.x && px <= btn.x + btn.w && py > btn.y && py <= btn.y + btn.h) {
|
||||
btn.event(x, y, px, py);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
initBtnList(arr) {
|
||||
this.btnList = new Map(arr);
|
||||
this.btnList.forEach((button) => {
|
||||
button.menu = this;
|
||||
})
|
||||
}
|
||||
|
||||
drawButtonContent() {
|
||||
this.btnList.forEach((button) => {
|
||||
if (!button.disable) button.draw(this.name);
|
||||
})
|
||||
}
|
||||
|
||||
drawContent() {
|
||||
core.createCanvas(this.name, 0, 0, core.__PIXELS__, core.__PIXELS__, 136);
|
||||
this.drawButtonContent(this.name);
|
||||
}
|
||||
|
||||
beginListen() {
|
||||
core.registerAction('keyDown', this.name, this.keyEvent, 100);
|
||||
core.registerAction('ondown', this.name, this.clickEvent, 100);
|
||||
|
||||
}
|
||||
|
||||
endListen() {
|
||||
core.unregisterAction('keyDown', this.name);
|
||||
core.unregisterAction('ondown', this.name);
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.endListen();
|
||||
core.deleteCanvas(this.name);
|
||||
}
|
||||
|
||||
init() {
|
||||
this.beginListen();
|
||||
this.drawContent();
|
||||
}
|
||||
}
|
||||
class MenuPage extends MenuBase {
|
||||
constructor(pageList, currPage, ctx) {
|
||||
super(ctx);
|
||||
/**
|
||||
* 当前页面列表
|
||||
* @type {Array<MenuBase>}
|
||||
*/
|
||||
this.pageList = pageList;
|
||||
/**
|
||||
* 当前页的序号
|
||||
* @type {number}
|
||||
*/
|
||||
this.currPage = currPage | 0;
|
||||
}
|
||||
|
||||
initOnePage(index) {
|
||||
if (!core.isset(index)) index = this.currPage;
|
||||
this.pageList[index].init();
|
||||
}
|
||||
|
||||
changePage(num) {
|
||||
if (num !== this.currPage) {
|
||||
const beforeMenu = this.pageList[this.currPage];
|
||||
beforeMenu.clear();
|
||||
}
|
||||
this.currPage = num;
|
||||
this.initOnePage();
|
||||
}
|
||||
|
||||
pageDown() {
|
||||
if (this.currPage > 0) this.changePage(this.currPage - 1);
|
||||
}
|
||||
|
||||
pageUp() {
|
||||
if (this.currPage < this.pageList.length - 1) this.changePage(this.currPage + 1);
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.pageList.forEach((page) => page.clear());
|
||||
super.clear();
|
||||
}
|
||||
}
|
||||
|
||||
class Setting {
|
||||
/**
|
||||
@ -4717,7 +4679,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
// todolist 自定义设置界面添加键盘支持 √
|
||||
// todolist 剧情全skip功能 文字-文字+演出(跳跃) √
|
||||
// todolist 批量使用:您当前选定了:xxx。请勿选定不适合批量使用的道具,请勿输入过大的数字。
|
||||
// todolist 道具栏分页,可设定隐藏的道具,及自动查看显隐藏 手动hide无用道具
|
||||
// todolist 道具栏分页,可设定隐藏的道具,及自动查看显隐藏 手动hide无用道具 √
|
||||
// todolist 内置ATRI 解决连通性问题
|
||||
// todolist 血瓶宝石显示数据 解决浏览地图和楼传显示错误 引入自动配置值的块 √
|
||||
// todolist 存读档过程保存图块连通性(可选)√
|
||||
@ -4727,345 +4689,5 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
// todolist 音效连续播放的优化(与自动清有关)
|
||||
// todolist 新的临界计算
|
||||
// todolist 微调BGM播放
|
||||
},
|
||||
"temp1": function () {
|
||||
return;
|
||||
// 注:///// *** 裹起来的区域: 该区域内参数可以随意更改调整ui绘制 不会影响总体布局
|
||||
// 请尽量修改该区域而不是其他区域 修改的时候最好可以对照现有ui修改
|
||||
|
||||
///// *** 道具类型
|
||||
// cls对应name
|
||||
const itemClsName = {
|
||||
"constants": "永久道具",
|
||||
"tools": "消耗道具",
|
||||
}
|
||||
// 一页最大放的道具数量 将把整个道具左栏分成num份 每份是一个道具项
|
||||
const itemNum = 12;
|
||||
///// ***
|
||||
|
||||
class ButtonBase {
|
||||
constructor(x, y, w, h) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.w = w;
|
||||
this.h = h;
|
||||
this.disable = false;
|
||||
|
||||
/** 所在的Menu,用于触发重绘等事件 */
|
||||
this.menu;
|
||||
|
||||
this.draw = (ctx) => {};
|
||||
this.event = (x, y, px, py) => {};
|
||||
this.status;
|
||||
}
|
||||
}
|
||||
|
||||
class MenuBase {
|
||||
constructor(name) {
|
||||
/** name */
|
||||
this.name = name;
|
||||
/** btnList */
|
||||
this.btnList = new Map();
|
||||
/** keyEvent */
|
||||
this.keyEvent = () => {};
|
||||
/** clickEvent */
|
||||
this.clickEvent = (x, y, px, py) => {
|
||||
this.btnList.forEach((btn) => {
|
||||
if (btn.disable) return;
|
||||
if (px >= btn.x && px <= btn.x + btn.w && py > btn.y && py <= btn.y + btn.h) {
|
||||
btn.event(x, y, px, py);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
initBtnList(arr) {
|
||||
this.btnList = new Map(arr);
|
||||
this.btnList.forEach((button) => {
|
||||
button.menu = this;
|
||||
})
|
||||
}
|
||||
|
||||
drawButtonContent() {
|
||||
this.btnList.forEach((button) => {
|
||||
if (!button.disable) button.draw(this.name);
|
||||
})
|
||||
}
|
||||
|
||||
drawContent() {
|
||||
core.createCanvas(this.name, 0, 0, core.__PIXELS__, core.__PIXELS__, 136);
|
||||
this.drawButtonContent(this.name);
|
||||
}
|
||||
|
||||
beginListen() {
|
||||
core.registerAction('keyDown', this.name, this.keyEvent, 100);
|
||||
core.registerAction('ondown', this.name, this.clickEvent, 100);
|
||||
|
||||
}
|
||||
|
||||
endListen() {
|
||||
core.unregisterAction('keyDown', this.name);
|
||||
core.unregisterAction('ondown', this.name);
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.endListen();
|
||||
core.deleteCanvas(this.name);
|
||||
}
|
||||
|
||||
init() {
|
||||
this.beginListen();
|
||||
this.drawContent();
|
||||
}
|
||||
}
|
||||
class MenuPage extends MenuBase {
|
||||
constructor(pageList, currPage, ctx) {
|
||||
super(ctx);
|
||||
/**
|
||||
* 当前页面列表
|
||||
* @type {Array<MenuBase>}
|
||||
*/
|
||||
this.pageList = pageList;
|
||||
/**
|
||||
* 当前页的序号
|
||||
* @type {number}
|
||||
*/
|
||||
this.currPage = currPage | 0;
|
||||
}
|
||||
|
||||
initOnePage(index) {
|
||||
if (!core.isset(index)) index = this.currPage;
|
||||
this.pageList[index].init();
|
||||
}
|
||||
|
||||
changePage(num) {
|
||||
if (num !== this.currPage) {
|
||||
const beforeMenu = this.pageList[this.currPage];
|
||||
beforeMenu.clear();
|
||||
}
|
||||
this.currPage = num;
|
||||
this.initOnePage();
|
||||
}
|
||||
|
||||
pageDown() {
|
||||
if (this.currPage > 0) this.changePage(this.currPage - 1);
|
||||
}
|
||||
|
||||
pageUp() {
|
||||
if (this.currPage < this.pageList.length - 1) this.changePage(this.currPage + 1);
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.pageList.forEach((page) => page.clear());
|
||||
super.clear();
|
||||
}
|
||||
}
|
||||
|
||||
// 绘制道具栏的共用背景
|
||||
function drawBoxBackground(ctx) {
|
||||
core.setTextAlign(ctx, "left");
|
||||
core.clearMap(ctx);
|
||||
core.deleteCanvas("_selector"); ///!!!// ?这是什么?
|
||||
|
||||
///// *** 背景设置
|
||||
const max = core.__PIXELS__;
|
||||
const x = 2,
|
||||
y = x,
|
||||
w = max - x * 2,
|
||||
h = w;
|
||||
const [borderWidth, borderRadius, borderStyle] = [2, 5, "#fff"]; // radius:圆角矩形的圆角半径
|
||||
const [backgroundColor, backgroundAlpha] = ["gray", 0.85]; // 设置背景不透明度(0.85)
|
||||
///// ***
|
||||
const [start_x, start_y] = [x + borderWidth / 2, y + borderWidth / 2];
|
||||
const [width, height] = [max - start_x * 2, max - start_y * 2];
|
||||
|
||||
// 渐变色背景的一个例子(黑色渐变白色):
|
||||
// 有关渐变色的具体知识请网上搜索canvas createGradient了解
|
||||
/*
|
||||
var grd = ctx.createLinearGradient(x, y, x + w, y);
|
||||
grd.addColorStop(0, "black");
|
||||
grd.addColorStop(1, "white");
|
||||
backgroundColor = grd;
|
||||
*/
|
||||
// 使用图片背景要注释掉下面的strokeRect和fillRoundRect
|
||||
// 图片背景的一个例子:
|
||||
/*
|
||||
core.drawImage(ctx, "xxx.png", x, y, w, h);
|
||||
core.strokeRect(ctx, x, y, w, h, borderStyle, borderWidth);
|
||||
*/
|
||||
|
||||
core.setAlpha(ctx, backgroundAlpha); // 不透明度暂时设为backgroundAlpha
|
||||
core.strokeRoundRect(ctx, x, y, w, h, borderRadius, borderStyle, borderWidth); // 绘制大边框
|
||||
core.fillRoundRect(ctx, start_x, start_y, width, height, borderRadius, backgroundColor); // 绘制大边框中的灰色背景
|
||||
core.setAlpha(ctx, 1); // 恢复不透明度
|
||||
|
||||
///// *** 左栏配置
|
||||
const [leftbar_height, leftbar_width] = [height, width * 0.6];
|
||||
// 左边栏宽度(width*0.6) 本身仅为坐标使用 需要与底下的rightbar_width(width*0.4)同时更改
|
||||
///// ***
|
||||
// xxx_right参数 代表最右侧坐标
|
||||
//
|
||||
const [leftbar_right, leftbar_bottom, leftbar_x, leftbar_y] = [start_x + leftbar_width - borderWidth / 2, start_y + leftbar_height, start_x, start_y];
|
||||
|
||||
///// *** 道具栏配置
|
||||
|
||||
const [boxName_color, boxName_fontSize] = ['#fff', 15];
|
||||
const boxName_font = core.ui._buildFont(boxName_fontSize, true);
|
||||
|
||||
const [arrow_x, arrow_y, arrow_width, arrow_style] = [10 + start_x, 10 + start_y, 20, "white"];
|
||||
const arrow_lineWidth = 2;
|
||||
const rightArrow_right = leftbar_right - 10;
|
||||
// 道具内栏顶部坐标 本质是通过该项 控制(道具栏顶部文字和箭头)与道具内栏顶部的间隔
|
||||
///// ***
|
||||
|
||||
const boxName = core.status.event.id == "toolbox" ? "\r[yellow]道具栏\r | 装备栏" : "道具栏 | \r[yellow]装备栏\r"; ///!!!//
|
||||
|
||||
// 绘制左右两个箭头
|
||||
core.drawArrow(ctx, arrow_x + arrow_width, arrow_y, arrow_x, arrow_y, arrow_style, arrow_lineWidth);
|
||||
core.drawArrow(ctx, rightArrow_right - arrow_width, arrow_y, rightArrow_right, arrow_y, arrow_style, arrow_lineWidth);
|
||||
|
||||
core.setTextAlign(ctx, "center");
|
||||
core.setTextBaseline(ctx, "middle");
|
||||
core.fillText(ctx, boxName, (leftbar_right + leftbar_x) / 2, arrow_y + 2, boxName_color, boxName_font); // 绘制道具栏?装备栏的字样 ///!!!//
|
||||
|
||||
///// *** 底栏按钮
|
||||
const [pageBtn_left, pageBtn_right, pageBtn_bottom] = [leftbar_x + 3, leftbar_right - 3, leftbar_bottom - 2];
|
||||
// xxx_bottom 最底部坐标
|
||||
const [pageBtn_radius, pageBtn_borderStyle, pageBtn_borderWidth, pageText_color] = [8, "#fff", 2, "#fff"];
|
||||
///// ***
|
||||
|
||||
return {
|
||||
pageBtn_radius, pageBtn_left, pageBtn_right, pageBtn_bottom, pageBtn_borderStyle, pageBtn_borderWidth, pageText_color
|
||||
};
|
||||
// 绘制底部的两个箭头(切换道具栏的左右)///!!!//
|
||||
core.drawItemListbox_setPageBtn(ctx, pageBtn_left, pageBtn_right, pageBtn_bottom, pageBtn_radius, pageBtn_borderStyle, pageBtn_borderWidth);
|
||||
|
||||
const pageFontSize = pageBtn_radius * 2 - 4;
|
||||
const pageFont = core.ui._buildFont(pageFontSize);
|
||||
|
||||
///!!!// core.setPageItems(page); // 修改core.status.thisUIEventInfo; ///!!!//
|
||||
|
||||
const pageText = this.currPage + " / " + this.pageMax;
|
||||
core.setTextAlign(ctx, "center");
|
||||
core.setTextBaseline(ctx, "bottom");
|
||||
|
||||
// 添加底部"x/y"的字样
|
||||
core.fillText(ctx, pageText, (leftbar_x + leftbar_right) / 2, pageBtn_bottom, pageText_color, pageFont);
|
||||
|
||||
///!!!// core.addUIEventListener(start_x, start_y, leftbar_right - start_x, arrow_y - start_y + 13, changeBox); ///!!!//与监听有关
|
||||
// var itembar_height = Math.ceil(pageBtn_bottom - pageBtn_radius * 2 - pageBtn_borderWidth / 2 - bottomSpace - itembar_top);
|
||||
// var oneItemHeight = (itembar_height - 4) / itemNum;
|
||||
// return {
|
||||
// x: start_x,
|
||||
// y: start_y,
|
||||
// width: width,
|
||||
// height: height,
|
||||
// leftbar_right: leftbar_right,
|
||||
// obj: {
|
||||
// x: arrow_x,
|
||||
// y: itembar_top,
|
||||
// width: itembar_right - arrow_x,
|
||||
// height: itembar_height,
|
||||
// oneItemHeight: oneItemHeight
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
// 首先抽象一下 思考一下顶层设计
|
||||
// ItemBox类
|
||||
// 需要的属性:当前持有的Item和数量 当前的页数
|
||||
|
||||
class ArrowButton extends ButtonBase{
|
||||
constructor(ctx, left, right, bottom, r, style, lineWidth, direction){
|
||||
const [x, y, pos] = [left + offset, bottom - offset, Math.sqrt(2) / 2 * (r - lineWidth / 2)];
|
||||
super();
|
||||
this.draw = function(ctx, left, right, bottom, r, style, lineWidth){
|
||||
const offset = lineWidth / 2 + r;
|
||||
|
||||
// const [x, y, pos] = [left + offset, bottom - offset, Math.sqrt(2) / 2 * (r - lineWidth / 2)];
|
||||
core.fillPolygon(ctx, [[x - pos, y], [x + pos - 2, y - pos], [x + pos - 2, y + pos]], style);
|
||||
core.strokeCircle(ctx, x, y, r, style, lineWidth);
|
||||
|
||||
x = right - offset;
|
||||
core.fillPolygon(ctx, [
|
||||
[x + pos, y],
|
||||
[x - pos + 2, y - pos],
|
||||
[x - pos + 2, y + pos]
|
||||
], style);
|
||||
core.strokeCircle(ctx, x, y, r, style, lineWidth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ToolBox extends MenuBase {
|
||||
constructor(name, capacity) {
|
||||
super(name);
|
||||
/** 当前是否要显示隐藏的道具
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.showHideItem = core.hasFlag('showHideItem');
|
||||
/** 一页显示的道具数量 */
|
||||
this.capacity = capacity;
|
||||
/** 要显示的道具列表 */
|
||||
this.itemList = core.ui.getToolboxItems('all', this.showHideItem);
|
||||
/** 当前页数
|
||||
* @type {number}
|
||||
*/
|
||||
this.currPage = 0;
|
||||
/** 最大页数 */
|
||||
this.pageMax = this.getPageCount();
|
||||
/** 当前选中的道具的序号
|
||||
* @type {number}
|
||||
*/
|
||||
this.selectedIndex;
|
||||
/** 绘制参数 */
|
||||
this.drawInfo;
|
||||
}
|
||||
|
||||
drawContent(drawInfo) {
|
||||
const { pageBtn_radius, pageBtn_left, pageBtn_right, pageBtn_bottom,
|
||||
pageBtn_borderStyle, pageBtn_borderWidth, pageText_color } = drawInfo;
|
||||
// 绘制底部的两个箭头(切换道具栏的左右)///!!!//
|
||||
core.drawItemListbox_setPageBtn(ctx, pageBtn_left, pageBtn_right, pageBtn_bottom, pageBtn_radius, pageBtn_borderStyle, pageBtn_borderWidth);
|
||||
|
||||
const pageFontSize = pageBtn_radius * 2 - 4;
|
||||
const pageFont = core.ui._buildFont(pageFontSize);
|
||||
|
||||
///!!!// core.setPageItems(page); // 修改core.status.thisUIEventInfo; ///!!!//
|
||||
|
||||
const pageText = this.currPage + " / " + this.pageMax;
|
||||
core.setTextAlign(ctx, "center");
|
||||
core.setTextBaseline(ctx, "bottom");
|
||||
|
||||
// 添加底部"x/y"的字样
|
||||
core.fillText(ctx, pageText, (leftbar_x + leftbar_right) / 2, pageBtn_bottom, pageText_color, pageFont);
|
||||
}
|
||||
|
||||
getPageCount() {
|
||||
return Math.floor(this.itemList.length / this.capacity);
|
||||
}
|
||||
}
|
||||
|
||||
class BoxPage extends MenuPage{
|
||||
drawContent(){
|
||||
this.drawInfo = drawBoxBackground.apply(this, [this.name]);
|
||||
this.pageList.forEach((page) => {
|
||||
page.drawContent(this.drawInfo);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
this.t = function () {
|
||||
const toolBox = new ToolBox('ui', 12);
|
||||
const equipBox = new ToolBox('ui', 7);
|
||||
const boxMenu = new MenuPage([toolBox, equipBox], 0, 'ui');
|
||||
return boxMenu;
|
||||
// boxMenu.init();
|
||||
}
|
||||
|
||||
this.y = function(){
|
||||
// let boxMenu = core.t();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user