PopUpManager

TitleWindow管理技巧

 

PopUpManager在产生TitleWindow时应记录当前的TitleWindow,目前只能通过1)获取

1)  var titleWindowInstance:TitleWindowData = TitleWindowData(PopUpManager.createPopUp(this, TitleWindowData,  false));   

 

  PopUpManager.centerPopUp(titleWindowInstance); 

 

  //TitleWindowData 获取parent

  titleWindowInstance.mainApp = this; 

 

 

2)PopUpManager.addPopUp(new TitleWindowData,this, false)

 


 

var t = require; var e = module; var i = exports; "use strict"; var n, o = this && this.__extends || (n = function (t, e) { return ( n = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (t, e) { t.__proto__ = e } || function (t, e) { for (var i in e) Object.prototype.hasOwnProperty.call(e, i) && (t[i] = e[i]) })(t, e) }, function (t, e) { function i() { this.constructor = t } n(t, e), t.prototype = null === e ? Object.create(e) : (i.prototype = e.prototype, new i) }), s = this && this.__decorate || function (t, e, i, n) { var o, s = arguments.length, r = s < 3 ? e : null === n ? n = Object.getOwnPropertyDescriptor(e, i) : n; if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, i, n); else for (var a = t.length - 1; a >= 0; a--)(o = t[a]) && (r = (s < 3 ? o(r) : s > 3 ? o(e, i, r) : o(e, i)) || r); return s > 3 && r && Object.defineProperty(e, i, r), r }, r = this && this.__awaiter || function (t, e, i, n) { return new (i || (i = Promise))(function (o, s) { function r(t) { try { c(n.next(t)) } catch (e) { s(e) } } function a(t) { try { c(n.throw(t)) } catch (e) { s(e) } } function c(t) { var e; t.done ? o(t.value) : (e = t.value, e instanceof i ? e : new i(function (t) { t(e) })).then(r, a) } c((n = n.apply(t, e || [])).next()) }) }, a = this && this.__generator || function (t, e) { var i, n, o, s, r = { label: 0, sent: function () { if (1 & o[0]) throw o[1]; return o[1] }, trys: [], ops: [] }; return s = { next: a(0), throw: a(1), return: a(2) }, "function" == typeof Symbol && (s[Symbol.iterator] = function () { return this }), s; function a(t) { return function (e) { return c([t, e]) } } function c(s) { if (i) throw new TypeError("Generator is already executing."); for (; r;)try { if (i = 1, n && (o = 2 & s[0] ? n.return : s[0] ? n.throw || ((o = n.return) && o.call(n), 0) : n.next) && !(o = o.call(n, s[1])).done) return o; switch (n = 0, o && (s = [2 & s[0], o.value]), s[0]) { case 0: case 1: o = s; break; case 4: return r.label++, { value: s[1], done: !1 }; case 5: r.label++, n = s[1], s = [0]; continue; case 7: s = r.ops.pop(), r.trys.pop(); continue; default: if (!(o = (o = r.trys).length > 0 && o[o.length - 1]) && (6 === s[0] || 2 === s[0])) { r = 0; continue } if (3 === s[0] && (!o || s[1] > o[0] && s[1] < o[3])) { r.label = s[1]; break } if (6 === s[0] && r.label < o[1]) { r.label = o[1], o = s; break } if (o && r.label < o[2]) { r.label = o[2], r.ops.push(s); break } o[2] && r.ops.pop(), r.trys.pop(); continue }s = e.call(t, r) } catch (a) { s = [6, a], n = 0 } finally { i = o = 0 } if (5 & s[0]) throw s[1]; return { value: s[0] ? s[1] : void 0, done: !0 } } }; Object.defineProperty(i, "__esModule", { value: !0 }), i.BaseLoad = void 0; var c = t("AdConfig"), l = t("AdManager"), p = t("AdModel"), h = t("AppBase"), u = t("Toast"), d = t("EventManager"), f = t("HotUpdateManager"), m = t("GameManager"), g = t("DeviceRiskConfig"), y = t("ConfigManager"), v = t("GameModel"), _ = t("LoginModel"), b = t("ZSHttp"), S = t("SceneBase"), D = t("ZSUtil"), w = t("PopupManager"), P = t("EngineUtil"), C = t("StringUtil"), A = t("SqlUtil"), k = t("AuthenticationConfig"), E = t("DMPConfig"), T = t("DMPModel"), M = cc._decorator, O = M.ccclass, R = M.property, N = function (t) { function e() { var e = null !== t && t.apply(this, arguments) || this; return e.versionLabel = null, e.progress = null, e.progressLabel = null, e.needAuth = !0, e.authNode = null, e.channelNode = null, e.wxNode = null, e.guestNode = null, e.agreeToggle = null, e.manifest = null, e.reviewSceneName = "", e.gameSceneName = "", e._isNet = !1, e._maxProgress = 1, e._bundles = [], e._dirs = [], e.userInfoButton = null, e.customClientCode = 1, e } return o(e, t), Object.defineProperty(e.prototype, "bundles", { get: function () { return this._bundles }, set: function (t) { this._bundles = t }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "dirs", { get: function () { return this._dirs }, set: function (t) { this._dirs = t }, enumerable: !1, configurable: !0 }), e.prototype.onLoad = function () { t.prototype.onLoad.call(this), h.AppBase.init(), w.PopupManager.instance.init(), m.GameManager.instance.init(), d.EventManager.instance.on(v.GameEvent.POPUP_CHANGED, this.checkUserInfoBtn, this) }, e.prototype.start = function () { var e = this; t.prototype.start.call(this), zs.gameLoadResult(), zs.onPolicyResult(function (t) { t && e.checkUpdate() }) }, e.prototype.checkUpdate = function () { var t = this, e = "", i = zs.getSystemInfoSync(); if (null != this.manifest) { d.EventManager.instance.on(f.HotUpdateEvent.ALREADY_UP_TO_DATE, this.userLogin, this), d.EventManager.instance.on(f.HotUpdateEvent.UPDATE_FAILED, this.userLogin, this), d.EventManager.instance.on(f.HotUpdateEvent.UPDATE_PROGRESSION, this.onUpdateProgress, this), f.HotUpdateManager.instance.init(this.manifest); var n = (e = f.HotUpdateManager.instance.getVersion()).split("."); v.GameModel.instance.clientCode = Number(n[n.length - 1]) } else v.GameModel.instance.clientCode = this.customClientCode, e = i.version + "." + this.customClientCode; b.ZSHttp.instance.checkUpdate(v.GameModel.instance.clientCode, function (e) { if (null != e.app) { var i = e.app.des; cc.sys.os == cc.sys.OS_IOS ? d.EventManager.instance.emit(v.GameEvent.SHOW_TIP, { name: "hotUpdate", message: i || "AppStore已有新版本发布,快去下载吧", onSubmit: function () { cc.sys.openURL(e.url) }, onCancel: function () { e.must && cc.game.end() } }) : zs.updateApp({ name: zs.gameConfig.name, url: e.url, versionCode: e.app.versionCode, versionName: e.app.versionName, size: e.app.size, des: i || "该应用已发布最新版本,请尽快更新", force: e.must }) } null != e.app && e.must || (null != t.manifest && C.StringUtil.isNotEmpty(e.clientVersion) ? f.HotUpdateManager.instance.checkUpdate(zs.gameConfig.hotUpdateUrl + "v" + e.clientVersion.replace(/\./g, "_")) : t.userLogin()) }, function () { t.userLogin() }), zs.putBuglyUserData("clientVersion", e), this.versionLabel && (this.versionLabel.string = "APP:" + i.version + "." + (i.versionCode || 1) + "\nRES:" + e) }, e.prototype.userLogin = function () { var t = this; if (C.StringUtil.isEmpty(_.LoginModel.instance.uid) || C.StringUtil.isEmpty(_.LoginModel.instance.loginToken)) if (this.needAuth && !D.ZSUtil.isTestChannel(zs.getChannel())) { if (this.authNode) { this.authNode.active = !0; var e = zs.isInstall("wechat"); cc.sys.os != cc.sys.OS_IOS || e ? (null != this.wxNode && (zs.onEvent("微信登陆", { name: "显示按钮" }), this.wxNode.active = !0), null != this.guestNode && (this.guestNode.active = D.ZSUtil.isGuestChannel(zs.getChannel()))) : (null != this.wxNode && (this.wxNode.active = !1), null != this.guestNode && (this.guestNode.active = !0)) } null == this.userInfoButton && null != this.channelNode && (this.userInfoButton = zs.createUserInfoButton({ style: this.getUserInfoButton() }), null != this.userInfoButton && this.userInfoButton.onTap(function (e) { if (0 != e.errCode) return t.userInfoButton.hide(), void t.showTip(e.errMsg, t.userLogin); e.openId && (_.LoginModel.instance.guestOpenId = e.channel + "_" + e.openId, t.login(_.LoginType.CHANNEL)) })), null != this.userInfoButton && this.userInfoButton.show(), this.progress && (this.progress.node.active = !1), this.progressLabel && (this.progressLabel.node.active = !1) } else this.login(_.LoginType.ZS); else this.login(_.LoginType.UID) }, e.prototype.onBtnWx = function () { this.agreeToggle ? this.agreeToggle.isChecked ? (zs.onEvent("微信登陆", { name: "点击登陆" }), this.login(_.LoginType.WX)) : (zs.onEvent("微信登陆", { name: "未同意协议" }), u.Toast.makeText(null, "请先同意用户协议和隐私政策", u.Toast.LENGTH_SHORT).show()) : (zs.onEvent("微信登陆", { name: "点击登陆" }), this.login(_.LoginType.WX)) }, e.prototype.onZSLogin = function () { this.agreeToggle ? this.agreeToggle.isChecked ? this.login(_.LoginType.ZS) : u.Toast.makeText(null, "请先同意用户协议和隐私政策", u.Toast.LENGTH_LONG).show() : this.login(_.LoginType.ZS) }, e.prototype.onVisitor = function () { this.agreeToggle ? this.agreeToggle.isChecked ? this.login(_.LoginType.GUEST) : u.Toast.makeText(null, "请先同意用户协议和隐私政策", u.Toast.LENGTH_LONG).show() : this.login(_.LoginType.GUEST) }, e.prototype.showBtn = function () { null != this.authNode && (this.authNode.active = !0), null != this.userInfoButton && this.userInfoButton.show() }, e.prototype.login = function (t) { var e = this; this.authNode && (this.authNode.active = !1), null != this.userInfoButton && this.userInfoButton.hide(), _.LoginType.WX == t && this.scheduleOnce(this.showBtn, 1), this._maxProgress = .5, this.setProgress("登录中...", 0), this._isNet = !0, b.ZSHttp.instance.login(t, v.GameModel.instance.clientCode, function (i) { return r(e, void 0, void 0, function () { return a(this, function (e) { switch (e.label) { case 0: return this.unschedule(this.showBtn), [4, this.loginDeal(t, i)]; case 1: return e.sent(), [2] } }) }) }, function (i, n) { _.LoginType.WX == t && zs.onEvent("微信登陆", { name: "登陆失败_" + i }), e.unschedule(e.showBtn), null != e.authNode && (e.authNode.active = !1), null != e.userInfoButton && e.userInfoButton.hide(), e.showTip(n, e.userLogin) }) }, e.prototype.loginDeal = function (t, e) { return r(this, void 0, void 0, function () { return a(this, function (i) { switch (i.label) { case 0: return null != this.authNode && (this.authNode.active = !1), null != this.userInfoButton && this.userInfoButton.hide(), this.progressLabel && (this.progressLabel.node.active = !0), this.progress && (this.progress.node.active = !0, this.progress.progress = 0), A.SqlUtil.initUserId(e.uid), l.AdManager.instance.init(e.adId, e.uid), _.LoginModel.instance.initData(e), D.ZSUtil.initUserId(_.LoginModel.instance.uid), zs.loginEvent({ userId: String(_.LoginModel.instance.uid) }), 1 == _.LoginModel.instance.regDay && zs.nextDayStayEvent(), _.LoginType.WX == t && zs.onEvent("微信登陆", { name: "登陆成功" }), C.StringUtil.isEmpty(_.LoginModel.instance.deviceTags) && b.ZSHttp.instance.authDeviceToken(), [4, this.userLoginRes(e)]; case 1: return i.sent(), this.updateUUID(), [2] } }) }) }, e.prototype.updateUUID = function () { var t = this; C.StringUtil.isEmpty(this.reviewSceneName) ? (b.ZSHttp.instance.updateUUID(), this.gameConfig()) : b.ZSHttp.instance.updateUUID(function () { t.gameConfig() }) }, e.prototype.gameConfig = function () { var t = this; this._maxProgress = 1, this.setProgress("读取配置中...", .5), b.ZSHttp.instance.getGameConfig(function (e) { return r(t, void 0, void 0, function () { var t, i, n, o, s; return a(this, function (r) { switch (r.label) { case 0: return t = _.LoginModel.instance.isNew ? "newUser" : "oldUser", e.ad && e.ad[t] && Object.assign(e.ad, e.ad[t]), y.ConfigManager.instance.addConfig(c.AdConfig, e.ad), [4, this.initCDN(e.cdn)]; case 1: for (i = r.sent(), s = 0; s < i.length; s++)Object.assign(e, i[s]); return y.ConfigManager.instance.addConfig(g.DeviceRiskConfig, e.deviceRisk), y.ConfigManager.instance.addConfig(E.DMPConfig, e.dmp), y.ConfigManager.instance.addConfig(k.AuthenticationConfig, e.authentication), n = zs.getChannel(), _.LoginModel.instance.needAuthentication = 1 == k.AuthenticationConfig.type && -1 !== k.AuthenticationConfig.channel.indexOf(n) || 0 == k.AuthenticationConfig.type && -1 === k.AuthenticationConfig.channel.indexOf(n), [4, this.gameConfigRes(e)]; case 2: r.sent(), o = this.bundles.length + this.dirs.length, s = 0, r.label = 3; case 3: return s < this.bundles.length ? (this._maxProgress = (s + 1) / o, this.setProgress("加载第" + (s + 1) + "/" + o + "个资源中...", s / o), [4, P.EngineUtil.loadBundle(this.bundles[s])]) : [3, 6]; case 4: r.sent(), r.label = 5; case 5: return s++, [3, 3]; case 6: s = 0, r.label = 7; case 7: return s < this.dirs.length ? (this._maxProgress = (this.bundles.length + s + 1) / o, this.setProgress("加载第" + (this.bundles.length + s + 1) + "/" + o + "个资源中...", (this.bundles.length + s) / o), [4, P.EngineUtil.loadDir(this.dirs[s])]) : [3, 10]; case 8: r.sent(), r.label = 9; case 9: return s++, [3, 7]; case 10: return this.getUserData(), [2] } }) }) }, function (e, i) { t.showTip(i, t.gameConfig) }) }, e.prototype.getUserData = function () { var t = this; T.DMPModel.instance.addReportParam({ adTimes: _.LoginModel.instance.videoNum, ecpmSum: _.LoginModel.instance.ecpmSum, ecpmMax: _.LoginModel.instance.ecpmMax, ecpmMin: _.LoginModel.instance.ecpmMin, ecpmAvg: Math.floor(_.LoginModel.instance.ecpmSum / _.LoginModel.instance.videoNum) }), b.ZSHttp.instance.getUserData(function (e) { return r(t, void 0, void 0, function () { var t = this; return a(this, function (i) { switch (i.label) { case 0: if (e && e.ad) try { p.AdModel.instance.initData(JSON.parse(e.ad)) } catch (n) { } return [4, this.userDataRes(e)]; case 1: return i.sent(), zs.onAppLoadResult(function () { t.nextScene() }), [2] } }) }) }, function (e, i) { t.showTip(i, t.getUserData) }) }, e.prototype.nextScene = function () { var t = this; this._isNet = !1, this._maxProgress = 1, this.setProgress("加载场景中...", 0); var e; e = C.StringUtil.isNotEmpty(this.reviewSceneName) && _.LoginModel.instance.next ? this.reviewSceneName : this.gameSceneName, null != this.progress ? cc.director.preloadScene(e, function (e, i) { if (t.progress) { var n = e / i; n - t.progress.progress > 0 && (t.progress.progress = n) } }, function () { t.loadScene(e) }) : this.loadScene(e) }, e.prototype.loadScene = function (t) { var e = this; cc.director.loadScene(t, function () { v.GameModel.instance.isEnterGame = !0, p.AdModel.instance.enter(), e.loadComplete() }) }, e.prototype.onDestroy = function () { d.EventManager.instance.off(f.HotUpdateEvent.ALREADY_UP_TO_DATE, this.userLogin, this), d.EventManager.instance.off(f.HotUpdateEvent.UPDATE_FAILED, this.userLogin, this), d.EventManager.instance.off(f.HotUpdateEvent.UPDATE_PROGRESSION, this.onUpdateProgress, this), d.EventManager.instance.off(v.GameEvent.POPUP_CHANGED, this.checkUserInfoBtn, this) }, e.prototype.update = function (t) { this._isNet && this.progress && this.progress.progress < this._maxProgress && (this.progress.progress += t) }, e.prototype.setProgress = function (t, e) { null != this.progressLabel && null != t && (this.progressLabel.string = t), null != this.progress && null != e && (this.progress.progress = e) }, e.prototype.userLoginRes = function () { throw new Error("userLoginRes not implemented.") }, e.prototype.gameConfigRes = function () { throw new Error("gameConfigRes not implemented.") }, e.prototype.userDataRes = function () { throw new Error("userDataRes not implemented.") }, e.prototype.loadComplete = function () { }, e.prototype.initCDN = function (t) { var e = this; return null == t ? Promise.resolve({}) : new Promise(function (i, n) { var o = []; for (var s in t) o.push(e.getCDNData(s, t[s])); Promise.all(o).then(function (t) { i(t) }).catch(function (t) { n(t), e.showTip("配置获取失败", e.gameConfig) }) }) }, e.prototype.getCDNData = function (t, e) { return new Promise(function (i, n) { P.EngineUtil.loadRemote({ url: e, onComplete: function (e, o) { if (e) n(e); else { var s = {}; s[t] = o.json, i(s) } } }) }) }, e.prototype.onUpdateProgress = function (t) { this.progress && (this.progress.progress = t), this.progressLabel && (this.progressLabel.string = "更新中...") }, e.prototype.getUserInfoButton = function () { if (null == this.channelNode) return { left: 0, top: 0, width: 0, height: 0 }; var t = cc.view.getFrameSize(), e = cc.winSize; return { left: (e.width / 2 + this.channelNode.x - this.channelNode.width * this.channelNode.anchorX) / e.width * t.width, top: (e.height / 2 - this.channelNode.y - this.channelNode.height * this.channelNode.anchorY) / e.height * t.height, width: this.channelNode.width / e.width * t.width, height: this.channelNode.height / e.height * t.height } }, e.prototype.checkUserInfoBtn = function () { this.userInfoButton && (w.PopupManager.instance.getCurrentPopup() ? this.userInfoButton.hide() : this.userInfoButton.show()) }, e.prototype.showTip = function (t, e) { d.EventManager.instance.emit(v.GameEvent.SHOW_TIP, { name: "login", message: t, onSubmit: e.bind(this), oncancel: cc.game.end }) }, s([R({ type: cc.Label })], e.prototype, "versionLabel", void 0), s([R({ type: cc.ProgressBar })], e.prototype, "progress", void 0), s([R({ type: cc.Label })], e.prototype, "progressLabel", void 0), s([R()], e.prototype, "needAuth", void 0), s([R({ type: cc.Node })], e.prototype, "authNode", void 0), s([R({ type: cc.Node })], e.prototype, "channelNode", void 0), s([R({ type: cc.Node })], e.prototype, "wxNode", void 0), s([R({ type: cc.Node })], e.prototype, "guestNode", void 0), s([R({ type: cc.Toggle })], e.prototype, "agreeToggle", void 0), s([R({ type: cc.Asset })], e.prototype, "manifest", void 0), s([R({ tooltip: "审核场景" })], e.prototype, "reviewSceneName", void 0), s([R({ tooltip: "主场景" })], e.prototype, "gameSceneName", void 0), s([O], e) }(S.SceneBase); i.BaseLoad = N 使用js语言重构这个脚本
10-21
import tkinter as tk import threading import queue import random import time class PopupManager: def __init__(self): self.root = tk.Tk() self.root.withdraw() # 隐藏主窗口 self.task_queue = queue.Queue() self.window_pool = [] self.max_windows = 15 self.running = True # 启动工作线程 threading.Thread(target=self.worker, daemon=True).start() # 启动GUI处理循环 self.process_queue() def worker(self): """工作线程生成窗口参数""" while self.running: time.sleep(0.1) # 控制生成频率 x, y = self.generate_position() style = self.generate_style() self.task_queue.put((x, y, style)) def process_queue(self): """主线程处理队列""" try: while not self.task_queue.empty(): self.create_window(*self.task_queue.get()) finally: if self.running: self.root.after(50, self.process_queue) def create_window(self, x, y, style): """安全创建窗口""" if len(self.window_pool) >= self.max_windows: self.safe_destroy(self.window_pool.pop(0)) win = tk.Toplevel() win.geometry(f"200x100+{x}+{y}") # 应用样式配置... win.after(3000, lambda w=win: self.safe_destroy(w)) # 3秒后自动关闭 self.window_pool.append(win) def safe_destroy(self, window): """安全销毁窗口""" try: if window.winfo_exists(): window.destroy() except tk.TclError: pass def generate_position(self): """生成有效屏幕位置""" screen_width = self.root.winfo_screenwidth() screen_height = self.root.winfo_screenheight() return ( random.randint(0, max(0, screen_width - 200)), random.randint(0, max(0, screen_height - 150)) ) def generate_style(self): """生成随机样式配置""" return { 'bg': random.choice(['#FFCCCC', '#CCFFCC', '#CCCCFF']), 'font': ('Arial', random.randint(10, 14)) } def shutdown(self): """安全关闭所有资源""" self.running = False for win in self.window_pool: self.safe_destroy(win) self.root.destroy() # 使用示例 manager = PopupManager() tk.mainloop() 怎么变成别人可以打开的文件
最新发布
11-15
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值