// noinspection JSUnresolvedVariable let Selected = 0; let Applications = []; let self = { GetAppsList: () => { let Applications1 = require('fs').readdirSync(global._STRAWBERRY_APPLICATIONS_ROOT).filter((i) => { return i.endsWith(".app") && require('fs').lstatSync(global._STRAWBERRY_APPLICATIONS_ROOT + "/" + i).isDirectory(); }); let Applications2 = require('fs').readdirSync(global._STRAWBERRY_SYSTEMAPPS_ROOT).filter((i) => { return i.endsWith(".app") && require('fs').lstatSync(global._STRAWBERRY_SYSTEMAPPS_ROOT + "/" + i).isDirectory(); }); Applications = [...Applications1, ...Applications2].sort((a, b) => a.localeCompare(b)); }, Init: () => { Selected = 0; self.GetAppsList(); }, Spawn: () => { load("Strawberry.DisplayRaw"); Strawberry.DisplayRaw.Write(color.bgWhite.black("┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓"), 1, 1) let line = 1; let appIndex = 0; for (let application of Applications) { line++; let appName = application.substring(0, 48); appName = appName.substring(0, appName.length - 4); if (appIndex === Selected) { Strawberry.DisplayRaw.Write(color.bgWhite.black("┃ " + color.bgBlue.white(" " + appName + " ".repeat(48 - appName.length) + " ") + " ┃"), 1, line); } else { Strawberry.DisplayRaw.Write(color.bgWhite.black("┃ " + appName + " ".repeat(48 - appName.length) + " ┃"), 1, line); } appIndex++; } Strawberry.DisplayRaw.Write(color.bgWhite.black("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫"), 1, line + 1) Strawberry.DisplayRaw.Write(color.bgWhite.black("┃ Strawberry OS " + Strawberry.SystemInfo.Version() + " ".repeat(34 - Strawberry.SystemInfo.Version().length) + " ┃"), 1, line + 2) Strawberry.DisplayRaw.Write(color.bgWhite.black("┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛"), 1, line + 3) }, GoUp: () => { Strawberry.Audio.SystemSound("Strawberry.Menu.Select") if (Selected > 0) { Selected--; } else { Selected = Applications.length - 1; } self.Spawn(); }, GoDown: () => { Strawberry.Audio.SystemSound("Strawberry.Menu.Select") if (Selected < Applications.length - 1) { Selected++; } else { Selected = 0; } self.Spawn(); }, Open: () => { Strawberry.Audio.SystemSound("Strawberry.Menu.Click") let line = 2 + Selected; let appName = Applications[Selected].substring(0, 48); appName = appName.substring(0, appName.length - 4); setTimeout(() => { self._OpenActive(appName, line); setTimeout(() => { self._OpenInactive(appName, line); setTimeout(() => { self._OpenActive(appName, line); setTimeout(() => { self._OpenInactive(appName, line); setTimeout(() => { self._OpenActive(appName, line); setTimeout(() => { self._OpenInactive(appName, line); setTimeout(() => { global._STRAWBERRY_APPMENU_OPEN = false; console.clear(); Strawberry.WhenLoaded(); Strawberry.MenuBar.Reset(); if (fs.existsSync(global._STRAWBERRY_APPLICATIONS_ROOT + "/" + appName + ".app")) { Strawberry.AppManager.Start(global._STRAWBERRY_APPLICATIONS_ROOT + "/" + appName + ".app"); } else { Strawberry.AppManager.Start(global._STRAWBERRY_SYSTEMAPPS_ROOT + "/" + appName + ".app"); } }, 30); }, 30); }, 30); }, 30); }, 30); }, 30); }, 30); }, _OpenActive: (appName, line) => { Strawberry.DisplayRaw.Write(color.bgWhite.black("┃ " + color.bgCyan.white(" " + appName + " ".repeat(48 - appName.length) + " ") + " ┃"), 1, line); }, _OpenInactive: (appName, line) => { Strawberry.DisplayRaw.Write(color.bgWhite.black("┃ " + appName + " ".repeat(48 - appName.length) + " ┃"), 1, line); } } module.exports = self;