Last active
October 10, 2024 00:43
-
-
Save rmgimenez/a87e7a35dc3d24378625378a4bc42274 to your computer and use it in GitHub Desktop.
Script para gerar o arquivo config.xml para os newgens que estiverem na pasta
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Script para ler todas as imagens desse diretório e criar um arquivo XML igual ao config.xml usado no jogo Football Manager 2024. Acredito que funcione para outras versões do jogo. | |
Exemplo de uso: | |
Copie a imagem para esse diretório e renomeie o arquivo para o id do jogador. | |
Execute o script com o comando: | |
node app.js | |
O script irá criar um arquivo config.xml com todas as imagens do diretório. | |
*/ | |
const fs = require('fs'); | |
const path = require('path'); | |
// apaga o arquivo config.xml | |
if (fs.existsSync(path.join(__dirname, 'config.xml'))) { | |
fs.unlinkSync(path.join(__dirname, 'config.xml')); | |
} | |
const imagens = fs.readdirSync(path.join(__dirname)); | |
// filtrar apenas imagens | |
const imagensFiltradas = imagens.filter((imagem) => { | |
return imagem.endsWith('.png') || imagem.endsWith('.jpg'); | |
}); | |
const xml = `<record> | |
<!-- resource manager options --> | |
<!-- dont preload anything in this folder --> | |
<boolean id="preload" value="false"/> | |
<!-- turn off auto mapping --> | |
<boolean id="amap" value="false"/> | |
<!-- logo mappings --> | |
<!-- the following XML maps pictures inside this folder into other positions | |
in the resource system, which allows this folder to be dropped into any | |
place in the graphics folder and still have the game pick up the graphics | |
files from the correct places | |
--> | |
<list id="maps"> | |
<!-- Auto generated by fmXML --> | |
${imagensFiltradas | |
.map( | |
(image) => | |
`<record from="${image.split('.')[0]}" to="graphics/pictures/person/${ | |
image.split('.')[0] | |
}/portrait"/>` | |
) | |
.join('\n')} | |
</list> | |
</record> | |
`; | |
fs.writeFileSync(path.join(__dirname, 'config.xml'), xml); | |
console.log('XML criado com sucesso!'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment