diff --git a/extensions/community/CustomizableConfig.json b/extensions/community/CustomizableConfig.json new file mode 100644 index 00000000..f0d5211c --- /dev/null +++ b/extensions/community/CustomizableConfig.json @@ -0,0 +1,472 @@ +{ + "author": "", + "category": "General", + "extensionNamespace": "", + "fullName": "Customizable Config", + "helpPath": "", + "iconUrl": "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0ibWRpLXdyZW5jaCIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiB2aWV3Qm94PSIwIDAgMjQgMjQiPjxwYXRoIGQ9Ik0yMi43LDE5TDEzLjYsOS45QzE0LjUsNy42IDE0LDQuOSAxMi4xLDNDMTAuMSwxIDcuMSwwLjYgNC43LDEuN0w5LDZMNiw5TDEuNiw0LjdDMC40LDcuMSAwLjksMTAuMSAyLjksMTIuMUM0LjgsMTQgNy41LDE0LjUgOS44LDEzLjZMMTguOSwyMi43QzE5LjMsMjMuMSAxOS45LDIzLjEgMjAuMywyMi43TDIyLjYsMjAuNEMyMy4xLDIwIDIzLjEsMTkuMyAyMi43LDE5WiIgLz48L3N2Zz4=", + "name": "CustomizableConfig", + "previewIconUrl": "https://asset-resources.gdevelop.io/public-resources/Icons/0ce0ace369dff774e31b30c216c060d99c82e08336debc5848938e8c06e7fb51_wrench.svg", + "shortDescription": "Allow players to modify game resolution & quality for themselves.", + "version": "0.1.0", + "description": [ + "This extension ports Unity's Game Resolution Dialog to GDevelop, allow for players to choose their Game's Resolution & Quality/Graphics based on their hardware.", + "", + "_Note:", + "Start Button - Closes Dialog", + "Close Button - Closes the Game", + "This is meant to be shown at the beginning of a scene, which is why the buttons are like this currently, change is coming soon_" + ], + "tags": [], + "authorIds": [ + "wJNvBw2TGEZ09MUQUZDv8c12dig1" + ], + "dependencies": [], + "globalVariables": [], + "sceneVariables": [], + "eventsFunctions": [ + { + "description": "Opens a menu overlayed on top of your game, this menu allows the player to config the game resolution, quality, and fullscreen.", + "fullName": "Open the Game Configuration Menu", + "functionType": "Action", + "name": "CreateMenu", + "sentence": "Open the Game Config Menu", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BuiltinCommonInstructions::Once" + }, + "parameters": [] + } + ], + "actions": [], + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "// console.log(runtimeScene);", + "", + "function __createGameDialog() {", + " // Create and append styles", + " const style = document.createElement('style');", + " style.textContent = `", + " p, button, label, fieldset {", + " font-family: Arial;", + " color: white;", + " }", + "", + " @keyframes fadeIn {", + " from {", + " opacity: 0;", + " pointer-events: none;", + " top: 60%;", + " }", + " to {", + " opacity: 1;", + " pointer-events: all;", + " top: 50%;", + " }", + " }", + "", + " @keyframes fadeOut {", + " from {", + " opacity: 1;", + " pointer-events: all;", + " top: 50%;", + " }", + " to {", + " opacity: 0;", + " pointer-events: none;", + " top: 60%;", + " }", + " }", + "", + " .fadeOut {", + " animation: fadeOut 0.5s ease-out forwards;", + " }", + "", + " .dialog {", + " width: 50%;", + " height: 400px;", + " background-color: #000000aa;", + " display: flex;", + " flex-direction: column;", + " position: fixed;", + " left: 50%;", + " top: 50%;", + " transform: translate(-50%, -50%);", + " border: 1px solid #adadad;", + " border-radius: 20px;", + " box-shadow: 0px 0px 20px #000000;", + " align-items: center;", + " animation: fadeIn 0.5s ease-out forwards;", + " z-index: 5;", + " }", + "", + " .title {", + " text-shadow: 0px 0px 10px #ffffffcc;", + " }", + "", + " .title-bar {", + " width: 100%;", + " border-bottom: 1px solid #adadad;", + " display: flex;", + " align-items: center;", + " justify-content: center;", + " }", + "", + " .banner {", + " width: calc(100% - 20px);", + " height: 100px;", + " background-color: #00000050;", + " border: 1px solid #adadadcc;", + " border-radius: 10px;", + " margin: 10px;", + " display: flex;", + " align-items: center;", + " justify-content: center;", + " }", + "", + " select, input {", + " margin-bottom: 10px;", + " }", + "", + " fieldset {", + " width: 90%;", + " height: 190px;", + " display: flex;", + " flex-direction: column;", + " border: 1px solid #adadad;", + " border-radius: 20px;", + " align-items: center;", + " justify-content: center;", + " gap: 7px;", + " }", + "", + " button {", + " background-color: #ffffff00;", + " border: 1px solid #adadad;", + " border-radius: 7px;", + " padding: 10px;", + " padding-top: 7px;", + " padding-bottom: 7px;", + " width: 70px;", + " font-size: 15px;", + " transition-duration: 0.2s;", + " }", + "", + " button:hover {", + " background-color: #ffffff20;", + " scale: 1.05;", + " }", + "", + " button:active {", + " background-color: #00000020;", + " scale: 0.95;", + " }", + " `;", + " document.head.appendChild(style);", + " ", + " // Create dialog container", + " const dialog = document.createElement('div');", + " dialog.className = 'dialog';", + " dialog.id = 'config-menu';", + "", + " // Create title bar", + " const titleBar = document.createElement('div');", + " titleBar.className = 'title-bar';", + " const title = document.createElement('p');", + " title.className = 'title';", + " title.textContent = eventsFunctionContext.getArgument('Title');", + " titleBar.appendChild(title);", + " dialog.appendChild(titleBar);", + "", + " // Create banner", + " const banner = document.createElement('div');", + " banner.className = 'banner';", + "", + " if (eventsFunctionContext.getArgument('BannerColor') !== \"\") {", + " banner.style.backgroundColor = eventsFunctionContext.getArgument('BannerColor');", + " };", + "", + " // console.log(eventsFunctionContext.getArgument('BannerImage'));", + "", + " if (eventsFunctionContext.getArgument('BannerImage') === \"\") {", + " const bannerText = document.createElement('p');", + " bannerText.textContent = eventsFunctionContext.getArgument('Title');", + " banner.appendChild(bannerText);", + " } else {", + " banner.style.backgroundImage = 'url(' + eventsFunctionContext.getArgument('BannerImage') + ')';", + " };", + "", + " dialog.appendChild(banner);", + "", + " // Create fieldset", + " const fieldset = document.createElement('fieldset');", + " const legend = document.createElement('legend');", + " legend.textContent = 'Game Config';", + " fieldset.appendChild(legend);", + "", + " // Create resolution selection", + " const resolutionDiv = document.createElement('div');", + " const resolutionLabel = document.createElement('label');", + " resolutionLabel.setAttribute('for', 'resolution');", + " resolutionLabel.textContent = 'Game Resolution:';", + " const resolutionSelect = document.createElement('select');", + " resolutionSelect.id = 'resolution';", + " const resolutions = [", + " \"1920x1080 (16:9)\",", + " \"1280x720 (16:9)\",", + " \"1024x640 (16:9)\",", + " \"1280x1024 (5:4)\",", + " \"720x576 (5:4)\",", + " \"1024x768 (16:10)\",", + " \"1600x1050 (4:3)\",", + " \"1280x960 (4:3)\",", + " \"1024x768 (4:3)\",", + " \"800x600 (4:3)\",", + " \"640x480 (4:3)\",", + " \"320x240 (4:3)\"", + " ];", + " resolutions.forEach(res => {", + " const option = document.createElement('option');", + " option.value = res.split(' ')[0]; // Set value to resolution only", + " option.textContent = res;", + " resolutionSelect.appendChild(option);", + " });", + " resolutionDiv.appendChild(resolutionLabel);", + " resolutionDiv.appendChild(resolutionSelect);", + " fieldset.appendChild(resolutionDiv);", + "", + " // Create quality selection", + " const qualityDiv = document.createElement('div');", + " const qualityLabel = document.createElement('label');", + " qualityLabel.setAttribute('for', 'quality');", + " qualityLabel.textContent = 'Game Quality:';", + " const qualitySelect = document.createElement('select');", + " qualitySelect.id = 'quality';", + " const qualities = [\"Best <3\", \"Good\", \"Okay\", \"Microwave :3\"];", + " qualities.forEach(q => {", + " const option = document.createElement('option');", + " option.value = q.toLowerCase(); // Set value to lowercase", + " option.textContent = q;", + " qualitySelect.appendChild(option);", + " });", + " qualityDiv.appendChild(qualityLabel);", + " qualityDiv.appendChild(qualitySelect);", + " fieldset.appendChild(qualityDiv);", + "", + " // Create fullscreen checkbox", + " const fullscreenDiv = document.createElement('div');", + " const fullscreenLabel = document.createElement('label');", + " fullscreenLabel.setAttribute('for', 'fullscreen');", + " fullscreenLabel.textContent = 'Fullscreen:';", + " const fullscreenInput = document.createElement('input');", + " fullscreenInput.id = 'fullscreen';", + " fullscreenInput.type = 'checkbox';", + " fullscreenDiv.appendChild(fullscreenLabel);", + " fullscreenDiv.appendChild(fullscreenInput);", + " fieldset.appendChild(fullscreenDiv);", + "", + " // Create buttons", + " const buttonDiv = document.createElement('div');", + "", + " // const testButton = document.createElement('button');", + " // testButton.id = 'test-config';", + " // testButton.textContent = 'Test';", + "", + " const startButton = document.createElement('button');", + " // startButton.id = 'start-gd-game';", + " startButton.textContent = 'Start';", + " startButton.onclick = __configStart;", + "", + " const closeButton = document.createElement('button');", + " // closeButton.id = 'close-gd-game';", + " closeButton.textContent = 'Close';", + " closeButton.onclick = __configClose;", + "", + " // buttonDiv.appendChild(testButton);", + " buttonDiv.appendChild(startButton);", + " buttonDiv.appendChild(closeButton);", + " fieldset.appendChild(buttonDiv);", + "", + " // Append fieldset to dialog", + " dialog.appendChild(fieldset);", + "", + " // Append dialog to body", + " document.body.appendChild(dialog);", + "}", + "", + "// Call the function to create the dialog", + "__createGameDialog();", + "", + "function __configStart() {", + " // setGameConfig();", + " // runtimeScene.getVariablesForExtension().get('__setGameConfig').setBoolean(true);", + " // runtimeScene.getGame()._sceneStack.replace(eventsFunctionContext.getArgument('Scene'), false)", + " // runtimeScene.getVariables().get(eventsFunctionContext.getArgument('Result')).setBoolean(true);", + " document.getElementById('config-menu').classList.add('fadeOut')", + " setTimeout(function() {", + " document.getElementById('config-menu').remove();", + " }, 500)", + "}", + "", + "function __configClose() {", + " runtimeScene.getGame().getRenderer().stopGame();", + "}", + "" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": true + } + ] + } + ], + "parameters": [ + { + "description": "Menu Title", + "name": "Title", + "type": "string" + }, + { + "description": "Banner Image", + "name": "BannerImage", + "type": "imageResource" + }, + { + "description": "Banner Background Color ", + "longDescription": "This is the Background Color for the Banner, resort to using this if the image isn't big enough or you don't have one. (Write in hexadecimal (#FFFFFF), alpha is supported!)", + "name": "BannerColor", + "type": "string" + }, + { + "description": "Result", + "longDescription": "As soon as the player clicks Start, the selected variable will be set to True (Boolean).\nNote: This extension is in beta, thus this particular parameter doesn't work as of now.", + "name": "Result", + "type": "variable" + } + ], + "objectGroups": [] + }, + { + "fullName": "", + "functionType": "Action", + "name": "onScenePostEvents", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "CustomizableConfig::setGameConfig" + }, + "parameters": [ + "", + "" + ] + } + ] + }, + { + "disabled": true, + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "__setGameConfig", + "True", + "" + ] + }, + { + "type": { + "value": "BuiltinCommonInstructions::Once" + }, + "parameters": [] + } + ], + "actions": [ + { + "type": { + "value": "CustomizableConfig::setGameConfig" + }, + "parameters": [ + "", + "" + ] + }, + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "__setGameConfig", + "False", + "" + ] + } + ] + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "fullName": "", + "functionType": "Action", + "name": "setGameConfig", + "private": true, + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "function setGameConfig() {", + " const conf__gameResolution = document.getElementById('resolution').value;", + " const conf__gameQuality = document.getElementById('quality').value;", + " const conf__mustFullscreen = document.getElementById('fullscreen').checked;", + "", + " const [conf__winWidth, conf__winHeight] = conf__gameResolution.split('x').map(Number);", + "", + " runtimeScene.getGame().setGameResolutionSize(conf__winWidth, conf__winHeight);", + " runtimeScene.getVariables().get('gameQuality').setString(conf__gameQuality);", + " runtimeScene.getGame().getRenderer().setFullScreen(conf__mustFullscreen);", + "};", + "", + "if (document.getElementById('config-menu')) {", + " setGameConfig();", + "}", + "", + "// document.getElementById('test-config').addEventListener('click', setGameConfig());", + "", + "// document.getElementById('start-gd-game').addEventListener('click', function() {", + "// setGameConfig();", + "// // runtimeScene.getGame()._sceneStack.replace(eventsFunctionContext.getArgument('Scene'), false)", + "// runtimeScene.getVariables().get(window.conf__resultForStart).setBoolean(true);", + "// });", + "", + "// document.getElementById('close-gd-game').addEventListener('click', function() {", + "// runtimeScene.getGame().getRenderer().stopGame();", + "// });" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + } + ], + "eventsBasedBehaviors": [], + "eventsBasedObjects": [] +} \ No newline at end of file