Compare commits
7 commits
36e14399d8
...
852d64776b
Author | SHA1 | Date | |
---|---|---|---|
852d64776b | |||
20fc663bcb | |||
185a745f26 | |||
72340994da | |||
ddc7830c4c | |||
7974325eea | |||
a3421af127 |
7 changed files with 131 additions and 43 deletions
|
@ -13,6 +13,7 @@
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
grid-template-columns: 340px;
|
grid-template-columns: 340px;
|
||||||
|
z-index: 88888888;
|
||||||
}
|
}
|
||||||
|
|
||||||
.msgbox-dialog {
|
.msgbox-dialog {
|
||||||
|
|
|
@ -37,8 +37,15 @@
|
||||||
|
|
||||||
.sidebar__selector-top {
|
.sidebar__selector-top {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
|
flex-shrink: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
.sidebar__selector-bottom {
|
||||||
|
flex-shrink: 1;
|
||||||
|
flex-grow: 0;
|
||||||
|
overflow: hidden auto;
|
||||||
|
scrollbar-width: thin;
|
||||||
|
}
|
||||||
|
|
||||||
.sidebar__selector-mode {
|
.sidebar__selector-mode {
|
||||||
height: 40px;
|
height: 40px;
|
||||||
|
|
|
@ -49,6 +49,9 @@ const MamiAnimate = info => {
|
||||||
easing = MamiEasings.linear;
|
easing = MamiEasings.linear;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(typeof window.mami?.settings?.get === 'function')
|
||||||
|
duration *= mami.settings.get('dbgAnimDurationMulti');
|
||||||
|
|
||||||
let tStart, tLast,
|
let tStart, tLast,
|
||||||
cancel = false,
|
cancel = false,
|
||||||
tRawCompletion = 0,
|
tRawCompletion = 0,
|
||||||
|
|
|
@ -4,16 +4,68 @@
|
||||||
|
|
||||||
const MamiMessageBoxContainer = function() {
|
const MamiMessageBoxContainer = function() {
|
||||||
const container = <div class="msgbox-container"/>;
|
const container = <div class="msgbox-container"/>;
|
||||||
|
let raised = false;
|
||||||
|
let currAnim;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
getElement: () => container,
|
raise: async parent => {
|
||||||
|
if(raised) return;
|
||||||
|
raised = true;
|
||||||
|
container.style.pointerEvents = null;
|
||||||
|
|
||||||
|
if(!parent.contains(container))
|
||||||
|
parent.appendChild(container);
|
||||||
|
|
||||||
|
currAnim?.cancel();
|
||||||
|
|
||||||
|
currAnim = MamiAnimate({
|
||||||
|
async: true,
|
||||||
|
delayed: true,
|
||||||
|
duration: 300,
|
||||||
|
easing: 'outExpo',
|
||||||
|
start: () => { container.style.opacity = '0'; },
|
||||||
|
update: t => { container.style.opacity = t; },
|
||||||
|
end: () => { container.style.opacity = null; },
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await currAnim.start();
|
||||||
|
} catch(ex) {}
|
||||||
|
},
|
||||||
|
dismiss: async parent => {
|
||||||
|
if(!raised) return;
|
||||||
|
raised = false;
|
||||||
|
container.style.pointerEvents = 'none';
|
||||||
|
|
||||||
|
currAnim?.cancel();
|
||||||
|
|
||||||
|
currAnim = MamiAnimate({
|
||||||
|
async: true,
|
||||||
|
delayed: true,
|
||||||
|
duration: 300,
|
||||||
|
easing: 'outExpo',
|
||||||
|
update: t => { container.style.opacity = 1 - t; },
|
||||||
|
end: t => { parent.removeChild(container); },
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await currAnim.start();
|
||||||
|
} catch(ex) {}
|
||||||
|
},
|
||||||
show: async dialog => {
|
show: async dialog => {
|
||||||
if(typeof dialog !== 'object' || dialog === null)
|
if(typeof dialog !== 'object' || dialog === null)
|
||||||
throw 'dialog must be a non-null object';
|
throw 'dialog must be a non-null object';
|
||||||
|
|
||||||
|
const backgroundClick = ev => {
|
||||||
|
ev.stopPropagation();
|
||||||
|
if(ev.target === container)
|
||||||
|
dialog.clickButtonIndex(0);
|
||||||
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if(dialog.buttonCount === 1)
|
||||||
|
container.addEventListener('click', backgroundClick);
|
||||||
return await dialog.show(container);
|
return await dialog.show(container);
|
||||||
} finally {
|
} finally {
|
||||||
|
container.removeEventListener('click', backgroundClick);
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -28,6 +80,7 @@ const MamiMessageBoxDialog = function(info) {
|
||||||
{ name: 'cancel', text: 'Cancel', reject: true },
|
{ name: 'cancel', text: 'Cancel', reject: true },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const dialog = <form class="msgbox-dialog"/>;
|
||||||
let showResolve, showReject;
|
let showResolve, showReject;
|
||||||
|
|
||||||
const doResolve = (...args) => {
|
const doResolve = (...args) => {
|
||||||
|
@ -35,6 +88,7 @@ const MamiMessageBoxDialog = function(info) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
showReject = undefined;
|
showReject = undefined;
|
||||||
|
dialog.style.pointerEvents = 'none';
|
||||||
showResolve(...args);
|
showResolve(...args);
|
||||||
};
|
};
|
||||||
const doReject = (...args) => {
|
const doReject = (...args) => {
|
||||||
|
@ -42,11 +96,10 @@ const MamiMessageBoxDialog = function(info) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
showResolve = undefined;
|
showResolve = undefined;
|
||||||
|
dialog.style.pointerEvents = 'none';
|
||||||
showReject(...args);
|
showReject(...args);
|
||||||
};
|
};
|
||||||
|
|
||||||
const dialog = <form class="msgbox-dialog"/>;
|
|
||||||
|
|
||||||
const body = <div class="msgbox-dialog-body"/>;
|
const body = <div class="msgbox-dialog-body"/>;
|
||||||
dialog.appendChild(body);
|
dialog.appendChild(body);
|
||||||
|
|
||||||
|
@ -116,7 +169,13 @@ const MamiMessageBoxDialog = function(info) {
|
||||||
buttons.classList.add('msgbox-dialog-buttons-many');
|
buttons.classList.add('msgbox-dialog-buttons-many');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
getElement: () => dialog,
|
get buttonCount() {
|
||||||
|
return buttons.childElementCount;
|
||||||
|
},
|
||||||
|
clickButtonIndex: num => {
|
||||||
|
buttons.children[num].click();
|
||||||
|
},
|
||||||
|
|
||||||
show: container => {
|
show: container => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
showResolve = resolve;
|
showResolve = resolve;
|
||||||
|
@ -160,6 +219,8 @@ const MamiMessageBoxDialog = function(info) {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
dismiss: async () => {
|
dismiss: async () => {
|
||||||
|
dialog.style.pointerEvents = 'none';
|
||||||
|
|
||||||
await MamiAnimate({
|
await MamiAnimate({
|
||||||
async: true,
|
async: true,
|
||||||
duration: 600,
|
duration: 600,
|
||||||
|
@ -178,10 +239,10 @@ const MamiMessageBoxDialog = function(info) {
|
||||||
|
|
||||||
const MamiMessageBoxControl = function(options) {
|
const MamiMessageBoxControl = function(options) {
|
||||||
options = MamiArguments.verify(options, [
|
options = MamiArguments.verify(options, [
|
||||||
MamiArguments.type('views', 'object', undefined, true),
|
MamiArguments.check('parent', undefined, value => value instanceof Element, true),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const views = options.views;
|
const parent = options.parent;
|
||||||
const container = new MamiMessageBoxContainer;
|
const container = new MamiMessageBoxContainer;
|
||||||
const queue = [];
|
const queue = [];
|
||||||
let currentDialog;
|
let currentDialog;
|
||||||
|
@ -214,14 +275,7 @@ const MamiMessageBoxControl = function(options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
const raise = async () => {
|
const raise = async () => {
|
||||||
if(!views.isCurrent(container))
|
container.raise(parent);
|
||||||
views.raise(container, ctx => MamiAnimate({
|
|
||||||
async: true,
|
|
||||||
duration: 300,
|
|
||||||
easing: 'outExpo',
|
|
||||||
update: t => { ctx.toElem.style.opacity = t; },
|
|
||||||
end: () => { ctx.toElem.style.opacity = null; },
|
|
||||||
}));
|
|
||||||
|
|
||||||
if(!processingQueue)
|
if(!processingQueue)
|
||||||
await processQueue();
|
await processQueue();
|
||||||
|
@ -229,16 +283,8 @@ const MamiMessageBoxControl = function(options) {
|
||||||
|
|
||||||
const dismiss = async () => {
|
const dismiss = async () => {
|
||||||
processingQueue = false;
|
processingQueue = false;
|
||||||
|
container.dismiss(parent);
|
||||||
currentDialog?.cancel();
|
currentDialog?.cancel();
|
||||||
|
|
||||||
if(views.isCurrent(container))
|
|
||||||
await views.pop(ctx => MamiAnimate({
|
|
||||||
async: true,
|
|
||||||
duration: 300,
|
|
||||||
easing: 'outExpo',
|
|
||||||
update: t => { ctx.fromElem.style.opacity = 1 - t; },
|
|
||||||
end: t => { ctx.fromElem.style.opacity = '0'; },
|
|
||||||
}));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -42,7 +42,7 @@ window.Umi = { UI: {} };
|
||||||
Object.defineProperty(window, 'mami', { enumerable: true, value: ctx });
|
Object.defineProperty(window, 'mami', { enumerable: true, value: ctx });
|
||||||
|
|
||||||
ctx.views = new MamiViewsControl({ body: document.body });
|
ctx.views = new MamiViewsControl({ body: document.body });
|
||||||
ctx.msgbox = new MamiMessageBoxControl({ views: ctx.views });
|
ctx.msgbox = new MamiMessageBoxControl({ parent: document.body });
|
||||||
|
|
||||||
const loadingOverlay = new Umi.UI.LoadingOverlay('spinner', 'Loading...');
|
const loadingOverlay = new Umi.UI.LoadingOverlay('spinner', 'Loading...');
|
||||||
await ctx.views.push(loadingOverlay);
|
await ctx.views.push(loadingOverlay);
|
||||||
|
@ -99,7 +99,7 @@ window.Umi = { UI: {} };
|
||||||
settings.define('autoEmbedV1').default(false).create();
|
settings.define('autoEmbedV1').default(false).create();
|
||||||
settings.define('soundEnable').default(true).critical().create();
|
settings.define('soundEnable').default(true).critical().create();
|
||||||
settings.define('soundPack').default('').create();
|
settings.define('soundPack').default('').create();
|
||||||
settings.define('soundVolume').default(80).create();
|
settings.define('soundVolume').default(80).min(0).max(100).create();
|
||||||
settings.define('soundEnableJoin').default(true).create();
|
settings.define('soundEnableJoin').default(true).create();
|
||||||
settings.define('soundEnableLeave').default(true).create();
|
settings.define('soundEnableLeave').default(true).create();
|
||||||
settings.define('soundEnableError').default(true).create();
|
settings.define('soundEnableError').default(true).create();
|
||||||
|
@ -121,11 +121,12 @@ window.Umi = { UI: {} };
|
||||||
settings.define('motivationalVideos').default(false).create();
|
settings.define('motivationalVideos').default(false).create();
|
||||||
settings.define('osuKeys').default(false).create();
|
settings.define('osuKeys').default(false).create();
|
||||||
settings.define('osuKeysV2').type(['no', 'yes', 'rng']).default('no').create();
|
settings.define('osuKeysV2').type(['no', 'yes', 'rng']).default('no').create();
|
||||||
settings.define('explosionRadius').default(20).create();
|
settings.define('explosionRadius').default(20).min(0).create();
|
||||||
settings.define('dumpPackets').default(FUTAMI_DEBUG).create();
|
settings.define('dumpPackets').default(FUTAMI_DEBUG).create();
|
||||||
settings.define('dumpEvents').default(FUTAMI_DEBUG).create();
|
settings.define('dumpEvents').default(FUTAMI_DEBUG).create();
|
||||||
settings.define('marqueeAllNames').default(false).create();
|
settings.define('marqueeAllNames').default(false).create();
|
||||||
settings.define('tmpDisableOldThemeSys').default(false).critical().create();
|
settings.define('tmpDisableOldThemeSys').default(false).critical().create();
|
||||||
|
settings.define('dbgAnimDurationMulti').default(1).min(0).max(10).create();
|
||||||
|
|
||||||
const noNotifSupport = !('Notification' in window);
|
const noNotifSupport = !('Notification' in window);
|
||||||
settings.define('enableNotifications').default(false).immutable(noNotifSupport).critical().create();
|
settings.define('enableNotifications').default(false).immutable(noNotifSupport).critical().create();
|
||||||
|
|
|
@ -71,6 +71,11 @@ const MamiSettings = function(storageOrPrefix, eventTarget) {
|
||||||
if(setting.type === 'number') {
|
if(setting.type === 'number') {
|
||||||
value = parseFloat(value);
|
value = parseFloat(value);
|
||||||
resolved = true;
|
resolved = true;
|
||||||
|
|
||||||
|
if(setting.min !== undefined && value < setting.min)
|
||||||
|
value = setting.min;
|
||||||
|
else if(setting.max !== undefined && value > setting.max)
|
||||||
|
value = setting.max;
|
||||||
} else if(setting.type === 'boolean') {
|
} else if(setting.type === 'boolean') {
|
||||||
value = !!value;
|
value = !!value;
|
||||||
resolved = true;
|
resolved = true;
|
||||||
|
@ -122,11 +127,16 @@ const MamiSettings = function(storageOrPrefix, eventTarget) {
|
||||||
checkDefined();
|
checkDefined();
|
||||||
|
|
||||||
let created = false;
|
let created = false;
|
||||||
let type = undefined;
|
|
||||||
let fallback = null;
|
|
||||||
let immutable = false;
|
|
||||||
let critical = false;
|
|
||||||
let virtual = false;
|
let virtual = false;
|
||||||
|
const setting = {
|
||||||
|
name: name,
|
||||||
|
type: undefined,
|
||||||
|
fallback: null,
|
||||||
|
immutable: false,
|
||||||
|
critical: false,
|
||||||
|
min: undefined,
|
||||||
|
max: undefined,
|
||||||
|
};
|
||||||
|
|
||||||
const checkCreated = () => {
|
const checkCreated = () => {
|
||||||
if(created)
|
if(created)
|
||||||
|
@ -140,26 +150,42 @@ const MamiSettings = function(storageOrPrefix, eventTarget) {
|
||||||
|
|
||||||
checkCreated();
|
checkCreated();
|
||||||
|
|
||||||
type = value;
|
setting.type = value;
|
||||||
return pub;
|
return pub;
|
||||||
},
|
},
|
||||||
default: value => {
|
default: value => {
|
||||||
checkCreated();
|
checkCreated();
|
||||||
fallback = value === undefined ? null : value;
|
setting.fallback = value === undefined ? null : value;
|
||||||
|
|
||||||
if(type === undefined)
|
if(setting.type === undefined)
|
||||||
type = typeof fallback;
|
setting.type = typeof setting.fallback;
|
||||||
|
|
||||||
return pub;
|
return pub;
|
||||||
},
|
},
|
||||||
immutable: value => {
|
immutable: value => {
|
||||||
checkCreated();
|
checkCreated();
|
||||||
immutable = value === undefined || value === true;
|
setting.immutable = value === undefined || value === true;
|
||||||
return pub;
|
return pub;
|
||||||
},
|
},
|
||||||
critical: value => {
|
critical: value => {
|
||||||
checkCreated();
|
checkCreated();
|
||||||
critical = value === undefined || value === true;
|
setting.critical = value === undefined || value === true;
|
||||||
|
return pub;
|
||||||
|
},
|
||||||
|
min: value => {
|
||||||
|
checkCreated();
|
||||||
|
if(typeof value !== 'number')
|
||||||
|
throw 'value must be a number';
|
||||||
|
|
||||||
|
setting.min = value;
|
||||||
|
return pub;
|
||||||
|
},
|
||||||
|
max: value => {
|
||||||
|
checkCreated();
|
||||||
|
if(typeof value !== 'number')
|
||||||
|
throw 'value must be a number';
|
||||||
|
|
||||||
|
setting.max = value;
|
||||||
return pub;
|
return pub;
|
||||||
},
|
},
|
||||||
virtual: value => {
|
virtual: value => {
|
||||||
|
@ -171,13 +197,7 @@ const MamiSettings = function(storageOrPrefix, eventTarget) {
|
||||||
checkCreated();
|
checkCreated();
|
||||||
checkDefined();
|
checkDefined();
|
||||||
|
|
||||||
settings.set(name, Object.freeze({
|
settings.set(name, Object.freeze(setting));
|
||||||
name: name,
|
|
||||||
type: type,
|
|
||||||
fallback: fallback,
|
|
||||||
immutable: immutable,
|
|
||||||
critical: critical,
|
|
||||||
}));
|
|
||||||
|
|
||||||
if(virtual)
|
if(virtual)
|
||||||
storage.virtualise(name);
|
storage.virtualise(name);
|
||||||
|
|
|
@ -399,6 +399,11 @@ Umi.UI.Settings = (function() {
|
||||||
title: 'Disable Old Theme System',
|
title: 'Disable Old Theme System',
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'dbgAnimDurationMulti',
|
||||||
|
title: 'Animation multiplier',
|
||||||
|
type: 'range',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: 'Test kick/ban notice',
|
title: 'Test kick/ban notice',
|
||||||
type: 'button',
|
type: 'button',
|
||||||
|
@ -475,6 +480,11 @@ Umi.UI.Settings = (function() {
|
||||||
if(!input.disabled && setting.immutable)
|
if(!input.disabled && setting.immutable)
|
||||||
input.disabled = true;
|
input.disabled = true;
|
||||||
|
|
||||||
|
if(setting.min !== undefined)
|
||||||
|
input.min = setting.min;
|
||||||
|
if(setting.max !== undefined)
|
||||||
|
input.max = setting.max;
|
||||||
|
|
||||||
if(display.type === 'checkbox') {
|
if(display.type === 'checkbox') {
|
||||||
mami.settings.watch(setting.name, ev => input.checked = ev.detail.value);
|
mami.settings.watch(setting.name, ev => input.checked = ev.detail.value);
|
||||||
input.addEventListener('change', () => {
|
input.addEventListener('change', () => {
|
||||||
|
|
Loading…
Reference in a new issue