From 3b03b11b7d2cebe3595a38ad2cccc37b38e2c1b9 Mon Sep 17 00:00:00 2001 From: IntegerLimit <103940576+IntegerLimit@users.noreply.github.com> Date: Sat, 21 Oct 2023 15:08:14 +1100 Subject: [PATCH] Update Custom Main Menu Per Update (#468) [COMBINE] commits = ["fbd1584e7baed4a3603e3c810066603185f1b230"] [COMBINE] --- overrides/config/CustomMainMenu/mainmenu.json | 213 +++++++++--------- tools/gulpfile.ts | 2 + tools/package-lock.json | 20 +- tools/package.json | 4 +- tools/tasks/misc/releaseCommit.ts | 33 ++- tools/templates/mainmenu.json | 150 ++++++++++++ 6 files changed, 309 insertions(+), 113 deletions(-) create mode 100644 tools/templates/mainmenu.json diff --git a/overrides/config/CustomMainMenu/mainmenu.json b/overrides/config/CustomMainMenu/mainmenu.json index d9e1a31..caf8b58 100644 --- a/overrides/config/CustomMainMenu/mainmenu.json +++ b/overrides/config/CustomMainMenu/mainmenu.json @@ -1,118 +1,119 @@ { + "_comment": "DO NOT EDIT THIS FILE! EDIT THE TEMPlATES INSTEAD! See https://github.com/Nomi-CEu/Nomi-CEu/wiki/Part-1:-Contributing-Information#section-5-template-information!", + "buttons": { + "akliz": { + "action": { + "link": "https://www.akliz.net/nomifactory", + "type": "openLink" + }, + "alignment": "left_center", + "height": 20, + "posX": 4, + "posY": 50, + "text": "Rent Your Own Nomifactory Server!", + "width": 240 + }, + "discord": { + "action": { + "link": "https://discord.gg/zwQzqP8b6q", + "type": "openLink" + }, + "alignment": "left_center", + "height": 20, + "posX": 4, + "posY": 26, + "text": "Join Us On Discord!", + "width": 120 + }, + "mods": { + "action": { + "gui": "mods", + "type": "openGui" + }, + "alignment": "left_center", + "height": 20, + "posX": 4, + "posY": -22, + "text": "fml.menu.mods", + "width": 120 + }, + "multiplayer": { + "action": { + "gui": "multiplayer", + "type": "openGui" + }, + "alignment": "left_center", + "height": 20, + "posX": 125, + "posY": -46, + "text": "menu.multiplayer", + "width": 120 + }, + "options": { + "action": { + "gui": "options", + "type": "openGui" + }, + "alignment": "left_center", + "height": 20, + "posX": 125, + "posY": -22, + "text": "menu.options", + "width": 120 + }, + "quit": { + "action": { + "type": "quit" + }, + "alignment": "left_center", + "height": 20, + "posX": 4, + "posY": 74, + "text": "menu.quit", + "width": 240 + }, + "singleplayer": { + "action": { + "gui": "singleplayer", + "type": "openGui" + }, + "alignment": "left_center", + "height": 20, + "posX": 4, + "posY": -46, + "text": "menu.singleplayer", + "width": 120 + }, + "update": { + "action": { + "link": "https://github.com/Nomi-CEu/Nomi-CEu/releases/tag/1.6.1a", + "type": "openLink" + }, + "alignment": "left_center", + "height": 20, + "posX": 125, + "posY": 26, + "text": "Update Changes", + "width": 120 + } + }, "images": { "title": { + "alignment": "top_center", + "height": 79, "image": "minecraft:textures/gui/title/top.png", "posX": -150, "posY": 4, - "width": 300, - "height": 79, - "alignment": "top_center" - } - }, - "buttons": { - "singleplayer": { - "text": "menu.singleplayer", - "posX": 4, - "posY": -46, - "width": 120, - "height": 20, - "alignment": "left_center", - "action": { - "type": "openGui", - "gui": "singleplayer" - } - }, - "multiplayer": { - "text": "menu.multiplayer", - "posX": 125, - "posY": -46, - "width": 120, - "height": 20, - "alignment": "left_center", - "action": { - "type": "openGui", - "gui": "multiplayer" - } - }, - "mods": { - "text": "fml.menu.mods", - "posX": 4, - "posY": -22, - "width": 120, - "height": 20, - "alignment": "left_center", - "action": { - "type": "openGui", - "gui": "mods" - } - }, - "options": { - "text": "menu.options", - "posX": 125, - "posY": -22, - "width": 120, - "height": 20, - "alignment": "left_center", - "action": { - "type": "openGui", - "gui": "options" - } - }, - "quit": { - "text": "menu.quit", - "posX": 4, - "posY": 74, - "width": 240, - "height": 20, - "alignment": "left_center", - "action": { - "type": "quit" - } - }, - "update": { - "text": "Update Changes", - "posX": 125, - "posY": 26, - "width": 120, - "height": 20, - "alignment": "left_center", - "action": { - "type": "openLink", - "link": "https://github.com/Nomi-CEu/nomi-ceu/releases/tag/1.6" - } - }, - "discord": { - "text": "Join Us On Discord!", - "posX": 4, - "posY": 26, - "width": 120, - "height": 20, - "alignment": "left_center", - "action": { - "type": "openLink", - "link": "https://discord.gg/zwQzqP8b6q" - } - }, - "akliz": { - "text": "Rent Your Own Nomifactory Server!", - "posX": 4, - "posY": 50, - "width": 240, - "height": 20, - "alignment": "left_center", - "action": { - "type": "openLink", - "link": "https://www.akliz.net/nomifactory" - } + "width": 300 } }, "labels": { "mojang": { - "text": "Copyright Mojang AB. Do not distribute!", + "alignment": "bottom_right", + "color": -1, "posX": -197, "posY": -10, - "color": -1, - "alignment": "bottom_right" + "text": "Copyright Mojang AB. Do not distribute!" } }, "other": { @@ -121,7 +122,6 @@ "slideshow": { "displayDuration": 100, "fadeDuration": 40, - "shuffle" : true, "images": [ "minecraft:textures/gui/title/background/besoiobiy_1.png", "minecraft:textures/gui/title/background/besoiobiy_2.png", @@ -143,8 +143,9 @@ "minecraft:textures/gui/title/background/pgs_2.png", "minecraft:textures/gui/title/background/qr_est.png", "minecraft:textures/gui/title/background/supasem.png" - ] + ], + "shuffle": true } } } -} +} \ No newline at end of file diff --git a/tools/gulpfile.ts b/tools/gulpfile.ts index 454bc78..027b4c8 100644 --- a/tools/gulpfile.ts +++ b/tools/gulpfile.ts @@ -15,6 +15,7 @@ export const checkRelease = releaseCommit.check; export const addVersionIssue = gulp.series(checkRelease, releaseCommit.updateIssueTemplates); export const addVersionRandomPatches = gulp.series(checkRelease, releaseCommit.updateRandomPatchesConfig); export const addVersionServer = gulp.series(checkRelease, releaseCommit.updateServerProperties); +export const addVersionMainMenu = gulp.series(checkRelease, releaseCommit.updateMainMenuConfig); export const addVersionAll = gulp.series(checkRelease, releaseCommit.updateAll); // Non Release Tasks @@ -22,6 +23,7 @@ const setNotRelease = releaseCommit.setNotRelease; export const updateTemplatesIssue = gulp.series(setNotRelease, addVersionIssue); export const updateTemplatesRandomPatches = gulp.series(setNotRelease, addVersionRandomPatches); export const updateTemplatesServer = gulp.series(setNotRelease, addVersionServer); +export const updateTemplatesMainMenu = gulp.series(setNotRelease, addVersionMainMenu); export const updateTemplatesAll = gulp.series(setNotRelease, addVersionAll); import * as changelog from "./tasks/changelog/createChangelog"; diff --git a/tools/package-lock.json b/tools/package-lock.json index bb1081a..55db4ca 100644 --- a/tools/package-lock.json +++ b/tools/package-lock.json @@ -11,7 +11,9 @@ "dependencies": { "@egjs/list-differ": "^1.0.1", "@ltd/j-toml": "^1.38.0", - "dedent-js": "^1.0.1" + "@types/json-stable-stringify-without-jsonify": "^1.0.1", + "dedent-js": "^1.0.1", + "json-stable-stringify-without-jsonify": "^1.0.1" }, "devDependencies": { "@octokit/rest": "^18.3.5", @@ -613,6 +615,11 @@ "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", "dev": true }, + "node_modules/@types/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@types/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-SOnWV7/4szUZaf9qKd+HWah42YdP0unUnu0tBhcZwyBIqP5nfJvoABOM8GOPbY3uCzU0mtFKi/E56q2EKTfNQw==" + }, "node_modules/@types/md5": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/@types/md5/-/md5-2.3.2.tgz", @@ -7043,8 +7050,7 @@ "node_modules/json-stable-stringify-without-jsonify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", - "dev": true + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==" }, "node_modules/json-stringify-safe": { "version": "5.0.1", @@ -12303,6 +12309,11 @@ "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", "dev": true }, + "@types/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@types/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-SOnWV7/4szUZaf9qKd+HWah42YdP0unUnu0tBhcZwyBIqP5nfJvoABOM8GOPbY3uCzU0mtFKi/E56q2EKTfNQw==" + }, "@types/md5": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/@types/md5/-/md5-2.3.2.tgz", @@ -17355,8 +17366,7 @@ "json-stable-stringify-without-jsonify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", - "dev": true + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==" }, "json-stringify-safe": { "version": "5.0.1", diff --git a/tools/package.json b/tools/package.json index 904cd6e..68e39c3 100644 --- a/tools/package.json +++ b/tools/package.json @@ -52,6 +52,8 @@ "dependencies": { "@egjs/list-differ": "^1.0.1", "@ltd/j-toml": "^1.38.0", - "dedent-js": "^1.0.1" + "@types/json-stable-stringify-without-jsonify": "^1.0.1", + "dedent-js": "^1.0.1", + "json-stable-stringify-without-jsonify": "^1.0.1" } } diff --git a/tools/tasks/misc/releaseCommit.ts b/tools/tasks/misc/releaseCommit.ts index 581350a..c869df1 100644 --- a/tools/tasks/misc/releaseCommit.ts +++ b/tools/tasks/misc/releaseCommit.ts @@ -5,6 +5,7 @@ import mustache from "mustache"; import gulp from "gulp"; import dedent from "dedent-js"; import { checkEnvironmentalVariables } from "../../util/util"; +import sortedStringify from "json-stable-stringify-without-jsonify"; // This updates all the files, for a release. @@ -204,4 +205,34 @@ export async function updateServerProperties(): Promise { await modifyFile(readPathExpert, [writePathExpert], replacementObject); } -export const updateAll = gulp.series(updateIssueTemplates, updateRandomPatchesConfig, updateServerProperties); +export async function updateMainMenuConfig(): Promise { + // Filename & paths + const fileName = "mainmenu.json"; + const readPath: string = upath.join(templatesFolder, fileName); + const writePath: string = upath.join(rootDirectory, configFolder, "CustomMainMenu", fileName); + + // Replacement object + const replacementObject: Record = { + version: version, + }; + + // Read file + const data: string = await fs.promises.readFile(readPath, "utf8"); + + // Moustache Render + const modifiedData = JSON.parse(mustache.render(data, replacementObject)); + + // Add warning to not edit file + modifiedData["_comment"] = + "DO NOT EDIT THIS FILE! EDIT THE TEMPlATES INSTEAD! See https://github.com/Nomi-CEu/Nomi-CEu/wiki/Part-1:-Contributing-Information#section-5-template-information!"; + + // Sort keys so that comment appears first + return await fs.promises.writeFile(writePath, sortedStringify(modifiedData, { space: 2 }), "utf8"); +} + +export const updateAll = gulp.series( + updateIssueTemplates, + updateRandomPatchesConfig, + updateServerProperties, + updateMainMenuConfig, +); diff --git a/tools/templates/mainmenu.json b/tools/templates/mainmenu.json new file mode 100644 index 0000000..6445d53 --- /dev/null +++ b/tools/templates/mainmenu.json @@ -0,0 +1,150 @@ +{ + "images": { + "title": { + "image": "minecraft:textures/gui/title/top.png", + "posX": -150, + "posY": 4, + "width": 300, + "height": 79, + "alignment": "top_center" + } + }, + "buttons": { + "singleplayer": { + "text": "menu.singleplayer", + "posX": 4, + "posY": -46, + "width": 120, + "height": 20, + "alignment": "left_center", + "action": { + "type": "openGui", + "gui": "singleplayer" + } + }, + "multiplayer": { + "text": "menu.multiplayer", + "posX": 125, + "posY": -46, + "width": 120, + "height": 20, + "alignment": "left_center", + "action": { + "type": "openGui", + "gui": "multiplayer" + } + }, + "mods": { + "text": "fml.menu.mods", + "posX": 4, + "posY": -22, + "width": 120, + "height": 20, + "alignment": "left_center", + "action": { + "type": "openGui", + "gui": "mods" + } + }, + "options": { + "text": "menu.options", + "posX": 125, + "posY": -22, + "width": 120, + "height": 20, + "alignment": "left_center", + "action": { + "type": "openGui", + "gui": "options" + } + }, + "quit": { + "text": "menu.quit", + "posX": 4, + "posY": 74, + "width": 240, + "height": 20, + "alignment": "left_center", + "action": { + "type": "quit" + } + }, + "update": { + "text": "Update Changes", + "posX": 125, + "posY": 26, + "width": 120, + "height": 20, + "alignment": "left_center", + "action": { + "type": "openLink", + "link": "https://github.com/Nomi-CEu/Nomi-CEu/releases/tag/{{version}}" + } + }, + "discord": { + "text": "Join Us On Discord!", + "posX": 4, + "posY": 26, + "width": 120, + "height": 20, + "alignment": "left_center", + "action": { + "type": "openLink", + "link": "https://discord.gg/zwQzqP8b6q" + } + }, + "akliz": { + "text": "Rent Your Own Nomifactory Server!", + "posX": 4, + "posY": 50, + "width": 240, + "height": 20, + "alignment": "left_center", + "action": { + "type": "openLink", + "link": "https://www.akliz.net/nomifactory" + } + } + }, + "labels": { + "mojang": { + "text": "Copyright Mojang AB. Do not distribute!", + "posX": -197, + "posY": -10, + "color": -1, + "alignment": "bottom_right" + } + }, + "other": { + "background": { + "image": "", + "slideshow": { + "displayDuration": 100, + "fadeDuration": 40, + "shuffle" : true, + "images": [ + "minecraft:textures/gui/title/background/besoiobiy_1.png", + "minecraft:textures/gui/title/background/besoiobiy_2.png", + "minecraft:textures/gui/title/background/cactus_cool.png", + "minecraft:textures/gui/title/background/cobracreeper1.png", + "minecraft:textures/gui/title/background/darkarkangel.png", + "minecraft:textures/gui/title/background/ely_1.png", + "minecraft:textures/gui/title/background/ely_2.png", + "minecraft:textures/gui/title/background/ely_3.png", + "minecraft:textures/gui/title/background/emiuna.png", + "minecraft:textures/gui/title/background/extracoolcat_1.png", + "minecraft:textures/gui/title/background/extracoolcat_2.png", + "minecraft:textures/gui/title/background/extracoolcat_3.png", + "minecraft:textures/gui/title/background/extracoolcat_4.png", + "minecraft:textures/gui/title/background/gaboggamer.png", + "minecraft:textures/gui/title/background/itstheguywhoasked.png", + "minecraft:textures/gui/title/background/lyeo.png", + "minecraft:textures/gui/title/background/pgs_1.png", + "minecraft:textures/gui/title/background/pgs_2.png", + "minecraft:textures/gui/title/background/qr_est.png", + "minecraft:textures/gui/title/background/supasem.png" + ] + } + } + } +}