2024-01-30 11:29:07 -05:00
|
|
|
const { timeout } = Utils;
|
|
|
|
const { Stack } = Widget;
|
2023-11-10 23:51:50 -05:00
|
|
|
|
2024-01-13 23:38:31 -05:00
|
|
|
import PopupWindow from '../misc/popup.ts';
|
2024-01-29 20:56:56 -05:00
|
|
|
|
|
|
|
// Types
|
2024-02-27 18:27:47 -05:00
|
|
|
import { BoxGeneric } from 'global-types';
|
2023-11-10 23:51:50 -05:00
|
|
|
|
2023-11-27 22:02:28 -05:00
|
|
|
// Import all the OSDs as an array
|
2024-02-27 18:27:47 -05:00
|
|
|
const OSDList = [] as Array<() => BoxGeneric>;
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2024-01-13 23:38:31 -05:00
|
|
|
import * as Modules from './osds.ts';
|
2023-11-27 22:02:28 -05:00
|
|
|
for (const osd in Modules) {
|
|
|
|
OSDList.push(Modules[osd]);
|
|
|
|
} // Array
|
2023-11-10 23:51:50 -05:00
|
|
|
|
2023-11-27 22:02:28 -05:00
|
|
|
const HIDE_DELAY = 2000;
|
2024-01-02 16:40:12 -05:00
|
|
|
const transition_duration = 300;
|
2023-11-10 23:51:50 -05:00
|
|
|
|
|
|
|
|
2023-11-27 22:02:28 -05:00
|
|
|
const OSDs = () => {
|
2023-11-10 23:51:50 -05:00
|
|
|
const stack = Stack({
|
2023-11-27 22:02:28 -05:00
|
|
|
transition: 'over_up_down',
|
2024-01-02 16:40:12 -05:00
|
|
|
transition_duration,
|
2023-12-21 01:25:59 -05:00
|
|
|
|
2024-02-27 16:55:01 -05:00
|
|
|
attribute: {
|
|
|
|
popup: (osd: string) => {
|
|
|
|
if (!osd) {
|
|
|
|
//
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
2023-11-10 23:51:50 -05:00
|
|
|
});
|
|
|
|
|
2024-02-03 14:25:47 -05:00
|
|
|
// Send reference of stack to all children
|
|
|
|
stack.children = Object.fromEntries(
|
2024-02-27 16:55:01 -05:00
|
|
|
OSDList.map((osd) => {
|
2024-02-27 18:27:47 -05:00
|
|
|
const widget = osd();
|
2024-02-27 16:55:01 -05:00
|
|
|
|
|
|
|
return [widget.name, widget];
|
|
|
|
}),
|
2024-02-03 14:25:47 -05:00
|
|
|
);
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-11-27 22:02:28 -05:00
|
|
|
// Delay popup method so it
|
|
|
|
// doesn't show any OSDs at launch
|
|
|
|
timeout(1000, () => {
|
|
|
|
let count = 0;
|
2023-11-10 23:51:50 -05:00
|
|
|
|
2024-02-27 16:55:01 -05:00
|
|
|
stack.attribute.popup = (osd: string) => {
|
2023-11-27 22:02:28 -05:00
|
|
|
++count;
|
2024-02-27 16:55:01 -05:00
|
|
|
stack.shown = osd;
|
2023-11-27 22:02:28 -05:00
|
|
|
App.openWindow('osd');
|
2023-11-10 23:51:50 -05:00
|
|
|
|
2023-11-27 22:02:28 -05:00
|
|
|
timeout(HIDE_DELAY, () => {
|
|
|
|
--count;
|
2023-11-10 23:51:50 -05:00
|
|
|
|
2023-11-27 22:02:28 -05:00
|
|
|
if (count === 0) {
|
|
|
|
App.closeWindow('osd');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
2024-02-27 16:55:01 -05:00
|
|
|
|
|
|
|
globalThis['popup_osd'] = stack.attribute.popup;
|
2023-11-27 22:02:28 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
return stack;
|
2023-11-10 23:51:50 -05:00
|
|
|
};
|
2023-11-27 22:02:28 -05:00
|
|
|
|
|
|
|
export default () => PopupWindow({
|
|
|
|
name: 'osd',
|
|
|
|
anchor: ['bottom'],
|
|
|
|
exclusivity: 'ignore',
|
2023-12-18 23:20:32 -05:00
|
|
|
close_on_unfocus: 'stay',
|
2023-11-27 22:02:28 -05:00
|
|
|
transition: 'slide_up',
|
2024-01-02 16:40:12 -05:00
|
|
|
transition_duration,
|
2024-01-02 18:37:12 -05:00
|
|
|
bezier: 'ease',
|
2024-01-29 18:54:07 -05:00
|
|
|
content: OSDs(),
|
2023-11-27 22:02:28 -05:00
|
|
|
});
|