diff --git a/extensions/community/Lista.json b/extensions/community/Lista.json new file mode 100644 index 000000000..2843adfe0 --- /dev/null +++ b/extensions/community/Lista.json @@ -0,0 +1,361 @@ +{ + "author": "", + "category": "General", + "extensionNamespace": "", + "fullName": "Lista Scrolling", + "gdevelopVersion": "", + "helpPath": "", + "iconUrl": "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0ibWRpLWZvcm1hdC1saXN0LWJ1bGxldGVkLXNxdWFyZSIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiB2aWV3Qm94PSIwIDAgMjQgMjQiPjxwYXRoIGQ9Ik0zLDRIN1Y4SDNWNE05LDVWN0gyMVY1SDlNMywxMEg3VjE0SDNWMTBNOSwxMVYxM0gyMVYxMUg5TTMsMTZIN1YyMEgzVjE2TTksMTdWMTlIMjFWMTdIOSIgLz48L3N2Zz4=", + "name": "Lista", + "previewIconUrl": "https://asset-resources.gdevelop.io/public-resources/Icons/a449911169181f2bd2c1b4e707a0c02b3c331138694fa612fe4d87094e3de7ab_format-list-bulleted-square.svg", + "shortDescription": "Crie listas com scrolling de forma simples.", + "version": "1.0.0", + "description": [ + "# Criar Lista (por Game Tutorial)", + "", + "Extensão para criação e gerenciamento de listas dinâmicas usando JavaScript, HTML e CSS.", + "", + "## Recursos", + "- Criar listas com **ID personalizado**", + "- Adicionar itens", + "- Excluir itens", + "- Atualizar / reconstruir lista", + "- Salvar lista localmente", + "- Carregar lista salva", + "", + "", + "" + ], + "tags": [ + "list", + "lista", + "scroll", + "scrolling", + "listas", + "criar listas" + ], + "authorIds": [ + "kaXHa9ThbydpHsnmHCGyWb0XCpm2" + ], + "dependencies": [], + "globalVariables": [], + "sceneVariables": [], + "eventsFunctions": [ + { + "description": "Cria uma Lista.", + "fullName": "Criar Lista", + "functionType": "Action", + "name": "Criar_Lista", + "sentence": "Criar a lista _PARAM1_ na posição _PARAM2_ e _PARAM3_, com largura de _PARAM4_ e Altura _PARAM5_ e background _PARAM6_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const id = eventsFunctionContext.getArgument(\"Lista_ID\");", + "", + "if (!window._gdLists) {", + " window._gdLists = {};", + "}", + "", + "", + "if (window._gdLists[id]) return;", + "", + "const x = eventsFunctionContext.getArgument(\"x\");", + "const y = eventsFunctionContext.getArgument(\"y\");", + "const w = eventsFunctionContext.getArgument(\"Largura\");", + "const h = eventsFunctionContext.getArgument(\"Altura\");", + "const bg = eventsFunctionContext.getArgument(\"background_color\");", + "", + "", + "const container = document.createElement(\"div\");", + "container.id = \"gd-list-\" + id;", + "", + "container.style.position = \"absolute\";", + "container.style.left = x + \"px\";", + "container.style.top = y + \"px\";", + "container.style.width = w + \"px\";", + "container.style.height = h + \"px\";", + "container.style.overflowY = \"auto\";", + "container.style.background = bg;", + "container.style.zIndex = 9999;", + "container.style.pointerEvents = \"auto\";", + "", + "", + "const gameDiv =", + " document.getElementById(\"canvas-container\") ||", + " document.body;", + "", + "gameDiv.appendChild(container);", + "", + "", + "window._gdLists[id] = {", + " container,", + " items: [],", + " selectedIndex: -1", + "};", + "" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": true + } + ], + "parameters": [ + { + "description": "Defina um ID para sua Lista", + "name": "Lista_ID", + "type": "string" + }, + { + "description": "Posição X", + "name": "x", + "type": "expression" + }, + { + "description": "Posição Y", + "name": "y", + "type": "expression" + }, + { + "description": "Largura da Lista", + "name": "Largura", + "type": "expression" + }, + { + "description": "Altura da Lista", + "name": "Altura", + "type": "expression" + }, + { + "description": "Cor de Fundo", + "name": "background_color", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Salvar a lista no armazenamento.", + "fullName": "Salvar Lista", + "functionType": "Action", + "name": "Salvar_Lista", + "sentence": "Salvar a lista _PARAM1_ no storage", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [] + }, + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const id = eventsFunctionContext.getArgument(\"Lista_ID\");", + "const list = window._gdLists?.[id];", + "if (!list) return;", + "", + "const data = {", + " items: list.items,", + " selectedIndex: list.selectedIndex", + "};", + "", + "localStorage.setItem(", + " \"gd_list_\" + id,", + " JSON.stringify(data)", + ");", + "" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": true + } + ], + "parameters": [ + { + "description": "Nome da Lista a Salvar", + "name": "Lista_ID", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Carregar lista do armazenamento.", + "fullName": "Carregar Lista Salva", + "functionType": "Action", + "name": "Carregar_Lista", + "sentence": "Carregar a lista _PARAM1_ do armazenamento", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const id = eventsFunctionContext.getArgument(\"Lista_ID\");", + "const list = window._gdLists?.[id];", + "if (!list) return;", + "", + "const raw = localStorage.getItem(\"gd_list_\" + id);", + "if (!raw) return;", + "", + "const data = JSON.parse(raw);", + "", + "list.items = data.items || [];", + "list.selectedIndex = data.selectedIndex ?? -1;", + "" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": true + } + ], + "parameters": [ + { + "description": "Noma da Lista Salva", + "name": "Lista_ID", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Atualiza a Lista na tela.", + "fullName": "Atualizar Lista", + "functionType": "Action", + "name": "Atualizar_Lista", + "sentence": "Atualizar a lista _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const id = eventsFunctionContext.getArgument(\"Lista_ID\");", + "const list = window._gdLists?.[id];", + "if (!list) return;", + "", + "", + "list.container.innerHTML = \"\";", + "", + "", + "list.items.forEach((item, index) => {", + " const div = document.createElement(\"div\");", + " div.innerText = item.text;", + "", + " div.style.padding = \"10px\";", + " div.style.color = \"white\";", + " div.style.cursor = \"pointer\";", + " div.style.borderBottom = \"1px solid rgba(255,255,255,0.2)\";", + " div.style.color = \"white\";", + "div.style.borderBottom = \"1px solid rgba(255,255,255,0.2)\";", + "", + "", + " ", + " if (index === list.selectedIndex) {", + " div.style.background = \"#BDB76B\";", + " }", + "", + " div.onclick = () => {", + " list.selectedIndex = index;", + "", + " ", + " Array.from(list.container.children).forEach(child => {", + " child.style.background = \"transparent\";", + " });", + "", + " ", + " div.style.background = \"#BDB76B\";", + "};", + "", + "", + " list.container.appendChild(div);", + "});", + "" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": true + } + ], + "parameters": [ + { + "description": "Lista a ser atualizada", + "name": "Lista_ID", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Adicionar Item na Lista.", + "fullName": "Adicionar Item", + "functionType": "Action", + "name": "Adicionar_Item", + "sentence": "Adicionar o item _PARAM1_ na lista _PARAM2_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const id = eventsFunctionContext.getArgument(\"Lista_ID\");", + "const text = eventsFunctionContext.getArgument(\"texto\");", + "", + "const list = window._gdLists?.[id];", + "if (!list) return;", + "", + "list.items.push({ text });", + "list.selectedIndex = list.items.length - 1;", + "" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": true + } + ], + "parameters": [ + { + "description": "Lista", + "name": "Lista_ID", + "type": "string" + }, + { + "description": "Texto do item a ser adicionado", + "name": "texto", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Excluir Item da Lista.", + "fullName": "Excluir Item", + "functionType": "Action", + "name": "Excluir_Item", + "sentence": "Excluir item da lista _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const id = eventsFunctionContext.getArgument(\"Lista_ID\");", + "const list = window._gdLists?.[id];", + "if (!list) return;", + "", + "const index = list.selectedIndex;", + "if (index < 0) return;", + "", + "list.items.splice(index, 1);", + "list.selectedIndex = -1;", + "" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": true + } + ], + "parameters": [ + { + "description": "Nome da Lista onde o Item selecionado se encontra", + "name": "Lista_ID", + "type": "string" + } + ], + "objectGroups": [] + } + ], + "eventsBasedBehaviors": [], + "eventsBasedObjects": [] +} \ No newline at end of file