Allow TXTP groups selecting subfiles like random for testing

This commit is contained in:
bnnm 2020-12-01 23:30:01 +01:00
parent 54340f9bcd
commit 78bb21b3ed
2 changed files with 8 additions and 2 deletions

View File

@ -165,7 +165,7 @@ mode = layers
- `type`: group as `S`=segments, `L`=layers, or `R`=pseudo-random
- `count`: number of files in group (optional, default is all)
- `repeat`: R=repeat group of `count` files until end (optional, default is no repeat)
- `>file`: select file in pseudo-random groups (ignored for others)
- `>file`: select file (for pseudo-random groups)
Examples:
- `L`: take all files as layers (equivalent to `mode = layers`)
@ -193,7 +193,7 @@ group = -S2 #segment prev 2 (will start from pos.1 = bgm1+2, makes group of bgm
```
### Pseudo-random groups
Group `R` is meant to help with games that randomly select a file in a group. You can set with `>N` which file will be selected. This way you can quickly edit the TXTP and change the file (you could just comment files too, this is just for convenience in complex cases and testing). You can also set `>-`, meaning "play all", basically turning `R` into `S`. Files do need to exist and are parsed before being selected, and it can select groups too.
Group `R` is meant to help with games that randomly select a file in a group. You can set with `>N` which file will be selected. This way you can quickly edit the TXTP and change the file (you could just comment files too, this is just for convenience in complex cases and testing). You can also set `>-`, meaning "play all", basically turning `R` into `S` (this can be ommited, but it's clearer). Files do need to exist and are parsed before being selected, and it can select groups too.
```
bgm1.adx
bgm2.adx

View File

@ -1629,15 +1629,21 @@ static int add_group(txtp_header* txtp, char* line) {
m = sscanf(line, " >%c%n", &c, &n);
if (m == 1 && c == TXTP_GROUP_RANDOM_ALL) {
cfg.type = TXTP_GROUP_MODE_RANDOM; /* usually R>- but allows L/S>- */
cfg.selected = cfg.count; /* special meaning */
line += n;
}
else {
m = sscanf(line, " >%d%n", &cfg.selected, &n);
if (m == 1) {
cfg.type = TXTP_GROUP_MODE_RANDOM; /* usually R>1 but allows L/S>1 */
cfg.selected--; /* externally 1=first but internally 0=first */
line += n;
}
else if (cfg.type == TXTP_GROUP_MODE_RANDOM) {
/* was a random but didn't select anything, just select all */
cfg.selected = cfg.count;
}
}
parse_params(&cfg.entry, line);