diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 341e0615b..40ff7176c 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -1,5 +1,10 @@ # Change Log +## Version 3.9.1 - Nov 30, 2020 + +* Check if a new version is available at startup. +* *Check For Updates* is a new option in the main menu. It shows a message if there is a new version. + ## Version 3.9.0 - Nov 24, 2020 ### Added diff --git a/source/editor/plugins/colibri/ColibriPlugin.ts b/source/editor/plugins/colibri/ColibriPlugin.ts deleted file mode 100644 index 356df62f9..000000000 --- a/source/editor/plugins/colibri/ColibriPlugin.ts +++ /dev/null @@ -1,76 +0,0 @@ -/// -/// - -namespace colibri { - - export const ICON_FILE = "file"; - export const ICON_FOLDER = "folder"; - export const ICON_PLUS = "plus"; - export const ICON_MINUS = "minus"; - export const ICON_CHECKED = "checked"; - export const ICON_MENU = "menu"; - export const ICON_SMALL_MENU = "small-menu"; - export const ICON_KEYMAP = "keymap"; - export const ICON_CONTROL_TREE_COLLAPSE = "tree-collapse"; - export const ICON_CONTROL_TREE_EXPAND = "tree-expand"; - export const ICON_CONTROL_CLOSE = "close"; - export const ICON_CONTROL_DIRTY = "dirty"; - - export class ColibriPlugin extends colibri.Plugin { - - private static _instance; - - static getInstance() { - return this._instance ?? (this._instance = new ColibriPlugin()); - } - - private _openingProject: boolean; - - private constructor() { - super("colibri"); - - this._openingProject = false; - } - - registerExtensions(reg: colibri.ExtensionRegistry) { - - reg.addExtension( - colibri.ui.ide.IconLoaderExtension.withPluginFiles(this, [ - ICON_FILE, - ICON_FOLDER, - ICON_PLUS, - ICON_MINUS, - ICON_CHECKED, - ICON_MENU, - ICON_SMALL_MENU, - ICON_KEYMAP, - ICON_CONTROL_TREE_COLLAPSE, - ICON_CONTROL_TREE_EXPAND, - ICON_CONTROL_CLOSE, - ICON_CONTROL_DIRTY - ]) - ); - - // themes - - reg.addExtension( - new colibri.ui.ide.themes.ThemeExtension(colibri.ui.controls.Controls.LIGHT_THEME), - new colibri.ui.ide.themes.ThemeExtension(colibri.ui.controls.Controls.DARK_THEME) - ); - - // keys - - reg.addExtension( - new colibri.ui.ide.commands.CommandExtension( - ui.ide.actions.ColibriCommands.registerCommands - ) - ); - - // editor inputs - - reg.addExtension(new colibri.ui.ide.FileEditorInputExtension()); - } - } - - Platform.addPlugin(ColibriPlugin.getInstance()); -} \ No newline at end of file diff --git a/source/editor/plugins/colibri/src/ui/controls/dialogs/AlertDialog.ts b/source/editor/plugins/colibri/src/ui/controls/dialogs/AlertDialog.ts index e7fe54629..5eb8fd3dc 100644 --- a/source/editor/plugins/colibri/src/ui/controls/dialogs/AlertDialog.ts +++ b/source/editor/plugins/colibri/src/ui/controls/dialogs/AlertDialog.ts @@ -34,6 +34,11 @@ namespace colibri.ui.controls.dialogs { }); } + setMessage(text: string) { + + this._messageElement.innerHTML = text; + } + static replaceConsoleAlert() { window["__alert"] = window.alert; diff --git a/source/editor/plugins/colibri/src/ui/controls/dialogs/Dialog.ts b/source/editor/plugins/colibri/src/ui/controls/dialogs/Dialog.ts index 52a635c50..26c426190 100644 --- a/source/editor/plugins/colibri/src/ui/controls/dialogs/Dialog.ts +++ b/source/editor/plugins/colibri/src/ui/controls/dialogs/Dialog.ts @@ -237,6 +237,11 @@ namespace colibri.ui.controls.dialogs { } } + isClosed() { + + return !this.getElement().isConnected; + } + protected goFront() { // nothing } diff --git a/source/editor/plugins/colibri/src/ui/ide/Workbench.ts b/source/editor/plugins/colibri/src/ui/ide/Workbench.ts index 887ac3ef4..d5e887606 100644 --- a/source/editor/plugins/colibri/src/ui/ide/Workbench.ts +++ b/source/editor/plugins/colibri/src/ui/ide/Workbench.ts @@ -79,6 +79,27 @@ namespace colibri.ui.ide { return this._projectPreferences; } + showNotification(text: string) { + + const element = document.createElement("div"); + element.classList.add("Notification"); + element.innerHTML = text; + + document.body.appendChild(element); + + element.classList.add("FadeInEffect"); + + element.addEventListener("click", () => element.remove()); + + setTimeout(() => { + + element.classList.add("FadeOutEffect"); + + setTimeout(() => element.remove(), 4000); + + }, 4000); + } + async launch() { console.log("Workbench: starting."); diff --git a/source/editor/plugins/colibri/styles/controls.css b/source/editor/plugins/colibri/styles/controls.css index 39d4087b2..3ae584da4 100644 --- a/source/editor/plugins/colibri/styles/controls.css +++ b/source/editor/plugins/colibri/styles/controls.css @@ -336,20 +336,19 @@ div.TabPaneTitleBar::-webkit-scrollbar { height: 10px; } -/* Dialog */ +/* Dialog & Notification */ -.DialogContainer { +.Notification { + z-index: 10000; position: absolute; - z-index: 1000; - left: 0px; - right: 0px; - width: 100%; - height: 100%; + bottom: 30px; + right: 30px; + padding: 20px; + border-radius: 3px; } -.Dialog { - position: absolute; - z-index: 1001; +.Dialog, +.Notification { border-radius: 5px; border-width: 1px; border-color: rgba(0, 0, 0, 0.5); @@ -361,6 +360,20 @@ div.TabPaneTitleBar::-webkit-scrollbar { } +.DialogContainer { + position: absolute; + z-index: 1000; + left: 0px; + right: 0px; + width: 100%; + height: 100%; +} + +.Dialog { + position: absolute; + z-index: 1001; +} + .Dialog { display: grid; grid-template-columns: 5px 1fr 5px; @@ -523,4 +536,35 @@ div.TabPaneTitleBar::-webkit-scrollbar { .MenuItemSeparator { height: 1px; +} + +/* Effects */ + +.FadeInEffect { + animation: fadein 2s; +} + +.FadeOutEffect { + animation: fadeout 2s; + opacity: 0; +} + + +@keyframes fadein { + from { + opacity: 0; + } + + to { + opacity: 1; + } +} +@keyframes fadeout { + from { + opacity: 1; + } + + to { + opacity: 0; + } } \ No newline at end of file diff --git a/source/editor/plugins/phasereditor2d.ide/src/IDEPlugin.ts b/source/editor/plugins/phasereditor2d.ide/src/IDEPlugin.ts index 773533f8a..4b96914f7 100644 --- a/source/editor/plugins/phasereditor2d.ide/src/IDEPlugin.ts +++ b/source/editor/plugins/phasereditor2d.ide/src/IDEPlugin.ts @@ -127,6 +127,24 @@ namespace phasereditor2d.ide { this._licenseActivated = data.unlocked === true; } + async requestUpdateAvailable() { + + if (this.isDesktopMode()) { + + if (await this.isNewUpdateAvailable()) { + + colibri.Platform.getWorkbench().showNotification("A new version is available!"); + } + } + } + + async isNewUpdateAvailable() { + + const data = await colibri.core.io.apiRequest("GetNewVersionAvailable"); + + return data.available; + } + isLicenseActivated() { return this._licenseActivated; @@ -317,7 +335,7 @@ namespace phasereditor2d.ide { /* program entry point */ - export const VER = "3.9.0"; + export const VER = "3.9.1"; async function main() { @@ -331,13 +349,14 @@ namespace phasereditor2d.ide { "background-color:silver", ); - colibri.ui.controls.dialogs.AlertDialog.replaceConsoleAlert(); await IDEPlugin.getInstance().requestServerMode(); await colibri.Platform.start(); await IDEPlugin.getInstance().openFirstWindow(); + + await IDEPlugin.getInstance().requestUpdateAvailable(); } window.addEventListener("load", main); diff --git a/source/editor/plugins/phasereditor2d.ide/src/ui/actions/OpenMainMenuAction.ts b/source/editor/plugins/phasereditor2d.ide/src/ui/actions/OpenMainMenuAction.ts index 67c4d857c..b6408aabc 100644 --- a/source/editor/plugins/phasereditor2d.ide/src/ui/actions/OpenMainMenuAction.ts +++ b/source/editor/plugins/phasereditor2d.ide/src/ui/actions/OpenMainMenuAction.ts @@ -51,6 +51,20 @@ namespace phasereditor2d.ide.ui.actions { } })); + menu.add(new controls.Action({ + text: "Check For Updates", + callback: async () => { + + const dlg = new controls.dialogs.AlertDialog(); + dlg.create(); + dlg.setTitle("Updates"); + dlg.setMessage("Checking for updates..."); + + const available = await IDEPlugin.getInstance().isNewUpdateAvailable(); + + dlg.setMessage(available ? "A new version is available!" : "Updates not found."); + } + })); } menu.add(new controls.Action({