-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: support MAME software list DATs (#1031)
- Loading branch information
Showing
22 changed files
with
179,753 additions
and
110 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Expose, Transform, Type } from 'class-transformer'; | ||
|
||
import ROM from '../rom.js'; | ||
|
||
/** | ||
* Media image used by a {@link Part}. | ||
*/ | ||
export default class DataArea { | ||
// @Expose() | ||
// readonly name?: string; | ||
|
||
// @Expose() | ||
// readonly size?: number; | ||
|
||
@Expose() | ||
@Type(() => ROM) | ||
@Transform(({ value }) => value || []) | ||
readonly rom?: ROM | ROM[]; | ||
|
||
constructor(rom: ROM | ROM[]) { | ||
this.rom = rom; | ||
} | ||
|
||
getRoms(): ROM[] { | ||
if (Array.isArray(this.rom)) { | ||
return this.rom; | ||
} if (this.rom) { | ||
return [this.rom]; | ||
} | ||
return []; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Expose, Transform, Type } from 'class-transformer'; | ||
|
||
import DataArea from './dataArea.js'; | ||
|
||
/** | ||
* Media used by a {@link Software}. | ||
*/ | ||
export default class Part { | ||
// @Expose() | ||
// readonly name?: string; | ||
|
||
// @Expose() | ||
// readonly interface?: string; | ||
|
||
@Expose() | ||
@Type(() => DataArea) | ||
@Transform(({ value }) => value || []) | ||
readonly dataarea?: DataArea | DataArea[]; | ||
|
||
constructor(dataarea: DataArea | DataArea[]) { | ||
this.dataarea = dataarea; | ||
} | ||
|
||
getDataAreas(): DataArea[] { | ||
if (Array.isArray(this.dataarea)) { | ||
return this.dataarea; | ||
} if (this.dataarea) { | ||
return [this.dataarea]; | ||
} | ||
return []; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Expose, Transform, Type } from 'class-transformer'; | ||
|
||
import Game from '../game.js'; | ||
import ROM from '../rom.js'; | ||
import Part from './part.js'; | ||
|
||
/** | ||
* A MAME software image. | ||
*/ | ||
export default class Software extends Game { | ||
@Expose() | ||
@Type(() => Part) | ||
@Transform(({ value }) => value || []) | ||
readonly part?: Part | Part[]; | ||
|
||
constructor(part: Part | Part[]) { | ||
super(); | ||
this.part = part; | ||
} | ||
|
||
private getParts(): Part[] { | ||
if (Array.isArray(this.part)) { | ||
return this.part; | ||
} if (this.part) { | ||
return [this.part]; | ||
} | ||
return []; | ||
} | ||
|
||
getRoms(): ROM[] { | ||
return this.getParts() | ||
.flatMap((part) => part.getDataAreas()) | ||
.flatMap((dataArea) => dataArea.getRoms()); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { | ||
Expose, plainToInstance, Transform, Type, | ||
} from 'class-transformer'; | ||
|
||
import DAT from '../dat.js'; | ||
import Game from '../game.js'; | ||
import Header from '../logiqx/header.js'; | ||
import Software from './software.js'; | ||
|
||
/** | ||
* MAME-schema DAT that documents {@link Software}s. | ||
*/ | ||
export default class SoftwareListDAT extends DAT { | ||
@Expose() | ||
readonly name?: string; | ||
|
||
@Expose() | ||
readonly description?: string; | ||
|
||
@Expose() | ||
@Type(() => Software) | ||
@Transform(({ value }) => value || []) | ||
readonly software?: Software | Software[]; | ||
|
||
constructor(software: Software | Software[]) { | ||
super(); | ||
this.software = software; | ||
} | ||
|
||
/** | ||
* Construct a {@link SoftwareListDAT} from a generic object, such as one from reading an XML | ||
* file. | ||
*/ | ||
static fromObject(obj: object): SoftwareListDAT { | ||
return plainToInstance(SoftwareListDAT, obj, { | ||
enableImplicitConversion: true, | ||
excludeExtraneousValues: true, | ||
}) | ||
.generateGameNamesToParents(); | ||
} | ||
|
||
getHeader(): Header { | ||
return new Header({ | ||
name: this.name, | ||
description: this.description, | ||
}); | ||
} | ||
|
||
getGames(): Game[] { | ||
if (Array.isArray(this.software)) { | ||
return this.software; | ||
} if (this.software) { | ||
return [this.software]; | ||
} | ||
return []; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { | ||
Expose, plainToInstance, Transform, Type, | ||
} from 'class-transformer'; | ||
|
||
import DAT from '../dat.js'; | ||
import Game from '../game.js'; | ||
import Header from '../logiqx/header.js'; | ||
import SoftwareListDAT from './softwareListDat.js'; | ||
|
||
/** | ||
* MAME-schema DAT that documents {@link SoftwareListDAT}s. | ||
*/ | ||
export default class SoftwareListsDAT extends DAT { | ||
@Expose() | ||
@Type(() => SoftwareListDAT) | ||
@Transform(({ value }) => value || []) | ||
readonly softwarelist?: SoftwareListDAT | SoftwareListDAT[]; | ||
|
||
/** | ||
* Construct a {@link SoftwareListsDAT} from a generic object, such as one from reading an XML | ||
* file. | ||
*/ | ||
static fromObject(obj: object): SoftwareListsDAT { | ||
return plainToInstance(SoftwareListsDAT, obj, { | ||
enableImplicitConversion: true, | ||
excludeExtraneousValues: true, | ||
}) | ||
.generateGameNamesToParents(); | ||
} | ||
|
||
getHeader(): Header { | ||
return new Header({ | ||
name: this.getSoftwareLists() | ||
.map((softwareList) => softwareList.getName()).join(', '), | ||
description: this.getSoftwareLists() | ||
.map((softwareList) => softwareList.getDescription()).join(', '), | ||
}); | ||
} | ||
|
||
private getSoftwareLists(): SoftwareListDAT[] { | ||
if (Array.isArray(this.softwarelist)) { | ||
return this.softwarelist; | ||
} if (this.softwarelist) { | ||
return [this.softwarelist]; | ||
} | ||
return []; | ||
} | ||
|
||
getGames(): Game[] { | ||
return this.getSoftwareLists() | ||
.flatMap((softwareList) => softwareList.getGames()); | ||
} | ||
} |
Oops, something went wrong.