Skip to content

Commit

Permalink
Merge branch 'main' into feature/custom_import_with_svelte
Browse files Browse the repository at this point in the history
  • Loading branch information
Julen-BZ committed Oct 28, 2024
2 parents bdeabf8 + bf22a5c commit 63f9d7f
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 19 deletions.
1 change: 1 addition & 0 deletions docs/develop/es/es.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ git clone https://github.com/AnimaBeyondDevelop/AnimaBeyondFoundry.git
> echo "alias foundry='node $HOME/foundryvtt/resources/app/main.js --dataPath=$HOME/foundrydata'" >> ~/.bash_aliases
>```
> *Tras crear el alias (y reiniciar la terminal para que surta efecto), bastará con usar el comando `foundry` para lanzarlo. Para conectarse habrá que abrir cualquier explorador y abrir la url `localhost:30000`.*
> *Aunque el alias es suficiente cuando se tiene una sola versión instalada, el cli de Foundry ([foundryvtt-cli](https://github.com/foundryvtt/foundryvtt-cli)) es una buena herramienta para gestionar distintas instalaciones. En [esta página](./foundry-cli.md) pueden encontrarse instrucciones para gestionar instalaciones con foundryvtt-cli.*
## Instrucciones de trabajo para desarrolladores
Expand Down
89 changes: 89 additions & 0 deletions docs/develop/es/foundry-cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Ventajas de usar el FoundryVtt-cli

La principal ventaja es poder centralizar en una sola herramienta los paths de instalación y de datos de foundry. Así, con hacer

```bash
fvtt configure set installPath "/path/to/foundry/install"
fvtt configure set dataPath "/path/to/foundry/data"
```

El CLI registra los paths correspondientes y para lanzar foundry tan sólo tendremos que hacer

```bash
fvtt launch
```

sin necesidad de indicar los paths cada vez que queramos lanzar foundry.

Además, el foundry provee comandos para obtener dichos paths una vez establecidos:

```bash
fvtt configure get installPath # prints /path/to/foundry/install
fvtt configure get dataPath # prints /path/to/foundry/data
```

Esto es útil para construir la ruta donde deben ir los sistemas, por ejemplo, y copiar allí el sistema una vez hecha la build. En concreto, si se encuentra instalado, no será necesario crear el archivo `foundryconfig.json` para especificar el `dataPath`, sino que se obtendrá a través del CLI.

# Instalación

La instalación es sencilla: se hace usando npm. Conviene instalarlo globalmente para tenerlo accesible desde la línea de comandos:

```bash
npm install -g @foudryvtt/foundryvtt-cli
```

Tras esto, sólo tendremos que configurar los paths como arriba y comprobar nuestra configuración haciendo `fvtt configure` (obtendremos un `configuration complete!` si está todo correcto).

# Selector de versiones

Si se instala el CLI, es posible tener un selector de versiones para cambiar entre las instaladas. En concreto, podemos tener la instalación de Foundry siguiendo esta estructura de carpetas:

```
/home/<user>
├── data
│ ├── v11
│ └── v12
└── installations
├── v11
└── v12
```

En este caso, podemos valernos de ésta para crear una utilidad que nos permita cambiar de versiones de manera fácil:

Copiando el código anterior a un archivo guardado en algún sitio en el path (por ejemplo `~/.local/bin/fvtt-config`) y dándole permisos de ejecución si es necesario (`chmod +x ~/.local/bin/fvtt-config`), deberíamos poder lanzar fvtt-config, que nos permitirá seleccionar una de las versiones instaladas y establecerá los paths correspondientes.

> _Nota: aunque no es necesario, si fzf está instalado se usa para seleccionar la versión permitiéndonos buscar entre las disponibles._
```bash
#!/usr/bin/bash

if ! [ -x "$(command -v fvtt)" ]
then
echo "Error: fvtt not available."
echo "Please install it with 'npm install -g @foundryvtt/foundryvtt-cli'"
exit 1
fi

installPath=$HOME/foundry/installations

if [ -x "$(command -v fzf)" ]
then
version=$(ls $installPath | fzf --reverse --info=inline --height=10%)
else
PS3="Select your version: "
select installation in $installPath/*
do
version=${installation#*installations/}
break
done
fi

if [ -z "$version" ]
then
echo "No changes!"
fvtt configure view
else
fvtt configure set installPath "$HOME/foundry/installations/$version"
fvtt configure set dataPath "$HOME/foundry/data/${version%.*}"
fi
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "anima-beyond-foundry",
"version": "1.19.1",
"version": "1.19.2",
"description": "Unofficial Anima Beyond Fantasy system for Foundry VTT",
"type": "module",
"scripts": {
Expand Down
19 changes: 14 additions & 5 deletions scripts/copyDirectoryToFoundrySystem.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,27 @@ const { execSync } = require('child_process');
const chalk = require('chalk');
const fs = require('fs-extra');

const config = fs.readJSONSync('foundryconfig.json');
const directory = process.argv[2];
const directory = process.argv[2] ?? 'animabf';
let destPath;

try {
fs.rmSync(`${config.destPath}/${directory}`, { recursive: true, force: true });
console.log(chalk.yellow('Trying to use fvtt to get dataPath...'));
dataPath = execSync('fvtt configure get dataPath', { encoding: 'utf8' }).trim();
destPath = `${dataPath}/Data/systems`;
} catch (e) {
console.log(chalk.yellow('Falling back to foundryconfig.json'));
destPath = fs.readJSONSync('foundryconfig.json').destPath;
}

try {
fs.rmSync(`${destPath}/${directory}`, { recursive: true, force: true });
} catch {
// ignore
}

try {
execSync(`cp -r $(pwd)/dist ${config.destPath}/${directory}`);
console.log(chalk.green(`Directory ${directory} copied into ${config.destPath}\n\n`));
execSync(`cp -r $(pwd)/dist ${destPath}/${directory}`);
console.log(chalk.green(`Directory ${directory} copied into ${destPath}\n\n`));
} catch (e) {
console.error(chalk.red(e.stack));
}
16 changes: 6 additions & 10 deletions src/module/actor/ABFActorSheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default class ABFActorSheet extends sveltify(
width: 1000,
height: 850,
submitOnChange: true,
viewPermission: CONST.DOCUMENT_OWNERSHIP_LEVELS.OBSERVER,
tabs: [
{
navSelector: '.sheet-tabs',
Expand Down Expand Up @@ -83,18 +84,13 @@ export default class ABFActorSheet extends sveltify(
return 1000;
}

/**
* Tests if a given user has permission to render the ActorSheet.
* If it does not, instead of rendering the sheet, shows the Actor's portrait.
* @param {ABFActor} user
* @returns {boolean}
*/
_canUserView(user) {
const canView = this.actor.testUserPermission(user, 'OBSERVER');
if (!canView) {
async _render(force, options = {}) {
// If user permission is exactly LIMITED, then display image popout and quit; else do normal render
if (force && this.actor.testUserPermission(game.user, 'LIMITED', { exact: true })) {
this.displayActorImagePopout();
return;
}
return canView;
return super._render(force, options);
}

displayActorImagePopout() {
Expand Down
6 changes: 3 additions & 3 deletions src/system.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
"id": "animabf",
"title": "Anima Beyond Fantasy",
"description": "Unofficial Anima Beyond Fantasy system for Foundry VTT",
"version": "1.19.1",
"version": "1.19.2",
"compatibility": { "minimum": "12", "verified": "12.331" },
"url": "https://github.com/AnimaBeyondDevelop/AnimaBeyondFoundry",
"manifest": "https://raw.githubusercontent.com/AnimaBeyondDevelop/AnimaBeyondFoundry/main/src/system.json",
"changelog": "https://github.com/AnimaBeyondDevelop/AnimaBeyondFoundry/releases/tag/v1.19.1",
"download": "https://github.com/AnimaBeyondDevelop/AnimaBeyondFoundry/releases/download/v1.19.1/animabf.zip",
"changelog": "https://github.com/AnimaBeyondDevelop/AnimaBeyondFoundry/releases/tag/v1.19.2",
"download": "https://github.com/AnimaBeyondDevelop/AnimaBeyondFoundry/releases/download/v1.19.2/animabf.zip",
"bugs": "https://github.com/AnimaBeyondDevelop/AnimaBeyondFoundry/issues",
"authors": [{ "name": "Linkaynn", "url": "https://www.jeseromero.com" }],
"scripts": [],
Expand Down

0 comments on commit 63f9d7f

Please sign in to comment.