From fb534a8b7c064edd9c23c1c4c3fd6aa3aa679293 Mon Sep 17 00:00:00 2001 From: "Damian A. Pastorini" Date: Tue, 23 Jul 2024 06:59:26 +0200 Subject: [PATCH 001/315] - Reldens - v4.0.0 - Maps Wizard WIP. --- lib/admin/server/admin-manager.js | 51 +++++++++++++++++- lib/admin/server/admin-translations.js | 1 + lib/admin/server/templates-list.js | 1 + theme/admin/reldens-admin-client.scss | 16 ++++++ theme/admin/templates/maps-wizard.html | 72 ++++++++++++++++++++++++++ 5 files changed, 139 insertions(+), 2 deletions(-) create mode 100644 theme/admin/templates/maps-wizard.html diff --git a/lib/admin/server/admin-manager.js b/lib/admin/server/admin-manager.js index 48f3da52..d4680961 100644 --- a/lib/admin/server/admin-manager.js +++ b/lib/admin/server/admin-manager.js @@ -60,6 +60,7 @@ class AdminManager this.savePath = '/save'; this.deletePath = '/delete'; this.managementPath = '/management'; + this.mapsWizardPath = '/maps-wizard'; this.adminEntitiesGenerator = new AdminEntitiesGenerator(); this.uploaderFactory = new UploaderFactory(); } @@ -139,6 +140,7 @@ class AdminManager this.adminContents.login = await this.buildLogin(); this.adminContents.dashboard = await this.buildDashboard(); this.adminContents.management = await this.buildManagement(); + this.adminContents.mapsWizard = await this.buildMapsWizard(); this.adminContents.entities = await this.buildEntitiesContents(); } @@ -160,7 +162,14 @@ class AdminManager async buildSideBar() { - let navigationContents = {}; + let navigationContents = { + 'Wizards': { + [this.translations.labels['mapsWizard']]: await this.render( + this.adminFilesContents.sideBarItem, + {name: this.translations.labels['mapsWizard'], path: this.rootPath+this.mapsWizardPath} + ) + } + }; for(let driverResource of this.resources){ let navigation = driverResource.options?.navigation; let name = this.translations.labels[driverResource.id()] || this.translations.labels[driverResource.entityKey]; @@ -180,7 +189,7 @@ class AdminManager {name, path} ); } - navigationContents['Server'] = {'Maintenance': await this.render( + navigationContents['Server'] = {'Management': await this.render( this.adminFilesContents.sideBarItem, {name: this.translations.labels['management'], path: this.rootPath+this.managementPath} )}; @@ -265,6 +274,27 @@ class AdminManager ); } + async buildMapsWizard() + { + let pageContent = await this.render( + this.adminFilesContents.mapsWizard, + { + actionPath: this.rootPath+this.mapsWizardPath + } + ); + return await this.render( + this.adminContents.layout, + { + sideBar: this.adminContents.sideBar, + pageContent, + stylesFilePath: this.stylesFilePath, + scriptsFilePath: this.scriptsFilePath, + brandingCompanyName: this.branding.companyName, + copyRight: this.branding.copyRight + } + ); + } + async buildEntitiesContents() { let entitiesContents = {}; @@ -571,6 +601,23 @@ class AdminManager return res.redirect(redirectManagementPath+'?result=success'); } ); + // maps-wizard routes: + this.adminRouter.get( + this.mapsWizardPath, + this.isAuthenticated.bind(this), + async (req, res) => { + let rendererContent = await this.render(this.adminContents.mapsWizard, this.fetchShuttingDownData()); + return res.send(rendererContent); + } + ); + this.adminRouter.post( + this.mapsWizardPath, + this.isAuthenticated.bind(this), + async (req, res) => { + let redirectManagementPath = this.rootPath+this.mapsWizardPath; + return res.redirect(redirectManagementPath+'?result=success'); + } + ); // apply the adminRouter to the /admin path: this.app.use(this.rootPath, this.adminRouter); } diff --git a/lib/admin/server/admin-translations.js b/lib/admin/server/admin-translations.js index 134a1512..a78412a7 100644 --- a/lib/admin/server/admin-translations.js +++ b/lib/admin/server/admin-translations.js @@ -29,6 +29,7 @@ class AdminTranslations loginWelcome: 'Reldens', pages: 'Server Management', management: 'Management', + mapsWizard: 'Maps Generation', shuttingDown: 'Server is shutting down in:', submitShutdownLabel: 'Shutdown Server', submitCancelLabel: 'Cancel Server Shutdown', diff --git a/lib/admin/server/templates-list.js b/lib/admin/server/templates-list.js index 17592419..dc94fc4d 100644 --- a/lib/admin/server/templates-list.js +++ b/lib/admin/server/templates-list.js @@ -8,6 +8,7 @@ module.exports.TemplatesList = { login: 'login.html', dashboard: 'dashboard.html', management: 'management.html', + mapsWizard: 'maps-wizard.html', list: 'list.html', listContent: 'list-content.html', view: 'view.html', diff --git a/theme/admin/reldens-admin-client.scss b/theme/admin/reldens-admin-client.scss index 90ddf7da..6ea61b2d 100644 --- a/theme/admin/reldens-admin-client.scss +++ b/theme/admin/reldens-admin-client.scss @@ -500,6 +500,22 @@ $darkGreen: #27ae60; } } + + textarea { + position: relative; + display: block; + width: 98%; + padding: 1%; + margin: 1rem 0; + } + } + + .maps-wizard { + .main-option { + display: inline-block; + cursor: pointer; + margin-bottom: 1rem; + } } .entity-view, .entity-edit { diff --git a/theme/admin/templates/maps-wizard.html b/theme/admin/templates/maps-wizard.html new file mode 100644 index 00000000..2707bc10 --- /dev/null +++ b/theme/admin/templates/maps-wizard.html @@ -0,0 +1,72 @@ +

Maps Wizard

+
+
+
+
+

What would you like to do?

+
    +
  • + + +
    +
    + + +
    +
    + + +
    +
    +
  • +
  • + + +
    +
    + + +
    +
    + + +
    +
    +
  • +
  • + + +
  • +
  • + + +
  • + +
+ + +
+
+
+
From 8c77e9c08cda393eb07fb3f020b7c52b3a298bea Mon Sep 17 00:00:00 2001 From: "Damian A. Pastorini" Date: Tue, 23 Jul 2024 22:51:49 +0200 Subject: [PATCH 002/315] - Reldens - v4.0.0 - Maps Wizard WIP. --- lib/admin/server/admin-manager.js | 56 ++++--------------------------- lib/game/server/login-manager.js | 4 +-- 2 files changed, 8 insertions(+), 52 deletions(-) diff --git a/lib/admin/server/admin-manager.js b/lib/admin/server/admin-manager.js index d4680961..4791f46b 100644 --- a/lib/admin/server/admin-manager.js +++ b/lib/admin/server/admin-manager.js @@ -33,7 +33,7 @@ class AdminManager secret = ''; useSecureLogin = false; rootPath = ''; - adminRoleId = null; + adminRoleId = 0; buildAdminScriptsOnActivation = null; buildAdminCssOnActivation = null; buckets = null; @@ -220,32 +220,12 @@ class AdminManager async buildLogin() { - return await this.render( - this.adminContents.layout, - { - sideBar: '', - pageContent: this.adminFilesContents.login, - stylesFilePath: this.stylesFilePath, - scriptsFilePath: this.scriptsFilePath, - brandingCompanyName: this.branding.companyName, - copyRight: this.branding.copyRight - } - ); + return await this.renderRoute(this.adminFilesContents.login, ''); } async buildDashboard() { - return await this.render( - this.adminContents.layout, - { - sideBar: this.adminContents.sideBar, - pageContent: this.adminFilesContents.dashboard, - stylesFilePath: this.stylesFilePath, - scriptsFilePath: this.scriptsFilePath, - brandingCompanyName: this.branding.companyName, - copyRight: this.branding.copyRight - } - ); + return await this.renderRoute(this.adminContents.dashboard, this.adminContents.sideBar); } async buildManagement() @@ -261,17 +241,7 @@ class AdminManager submitType: '{{&submitType}}' } ); - return await this.render( - this.adminContents.layout, - { - sideBar: this.adminContents.sideBar, - pageContent, - stylesFilePath: this.stylesFilePath, - scriptsFilePath: this.scriptsFilePath, - brandingCompanyName: this.branding.companyName, - copyRight: this.branding.copyRight - } - ); + return await this.renderRoute(pageContent, this.adminContents.sideBar); } async buildMapsWizard() @@ -282,17 +252,7 @@ class AdminManager actionPath: this.rootPath+this.mapsWizardPath } ); - return await this.render( - this.adminContents.layout, - { - sideBar: this.adminContents.sideBar, - pageContent, - stylesFilePath: this.stylesFilePath, - scriptsFilePath: this.scriptsFilePath, - brandingCompanyName: this.branding.companyName, - copyRight: this.branding.copyRight - } - ); + return await this.renderRoute(pageContent, this.adminContents.sideBar); } async buildEntitiesContents() @@ -515,11 +475,7 @@ class AdminManager { // apply session middleware only to /admin routes: this.adminRouter = this.applicationFramework.Router(); - this.adminRouter.use(this.session({ - secret: this.secret, - resave: false, - saveUninitialized: true - })); + this.adminRouter.use(this.session({secret: this.secret, resave: false, saveUninitialized: true})); this.adminRouter.use(this.bodyParser.json()); // route for the login page: this.adminRouter.get(this.loginPath, async (req, res) => { diff --git a/lib/game/server/login-manager.js b/lib/game/server/login-manager.js index f9f4ff06..6eaf4ccb 100644 --- a/lib/game/server/login-manager.js +++ b/lib/game/server/login-manager.js @@ -182,10 +182,10 @@ class LoginManager } } - async roleAuthenticationCallback(email, password, roleId = false) + async roleAuthenticationCallback(email, password, roleId = 0) { let user = await this.usersManager.loadUserByEmail(email); - let validatedRole = !roleId || String(user.role_id) === String(roleId); + let validatedRole = 0 === roleId || String(user.role_id) === String(roleId); if(user && validatedRole){ let result = this.passwordManager.validatePassword( password, From dccbfca2f84a95e5a36b8b8ab3fb1fa3ce90f7ac Mon Sep 17 00:00:00 2001 From: "Damian A. Pastorini" Date: Tue, 23 Jul 2024 23:34:41 +0200 Subject: [PATCH 003/315] - Reldens - v4.0.0 - Maps Wizard WIP. --- lib/admin/server/admin-manager.js | 245 +++++++++++-------------- theme/admin/reldens-admin-client.js | 15 ++ theme/admin/reldens-admin-client.scss | 12 ++ theme/admin/templates/maps-wizard.html | 25 ++- 4 files changed, 146 insertions(+), 151 deletions(-) diff --git a/lib/admin/server/admin-manager.js b/lib/admin/server/admin-manager.js index 4791f46b..0cc5b9c1 100644 --- a/lib/admin/server/admin-manager.js +++ b/lib/admin/server/admin-manager.js @@ -501,91 +501,79 @@ class AdminManager res.redirect(this.rootPath+this.loginPath); }); // management routes: - this.adminRouter.get( - this.managementPath, - this.isAuthenticated.bind(this), - async (req, res) => { - let management = this.adminContents.management; - let rendererContent = await this.render(management, this.fetchShuttingDownData()); - return res.send(rendererContent); + this.adminRouter.get(this.managementPath, this.isAuthenticated.bind(this), async (req, res) => { + let management = this.adminContents.management; + let rendererContent = await this.render(management, this.fetchShuttingDownData()); + return res.send(rendererContent); + }); + this.adminRouter.post(this.managementPath, this.isAuthenticated.bind(this), async (req, res) => { + this.shutdownTime = req.body['shutdown-time']; + let redirectManagementPath = this.rootPath+this.managementPath; + if(!this.shutdownTime){ + return res.redirect(redirectManagementPath+'?result=shutdownError'); } - ); - this.adminRouter.post( - this.managementPath, - this.isAuthenticated.bind(this), - async (req, res) => { - this.shutdownTime = req.body['shutdown-time']; - let redirectManagementPath = this.rootPath+this.managementPath; - if(!this.shutdownTime){ - return res.redirect(redirectManagementPath+'?result=shutdownError'); - } - if(0 < this.shuttingDownIn){ - clearInterval(this.shutdownInterval); - clearTimeout(this.shutdownTimeout); - this.shuttingDownIn = 0; - return res.redirect(redirectManagementPath+'?result=success'); - } - await this.broadcastShutdownMessage(); - this.shutdownTimeout = setTimeout( - async () => { - Logger.info('Server is shutting down by request on the administration panel.', sc.getTime()); - if(this.broadcastCallback && sc.isFunction(this.broadcastCallback)){ - await this.broadcastCallback({message: 'Server Offline.'}); - } - throw new Error('Server shutdown by request on the administration panel.'); - }, - this.shutdownTime * 1000 - ); - this.shutdownInterval = setInterval( - async () => { - this.shuttingDownIn--; - Logger.info('Server is shutting down in '+this.shuttingDownIn+' seconds.'); - if( - 0 < this.shuttingDownIn - && (this.shuttingDownIn <= 5 || Math.ceil(this.shutdownTime / 2) === this.shuttingDownIn) - ){ - await this.broadcastShutdownMessage(); - } - if(0 === this.shuttingDownIn){ - Logger.info('Server OFF at: '+ sc.getTime()); - clearInterval(this.shutdownInterval); - } - }, - 1000 - ); - this.shuttingDownIn = this.shutdownTime; + if(0 < this.shuttingDownIn){ + clearInterval(this.shutdownInterval); + clearTimeout(this.shutdownTimeout); + this.shuttingDownIn = 0; return res.redirect(redirectManagementPath+'?result=success'); } - ); + await this.broadcastShutdownMessage(); + this.shutdownTimeout = setTimeout( + async () => { + Logger.info('Server is shutting down by request on the administration panel.', sc.getTime()); + if(this.broadcastCallback && sc.isFunction(this.broadcastCallback)){ + await this.broadcastCallback({message: 'Server Offline.'}); + } + throw new Error('Server shutdown by request on the administration panel.'); + }, + this.shutdownTime * 1000 + ); + this.shutdownInterval = setInterval( + async () => { + this.shuttingDownIn--; + Logger.info('Server is shutting down in '+this.shuttingDownIn+' seconds.'); + if( + 0 < this.shuttingDownIn + && (this.shuttingDownIn <= 5 || Math.ceil(this.shutdownTime / 2) === this.shuttingDownIn) + ){ + await this.broadcastShutdownMessage(); + } + if(0 === this.shuttingDownIn){ + Logger.info('Server OFF at: '+ sc.getTime()); + clearInterval(this.shutdownInterval); + } + }, + 1000 + ); + this.shuttingDownIn = this.shutdownTime; + return res.redirect(redirectManagementPath+'?result=success'); + }); // maps-wizard routes: - this.adminRouter.get( - this.mapsWizardPath, - this.isAuthenticated.bind(this), - async (req, res) => { - let rendererContent = await this.render(this.adminContents.mapsWizard, this.fetchShuttingDownData()); - return res.send(rendererContent); - } - ); - this.adminRouter.post( - this.mapsWizardPath, - this.isAuthenticated.bind(this), - async (req, res) => { - let redirectManagementPath = this.rootPath+this.mapsWizardPath; - return res.redirect(redirectManagementPath+'?result=success'); - } - ); + this.adminRouter.get(this.mapsWizardPath, this.isAuthenticated.bind(this), async (req, res) => { + let rendererContent = await this.render(this.adminContents.mapsWizard, this.fetchShuttingDownData()); + return res.send(rendererContent); + }); + this.adminRouter.post(this.mapsWizardPath, this.isAuthenticated.bind(this), async (req, res) => { + let redirectManagementPath = this.rootPath+this.mapsWizardPath; + return res.redirect(redirectManagementPath+'?result=success'); + }); // apply the adminRouter to the /admin path: this.app.use(this.rootPath, this.adminRouter); } async broadcastShutdownMessage() { - if(this.broadcastCallback && sc.isFunction(this.broadcastCallback)){ - let shuttingDownTime = 0 === this.shuttingDownIn ? this.shutdownTime : this.shuttingDownIn; - await this.broadcastCallback({ - message: 'Server is shutting down in ' + shuttingDownTime + ' seconds.' - }); + let shuttingDownTime = 0 === this.shuttingDownIn ? this.shutdownTime : this.shuttingDownIn; + await this.broadcastSystemMessage('Server is shutting down in ' + shuttingDownTime + ' seconds.'); + } + + async broadcastSystemMessage(message) + { + if(!this.broadcastCallback || !sc.isFunction(this.broadcastCallback)){ + return; } + await this.broadcastCallback({message}); } fetchShuttingDownData() @@ -614,53 +602,33 @@ class AdminManager for(let driverResource of this.resources){ let entityPath = driverResource.entityPath; let entityRoute = '/'+entityPath; - this.adminRouter.get( - entityRoute, - this.isAuthenticated.bind(this), - async (req, res) => { - let routeContents = await this.generateListRouteContent(req, driverResource, entityPath); - return res.send(routeContents); - } - ); - this.adminRouter.post( - entityRoute, - this.isAuthenticated.bind(this), - async (req, res) => { - let routeContents = await this.generateListRouteContent(req, driverResource, entityPath); - return res.send(routeContents); - } - ); - this.adminRouter.get( - entityRoute+this.viewPath, - this.isAuthenticated.bind(this), - async (req, res) => { - let routeContents = await this.generateViewRouteContent(req, driverResource, entityPath); - if('' === routeContents){ - return res.redirect(this.rootPath+'/'+entityPath+'?result=errorView'); - } - return res.send(routeContents); + this.adminRouter.get(entityRoute, this.isAuthenticated.bind(this), async (req, res) => { + let routeContents = await this.generateListRouteContent(req, driverResource, entityPath); + return res.send(routeContents); + }); + this.adminRouter.post(entityRoute, this.isAuthenticated.bind(this), async (req, res) => { + let routeContents = await this.generateListRouteContent(req, driverResource, entityPath); + return res.send(routeContents); + }); + this.adminRouter.get(entityRoute+this.viewPath, this.isAuthenticated.bind(this), async (req, res) => { + let routeContents = await this.generateViewRouteContent(req, driverResource, entityPath); + if('' === routeContents){ + return res.redirect(this.rootPath+'/'+entityPath+'?result=errorView'); } - ); - this.adminRouter.get( - entityRoute+this.editPath, - this.isAuthenticated.bind(this), - async (req, res) => { - let routeContents = await this.generateEditRouteContent(req, driverResource, entityPath); - if('' === routeContents){ - return res.redirect(this.rootPath+'/'+entityPath+'?result=errorEdit'); - } - return res.send(routeContents); + return res.send(routeContents); + }); + this.adminRouter.get(entityRoute+this.editPath, this.isAuthenticated.bind(this), async (req, res) => { + let routeContents = await this.generateEditRouteContent(req, driverResource, entityPath); + if('' === routeContents){ + return res.redirect(this.rootPath+'/'+entityPath+'?result=errorEdit'); } - ); + return res.send(routeContents); + }); this.setupSavePath(entityRoute, driverResource, entityPath); - this.adminRouter.post( - entityRoute+this.deletePath, - this.isAuthenticated.bind(this), - async (req, res) => { - let redirectResult = await this.processDeleteEntities(req, res, driverResource, entityPath); - return res.redirect(redirectResult); - } - ); + this.adminRouter.post(entityRoute+this.deletePath, this.isAuthenticated.bind(this), async (req, res) => { + let redirectResult = await this.processDeleteEntities(req, res, driverResource, entityPath); + return res.redirect(redirectResult); + }); } } @@ -976,17 +944,15 @@ class AdminManager let totalPages = Math.ceil(await this.countTotalEntities(driverResource) / pageSize); let pages = this.getPageRange(page, totalPages); let renderedPagination = ''; - if(0 < pages.length){ - for (let page of pages){ - renderedPagination += await this.render( - this.adminFilesContents.fields.view['link'], - { - fieldName: page.label, - fieldValue: this.rootPath+'/'+driverResource.entityPath+'?page='+ page.value, - fieldOriginalValue: page.value, - } - ); - } + for(let page of pages){ + renderedPagination += await this.render( + this.adminFilesContents.fields.view['link'], + { + fieldName: page.label, + fieldValue: this.rootPath+'/'+driverResource.entityPath+'?page='+ page.value, + fieldOriginalValue: page.value, + } + ); } let listVars = { deletePath: this.rootPath + '/' + driverResource.entityPath + this.deletePath, @@ -1004,10 +970,7 @@ class AdminManager listRawContent, Object.assign({list, pagination: renderedPagination}, ...mappedFiltersValues) ); - return await this.renderRoute( - entitiesListView, - this.adminContents.sideBar - ); + return await this.renderRoute(entitiesListView, this.adminContents.sideBar); } getPageRange(page, totalPages) @@ -1226,15 +1189,15 @@ class AdminManager return allowContinue.callback(event); } let user = req.session?.user; - if(user){ - let userBlackList = this.blackList[user.role_id] || []; - if(-1 !== userBlackList.indexOf(req.path)){ - let referrer = String(req.headers?.referer || ''); - return res.redirect('' !== referrer ? referrer : returnPath); - } - return next(); + if(!user){ + return res.redirect(returnPath); + } + let userBlackList = this.blackList[user.role_id] || []; + if(-1 !== userBlackList.indexOf(req.path)){ + let referrer = String(req.headers?.referer || ''); + return res.redirect('' !== referrer ? referrer : returnPath); } - res.redirect(returnPath); + return next(); } prepareFilters(filtersList, driverResource) diff --git a/theme/admin/reldens-admin-client.js b/theme/admin/reldens-admin-client.js index 613c59d6..e878ccf8 100644 --- a/theme/admin/reldens-admin-client.js +++ b/theme/admin/reldens-admin-client.js @@ -166,4 +166,19 @@ window.addEventListener('DOMContentLoaded', () => { ); } } + + // maps wizards options display behavior: + let mapsWizardsOptions = document.querySelectorAll('.maps-wizard-form .map-wizard-option'); + if(mapsWizardsOptions){ + for(let option of mapsWizardsOptions){ + option.addEventListener('click', (event) => { + let wizardOptionsContainer = document.querySelectorAll('.wizard-option-container'); + for(let container of wizardOptionsContainer){ + container.classList.remove('active'); + } + event.currentTarget.parentNode.classList.add('active'); + }); + } + } + }); diff --git a/theme/admin/reldens-admin-client.scss b/theme/admin/reldens-admin-client.scss index 6ea61b2d..ebbdfbaf 100644 --- a/theme/admin/reldens-admin-client.scss +++ b/theme/admin/reldens-admin-client.scss @@ -516,6 +516,18 @@ $darkGreen: #27ae60; cursor: pointer; margin-bottom: 1rem; } + + li { + .maps-wizard-option-content { + display: none; + } + + &.active { + .maps-wizard-option-content { + display: block; + } + } + } } .entity-view, .entity-edit { diff --git a/theme/admin/templates/maps-wizard.html b/theme/admin/templates/maps-wizard.html index 2707bc10..f235f964 100644 --- a/theme/admin/templates/maps-wizard.html +++ b/theme/admin/templates/maps-wizard.html @@ -10,12 +10,12 @@

Maps Wizard

What would you like to do?

    -
  • - +
  • + -
    +
    @@ -26,12 +26,12 @@

    Maps Wizard

  • -
  • - +
  • + -
    +
    @@ -42,17 +42,21 @@

    Maps Wizard

  • -
  • - +
  • + +
    +
  • -
  • - +
  • + +
    +
- - +
+ + +
+
+ + +
+ +
+ \ No newline at end of file From ccd38c0babc2f7d04fcda3024ca59087cdc0c5de Mon Sep 17 00:00:00 2001 From: "Damian A. Pastorini" Date: Mon, 29 Jul 2024 19:39:27 +0200 Subject: [PATCH 005/315] - Reldens - v4.0.0 - Maps Wizard WIP, restore authentication on administration panel static assets. --- lib/admin/server/admin-manager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/admin/server/admin-manager.js b/lib/admin/server/admin-manager.js index 100a054c..562db490 100644 --- a/lib/admin/server/admin-manager.js +++ b/lib/admin/server/admin-manager.js @@ -577,12 +577,12 @@ class AdminManager // set generated paths to be available in the admin this.adminRouter.use( '/generate-data', - //this.isAuthenticated.bind(this), + this.isAuthenticated.bind(this), express.static(this.themeManager.projectGenerateDataPath) ); this.adminRouter.use( '/generated', - //this.isAuthenticated.bind(this), + this.isAuthenticated.bind(this), express.static(this.themeManager.projectGeneratedDataPath) ); Logger.info( From 815b211a166a5d5be41563ccb4322f7711b88c08 Mon Sep 17 00:00:00 2001 From: "Damian A. Pastorini" Date: Mon, 29 Jul 2024 22:33:12 +0200 Subject: [PATCH 006/315] - Reldens - v4.0.0 - Maps Wizard WIP, Generate a SINGLE random map with Layer Elements Composite Loader. --- lib/admin/server/admin-manager.js | 21 +++- lib/admin/server/admin-translations.js | 2 +- theme/admin/reldens-admin-client.scss | 15 ++- theme/admin/templates/maps-wizard.html | 153 ++++++++++++++++--------- 4 files changed, 132 insertions(+), 59 deletions(-) diff --git a/lib/admin/server/admin-manager.js b/lib/admin/server/admin-manager.js index 562db490..291a98d5 100644 --- a/lib/admin/server/admin-manager.js +++ b/lib/admin/server/admin-manager.js @@ -649,13 +649,32 @@ class AdminManager let generatorWithData = false; let generatedMap = false; try { + let handlerParams = {mapData, rootFolder: this.themeManager.projectGenerateDataPath}; if('elements-object-loader' === selectedHandler){ - let loader = new handler({mapData, rootFolder: this.themeManager.projectGenerateDataPath}); + let loader = new handler(handlerParams); await loader.load(); let generator = new RandomMapGenerator(loader.mapData); generatedMap = await generator.generate(); generatorWithData = generator; } + if('elements-composite-loader' === selectedHandler){ + let loader = new handler(handlerParams); + await loader.load(); + let generator = new RandomMapGenerator(); + await generator.fromElementsProvider(loader.mapData); + await generator.generate(); + generatorWithData = generator; + } + if('multiple-by-loader' === selectedHandler){ + let generator = new MultipleByLoaderGenerator({loaderData: handlerParams}); + await generator.generate(); + generatorWithData = generator; + } + if('multiple-with-association-by-loader' === selectedHandler){ + let generator = new MultipleWithAssociationsByLoaderGenerator({loaderData: handlerParams}); + await generator.generate(); + generatorWithData = generator; + } } catch (error) { Logger.error('Maps generator error.', selectedHandler, generatorData, error); return this.mapsWizardRedirect(res, 'mapsWizardGeneratorError'); diff --git a/lib/admin/server/admin-translations.js b/lib/admin/server/admin-translations.js index a78412a7..3274befa 100644 --- a/lib/admin/server/admin-translations.js +++ b/lib/admin/server/admin-translations.js @@ -29,7 +29,7 @@ class AdminTranslations loginWelcome: 'Reldens', pages: 'Server Management', management: 'Management', - mapsWizard: 'Maps Generation', + mapsWizard: 'Maps Generation and Import', shuttingDown: 'Server is shutting down in:', submitShutdownLabel: 'Shutdown Server', submitCancelLabel: 'Cancel Server Shutdown', diff --git a/theme/admin/reldens-admin-client.scss b/theme/admin/reldens-admin-client.scss index caf5d216..0cd45200 100644 --- a/theme/admin/reldens-admin-client.scss +++ b/theme/admin/reldens-admin-client.scss @@ -35,9 +35,9 @@ $darkGreen: #27ae60; display: none; position: absolute; top: 1.5rem; - right: 1.5rem; - padding: 1rem 2rem; - border-radius: 8px; + right: 0; + padding: 1rem 5rem 1rem 2rem; + border-radius: 8px 0 0 8px; font-size: 14px; &.success, &.error { @@ -56,8 +56,8 @@ $darkGreen: #27ae60; .close { position: absolute; - top: 0.5rem; - right: 0.5rem; + top: 1rem; + right: 1rem; cursor: pointer; font-weight: $bold; } @@ -531,6 +531,11 @@ $darkGreen: #27ae60; flex-direction: column; list-style: none; + input.map-wizard-option { + position: relative; + top: 2px; + } + label { cursor: pointer; } diff --git a/theme/admin/templates/maps-wizard.html b/theme/admin/templates/maps-wizard.html index f84ff62d..1e79d771 100644 --- a/theme/admin/templates/maps-wizard.html +++ b/theme/admin/templates/maps-wizard.html @@ -45,24 +45,65 @@

Maps Wizard

- Note and disclaimer:
- In the examples above all the tileset JSON files use the same tileset image (this is because we used the already optimized version of the tileset).
+ Note:
+ In the examples above, all the tileset JSON files use the same tileset image (this is because we used the already optimized version of the tileset).
+ Case disclaimer: In theory, it should also work if each element has its own image, but this still needs to be tested.
For now, you can use the composite option to use multiple tileset images and those will be merged by the generator which use the Tile Map Optimizer.

  • - +
  • - + @@ -71,7 +112,7 @@

    Maps Wizard

  • - + @@ -106,51 +147,59 @@

    Maps Wizard