2023-11-10 23:51:50 -05:00
|
|
|
import App from 'resource:///com/github/Aylur/ags/app.js';
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-11-10 23:51:50 -05:00
|
|
|
import { timeout } from 'resource:///com/github/Aylur/ags/utils.js';
|
|
|
|
import { Stack } from 'resource:///com/github/Aylur/ags/widget.js';
|
|
|
|
|
2024-01-13 23:38:31 -05:00
|
|
|
import PopupWindow from '../misc/popup.ts';
|
2024-01-29 20:56:56 -05:00
|
|
|
|
|
|
|
// Types
|
|
|
|
import { BoxGeneric, StackGeneric } 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-01-29 20:56:56 -05:00
|
|
|
const OSDList = [] as Array<(stack: StackGeneric) => 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-01-29 20:56:56 -05:00
|
|
|
attribute: { popup: (osd: BoxGeneric) => {
|
2024-01-29 21:00:56 -05:00
|
|
|
if (!osd) {
|
|
|
|
console.log();
|
|
|
|
}
|
2024-01-29 20:56:56 -05:00
|
|
|
} },
|
2023-11-10 23:51:50 -05:00
|
|
|
});
|
|
|
|
|
2023-12-23 01:14:21 -05:00
|
|
|
// Send reference of stack to all items
|
2023-11-27 22:02:28 -05:00
|
|
|
stack.items = OSDList.map((osd, i) => [`${i}`, osd(stack)]);
|
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-01-29 20:56:56 -05:00
|
|
|
stack.attribute.popup = (osd: BoxGeneric) => {
|
2023-11-27 22:02:28 -05:00
|
|
|
++count;
|
|
|
|
stack.set_visible_child(osd);
|
|
|
|
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');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
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
|
|
|
});
|