123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266 |
- var t = require;
- var e = module;
- var i = exports;
- var s,
- e =
- (this && this.__decorate) ||
- function (t, e, i, s) {
- var o,
- a = arguments.length,
- n = a < 3 ? e : null === s ? (s = Object.getOwnPropertyDescriptor(e, i)) : s;
- if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(t, e, i, s);
- else
- for (var r = t.length - 1; 0 <= r; r--)
- (o = t[r]) && (n = (a < 3 ? o(n) : 3 < a ? o(e, i, n) : o(e, i)) || n);
- return 3 < a && n && Object.defineProperty(e, i, n), n;
- },
- a =
- (this && this.__awaiter) ||
- function (t, n, r, l) {
- return new (r = r || Promise)(function (i, e) {
- function s(t) {
- try {
- a(l.next(t));
- } catch (t) {
- e(t);
- }
- }
- function o(t) {
- try {
- a(l.throw(t));
- } catch (t) {
- e(t);
- }
- }
- function a(t) {
- var e;
- t.done
- ? i(t.value)
- : ((e = t.value) instanceof r
- ? e
- : new r(function (t) {
- t(e);
- })
- ).then(s, o);
- }
- a((l = l.apply(t, n || [])).next());
- });
- };
- Object.defineProperty(i, "__esModule", {value: !0}), (i.ArchiveonMgrView = void 0);
- const n = t("App"),
- o = t("List"),
- r = t("BaseView"),
- l = t("Toast"),
- h = (t("ViewConst"), t("GameDataMsr")),
- c = t("TipView"),
- {ccclass: d, property: u} = cc._decorator;
- let p = null,
- f = (s = class extends r.default {
- constructor() {
- super(...arguments), (this.itemList = null), (this.itemDatas = null), (this.items = []);
- }
- initUI() {
- super.initUI(),
- (this.itemDatas = s.getArchiveonData()),
- (this.itemList.numItems = this.itemDatas.list.length);
- }
- static getArchiveonData() {
- if (!p) {
- var t = cc.sys.localStorage.getItem("ArchiveonCache");
- if (t)
- try {
- p = JSON.parse(t);
- } catch (t) {
- p = {cur: "", list: []};
- }
- else p = {cur: "", list: []};
- }
- return p;
- }
- saveData() {
- cc.sys.localStorage.setItem("ArchiveonCache", JSON.stringify(this.itemDatas));
- }
- loadRemote(o) {
- return a(this, void 0, void 0, function* () {
- const s = yield n.default.Http.requestAsync(
- "https://wxclient.gzqidong.cn/MergeElves/archive/assets/archive/r_cfg.txt?" + Date.now(),
- {},
- "GET"
- );
- Log.trace("result:", s),
- cc.assetManager.downloader.bundleVers
- ? (cc.assetManager.downloader.bundleVers.archive = s)
- : (cc.assetManager.downloader.bundleVers = {archive: s});
- var t = o.target.getComponentInChildren(cc.EditBox).string || "normal";
- for (const o of yield n.default.ResManager.loadDirInBundle(
- "https://wxclient.gzqidong.cn/MergeElves/archive/assets/archive",
- t,
- cc.JsonAsset
- )) {
- const s = o.json;
- let t = !1,
- e = this.itemDatas.list.length,
- i = 0;
- for (; i < e; i++)
- if (this.itemDatas.list[i].name == s.name) {
- t = !0;
- break;
- }
- t
- ? (this.itemDatas.list[i] = s)
- : s.name
- ? this.itemDatas.list.push(s)
- : this.itemDatas.list.push({name: new Date().Format("远程-0(MM-dd hh:mm:ss)"), data: s});
- }
- l.default.launch("导入完成!"), (this.itemList.numItems = this.itemDatas.list.length), this.saveData();
- });
- }
- addNewArchive(t) {
- let i = t.target.getComponentInChildren(cc.EditBox);
- try {
- let e;
- (e = i.string.includes("{") ? JSON.parse(i.string) : JSON.parse(n.default.StringUtil.unzip(i.string)))
- .name || (e = {name: new Date().Format("存档(MM-dd hh:mm:ss)"), data: e});
- var s = this.itemDatas.list.length;
- for (let t = 0; t < s; t++)
- if (this.itemDatas.list[t].name == e.name)
- return void n.default.ViewManager.open(14, {
- tipsStr: "已有相同名字的存档,是否覆盖旧存档!!!",
- leftBtnText: "覆盖",
- hasCloseBtn: !1,
- curState: c.TIPSTATE.SURE_CANCEL,
- leftFunc: () => {
- (this.itemDatas.list[t] = e), l.default.launch("导入存档成功,覆盖了旧的存档!");
- },
- leftThisObj: this,
- rightBtnText: "新增",
- rightFunc: () => {
- this.itemDatas.list.push(e),
- (e.name += "(new)"),
- (this.itemList.numItems = this.itemDatas.list.length),
- l.default.launch("导入了存档:" + e.name);
- },
- rightThisObj: this
- });
- this.itemDatas.list.push(e), (this.itemList.numItems = this.itemDatas.list.length), this.saveData();
- } catch (t) {
- l.default.launch("导入失败!"), Log.error(t);
- }
- }
- addCurArchive(t) {
- var i = t.target.getComponentInChildren(cc.EditBox);
- try {
- let e = n.default.SaveManage.getAllAutoSaveData();
- if (i.string) {
- var s = this.itemDatas.list.length;
- for (let t = 0; t < s; t++)
- if (this.itemDatas.list[t].name == i.string)
- return void n.default.ViewManager.open(14, {
- tipsStr: "已有相同名字的存档,是否覆盖旧存档!!!",
- leftBtnText: "覆盖",
- hasCloseBtn: !1,
- curState: c.TIPSTATE.SURE_CANCEL,
- leftFunc: () => {
- (this.itemDatas.list[t].data = e), this.saveData(), l.default.launch("存入成功!");
- },
- leftThisObj: this,
- rightBtnText: "取消",
- rightFunc: () => {},
- rightThisObj: this
- });
- var o = i.string;
- } else o = new Date().Format("存档(MM-dd hh:mm:ss)");
- this.itemDatas.list.push({name: o, data: JSON.parse(e)}),
- (this.itemList.numItems = this.itemDatas.list.length),
- this.saveData();
- } catch (t) {
- l.default.launch("导入失败!"), Log.error(t);
- }
- }
- importText(a) {
- try {
- let t = "string" == typeof a.data ? JSON.parse(a.data) : a.data,
- e = Object.keys(t),
- i = {};
- for (const a of e) i[a.replace(/[\d]{8}/, "")] = t[a];
- let s = (t = i)[h.GameDataSaveKey.PLAYER_INFO],
- o = n.default.GameDataMsr.playerInfo;
- (s.saveTime = n.default.DateUtils.Now()),
- (s.id = o.id),
- (s.account = o.account),
- (s.nickName = o.nickName),
- n.default.SaveManage.syncByData(t),
- (n.default.GameDataMsr.playerInfo.token = null),
- n.default.SaveManage.clearAllItem(),
- n.default.ViewManager.open(14, {
- tipsStr: "导入存档成功",
- hasCloseBtn: !1,
- curState: c.TIPSTATE.SURE,
- leftFunc: () => {
- n.default.Platform.resetGame();
- },
- leftThisObj: this
- });
- } catch (t) {
- n.default.ViewManager.open(14, {
- tipsStr: "导入存档出错",
- curState: c.TIPSTATE.NO_SURE,
- hasCloseBtn: !0
- });
- }
- }
- onEditArchiveName(e, i) {
- if (this.itemDatas.list[i].name != e.string) {
- var s = this.itemDatas.list.length;
- for (let t = 0; t < s; t++)
- if (this.itemDatas.list[t].name == e.string)
- return (
- l.default.launch("修改失败,存档名不允许重复"), void (e.string = this.itemDatas.list[i].name)
- );
- (this.itemDatas.list[i].name = e.string), this.saveData();
- }
- }
- onOutputArchive(t, e) {
- var i,
- s = parseInt(e),
- e = this.itemDatas.list[s];
- cc.sys.platform !== cc.sys.WECHAT_GAME
- ? (((i = document.createElement("a")).download = e.name + ".json"),
- (i.style.display = "none"),
- (s = new Blob([JSON.stringify(e, null, 4)])),
- (i.href = URL.createObjectURL(s)),
- document.body.appendChild(i),
- i.click(),
- document.body.removeChild(i))
- : ((i = ""),
- (i = "string" == typeof e.data ? e.data : n.default.StringUtil.zipStr(JSON.stringify(e.data))),
- wx.setClipboardData({data: i, success(t) {}}));
- }
- onDeleteArchive(t, e) {
- e = parseInt(e);
- this.itemDatas.list.splice(e, 1), (this.itemList.numItems = this.itemDatas.list.length), this.saveData();
- }
- onLoadArchive(t, e) {
- (e = parseInt(e)), (e = this.itemDatas.list[e]);
- this.importText(e);
- }
- onRenderItem(t, e) {
- let i = this.itemDatas.list[e],
- s = t.getChildByName("btns"),
- o = {
- edit: t.getChildByName("EditBox").getComponent(cc.EditBox),
- loadBtn: s.getChildByName("加载").getComponent(cc.Button),
- delBtn: s.getChildByName("删除").getComponent(cc.Button),
- outputBtn: s.getChildByName("导出").getComponent(cc.Button),
- visistBtn: s.getChildByName("访问").getComponent(cc.Button)
- };
- (o.edit.string = i.name),
- (o.loadBtn.clickEvents[0].customEventData =
- o.delBtn.clickEvents[0].customEventData =
- o.visistBtn.clickEvents[0].customEventData =
- o.outputBtn.clickEvents[0].customEventData =
- o.edit.editingDidEnded[0].customEventData =
- e + "");
- }
- });
- e([u({type: o.default})], f.prototype, "itemList", void 0), (s = e([d], f)), (i.ArchiveonMgrView = s);
|