From 0e2864e9dcd492f5dfe01ffe35fe5072aa3f84a3 Mon Sep 17 00:00:00 2001 From: Tipx-L <138244655+Tipx-L@users.noreply.github.com> Date: Mon, 9 Oct 2023 22:47:10 -0700 Subject: [PATCH] Add Dialog class. --- game/game.js | 110 ++++++++++++++++++++++++++------------------------- 1 file changed, 56 insertions(+), 54 deletions(-) diff --git a/game/game.js b/game/game.js index 99c87c970..030e3a6ad 100644 --- a/game/game.js +++ b/game/game.js @@ -31020,8 +31020,43 @@ } } }, - dialog:{ - add:function(item,noclick,zoom){ + Dialog:class extends HTMLDivElement{ + constructor(){ + let hidden=false; + let noTouchScroll=false; + let forceButton=false; + let noForceButton=false; + const dialog=ui.create.div('.dialog'); + Object.setPrototypeOf(dialog,lib.element.Dialog.prototype); + dialog.contentContainer=ui.create.div('.content-container',dialog); + dialog.content=ui.create.div('.content',dialog.contentContainer); + dialog.bar1=ui.create.div('.bar.top',dialog); + dialog.bar2=ui.create.div('.bar.bottom',dialog); + dialog.buttons=[]; + Array.from(arguments).forEach(argument=>{ + if(typeof argument=='boolean') dialog.static=argument; + else if(argument=='hidden') hidden=true; + else if(argument=='notouchscroll') noTouchScroll=true; + else if(argument=='forcebutton') forceButton=true; + else if(argument=='noforcebutton') noForceButton=true; + else dialog.add(argument); + }); + if(!hidden) dialog.open(); + if(!lib.config.touchscreen) dialog.contentContainer.onscroll=ui.update; + if(!noTouchScroll){ + dialog.contentContainer.ontouchstart=ui.click.dialogtouchStart; + dialog.contentContainer.ontouchmove=ui.click.touchScroll; + dialog.contentContainer.style.WebkitOverflowScrolling='touch'; + dialog.ontouchstart=ui.click.dragtouchdialog; + } + if(noForceButton) dialog.noforcebutton=true; + else if(forceButton){ + dialog.forcebutton=true; + dialog.classList.add('forcebutton'); + } + return dialog; + } + add(item,noclick,zoom){ if(typeof item=='string'){ if(item.startsWith('###')){ var items=item.slice(3).split('###'); @@ -31069,8 +31104,8 @@ } ui.update(); return item; - }, - addText:function(str,center){ + } + addText(str,center){ if(str&&str.startsWith('