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';
|
|
|
|
|
|
|
|
import PopupWindow from '../misc/popup.js';
|
|
|
|
|
2023-11-27 22:02:28 -05:00
|
|
|
// Import all the OSDs as an array
|
|
|
|
const OSDList = [];
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-11-27 22:02:28 -05:00
|
|
|
import * as Modules from './osds.js';
|
|
|
|
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;
|
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',
|
2023-11-10 23:51:50 -05:00
|
|
|
transitionDuration: 200,
|
|
|
|
});
|
|
|
|
|
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
|
|
|
stack.popup = () => { /**/ };
|
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
|
|
|
|
2023-11-27 22:02:28 -05:00
|
|
|
stack.popup = (osd) => {
|
|
|
|
++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',
|
2023-12-18 23:20:32 -05:00
|
|
|
transition_duration: 200,
|
2023-11-27 22:02:28 -05:00
|
|
|
child: OSDs(),
|
|
|
|
});
|