igir
Version:
🕹 A zero-setup ROM collection manager that sorts, filters, extracts or archives, patches, and reports on collections of any size on any OS.
86 lines (85 loc) • 2.29 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __decorateClass = (decorators, target, key, kind) => {
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
for (var i = decorators.length - 1, decorator; i >= 0; i--)
if (decorator = decorators[i])
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
if (kind && result) __defProp(target, key, result);
return result;
};
import { Expose, plainToClassFromExist, Transform, Type } from "class-transformer";
import DAT from "../dat.js";
import Game from "../game.js";
import Header from "../logiqx/header.js";
const _MameDAT = class _MameDAT extends DAT {
build;
machine;
game;
constructor(props) {
super(props);
this.build = props?.build;
this.machine = props?.machine;
this.game = props?.game;
this.generateGameNamesToParents();
}
/**
* Construct a {@link DAT} from a generic object, such as one from reading an XML file.
*/
static fromObject(obj, props) {
const dat = new _MameDAT(props);
return plainToClassFromExist(dat, obj, {
enableImplicitConversion: true,
excludeExtraneousValues: true
}).generateGameNamesToParents();
}
getHeader() {
return new Header({
name: this.build ?? "MAME"
});
}
getGames() {
if (Array.isArray(this.machine)) {
if (this.machine.length > 0) {
return this.machine;
}
} else if (this.machine) {
return [this.machine];
}
if (Array.isArray(this.game)) {
if (this.game.length > 0) {
return this.game;
}
} else if (this.game) {
return [this.game];
}
return [];
}
/**
* @inheritdoc
*/
isMame() {
return true;
}
withGames(games) {
return new _MameDAT({ ...this, machine: games, games: [] });
}
};
__decorateClass([
Expose()
], _MameDAT.prototype, "build", 2);
__decorateClass([
Expose(),
Type(() => Game),
Transform(({ value }) => value ?? [])
], _MameDAT.prototype, "machine", 2);
__decorateClass([
Expose(),
Type(() => Game),
Transform(({ value }) => value ?? [])
], _MameDAT.prototype, "game", 2);
let MameDAT = _MameDAT;
export {
MameDAT as default
};
//# sourceMappingURL=mameDat.js.map