Skip to content

Commit

Permalink
Improve name recognition of Live2D models
Browse files Browse the repository at this point in the history
  • Loading branch information
guansss committed Mar 20, 2020
1 parent 7b3410e commit a4bb45b
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/module/config/settings/CharacterSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,21 @@ class ModelEntity {
}
constructor(config: ModelConfig) {
this.file = Array.isArray(config.file)
? config.file.length > 0
? config.file[0].replace(/\/.*/, '')
: '<EMPTY>'
: config.file;
this.name = basename(this.file).replace(/\.(moc|json|model\.json)/, '');
if (Array.isArray(config.file)) {
if (config.file.length > 0) {
this.file =
config.file.find(f => f.endsWith('.model.json')) ||
config.file.find(f => f.endsWith('.moc')) ||
'None';
this.name = config.file[0].replace(/\/.*/, ''); // take folder's name
} else {
this.file = 'None';
this.name = 'Unknown';
}
} else {
this.file = config.file;
this.name = basename(this.file).replace(/\.(json|model\.json)/, '');
}
this.updateConfig(config);
}
Expand Down

0 comments on commit a4bb45b

Please sign in to comment.