init: add workspace files
This commit is contained in:
137
src/dialog/base.js
Normal file
137
src/dialog/base.js
Normal file
@@ -0,0 +1,137 @@
|
||||
|
||||
import DialogScore from './score.js';
|
||||
import DialogMap from './map.js';
|
||||
import DialogKeys from './keys.js';
|
||||
import DialogSetting from './setting.js';
|
||||
import DialogExtend from './extend.js';
|
||||
import DialogChannel from './channel.js';
|
||||
import DialogPack from './packet.js';
|
||||
import DialogSkills from './skills.js';
|
||||
import DialogTasks from './tasks.js';
|
||||
import DialogShop from './shop.js';
|
||||
import DialogMessage from './message.js';
|
||||
import DialogStats from './stats.js';
|
||||
import DialogJh from './jh.js';
|
||||
import DialogRelation from './relation.js';
|
||||
import DialogTeam from './team.js';
|
||||
import DialogParty from './party.js';
|
||||
import DialogTrade from './trade.js';
|
||||
import DialogEvents from './events.js';
|
||||
import DialogPm from './paimai.js';
|
||||
import DialogPack2 from './packet2.js';
|
||||
import DialogMaster from './master.js';
|
||||
import DialogList from './list.js';
|
||||
|
||||
|
||||
|
||||
const Dialog = {
|
||||
isShow: false,
|
||||
curItem: null,
|
||||
score: DialogScore,
|
||||
map: DialogMap,
|
||||
keys: DialogKeys,
|
||||
setting: DialogSetting,
|
||||
extend: DialogExtend,
|
||||
channel: DialogChannel,
|
||||
pack: DialogPack,
|
||||
skills: DialogSkills,
|
||||
tasks: DialogTasks,
|
||||
shop: DialogShop,
|
||||
message: DialogMessage,
|
||||
stats: DialogStats,
|
||||
jh: DialogJh,
|
||||
relation: DialogRelation,
|
||||
team: DialogTeam,
|
||||
party: DialogParty,
|
||||
trade: DialogTrade,
|
||||
events: DialogEvents,
|
||||
pm: DialogPm,
|
||||
pack2: DialogPack2,
|
||||
master: DialogMaster,
|
||||
list: DialogList,
|
||||
|
||||
show: function (name, data) {
|
||||
if (!name) return;
|
||||
const dialog = this[name];
|
||||
if (!dialog) throw new Error('没有' + name);
|
||||
if (!dialog.created) {
|
||||
dialog.init();
|
||||
dialog.created = true;
|
||||
}
|
||||
if (!data) {
|
||||
if (this.isShow && name == this.curItem) return this.hide();
|
||||
if (this.curItem && name != this.curItem) {
|
||||
Dialog[Dialog.curItem].close && Dialog[Dialog.curItem].close();
|
||||
Dialog[Dialog.curItem].isShow = false;
|
||||
Dialog.contentElement.empty();
|
||||
}
|
||||
this.init();
|
||||
this.curItem = name;
|
||||
dialog.show(data);
|
||||
Process.message.scroll2end();
|
||||
} else {
|
||||
dialog.onData(data);
|
||||
}
|
||||
},
|
||||
select: function (name) {
|
||||
if (this.isShow && name == this.curItem) return this.hide();
|
||||
if (this.curItem && name != this.curItem) {
|
||||
Dialog[Dialog.curItem].close && Dialog[Dialog.curItem].close();
|
||||
Dialog[Dialog.curItem].isShow = false;
|
||||
Dialog.contentElement.empty();
|
||||
}
|
||||
this.init();
|
||||
this.curItem = name;
|
||||
},
|
||||
init: function () {
|
||||
if (this.isShow) return;
|
||||
if (!this.isInit) {
|
||||
this.contentElement = $(".dialog>.dialog-content");
|
||||
this.titleElement = $(".dialog>.dialog-header>.dialog-title");
|
||||
this.iconElement = $(".dialog>.dialog-header>.dialog-icon");
|
||||
this.footerElement = $(".dialog>.dialog-footer")
|
||||
.on("click", ".footer-item", Dialog.footerClick);
|
||||
this.hiddenElement = $(".hidden-item");
|
||||
this.element = $(".dialog");
|
||||
$(".dialog>.dialog-header>.dialog-close").on("click", Dialog.hide);
|
||||
this.isInit = true;
|
||||
}
|
||||
$(".content-room").addClass("hide");
|
||||
this.element.removeClass("hide");
|
||||
this.isShow = true;
|
||||
},
|
||||
hide: function () {
|
||||
if (Dialog[Dialog.curItem].hide && Dialog[Dialog.curItem].hide() == false) return;
|
||||
Dialog.close();
|
||||
},
|
||||
footerClick: function () {
|
||||
var elem = $(this);
|
||||
if (elem.is(".select")) return;
|
||||
var cmd = elem.attr("for");
|
||||
elem.parent().find(".footer-item.select").removeClass("select");
|
||||
elem.addClass("select");
|
||||
Dialog[Dialog.curItem].footerChanged(cmd, elem);
|
||||
},
|
||||
title: function (title) {
|
||||
Dialog.titleElement.html(title);
|
||||
},
|
||||
icon: function (css) {
|
||||
this.iconElement.attr("class", "dialog-icon glyphicon glyphicon-" + css);
|
||||
},
|
||||
footer: function (html) {
|
||||
html ? this.footerElement.html(html) : this.footerElement.empty();
|
||||
},
|
||||
close: function () {
|
||||
if (!Dialog.isShow) return;
|
||||
Dialog.isShow = false;
|
||||
$(".content-room").removeClass("hide");
|
||||
Dialog.element.addClass("hide");
|
||||
},
|
||||
injectStyle: function (css) {
|
||||
const style = document.createElement("style");
|
||||
style.textContent = css;
|
||||
document.head.append(style);
|
||||
},
|
||||
};
|
||||
|
||||
export default Dialog;
|
||||
118
src/dialog/channel.js
Normal file
118
src/dialog/channel.js
Normal file
@@ -0,0 +1,118 @@
|
||||
|
||||
|
||||
export default {
|
||||
footer: [["全部", ""], ["世界", "chat"], ["队伍", "tm"], ["门派", "fam"], ["全区", "es"], ["帮派", "pty"], ["系统", "sys"]],
|
||||
isScroll: true,
|
||||
last_click: 0,
|
||||
show: function () {
|
||||
if (Date.now() - this.last_click > 500) {
|
||||
this.last_click = Date.now();
|
||||
return;
|
||||
}
|
||||
if (Dialog.channel.isShow) return;
|
||||
Dialog.select("channel");
|
||||
Dialog.icon("comment");
|
||||
Dialog.title("");
|
||||
Dialog.footer("");
|
||||
for (var i = 0; i < Dialog.channel.footer.length; i++) {
|
||||
var elem = $("<span class='footer-item channel-item' for='" + Dialog.channel.footer[i][1] + "'>"
|
||||
+ Dialog.channel.footer[i][0] + "</span>").appendTo(Dialog.footerElement);
|
||||
if (i == 0) elem.addClass("select");
|
||||
}
|
||||
Dialog.contentElement.html("").append(Process.ChannelElement.addClass("channel-dialog"));
|
||||
|
||||
Dialog.channel.isShow = true;
|
||||
Dialog.channel.scrollBottom();
|
||||
|
||||
}, hide: function () {
|
||||
Dialog.channel.footerChanged("");
|
||||
Process.ChannelElement.removeClass("channel-dialog").insertBefore(".content-message");
|
||||
|
||||
this.scrollBottom();
|
||||
this.isShow = false;
|
||||
}, close: function () {
|
||||
this.hide();
|
||||
}, scrollBottom: function () {
|
||||
Process.channel.scroll2end();
|
||||
},
|
||||
footerChanged: function (type) {
|
||||
if (Dialog.channel.select_item == type) return;
|
||||
Dialog.channel.select_item = type;
|
||||
|
||||
Process.channel.clear();
|
||||
for (var i = 0; i < this.datas.length; i++) {
|
||||
var item = this.datas[i];
|
||||
if (!type || item[0] == type) {
|
||||
Process.channel.push(item[1]);
|
||||
}
|
||||
}
|
||||
Process.channel.scroll2end();
|
||||
}, datas: [],
|
||||
createElement: function (data, isTop) {
|
||||
var color = "hic";
|
||||
var name = "";
|
||||
switch (data.ch) {
|
||||
case "tm":
|
||||
color = "hig";
|
||||
name = "队伍";
|
||||
break;
|
||||
case "fam":
|
||||
color = "hiy";
|
||||
name = data.fam || "门派";
|
||||
break;
|
||||
case "rumor":
|
||||
color = "him";
|
||||
name = "谣言";
|
||||
data.name = "某人";
|
||||
break;
|
||||
case "sys":
|
||||
color = "hir";
|
||||
name = "系统";
|
||||
data.name = "";
|
||||
break;
|
||||
case "es":
|
||||
color = "hio";
|
||||
name = data.server;
|
||||
data.uid = null;
|
||||
break;
|
||||
case "pty":
|
||||
color = "hiz";
|
||||
name = "帮派";
|
||||
break;
|
||||
default:
|
||||
name = ["闲聊", "闲聊", "闲聊", "<hiy>宗师</hiy>", "<HIZ>武圣</HIZ>", "<hio>武帝</hio>", "<ord>武神</ord>"][data.lv];
|
||||
if (data.lv6) {
|
||||
name = ["<ord>武神</ord>", "<ord>剑神</ord>", "<ord>刀皇</ord>", "<ord>兵主</ord>", "<ord>战神</ord>"][data.lv6];
|
||||
}
|
||||
break;
|
||||
}
|
||||
var html = ["<", color, ">【"];
|
||||
html.push(name);
|
||||
html.push("】");
|
||||
if (data.name) {
|
||||
html.push("<span");
|
||||
if (data.uid) html.push(" cmd='look3 " + data.uid + "'");
|
||||
html.push(">");
|
||||
html.push(data.name);
|
||||
html.push("</span>:");
|
||||
}
|
||||
html.push(data.content);
|
||||
// if (isTop) {
|
||||
// html.push("\n");
|
||||
// }
|
||||
var str = html.join("");
|
||||
if (this.datas.length > 800) {
|
||||
this.datas.length = 0;
|
||||
this.datas.splice(0, 200);
|
||||
}
|
||||
if (data.ch == "rumor") data.ch = "sys";
|
||||
this.datas.push([
|
||||
data.ch, str
|
||||
]);
|
||||
if (this.select_item && this.select_item != data.ch) {
|
||||
return "";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
};
|
||||
136
src/dialog/events.js
Normal file
136
src/dialog/events.js
Normal file
@@ -0,0 +1,136 @@
|
||||
|
||||
import { showFlag } from '../game/tool.js';
|
||||
|
||||
const events_css = `
|
||||
|
||||
.dialog-events {
|
||||
max-height: 32em;
|
||||
margin-bottom: 0.5em;
|
||||
margin-top: 0.5em;
|
||||
}
|
||||
|
||||
.dialog-events>.empty {
|
||||
text-align: center;
|
||||
color: gray;
|
||||
margin-bottom: 3em;
|
||||
margin-top: 3em;
|
||||
}
|
||||
|
||||
.dialog-events>.event-item {
|
||||
border-radius: 6px;
|
||||
background-color: #111111;
|
||||
border-left-width: 4px;
|
||||
border-left-style: solid;
|
||||
position: relative;
|
||||
margin-top: 0.5em;
|
||||
padding-left: 0.5em;
|
||||
}
|
||||
|
||||
.event-item h3 {
|
||||
margin: 0px;
|
||||
padding-top: 0.5em;
|
||||
color: var(--border-color)
|
||||
}
|
||||
|
||||
.event-item .event-desc {
|
||||
white-space: pre-wrap;
|
||||
margin: 0;
|
||||
padding-top: 0.5em;
|
||||
padding-bottom: 0.5em;
|
||||
}
|
||||
|
||||
.event-item>.event-btn {
|
||||
width: 7em;
|
||||
border-left: 1px solid var(--border-color);
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
background-color: transparent;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
color: var(--border-color);
|
||||
}
|
||||
|
||||
`;
|
||||
|
||||
export default {
|
||||
unRead: 0,
|
||||
init: function () {
|
||||
Dialog.injectStyle(events_css);
|
||||
},
|
||||
hide: function () {
|
||||
this.element.remove();
|
||||
this.isShow = false;
|
||||
}, onData: function (data) {
|
||||
if (data.close) return Dialog.hide();
|
||||
if (!data.items) {
|
||||
if (data.finish) this.unRead--;
|
||||
else this.unRead++;
|
||||
return this.showUnread();
|
||||
}
|
||||
this.items = data.items;
|
||||
this.create_items();
|
||||
}, showUnread: function () {
|
||||
showFlag("events", this.unRead);
|
||||
},
|
||||
show: function () {
|
||||
if (!this.element)
|
||||
this.element = $("<div class='dialog-events'></div>");
|
||||
SendCommand("events");
|
||||
if (this.isShow) return;
|
||||
|
||||
Dialog.title("活动");
|
||||
Dialog.icon("dashboard");
|
||||
this.unRead = 0;
|
||||
this.showUnread();
|
||||
Dialog.footer("");
|
||||
this.element.appendTo(Dialog.contentElement);
|
||||
this.isShow = true;
|
||||
},
|
||||
create_items: function () {
|
||||
let str = [];
|
||||
for (let i = 0; i < this.items.length; i++) {
|
||||
const [id, title, desc, grade, time, command] = this.items[i];
|
||||
str.push("<div class='event-item flex-row ");
|
||||
str.push('grade', grade);
|
||||
str.push("'><div class='flex-1'><h3>");
|
||||
str.push(title)
|
||||
str.push("</h3>");
|
||||
str.push("<pre class='event-desc'>");
|
||||
str.push(desc);
|
||||
if (time > 0)
|
||||
str.push('\n<mem>', this.format_time(time), '</mem>');
|
||||
str.push("</pre></div>");
|
||||
|
||||
str.push("<span class='event-btn flex-0'");
|
||||
if (command) str.push(" cmd='events ", id, "' >", command);
|
||||
else str.push(">进行中");
|
||||
str.push("</span>");
|
||||
str.push("</div>");
|
||||
}
|
||||
if (!str.length) str.push('<div class="empty">暂无活动</div>');
|
||||
this.element.html(str.join(""));
|
||||
Dialog.footer('<span class="obj-money">共有' + this.items.length + '项活动正在进行</span>');
|
||||
|
||||
}, format_time: function (time) {
|
||||
let dt = new Date(time);
|
||||
let now = new Date();
|
||||
let day = dt.getDate();
|
||||
let hour = dt.getHours();
|
||||
let minu = dt.getMinutes();
|
||||
let str = ['持续到'];
|
||||
if (now.getFullYear() !== dt.getFullYear())
|
||||
str.push(dt.getFullYear(), '年');
|
||||
if (now.getMonth() !== dt.getMonth())
|
||||
str.push(this.format_num(dt.getMonth() + 1), '月', this.format_num(day), '日');
|
||||
else if (day !== now.getDate())
|
||||
str.push(this.format_num(day), '日');
|
||||
str.push(this.format_num(hour), ':', this.format_num(minu));
|
||||
|
||||
return str.join("");
|
||||
|
||||
}, format_num: function (num) {
|
||||
return num > 9 ? num.toString() : "0" + num.toString();
|
||||
}
|
||||
};
|
||||
629
src/dialog/extend.js
Normal file
629
src/dialog/extend.js
Normal file
@@ -0,0 +1,629 @@
|
||||
|
||||
import Util from '../utils/util.js';
|
||||
import { ReceiveMessage } from '../client.js';
|
||||
|
||||
export default {
|
||||
types: [
|
||||
{
|
||||
name: "自定义快捷操作", value: "button", for: [
|
||||
{ name: "动作栏", value: "action" },
|
||||
{ name: "地图", value: "map" },
|
||||
{ name: "背包道具", value: "pack" },
|
||||
{ name: "技能", value: "skill" },
|
||||
{ name: "师父/随从技能", value: "mskill" },
|
||||
{ name: "房间物体", value: "item" },
|
||||
]
|
||||
}
|
||||
// , {
|
||||
// name: "触发", value: "trigger",
|
||||
// for: [
|
||||
// { name: "文本触发", value: "message" },
|
||||
// { name: "事件处理", value: "data" },
|
||||
// ]
|
||||
// }, {
|
||||
// name: "过滤", value: "filter",
|
||||
// for: [
|
||||
// { name: "文本过滤", value: "fmessage" },
|
||||
// { name: "事件过滤", value: "fdata" },
|
||||
// ]
|
||||
// }
|
||||
],
|
||||
init: function (elem) {
|
||||
elem.on('click', '[ecmd]', this.onButtonClick);
|
||||
elem.on('click', '.setting-item', this.onClickRow);
|
||||
elem.on("click", ".switch", this.switchClick);
|
||||
elem.on("change", "select", this.selectChanged);
|
||||
if (this.element) return;
|
||||
this.element = elem;
|
||||
let html = [];
|
||||
html.push('<div class="extend-list">');
|
||||
this.append_settings(html);
|
||||
html.push("</div>");
|
||||
this.append_edit(html);
|
||||
elem.html(html.join(""));
|
||||
this.edit_elem = this.element.find('.extend-add');
|
||||
this.list_elem = this.element.find('.extend-list');
|
||||
},
|
||||
refresh_list: function () {
|
||||
let html = [];
|
||||
this.append_settings(html);
|
||||
this.list_elem.html(html.join(""));
|
||||
},
|
||||
append_settings: function (html) {
|
||||
let items = this.setting, index = 0;
|
||||
for (let item of items) {
|
||||
html.push(this.create_item(item, index++));
|
||||
}
|
||||
},
|
||||
action_types: {
|
||||
button: "快捷操作",
|
||||
trigger: "触发器",
|
||||
filter: "过滤器"
|
||||
},
|
||||
regex: {
|
||||
message: true,
|
||||
fmessage: true
|
||||
},
|
||||
for_types: {
|
||||
map: "地图",
|
||||
action: "动作栏",
|
||||
pack: "背包道具",
|
||||
skill: "技能",
|
||||
item: "房间物体",
|
||||
mskill: "师父/随从技能",
|
||||
message: "文本",
|
||||
data: "事件",
|
||||
fmessage: "文本",
|
||||
fdata: "事件"
|
||||
},
|
||||
create_item: function (item, index) {
|
||||
let html = [];
|
||||
html.push('<div class="setting-item" sid="', index++, '">');
|
||||
html.push('<div class="title">');
|
||||
html.push(this.for_types[item.for], this.action_types[item.type], '【', item.name, '】');
|
||||
html.push('</div>');
|
||||
let isopend = false;
|
||||
if (item.on && item.on[Process.player]) isopend = true;
|
||||
|
||||
html.push('<span class="switch ', isopend ? "on" : "",
|
||||
'"><span class="switch-button"></span><span class="switch-text">开</span></span>');
|
||||
|
||||
html.push('</div>');
|
||||
return html.join("");
|
||||
},
|
||||
selectChanged: function () {
|
||||
let elem = $(this);
|
||||
if (elem.attr('prop') !== 'type') {
|
||||
const fortype = elem.val();
|
||||
elem.parent().next().find('.extend-row-header').html(
|
||||
Dialog.extend.regex[fortype] ? "正则表达式" : "可选参数"
|
||||
);
|
||||
return;
|
||||
}
|
||||
let type = elem.val()
|
||||
let items = null;
|
||||
for (let item of Dialog.extend.types) {
|
||||
if (type === item.value) {
|
||||
items = item.for;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!items) return;
|
||||
elem = elem.parent().next().find('select');
|
||||
let html = [];
|
||||
for (let item of items) {
|
||||
html.push('<option value="', item.value, '">', item.name, '</option>');
|
||||
}
|
||||
elem.html(html.join(""));
|
||||
},
|
||||
switchClick: function () {
|
||||
let elem = $(this);
|
||||
let text_elem = elem.find(".switch-text");
|
||||
let text = text_elem.text();
|
||||
let is_open = text !== "开始记录";
|
||||
let is_selected = false;
|
||||
if (elem.is(".on")) {
|
||||
elem.removeClass("on");
|
||||
is_open && text_elem.html("关");
|
||||
} else {
|
||||
elem.addClass("on");
|
||||
is_open && text_elem.html("开");
|
||||
is_selected = true;
|
||||
}
|
||||
if (!is_open) {
|
||||
if (is_selected) {
|
||||
Dialog.close();
|
||||
Dialog.extend.start_record();
|
||||
} else {
|
||||
Dialog.extend.stop_record();
|
||||
}
|
||||
} else {
|
||||
let item = Dialog.extend.setting[elem.parent().attr("sid")];
|
||||
if (item) {
|
||||
if (!item.on) item.on = {};
|
||||
if (is_selected) {
|
||||
item.on[Process.player] = 1;
|
||||
} else {
|
||||
delete item.on[Process.player];
|
||||
}
|
||||
Dialog.extend.save_extend(item);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
start_record: function () {
|
||||
if (this.is_record) return;
|
||||
this.is_record = true;
|
||||
this.prev_time = 0;
|
||||
this.record_cmds = [];
|
||||
ReceiveMessage('<hic>开始记录你的操作命令。</hic>');
|
||||
Process.state({ state: "正在记录你的操作命令" });
|
||||
},
|
||||
excluded: {
|
||||
score: true, score2: true, pack: true, cha: true, tasks: true,
|
||||
message: true, relation: true, shop: true, team: true, jh: true
|
||||
},
|
||||
excluded_check: [
|
||||
(x) => x.startsWith('jh') && x.indexOf('start') < 0,
|
||||
(x) => x.startsWith('stats'),
|
||||
(x) => x.startsWith('map'),
|
||||
(x) => x.startsWith('look')
|
||||
],
|
||||
record: function (cmd) {
|
||||
if (!this.is_record) return;
|
||||
if (this.excluded[cmd]) return;
|
||||
for (let check of this.excluded_check) {
|
||||
if (check(cmd)) return;
|
||||
}
|
||||
let now = Date.now();
|
||||
if (this.prev_time > 0) {
|
||||
this.record_cmds.push('#wait ' + (now - this.prev_time));
|
||||
}
|
||||
this.record_cmds.push(cmd);
|
||||
this.prev_time = now;
|
||||
},
|
||||
stop_record: function () {
|
||||
if (!this.is_record) return;
|
||||
this.is_record = false;
|
||||
ReceiveMessage('<cyn>已停止记录你的操作命令。</cyn>');
|
||||
this.edit_elem.find('.switch').removeClass('on');
|
||||
if (this.record_cmds.length > 0) {
|
||||
Dialog.show('setting');
|
||||
Dialog.setting.footerChanged(3);
|
||||
this.edit_elem.show();
|
||||
this.list_elem.hide();
|
||||
this.edit_elem.find('textarea').val(this.record_cmds.join(";"));
|
||||
Process.state();
|
||||
}
|
||||
},
|
||||
helper: "<li ecmd='show_actions'>可用命令参考</li><li ecmd='show_vars'>可用变量参考</li><li ecmd='show_paras'>参数用法参考</li>",
|
||||
append_edit: function (html) {
|
||||
html.push('<div class="extend-add hide">');
|
||||
html.push('<div class="extend-row">');
|
||||
html.push('<input prop="name" class="extend-input"/>');
|
||||
html.push("<div class='extend-row-header'>提示/描述/说明</div>");
|
||||
html.push("</div>");
|
||||
|
||||
html.push('<div class="extend-row">');
|
||||
html.push('<select prop="type" class="extend-input">');
|
||||
for (let item of this.types) {
|
||||
html.push('<option value="', item.value, '">', item.name, '</option>');
|
||||
}
|
||||
html.push("</select><div class='extend-row-header'>扩展类型</div>");
|
||||
html.push("</div>");
|
||||
let item1 = this.types[0];
|
||||
html.push('<div class="extend-row">');
|
||||
html.push('<select prop="for" class="extend-input">');
|
||||
for (let item of item1.for) {
|
||||
html.push('<option value="', item.value, '">', item.name, '</option>');
|
||||
}
|
||||
html.push("</select><div class='extend-row-header'>可用选项</div>");
|
||||
html.push("</div>");
|
||||
|
||||
html.push('<div class="extend-row">');
|
||||
html.push('<input prop="paras" class="extend-input"/>');
|
||||
html.push("<div class='extend-row-header'>可选参数</div>");
|
||||
html.push("</div>");
|
||||
|
||||
html.push('<div class="extend-row flex-1">');
|
||||
html.push('<textarea prop="content" class="extend-input"></textarea>');
|
||||
html.push("<div class='extend-row-header extend-menus'>");
|
||||
html.push('<span class="switch"> <span class="switch-button"> </span><span class="switch-text">开始记录</span></span>');
|
||||
html.push("<ul class='extend-help'>");
|
||||
html.push(this.helper);
|
||||
html.push("</ul><button ecmd='save'>保存</button>");
|
||||
|
||||
html.push("</div></div>");
|
||||
|
||||
html.push("</div>");
|
||||
}, onClickRow: function () {
|
||||
var elem = $(this);
|
||||
var item = Dialog.extend.setting[elem.attr("sid")];
|
||||
if (!item) return;
|
||||
Dialog.extend.selected_item = item;
|
||||
if (!Dialog.extend.edit_button) {
|
||||
Dialog.extend.edit_button =
|
||||
$('<div class="buttons"><button ecmd="edit">编辑</button><button ecmd="up">上移</button><button ecmd="down">下移</button><button ecmd="remove">移除</button></div>');
|
||||
}
|
||||
Dialog.extend.edit_button.insertAfter(elem);
|
||||
},
|
||||
show: function (elem) {
|
||||
this.init(elem);
|
||||
if (!this.footer_buttons) {//<button ecmd="add">添加新的扩展</button>
|
||||
this.footer_buttons = $('<div class="obj-money"><span for="import" class="footer-item">导入</span><span for="export" class="footer-item">导出</span><span for="add" class="footer-item">添加扩展</span></div>');
|
||||
}
|
||||
Dialog.footerElement.append(this.footer_buttons);
|
||||
},
|
||||
command: function (cmd) {
|
||||
const func = this['cmd_' + cmd];
|
||||
if (func) func.call(this);
|
||||
},
|
||||
cmd_import: function () {
|
||||
if (!this.fileinput) {
|
||||
let elem = $('<input type="file" style="display:none" accept=".json" />')[0];
|
||||
document.body.appendChild(elem);
|
||||
this.fileinput = elem;
|
||||
elem.addEventListener('change', function (e) {
|
||||
const file = e.target.files[0];
|
||||
if (!file) {
|
||||
return ReceiveMessage('<red>未选择扩展文件。</red>');
|
||||
}
|
||||
const fileExt = file.name.split('.').pop().toLowerCase();
|
||||
const validMimeTypes = ['application/json', 'text/json', 'text/plain'];
|
||||
if (fileExt !== 'json' && !validMimeTypes.includes(file.type)) {
|
||||
e.target.value = '';
|
||||
return ReceiveMessage('<red>请选择有效的JSON文件!</red>');
|
||||
}
|
||||
const reader = new FileReader();
|
||||
reader.onload = function (event) {
|
||||
try {
|
||||
const jsonObj = JSON.parse(event.target.result);
|
||||
Dialog.extend.setting = jsonObj.items;
|
||||
Dialog.extend.refresh_list();
|
||||
Dialog.extend.save_extend();
|
||||
ReceiveMessage("<cyn>扩展文件加载成功。</cyn>");
|
||||
} catch (error) {
|
||||
console.error("JSON解析错误:", error);
|
||||
ReceiveMessage('<red>扩展文件加载失败。</red>');
|
||||
}
|
||||
};
|
||||
reader.onerror = function () {
|
||||
console.error("文件读取错误:", reader.error);
|
||||
ReceiveMessage('<red>扩展文件读取失败。</red>');
|
||||
};
|
||||
reader.readAsText(file, 'utf-8');
|
||||
});
|
||||
}
|
||||
this.fileinput.click();
|
||||
|
||||
},
|
||||
cmd_export: function () {
|
||||
try {
|
||||
let jsonObj = {
|
||||
id: Process.player,
|
||||
version: "0.1",
|
||||
items: Dialog.extend.setting,
|
||||
};
|
||||
const jsonStr = JSON.stringify(jsonObj, null, 2);
|
||||
if (window.android && typeof window.android.saveJsonFile === "function") {
|
||||
// 传递文件名和JSON内容给安卓
|
||||
window.android.saveJsonFile("武神扩展.json", jsonStr);
|
||||
ReceiveMessage(`<cyn>扩展导出为本地文件【武神扩展.json】。</cyn>`);
|
||||
} else {
|
||||
const blob = new Blob([jsonStr], { type: "application/json;charset=utf-8" });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.style.display = "none ";
|
||||
a.download = '武神扩展.json';
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
URL.revokeObjectURL(url);
|
||||
ReceiveMessage(`<cyn>扩展导出为本地文件【武神扩展.json】。</cyn>`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("保存JSON文件失败:", error);
|
||||
alert("文件保存失败,请重试!");
|
||||
}
|
||||
},
|
||||
hide: function () {
|
||||
if (this.is_record) {
|
||||
this.stop_record();
|
||||
}
|
||||
if (this.list_elem.is('.hide')) {
|
||||
this.list_elem.removeClass('hide');
|
||||
this.edit_elem.addClass('hide');
|
||||
return false;
|
||||
}
|
||||
this.footer_buttons.remove(); 59
|
||||
}, close: function () {
|
||||
|
||||
},
|
||||
default_extend: [
|
||||
{
|
||||
name: "<red>全部击杀</red>",
|
||||
type: "button", for: "action",
|
||||
content: "kill @npc"
|
||||
},
|
||||
{
|
||||
name: "<gre>全部拾取</gre>",
|
||||
type: "button", for: "action",
|
||||
content: "get all from @item(尸体)"
|
||||
},
|
||||
{
|
||||
name: "<gre>返回武庙</gre>",
|
||||
type: "button", for: "map",
|
||||
paras: "name(扬州)",
|
||||
content: "jh fam 0 start;go north;go north;go west"
|
||||
},
|
||||
{
|
||||
name: "练习到指定等级",
|
||||
type: "button", for: "skill",
|
||||
content: "lianxi @id @input"
|
||||
},
|
||||
{
|
||||
name: "学习到指定等级",
|
||||
type: "button", for: "mskill",
|
||||
content: "xue @input @id from @master"
|
||||
}
|
||||
],
|
||||
init_extend: function () {
|
||||
if (!this.setting)
|
||||
this.setting = Util.storage.getItem('extends') ?? this.default_extend;
|
||||
this.init_extend_group();
|
||||
},
|
||||
init_extend_group: function () {
|
||||
this.groups = {};
|
||||
for (let item of this.setting) {
|
||||
this.init_extend_item(item);
|
||||
}
|
||||
},
|
||||
save_extend: function () {
|
||||
Util.storage.setItem('extends', this.setting);
|
||||
this.init_extend_group();
|
||||
Combat.refActions();
|
||||
},
|
||||
init_extend_item: function (item) {
|
||||
let group = this.groups[item.for];
|
||||
if (!group) group = this.groups[item.for] = [];
|
||||
let cmd = item.content;
|
||||
if (item.on === true) {
|
||||
item.on = {};
|
||||
item.on[Process.player] = 1;
|
||||
}
|
||||
if (!cmd || !item.on || !item.on[Process.player]) return;
|
||||
if (cmd[0] !== '#') cmd = '#' + cmd;
|
||||
|
||||
group.push({
|
||||
name: item.name,
|
||||
extend: true,
|
||||
check: this.regex[item.for] ?
|
||||
this.match(item.paras) : this.condtion(item.paras),
|
||||
cmd: cmd
|
||||
});
|
||||
},
|
||||
match: function (paras) {
|
||||
try {
|
||||
if (!paras) return null;
|
||||
return this.express.match.bind(this, new RegExp(paras));
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
return null;
|
||||
}
|
||||
},
|
||||
exp_reg: /(\w+)\((>=|<=|!=|>|<)?(.+?)\)/g,
|
||||
condtion: function (paras) {
|
||||
if (!paras) return null;
|
||||
let match = null;
|
||||
let funcs = [];
|
||||
while (match = this.exp_reg.exec(paras)) {
|
||||
let prop = match[1];
|
||||
let oper = match[2];
|
||||
let para = match[3];
|
||||
if (!prop || !para) return null;
|
||||
if (oper) {
|
||||
let func = this.express[oper];
|
||||
if (!func) return null;
|
||||
funcs.push(func.bind(this, prop, para));
|
||||
} else {
|
||||
if (para[0] === '/' && para[para.length - 1] === '/')
|
||||
funcs.push(this.express.match_prop.bind(this, prop, new RegExp(para.substring(1, para.length - 1))));
|
||||
else
|
||||
funcs.push(this.express.def.bind(this, prop, para));
|
||||
}
|
||||
}
|
||||
return funcs.length > 0 ? funcs : null;
|
||||
}, express: {
|
||||
">=": function (prop, value, obj) {
|
||||
return obj[prop] >= parseInt(value);
|
||||
}, ">": function (prop, value, obj) {
|
||||
return obj[prop] > parseInt(value);
|
||||
}, "<": function (prop, value, obj) {
|
||||
return obj[prop] < parseInt(value);
|
||||
}, "<=": function (prop, value, obj) {
|
||||
return obj[prop] <= parseInt(value);
|
||||
}, "=": function (prop, value, obj) {
|
||||
return obj[prop] = parseInt(value);
|
||||
}, "!=": function (prop, value, obj) {
|
||||
return obj[prop] != parseInt(value);
|
||||
},
|
||||
match: function (regex, text) {
|
||||
let result = regex.exec(text);
|
||||
if (!result) return false;
|
||||
SCRIPT.lAST_MATCHES = result;
|
||||
return true;
|
||||
},
|
||||
match_prop: function (prop, regex, obj) {
|
||||
let str = obj[prop];
|
||||
if (!str || !regex) return false;
|
||||
return regex.test(str);
|
||||
},
|
||||
def: function (prop, value, obj) {
|
||||
let str = obj[prop];
|
||||
if (typeof str === 'number')
|
||||
return str === parseInt(value);
|
||||
else if (typeof str === 'boolean')
|
||||
return str && str.toString() === value;
|
||||
return str && str.indexOf(value) > -1;
|
||||
}
|
||||
},
|
||||
query: function (type, para) {
|
||||
let cmds = [];
|
||||
this.append(cmds, type, para);
|
||||
return cmds;
|
||||
},
|
||||
append: function (cmds, type, para) {
|
||||
let items = this.groups[type];
|
||||
if (!items) return;
|
||||
for (let item of items) {
|
||||
if (this.check_para(item, para)) {
|
||||
cmds.push(item)
|
||||
}
|
||||
}
|
||||
},
|
||||
message_filter: function (mes) {
|
||||
|
||||
},
|
||||
data_filter: function () {
|
||||
|
||||
},
|
||||
trigger: function (msg) {
|
||||
if (!this.groups) return;
|
||||
let items = this.groups.message;
|
||||
if (!items) return;
|
||||
for (let item of items) {
|
||||
if (!item.check) continue;
|
||||
if (item.check(msg)) {
|
||||
SCRIPT.run(item.cmd);
|
||||
}
|
||||
}
|
||||
},
|
||||
process: function (data) {
|
||||
if (!this.groups) return;
|
||||
let items = this.groups.data;
|
||||
if (!items) return;
|
||||
for (let item of items) {
|
||||
if (this.check_para(item, data)) {
|
||||
SCRIPT.LAST_DATA = data;
|
||||
SCRIPT.run(item.cmd);
|
||||
}
|
||||
}
|
||||
},
|
||||
check_para: function (item, para) {
|
||||
if (!item.check) return true;
|
||||
for (let func of item.check) {
|
||||
if (!func(para)) return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
onButtonClick: function () {
|
||||
let paras = $(this).attr('ecmd').split('_');
|
||||
let cmd = paras[0];
|
||||
paras[0] = $(this);
|
||||
let func = Dialog.extend['cmd_' + cmd];
|
||||
func && func.apply(Dialog.extend, paras);
|
||||
}, cmd_add: function () {
|
||||
this.edit_elem.removeClass('hide');
|
||||
this.list_elem.addClass('hide');
|
||||
this.edit_elem.attr("sid", '-1');
|
||||
let elems = this.edit_elem.find('input, textarea');
|
||||
for (let elem of elems) {
|
||||
$(elem).val("");
|
||||
}
|
||||
},
|
||||
cmd_up: function () {
|
||||
this.cmd_move(-1);
|
||||
},
|
||||
cmd_down: function () {
|
||||
this.cmd_move(1);
|
||||
},
|
||||
cmd_move: function (mv) {
|
||||
let item = this.selected_item;
|
||||
if (!item) return;
|
||||
let index = this.setting.indexOf(item);
|
||||
let index2 = this.setting.indexOf(item) + mv;
|
||||
if (index2 < 0 || index2 >= this.setting.length)
|
||||
return;
|
||||
this.setting.splice(index, 1);
|
||||
this.setting.splice(index2, 0, item);
|
||||
this.refresh_list();
|
||||
this.save_extend();
|
||||
|
||||
},
|
||||
cmd_edit: function () {
|
||||
let item = this.selected_item;
|
||||
if (!item) return;
|
||||
this.edit_elem.show();
|
||||
this.list_elem.hide();
|
||||
this.edit_elem.attr("sid", this.setting.indexOf(item));
|
||||
let elems = this.edit_elem.find('input, textarea, select');
|
||||
for (let elem of elems) {
|
||||
let val = $(elem).val();
|
||||
let val2 = item[elem.getAttribute('prop')];
|
||||
if (val2 !== val) {
|
||||
$(elem).val(val2).change();;
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
cmd_save: function () {
|
||||
let index = parseInt(this.edit_elem.attr('sid'));
|
||||
|
||||
let elems = this.edit_elem.find('input, textarea, select');
|
||||
let item = {};
|
||||
for (let elem of elems) {
|
||||
item[elem.getAttribute("prop")] = elem.value;
|
||||
}
|
||||
if (!item.name) return this.show_error('name');
|
||||
if (!item.type) return this.show_error('type');
|
||||
if (!item.content) return this.show_error('content');
|
||||
if (item.paras) {
|
||||
if (Dialog.extend.regex[item.for]) {
|
||||
item.check = this.match(item.paras);
|
||||
} else {
|
||||
item.check = this.condtion(item.paras);
|
||||
}
|
||||
if (!item.check) return this.show_error('paras');
|
||||
}
|
||||
this.hide();
|
||||
$(this.create_item(item, this.setting.length)).appendTo(this.list_elem);
|
||||
|
||||
if (index < 0) {
|
||||
this.setting.push(item);
|
||||
} else {
|
||||
item.on = this.setting[index].on;
|
||||
this.setting[index] = item;
|
||||
this.refresh_list();
|
||||
}
|
||||
this.save_extend();
|
||||
|
||||
}, cmd_remove: function () {
|
||||
let item = this.selected_item;
|
||||
if (!item) return;
|
||||
this.setting.Remove(item);
|
||||
this.refresh_list();
|
||||
this.save_extend();
|
||||
},
|
||||
show_error: function (key) {
|
||||
let elem = this.element.find('[prop="' + key + '"]').parent();
|
||||
elem.addClass('error-shake');
|
||||
setTimeout(() => {
|
||||
elem.removeClass('error-shake');
|
||||
}, 1500);
|
||||
}, cmd_show: function (elem, t) {
|
||||
let infos = SCRIPT.helper[t];
|
||||
if (!infos) return;
|
||||
let html = [];
|
||||
for (let i = 0; i < infos.length; i++) {
|
||||
html.push('<li>', infos[i], '</li>');
|
||||
}
|
||||
let ul = elem.parent();
|
||||
ul.html(html.join(""));
|
||||
ul.next().html('返回').attr('ecmd', 'return');
|
||||
},
|
||||
cmd_return: function (elem) {
|
||||
elem.html('保存').attr('ecmd', 'save').prev().html(this.helper);
|
||||
}
|
||||
};
|
||||
530
src/dialog/jh.js
Normal file
530
src/dialog/jh.js
Normal file
@@ -0,0 +1,530 @@
|
||||
|
||||
|
||||
const jh_fam = {
|
||||
name: "门派",
|
||||
items: null,
|
||||
selected_index: 0,
|
||||
type: "fam",
|
||||
onDetail: function (data) {
|
||||
var fb = this.items[data.index];
|
||||
if (!fb) return;
|
||||
fb.type = '门派';
|
||||
fb.desc = data.desc;
|
||||
fb.sp = data.sp;
|
||||
fb.actions = data.actions;
|
||||
fb.skills = data.skills;
|
||||
return this.showDetail(fb);
|
||||
},
|
||||
showDetail: function (fb) {
|
||||
var html = ["<pre><hig>"];
|
||||
html.push(fb.name);
|
||||
html.push("</hig>\n");
|
||||
html.push(fb.desc);
|
||||
if (fb.sp) {
|
||||
html.push("\n<hig>特点:");
|
||||
html.push(fb.sp);
|
||||
html.push("</hig>\n");
|
||||
}
|
||||
|
||||
this.append_actions(html, fb);
|
||||
html.push('<div class="item-commands"><span cmd="jh fam ' + fb.index + ' start">进入地图</span>');
|
||||
let cmds = [];
|
||||
Dialog.extend.append(cmds, 'map', fb);
|
||||
for (let item of cmds) {
|
||||
html.push('<span cmd="', item.cmd, '">', item.name, '</span>');
|
||||
}
|
||||
html.push('</div>');
|
||||
if (fb.skills) {
|
||||
html.push(fb.skills);
|
||||
}
|
||||
|
||||
html.push("</pre>");
|
||||
this.descElement.html(html.join(""));
|
||||
this.select(fb.index);
|
||||
},
|
||||
append_actions: function (html, fb) {
|
||||
let actions = fb.actions ?? [];
|
||||
html.push('<div class="fb-actions">');
|
||||
for (let item of actions) {
|
||||
html.push('<div class="fb-action">');
|
||||
html.push('<span class="action-desc">', item[2] ?? "", "</span>");
|
||||
if (item[1])
|
||||
html.push('<span class="action-name" cmd="', item[0], '">', item[1], "</span>");
|
||||
html.push('</div>');
|
||||
}
|
||||
|
||||
html.push('</div>');
|
||||
},
|
||||
show: function (left_panel, right_panel) {
|
||||
var html = [];
|
||||
for (var i = 0; i < this.items.length; i++) {
|
||||
var fb = this.items[i];
|
||||
html.push('<div class="fam-item');
|
||||
html.push('" index="', i, '">', fb.name, "</div>");
|
||||
fb.index = i;
|
||||
}
|
||||
left_panel.html(html.join(""));
|
||||
this.listElement = left_panel;
|
||||
this.descElement = right_panel;
|
||||
this.onClickItem(this.selected_index);
|
||||
}, select: function (index) {
|
||||
var elem = this.listElement.find("div[index='" + index + "']");
|
||||
if (elem.length && !elem.is(".selected")) {
|
||||
var top = elem[0].offsetTop;
|
||||
var height = this.listElement.height();
|
||||
if (top > height / 2) {
|
||||
top = (height - elem.height()) / 2;
|
||||
this.listElement[0].scrollTop = top;
|
||||
}
|
||||
if (this.selectedItem) this.selectedItem.removeClass("selected");
|
||||
this.selectedItem = elem;
|
||||
this.selectedItem.addClass("selected");
|
||||
this.selected_index = index;
|
||||
}
|
||||
}, onClickItem: function (index) {
|
||||
const item = this.items[index];
|
||||
if (!item.desc) SendCommand("jh " + this.type + " " + index);
|
||||
else this.showDetail(item);
|
||||
this.select(index);
|
||||
},
|
||||
append_footer: function () {
|
||||
let fb = this.items[this.selected_index];
|
||||
Dialog.footerElement.find('.item-commands').
|
||||
html(`<span cmd="jh fam ${fb.index} start">进入地图</span>`);
|
||||
}
|
||||
};
|
||||
const jh_fb = {
|
||||
name: "副本",
|
||||
type: "fb",
|
||||
items: null,
|
||||
selected_index: -1,
|
||||
select: jh_fam.select,
|
||||
onClickItem: jh_fam.onClickItem,
|
||||
onDetail: function (data) {
|
||||
var fb = this.items[data.index];
|
||||
if (!fb) return;
|
||||
fb.type = '副本';
|
||||
fb.desc = data.desc;
|
||||
fb.reward = data.reward;
|
||||
fb.diffs = data.diffs;
|
||||
fb.status = data.status;
|
||||
return this.showDetail(fb);
|
||||
}, update_unlock: function (unlock) {
|
||||
this.unlock = unlock;
|
||||
for (let i = 0; i < this.items.length; i++) {
|
||||
this.items[i].unlock = unlock >= i;
|
||||
}
|
||||
if (this.selected_index < 0)
|
||||
this.selected_index = unlock;
|
||||
|
||||
}, show: function (left_panel, right_panel) {
|
||||
this.listElement = left_panel;
|
||||
this.descElement = right_panel;
|
||||
var html = ["<div class='fb-content'>"];
|
||||
for (var i = 0; i < this.items.length; i++) {
|
||||
var fb = this.items[i];
|
||||
html.push('<div class="fb-item');
|
||||
if (!fb.unlock) {
|
||||
html.push(" lock");
|
||||
}
|
||||
fb.index = i;
|
||||
html.push('" index="', i, '">', fb.name, "</div>");
|
||||
}
|
||||
html.join("</div>");
|
||||
this.listElement.html(html.join(""));
|
||||
this.onClickItem(this.selected_index);
|
||||
},
|
||||
show_first: function (elem) {
|
||||
let text = elem.prev().html();
|
||||
text && ReceiveMessage(text);
|
||||
},
|
||||
fb_models: ['普通', '<red>困难</red>', '<cyn>组队</cyn>'],
|
||||
showDetail: function (fb) {
|
||||
var html = ["<pre>"];
|
||||
html.push(fb.name);
|
||||
if (fb.unlock) {
|
||||
html.push("\n<hig>已解锁</hig>\n");
|
||||
} else {
|
||||
html.push("\n<red>未解锁</red>\n");
|
||||
}
|
||||
html.push(fb.desc);
|
||||
this.append_status(html, fb);
|
||||
if (fb.unlock && fb.diffs) {
|
||||
html.push('<div class="item-commands">');
|
||||
for (let i = 0; i < fb.diffs.length; i++) {
|
||||
if (fb.diffs[i])
|
||||
html.push('<span cmd="jh fb ',
|
||||
fb.index, ' start', i + 1, '">', this.fb_buttons[i], '</span>');
|
||||
}
|
||||
let cmds = [];
|
||||
Dialog.extend.append(cmds, 'map', fb);
|
||||
for (let item of cmds) {
|
||||
html.push('<span cmd="', item.cmd, '">', item.name, '</span>');
|
||||
}
|
||||
html.push('</div>');
|
||||
}
|
||||
html.push(fb.reward);
|
||||
html.push("</pre>");
|
||||
this.descElement.html(html.join(""));
|
||||
this.select(fb.index);
|
||||
|
||||
}, append_status: function (html, fb) {
|
||||
const sts = fb.status ?? [];
|
||||
if (!sts.length) return;
|
||||
html.push('<div class="fb-actions">');
|
||||
for (let i = 0; i < sts.length; i++) {
|
||||
let status = sts[i];
|
||||
if (!status) continue;
|
||||
if (status[0] === 1) {
|
||||
html.push('<div class="fb-action finshed">');
|
||||
html.push('<span class="action-desc">由', status[1], "首次通过", "</span>");
|
||||
html.push('<span class="action-name" cmd="cr2 ', fb.index, ' ', i, '">', this.fb_models[i], "</span>");
|
||||
html.push('</div>');
|
||||
} else {
|
||||
html.push('<div class="fb-action">');
|
||||
html.push('<span class="action-desc">该模式尚未完成首杀',
|
||||
status[1] ? ",称号奖励:" + status[1] : "",
|
||||
"</span>");
|
||||
html.push('<span class="action-name" cmd="cr2 ', fb.index, ' ', i, '">', this.fb_models[i], "</span>");
|
||||
html.push('</div>');
|
||||
}
|
||||
}
|
||||
html.push('</div>');
|
||||
},
|
||||
fb_buttons: ['进入副本', '困难模式', '组队进入'],
|
||||
append_footer: function () {
|
||||
let fb = this.items[this.selected_index];
|
||||
let html = [];
|
||||
if (fb.unlock) {
|
||||
for (let i = 0; i < fb.diffs.length; i++) {
|
||||
if (fb.diffs[i])
|
||||
html.push('<span cmd="jh fb ',
|
||||
fb.index, ' start', i + 1, '">', this.fb_buttons[i], '</span>');
|
||||
}
|
||||
}
|
||||
Dialog.footerElement.find('.item-commands').html(html.join(""));
|
||||
}
|
||||
};
|
||||
const jh_ar = {
|
||||
name: "禁地",
|
||||
items: null,
|
||||
type: "ar",
|
||||
selected_index: 0,
|
||||
select: jh_fam.select,
|
||||
onClickItem: jh_fam.onClickItem,
|
||||
append_status: jh_fb.append_status,
|
||||
append_actions: jh_fam.append_actions,
|
||||
fb_models: ['普通', '普通', '组队'],
|
||||
onDetail: function (data) {
|
||||
var fb = this.items[data.index];
|
||||
if (!fb) return;
|
||||
fb.type = '禁地';
|
||||
fb.desc = data.desc;
|
||||
fb.actions = data.actions;
|
||||
fb.status = data.status;
|
||||
fb.reward = data.reward;
|
||||
return this.showDetail(fb);
|
||||
}, update_unlock: function (unlock) {
|
||||
for (let i = 0; i < this.items.length; i++) {
|
||||
this.items[i].unlock = (unlock & Math.pow(2, i)) !== 0;
|
||||
}
|
||||
}, show: function (left_panel, right_panel) {
|
||||
var html = ["<div class='fb-content'>"];
|
||||
let count = Math.max(this.items.length, 10);
|
||||
for (var i = 0; i < count; i++) {
|
||||
var fb = this.items[i];
|
||||
html.push('<div class="fb-item');
|
||||
if (fb) {
|
||||
if (!fb.unlock) {
|
||||
html.push(" lock");
|
||||
}
|
||||
html.push('" index="', i, '">', fb.name, "</div>");
|
||||
fb.index = i;
|
||||
} else {
|
||||
html.push('"> </div>');
|
||||
}
|
||||
}
|
||||
html.join("</div>");
|
||||
this.listElement = left_panel;
|
||||
this.descElement = right_panel;
|
||||
this.listElement.html(html.join(""));
|
||||
this.onClickItem(this.selected_index);
|
||||
|
||||
}, showDetail: function (fb) {
|
||||
var html = ["<pre>"];
|
||||
html.push(fb.name);
|
||||
if (fb.unlock) {
|
||||
html.push("\n<hig>已解锁</hig>\n");
|
||||
} else {
|
||||
html.push("\n<red>未解锁</red>\n");
|
||||
}
|
||||
html.push(fb.desc, '\n');
|
||||
this.append_status(html, fb);
|
||||
this.append_actions(html, fb);
|
||||
if (fb.unlock) {
|
||||
html.push('<div class="item-commands">');
|
||||
html.push(`<span cmd="jh ar ${fb.index} start">进入地图</span>`);
|
||||
let cmds = [];
|
||||
Dialog.extend.append(cmds, 'map', fb);
|
||||
for (let item of cmds) {
|
||||
html.push('<span cmd="', item.cmd, '">', item.name, '</span>');
|
||||
}
|
||||
html.push('</div>');
|
||||
}
|
||||
html.push(fb.reward);
|
||||
html.push("</pre>");
|
||||
this.descElement.html(html.join(""));
|
||||
this.select(fb.index);
|
||||
|
||||
},
|
||||
append_footer: function () {
|
||||
let fb = this.items[this.selected_index];
|
||||
if (fb.unlock)
|
||||
Dialog.footerElement.find('.item-commands').
|
||||
html(`<span cmd="jh ar ${fb.index} start">进入地图</span>`);
|
||||
else
|
||||
Dialog.footerElement.find('.item-commands').empty();
|
||||
}
|
||||
};
|
||||
const MAP_TYPES = {
|
||||
fb: jh_fb,
|
||||
fam: jh_fam,
|
||||
ar: jh_ar
|
||||
};
|
||||
export default {
|
||||
init: function () {
|
||||
Dialog.injectStyle(jh_css);
|
||||
},
|
||||
close: function () {
|
||||
this.element.remove();
|
||||
this.isShow = false;
|
||||
},
|
||||
onData: function (data) {
|
||||
if (data.close) {
|
||||
return Dialog.isShow && Dialog.hide();
|
||||
}
|
||||
if (data.desc) return this.selected_item.onDetail(data);
|
||||
|
||||
if (data.unlock !== undefined || data.unlock2 !== undefined) {
|
||||
return this.update_lock(data);
|
||||
}
|
||||
if (data.refresh !== undefined && this.isLoad) {
|
||||
let dialog = MAP_TYPES[data.t];
|
||||
let item = dialog.items[data.refresh];
|
||||
if (item && item.desc) {
|
||||
item.desc = null;
|
||||
let index = dialog.items.indexOf(item);
|
||||
if (dialog.selected_index == index) {
|
||||
dialog.onClickItem(index);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!data.fbs) return;
|
||||
jh_fam.items = data.families.map(function (x) { return { name: x, unlock: false }; });
|
||||
jh_fb.items = data.fbs.map(function (x) { return { name: x }; });
|
||||
jh_ar.items = data.areas.map(function (x) { return { name: x, unlock: false }; });
|
||||
this.selected_item.show(this.listElement, this.descElement);
|
||||
},
|
||||
show: function () {
|
||||
if (this.isShow) return;
|
||||
if (!this.element)
|
||||
this.element = $("<div class='dialog-fb'><div class='fb-left'></div><div class='fb-right'></div></div>");
|
||||
this.listElement = this.element.find(".fb-left").on("click",
|
||||
".fb-item,.fam-item", this.item_click);
|
||||
this.descElement = this.element.find(".fb-right");
|
||||
Dialog.title("江湖");
|
||||
Dialog.icon("home");
|
||||
this.element.appendTo(Dialog.contentElement);
|
||||
this.isShow = true;
|
||||
if (this.isLoad) {
|
||||
SendCommand("jh fb lock");
|
||||
} else {
|
||||
SendCommand("jh");
|
||||
this.isLoad = true;
|
||||
this.selected_item = this.footers[0];
|
||||
}
|
||||
this.create_footer();
|
||||
},
|
||||
selected_item: null,
|
||||
footers: [jh_fam, jh_fb, jh_ar],
|
||||
create_footer: function () {
|
||||
var html = [];
|
||||
for (var i = 0; i < this.footers.length; i++) {
|
||||
let item = this.footers[i];
|
||||
html.push("<span class='footer-item" +
|
||||
(item == this.selected_item ? " select" : "") + "' for='" + i + "'>"
|
||||
+ this.footers[i].name + "</span>");
|
||||
}
|
||||
html.push('<div class="item-commands"></div>');
|
||||
Dialog.footerElement.html(html.join(""));
|
||||
}, item_click: function () {
|
||||
var elem = $(this);
|
||||
if (elem.is(".selected")) return;
|
||||
let index = elem.attr("index");
|
||||
if (index !== undefined)
|
||||
Dialog.jh.selected_item.onClickItem(index);
|
||||
},
|
||||
update_lock: function (data) {
|
||||
if (data.unlock >= 0 && jh_fb.items) {
|
||||
jh_fb.update_unlock(data.unlock);
|
||||
if (this.selected_item === jh_fb)
|
||||
jh_fb.show(this.listElement, this.descElement);
|
||||
}
|
||||
if (data.unlock2 >= 0 && jh_ar.items) {
|
||||
jh_ar.update_unlock(data.unlock2);
|
||||
if (this.selected_item === jh_ar)
|
||||
jh_ar.show(this.listElement, this.descElement);
|
||||
}
|
||||
|
||||
},
|
||||
footerChanged: function (index) {
|
||||
let item = this.footers[index];
|
||||
if (item == this.selected_item) return;
|
||||
this.selected_item = item;
|
||||
Dialog.footerElement.find('.item-commands').empty();
|
||||
item.show(this.listElement, this.descElement);
|
||||
}
|
||||
};
|
||||
|
||||
const jh_css = `
|
||||
|
||||
|
||||
.dialog-fb {
|
||||
height: 25.5em;
|
||||
overflow-y: hidden;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.dialog-fb>.fb-left {
|
||||
width: 12.5em;
|
||||
height: 100%;
|
||||
text-align: center;
|
||||
margin-top: 0.5em;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.dialog-fb>.fb-right {
|
||||
flex: 1;
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
padding-left: 0.5em;
|
||||
}
|
||||
|
||||
.fb-actions {
|
||||
margin-top: 0.5em;
|
||||
}
|
||||
|
||||
.fb-actions>.fb-action {
|
||||
line-height: 2em;
|
||||
padding-left: 1em;
|
||||
border-radius: 4px;
|
||||
border-left-width: 2px;
|
||||
border-left-style: solid;
|
||||
border-left-color: gray;
|
||||
white-space: nowrap;
|
||||
overflow-x: auto;
|
||||
margin-bottom: 0.5em;
|
||||
background-color: #111;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.fb-actions>.fb-action>.action-desc {
|
||||
flex: 1;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
color: gray;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.fb-actions>.fb-action>.action-name {
|
||||
flex: 0;
|
||||
background-color: #222;
|
||||
padding-left: 1em;
|
||||
padding-right: 1em;
|
||||
}
|
||||
|
||||
.fb-actions>.fb-action>.action-name:hover {
|
||||
background-color: #333;
|
||||
}
|
||||
|
||||
.fb-actions>.finshed {
|
||||
border-left-color: #00FF00;
|
||||
}
|
||||
|
||||
.fb-actions>.finshed>.action-desc {
|
||||
color: #00FF00;
|
||||
}
|
||||
|
||||
.dialog-fb>.fb-right>pre {
|
||||
white-space: pre-wrap;
|
||||
margin: 0.5em 0.5em 2em 0.5em;
|
||||
}
|
||||
|
||||
.dialog-fb>.fb-left>.fb-content {
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.dialog-fb>.fb-left>.fb-content>.fb-item {
|
||||
line-height: 2em;
|
||||
padding-left: 1.5em;
|
||||
border-radius: 4px;
|
||||
border-left-width: 2px;
|
||||
border-left-style: solid;
|
||||
border-left-color: gray;
|
||||
white-space: nowrap;
|
||||
overflow-x: auto;
|
||||
margin-bottom: 0.5em;
|
||||
background-color: #111;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
|
||||
.dialog-fb>.fb-left>.fam-item {
|
||||
line-height: 2em;
|
||||
padding-left: 0.5em;
|
||||
border-radius: 4px;
|
||||
border-left-width: 2px;
|
||||
border-left-style: solid;
|
||||
border-left-color: gray;
|
||||
white-space: nowrap;
|
||||
overflow-x: auto;
|
||||
margin-bottom: 0.5em;
|
||||
background-color: #111;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.dialog-fb>.fb-left>.fb-content>.line {
|
||||
height: 1.25em;
|
||||
width: 0px;
|
||||
border-left: 1px solid #343434;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
margin-top: -1em;
|
||||
margin-bottom: -1em;
|
||||
}
|
||||
|
||||
.dialog-fb>.fb-left>.fb-content>.lock {
|
||||
border-color: #bebebe;
|
||||
color: #bebebe !important;
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.dialog-fb>.fb-left>.fb-content .selected,
|
||||
.dialog-fb>.fb-left>.selected {
|
||||
border-color: #00ff00;
|
||||
color: #00ff00;
|
||||
}
|
||||
|
||||
.dialog-fb>.fb-left>.fb-content>.lock:before {
|
||||
font-family: 'Glyphicons Halflings';
|
||||
content: "\\e033";
|
||||
float: left;
|
||||
margin-left: 0.25em;
|
||||
opacity: 0.6;
|
||||
}
|
||||
`;
|
||||
194
src/dialog/keys.js
Normal file
194
src/dialog/keys.js
Normal file
@@ -0,0 +1,194 @@
|
||||
|
||||
import Util from '../utils/util.js';
|
||||
import SCRIPT from '../script.js';
|
||||
|
||||
const Keys = {
|
||||
groups: [{
|
||||
name: "移动",
|
||||
items: [
|
||||
{ name: "左", key: null, cmd: "#go @dir(left)" },
|
||||
{ name: "右", key: null, cmd: "#go @dir(right)" },
|
||||
{ name: "上", key: null, cmd: "#go @dir(up)" },
|
||||
{ name: "下", key: null, cmd: "#go @dir(down)" },
|
||||
{ name: "左上", key: null, cmd: "#go @dir(leftup)" },
|
||||
{ name: "左下", key: null, cmd: "#go @dir(leftdown)" },
|
||||
{ name: "右上", key: null, cmd: "#go @dir(rightup)" },
|
||||
{ name: "右下", key: null, cmd: "#go @dir(rightdown)" }
|
||||
]
|
||||
}, {
|
||||
name: "菜单",
|
||||
items: [
|
||||
{ name: "属性", key: null, cmd: "#menu score" },
|
||||
{ name: "背包", key: null, cmd: "#menu pack" },
|
||||
{ name: "技能", key: null, cmd: "#menu skills" },
|
||||
{ name: "任务", key: null, cmd: "#menu tasks" },
|
||||
{ name: "商城", key: null, cmd: "#menu shop" },
|
||||
{ name: "社交", key: null, cmd: "#menu message" },
|
||||
{ name: "排行", key: null, cmd: "#menu stats" },
|
||||
{ name: "设置", key: null, cmd: "#menu setting" },
|
||||
{ name: "动作", key: null, cmd: "#menu showcombat" },
|
||||
{ name: "活动", key: null, cmd: "#menu events" },
|
||||
{ name: "聊天", key: null, cmd: "#menu showchat" },
|
||||
{ name: "停止", key: null, cmd: "#menu stopstate" },
|
||||
{ name: "江湖", key: null, cmd: "#menu jh" }
|
||||
]
|
||||
}
|
||||
],
|
||||
setting: null,
|
||||
show: function (elem) {
|
||||
this.element = elem;
|
||||
this.init();
|
||||
elem.on('click', '.skey-item', this.item_clicked);
|
||||
document.body.addEventListener('keydown', this.record_press);
|
||||
}, hide: function () {
|
||||
document.body.removeEventListener('keydown', this.record_press);
|
||||
}, close: function () {
|
||||
document.body.removeEventListener('keydown', this.record_press);
|
||||
},
|
||||
record_press: function (e) {
|
||||
let item = Dialog.keys.select_item;
|
||||
if (!item) return;
|
||||
let keyitem = Dialog.keys.get_item(item.attr("sid"));
|
||||
if (!keyitem) return;
|
||||
if (e.keyCode === 8 || e.keyCode === 27) {
|
||||
Dialog.keys.save_setting(keyitem, null);
|
||||
return item.find('.skey-key').html('');
|
||||
}
|
||||
let code = Dialog.keys.get_key_code(e);
|
||||
Dialog.keys.save_setting(keyitem, code);
|
||||
item.find('.skey-key').html(keyitem.key);
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}, get_key_code: function (e) {
|
||||
let code = e.code;
|
||||
if (e.ctrlKey) {
|
||||
if (e.key === "Control") return;
|
||||
code = "Ctrl+" + code;
|
||||
}
|
||||
if (e.altKey) {
|
||||
if (e.key === "Alt") return;
|
||||
code = "Alt+" + code;
|
||||
}
|
||||
if (e.shiftKey) {
|
||||
if (e.key === "Shift") return;
|
||||
code = "Shift+" + code;
|
||||
}
|
||||
return code;
|
||||
|
||||
}, save_setting: function (item, key) {
|
||||
item.key = key;
|
||||
if (!this.setting) this.setting = {};
|
||||
if (!key) {
|
||||
key = this.id2keys[item.id];
|
||||
if (key) delete this.setting[key];
|
||||
delete this.id2keys[item.id];
|
||||
}
|
||||
else if (key) {
|
||||
if (this.setting[key]) {
|
||||
if (this.setting[key] === item.id) {
|
||||
return;
|
||||
}
|
||||
let old_item = this.get_item(this.setting[key]);
|
||||
if (old_item) {
|
||||
old_item.key = null;
|
||||
this.element.find('.skey-item[sid="'
|
||||
+ old_item.id + '"]>.skey-key').html("");
|
||||
}
|
||||
}
|
||||
this.setting[key] = item.id;
|
||||
}
|
||||
Util.storage.setItem('keys', this.setting);
|
||||
}, get_item: function (id) {
|
||||
if (this.groups.length === 2) this.init();
|
||||
let sid = id.split('_');
|
||||
let group = Dialog.keys.groups[parseInt(sid[0])];
|
||||
if (!group) return;
|
||||
let keyitem = group.items[parseInt(sid[1])];
|
||||
return keyitem;
|
||||
},
|
||||
default_keys: {
|
||||
"KeyW": "0_2", "KeyA": "0_0", "KeyR": "0_6",
|
||||
"KeyD": "0_1", "KeyS": "0_3", "KeyQ": "0_4"
|
||||
},
|
||||
init_key: function () {
|
||||
if (this.load_storage) return;
|
||||
if (Util.isMobile) return;
|
||||
this.load_storage = true;
|
||||
this.setting = Util.storage.getItem('keys');
|
||||
window.addEventListener('keydown', this.keypress);
|
||||
this.id2keys = {};
|
||||
if (!this.setting) return;
|
||||
for (let key in this.setting) {
|
||||
this.id2keys[this.setting[key]] = key;
|
||||
}
|
||||
},
|
||||
keypress: function (e) {
|
||||
if (e.target !== document.body) return;
|
||||
let setting = Dialog.keys.setting;
|
||||
if (!setting) return;
|
||||
let code = Dialog.keys.get_key_code(e);
|
||||
if (setting[code]) {
|
||||
let item = Dialog.keys.get_item(setting[code]);
|
||||
if (item) {
|
||||
SCRIPT.run(item.cmd);
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
},
|
||||
item_clicked: function () {
|
||||
let item = Dialog.keys.select_item;
|
||||
if (item) item.removeClass('selected');
|
||||
Dialog.keys.select_item = $(this).addClass('selected');
|
||||
|
||||
},
|
||||
init: function () {
|
||||
if (this.groups.length > 2) return;
|
||||
let setting = this.id2keys || {}, id = null, j = 0;
|
||||
for (let group of this.groups) {
|
||||
for (let i = 0; i < group.items.length; i++) {
|
||||
id = j + "_" + i;
|
||||
group.items[i].id = id;
|
||||
group.items[i].key = setting[id];
|
||||
} j++;
|
||||
}
|
||||
let group = { name: "动作栏", items: [] };
|
||||
for (let i = 0; i < 12; i++) {
|
||||
|
||||
id = "2_" + i;
|
||||
group.items.push({
|
||||
name: "栏位" + (i + 1), id: id,
|
||||
cmd: "#action " + i, key: setting[id]
|
||||
});
|
||||
}
|
||||
this.groups.push(group);
|
||||
group = { name: "技能栏", items: [] };
|
||||
for (let i = 0; i < 12; i++) {
|
||||
id = "3_" + i;
|
||||
group.items.push({
|
||||
name: "栏位"
|
||||
+ (i + 1), id: id, cmd: "#pfm " + i, key: setting[id]
|
||||
});
|
||||
}
|
||||
this.groups.push(group);
|
||||
this.element && this.create_html();
|
||||
},
|
||||
create_html: function () {
|
||||
let html = [];
|
||||
let i = 0, j = 0;
|
||||
for (let group of this.groups) {
|
||||
html.push('<h3>', group.name, '</h3>');
|
||||
j = 0;
|
||||
for (let item of group.items) {
|
||||
html.push('<div class="skey-item" sid="', item.id, '">');
|
||||
html.push('<div class="skey-name">', item.name, '</div>');
|
||||
html.push('<div class="skey-key">', item.key, '</div>');
|
||||
html.push('</div>');
|
||||
j++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
this.element.html(html.join(""));
|
||||
}
|
||||
};
|
||||
|
||||
export default Keys;
|
||||
274
src/dialog/list.js
Normal file
274
src/dialog/list.js
Normal file
@@ -0,0 +1,274 @@
|
||||
|
||||
import Util from '../utils/util.js';
|
||||
export default {
|
||||
init: function () {
|
||||
Dialog.pack.init();
|
||||
},
|
||||
hide: function () {
|
||||
this.element.remove();
|
||||
this.isShow = false;
|
||||
},
|
||||
close: function () {
|
||||
this.hide();
|
||||
},
|
||||
updateitem: function (data) {
|
||||
if (data.store) {
|
||||
if (!this.stores || !this.isShow)
|
||||
return Dialog.pack.onData({ remove: data.store, id: data.id });
|
||||
var item = this.find_item(1, data.id);
|
||||
var store_item = this.find_item(3, data.storeid);
|
||||
if (!item) {
|
||||
item = Object.assign({}, store_item);
|
||||
item.id = data.id; item.count = (-data.store);
|
||||
Dialog.pack.items.push(item);
|
||||
} else {
|
||||
item.count -= data.store;
|
||||
}
|
||||
if (!store_item) {
|
||||
store_item = Object.assign({}, item);
|
||||
store_item.id = data.storeid; store_item.count = data.store;
|
||||
this.stores.push(store_item);
|
||||
} else {
|
||||
store_item.count += data.store;
|
||||
}
|
||||
this.store_count = data.sum ?? this.stores.length;
|
||||
if (store_item.count == 0) this.stores.Remove(store_item);
|
||||
if (item.count == 0) Dialog.pack.items.Remove(item);
|
||||
|
||||
} else if (data.sell) {
|
||||
var item = this.find_item(2, data.id);
|
||||
if (item) {
|
||||
item.count -= data.sell;
|
||||
return this.create_items(this.selllist, this.leftElement, 2, this.selllist.length);
|
||||
}
|
||||
}
|
||||
if (this.isstore && this.isShow) {
|
||||
this.create_items(this.stores, this.leftElement, 3,
|
||||
Math.max(this.max_store_count, 100));// this.max_store_count
|
||||
|
||||
Dialog.title("你的仓库中有" + this.store_count + "/" + this.max_store_count + "件物品");
|
||||
}
|
||||
this.update_pack();
|
||||
if (data.money != undefined) this.show_footer(data.money);
|
||||
}, find_item: function (otype, id) {
|
||||
var items = Dialog.pack.items;
|
||||
if (otype == 2) items = this.selllist;
|
||||
else if (otype == 3) items = this.stores;
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
if (items[i].id == id) { return items[i]; }
|
||||
}
|
||||
}, formatItems: function (data) {
|
||||
let items = [];
|
||||
for (let item of data) {
|
||||
items.push({
|
||||
name: item[0], id: item[1],
|
||||
count: item[2], grade: item[3],
|
||||
unit: item[4], value: item[5]
|
||||
});
|
||||
}
|
||||
return items;
|
||||
}, onData: function (data) {
|
||||
if (data.id) {
|
||||
return this.updateitem(data);
|
||||
}
|
||||
var gongji = data.gongji ?? data.jungong ?? data.yaoyuan ?? data.mvalue;
|
||||
if (data.selllist) {
|
||||
this.show();
|
||||
this.isstore = false;
|
||||
this.gongji = gongji;
|
||||
this.money_name = null;
|
||||
this.typeElement.hide();
|
||||
this.selllist = this.formatItems(data.selllist);
|
||||
if (data.gongji >= 0) this.money_name = '门派功绩';
|
||||
else if (data.jungong >= 0) this.money_name = "军功";
|
||||
else if (data.yaoyuan >= 0) this.money_name = "<ord>妖元</ord>";
|
||||
else this.money_name = data.mtype;
|
||||
this.create_items(this.selllist, this.leftElement, 2, this.selllist.length);
|
||||
Dialog.titleElement.html(data.title);
|
||||
Dialog.icon("shopping-cart");
|
||||
if (data.seller) this.seller = data.seller;
|
||||
this.update_pack();
|
||||
} else if (data.stores) {
|
||||
this.show();
|
||||
this.typeElement.show();
|
||||
this.isstore = true;
|
||||
this.stores = Dialog.pack.formatItems(data.stores);
|
||||
if (data.sum > 0) {
|
||||
this.typeElement.show();
|
||||
this.store_count = data.sum;
|
||||
}
|
||||
else {
|
||||
this.typeElement.hide();
|
||||
this.store_count = data.stores.length;
|
||||
}
|
||||
this.create_items(this.stores, this.leftElement, 3,
|
||||
Math.max(data.max_store_count, 100));
|
||||
this.leftElement[0].scrollTop = 0;
|
||||
Dialog.titleElement.html("你的仓库中有" + this.store_count + "/"
|
||||
+ data.max_store_count + "件物品");
|
||||
this.max_store_count = data.max_store_count;
|
||||
Dialog.icon("lock");
|
||||
this.update_pack();
|
||||
}
|
||||
if (gongji >= 0) {
|
||||
this.gongji = gongji;
|
||||
this.show_footer(gongji);
|
||||
}
|
||||
},
|
||||
show: function (data) {
|
||||
if (!Dialog.isShow || Dialog.curItem != "list")
|
||||
Dialog.show("list");
|
||||
if (this.rightElement) {
|
||||
this.rightElement.show();
|
||||
if (Dialog.pack.objelement) Dialog.pack.objelement.remove();
|
||||
}
|
||||
if (this.isShow) return;
|
||||
if (!this.element) {
|
||||
this.element = $('<div class="dialog-list"><div class="otype-list"><div class="otype-item select" otype="0">道具</div><div class="otype-item" otype="1">秘籍</div><div class="otype-item" otype="2">宝石</div><div class="otype-item" otype="3">资源</div><div class="otype-item" otype="4">装备</div></div><div class="trade-list"></div><div class="obj-list"></div></div >');
|
||||
var children = this.element.children();
|
||||
this.typeElement = $(children[0])
|
||||
this.typeElement.hide();
|
||||
this.leftElement = $(children[1]);
|
||||
this.rightElement = $(children[2]);
|
||||
}
|
||||
this.element.on("click", ".obj-item", Dialog.list.item_click);
|
||||
this.element.on("click", ".otype-item", Dialog.list.otype_click);
|
||||
this.element.appendTo(Dialog.contentElement.empty());
|
||||
this.isShow = true;
|
||||
|
||||
},
|
||||
selected_type: 0,
|
||||
otype_click: function () {
|
||||
let type = $(this).attr('otype');
|
||||
let index = parseInt(type);
|
||||
let store = Dialog.list;
|
||||
if (!store.stores) return;
|
||||
if (index === store.selected_type) return;
|
||||
let type_elems = store.typeElement.children();
|
||||
$(type_elems[store.selected_type]).removeClass('select');
|
||||
store.selected_type = parseInt(type);
|
||||
$(type_elems[index]).addClass('select');
|
||||
SendCommand('store ' + index);
|
||||
},
|
||||
show_footer: function (money) {
|
||||
money = this.money_name ? this.gongji : money;
|
||||
let cmd = this.isstore ? "store" : "sell";
|
||||
if (this.isstore) {
|
||||
var str = this.money_name ? ("你目前有" + money + "<hiy>"
|
||||
+ this.money_name + "</hiy>") : ("你身上有" + Util.moneyToStr(money));
|
||||
Dialog.footerElement.html("<div class='obj-money'>" + str + "<span cmd='" + cmd + " all'>存仓库</span></div>");
|
||||
} else {
|
||||
var str = this.money_name ? ("你目前有" + money + "<hiy>"
|
||||
+ this.money_name + "</hiy>") : ("你身上有" + Util.moneyToStr(money));
|
||||
Dialog.footerElement.html("<div class='obj-money'>" + str + "<span cmd='" + cmd + " all'>清理杂物</span></div>");
|
||||
}
|
||||
}, update_pack: function () {
|
||||
var items = Dialog.pack.items;
|
||||
if (!items) SendCommand("pack");
|
||||
else {
|
||||
this.create_items(items, this.rightElement, 1, Dialog.pack.max_count);
|
||||
this.show_footer(Dialog.pack.money);
|
||||
}
|
||||
|
||||
},
|
||||
create_items: function (items, elem, otype, max_count) {
|
||||
var html = [];
|
||||
//otype 1自己的物品 2,贩卖的物品
|
||||
var list = items;
|
||||
if (otype === 1 || otype === 3) {
|
||||
list = Dialog.pack.sort_items(items);
|
||||
}
|
||||
for (var i = 0; i < max_count; i++) {
|
||||
var item = list[i];
|
||||
// if (otype === 3 && item
|
||||
// && item.otype !== this.selected_type) continue;
|
||||
html.push('<div class="obj-item');
|
||||
if (item) {
|
||||
html.push(item.is_lock ? " lock" : "", ' grade', item.grade);
|
||||
html.push('" obj="');
|
||||
html.push(item.id);
|
||||
html.push('" otype="')
|
||||
html.push(otype);
|
||||
html.push('">');
|
||||
if (otype === 1) {
|
||||
html.push('<span class="grade', item.grade, '">');
|
||||
html.push(item.name);
|
||||
html.push('</span>');
|
||||
} else {
|
||||
html.push(item.name);
|
||||
}
|
||||
html.push("<span class='obj-value'>");
|
||||
if (otype == 2) {
|
||||
html.push("每");
|
||||
html.push(item.unit);
|
||||
html.push(this.money_name ? (item.value + "<hiy>" + this.money_name + "</hiy>")
|
||||
: Util.moneyToStr(item.value));
|
||||
if (item.count == -1) {
|
||||
html.push(":大量现货");
|
||||
} else {
|
||||
html.push(":剩余");
|
||||
html.push(item.count);
|
||||
html.push(item.unit);
|
||||
}
|
||||
|
||||
} else if (otype === 1 && !this.isstore) {
|
||||
if (item.value) {
|
||||
html.push("每");
|
||||
html.push(item.unit);
|
||||
html.push(Util.moneyToStr(item.value));
|
||||
html.push(":");
|
||||
html.push(item.count);
|
||||
html.push(item.unit);
|
||||
} else {
|
||||
html.push("不可出售");
|
||||
}
|
||||
|
||||
} else if (item.count > 1) {
|
||||
html.push(item.count);
|
||||
html.push(item.unit);
|
||||
}
|
||||
html.push('</span>');
|
||||
} else {
|
||||
html.push('">');
|
||||
}
|
||||
|
||||
html.push('</div>');
|
||||
}
|
||||
elem.html(html.join(""));
|
||||
|
||||
}
|
||||
, item_click: function () {
|
||||
var elem = $(this);
|
||||
var obj = elem.attr("obj");
|
||||
var otype = elem.attr("otype");
|
||||
var item = Dialog.list.find_item(otype, obj);
|
||||
if (!item) return;
|
||||
var html = ["<div class='item-commands'>"];
|
||||
if (Dialog.list.isstore) {
|
||||
if (otype == 3) {
|
||||
html.push('<span cmd="checkobj ' + obj + ' from ' + "store" + '">查看</span>');
|
||||
html.push('<span cmd="_confirm qu ' + obj + '">取出</span>');
|
||||
} else if (otype == 1) {
|
||||
html.push('<span cmd="checkobj ' + obj + ' from item">查看</span>');
|
||||
html.push('<span cmd="_confirm store ' + item.count + ' ' + obj + '">存到仓库</span>');
|
||||
}
|
||||
} else {
|
||||
if (otype == 2) {
|
||||
html.push('<span cmd="checkobj ' + obj + ' from ' + Dialog.list.seller + '">查看</span>');
|
||||
if (item.count)
|
||||
html.push('<span cmd="_confirm buy ' + item.count + ' ' + obj + ' from ' + Dialog.list.seller + '">购买</span>');
|
||||
} else if (otype == 1) {
|
||||
|
||||
html.push('<span cmd="checkobj ' + obj + ' from item">查看</span>');
|
||||
html.push('<span cmd="_confirm sell ' + item.count + ' ' + obj + ' to ' + Dialog.list.seller + '">卖掉</span>');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
html.push("</div>");
|
||||
Dialog.list.element.find(".item-commands").remove();
|
||||
|
||||
elem = $(html.join("")).insertAfter(elem);
|
||||
Util.checkScroll(elem);
|
||||
}
|
||||
};
|
||||
35
src/dialog/map.js
Normal file
35
src/dialog/map.js
Normal file
@@ -0,0 +1,35 @@
|
||||
|
||||
import MAP from '../map.js';
|
||||
|
||||
export default {
|
||||
onData: function (data) {
|
||||
Dialog.title(data.title || "地图");
|
||||
},
|
||||
init: function () {
|
||||
|
||||
},
|
||||
show: function () {
|
||||
Dialog.init();
|
||||
var rm = MAP.Room.name;
|
||||
var index = rm.indexOf('-');
|
||||
if (index > -1) {
|
||||
rm = rm.substr(0, index);
|
||||
}
|
||||
Dialog.title(rm);
|
||||
Dialog.footer("");
|
||||
this.element = $(".map");
|
||||
Dialog.contentElement.append(this.element);
|
||||
Dialog.icon("map-marker");
|
||||
Dialog.iconElement.attr("class", "dialog-icon glyphicon glyphicon-map-marker");
|
||||
|
||||
},
|
||||
hide: function () {
|
||||
this.element.remove();
|
||||
if ($(".map-panel").children().length == 0)
|
||||
this.element.appendTo(".map-panel");
|
||||
|
||||
},
|
||||
close: function () {
|
||||
this.hide();
|
||||
}
|
||||
};
|
||||
156
src/dialog/master.js
Normal file
156
src/dialog/master.js
Normal file
@@ -0,0 +1,156 @@
|
||||
|
||||
import Util from '../utils/util.js';
|
||||
import SCRIPT from '../script.js';
|
||||
|
||||
export default {
|
||||
isShow: false,
|
||||
init: function () {
|
||||
Dialog.skills.init();
|
||||
this.createSkillItems = Dialog.skills.createSkillItems;
|
||||
this.createSkillItem = Dialog.skills.createSkillItem;
|
||||
this.updateSkill = Dialog.skills.updateSkill;
|
||||
this.updateSkillItem = Dialog.skills.updateSkillItem;
|
||||
this.showdesc = Dialog.skills.showdesc;
|
||||
this.isEnable = Dialog.skills.isEnable;
|
||||
this.close = Dialog.skills.close;
|
||||
},
|
||||
hide: function () {
|
||||
if (this.skill_element) {
|
||||
this.skill_element.remove();
|
||||
this.skill_element = null;
|
||||
this.element.removeClass("hide-item");
|
||||
Dialog.footer("");
|
||||
return false;
|
||||
}
|
||||
this.isShow = false;
|
||||
},
|
||||
|
||||
onData: function (data) {
|
||||
if (data.desc) {
|
||||
return this.showdesc(data);
|
||||
}
|
||||
if (data.id) {
|
||||
//更新技能状态
|
||||
return this.updateSkill(data);
|
||||
}
|
||||
if (data.books) {
|
||||
return this.showBooks();
|
||||
}
|
||||
if (data.remove && data.from === this.master) {
|
||||
this.items.Remove(this.skills[data.remove]);
|
||||
var skill = this.skills[data.remove];
|
||||
for (var i = 0; i < this.items.length; i++) {
|
||||
if (this.items[i].enable_skill == data.remove) {
|
||||
this.items[i].enable_skill = null;
|
||||
}
|
||||
}
|
||||
delete this.skills[data.remove];
|
||||
return this.createSkillItems(this.items);
|
||||
}
|
||||
if (!data.master && !data.follower) return;
|
||||
Dialog.show("master");
|
||||
this.master = data.master || data.follower;
|
||||
this.is_follower = !!data.follower;
|
||||
var skills = {};
|
||||
for (var i = 0; i < data.items.length; i++) {
|
||||
var item = data.items[i];
|
||||
skills[item.id] = item;
|
||||
}
|
||||
this.skills = skills;
|
||||
this.items = data.items;
|
||||
Dialog.title(data.title);
|
||||
Dialog.icon("book");
|
||||
this.createSkillItems(data.items, skills);
|
||||
if (data.limit) {
|
||||
if (this.is_follower) {
|
||||
let str = ['<div class="footer-item select" for="0">', '技能</div>'];
|
||||
str.push('<div class="footer-item" for="1">书架</div>');
|
||||
str.push("<span class='obj-money'>", data.target, "目前的技能上限为<HIC>", data.limit, "</HIC>级</span>");
|
||||
Dialog.footer(str.join(""));
|
||||
}
|
||||
else
|
||||
Dialog.footer("<span class='obj-money'>你目前的技能上限为<HIC>" + data.limit + "</HIC>级</span>");
|
||||
}
|
||||
},
|
||||
create_footer: function () {
|
||||
|
||||
},
|
||||
selectedItem: 0,
|
||||
footerChanged: function (index) {
|
||||
index = parseInt(index);
|
||||
if (index === this.selectedItem) return;
|
||||
this.selectedItem = index;
|
||||
if (index === 0) {
|
||||
this.element.removeClass("dialog-books");
|
||||
this.createSkillItems(this.items, this.skills);
|
||||
} else {
|
||||
if (!Dialog.skills.books) SendCommand('sbook');
|
||||
else this.showBooks();
|
||||
return this.element.addClass("dialog-books");
|
||||
}
|
||||
}, showBooks: function () {
|
||||
if (!this.isShow || !this.is_follower) return;
|
||||
var html = [];
|
||||
var books = Dialog.skills.sort_items(Dialog.skills.books);
|
||||
for (let item of books) {
|
||||
html.push('<div class="book-item ');
|
||||
html.push('grade', item.grade, '" >');
|
||||
html.push('<div class="book-name">', item.name, '</div>');
|
||||
html.push('<div class="book-action border-right" cmd="sbook ', item.id, '">查看</div>');
|
||||
html.push('<div class="book-action" cmd="dc ',
|
||||
Dialog.master.master, ' study ', item.id, '">学习</div>');
|
||||
html.push('</div>');
|
||||
}
|
||||
this.element.html(html.join(""));
|
||||
},
|
||||
show: function () {
|
||||
if (this.isShow) return;
|
||||
if (!this.element) {
|
||||
this.element = $('<div class="dialog-skills"></div >');
|
||||
}
|
||||
this.element.on("click", ".skill-item", this.item_click);
|
||||
this.element.appendTo(Dialog.contentElement);
|
||||
this.element.removeClass("hide-item");
|
||||
this.isShow = true;
|
||||
}, item_click: function () {
|
||||
var elem = $(this);
|
||||
var item = Dialog.master.skills[elem.attr("skid")];
|
||||
if (!item) return;
|
||||
var html = ["<div class='item-commands'>"];
|
||||
html.push('<span cmd="checkskill ' + item.id + ' ' + Dialog.master.master + '">查看详细</span>');
|
||||
html.push('<span cmd="xue ' + elem.attr("skid") + ' from ' + Dialog.master.master + '">学习</span>');
|
||||
|
||||
item.master = 1;
|
||||
if (Dialog.master.is_follower) {
|
||||
var bf = 'dc ' + Dialog.master.master;
|
||||
html.push('<span cmd="_confirm ' + bf + ' fangqi ' + elem.attr("skid") + '">遗忘</span>');
|
||||
html.push('<span cmd="' + bf + ' lianxi ' + elem.attr("skid") + '">练习</span>');
|
||||
if (item.can_enables) {
|
||||
for (var i = 0; i < item.can_enables.length; i++) {
|
||||
var baseSkill = Dialog.master.skills[item.can_enables[i]];
|
||||
if (!baseSkill) continue;
|
||||
if (baseSkill.enable_skill != item.id)
|
||||
html.push('<span cmd="' + bf + ' enable ' + baseSkill.id + ' ' + item.id + '">装备' + baseSkill.name + '</span>');
|
||||
else {
|
||||
html.push('<span cmd="' + bf + ' enable ' + baseSkill.id + ' none">取消装备' + baseSkill.name + '</span>');
|
||||
}
|
||||
}
|
||||
}
|
||||
if (item.enable_skill) {
|
||||
var sp_skill = Dialog.master.skills[item.enable_skill];
|
||||
if (sp_skill) html.push('<span cmd="' + bf + ' enable ' + item.id + ' none">取消装备' + sp_skill.name + '</span>');
|
||||
else item.enable_skill = null;
|
||||
}
|
||||
item.master = 0;
|
||||
}
|
||||
SCRIPT.LAST_OBJ = item;
|
||||
let commands = Dialog.extend.query('mskill', item);
|
||||
for (let item of commands) {
|
||||
html.push('<span cmd="', item.cmd, '">', item.name, '</span>');
|
||||
}
|
||||
html.push("</div>");
|
||||
Dialog.master.element.find(".item-commands").remove();
|
||||
$(html.join("")).insertAfter(elem);
|
||||
Util.checkScroll(elem);
|
||||
}
|
||||
}
|
||||
456
src/dialog/message.js
Normal file
456
src/dialog/message.js
Normal file
@@ -0,0 +1,456 @@
|
||||
|
||||
|
||||
import { showFlag } from '../game/tool.js';
|
||||
export default {
|
||||
init: function () {
|
||||
|
||||
Dialog.injectStyle(message_css);
|
||||
},
|
||||
close: function () {
|
||||
|
||||
this.element.remove();
|
||||
this.isShow = false;
|
||||
}, hide: function () {
|
||||
if (this.detailID) {
|
||||
this.hide_detail();
|
||||
return false;
|
||||
}
|
||||
}, hide_detail: function () {
|
||||
this.element.removeClass("detail");
|
||||
this.detailID = null;
|
||||
Dialog.footerElement.find('.item-commands').empty();
|
||||
},
|
||||
selected_item: 0,
|
||||
messages: [],
|
||||
isLoad: false,
|
||||
unRead: 0,
|
||||
onData: function (data) {
|
||||
if (data.receive) return this.updateMessageState(data.receive, data.index);
|
||||
if (data.items) {
|
||||
return this.createMessageDetail(data.id, data.items);
|
||||
}
|
||||
if (data.clear) return this.clear_message(data.clear);
|
||||
|
||||
if (data.unRead != undefined) {
|
||||
this.unRead = data.unRead;
|
||||
}
|
||||
if (data.messages) {
|
||||
for (var i = 0; i < data.messages.length; i++) {
|
||||
this.addMessage(data.messages[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (data.message) {
|
||||
if (!this.isShow) this.unRead++;
|
||||
if (this.messages)
|
||||
this.addMessage(data.message);
|
||||
if (data.message.id == "notice") {
|
||||
this.showNotice(data.message);
|
||||
}
|
||||
}
|
||||
if (this.element)
|
||||
this.showMessages();
|
||||
if (this.isShow) {
|
||||
if (data.message && this.element.is(".detail")
|
||||
& this.detailID == data.message.id) {
|
||||
this.detailElement.prepend($(this.createMessageDetailItem(data.message.id,
|
||||
data.message.name, data.message)));
|
||||
}
|
||||
} else
|
||||
this.showUnread();
|
||||
|
||||
}, showUnread: function () {
|
||||
if (this.unRead) showFlag("message", this.unRead);
|
||||
else showFlag("message", 0);
|
||||
},
|
||||
addMessage: function (msg) {
|
||||
for (let i = 0; i < this.messages.length; i++) {
|
||||
if (this.messages[i].id == msg.id) {
|
||||
this.messages[i] = msg;
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.messages.push(msg);
|
||||
}, clear_message: function (type) {
|
||||
for (let i = 0; i < this.messages.length; i++) {
|
||||
let from = this.messages[i].id;
|
||||
if ((type === true && from !== 'notice') || from == type) {
|
||||
this.messages.splice(i, 1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
this.showMessages();
|
||||
if (!this.isShow) return;
|
||||
if (this.element.is(".detail")
|
||||
& (type === true || this.detailID == type)) {
|
||||
this.hide_detail();
|
||||
}
|
||||
},
|
||||
show: function (data) {
|
||||
this.unRead = 0;
|
||||
this.showUnread();
|
||||
if (this.isShow) return;
|
||||
this.isShow = true;
|
||||
Dialog.title("消息");
|
||||
Dialog.icon("envelope");
|
||||
this.create_footer();
|
||||
this.footerChanged(this.selected_item);
|
||||
if (this.isLoad) return;
|
||||
SendCommand("message");
|
||||
this.isLoad = true;
|
||||
|
||||
// this.element.on("click", ".detail-item", this.showDetailCommand);
|
||||
},
|
||||
inner_show: function () {
|
||||
|
||||
Dialog.title("消息");
|
||||
Dialog.icon("envelope");
|
||||
this.element.on("click",
|
||||
".message-item", this.showMessageDetail);
|
||||
},
|
||||
inner_close: function () {
|
||||
this.element.remove();
|
||||
this.isShow = false;
|
||||
},
|
||||
footers: ["消息", "队伍", "关系", "帮派"],
|
||||
footerElements: ["message", "team", "relation", "party"],
|
||||
create_footer: function () {
|
||||
var html = [];
|
||||
for (var i = 0; i < this.footers.length; i++) {
|
||||
html.push("<span class='footer-item" + (i == this.selected_item ? " select" : "") + "' for='" + i + "''>"
|
||||
+ this.footers[i] + "</span>");
|
||||
}
|
||||
html.push('<dic class="item-commands"></div>');
|
||||
Dialog.footer(html.join(""));
|
||||
|
||||
|
||||
}, footerChanged: function (index) {
|
||||
//if (index == this.selected_item) return;
|
||||
this.selected_item = index;
|
||||
Dialog.footerElement.find('.item-commands').empty();
|
||||
this.showChild();
|
||||
}, showChild: function () {
|
||||
var child = Dialog[this.footerElements[this.selected_item]];
|
||||
//if (this.selectedChild == child) return;
|
||||
if (this.selectedChild) this.selectedChild.inner_close();
|
||||
if (!child.element) child.element = child.createElement();
|
||||
Dialog.contentElement.html(child.element);
|
||||
child.inner_show();
|
||||
|
||||
this.selectedChild = child;
|
||||
}, showNotice: function (nt) {
|
||||
var str = ["\n<hiy>系统公告</hiy>\n"];
|
||||
var dt = new Date(nt.time);
|
||||
str.push(dt.getFullYear());
|
||||
str.push("年");
|
||||
str.push(dt.getMonth() + 1);
|
||||
str.push("月");
|
||||
str.push(dt.getDate());
|
||||
str.push("日 ");
|
||||
str.push(dt.getHours());
|
||||
str.push("时");
|
||||
str.push(dt.getMinutes());
|
||||
str.push("分\n<hic>");
|
||||
str.push(nt.content);
|
||||
str.push("\n</hic>");
|
||||
ReceiveMessage(str.join(""));
|
||||
}, showMessages: function (newmsg) {
|
||||
var str = [];
|
||||
for (var i = 0; i < this.messages.length; i++) {
|
||||
var msg = this.messages[i];
|
||||
str.push("<div class='message-item' fromid=\"");
|
||||
str.push(msg.id);
|
||||
str.push("\"><div class='message-title'>");
|
||||
str.push(msg.name);
|
||||
|
||||
str.push("<span class='message-time'>");
|
||||
str.push(this.getTimedesc(msg.time));
|
||||
str.push("</span>");
|
||||
str.push("</div>");
|
||||
str.push("<div class='message-content'>");
|
||||
str.push(msg.content);
|
||||
str.push("</div>");
|
||||
str.push("</div>");
|
||||
}
|
||||
if (!str.length) str.push('<div class="empty">暂无新消息</div>');
|
||||
if (!this.listElement) this.listElement = this.element.find(".message-list");
|
||||
this.listElement.html(str.join(""));
|
||||
|
||||
}, getTimedesc: function (long) {
|
||||
var now = new Date();
|
||||
var time = new Date(long);
|
||||
var dt = (now - time) / 1000;
|
||||
if (dt < 60) return "刚刚";
|
||||
else if (dt < 3600) return parseInt(dt / 60) + "分钟前";
|
||||
else if (time.getFullYear() == now.getFullYear() && time.getMonth() == now.getMonth()) {
|
||||
var diff_day = time.getDate() - now.getDate();
|
||||
var msg = "今天 " + this.add_zero(time.getHours()) + ":" + this.add_zero(time.getMinutes());
|
||||
if (diff_day == 0) return msg;
|
||||
else if (diff_day == 1) return "昨天 " + msg;
|
||||
else if (diff_day == 2) return "前天 " + msg;
|
||||
|
||||
}
|
||||
var str = (time.getMonth() + 1) + "月" + time.getDate() + "日 " + this.add_zero(time.getHours()) + ":" + this.add_zero(time.getMinutes());
|
||||
if (now - time > 2332800000) {
|
||||
str += "<mem>即将过期</mem>";
|
||||
}
|
||||
return str;
|
||||
|
||||
}, add_zero: function (num) {
|
||||
if (num < 10) return "0" + num;
|
||||
return num;
|
||||
}, showMessageDetail: function () {
|
||||
var id = $(this).attr("fromid");
|
||||
if (!id) return;
|
||||
SendCommand("message " + id);
|
||||
Dialog.message.element.addClass("detail");
|
||||
|
||||
}, getMessageitem: function (id) {
|
||||
for (var i = 0; i < this.messages.length; i++) {
|
||||
if (this.messages[i].id == id) return this.messages[i];
|
||||
}
|
||||
}, createMessageDetail: function (id, items) {
|
||||
if (!this.detailElement) {
|
||||
this.detailElement = this.element.find(".detail-list");
|
||||
}
|
||||
var msg = this.getMessageitem(id);
|
||||
if (!msg) return;
|
||||
var str = [];
|
||||
this.detailID = id;
|
||||
let has_rec = false;
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
var item = items[i];
|
||||
str.push(this.createMessageDetailItem(id, msg.name, item));
|
||||
if (item.attach && !item.rec) {
|
||||
has_rec = true;
|
||||
}
|
||||
}
|
||||
this.detailElement.html(str.join(""));
|
||||
let cmds = "";
|
||||
if (id !== 'notice') {
|
||||
cmds = `<span cmd="message delete ${id}">删除</span><span cmd="receive ${id}">领取全部</span>`;
|
||||
}
|
||||
Dialog.footerElement.find('.item-commands').html(cmds);
|
||||
|
||||
}, createMessageDetailItem: function (id, name, item) {
|
||||
var str = [];
|
||||
str.push("<div class='detail-item' rec='",
|
||||
item.attach && !item.rec ? 1 : 0,
|
||||
"' fid='", id, "' index='" + item.index + "'>");
|
||||
str.push("<span class='detail-name'>");
|
||||
str.push(name);
|
||||
str.push("</span>");
|
||||
str.push("<span class='detail-time'>");
|
||||
str.push(this.getTimedesc(item.time));
|
||||
str.push("</span>");
|
||||
str.push("<pre class='detail-content'>");
|
||||
str.push(item.content);
|
||||
str.push("</pre>");
|
||||
if (item.attach) {
|
||||
for (var j = 0; j < item.attach.length; j++) {
|
||||
str.push("<div class='detail-attach'>");
|
||||
str.push(item.attach[j].name);
|
||||
str.push("</div>");
|
||||
}
|
||||
if (item.rec) {
|
||||
str.push("<div class='detail-rec'>已领取</div>");
|
||||
} else {
|
||||
str.push("<div class='detail-rec' cmd='receive " + id
|
||||
+ " " + item.index + "'><hig>领取</hig></div>");
|
||||
}
|
||||
}
|
||||
str.push("</div>");
|
||||
return str.join("");
|
||||
},
|
||||
createElement: function () {
|
||||
return $('<div class="dialog-message"><div class="message-list"></div><div class="detail-list"></div></div>');
|
||||
}, updateMessageState: function (rec, index) {
|
||||
if (this.detailID != rec) return;
|
||||
const elem = this.detailElement.find(".detail-item[index='" + index + "']>.detail-rec");
|
||||
elem.html("已领取").removeAttr('cmd');
|
||||
}
|
||||
};
|
||||
const message_css = `
|
||||
|
||||
.dialog-message{
|
||||
height: 25em;
|
||||
max-height: 30em;
|
||||
}
|
||||
|
||||
.dialog-message>.message-list>.empty{
|
||||
color: #505050;
|
||||
padding-top: 1em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.dialog-message>.message-list>.message-item {
|
||||
|
||||
padding-left: 1em;
|
||||
border-radius: 4px;
|
||||
border-left-width: 2px;
|
||||
border-left-style: solid;
|
||||
border-left-color: gray;
|
||||
white-space: nowrap;
|
||||
overflow-x: auto;
|
||||
margin-top: 0.5em;
|
||||
margin-bottom: 0.5em;
|
||||
background-color: #111;
|
||||
cursor: pointer;
|
||||
|
||||
}
|
||||
|
||||
.dialog-message>.message-list>.message-item>.message-title {
|
||||
color: #FFFF00;
|
||||
line-height: 2em;
|
||||
}
|
||||
|
||||
.dialog-message>.message-list>.message-item>.message-content {
|
||||
white-space: break-spaces;
|
||||
word-wrap: break-word;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
.dialog-message>.message-list>.message-item>.message-title>.message-time {
|
||||
float: right;
|
||||
margin-right: 0.5em;
|
||||
|
||||
}
|
||||
|
||||
.detail {
|
||||
min-height: 25em;
|
||||
max-height: 25em;
|
||||
}
|
||||
|
||||
.detail>.message-list {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.dialog-message>.detail-list {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.detail>.detail-list {
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
||||
.dialog-team,
|
||||
.dialog-party,
|
||||
.dialog-relation {
|
||||
height: 25em;
|
||||
max-height: 30em;
|
||||
}
|
||||
|
||||
.dialog-team>.empty {
|
||||
color: #505050;
|
||||
padding-top: 1em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.dialog-team>.team-item {
|
||||
padding-left: 0.5em;
|
||||
border-radius: 4px;
|
||||
border-left-width: 2px;
|
||||
border-left-style: solid;
|
||||
border-left-color: gray;
|
||||
white-space: nowrap;
|
||||
overflow-x: auto;
|
||||
margin-top: 0.5em;
|
||||
margin-bottom: 0.5em;
|
||||
background-color: #111;
|
||||
line-height: 2em;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.dialog-team>.team-item>.item-commands {
|
||||
padding-left: 2em;
|
||||
}
|
||||
|
||||
.dialog-team>.team-item>.team-flag {
|
||||
width: 2em;
|
||||
display: inline-block;
|
||||
text-align: center;
|
||||
color: #FFFF00
|
||||
}
|
||||
|
||||
.dialog-team>.team-item>.team-name {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.dialog-relation>.relation-item {
|
||||
padding-left: 0.5em;
|
||||
border-radius: 4px;
|
||||
border-left-width: 2px;
|
||||
border-left-style: solid;
|
||||
border-left-color: gray;
|
||||
white-space: nowrap;
|
||||
overflow-x: auto;
|
||||
margin-top: 0.5em;
|
||||
margin-bottom: 0.5em;
|
||||
background-color: #111;
|
||||
line-height: 2em;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.dialog-relation>.relation-item>.relation-desc {
|
||||
flex: 1;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.dialog-relation>.relation-item>.relation-cmd {
|
||||
flex: 0;
|
||||
background-color: #222;
|
||||
padding-left: 1em;
|
||||
padding-right: 1em;
|
||||
cursor: pointer;
|
||||
border-left: 2px solid #111;
|
||||
}
|
||||
|
||||
.detail-item {
|
||||
margin-bottom: 0.5em;
|
||||
margin-top: 0.5em;
|
||||
padding: 0.5em;
|
||||
background-color: #111;
|
||||
padding-left: 1em;
|
||||
border-radius: 4px;
|
||||
border-top-width: 2px;
|
||||
border-top-style: solid;
|
||||
border-top-color: gray;
|
||||
white-space: nowrap;
|
||||
overflow-x: auto;
|
||||
margin-top: 0.5em;
|
||||
margin-bottom: 0.5em;
|
||||
background-color: #111;
|
||||
}
|
||||
|
||||
.detail-item>.detail-name {
|
||||
color: #FFFF00;
|
||||
}
|
||||
|
||||
.detail-item>.detail-time {
|
||||
margin-left: 1em;
|
||||
color: gray;
|
||||
}
|
||||
|
||||
.detail-item>.detail-content {
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.detail-item>.detail-rec {
|
||||
margin-top: 1em;
|
||||
background-color: #222;
|
||||
color: gray;
|
||||
display: inline-block;
|
||||
font-size: 0.8em;
|
||||
padding-left: 1em;
|
||||
padding-right: 1em;
|
||||
border-radius: 1em;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
`;
|
||||
701
src/dialog/packet.js
Normal file
701
src/dialog/packet.js
Normal file
@@ -0,0 +1,701 @@
|
||||
import Setting from '../setting.js';
|
||||
import Util from '../utils/util.js';
|
||||
import SCRIPT from '../script.js';
|
||||
import Combat from '../combat.js';
|
||||
|
||||
|
||||
export default {
|
||||
close: function () {
|
||||
this.hide();
|
||||
this.element.remove();
|
||||
//Dialog.footerElement.addClass("hide");
|
||||
this.isShow = false;
|
||||
this.skill_element_id = null;
|
||||
this.element.removeClass("hide-item");
|
||||
},
|
||||
hide: function () { },
|
||||
init: function () {
|
||||
if (!this.created) {
|
||||
Dialog.injectStyle(packet_css);
|
||||
Dialog.injectStyle(list_css);
|
||||
}
|
||||
this.created = true;
|
||||
},
|
||||
command_before: '',
|
||||
updateitem: function (data) {
|
||||
if (data.money != undefined) {
|
||||
this.money = data.money;
|
||||
this.show_moeny();
|
||||
}
|
||||
if (data.eq_group !== undefined) {
|
||||
this.eq_group = data.eq_group;
|
||||
this.show_moeny();
|
||||
}
|
||||
else if (data.eq != undefined && this.items) {
|
||||
for (var i = 0; i < this.items.length; i++) {
|
||||
if (this.items[i].id == data.id) {
|
||||
this.eqs[data.eq] = this.items[i];
|
||||
this.items.splice(i, 1);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.show_items();
|
||||
} else if (data.uneq != undefined && this.items) {
|
||||
var item = this.eqs[data.uneq];
|
||||
item.can_eq = 1;
|
||||
item.count = 1;
|
||||
this.items.push(item);
|
||||
this.eqs[data.uneq] = null;
|
||||
|
||||
this.show_items();
|
||||
|
||||
}
|
||||
else if (data.locked >= 0) {
|
||||
let item = this.get_item(data.id);
|
||||
if (item) {
|
||||
item.is_lock = data.locked;
|
||||
let elem = this.packElement.find('[oindex="' + data.id + '"]');
|
||||
item.is_lock ? elem.addClass('lock') : elem.removeClass('lock');
|
||||
}
|
||||
} else if (data.jldesc) {
|
||||
var str = [];
|
||||
str.push(data.jldesc);
|
||||
str.push("<span class='item-commands'>");
|
||||
str.push('<span cmd="' + this.command_before + 'jinglian ' + data.id + ' ok">精炼</span>');
|
||||
str.push('<span cmd="' + this.command_before + 'jinglian ' + data.id + ' full">精炼到满级</span>');
|
||||
str.push("</span>");
|
||||
this.show_sub(str.join(""));
|
||||
} else if (data.xqdesc) {
|
||||
var str = [];
|
||||
str.push(data.xqdesc);
|
||||
str.push("<span class='item-commands'>");
|
||||
for (var i = 0; i < data.stones.length; i++) {
|
||||
var st = data.stones[i];
|
||||
str.push('<span cmd="' + this.command_before + 'xiangqian ' + data.id + ' '
|
||||
+ st.id + '">镶嵌' + st.name + '</span><br/>');
|
||||
}
|
||||
str.push("</span>");
|
||||
this.show_sub(str.join(""));
|
||||
}
|
||||
else if (data.desc) {
|
||||
var str = [];
|
||||
str.push(data.desc);
|
||||
str.push("<span class='item-commands'>");
|
||||
var from = data.from;
|
||||
if (from == "eq") {
|
||||
str.push('<span cmd="' + this.command_before + 'uneq ' + data.id + '">取消装备</span>');
|
||||
} else if (from == "item") {
|
||||
var obj = this.get_item(data.id);
|
||||
SCRIPT.LAST_OBJ = obj;
|
||||
if (obj) {
|
||||
this.create_item_command(obj, str, data.commands);
|
||||
}
|
||||
} else if (from == "store") {
|
||||
str.push('<span cmd="_confirm qu ' + data.id + '">取出</span>');
|
||||
} else if (from == "sj") {
|
||||
str.push('<span cmd="_confirm qu ' + data.id + '">取出</span>');
|
||||
}
|
||||
else {
|
||||
str.push('<span cmd="_confirm buy 1 ' + data.id + ' from ' + Dialog.list.seller + '">购买</span>');
|
||||
}
|
||||
str.push("</span>");
|
||||
this.show_sub(str.join(""));
|
||||
} else if (data.remove && this.items) {//丢掉的
|
||||
var items = this.items;
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
if (items[i].id == data.id) {
|
||||
if (data.remove >= items[i].count) {
|
||||
items.splice(i, 1);
|
||||
Combat.DisObj(data);
|
||||
} else {
|
||||
items[i].count -= data.remove;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (this.isShow)
|
||||
this.show_items();
|
||||
else return false;
|
||||
|
||||
} else if (data.name && this.items) {//更新的
|
||||
var item = this.get_item(data.id);
|
||||
if (item) {
|
||||
item.count = data.count;
|
||||
item.name = data.name;
|
||||
} else {
|
||||
this.items.push(data);
|
||||
}
|
||||
if (this.isShow)
|
||||
this.show_items();
|
||||
else return false;
|
||||
} else if (data.max_item_count) {
|
||||
this.max_count = data.max_item_count;
|
||||
ReceiveMessage((Dialog.pack2.isShow ? Dialog.pack2.target_name : "你") + "的背包容量扩充为" + this.max_count + "。");
|
||||
this.show_items();
|
||||
} else return false;
|
||||
return true;
|
||||
},
|
||||
get_item: function (id, items) {
|
||||
items = items || this.items;
|
||||
if (!items) return;
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
if (items[i] && items[i].id == id) return items[i];
|
||||
}
|
||||
}, show_sub: function (str) {
|
||||
if (this.objelement) this.objelement.remove();
|
||||
var parent = this.packElement;
|
||||
|
||||
if (Dialog.list.isShow) {
|
||||
parent = Dialog.list.rightElement;
|
||||
}
|
||||
this.objelement = $("<pre class='obj-desc'>" + str + "</pre>").appendTo(
|
||||
parent.parent()).on("click", function () {
|
||||
this.objelement.remove();
|
||||
this.objelement = null;
|
||||
parent.show();
|
||||
}.bind(this));
|
||||
parent.hide();
|
||||
}, onData: function (data) {
|
||||
if (data.items) {
|
||||
this.eqs = this.formatEqs(data.eqs || []);
|
||||
this.money = data.money;
|
||||
this.eq_group = data.eq_group;
|
||||
this.items = this.formatItems(data.items);
|
||||
this.max_count = data.max_item_count;
|
||||
if (this.isShow) {
|
||||
this.show_items();
|
||||
this.show_moeny();
|
||||
}
|
||||
} else {
|
||||
if (Dialog.pack2.isShow && !data.name) return Dialog.pack2.onData(data);
|
||||
if (this.updateitem(data)) return;
|
||||
}
|
||||
if (!this.isShow) {
|
||||
if (Dialog.list.isShow) {
|
||||
return Dialog.list.update_pack(data);
|
||||
}
|
||||
if (Dialog.trade.isShow) {
|
||||
return Dialog.trade.update_pack(data);
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
formatPackItem: function (item) {
|
||||
return {
|
||||
name: item[0], id: item[1],
|
||||
count: item[2], grade: item[3],
|
||||
unit: item[4], value: item[5],
|
||||
can_eq: item[6], can_use: item[7],
|
||||
can_study: item[8], can_open: item[9],
|
||||
can_combine: item[10], is_lock: item[11],
|
||||
otype: item[12]
|
||||
};
|
||||
}
|
||||
, formatItems: function (data) {
|
||||
let items = [];
|
||||
for (let item of data) {
|
||||
items.push(this.formatPackItem(item));
|
||||
}
|
||||
return items;
|
||||
}, formatEqs: function (data) {
|
||||
let items = [];
|
||||
for (let item of data) {
|
||||
if (!item) items.push(item);
|
||||
else items.push({
|
||||
name: item[0], id: item[1],
|
||||
grade: item[2], can_use: item[3], is_lock: item[4]
|
||||
});
|
||||
}
|
||||
return items;
|
||||
},
|
||||
|
||||
|
||||
show_moeny: function () {
|
||||
if (!this.isShow) return;//+ "<span cmd='sell all'>清理包裹</span></div>"
|
||||
let mstr = Util.moneyToStr(this.money);
|
||||
let str = [];
|
||||
for (let i = 0; i < 3; i++) {
|
||||
str.push('<span class="footer-item eq-group',
|
||||
i === this.eq_group ? " select" : "", '" for="', i + 1, '">', i + 1, '</span>');
|
||||
}
|
||||
str.push("<div class='obj-money'>");
|
||||
if (this.packElement.is('.cleanup')) {
|
||||
|
||||
str.push("<span for='cancle' class='footer-item'>取消</span>");
|
||||
str.push("<span for='store' class='footer-item'>自动存仓</span>");
|
||||
str.push("<span for='sell' class='footer-item'>清理杂物</span>");
|
||||
str.push("<span for='cleanup' class='footer-item'>确定</span></div>");
|
||||
} else {
|
||||
str.push("你", (mstr ? "身上有"
|
||||
+ mstr : "身上没有任何银两"));
|
||||
str.push("<span for='cleanup' class='footer-item'>整理包裹</span></div>");
|
||||
}
|
||||
|
||||
Dialog.footer(str.join(""));
|
||||
|
||||
}, cleanup_cmds: { cleanup: true, cancle: true, store: true, sell: true },
|
||||
footerChanged: function (cmd, elem) {
|
||||
if (this.cleanup_cmds[cmd])
|
||||
return this.cleanup(cmd, elem);
|
||||
let index = parseInt(cmd) - 1;
|
||||
if (!(index >= 0 && index < 3)) return;
|
||||
SendCommand('eqgroup ' + index);
|
||||
},
|
||||
cleanup: function (cmd, elem) {
|
||||
let pack = this;
|
||||
elem.removeClass('select');
|
||||
if (pack.packElement.is('.cleanup')) {
|
||||
if (cmd == 'cleanup') {
|
||||
pack.packElement.find('.obj-item>.selected').
|
||||
each(this.cleanup_item);
|
||||
} else if (cmd == 'store') {
|
||||
SendCommand((this.command_before ?? "") + 'store all');
|
||||
} else if (cmd == 'sell') {
|
||||
SendCommand((this.command_before ?? "") + 'sell all');
|
||||
}
|
||||
pack.packElement.removeClass("cleanup");
|
||||
this.show_moeny();
|
||||
}
|
||||
else {
|
||||
pack.packElement.find(".item-commands").remove();
|
||||
pack.packElement.addClass("cleanup");
|
||||
pack.show_items();
|
||||
this.show_moeny();
|
||||
}
|
||||
},
|
||||
cleanup_item: function (x, y) {
|
||||
let elem = $(y);
|
||||
let item = elem.parent().attr('oindex');
|
||||
let cmd = elem.attr('cmd');
|
||||
SendCommand(cmd + " " + item);
|
||||
},
|
||||
show_items: function () {
|
||||
if (!this.packElement) return;
|
||||
this.createItems();
|
||||
this.create_eqs();
|
||||
Dialog.icon("briefcase");
|
||||
var name = this.target_name || "你";
|
||||
Dialog.title((this.items && this.items.length) ? (name + "身上共有" + this.items.length + "/" + this.max_count + "件物品") : (name + "身上没有任何东西"));
|
||||
|
||||
},
|
||||
init_element: function () {
|
||||
if (!this.element) {
|
||||
this.element = $('<div class="dialog-pack"><div class="eq-list"><div class="eq-item"><span class="eq-type">武器</span><span class="eq-name"></span></div><div class="eq-item"><span class="eq-type">衣服</span><span class="eq-name"></span>' +
|
||||
'</div > <div class="eq-item"><span class="eq-type">鞋</span><span class="eq-name"></span></div> <div class="eq-item"><span class="eq-type">头部</span><span class="eq-name"></span></div> <div class="eq-item">' +
|
||||
'<span class="eq-type">披风</span><span class="eq-name"></span></div> <div class="eq-item"><span class="eq-type">戒指</span><span class="eq-name"></span></div> <div class="eq-item"><span class="eq-type">项链</span><span class="eq-name"></span>' +
|
||||
'</div> <div class="eq-item"><span class="eq-type">饰品</span><span class="eq-name"></span></div> <div class="eq-item"><span class="eq-type">护腕</span><span class="eq-name"></span></div>' +
|
||||
'<div class="eq-item"><span class="eq-type">腰带</span><span class="eq-name"></span></div><div class="eq-item"><span class="eq-type">暗器</span><span class="eq-name"></span></div></div><div class="obj-list"></div></div>');
|
||||
this.packElement = this.element.find(".obj-list");
|
||||
this.eqElement = this.element.find(".eq-list");
|
||||
}
|
||||
},
|
||||
show: function () {
|
||||
if (!Dialog.isShow) Dialog.show();
|
||||
if (this.objelement) {
|
||||
this.objelement.remove();
|
||||
this.objelement = null;
|
||||
this.packElement && this.packElement.show();
|
||||
}
|
||||
if (this.isShow) return SendCommand(this.items ? "pack none" : "pack");
|
||||
this.isShow = true;
|
||||
this.init_element();
|
||||
this.packElement.on("click", ".obj-item", Dialog.pack.item_click)
|
||||
this.eqElement.on("click", ".eq-item", Dialog.pack.eqitem_click);
|
||||
this.packElement.removeClass('cleanup');
|
||||
this.element.appendTo(Dialog.contentElement);
|
||||
|
||||
if (!this.items) SendCommand("pack");
|
||||
else {
|
||||
SendCommand("pack none");
|
||||
this.show_items();
|
||||
}
|
||||
},
|
||||
|
||||
create_eqs: function () {
|
||||
var items = this.eqElement.children();
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
var eq = this.eqs[i];
|
||||
if (eq) {
|
||||
$(items[i]).attr('class',
|
||||
'eq-item grade' + eq.grade).attr("oindex", i).find('.eq-name').html(eq.name);
|
||||
} else {
|
||||
$(items[i]).attr('class',
|
||||
"eq-item empty").attr("oindex", "").find('.eq-name').html("");
|
||||
}
|
||||
}
|
||||
}, levels: {
|
||||
"wht": 0, "hig": 1, "hic": 2, "hiy": 3, "hiz": 4, "hio": 5, "ord": 6
|
||||
},
|
||||
sort_items: function (items) {
|
||||
if (!items || !Setting.auto_sortitem) return items;
|
||||
var list = [];
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
var item = items[i];
|
||||
var isok = false;
|
||||
for (var j = 0; j < list.length; j++) {
|
||||
if (item.grade < list[j].grade) {
|
||||
list.splice(j, 0, item);
|
||||
isok = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isok) {
|
||||
list.push(item);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
},
|
||||
createItems: function () {
|
||||
if (!this.items) return;
|
||||
var items = Dialog.pack.sort_items(this.items);
|
||||
var html = [];
|
||||
let is_cleanup = this.packElement?.is('.cleanup');
|
||||
for (var i = 0; i < this.max_count; i++) {
|
||||
var item = items[i];
|
||||
|
||||
if (item) {
|
||||
html.push('<div class="obj-item ', item.is_lock ? "lock " : "", 'grade', item.grade, '" oindex="');
|
||||
html.push(item.id);
|
||||
html.push('">');
|
||||
html.push(item.name);
|
||||
if (this.show_type == 1) {
|
||||
html.push("<span class='obj-value'>");
|
||||
html.push("每");
|
||||
html.push(item.unit);
|
||||
html.push(Util.moneyToStr(item.value));
|
||||
html.push(":");
|
||||
html.push(item.count);
|
||||
html.push(item.unit);
|
||||
html.push('</span>');
|
||||
} else if (item.count > 1) {
|
||||
html.push("<span class='obj-value'>");
|
||||
html.push(item.count);
|
||||
html.push(item.unit);
|
||||
html.push('</span>');
|
||||
}
|
||||
if (is_cleanup) {
|
||||
if (item.grade > 0) {
|
||||
html.push("<span cmd='store' class='obj-oper"
|
||||
, (item.can_study ? " selected" : " "), "'>存仓库</span>");
|
||||
}
|
||||
if (item.can_combine && item.count >= item.can_combine) {
|
||||
html.push("<span cmd='combine' class='obj-oper'>合成</span>");
|
||||
}
|
||||
if (this.target_name) {
|
||||
html.push("<span cmd='give ", Process.player,
|
||||
' ', item.count, "' class='obj-oper'>拿来</span>");
|
||||
}
|
||||
if (item.can_eq && item.grade > 0) {
|
||||
html.push("<span cmd='sell' class='obj-oper'>卖掉</span>");
|
||||
html.push("<span cmd='fenjie' class='obj-oper'>分解</span>");
|
||||
} else if (item.value > 0) {
|
||||
html.push("<span cmd='sell' class='obj-oper'>卖掉</span>");
|
||||
} else if (!item.grade) {
|
||||
html.push("<span cmd='drop' class='obj-oper'>丢掉</span>");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
html.push('<div class="obj-item" oindex="">');
|
||||
}
|
||||
html.push('</div>');
|
||||
}
|
||||
this.packElement.html(html.join(""));
|
||||
|
||||
}, create_item_command: function (item, html, commands) {
|
||||
html.push('<span cmd="_confirm ' + this.command_before + 'drop ' + item.count + ' ' + item.id + '">丢掉</span>');
|
||||
//if (item.count > 1) {
|
||||
// html.push('<span cmd="drop ' + item.count + " " + item.id + '">全部丢掉</span>');
|
||||
//}
|
||||
html.push('<span cmd="lockobj ' + item.id + '">', item.is_lock ? "解锁" : "锁定", '</span>');
|
||||
if (item.can_eq) {
|
||||
html.push('<span cmd="' + this.command_before + 'eq ' + item.id + '">装备</span>');
|
||||
if (!this.command_before) {
|
||||
html.push('<span cmd="jinglian ' + item.id + '">精炼</span>');
|
||||
html.push('<span cmd="xiangqian ' + item.id + '">镶嵌</span>');
|
||||
html.push('<span cmd="shortcut ' + item.id + '">设置快速装备</span>');
|
||||
}
|
||||
html.push('<span cmd="' + this.command_before + 'fenjie ' + item.id + '">分解</span>');
|
||||
|
||||
}
|
||||
if (item.can_use) {
|
||||
html.push('<span cmd="' + this.command_before + 'use ' + item.id + '">使用</span>');
|
||||
if (!item.can_eq && !this.command_before) {
|
||||
html.push('<span cmd="shortcut ' + item.id + '">设置快速使用</span>');
|
||||
}
|
||||
}
|
||||
if (item.can_open) {
|
||||
html.push('<span cmd="' + this.command_before + 'open ' + item.id + '">打开</span>');
|
||||
}
|
||||
if (item.can_study) {
|
||||
html.push('<span cmd="' + this.command_before + 'study ' + item.id + '">学习</span>');
|
||||
}
|
||||
if (item.can_combine && item.count >= item.can_combine) {
|
||||
html.push('<span cmd="_confirm ' + this.command_before + 'combine ' + item.id + ' ' + item.can_combine + '">合成</span>');
|
||||
}
|
||||
if (this.command_before) {
|
||||
html.push('<span cmd="_confirm ' + this.command_before + 'give ' + Process.player + ' ' + item.count + ' ' + item.id + '">拿来</span>');
|
||||
}
|
||||
commands = commands || [];
|
||||
Dialog.extend.append(commands, 'pack', item);
|
||||
for (var i = 0; i < commands.length; i++) {
|
||||
if (commands[i].extend)
|
||||
html.push('<span cmd="', commands[i].cmd, '">', commands[i].name, '</span>');
|
||||
else
|
||||
html.push('<span cmd="packitem ', commands[i].cmd, ' ', item.id, '">', commands[i].name, '</span>');
|
||||
}
|
||||
}
|
||||
, item_click: function (e) {
|
||||
let elem = $(e.target);
|
||||
let is_cleanup = Dialog.pack.packElement.is('.cleanup');
|
||||
if (is_cleanup && elem.is('.obj-oper'))
|
||||
return Dialog.pack.item_cleanup(elem);
|
||||
elem = $(this);
|
||||
var obj = elem.attr("oindex");
|
||||
if (!obj) return;
|
||||
var item = Dialog.pack.get_item(obj);
|
||||
Dialog.pack.packElement.find(".item-commands").remove();
|
||||
if (!item) return;
|
||||
SCRIPT.LAST_OBJ = item;
|
||||
var html = ["<span class='item-commands'>"];
|
||||
html.push('<span cmd="checkobj ' + item.id + ' from item">查看</span>');
|
||||
Dialog.pack.create_item_command(item, html);
|
||||
html.push("</span>");
|
||||
elem = $(html.join("")).insertAfter(elem);
|
||||
Util.checkScroll(elem);
|
||||
},
|
||||
eqitem_click: function () {
|
||||
var item = Dialog.pack.eqs[$(this).attr("oindex")];
|
||||
if (!item) return;
|
||||
SendCommand("checkobj " + item.id + " from eq");
|
||||
}, item_cleanup: function (elem) {
|
||||
if (elem.is('.selected')) elem.removeClass('selected');
|
||||
else {
|
||||
elem.parent().find('.selected').removeClass('selected');
|
||||
elem.addClass('selected');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
const packet_css = `
|
||||
|
||||
.dialog-pack {
|
||||
min-width: 360px;
|
||||
overflow-x: auto;
|
||||
padding-top: 0.5em;
|
||||
}
|
||||
|
||||
|
||||
.dialog-pack>.obj-list {
|
||||
width: 50%;
|
||||
display: inline-block;
|
||||
overflow-y: auto;
|
||||
height: 25.625em;
|
||||
}
|
||||
|
||||
|
||||
.obj-list>.obj-item {
|
||||
|
||||
margin-left: 0.5em;
|
||||
}
|
||||
|
||||
.dialog-pack>.obj-desc {
|
||||
padding: 0.25em;
|
||||
margin: 0px;
|
||||
white-space: pre-wrap;
|
||||
width: 45%;
|
||||
height: 25.625em;
|
||||
display: inline-block;
|
||||
float: left;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
|
||||
.eq-list {
|
||||
width: 50%;
|
||||
display: inline-block;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.eq-list>.eq-item {
|
||||
border-radius: 4px;
|
||||
border-left-width: 2px;
|
||||
border-left-style: solid;
|
||||
white-space: nowrap;
|
||||
overflow-x: auto;
|
||||
margin-bottom: 0.5em;
|
||||
background-color: #111;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.eq-list>.empty {
|
||||
border-color: gray;
|
||||
color: gray;
|
||||
}
|
||||
|
||||
.eq-list>.eq-item>.eq-name {
|
||||
white-space: nowrap;
|
||||
padding-left: 0.3125em;
|
||||
}
|
||||
|
||||
.eq-list>.eq-item>.eq-type {
|
||||
background-color: #333;
|
||||
color: gray;
|
||||
line-height: 1.875em;
|
||||
display: inline-block;
|
||||
height: 1.875em;
|
||||
width: 3em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.obj-list>.obj-item {
|
||||
background-color: #111;
|
||||
line-height: 1.875em;
|
||||
min-height: 1.875em;
|
||||
padding-left: 0.3125em;
|
||||
|
||||
overflow-x: auto;
|
||||
white-space: nowrap;
|
||||
margin-bottom: 0.5em;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.obj-list>.lock:before {
|
||||
content: "\e033";
|
||||
font-family: 'Glyphicons Halflings';
|
||||
font-size: 0.8em;
|
||||
margin-right: 0.2em;
|
||||
color: var(--border-color);
|
||||
|
||||
}
|
||||
|
||||
.obj-item>.obj-oper {
|
||||
float: right;
|
||||
margin-right: 0.625em;
|
||||
padding-left: 0.5em;
|
||||
padding-right: 0.5em;
|
||||
line-height: 1.5em;
|
||||
background-color: #222;
|
||||
border-radius: 0.5em;
|
||||
margin-top: 0.2em;
|
||||
color: gray;
|
||||
display: none;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.cleanup>.obj-item>.obj-oper {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.cleanup>.obj-item>.selected {
|
||||
color: #00FF00;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.obj-item>.obj-count,
|
||||
.obj-item>.obj-value {
|
||||
float: right;
|
||||
margin-right: 0.625em;
|
||||
}
|
||||
|
||||
.cleanup>.obj-item>.obj-value,
|
||||
.cleanup>.obj-item>.obj-count {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
.obj-list>.disabled {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
|
||||
|
||||
`;
|
||||
|
||||
const list_css = `
|
||||
|
||||
.dialog-list {
|
||||
width: 100%;
|
||||
white-space: nowrap;
|
||||
overflow-x: auto;
|
||||
padding-top: 0.5em;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.dialog-list>.otype-list {
|
||||
width: 6em;
|
||||
}
|
||||
|
||||
.dialog-list>.otype-list>.otype-item {
|
||||
white-space: nowrap;
|
||||
line-height: 2em;
|
||||
width: 5em;
|
||||
text-align: center;
|
||||
background-color: #111;
|
||||
border-radius: 4px;
|
||||
margin-bottom: 0.5em;
|
||||
margin-right: 0.5em;
|
||||
margin-left: 0.5em;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.dialog-list>.otype-list>.select {
|
||||
background-color: #222;
|
||||
color: #00ff00;
|
||||
border-left-width: 2px;
|
||||
border-left-style: solid;
|
||||
border-left-color: #00ff00;
|
||||
}
|
||||
|
||||
.dialog-list>.trade-list,
|
||||
.dialog-list>.obj-list {
|
||||
|
||||
height: 21.25em;
|
||||
display: inline-block;
|
||||
overflow-y: auto;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
|
||||
.dialog-list>.obj-desc {
|
||||
padding: 0.25em;
|
||||
margin: 0px;
|
||||
white-space: pre-wrap;
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.dialog-list>.trade-list {
|
||||
|
||||
height: 21.25em;
|
||||
display: inline-block;
|
||||
overflow-y: auto;
|
||||
flex: 1;
|
||||
}
|
||||
.trade-list>.obj-item {
|
||||
background-color: #111;
|
||||
line-height: 1.875em;
|
||||
min-height: 1.875em;
|
||||
padding-left: 0.3125em;
|
||||
|
||||
overflow-x: auto;
|
||||
white-space: nowrap;
|
||||
margin-bottom: 0.5em;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.trade-list>.lock:before {
|
||||
content: "\e033";
|
||||
font-family: 'Glyphicons Halflings';
|
||||
font-size: 0.8em;
|
||||
margin-right: 0.2em;
|
||||
color: var(--border-color);
|
||||
|
||||
}`;
|
||||
111
src/dialog/packet2.js
Normal file
111
src/dialog/packet2.js
Normal file
@@ -0,0 +1,111 @@
|
||||
import SCRIPT from '../script.js';
|
||||
import Util from '../utils/util.js';
|
||||
|
||||
|
||||
export default {
|
||||
init: function () {
|
||||
Dialog.pack.init();
|
||||
// this.cleanup_cmds = Dialog.pack.cleanup_cmds;
|
||||
// this.formatEqs = Dialog.pack.formatEqs;
|
||||
// this.formatItems = Dialog.pack.formatItems;
|
||||
// this.formatPackItem = Dialog.pack.formatPackItem;
|
||||
// this.createItems = Dialog.pack.createItems;
|
||||
// this.create_eqs = Dialog.pack.create_eqs;
|
||||
// this.init_element = Dialog.pack.init_element;
|
||||
// this.show_items = Dialog.pack.show_items;
|
||||
// this.updateitem = Dialog.pack.updateitem;
|
||||
// this.footerChanged = Dialog.pack.footerChanged;
|
||||
// this.cleanup = Dialog.pack.cleanup;
|
||||
|
||||
this.show_sub = Dialog.pack.show_sub;
|
||||
this.close = Dialog.pack.close;
|
||||
this.get_item = Dialog.pack.get_item;
|
||||
this.create_item_command = Dialog.pack.create_item_command;
|
||||
},
|
||||
onData: function (data) {
|
||||
|
||||
this.show();
|
||||
if (data.items) {
|
||||
this.eqs = this.formatEqs(data.eqs || []);
|
||||
this.money = data.money;
|
||||
this.id = data.id;
|
||||
this.command_before = "dc " + this.id + " ";
|
||||
this.items = this.formatItems(data.items);
|
||||
this.target_name = data.name;
|
||||
this.max_count = data.max_item_count;
|
||||
this.show_items();
|
||||
this.show_moeny();
|
||||
} else {
|
||||
this.updateitem(data)
|
||||
}
|
||||
|
||||
},
|
||||
show_moeny: function () {
|
||||
if (!this.isShow) return;//+ "<span cmd='sell all'>清理包裹</span></div>"
|
||||
let mstr = Util.moneyToStr(this.money);
|
||||
let str = [];
|
||||
str.push("<div class='obj-money'>");
|
||||
if (this.packElement.is('.cleanup')) {
|
||||
|
||||
str.push("<span for='cancle' class='footer-item'>取消</span>");
|
||||
str.push("<span for='store' class='footer-item'>自动存仓</span>");
|
||||
str.push("<span for='sell' class='footer-item'>清理杂物</span>");
|
||||
str.push("<span for='cleanup' class='footer-item'>确定</span></div>");
|
||||
} else {
|
||||
str.push(this.target_name, (mstr ? "身上有"
|
||||
+ mstr : "身上没有任何银两"));
|
||||
str.push("<span for='cleanup' class='footer-item'>整理</span></div>");
|
||||
}
|
||||
Dialog.footer(str.join(""));
|
||||
|
||||
},
|
||||
cleanup_item: function (x, y) {
|
||||
let elem = $(y);
|
||||
let item = elem.parent().attr('oindex');
|
||||
let cmd = elem.attr('cmd');
|
||||
SendCommand(Dialog.pack2.command_before + " " + cmd + " " + item);
|
||||
},
|
||||
hide: function () {
|
||||
this.element.remove();
|
||||
this.isShow = false;
|
||||
},
|
||||
show: function () {
|
||||
if (!Dialog.isShow) Dialog.show("pack2");
|
||||
if (this.objelement) {
|
||||
this.objelement.remove();
|
||||
this.objelement = null;
|
||||
this.packElement && this.packElement.show();
|
||||
}
|
||||
if (this.isShow) return;
|
||||
this.isShow = true;
|
||||
this.init_element();
|
||||
this.packElement.on("click", ".obj-item", this.item_click)
|
||||
this.eqElement.on("click", ".eq-item", this.eqitem_click);
|
||||
this.element.appendTo(Dialog.contentElement);
|
||||
}
|
||||
, item_click: function (e) {
|
||||
let elem = $(e.target);
|
||||
let is_cleanup = Dialog.pack2.packElement.is('.cleanup');
|
||||
if (is_cleanup && elem.is('.obj-oper'))
|
||||
return Dialog.pack.item_cleanup(elem);
|
||||
elem = $(this);
|
||||
var obj = elem.attr("oindex");
|
||||
if (!obj) return;
|
||||
var item = Dialog.pack2.get_item(obj);
|
||||
Dialog.pack2.element.find(".item-commands").remove();
|
||||
if (!item) return;
|
||||
SCRIPT.LAST_OBJ = item;
|
||||
var html = ["<span class='item-commands'>"];
|
||||
html.push('<span cmd="' + Dialog.pack2.command_before + ' checkobj ' + item.id + ' from item">查看</span>');
|
||||
Dialog.pack2.create_item_command(item, html);
|
||||
html.push("</span>");
|
||||
elem = $(html.join("")).insertAfter(elem);
|
||||
Util.checkScroll(elem);
|
||||
|
||||
}, eqitem_click: function () {
|
||||
var item = Dialog.pack2.eqs[$(this).attr("oindex")];
|
||||
if (!item) return;
|
||||
SendCommand(Dialog.pack2.command_before + " checkobj " + item.id + " from eq");
|
||||
}
|
||||
|
||||
};
|
||||
156
src/dialog/paimai.js
Normal file
156
src/dialog/paimai.js
Normal file
@@ -0,0 +1,156 @@
|
||||
|
||||
|
||||
const paimai_css = `
|
||||
.dialog-pms {
|
||||
max-height: 32em;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
.dialog-pms>.empty {
|
||||
text-align: center;
|
||||
margin-top: 3em;
|
||||
margin-bottom: 3em;
|
||||
color: gray;
|
||||
}
|
||||
|
||||
.dialog-pms>.pm-item {
|
||||
border-radius: 6px;
|
||||
background-color: #111111;
|
||||
border-left-width: 4px;
|
||||
border-left-style: solid;
|
||||
border-left-color: gray;
|
||||
position: relative;
|
||||
padding-left: 0.5em;
|
||||
line-height: 2em;
|
||||
margin-top: 0.5em;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.dialog-pms>.selected {
|
||||
border-left-color: #00ff00;
|
||||
background-color: #222;
|
||||
}
|
||||
|
||||
.dialog-pms>.pm-item>.pm-title {
|
||||
width: 10em;
|
||||
|
||||
}
|
||||
|
||||
.dialog-pms>.pm-item>.pm-desc {
|
||||
min-width: 10em;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.dialog-pms>.pm-item>.pm-mem {
|
||||
|
||||
padding-right: 1em;
|
||||
color: gray;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
.dialog-pms>.pm-item>.pm-add {
|
||||
width: 4em;
|
||||
border-left: 1px solid #343434;
|
||||
text-align: center;
|
||||
color: #008080
|
||||
}
|
||||
|
||||
.dialog-pms>.pm-item>.pm-add:hover {
|
||||
background-color: #333;
|
||||
}
|
||||
`;
|
||||
|
||||
function format_time_span(time) {
|
||||
let diff = Math.floor((time) / 1000);
|
||||
if (diff < 0) diff = 0;
|
||||
if (diff > 3600) {
|
||||
let str = Math.floor(diff / 3600) + "小时";
|
||||
diff = diff % 3600;
|
||||
str += Math.floor(diff / 60) + "分";
|
||||
return str;
|
||||
}
|
||||
let str = Math.floor(diff / 60) + "分";
|
||||
diff = diff % 60;
|
||||
|
||||
return str + diff + "秒";
|
||||
|
||||
}
|
||||
|
||||
export default {
|
||||
init: function () {
|
||||
Dialog.injectStyle(paimai_css);
|
||||
},
|
||||
close: function () {
|
||||
this.element.remove();
|
||||
this.isShow = false;
|
||||
}, onData: function (data) {
|
||||
if (data.list) {
|
||||
this.show();
|
||||
this.create_items(data.list);
|
||||
} else if (data.item) {
|
||||
this.update_item(data.item);
|
||||
}
|
||||
},
|
||||
show: function () {
|
||||
if (!Dialog.isShow || Dialog.curItem != "pm")
|
||||
Dialog.show("pm");
|
||||
if (!this.element)
|
||||
this.element = $("<div class='dialog-pms'></div>");
|
||||
if (this.isShow) return;
|
||||
Dialog.title("拍卖行");
|
||||
Dialog.icon("shopping-cart");
|
||||
Dialog.footer("");
|
||||
this.element.appendTo(Dialog.contentElement);
|
||||
this.element.on('click', '.pm-item', this.select_item);
|
||||
this.isShow = true;
|
||||
},
|
||||
select_item: function () {
|
||||
let elem = $(this);
|
||||
let dialog = Dialog.pm;
|
||||
if (dialog.selected_item)
|
||||
dialog.selected_item.removeClass('selected');
|
||||
dialog.selected_item = elem;
|
||||
dialog.selected_item.addClass('selected');
|
||||
}, update_item: function (item) {
|
||||
let elem = this.element.find('.pm-item[oid="' + item[0] + '"]');
|
||||
if (elem) elem.replaceWith(this.create_item(item));
|
||||
},
|
||||
create_items: function (list) {
|
||||
let str = [];
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
str.push(this.create_item(list[i]));
|
||||
}
|
||||
if (!str.length) str.push('<div class="empty">暂无拍卖</div>');
|
||||
this.element.html(str.join(""));
|
||||
Dialog.footer('<span class="obj-money">共有'
|
||||
+ list.length + '项道具正在拍卖</span>');
|
||||
|
||||
}, create_item: function (item) {
|
||||
let str = [];
|
||||
const [id, name, money, time, uname] = item;
|
||||
str.push("<div class='pm-item grade0 flex-row' oid='", id, "'>");
|
||||
str.push("<div class='pm-title' cmd='pm show ", id, "'>");
|
||||
str.push(name);
|
||||
str.push("</div>");
|
||||
|
||||
str.push("<div class='pm-desc flex-1'>");
|
||||
if (uname) {
|
||||
str.push(uname, '最后出价', moneyToStr(money),);
|
||||
} else {
|
||||
str.push('当前价格', moneyToStr(money),);
|
||||
}
|
||||
str.push("</div>");
|
||||
|
||||
str.push("<div class='pm-mem'>");
|
||||
str.push('剩余:', format_time_span(time), '');
|
||||
str.push("</div>");
|
||||
str.push("<div class='pm-add' cmd='pm add ", id, "'>");
|
||||
str.push('出价');
|
||||
str.push("</div>");
|
||||
str.push("</div>");
|
||||
return str.join("");
|
||||
},
|
||||
format_num: function (num) {
|
||||
return num > 9 ? num.toString() : "0" + num.toString();
|
||||
}
|
||||
};
|
||||
268
src/dialog/party.js
Normal file
268
src/dialog/party.js
Normal file
@@ -0,0 +1,268 @@
|
||||
|
||||
|
||||
const party_css = `
|
||||
.dialog-party>wht {
|
||||
display: inline-block;
|
||||
height: 15rem;
|
||||
line-height: 15rem;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.dialog-party>.dialog-party-add {
|
||||
margin-top: 2em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.dialog-party>.dialog-party-add>input {
|
||||
border: 1px solid gray;
|
||||
background-color: transparent;
|
||||
color: unset;
|
||||
resize: none;
|
||||
margin-top: 1em;
|
||||
margin-bottom: 1em;
|
||||
line-height: 2em;
|
||||
border-radius: 0.5em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.dialog-party>.party-title {
|
||||
font-size: 2rem;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
height: 2rem;
|
||||
line-height: 2rem;
|
||||
margin-top: 0.25em;
|
||||
margin-bottom: 0.25em;
|
||||
opacity: 0.7;
|
||||
font-weight: bold;
|
||||
|
||||
}
|
||||
|
||||
.dialog-party>.party-notice {
|
||||
padding-top: 0.25em;
|
||||
padding-bottom: 0.25em;
|
||||
color: #00FFFF;
|
||||
line-height: 2em;
|
||||
}
|
||||
|
||||
.dialog-party>.party-notice>*>span {
|
||||
|
||||
width: 3em;
|
||||
display: inline-block;
|
||||
padding-right: 0.5em;
|
||||
}
|
||||
|
||||
.dialog-party>.party-title>.party-count {
|
||||
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.dialog-party>.party-title>*>.glyphicon {
|
||||
|
||||
padding-right: 0.5em;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.dialog-party>.party-roles {
|
||||
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.dialog-party>.party-roles>.party-role,
|
||||
.dialog-party>.party-item {
|
||||
|
||||
padding-left: 0.5em;
|
||||
border-radius: 4px;
|
||||
border-left-width: 2px;
|
||||
border-left-style: solid;
|
||||
border-left-color: gray;
|
||||
white-space: nowrap;
|
||||
overflow-x: auto;
|
||||
margin-top: 0.5em;
|
||||
margin-bottom: 0.5em;
|
||||
background-color: #111;
|
||||
line-height: 2em;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.dialog-party>.party-item {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.dialog-party>.party-item>.party-item-name {
|
||||
padding-left: 0.5em;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.dialog-party>.party-item>.party-item-sc {
|
||||
|
||||
flex: 0;
|
||||
margin-left: 1em;
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
.dialog-party>.party-item>.party-item-cmd {
|
||||
flex: 0;
|
||||
background-color: #222;
|
||||
padding-left: 1em;
|
||||
padding-right: 1em;
|
||||
}
|
||||
|
||||
.dialog-party>.party-roles>.party-role>.role-level {
|
||||
|
||||
width: 3em;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.dialog-party>.party-roles>.party-role>.role-name {
|
||||
padding-left: 0.5em;
|
||||
}
|
||||
|
||||
.dialog-party>.party-roles>.party-role>.role-sc {
|
||||
float: right;
|
||||
padding-right: 0.5rem;
|
||||
|
||||
}
|
||||
`;
|
||||
|
||||
export default {
|
||||
init: function () {
|
||||
Dialog.injectStyle(party_css);
|
||||
},
|
||||
createElement: function () {
|
||||
return $('<div class="dialog-party"></div>');
|
||||
},
|
||||
inner_show: function () {
|
||||
//需要优化
|
||||
SendCommand("party load");
|
||||
this.isShow = true;
|
||||
Dialog.title("");
|
||||
this.element.on("click", '.party-role', this.show_commands);
|
||||
Dialog.icon("flag");
|
||||
},
|
||||
levels: ["", "<hio>帮主<hio>", "<hiz>副帮主</hiz>", "<hiy>长老</hiy>", "<hic>堂主</hic>", "帮众"],
|
||||
level_roles: [1, 20, 30, 40, 50, 60],
|
||||
level: 5,
|
||||
get_role: function (id) {
|
||||
if (!this.roles) return;
|
||||
for (var i = 0; i < this.roles.length; i++) {
|
||||
if (this.roles[i].id == id) return this.roles[i];
|
||||
}
|
||||
},
|
||||
command: function (type) {
|
||||
if (type === 'create') {
|
||||
|
||||
let str = ['<div class="dialog-party-add">'];
|
||||
str.push('<div>创建帮派需要500两<hiy>黄金</hiy>,请输入帮派名称(2-5字中文):</div>');
|
||||
|
||||
str.push('<input type="text" ></input>');
|
||||
|
||||
str.push("<div class='item-commands'><span cmd='_party cancle'>取消</span><span cmd='_party create2'>确定</span></div>");
|
||||
str.push('</div>');
|
||||
this.element.html(str.join(""));
|
||||
} else if (type === 'cancle') {
|
||||
this.empty('你还没有加入帮派');
|
||||
} else if (type === 'create2') {
|
||||
let val = $('.dialog-party-add>input').val();
|
||||
if (!val || val.length > 5 || val.length < 2)
|
||||
return ReceiveMessage("帮派名字需要是2-5中文字符。");
|
||||
SendCommand('party create2 ' + val);
|
||||
}
|
||||
|
||||
}, empty: function (str) {
|
||||
this.element.html("<wht>" + str + "</wht><div class='item-commands'><span cmd='_party create'>创建帮派</span><span cmd='party list'>加入帮派</span></div>");
|
||||
|
||||
},
|
||||
show_list: function (data) {
|
||||
if (!data.list.length) return this.empty('现在没有已经创建的帮派');
|
||||
var str = [];
|
||||
for (let item of data.list) {
|
||||
str.push("<div class='party-item'>");
|
||||
str.push("<span class='party-item-name'>");
|
||||
str.push(item[0]);
|
||||
str.push("</span>");
|
||||
str.push("<span class='party-item-sc'>人数:");
|
||||
str.push(item[1]);
|
||||
str.push("</span>");
|
||||
str.push("<span class='party-item-cmd' cmd='party join ", item[0], "'>加入</span>");
|
||||
str.push("</div>");
|
||||
}
|
||||
this.element.html(str.join(""));
|
||||
},
|
||||
onData: function (data) {
|
||||
if (data.list) return this.show_list(data);
|
||||
if (!data.name) {
|
||||
return this.empty('你还没有加入帮派');
|
||||
}
|
||||
var party = data;
|
||||
|
||||
Dialog.title('帮派【' + party.name + '】 <nor>' + data.roles.length + "/" + this.level_roles[data.level] + "</nor>");
|
||||
var str = [];
|
||||
// str.push("<div class='party-title'><hio>");
|
||||
// str.push(party.name);
|
||||
// str.push("</hio><span class='party-count'><nor>(" + data.roles.length + "/" + this.level_roles[data.level] + ")</nor></span>");
|
||||
// str.push("</div>");
|
||||
if (party.notice) {
|
||||
str.push("<div class='party-notice'>");
|
||||
str.push(party.notice);
|
||||
str.push("</div>");
|
||||
}
|
||||
str.push("<div class='party-roles'>");
|
||||
for (var i = 0; i < party.roles.length; i++) {
|
||||
var role = party.roles[i];
|
||||
if (role.id == Process.player) {
|
||||
this.level = role.level;
|
||||
}
|
||||
str.push("<div class='party-role' roleid='" + role.id + "'>");
|
||||
str.push("<span class='role-level'>");
|
||||
str.push(this.levels[role.level]);
|
||||
str.push("</span>");
|
||||
str.push("<span class='role-name'>");
|
||||
str.push(role.name);
|
||||
str.push("</span>");
|
||||
str.push("<span class='role-sc'>");
|
||||
str.push(role.sc);
|
||||
str.push("</span>");
|
||||
str.push("</div>");
|
||||
}
|
||||
str.push("</div>");
|
||||
this.roles = data.roles;
|
||||
this.element.html(str.join(""));
|
||||
}, show_commands: function () {
|
||||
var role = Dialog.party.get_role($(this).attr("roleid"));
|
||||
if (!role) return;
|
||||
var html = ["<div class='item-commands'>"];
|
||||
|
||||
|
||||
if (role.id == Process.player) {
|
||||
html.push('<span cmd="party out">退出帮派</span>');
|
||||
if (Dialog.party.level == 1) {
|
||||
html.push('<span cmd="party dissmiss">解散</span>');
|
||||
}
|
||||
} else {
|
||||
if (role.level > Dialog.party.level - 1 && role.level > 2)
|
||||
html.push('<span cmd="party uplevel ' + role.id + '">提升为' + (Dialog.party.levels[role.level - 1]) + '</span>');
|
||||
if (role.level > Dialog.party.level && role.level < 5) {
|
||||
html.push('<span cmd="party downlevel ' + role.id + '">降级为' + (Dialog.party.levels[role.level + 1]) + '</span>');
|
||||
}
|
||||
if (Dialog.party.level == 1 && role.level == 2) {
|
||||
html.push('<span cmd="party trans ' + role.id + '">让位</span>');
|
||||
}
|
||||
if (role.level > Dialog.party.level)
|
||||
html.push('<span cmd="party remove ' + role.id + '">开除</span>');
|
||||
if (role.online) {
|
||||
html.push('<span cmd="team add ' + role.id + '">邀请组队</span>');
|
||||
}
|
||||
}
|
||||
if (html.length == 1) return;
|
||||
html.push("</div>");
|
||||
Dialog.party.element.find(".item-commands").remove();
|
||||
$(html.join("")).insertAfter(this);
|
||||
},
|
||||
inner_close: function () {
|
||||
this.element.remove();
|
||||
this.isShow = false;
|
||||
}
|
||||
};
|
||||
94
src/dialog/relation.js
Normal file
94
src/dialog/relation.js
Normal file
@@ -0,0 +1,94 @@
|
||||
|
||||
|
||||
export default {
|
||||
init: function () { },
|
||||
createElement: function () {
|
||||
return $('<div class="dialog-relation"></div>');
|
||||
},
|
||||
inner_show: function () {
|
||||
SendCommand("relation");
|
||||
this.isShow = true;
|
||||
Dialog.title("关系");
|
||||
Dialog.icon("heart");
|
||||
},
|
||||
onData: function (data) {
|
||||
var str = [];
|
||||
str.push("<div class='relation-item'>");
|
||||
str.push("<div class='relation-desc'>");
|
||||
if (data.husband) {
|
||||
str.push("你的丈夫:");
|
||||
str.push(data.husband);
|
||||
} else if (data.wife) {
|
||||
str.push("你的妻子:");
|
||||
str.push(data.wife);
|
||||
} else {
|
||||
str.push("你目前没有结婚。");
|
||||
}
|
||||
str.push("</div>");
|
||||
if (data.wife || data.husband) {
|
||||
str.push("<div class='relation-cmd' cmd='_confirm greet wife'><him>❀送花❀</him></div>");
|
||||
str.push("<div class='relation-cmd' cmd='rel marry'>解除关系</div>");
|
||||
}
|
||||
str.push("</div>");
|
||||
|
||||
str.push("<div class='relation-item'>");
|
||||
str.push("<div class='relation-desc'>");
|
||||
if (data.shifu) {
|
||||
str.push("你的师父:");
|
||||
str.push(data.shifu);
|
||||
} else if (data.tudi) {
|
||||
str.push("你的徒弟:");
|
||||
str.push(data.tudi);
|
||||
|
||||
} else {
|
||||
str.push("你目前没有拜师,也没有收徒。");
|
||||
}
|
||||
str.push("</div>");
|
||||
if (data.shifu) {
|
||||
str.push("<div class='relation-cmd' cmd='greet master'><hig>请安</hig></div>");
|
||||
str.push("<div class='relation-cmd' cmd='rel st'>出师</div>");
|
||||
|
||||
str.push("</div>");
|
||||
} else if (data.tid) {
|
||||
str.push("<div class='relation-cmd' cmd='rel st'>解除关系</div>");
|
||||
}
|
||||
str.push("</div>");
|
||||
|
||||
if (data.st != undefined) {
|
||||
str.push("<div class='relation-item'><div class='relation-desc'>");
|
||||
str.push("当师徒组队完成副本后将获得额外奖励,本周已完成" + data.st + "/10。", '</div>');
|
||||
str.push("<div class='relation-cmd' cmd='team add ",
|
||||
data.tid ?? data.shifu, "'>邀请组队</div>");
|
||||
str.push("</div>");
|
||||
}
|
||||
if (data.reward) {
|
||||
str.push("<div class='relation-item'>");
|
||||
str.push(data.reward)
|
||||
str.push("</div>");
|
||||
}
|
||||
str.push("</div>");
|
||||
if (data.fls) {
|
||||
for (let item of data.fls) {
|
||||
if (!item) continue;
|
||||
str.push("<div class='relation-item'>");
|
||||
str.push("<div class='relation-desc'>你的家人:", item[0]);
|
||||
if (item[2]) {
|
||||
str.push(',已', item[2], format_time_span(item[3]));
|
||||
str.push('</div>');
|
||||
str.push("<div class='relation-cmd' cmd='rel ", item[1], " stop'>停止</div>");
|
||||
} else {
|
||||
str.push('空闲中</div>');
|
||||
str.push("<div class='relation-cmd' cmd='rel ", item[1], " caiyao'><hic>采药</hic></div>");
|
||||
str.push("<div class='relation-cmd' cmd='rel ", item[1], " diaoyu'><hic>钓鱼</hic></div>");
|
||||
str.push("<div class='relation-cmd' cmd='rel ", item[1], " wk'><hic>挖矿</hic></div>");
|
||||
}
|
||||
str.push("</div>");
|
||||
}
|
||||
}
|
||||
this.element.html(str.join(""));
|
||||
},
|
||||
inner_close: function () {
|
||||
this.element.remove();
|
||||
this.isShow = false;
|
||||
}
|
||||
};
|
||||
333
src/dialog/score.js
Normal file
333
src/dialog/score.js
Normal file
@@ -0,0 +1,333 @@
|
||||
|
||||
|
||||
export default {
|
||||
footer: [["属性", null],
|
||||
["详细", null], ["称号", null]],
|
||||
|
||||
selectIndex: 0,
|
||||
onData: function (data) {
|
||||
console.log(data);
|
||||
this.data = data;
|
||||
this.init_elem();
|
||||
Dialog.titleElement.html(data.name);
|
||||
Dialog.icon("user");
|
||||
if (data.titles) {
|
||||
this.titles = data.titles;
|
||||
this.create_titles();
|
||||
} else {
|
||||
if (data.id && data.id != this.uid) {
|
||||
this.uid = data.id;
|
||||
if (this.uid != Process.player) {
|
||||
Dialog.footerElement.find(".footer-item:eq(2)").hide();
|
||||
} else {
|
||||
Dialog.footerElement.find(".footer-item:eq(2)").show();
|
||||
}
|
||||
}
|
||||
var panel = $(data.name ? this.footer[0][1] : this.footer[1][1]);
|
||||
var elems = panel.find("span");
|
||||
for (var i = 0; i < elems.length; i++) {
|
||||
var elem = $(elems[i]);
|
||||
var prop = elem.attr("data-prop");
|
||||
if (prop) {
|
||||
elem.html(data[prop] || 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
init: function () {
|
||||
this.footer[0][1] = $(this.template_score);
|
||||
this.footer[1][1] = $(this.template_score2);
|
||||
this.footer[2][1] = $(this.template_title);
|
||||
Dialog.injectStyle(this.css);
|
||||
},
|
||||
init_elem: function () {
|
||||
Dialog.init();
|
||||
Dialog.curItem = "score";
|
||||
if (this.isShow) return;
|
||||
Dialog.footer("");
|
||||
|
||||
for (var i = 0; i < this.footer.length; i++) {
|
||||
$("<span class='footer-item " + (this.selectIndex == i ? "select" : "") + "' for='" + i + "'>"
|
||||
+ this.footer[i][0] + "</span>").appendTo(Dialog.footerElement);
|
||||
}
|
||||
this.isShow = true;
|
||||
this.footerChanged(this.selectIndex);
|
||||
|
||||
},
|
||||
show: function (nosend) {
|
||||
if (nosend) return;
|
||||
if (!this.selectIndex) SendCommand("score");
|
||||
else if (this.selectIndex == 1) SendCommand("score2");
|
||||
else SendCommand("score title");
|
||||
this.init_elem();
|
||||
},
|
||||
close: function () {
|
||||
this.footer[this.selectIndex][1].remove();
|
||||
Dialog.footer("");
|
||||
this.isShow = false;
|
||||
},
|
||||
footerChanged: function (item) {
|
||||
item = parseInt(item);
|
||||
this.footer[this.selectIndex][1].remove();
|
||||
this.selectIndex = item;
|
||||
|
||||
var panel = $(this.footer[this.selectIndex][1]).appendTo(Dialog.contentElement.empty());
|
||||
if (item == 1) {
|
||||
if (this.uid && Process.player != this.uid)
|
||||
SendCommand("score2 " + this.uid);
|
||||
else
|
||||
SendCommand("score2");
|
||||
}
|
||||
else if (item == 2) {
|
||||
if (!this.titles)
|
||||
SendCommand("score title");
|
||||
panel.on("click", ".btn-noused", function (e) {
|
||||
var elem = $(e.target);
|
||||
if (elem.is("red")) elem = elem.parent();
|
||||
var index = parseInt(elem.attr("index"));
|
||||
for (var i = 0; i < this.titles.length; i++) {
|
||||
if (i == index) this.titles[i].use = this.titles[i].use ? false : true;
|
||||
else this.titles[i].use = false;
|
||||
}
|
||||
SendCommand("title " + index);
|
||||
this.create_titles();
|
||||
}.bind(this));
|
||||
}
|
||||
},
|
||||
|
||||
create_titles: function () {
|
||||
var panel = $(".dialog-titles");
|
||||
var html = [];
|
||||
for (var i = 0; i < this.titles.length; i++) {
|
||||
html.push("<div class='title-item", this.titles[i].use ? " selected" : "", "'>");
|
||||
html.push(this.titles[i].title);
|
||||
html.push("<span class='btn-noused' index='");
|
||||
html.push(i);
|
||||
html.push("'>");
|
||||
html.push(this.titles[i].use ? "<red>取消</red>" : "使用");
|
||||
html.push("</span>");
|
||||
|
||||
html.push("</div>");
|
||||
}
|
||||
panel.html(html.length ? html.join("") : "<div class='empty'>你还没有获得任何称号</div>");
|
||||
},
|
||||
|
||||
|
||||
template_score: `
|
||||
<div class="dialog-score" cellpadding="0" cellspacing="1">
|
||||
<div class="score-section">
|
||||
<span class="title">
|
||||
<hic>【性别】</hic>
|
||||
</span><span data-prop="gender" class="value"></span>
|
||||
<span class="title">
|
||||
<hic>【等级】</hic>
|
||||
</span><span data-prop="level" class="value"></span><br />
|
||||
<span class="title">
|
||||
<hic>【年龄】</hic>
|
||||
</span><span data-prop="age" style="width:10em;" class="value">14</span><br />
|
||||
<span class="title">
|
||||
<hic>【经验】</hic>
|
||||
</span>
|
||||
<hic><span data-prop="exp" class="value">0</span></hic>
|
||||
<span class="title">
|
||||
<hic>【潜能】</hic>
|
||||
</span>
|
||||
<hic><span data-prop="pot" class="value">0</span></hic>
|
||||
</div>
|
||||
<div class="score-section">
|
||||
<div><span class="title">
|
||||
<hig>【气血】</hig>
|
||||
</span>
|
||||
<hig><span data-prop="hp" class="value"
|
||||
style="text-align:right">0</span><span> / </span><span class="value"
|
||||
data-prop="max_hp">0</span></hig>
|
||||
</div>
|
||||
<div><span class="title">
|
||||
<hig>【内力】</hig>
|
||||
</span>
|
||||
<hig><span data-prop="mp" class="value"
|
||||
style="text-align:right">0</span><span> / </span><span class="value"
|
||||
data-prop="max_mp">0</span></hig>
|
||||
</div>
|
||||
<span class="title" style="width:6em;">
|
||||
<hic>【内力上限】</hic>
|
||||
</span>
|
||||
<hic><span data-prop="limit_mp" class="value">0</span></hic><br />
|
||||
<span class="title" style="width:6em;">
|
||||
<hic>【精力】</hic>
|
||||
</span>
|
||||
<hic><span data-prop="jingli" class="value">0</span></hic>
|
||||
</div>
|
||||
<div class="score-section">
|
||||
<span class="title">
|
||||
<hiy>【臂力】</hiy>
|
||||
</span><span class="value">
|
||||
<hiy><span data-prop="str">0</span></hiy>
|
||||
<NOR> (+<span data-prop="str_add">0</span>)</NOR>
|
||||
</span>
|
||||
<span class="title">
|
||||
<hiy>【根骨】</hiy>
|
||||
</span><span class="value">
|
||||
<hiy><span data-prop="con">0</span></hiy>
|
||||
<NOR>(+<span data-prop="con_add">0</span>)</NOR>
|
||||
</span><br />
|
||||
<span class="title">
|
||||
<hiy>【身法】</hiy>
|
||||
</span><span class="value">
|
||||
<hiy><span data-prop="dex">0</span></hiy>
|
||||
<NOR>(+<span data-prop="dex_add">0</span>)</NOR>
|
||||
</span>
|
||||
<span class="title">
|
||||
<hiy>【悟性】</hiy>
|
||||
</span><span class="value">
|
||||
<hiy><span data-prop="int">0</span></hiy>
|
||||
<NOR>(+<span data-prop="int_add">0</span>)</NOR>
|
||||
</span><br />
|
||||
<span class="title">
|
||||
<hiy>【容貌】</hiy>
|
||||
</span><span class="value">
|
||||
<hiy><span data-prop="per">0</span></hiy>
|
||||
</span>
|
||||
</div>
|
||||
<div class="score-section">
|
||||
<span class="title">
|
||||
<hic>【攻击】</hic>
|
||||
</span>
|
||||
<hic><span data-prop="gj" class="value">0</span></hic>
|
||||
<span class="title">
|
||||
<hic>【防御】</hic>
|
||||
</span>
|
||||
<hic><span data-prop="fy" class="value">0</span></hic><br />
|
||||
<span class="title">
|
||||
<hic>【命中】</hic>
|
||||
</span>
|
||||
<hic><span data-prop="mz" class="value">0</span></hic>
|
||||
<span class="title">
|
||||
<hic>【躲闪】</hic>
|
||||
</span>
|
||||
<hic><span data-prop="ds" class="value">0</span></hic><br />
|
||||
<span class="title">
|
||||
<hic>【招架】</hic>
|
||||
</span>
|
||||
<hic><span data-prop="zj" class="value">0</span></hic>
|
||||
<span class="title">
|
||||
<hic>【暴击】</hic>
|
||||
</span>
|
||||
<hic><span data-prop="bj" class="value">0</span></hic><br />
|
||||
<span class="title" style="width:6em;">
|
||||
<hic>【攻击速度】</hic>
|
||||
</span>
|
||||
<hic><span data-prop="gjsd" class="value">0</span></hic>
|
||||
</div>
|
||||
<div class="score-section">
|
||||
<span class="title">
|
||||
<hic>【门派】</hic>
|
||||
</span>
|
||||
<hic><span data-prop="family" class="value">无门无派</span></hic><br />
|
||||
<span class="title">
|
||||
<hic>【师傅】</hic>
|
||||
</span>
|
||||
<hic><span data-prop="master" class="value">无</span></hic><br />
|
||||
<span class="title">
|
||||
<hic>【功绩】</hic>
|
||||
</span>
|
||||
<hic><span data-prop="gongji" class="value">0</span></hic><br />
|
||||
</div>
|
||||
</div>`,
|
||||
template_score2: ` <div class="dialog-score2">
|
||||
<span class="title">
|
||||
<hic>【最终伤害】</hic>
|
||||
</span>
|
||||
<hic>
|
||||
<span data-prop="add_sh" class="value">0</span>
|
||||
</hic>
|
||||
<br />
|
||||
<span class="title">
|
||||
<hic>【忽视防御】</hic>
|
||||
</span>
|
||||
<hic>
|
||||
<span data-prop="diff_fy" class="value">0</span>
|
||||
</hic><br />
|
||||
|
||||
<span class="title">
|
||||
<hic>【暴击伤害】</hic>
|
||||
</span>
|
||||
<hic>
|
||||
<span data-prop="add_bj" class="value">0</span>
|
||||
</hic>
|
||||
<br />
|
||||
|
||||
<span class="title">
|
||||
<hic>【伤害减免】</hic>
|
||||
</span>
|
||||
<hic>
|
||||
<span data-prop="diff_sh" class="value">0</span>
|
||||
</hic>
|
||||
<br />
|
||||
<span class="title">
|
||||
<hic>【暴击抵抗】</hic>
|
||||
</span>
|
||||
<hic>
|
||||
<span data-prop="diff_bj" class="value">0</span>
|
||||
</hic><br />
|
||||
<span class="title">
|
||||
<hic>【释放时间减少】</hic>
|
||||
</span>
|
||||
<hic>
|
||||
<span data-prop="releasetime" class="value">0</span>
|
||||
</hic><br />
|
||||
<span class="title">
|
||||
<hic>【忙乱时间】</hic>
|
||||
</span>
|
||||
<hic>
|
||||
<span data-prop="busy" class="value">0</span>
|
||||
</hic><br />
|
||||
<span class="title">
|
||||
<hic>【忽视忙乱】</hic>
|
||||
</span>
|
||||
<hic>
|
||||
<span data-prop="diff_busy" class="value">0</span>
|
||||
</hic><br />
|
||||
<span class="title">
|
||||
<hic>【冷却时间减少】</hic>
|
||||
</span>
|
||||
<hic>
|
||||
<span data-prop="distime" class="value">0</span>
|
||||
</hic><br />
|
||||
<span class="title">
|
||||
<hic>【内力消耗减少】</hic>
|
||||
</span>
|
||||
<hic>
|
||||
<span data-prop="expend_mp" class="value">0</span>
|
||||
</hic><br />
|
||||
<span class="title">
|
||||
<hic>【负面抵抗】</hic>
|
||||
</span>
|
||||
<hic>
|
||||
<span data-prop="downside_per" class="value">0</span>
|
||||
</hic><br />
|
||||
<span class="title">
|
||||
<hic>【打坐效率】</hic>
|
||||
</span>
|
||||
<hic>
|
||||
<span data-prop="dazuo_per" class="value">0</span>
|
||||
</hic><br />
|
||||
<span class="title">
|
||||
<hic>【学习效率】</hic>
|
||||
</span>
|
||||
<hic>
|
||||
<span data-prop="study_per" class="value">0</span>
|
||||
</hic><br />
|
||||
<span class="title">
|
||||
<hic>【练习效率】</hic>
|
||||
</span>
|
||||
<hic>
|
||||
<span data-prop="lianxi_per" class="value">0</span>
|
||||
</hic>
|
||||
</div>`,
|
||||
template_title: ` <div class="dialog-titles">
|
||||
</div>
|
||||
`,
|
||||
|
||||
|
||||
};
|
||||
1087
src/dialog/setting.js
Normal file
1087
src/dialog/setting.js
Normal file
File diff suppressed because it is too large
Load Diff
274
src/dialog/shop.js
Normal file
274
src/dialog/shop.js
Normal file
@@ -0,0 +1,274 @@
|
||||
|
||||
|
||||
import Util from '../utils/util.js';
|
||||
export default {
|
||||
init: function () {
|
||||
Dialog.injectStyle(shop_css);
|
||||
},
|
||||
selected_item: 0,
|
||||
close: function () {
|
||||
this.element.remove();
|
||||
this.isShow = false;
|
||||
}, onData: function (data) {
|
||||
if (data.money) {
|
||||
let ms = data.money ?? [0, 0];
|
||||
this.money = ms[0];
|
||||
this.cash_money = ms[1];
|
||||
if (ms.length > 2) {
|
||||
this.footers = ["黄金", "元宝", '活动'];
|
||||
this.act_money = ms[2];
|
||||
this.act_name = data.mtype ?? "<hic>积分</hic>";
|
||||
}
|
||||
this.create_footer();
|
||||
}
|
||||
if (data.remove) {
|
||||
let item = this.get_item(data.remove);
|
||||
if (item) item.removed = true;
|
||||
return this.show_items();
|
||||
}
|
||||
if (data.item) {
|
||||
let [id, count] = data.item;
|
||||
let item = this.get_item(id);
|
||||
if (item) {
|
||||
item.count = count;
|
||||
this.show_items();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.idx) return;
|
||||
this.idx = data.idx;
|
||||
this.list0 = this.format_items(data.selllist[0], 0);
|
||||
this.list1 = this.format_items(data.selllist[1], 1);
|
||||
if (data.selllist.length > 2)
|
||||
this.list2 = this.format_items(data.selllist[2], 2);
|
||||
|
||||
this.show_items();
|
||||
},
|
||||
footerChanged: function (index) {
|
||||
|
||||
this.selected_item = parseInt(index);
|
||||
this.show_items();
|
||||
this.create_footer();
|
||||
}, footers: ["黄金", "元宝"],
|
||||
create_footer: function () {
|
||||
if (!this.isShow) return;
|
||||
var html = [];
|
||||
for (var i = 0; i < this.footers.length; i++) {
|
||||
html.push("<span class='footer-item" + (i == this.selected_item
|
||||
? " select" : "") + "' for='" + i + "''>"
|
||||
+ this.footers[i] + "</span>");
|
||||
}
|
||||
if (this.selected_item === 0) {
|
||||
html.push('<div class="obj-money">',
|
||||
this.money > 0 ? "你身上有" + Util.moneyToStr(this.money) : "你身上没有银两"
|
||||
, '</div>');
|
||||
} else if (this.selected_item === 1) {
|
||||
html.push('<div class="obj-money">',
|
||||
this.cash_money > 0 ? "你身上有" + this.cash_money
|
||||
+ "<hij>元宝</hij>" : "你身上没有元宝"
|
||||
, '<span cmd="transmoney">账号转入</span></div>');
|
||||
} else if (this.selected_item === 2) {
|
||||
html.push('<div class="obj-money">',
|
||||
"你身上有", this.act_money > 0 ? this.act_money : 0
|
||||
, this.act_name);
|
||||
}
|
||||
Dialog.footer(html.join(""));
|
||||
},
|
||||
format_items: function (ary, mtype) {
|
||||
let items = [];
|
||||
for (let data of ary) {
|
||||
if (!data) continue;
|
||||
let item = {
|
||||
id: data[0], name: data[1],
|
||||
desc: data[2], value: data[3], grade: data[4],
|
||||
discount: data[5]
|
||||
};
|
||||
if (data[6]) {
|
||||
item.limit = data[6];
|
||||
item.count = data[7];
|
||||
}
|
||||
if (item.discount < 1) {
|
||||
if (mtype === 0)
|
||||
item.price0 = "<del>" + item.value + "两黄金</del>";
|
||||
else if (mtype === 1)
|
||||
item.price0 = "<del>" + item.value + "元宝</del>";
|
||||
else if (mtype === 2)
|
||||
item.price0 = "<del>" + item.value + this.act_name + "</del>";
|
||||
item.value = item.value * item.discount;
|
||||
}
|
||||
if (mtype === 0) {
|
||||
if (item.value >= 1)
|
||||
item.price = "<hiy>" + item.value + "两黄金</hiy>";
|
||||
else
|
||||
item.price = "<wht>" + (item.value * 100) + "两白银</wht>";
|
||||
} else if (mtype === 1) {
|
||||
item.price = "<hij>" + item.value + "元宝</hij>";
|
||||
} else if (mtype === 2) {
|
||||
item.price = item.value + this.act_name;
|
||||
|
||||
}
|
||||
|
||||
items.push(item);
|
||||
}
|
||||
return items;
|
||||
}
|
||||
, show_items: function () {
|
||||
if (!this.isShow) return;
|
||||
this.create_items([this.list0, this.list1, this.list2][this.selected_item]);
|
||||
}, get_item: function (id) {
|
||||
|
||||
if (this.list0) for (let item of this.list0) if (item.id === id) return item;
|
||||
if (this.list1) for (let item of this.list1) if (item.id === id) return item;
|
||||
if (this.list2) for (let item of this.list2) if (item.id === id) return item;
|
||||
},
|
||||
show: function (data) {
|
||||
if (!this.element) {
|
||||
this.element = $("<div class='dialog-shop-content'><div class='dialog-shop'></div></div>");
|
||||
}
|
||||
Dialog.title("商品列表");
|
||||
Dialog.icon("shopping-cart");
|
||||
this.isShow = true;
|
||||
this.element.appendTo(Dialog.contentElement);
|
||||
if (!this.idx) SendCommand("shop");
|
||||
else SendCommand("shop " + this.idx);
|
||||
}, create_items: function (items) {
|
||||
let str = [];
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
let item = items[i];
|
||||
if (item.removed) {
|
||||
items.splice(i, 1);
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
str.push("<div class='shop-item");
|
||||
str.push(' grade', item.grade);
|
||||
str.push("'><div class='flex-1'><div class='shop-item-title'>");
|
||||
|
||||
str.push('<div class="shop-item-name">', item.name, '</div>');
|
||||
if (item.limit > 0)
|
||||
str.push("(", item.count, "/", item.limit, ")");
|
||||
|
||||
str.push("</div>");
|
||||
str.push("<pre class='shop-desc'>");
|
||||
str.push(item.desc)
|
||||
str.push("</pre></div>");
|
||||
str.push("<div class='shop-btn' ");
|
||||
str.push('cmd="_confirm shop ', item.id);
|
||||
if (item.limit > 0) {
|
||||
str.push(' ', item.limit - item.count);
|
||||
}
|
||||
str.push('">');
|
||||
if (item.price0) {
|
||||
str.push(' ', item.price0, ' ');
|
||||
}
|
||||
str.push(item.price);
|
||||
str.push("</div>");
|
||||
str.push("</div>");
|
||||
}
|
||||
this.element.find('.dialog-shop').html(str.join(""));
|
||||
}
|
||||
};
|
||||
|
||||
const shop_css = `
|
||||
|
||||
.dialog-shop-content {
|
||||
height: 25em;
|
||||
}
|
||||
|
||||
.dialog-shop {
|
||||
max-height: 32em;
|
||||
padding-bottom: 0.5em;
|
||||
margin-top: 0.5em;
|
||||
}
|
||||
|
||||
.dialog-shop>.shop-item {
|
||||
border-radius: 6px;
|
||||
background-color: #111111;
|
||||
border-left-width: 4px;
|
||||
border-left-style: solid;
|
||||
position: relative;
|
||||
margin-bottom: 0.5em;
|
||||
padding-left: 0.5em;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.shop-item-title {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
line-height: 2em;
|
||||
place-items: 1em;
|
||||
}
|
||||
|
||||
.shop-item-title>.shop-item-name {
|
||||
margin: 0px;
|
||||
color: var(--border-color);
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.shop-item-title>.discount-tag {
|
||||
|
||||
background: linear-gradient(135deg, #ff3e3e 0%, #ff9100 100%);
|
||||
color: white;
|
||||
width: 4em;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
border-radius: 0.5em;
|
||||
box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
|
||||
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
.dialog-shop>.shop-item .shop-desc {
|
||||
margin: 0;
|
||||
padding-top: 0.5em;
|
||||
padding-bottom: 0.5em;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.dialog-shop>.shop-item .shop-label {
|
||||
background: linear-gradient(110deg, transparent 0%, rgba(255, 159, 28, 0.8) 50%, transparent 100%);
|
||||
|
||||
animation: shine 3s infinite linear;
|
||||
color: #fff;
|
||||
font-size: 12px;
|
||||
padding: 2px 8px;
|
||||
border-radius: 4px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
|
||||
.dialog-shop>.shop-item>.shop-btn {
|
||||
width: 8em;
|
||||
display: inline-block;
|
||||
border-left: 1px solid var(--border-color);
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
background-color: transparent;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
background-color: #222;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.dialog-shop-footer {
|
||||
text-align: right;
|
||||
padding-right: 0.5em;
|
||||
}
|
||||
|
||||
.dialog-shop-footer>span {
|
||||
line-height: 1.8em;
|
||||
margin-left: 1em;
|
||||
color: #808000;
|
||||
display: inline-block;
|
||||
padding-right: 1em;
|
||||
text-align: center;
|
||||
text-decoration: underline;
|
||||
border-right: 1px solid #808000;
|
||||
}
|
||||
|
||||
`;
|
||||
534
src/dialog/skills.js
Normal file
534
src/dialog/skills.js
Normal file
@@ -0,0 +1,534 @@
|
||||
import Setting from '../setting.js';
|
||||
import Util from '../utils/util.js';
|
||||
import SCRIPT from '../script.js';
|
||||
|
||||
|
||||
export default {
|
||||
isShow: false,
|
||||
selectItem: ".dialog-skills",
|
||||
init: function () {
|
||||
if (!this.created)
|
||||
Dialog.injectStyle(skills_css);
|
||||
this.created = true;
|
||||
},
|
||||
hide: function () {
|
||||
if (this.skill_element) {
|
||||
this.skill_element.remove();
|
||||
this.skill_element = null;
|
||||
this.element.removeClass("hide-item");
|
||||
this.create_footer();
|
||||
this.skill_element_id = null;
|
||||
return false;
|
||||
}
|
||||
},
|
||||
close: function () {
|
||||
this.hide();
|
||||
this.element.remove();
|
||||
//Dialog.footerElement.addClass("hide");
|
||||
this.isShow = false;
|
||||
this.skill_element_id = null;
|
||||
this.element.removeClass("hide-item");
|
||||
},
|
||||
limit: 0,
|
||||
selected_item: -1,
|
||||
showdesc: function (data) {
|
||||
if (!this.isShow) return;
|
||||
this.element.find(".item-commands").remove();
|
||||
if (this.skill_element) this.skill_element.remove();
|
||||
this.skill_element = $("<pre></pre>").html(data.desc).appendTo(this.element);
|
||||
// Dialog.title(data.title);
|
||||
this.skill_element_id = data.id;
|
||||
this.element.addClass("hide-item");
|
||||
let html = ['<div class="item-commands">'];
|
||||
|
||||
if (this.master) {
|
||||
html.push('<span cmd="xue ', data.id, ' from ', this.master, '">学习</span>');
|
||||
if (this.is_follower) {
|
||||
html.push('<span cmd="dc ', this.master, ' lingwu ', data.id, '">进阶</span>');
|
||||
html.push('<span cmd="dc ', this.master, ' fangqi ', data.id, '">遗忘</span>');
|
||||
}
|
||||
|
||||
} else {
|
||||
if (data.is_custom)
|
||||
html.push('<span cmd="zc ', data.id, '">推演</span>');
|
||||
html.push('<span cmd="lingwu ', data.id, '">进阶</span>');
|
||||
html.push('<span cmd="lingwu2 ', data.id, '">融合</span>');
|
||||
html.push('<span cmd="fangqi ', data.id, '">遗忘</span>');
|
||||
}
|
||||
html.push('</div>');
|
||||
Dialog.footer(html.join(""));
|
||||
|
||||
},
|
||||
footerChanged: function (index, ref) {
|
||||
if (index == this.selected_item && !ref) return;
|
||||
this.selected_item = index;
|
||||
Dialog.skills.element.find(".item-commands").remove();
|
||||
if (index == 2) {
|
||||
if (!this.books) SendCommand('sbook');
|
||||
else this.showBooks();
|
||||
return this.element.addClass("dialog-books");
|
||||
}
|
||||
if (this.element.is('.dialog-books')) {
|
||||
this.element.removeClass('dialog-books');
|
||||
this.create_footer();
|
||||
return this.createSkillItems(this.items);
|
||||
}
|
||||
if (index == 0) {
|
||||
this.element.find('.base').removeClass('hide');
|
||||
this.element.find(".skill").addClass('hide');
|
||||
} else if (index == 1) {
|
||||
this.element.find('.base').addClass('hide');
|
||||
this.element.find(".skill").removeClass('hide');
|
||||
}
|
||||
},
|
||||
footers: ["基础", "特殊", "书架"],
|
||||
eq_group: 0,
|
||||
create_footer: function (isbook) {
|
||||
var footers = this.footers;
|
||||
var html = [];
|
||||
for (var i = 0; i < footers.length; i++) {
|
||||
html.push("<span class='footer-item" +
|
||||
(i == this.selected_item ? " select" : "") + "' for='" + i + "''>"
|
||||
+ footers[i] + "</span>");
|
||||
}
|
||||
// if (isbook)
|
||||
// html.push("<span class='obj-money'>你的书架目前有<HIC>" + this.books.length + "</HIC>本秘籍</span>");
|
||||
// else
|
||||
// html.push("<span class='obj-money'>你目前的技能上限为<HIC>" + this.limit + "</HIC>级</span>");
|
||||
if (!isbook) {
|
||||
for (let i = 0; i < 3; i++) {
|
||||
html.push('<span class="sk-group',
|
||||
2 - i === this.sk_group ? " select" : "",
|
||||
'" group="', 2 - i, '">', 3 - i, '</span>');
|
||||
}
|
||||
}
|
||||
Dialog.footer(html.join(""));
|
||||
},
|
||||
eq_group_click: function () {
|
||||
let group = parseInt($(this).attr('group'));
|
||||
if (group >= 0) SendCommand('skgroup ' + group);
|
||||
},
|
||||
updateSkill: function (data) {
|
||||
if (!this.skills) return;
|
||||
var item = this.skills[data.id];
|
||||
if (!item) {
|
||||
|
||||
return this.addSkill(item);
|
||||
}
|
||||
if (data.name)
|
||||
item.name = data.name;
|
||||
if (data.grade >= 0 && data.grade !== item.grade) {
|
||||
item.grade = data.grade;
|
||||
if (item.can_enables) {
|
||||
for (let sk of item.can_enables) {
|
||||
let base_skill = this.skills[sk];
|
||||
if (base_skill && base_skill.enable_skill === data.id) {
|
||||
this.updateSkillItem(base_skill);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (data.enable) {
|
||||
if (item.enable_skill) {
|
||||
var old_skill = item.enable_skill;
|
||||
item.enable_skill = null;
|
||||
this.skills[old_skill][data.id] = false;
|
||||
this.updateSkillItem(this.skills[old_skill]);
|
||||
}
|
||||
this.skills[data.enable][data.id] = true;
|
||||
item.enable_skill = data.enable;
|
||||
this.updateSkillItem(this.skills[data.enable]);
|
||||
this.updateSkillItem(this.skills[data.id]);
|
||||
} else if (data.exp != undefined || data.level != undefined) {
|
||||
if (data.level >= 0) item.level = data.level;
|
||||
if (data.exp >= 0) item.exp = data.exp;
|
||||
if (data.can_enables) item.can_enables = data.can_enables;
|
||||
this.updateSkillItem(item);
|
||||
}
|
||||
else if (data.enable == false) {
|
||||
if (item.enable_skill) {
|
||||
var old_skill = item.enable_skill;
|
||||
this.skills[old_skill][data.id] = false;
|
||||
item.enable_skill = null;
|
||||
this.updateSkillItem(this.skills[old_skill]);
|
||||
this.updateSkillItem(this.skills[data.id]);
|
||||
}
|
||||
}
|
||||
|
||||
}, updateSkillItem: function (item) {
|
||||
var sk_elem = this.element.find(".skill-item[skid='" + item.id + "']");
|
||||
if (sk_elem) {
|
||||
let hide = sk_elem.css('display') === 'none';
|
||||
sk_elem.replaceWith(this.createSkillItem(item));
|
||||
if (hide) sk_elem.hide();
|
||||
}
|
||||
},
|
||||
addSkill: function (item) {
|
||||
|
||||
if (!this.items || !item) return;
|
||||
if (this.skills[item.id]) {
|
||||
return this.updateSkill(item);
|
||||
}
|
||||
this.items.push(item);
|
||||
this.skills[item.id] = item;
|
||||
this.items = this.sort_items(this.items);
|
||||
this.createSkillItems(this.items);
|
||||
}, format_books: function (data) {
|
||||
let books = [];
|
||||
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
books.push({
|
||||
name: data[i][0],
|
||||
grade: data[i][1],
|
||||
id: i
|
||||
});
|
||||
}
|
||||
return books;
|
||||
},
|
||||
onData: function (data) {
|
||||
if (data.book) {
|
||||
if (!this.books) return;
|
||||
this.books.push({ name: data.book[0], grade: data.book[1], id: data.book[2] });
|
||||
if (this.isShow && this.selected_item == 2) {
|
||||
return this.showBooks();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (data.books) {
|
||||
this.books = this.format_books(data.books);
|
||||
if (this.isShow || !Dialog.master.isShow)
|
||||
return this.showBooks();
|
||||
else
|
||||
return Dialog.master.showBooks();
|
||||
}
|
||||
if (data.id && !data.desc) {
|
||||
if (data.from)
|
||||
return this.updateSkill.call(Dialog.master, data);
|
||||
return this.updateSkill(data);
|
||||
}
|
||||
if (data.item) {
|
||||
if (Dialog.master.isShow && Dialog.master.is_follower) {
|
||||
return this.addSkill.call(Dialog.master, data.item);
|
||||
}
|
||||
return this.addSkill(data.item);
|
||||
}
|
||||
if (!this.isShow) {
|
||||
if (Dialog.master.isShow)
|
||||
return Dialog.master.onData(data);
|
||||
}
|
||||
|
||||
if (data.desc) {
|
||||
if (data.id) this.updateSkill(data);
|
||||
return this.showdesc(data);
|
||||
}
|
||||
|
||||
|
||||
if (data.remove && this.items) {
|
||||
if (data.from && data.from !== Process.player) return;
|
||||
this.items.Remove(this.skills[data.remove]);
|
||||
|
||||
for (var i = 0; i < this.items.length; i++) {
|
||||
if (this.items[i].enable_skill == data.remove) {
|
||||
this.items[i].enable_skill = null;
|
||||
}
|
||||
}
|
||||
delete this.skills[data.remove];
|
||||
if (this.skill_element && this.skill_element_id === data.remove) {
|
||||
this.hide();
|
||||
}
|
||||
return this.createSkillItems(this.items);
|
||||
}
|
||||
if (data.items) {
|
||||
this.title = data.title;
|
||||
Dialog.title(this.title + ",等级上限" + data.limit + "级");
|
||||
Dialog.icon("book");
|
||||
this.items = this.sort_items(data.items);
|
||||
this.skills = {};
|
||||
for (var i = 0; i < this.items.length; i++) {
|
||||
var item = this.items[i];
|
||||
this.skills[item.id] = item;
|
||||
}
|
||||
if (this.items.length > 10 && this.selected_item < 0) {
|
||||
this.footerChanged(0);
|
||||
}
|
||||
this.createSkillItems(this.items);
|
||||
}
|
||||
if (data.sk_group >= 0) {
|
||||
this.sk_group = data.sk_group;
|
||||
this.limit = data.limit;
|
||||
this.create_footer();
|
||||
}
|
||||
if (data.limit >= 0) {
|
||||
this.limit = data.limit;
|
||||
Dialog.title(this.title + ",等级上限" + this.limit + "级");
|
||||
}
|
||||
},
|
||||
show: function () {
|
||||
if (this.isShow) return;
|
||||
this.isShow = true;
|
||||
if (!this.element) {
|
||||
// this.container = $('<div class="skill-container"><div class="skill-sider"><div class="skill-sider-item select">1</div><div class="skill-sider-item">2</div><div class="skill-sider-item">3</div></div></div>');
|
||||
this.element = $('<div class="dialog-skills"></div>');
|
||||
Dialog.footerElement
|
||||
.on("click", ".sk-group", Dialog.skills.eq_group_click);
|
||||
}
|
||||
this.element.on("click", ".skill-item", Dialog.skills.item_click);
|
||||
//Dialog.footerElement.remveClass("hide");
|
||||
this.element.appendTo(Dialog.contentElement);
|
||||
//this.container.appendTo(Dialog.contentElement);
|
||||
this.element.removeClass("hide-item");
|
||||
if (!this.items) SendCommand("cha");
|
||||
else {
|
||||
SendCommand("cha none");
|
||||
Dialog.icon("book");
|
||||
this.create_footer();
|
||||
}
|
||||
},
|
||||
isEnable: function (item, skills) {
|
||||
if (!item.can_enables) return false;
|
||||
for (var i = 0; i < item.can_enables.length; i++) {
|
||||
var base_skill = skills[item.can_enables[i]];
|
||||
if (base_skill && base_skill.enable_skill == item.id) return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
showBooks: function () {
|
||||
var html = [];
|
||||
var books = this.sort_items(this.books);
|
||||
for (let item of books) {
|
||||
html.push('<div class="book-item ');
|
||||
html.push('grade', item.grade, '" >');
|
||||
html.push('<div class="book-name">', item.name, '</div>');
|
||||
html.push('<div class="book-action border-right" cmd="sbook ', item.id, '">查看</div>');
|
||||
html.push('<div class="book-action" cmd="study ', item.id, '">学习</div>');
|
||||
html.push('</div>');
|
||||
}
|
||||
this.element.html(html.join(""));
|
||||
this.create_footer(true);
|
||||
},
|
||||
createSkillItem: function (item, skills) {
|
||||
skills = skills || this.skills;
|
||||
var html = [];
|
||||
html.push('<div class="skill-item ');
|
||||
html.push('grade' + item.grade);
|
||||
if (!this.master) {
|
||||
if (item.can_enables) {
|
||||
html.push(' skill');
|
||||
if (this.selected_item == 0) html.push(' hide');
|
||||
} else {
|
||||
html.push(' base');
|
||||
if (this.selected_item == 1) html.push(' hide');
|
||||
}
|
||||
}
|
||||
|
||||
var is_enable = this.isEnable(item, skills);
|
||||
if (is_enable) {
|
||||
html.push(' enable');
|
||||
}
|
||||
html.push('" skid="' + item.id + '">');
|
||||
|
||||
html.push('<span class="glyphicon glyphicon-ok enable-flag"></span>');
|
||||
html.push(item.name);
|
||||
// html.push('</', lvcolor, '>');
|
||||
if (item.enable_skill && skills) {
|
||||
var sp_skill = skills[item.enable_skill];
|
||||
if (sp_skill) {
|
||||
html.push('<span class="enable_skill">已装备:');
|
||||
html.push(wrap_name(sp_skill));
|
||||
html.push("</span>");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
html.push('<span class="skill-level">');
|
||||
// var lv_desc = this.get_lvdesc(item.level);
|
||||
//push(lv_desc.replace(">", ">" + item.level + '级 / ' + item.exp + "%" + ' '));
|
||||
html.push(item.level);
|
||||
html.push('级 / ');
|
||||
html.push(item.exp);
|
||||
html.push("%");
|
||||
html.push(' ');
|
||||
html.push(Dialog.skills.get_lvdesc(item.level));
|
||||
html.push('</span></div>');
|
||||
return html.join("");
|
||||
},
|
||||
sort_items: function (items) {
|
||||
if (!items || !Setting.auto_sortitem) return items;
|
||||
var list = [];
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
var item = items[i];
|
||||
var isok = false;
|
||||
for (var j = 0; j < list.length; j++) {
|
||||
if (item.grade > list[j].grade) {
|
||||
list.splice(j, 0, item);
|
||||
isok = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isok) {
|
||||
list.push(item);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
},
|
||||
createSkillItems: function (items, skills) {
|
||||
let html = [];
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
html.push(this.createSkillItem(items[i], skills));
|
||||
}
|
||||
this.element.html(html.join(""));
|
||||
|
||||
}, level_color: ["wht", "hig", "hic", "hij", "hiz", "hio", "ord"]
|
||||
, get_lvdesc: function (level) {
|
||||
if (level < 1000)
|
||||
return Dialog.skills.skill_levels[parseInt(level / 50)];
|
||||
var v = parseInt((level - 1000) / 500);
|
||||
if (v > 6) v = 6;
|
||||
return Dialog.skills.skill_levels[v + 20];
|
||||
},
|
||||
skill_levels: [
|
||||
"<BLU>初学乍练</BLU>", "<BLU>不知所以</BLU>", "<HIB>粗通皮毛</HIB>", "<HIB>渐有所悟</HIB>",
|
||||
"<YEL>半生不熟</YEL>", "<YEL>马马虎虎</YEL>", "<HIY>平淡无奇</HIY>", "<HIY>触类旁通</HIY>",
|
||||
"<HIG>心领神会</HIG>", "<HIG>挥洒自如</HIG>", "<HIC>驾轻就熟</HIC>", "<HIC>出类拔萃</HIC>",
|
||||
"<CYN>初入佳境</CYN>", "<CYN>神乎其技</CYN>", "<MAG>威不可当</MAG>",
|
||||
"<HIW>豁然贯通</HIW>", "<HIW>超群绝伦</HIW>", "<RED>登峰造极</RED>", "<WHT>登堂入室</WHT>",
|
||||
"<HIM>一代宗师</HIM>", "<WHT>超凡入圣</WHT>", "<HIO>出神入化</HIO>", "<HIO>独步天下</HIO>",
|
||||
"<HIR>空前绝后</HIR>", "<HIR>旷古绝伦</HIR>", "<HIW>深不可测</HIW>", "<HIW>返璞归真</HIW>"]
|
||||
,
|
||||
item_click: function () {
|
||||
var elem = $(this);
|
||||
var html = ["<div class='item-commands'>"];
|
||||
var item = Dialog.skills.skills[elem.attr("skid")];
|
||||
if (!item) return;
|
||||
html.push('<span cmd="checkskill ' + item.id + '">查看详细</span>');
|
||||
if (item.can_enables) {
|
||||
for (var i = 0; i < item.can_enables.length; i++) {
|
||||
var baseSkill = Dialog.skills.skills[item.can_enables[i]];
|
||||
if (!baseSkill) continue;
|
||||
if (baseSkill.enable_skill != item.id)
|
||||
html.push('<span cmd="enable ' + baseSkill.id + ' ' + item.id + '">装备' + baseSkill.name + '</span>');
|
||||
else {
|
||||
html.push('<span cmd="enable ' + baseSkill.id + ' none">取消装备' + baseSkill.name + '</span>');
|
||||
}
|
||||
}
|
||||
}
|
||||
if (item.enable_skill) {
|
||||
var sp_skill = Dialog.skills.skills[item.enable_skill];
|
||||
if (sp_skill) html.push('<span cmd="enable ' + item.id + ' none">取消装备' + sp_skill.name + '</span>');
|
||||
else item.enable_skill = null;
|
||||
}
|
||||
html.push('<span cmd="_confirm fangqi ' + item.id + '">遗忘</span>');
|
||||
html.push('<span cmd="lianxi ' + item.id + '">练习</span>');
|
||||
SCRIPT.LAST_OBJ = item;
|
||||
let commands = Dialog.extend.query('skill', item);
|
||||
for (let item of commands) {
|
||||
html.push('<span cmd="', item.cmd, '">', item.name, '</span>');
|
||||
}
|
||||
html.push("</div>");
|
||||
Dialog.skills.element.find(".item-commands").remove();
|
||||
$(html.join("")).insertAfter(elem);
|
||||
Util.checkScroll(elem.next());
|
||||
}
|
||||
};
|
||||
const level_desc = ["wht", "hig", "hic", "hiy", "him", "hio", 'ord'];
|
||||
function wrap_name(obj) {
|
||||
let tag = level_desc[obj.grade];
|
||||
return `<${tag}>${obj.name}</${tag}>`;
|
||||
}
|
||||
const skills_css = `
|
||||
.dialog-skills {
|
||||
overflow-y: auto;
|
||||
min-height: 15em;
|
||||
max-height: 35em;
|
||||
}
|
||||
|
||||
.hide-item {}
|
||||
|
||||
.dialog-skills>pre {
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.dialog-skills>.skill-item {
|
||||
line-height: 2em;
|
||||
padding-left: 1.5em;
|
||||
border-radius: 4px;
|
||||
border-left-width: 2px;
|
||||
border-left-style: solid;
|
||||
white-space: nowrap;
|
||||
overflow-x: auto;
|
||||
margin-bottom: 0.5em;
|
||||
background-color: #111;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
|
||||
.hide-item>.skill-item {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.dialog-skills>.dialog-books>.skill-item {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.dialog-skills>.skill-item>.skill-level {
|
||||
float: right;
|
||||
margin-right: 0.625em;
|
||||
}
|
||||
|
||||
.dialog-skills>.skill-item>.enable-flag {
|
||||
display: none;
|
||||
color: var(--border-color);
|
||||
line-height: 2em;
|
||||
}
|
||||
|
||||
.dialog-skills>.enable {
|
||||
padding-left: 0px;
|
||||
}
|
||||
|
||||
.dialog-skills>.enable>.enable-flag {
|
||||
display: inline-block;
|
||||
padding-left: 0.25em;
|
||||
padding-right: 0.25em;
|
||||
}
|
||||
|
||||
.dialog-skills>.skill-item>.enable_skill {
|
||||
margin-left: 0.5em;
|
||||
}
|
||||
|
||||
.dialog-skills>.enable>.item-commands {
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
.dialog-skills>.book-item {
|
||||
line-height: 2em;
|
||||
padding-left: 1.5em;
|
||||
border-radius: 4px;
|
||||
border-left-width: 2px;
|
||||
border-left-style: solid;
|
||||
white-space: nowrap;
|
||||
overflow-x: auto;
|
||||
margin-bottom: 0.5em;
|
||||
background-color: #111;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.dialog-skills>.book-item>.book-name {
|
||||
flex: 1;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
color: var(--border-color);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.dialog-skills>.book-item>.book-action {
|
||||
flex: 0;
|
||||
background-color: #222;
|
||||
padding-left: 1em;
|
||||
padding-right: 1em;
|
||||
}
|
||||
|
||||
`;
|
||||
354
src/dialog/stats.js
Normal file
354
src/dialog/stats.js
Normal file
@@ -0,0 +1,354 @@
|
||||
|
||||
|
||||
const STATS_SILDER1 = [["总榜", ''], ["武当派", 'wudang'], ["少林派", 'shaolin'], ["华山派", 'huashan'],
|
||||
["峨眉派", 'emei'], ["逍遥派", 'xiaoyao'], ["丐帮", 'gaibang'], ["杀手楼", 'shashou'],
|
||||
["无门无派", 'none']];
|
||||
const STATS_SILDER2 = [
|
||||
["武器", ""], ["衣服", "cloth"], ["鞋", "shoes"], ["头部", "head"],
|
||||
["披风", "cape"], ["戒指", "ring"], ["项链", "necklace"], ["饰品", "jewels"],
|
||||
["护腕", "wrist"], ["腰带", "waist"], ["暗器", "throwing"]
|
||||
];
|
||||
export default {
|
||||
footers: [{ cmd: "score", name: "综合榜", selected_silder: "", silder: STATS_SILDER1 },
|
||||
{ cmd: "top", name: "高手榜", selected_silder: "", silder: STATS_SILDER1 },
|
||||
{ cmd: "weapon", name: "兵器谱", selected_silder: "", silder: STATS_SILDER2 },
|
||||
{ cmd: "exp", name: "经验榜", selected_silder: "", silder: STATS_SILDER1 },
|
||||
{ cmd: "mp", name: "内力榜", selected_silder: "", silder: STATS_SILDER1 },
|
||||
{ cmd: "money", name: "富豪榜", selected_silder: "", silder: STATS_SILDER1 }
|
||||
],
|
||||
selectedItem: 0,
|
||||
init: function () {
|
||||
Dialog.injectStyle(stats_css);
|
||||
},
|
||||
close: function () {
|
||||
this.element.remove();
|
||||
this.isShow = false;
|
||||
}, onData: function (data) {
|
||||
if (data.close) return Dialog.hide();
|
||||
if (data.tops) {
|
||||
if (data.top) {
|
||||
this.show_desc("你目前在第" + data.top + "名,积分" + data.sc);
|
||||
} else {
|
||||
this.show_desc("你目前没有上榜,积分:" + data.sc);
|
||||
}
|
||||
|
||||
return this.create_tops(data.tops, data);
|
||||
}
|
||||
if (data.weapons) {
|
||||
this.show_desc("");
|
||||
return this.create_weapons(data.weapons);
|
||||
}
|
||||
if (data.scores) {
|
||||
this.show_desc("你目前的评分:" + data.score);
|
||||
return this.create_scores(data.scores);
|
||||
}
|
||||
if (data.items) {
|
||||
this.create_other(data.items, data.st);
|
||||
let dt = new Date(data.time);
|
||||
data.fam = data.fam ?? "";
|
||||
this["last_" + data.st + data.fam] = {
|
||||
items: data.items,
|
||||
time: data.time + 60000,
|
||||
score: data.score
|
||||
};
|
||||
if (data.score)
|
||||
this.show_desc("你目前的评分:" + data.score);
|
||||
else
|
||||
this.show_desc("上次更新:" + dt.getHours() + ":" + dt.getMinutes());
|
||||
}
|
||||
|
||||
}, create_other: function (items, type) {
|
||||
var html = [];
|
||||
for (var i = 0; i < 20; i++) {
|
||||
html.push("<div class='top-item");
|
||||
if (i < 3) html.push(' top', i + 1);
|
||||
html.push("' top='");
|
||||
html.push(i + 1);
|
||||
html.push("'><span class='top-title'>");
|
||||
html.push(this.top_names[i]);
|
||||
html.push("、</span>");
|
||||
html.push("<span class='top-name'>");
|
||||
let role = items[i] ?? ["无", 0];
|
||||
html.push(role[0]);
|
||||
html.push("</span>");
|
||||
html.push("<span class='top-sc'>");
|
||||
html.push(role[1]);
|
||||
html.push("</span>");
|
||||
html.push("</div>")
|
||||
}
|
||||
this.container.html(html.join(""));
|
||||
},
|
||||
silderClick: function () {
|
||||
let elem = $(this);
|
||||
let type = elem.attr("stype");
|
||||
let item = Dialog.stats.selectedItem;
|
||||
if (item.selected_silder === type) return;
|
||||
item.selected_silder = type;
|
||||
elem.parent().find('.select').removeClass('select');
|
||||
elem.addClass('select');
|
||||
Dialog.stats.load_stats();
|
||||
},
|
||||
create_silder: function (items) {
|
||||
let str = [];
|
||||
items = items || [];
|
||||
let tab = this.selectedItem;
|
||||
for (let item of items) {
|
||||
str.push('<div class="stats-silder ',
|
||||
(tab.selected_silder === item[1] ? "select" : ""),
|
||||
'" stype="', item[1], '">', item[0], "</div>");
|
||||
}
|
||||
this.left_silder.html(str.join(""));
|
||||
},
|
||||
top_names: ["一 ", "二 ", "三 ", "四 ", "五 ",
|
||||
"六 ", "七 ", "八 ", "九 ", "十 ",
|
||||
"十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十"],
|
||||
create_scores: function (items, data) {
|
||||
var html = [];
|
||||
for (var i = 0; i < 20; i++) {
|
||||
html.push("<div class='top-item scores");
|
||||
if (i < 3) html.push(' top', i + 1);
|
||||
html.push("' top='");
|
||||
html.push(i + 1);
|
||||
html.push("'><span class='top-title'>");
|
||||
html.push(this.top_names[i]);
|
||||
html.push("、</span>");
|
||||
html.push("<span class='top-name'>");
|
||||
let role = items[i] ?? ["无", ""];
|
||||
html.push(role[0]);
|
||||
html.push("</span>");
|
||||
html.push("<span class='top-sc'>");
|
||||
html.push(role[1]);
|
||||
html.push("</span>");
|
||||
html.push("</div>")
|
||||
}
|
||||
this.container.html(html.join(""));
|
||||
|
||||
},
|
||||
fam_names: {
|
||||
emei: "峨眉第", wudang: "武当第", huashan: "华山第",
|
||||
xiaoyao: "逍遥第", gaibang: "丐帮第", shaolin: "少林第", shashou: "杀手第",
|
||||
none: "散修第"
|
||||
},
|
||||
create_tops: function (items, data) {
|
||||
var html = [];
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
html.push("<div class='top-item top ");
|
||||
if (i < 3) html.push(' top', i + 1);
|
||||
html.push("' top='");
|
||||
html.push(i + 1);
|
||||
html.push("'><span class='top-title'>");
|
||||
html.push(data.fam ? this.fam_names[data.fam] : "天下第");
|
||||
html.push(this.top_names[i]);
|
||||
html.push("</span>");
|
||||
html.push("<span class='top-name'>");
|
||||
html.push(items[i][0]);
|
||||
html.push("</span>");
|
||||
html.push("<span class='top-sc'>");
|
||||
html.push(items[i][1]);
|
||||
html.push("</span>");
|
||||
html.push("</div>")
|
||||
}
|
||||
this.container.html(html.join(""));
|
||||
this.top = data.top;
|
||||
}, create_weapons: function (items) {
|
||||
var html = [];
|
||||
for (var i = 0; i < 10; i++) {
|
||||
html.push("<div class='top-item weapon top")
|
||||
html.push(i + 1);
|
||||
html.push("' top='");
|
||||
html.push(i + 1);
|
||||
html.push("'><span class='top-title'>");
|
||||
let role = items[i] ?? ["无", ""];
|
||||
html.push(this.top_names[i]);
|
||||
html.push("、</span>");
|
||||
html.push("<span class='top-name'>");
|
||||
html.push(role[0]);
|
||||
html.push("</span>");
|
||||
html.push("<span class='top-sc'>");
|
||||
html.push(role[1]);
|
||||
html.push("</span>");
|
||||
html.push("</div>")
|
||||
}
|
||||
this.container.html(html.join(""));
|
||||
},
|
||||
show: function () {
|
||||
if (!this.selectedItem) this.selectedItem = this.footers[0];
|
||||
this.load_stats();
|
||||
if (!this.element) {
|
||||
|
||||
this.element = $("<div class='stats-container'><div class='stats-container-left'></div></div>");
|
||||
|
||||
this.container = $("<div class='dialog-stats'></div>").appendTo(this.element);
|
||||
this.left_silder = this.element.find('.stats-container-left');
|
||||
this.create_silder(this.selectedItem.silder);
|
||||
}
|
||||
if (this.isShow) return;
|
||||
this.create_footer();
|
||||
Dialog.icon("stats");
|
||||
Dialog.title(this.selectedItem.name);
|
||||
|
||||
Dialog.contentElement.html(this.element);
|
||||
this.element.on("click", ".top-item", this.itemClick);
|
||||
this.left_silder.on("click", ".stats-silder ", this.silderClick);
|
||||
this.isShow = true;
|
||||
}, load_stats: function () {
|
||||
let type = this.selectedItem.cmd;
|
||||
let fam = this.selectedItem.selected_silder;
|
||||
//if (this.ban_silder[fam]) fam = "";
|
||||
let data = this["last_" + type + fam];
|
||||
if (data && data.time > Date.now()) {
|
||||
let dt = new Date(data.time);
|
||||
let str = "";
|
||||
if (data.score) str = "你目前的评分:" + data.score;
|
||||
else str = "上次更新:" + dt.getHours() + ":" + dt.getMinutes();
|
||||
this.show_desc(str);
|
||||
return this.create_other(data.items, type);
|
||||
}
|
||||
let str = "stats " + type;
|
||||
if (fam) str = str + " " + fam;
|
||||
SendCommand(str);
|
||||
}, create_footer: function () {
|
||||
var html = [];
|
||||
for (var i = 0; i < this.footers.length; i++) {
|
||||
var foot = this.footers[i];
|
||||
html.push("<span class='footer-item" + (foot == this.selectedItem ? " select" : "") + "' for='" + i + "''>"
|
||||
+ foot.name + "</span>");
|
||||
}
|
||||
html.push("<span class='stats-span'></span>");
|
||||
Dialog.footer(html.join(""));
|
||||
}, show_desc: function (msg) {
|
||||
Dialog.footerElement.find(".stats-span").html(msg);
|
||||
},
|
||||
footerChanged: function (index) {
|
||||
var item = this.footers[index];
|
||||
if (item == this.selectedItem) return;
|
||||
this.selectedItem = item;
|
||||
Dialog.title(this.selectedItem.name);
|
||||
this.create_silder(this.selectedItem.silder);
|
||||
this.load_stats();
|
||||
|
||||
|
||||
},
|
||||
itemClick: function () {
|
||||
var elem = $(this);
|
||||
var index = parseInt(elem.attr("top"));
|
||||
var type = Dialog.stats.selectedItem.cmd;
|
||||
|
||||
var html = ["<div class='item-commands'>"];
|
||||
var stype = Dialog.stats.selectedItem.selected_silder;
|
||||
if (type === 'top') {
|
||||
html.push('<span cmd="stats ' + type + ' ' + stype + " " + index + '">查看</span>');
|
||||
if (!Dialog.stats.top || index < Dialog.stats.top) {
|
||||
html.push('<span cmd="biwu ' + stype + " " + index + '">挑战</span>');
|
||||
}
|
||||
html.push('<span cmd="reward top ' + index + '">查看规则和奖励</span>');
|
||||
} else {
|
||||
html.push('<span cmd="stats ' + type + ' ' + stype + " " + index + '">查看</span>');
|
||||
html.push('<span cmd="reward ' + type + " " + index + '">查看奖励</span>');
|
||||
}
|
||||
html.push("</div>");
|
||||
Dialog.stats.element.find(".item-commands").remove();
|
||||
$(html.join("")).insertAfter(elem);
|
||||
}
|
||||
};
|
||||
|
||||
const stats_css = `
|
||||
|
||||
.stats-container {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
height: 25em;
|
||||
margin-top: 0.5em;
|
||||
}
|
||||
|
||||
.stats-container>.stats-container-left {
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.stats-container-left>.stats-silder {
|
||||
white-space: nowrap;
|
||||
line-height: 2em;
|
||||
width: 5em;
|
||||
text-align: center;
|
||||
background-color: #111;
|
||||
border-radius: 4px;
|
||||
margin-bottom: 0.5em;
|
||||
margin-right: 0.5em;
|
||||
margin-left: 0.5em;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.stats-container-left>.select {
|
||||
background-color: #222;
|
||||
color: #00ff00;
|
||||
border-left-width: 2px;
|
||||
border-left-style: solid;
|
||||
border-left-color: #00ff00;
|
||||
}
|
||||
|
||||
.dialog-stats {
|
||||
flex: 1;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.dialog-stats>.top-item {
|
||||
white-space: nowrap;
|
||||
line-height: 2em;
|
||||
padding-left: .5em;
|
||||
border-radius: 4px;
|
||||
white-space: nowrap;
|
||||
overflow-x: auto;
|
||||
margin-bottom: 0.5em;
|
||||
background-color: #111;
|
||||
cursor: pointer;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.dialog-stats>.top-item>.top-title {
|
||||
display: inline-block;
|
||||
font-weight: bold;
|
||||
height: 1.875em;
|
||||
line-height: 1.875em;
|
||||
padding-left: 1em;
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
.dialog-stats>.top-item>.top-sc {
|
||||
float: right;
|
||||
margin-right: 1em;
|
||||
line-height: 1.875em;
|
||||
font-weight: bold;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.dialog-stats>.top1>.top-sc {
|
||||
color: #FFA500;
|
||||
}
|
||||
|
||||
.dialog-stats>.top2>.top-sc {
|
||||
color: #912CEE;
|
||||
}
|
||||
|
||||
.dialog-stats>.top3>.top-sc {
|
||||
color: #FFD700;
|
||||
}
|
||||
|
||||
.dialog-stats>.top-item>.top-name {
|
||||
height: 1.875em;
|
||||
line-height: 1.875em;
|
||||
}
|
||||
|
||||
.dialog-stats>.top-item>.item-commands {
|
||||
padding-left: 3.125em;
|
||||
}
|
||||
|
||||
.stats-span {
|
||||
float: right;
|
||||
padding-right: 10px;
|
||||
color: #C0C0C0;
|
||||
line-height: 2.5em;
|
||||
}
|
||||
`;
|
||||
169
src/dialog/tasks.js
Normal file
169
src/dialog/tasks.js
Normal file
@@ -0,0 +1,169 @@
|
||||
|
||||
|
||||
const task_css = `
|
||||
|
||||
.dialog-tasks {
|
||||
max-height: 32em;
|
||||
margin-bottom: 0.5em;
|
||||
margin-top: 0.5em;
|
||||
}
|
||||
|
||||
.dialog-tasks>.task-item {
|
||||
border-radius: 6px;
|
||||
background-color: #111111;
|
||||
border-left-width: 4px;
|
||||
border-left-style: solid;
|
||||
position: relative;
|
||||
margin-top: 0.5em;
|
||||
padding-left: 0.5em;
|
||||
}
|
||||
|
||||
.dialog-tasks>.none {
|
||||
border-left-color: #808080
|
||||
}
|
||||
|
||||
|
||||
|
||||
.dialog-tasks>.finish {
|
||||
border-left-color: #00ff00
|
||||
}
|
||||
|
||||
.dialog-tasks>.over {
|
||||
border-left-color: #008080
|
||||
}
|
||||
|
||||
.dialog-tasks>.none>.task-btn {
|
||||
border-left-color: #808080;
|
||||
color: #808080;
|
||||
}
|
||||
|
||||
.dialog-tasks>.finish>.task-btn {
|
||||
border-left-color: #00ff00;
|
||||
color: #00ff00;
|
||||
background-color: #00ff0033;
|
||||
}
|
||||
|
||||
.dialog-tasks>.over>.task-btn {
|
||||
border-left-color: #008080;
|
||||
color: #008080;
|
||||
}
|
||||
|
||||
.task-item h3 {
|
||||
margin: 0px;
|
||||
padding-top: 0.5em;
|
||||
}
|
||||
|
||||
.task-item .task-desc {
|
||||
|
||||
margin: 0;
|
||||
padding-top: 0.5em;
|
||||
padding-bottom: 0.5em;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.task-item>.task-btn {
|
||||
width: 4.5em;
|
||||
display: inline-block;
|
||||
border-left: 1px solid #343434;
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
background-color: transparent;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.task-item>.task-btn:hover {
|
||||
background-color: #222;
|
||||
}
|
||||
|
||||
.dialog-tasks>.task-item>.start {
|
||||
color: gray;
|
||||
}
|
||||
|
||||
.dialog-tasks>.task-item>.finish {
|
||||
color: #00ff00;
|
||||
}
|
||||
|
||||
.dialog-tasks>.task-item>.over {
|
||||
color: #ebebeb;
|
||||
}
|
||||
`;
|
||||
|
||||
export default {
|
||||
init: function () {
|
||||
|
||||
Dialog.injectStyle(task_css);
|
||||
},
|
||||
close: function () {
|
||||
this.element.remove();
|
||||
this.isShow = false;
|
||||
}, update_item: function (data) {
|
||||
for (var i = 0; i < this.items.length; i++) {
|
||||
if (this.items[i].id == data.id) {
|
||||
if (data.state) {
|
||||
this.items[i].title = data.title;
|
||||
this.items[i].state = data.state;
|
||||
this.items[i].desc = data.desc;
|
||||
} else {
|
||||
this.items.splice(i, 1);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.create_items();
|
||||
}, onData: function (data) {
|
||||
|
||||
if (data.id) return this.update_item(data);
|
||||
Dialog.title("任务列表");
|
||||
Dialog.icon("exclamation-sign");
|
||||
this.items = data.items;
|
||||
this.create_items();
|
||||
},
|
||||
show: function () {
|
||||
if (!this.element)
|
||||
this.element = $("<div class='dialog-tasks'></div>");
|
||||
SendCommand("tasks");
|
||||
if (this.isShow) return;
|
||||
this.element.appendTo(Dialog.contentElement);
|
||||
|
||||
this.isShow = true;
|
||||
},
|
||||
status_css: ['', 'none', 'finish', 'over'],
|
||||
create_items: function () {
|
||||
var str = [];
|
||||
var has_fin = false;
|
||||
for (var i = 0; i < this.items.length; i++) {
|
||||
var item = this.items[i];
|
||||
str.push("<div class='task-item flex-row ");
|
||||
str.push(this.status_css[item.state]);
|
||||
str.push("'><div class='flex-1'><h3>");
|
||||
str.push(item.title)
|
||||
str.push("</h3>");
|
||||
str.push("<pre class='task-desc'>");
|
||||
str.push(item.desc);
|
||||
|
||||
//str.push('<span class="glyphicon glyphicon-info-sign"></span>');
|
||||
str.push("</pre></div>");
|
||||
str.push("<span class='task-btn flex-0'");
|
||||
if (item.state == 1) {
|
||||
str.push(">进行中");
|
||||
} else if (item.state == 2) {
|
||||
str.push(" cmd=\"task ");
|
||||
str.push(item.id);
|
||||
str.push(' fin"');
|
||||
has_fin = true;
|
||||
str.push(">可领取");
|
||||
} else if (item.state == 3) {
|
||||
str.push(">已完成");
|
||||
}
|
||||
str.push("</span>");
|
||||
str.push("</div>");
|
||||
}
|
||||
this.element.html(str.join(""));
|
||||
|
||||
Dialog.footer("");
|
||||
}
|
||||
};
|
||||
75
src/dialog/team.js
Normal file
75
src/dialog/team.js
Normal file
@@ -0,0 +1,75 @@
|
||||
|
||||
|
||||
export default {
|
||||
init: function () { },
|
||||
createElement: function () {
|
||||
return $('<div class="dialog-team"></div>');
|
||||
},
|
||||
inner_show: function () {
|
||||
SendCommand("team");
|
||||
this.isShow = true;
|
||||
Dialog.title("队伍");
|
||||
this.element.on("click", ".team-item", this.clickItem);
|
||||
Dialog.icon("list");
|
||||
},
|
||||
items: [],
|
||||
onData: function (data) {
|
||||
if (data.items) {
|
||||
this.items = data.items;
|
||||
if (data.items.length) this.isCap = data.items[0].id == Process.player;
|
||||
else this.isCap = 0;
|
||||
}
|
||||
if (data.dismiss) {
|
||||
this.items.length = 0;
|
||||
this.isCap = false;
|
||||
}
|
||||
if (data.remove) {
|
||||
if (!this.items.length) return;
|
||||
for (var i = 0; i < this.items.length; i++) {
|
||||
if (this.items[i].id == data.remove) {
|
||||
this.items.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.createItems();
|
||||
},
|
||||
inner_close: function () {
|
||||
this.element.remove();
|
||||
this.isShow = false;
|
||||
}, createItems: function () {
|
||||
if (!this.element) return;
|
||||
var str = [];
|
||||
for (var i = 0; i < this.items.length; i++) {
|
||||
var msg = this.items[i];
|
||||
str.push("<div class='team-item' index='" + i + "'>");
|
||||
str.push("<span class='team-flag'>");
|
||||
str.push(i > 0 ? "" : "<span class='glyphicon glyphicon-flag'></span>");
|
||||
str.push("</span>");
|
||||
str.push("<span class='team-title'>");
|
||||
str.push(msg.name);
|
||||
str.push("</span>");
|
||||
str.push("</div>");
|
||||
}
|
||||
if (!str.length) str.push('<div class="empty">你还没有加入任何队伍。</div>');
|
||||
this.element.html(str.join(""));
|
||||
}, clickItem: function () {
|
||||
var elem = $(this);
|
||||
var item = Dialog.team.items[elem.attr("index")];
|
||||
if (!item) return;
|
||||
var html = ["<div class='item-commands'>"];
|
||||
html.push('<span cmd="look3 ' + item.id + '">查看</span>');
|
||||
var isCap = Dialog.team.items[0].id == Process.player;
|
||||
if (isCap && item.id != Process.player) {
|
||||
html.push('<span cmd="team remove ' + item.id + '">移出队伍</span>');
|
||||
} else if (item.id == Process.player) {
|
||||
html.push('<span cmd="team out ' + item.id + '">退出队伍</span>');
|
||||
}
|
||||
if (isCap && item.id == Process.player) {
|
||||
html.push('<span cmd="team set">更改分配方式</span>');
|
||||
}
|
||||
html.push("</div>");
|
||||
Dialog.team.element.find(".item-commands").remove();
|
||||
$(html.join("")).appendTo(elem);
|
||||
}
|
||||
};
|
||||
148
src/dialog/trade.js
Normal file
148
src/dialog/trade.js
Normal file
@@ -0,0 +1,148 @@
|
||||
|
||||
import Util from '../utils/util.js';
|
||||
|
||||
export default {
|
||||
init: function () {
|
||||
Dialog.pack.init();
|
||||
},
|
||||
hide: function () {
|
||||
this.element.remove();
|
||||
this.isShow = false;
|
||||
},
|
||||
close: function () {
|
||||
this.hide();
|
||||
}, onData: function (data) {
|
||||
if (!this.isShow) {
|
||||
Dialog.show("trade");
|
||||
}
|
||||
Dialog.title("和" + data.name + "交易中");
|
||||
var items = Dialog.pack.items;
|
||||
this.trade_target = data.target;
|
||||
this.trade_list.length = 0;
|
||||
if (!Dialog.pack.items) SendCommand("pack");
|
||||
else this.update_pack();
|
||||
Dialog.pack.isShow = false;
|
||||
this.create_items(this.leftElement.empty(), this.trade_list, this.max_count);
|
||||
},
|
||||
update_pack: function (data) {
|
||||
this.create_items(this.rightElement.empty(), Dialog.pack.items, Dialog.pack.max_count);
|
||||
},
|
||||
max_count: 10,
|
||||
trade_list: [],
|
||||
show: function (data) {
|
||||
if (this.isShow) return;
|
||||
Dialog.init();
|
||||
Dialog.curItem = "trade";
|
||||
if (!this.element) {
|
||||
this.element = $('<div class="dialog-list"><div class="obj-list"></div><div class="obj-list"></div></div >');
|
||||
this.leftElement = $(this.element.children()[0]);
|
||||
this.rightElement = $(this.element.children()[1]);
|
||||
}
|
||||
this.leftElement.on("click", ".obj-item", this.left_click);
|
||||
this.rightElement.on("click", ".obj-item", this.right_click);
|
||||
this.element.appendTo(Dialog.contentElement.empty());
|
||||
this.create_footer();
|
||||
this.isShow = true;
|
||||
|
||||
}, create_footer: function () {
|
||||
var html = ["<div class='item-commands'>"];
|
||||
html.push("<span cmd='_trade ok'>确定</span>");
|
||||
html.push("<span cmd='_trade cancle'>取消</span>");
|
||||
html.push('</div>');
|
||||
Dialog.footer(html.join(""));
|
||||
}, confirm: function (cmd) {
|
||||
if (cmd === 'ok' && this.trade_list.length) {
|
||||
for (var i = 0; i < this.trade_list.length; i++) {
|
||||
SendCommand("give " + this.trade_target
|
||||
+ " " + this.trade_list[i].count + " " + this.trade_list[i].id);
|
||||
}
|
||||
}
|
||||
Dialog.hide();
|
||||
|
||||
},
|
||||
create_items: function (elem, items, max) {
|
||||
var html = [];
|
||||
items = Dialog.pack.sort_items(items);
|
||||
for (var i = 0; i < max; i++) {
|
||||
var item = items[i];
|
||||
html.push('<div class="obj-item');
|
||||
|
||||
if (item) {
|
||||
html.push(item.is_lock ? " lock" : "", ' grade', item.grade);
|
||||
html.push('"');
|
||||
|
||||
html.push(" oindex='" + item.id + "'>");
|
||||
html.push(item.name);
|
||||
if (item.count > 1) {
|
||||
html.push("<span class='obj-value'>");
|
||||
html.push(item.count);
|
||||
html.push(item.unit);
|
||||
html.push('</span>');
|
||||
}
|
||||
} else {
|
||||
html.push('">');
|
||||
}
|
||||
html.push('</div>');
|
||||
}
|
||||
elem.html(html.join(""));
|
||||
}, left_click: function () {
|
||||
var elem = $(this);
|
||||
var obj = elem.attr("oindex");
|
||||
if (!obj) return;
|
||||
var item = null;
|
||||
for (var i = 0; i < Dialog.trade.trade_list.length; i++) {
|
||||
if (Dialog.trade.trade_list[i].id == obj) {
|
||||
item = Dialog.trade.trade_list[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!item) return;
|
||||
Dialog.trade.cancle_trade(item);
|
||||
return false;
|
||||
}, enable_item: function (obj, isenable) {
|
||||
var elem = this.rightElement.find(".obj-item[oindex='" + obj.id + "']");
|
||||
if (!elem.length) return;
|
||||
if (isenable) {
|
||||
elem.removeClass("disabled");
|
||||
} else {
|
||||
elem.addClass("disabled");
|
||||
}
|
||||
}
|
||||
,
|
||||
right_click: function () {
|
||||
var elem = $(this);
|
||||
if (elem.is(".disabled")) return;
|
||||
var obj = elem.attr("oindex");
|
||||
if (!obj) return;
|
||||
|
||||
var item = Dialog.pack.get_item(obj);
|
||||
|
||||
if (!item) return;
|
||||
if (item.count > 1) {
|
||||
Confirm.Show_trade_add(item);
|
||||
} else {
|
||||
Dialog.trade.add_trade(item);
|
||||
}
|
||||
return false;
|
||||
}, add_trade: function (obj) {
|
||||
for (var i = 0; i < this.trade_list.length; i++) {
|
||||
if (obj.id == this.trade_list[i].id) {
|
||||
this.trade_list[i].count += obj.count;
|
||||
return this.create_items();
|
||||
}
|
||||
}
|
||||
this.trade_list.push(obj);
|
||||
this.create_items(this.leftElement.empty(), this.trade_list, this.max_count);
|
||||
this.enable_item(obj, false);
|
||||
},
|
||||
cancle_trade: function (obj) {
|
||||
for (var i = 0; i < this.trade_list.length; i++) {
|
||||
if (obj.id == this.trade_list[i].id) {
|
||||
this.trade_list.splice(i, 1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
this.create_items(this.leftElement.empty(), this.trade_list, this.max_count);
|
||||
this.enable_item(obj, true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user