@bscotch/gml-parser
Version:
A parser for GML (GameMaker Language) files for programmatic manipulation and analysis of GameMaker projects.
115 lines • 4.96 kB
TypeScript
import { Pathy } from '@bscotch/pathy';
import { YyData, YyResourceType, YySchemas, YypResource } from '@bscotch/yy';
import type { ObjectEvent, ObjectEventName } from './lib.objects.js';
import { Code } from './project.code.js';
import { Project } from './project.js';
import { Signifier } from './signifiers.js';
import { StructType, Type } from './types.js';
export declare function isAssetOfKind<T extends YyResourceType>(asset: any, kind: T): asset is Asset<T>;
export declare function assertIsAssetOfKind<T extends YyResourceType>(asset: any, kind: T): asserts asset is Asset<T>;
export declare class Asset<T extends YyResourceType = YyResourceType> {
readonly project: Project;
readonly resource: YypResource;
readonly $tag = "Asset";
readonly assetKind: T;
readonly gmlFiles: Map<string, Code>;
yy: YyData<T>;
readonly yyPath: Pathy<YySchemas[T]>;
readonly signifier: Signifier;
/** For objects, their instance type. */
instanceType: Type<'Id.Instance'> | undefined;
assetType: Type<Asset['assetTypeKind']>;
variables: StructType | undefined;
nativeVariables: StructType | undefined;
/** For objects, their parent */
protected _parent: Asset<'objects'> | undefined;
protected initalized: {
globals: boolean;
locals: boolean;
};
protected constructor(project: Project, resource: YypResource, yyPath: Pathy);
get typeName(): string;
get instanceTypeName(): string;
saveYy(): Promise<void>;
get isScript(): boolean;
get isObject(): boolean;
get isSound(): boolean;
get isRoom(): boolean;
get isSprite(): boolean;
get isSpineSprite(): boolean;
get soundFile(): Pathy<Buffer>;
get sprite(): Asset<'sprites'> | undefined;
set sprite(sprite: Asset<'sprites'> | undefined);
get children(): Asset<'objects'>[];
get parent(): Asset<"objects"> | undefined;
set parent(parent: Asset<'objects'> | undefined);
/**
* Get the entire parent heirarchy, with immediate first
* and most-distant last
*/
get parents(): Asset<'objects'>[];
/**
* Get the first GML file belonging to this resource.
* For scripts, this is the *only* GML file.*/
get gmlFile(): Code;
get gmlFilesArray(): Code[];
getEventByName(name: ObjectEventName): Code | undefined;
get shaderPaths(): T extends 'shaders' ? {
[K in 'vertex' | 'fragment']: Pathy<string>;
} : undefined;
get roomInstances(): {
instanceId: string;
object: Asset<'objects'>;
}[];
get frameIds(): string[];
get framePaths(): Pathy<Buffer>[];
get spinePaths(): {
json: Pathy<unknown>;
atlas: Pathy<unknown>;
} | undefined;
/**
* During an Object asset rename, we need to ensure that all references to the
* old name are updated to the new name. This includes the object's name in rooms.
*/
renameRoomInstanceObjects(oldObjectName: string, newObjectName: string): Promise<void>;
removeRoomInstance(instanceId: string): Promise<void>;
reorganizeRoomInstances(instanceIds: string[]): Promise<void>;
addRoomInstance(obj: Asset<'objects'>, x?: number, y?: number): Promise<void>;
get folder(): string;
/**
* Check if this asset is in the given asset group ("folder").
* @param path E.g. `my/folder/of/stuff`
*/
isInFolder(path: string): boolean;
/** Move to a different, *existing* folder. */
moveToFolder(path: string): Promise<void>;
/**
* Re-order the existing frames of a sprite.
* Any frames not included in the new order will be deleted.
*/
reorganizeFrames(newFrameIdOrder: string[]): Promise<void>;
deleteFrames(frameIds: string[]): Promise<void>;
addFrames(sourceImages: Pathy[]): Promise<void>;
createEvent(eventInfo: ObjectEvent): Promise<Code | undefined>;
readYy(): Promise<YyData<T>>;
get dir(): Pathy<unknown>;
get name(): string;
/**
* Reprocess an existing file after it has been modified.
*/
reloadFile(path: Pathy, virtualContent?: string): Promise<void>;
getGmlFile(path: Pathy): Code | undefined;
protected updateParent(): void;
updateGlobals(initial?: boolean): void;
updateAllSymbols(initial?: boolean): void;
updateDiagnostics(): void;
protected addGmlFile(path: Pathy<string>): Code;
reload(): Promise<void>;
onRemove(): Promise<void>;
protected addObjectFile(children: Pathy<string>[]): void;
protected addScriptFile(children: Pathy<string>[]): void;
protected initiallyReadAndParseGml(): Promise<any[]>;
get assetTypeKind(): "Any" | "Asset.GMFont" | "Asset.GMObject" | "Asset.GMPath" | "Asset.GMRoom" | "Asset.GMScript" | "Asset.GMShader" | "Asset.GMSound" | "Asset.GMSprite" | "Asset.GMTimeline";
static from<T extends YyResourceType>(project: Project, resource: YypResource): Promise<Asset<T> | undefined>;
}
//# sourceMappingURL=project.asset.d.ts.map