Project beta
Class of @v12-engine/editor
export declare class ProjectThe project the editor keeps its maps and the game's files in (D12): a dev server with the editor's plugin (editorFiles), which reads and writes the files of the games. Without one, maps are kept in the browser. Whether there is one is asked once (find, which the editor does before it opens) or said (set); where each game is in it, and the version of each map file as this editor last read or wrote it, are its own. editor.project, handed to the map's files, the game's files, the asset index and the checks
Members
assetUses
assetUses(folder: string, path: string): Promise<string[]>;The files of the code and the maps that say an asset's name
codeFiles
codeFiles(game: string): Promise<CodeFile[]>;The files of a game's folder that are code or data, each with the definitions found in it (what the Code panel lists). Read only
compressAsset
compressAsset(folder: string, path: string): Promise<{
path: string;
before: number;
size: number;
manifest?: Manifest;
}>;Makes a file of a game's folder smaller where it is: a model as it is made on the way in, a picture written again as the file it is, no larger than its kind is drawn (a texture 2048 pixels, an icon 256). Says how big it was and is (the same where it was as small already), and what the folder holds where it was written
convertFbx
convertFbx(file: Blob): Promise<Uint8Array>;A model's FBX made a GLB through the dev server, with the project's machine's fbx2gltf. Refused where that is not on its path, with what to do
currentMapVersion
currentMapVersion(game: string, name: string): Promise<string | null>;The version of a map file on disk now, or null for none: to notice a change made there (a pull, another editor)
dataPack
dataPack: string | undefined;The pack of content the Data panel keeps its changes in (campaign plan RC6, packs/<id>/pack.json, its data), in place of the game's data.json: none when left out. Set by the project's code (editor.project.dataPack = 'gnomes')
deleteAsset
deleteAsset(folder: string, path: string): Promise<{
manifest: Manifest;
}>;Takes an asset of a game's folder away
deletePrefab
deletePrefab(game: string, name: string): Promise<{
file: string;
}>;Takes a prefab's file of the project away
facts
facts(): Promise<ProjectFacts>;What the project is, as its files say (ProjectFacts)
find
find(): Promise<boolean>;Asks the dev server, once, whether it has the editor's plugin: only a server that answers as the plugin does is a project. Any other (a game developer's own dev server without the plugin, a built page) is none, and maps go to the browser, where they once could not be saved at all
findFolder
findFolder(game: string): Promise<string>;Asks the dev server where a game is in the project, once: the editor does, before it opens. Nothing where there is no project
folder
folder(game: string): string;Where a game is in the project, from its root: as the dev server's plugin lays the project out (editorFiles's options), or src/games/<game> until it has said (findFolder)
has
has(): boolean;Whether there is a project to keep maps in: known once find has asked, or once it is said (set). A signal
importAsset
importAsset(folder: string, path: string, file: Blob): Promise<{
path: string;
size: number;
before: number;
manifest: Manifest;
}>;Takes a file into a game's folder, at a path where its kind goes (models/, sounds/, textures/…). A model is made smaller on the way in, a sound by a name there is becomes one more take of it. Says where it went, how big it came out, and what the folder holds now
listAssets
listAssets(folder?: string): Promise<{
own: ProjectAsset[];
shared: ProjectAsset[];
}>;The assets of a game's folder (GameView.files.assets, games/td), and of the shared folders
listMaps
listMaps(game: string): Promise<ProjectMap[]>;The maps of a game in the project, the last changed first
listPrefabs
listPrefabs(game: string): Promise<{
name: string;
clip: unknown;
}[]>;The prefabs of a game in the project, by name: copies of what was selected, to put down again
loadData
loadData(game: string): Promise<GameData>;What the game's data.json says (or its pack's data, dataPack): {} where there is none, never a missing file
loadLooks
loadLooks(game: string): Promise<LooksFile>;A game's looks.json: what its unit types look like as data, by their id (see layLooks)
loadMap
loadMap(game: string, name: string): Promise<GameMap>;Reads a map of the project, and notes its file's version, for saving it back without writing over a change made since
loadMapFiles
loadMapFiles(game: string, name: string): Promise<MapPack>;The files a map of the project brings with it (a ground made of a picture), kept beside its file: none for a map without
makeLevels
makeLevels(folder: string, path: string, ratios?: number[]): Promise<{
full: number;
levels: {
path: string;
triangles: number;
}[];
manifest?: Manifest;
}>;Makes the lighter levels of a model of a game's folder beside it (npm run lod: <model>.lod1.glb...), each a part of its triangles (ratios, 40% and 15% when left out): says how many triangles each has, and what the folder holds then. With no folder, of a shared model (the project's own under public, or @v12-engine/assets's): its levels are made into the project's own public/models, beside where it is served, and models/levels.json says them then
mapFacts
mapFacts(game: string): Promise<ProjectMapFacts[]>;What the maps of a game are, read from their files (what the Project panel shows), the last changed first
mapVersion
mapVersion(game: string, name: string): string | undefined;The version of a map file as this editor last read or wrote it (a hash of the file), where it did
offerCode
offerCode(runtime: Pick<ClientRuntime, 'openCode'>): () => void;The console's places in a stack opened in the code editor (an app's runtime.openCode), while there is a project to open them in, as it is found or said: what the editor does with its runtime. Gives back the way to stop, which takes the way away
openDefinition
openDefinition(game: string, id: string, key?: string): Promise<void>;Opens where something of a game is defined, in the code editor: a unit type, a field, a tile, by its id; or with key, a property of the game's (check for its checks). Rejects with why not
openInEditor
openInEditor(file: string, line?: number): Promise<void>;Opens a file of the project in the code editor the developer runs, at a line: through Vite's own /__open-in-editor
readCode
readCode(game: string, path: string): Promise<{
path: string;
text: string;
definitions: CodeDefinition[];
}>;One file of a game's folder read, by its path from it, with the definitions found in it. Rejects with why not (a path out of the folder is refused)
removeData
removeData(game: string, kind: DataKind, id: string, removed?: boolean): Promise<{
file: string;
}>;Takes a definition out of the game in its data.json (removed), what the file said of it gone, or puts it back (campaign plan RC3)
removeLevels
removeLevels(folder: string, path: string): Promise<{
manifest?: Manifest;
}>;Takes away the levels made of a model of a game's folder (says what the folder holds then), or of a shared one with no folder
renameAsset
renameAsset(folder: string, path: string, to: string): Promise<{
path: string;
uses: string[];
manifest: Manifest;
}>;Gives an asset another name, and the files that say it the new one
runScripts
runScripts(): Promise<RunScript[]>;The scripts the project lets the editor run, each as it stands
saveAssetCategories
saveAssetCategories(folder: string, categories: Record<string, unknown>): Promise<{
manifest: Manifest;
}>;Writes the categories of a game's folder (categories of its assets.json, by id), all of them: says what it holds then
saveAssetTags
saveAssetTags(folder: string, tags: Record<string, string[]>): Promise<{
manifest: Manifest;
}>;Writes the tags of a game's own files (tags of its assets.json, by path), all of them
saveData
saveData(game: string, kind: DataKind, id: string, values: Record<string, unknown>): Promise<{
file: string;
values: DataValues;
}>;Keeps values of a definition changed in the editor's Data panel in the game's data.json (S61), merged into what it has of it there (a null takes a field out), which the game reads over its code (layData)
saveLook
saveLook(game: string, type: string, entry: LooksEntry | undefined): Promise<{
file: string;
looks: LooksFile;
}>;Writes what a unit type looks like into the game's looks.json, or takes it out with nothing
saveMap
saveMap(game: string, name: string, map: GameMap, options?: {
force?: boolean;
}): Promise<{
file: string;
names: string;
version: string;
}>;Writes a map to its file, and the names in it next to it. Returns where, from the root of the project, and the file's new version. Checked against the version this editor read or wrote last (none for a file it never had): one changed since rejects with MapChanged, unless force writes it all the same
saveMapFiles
saveMapFiles(game: string, name: string, pack: MapPack): Promise<void>;Keeps the files a map of the project brings with it beside its file: what was there and is not in pack goes
savePrefab
savePrefab(game: string, name: string, clip: unknown): Promise<{
file: string;
}>;Keeps a prefab as a file of the project
saveRaceAi
saveRaceAi(game: string, race: string, profile: Record<string, unknown>): Promise<{
file: string;
}>;Keeps how the game's computers play a race in its data.json (ai.races[race], campaign plan AR4): the whole profile, in the place of what the file had; an empty one takes it out. The game reads it over its code (layData)
saveRules
saveRules(game: string, path: string, value: unknown): Promise<{
file: string;
}>;Keeps a part of the rules as data in the game's data.json (rules, campaign plan RC7: supply, heroes, resources, upkeep), whole, in place of what the file had there
saveScenario
saveScenario(game: string, name: string, scenario: ScenarioFile): Promise<{
file: string;
}>;Writes a scenario into the tests, the tests' scenarios (<scenarios>/<game>/<name>.scenario.json: tests/scenarios unless the project says otherwise) (see ScenarioFile)
saveSection
saveSection(game: string, section: 'tags' | 'callings' | 'defaults' | 'cellLayers', id: string, value: unknown): Promise<{
file: string;
}>;Keeps one entry of a part of the game's data.json kept by id, whole (items-and-spells plan, phase 9): a tag named (tags), a calling (callings), what is taken of a default set (defaults), what is said of a layer of cells' values by the layer's id (cellLayers: its styles of grass, DataCellLayer); null takes it out
saveTuning
saveTuning(game: string, values: Record<string, number>): Promise<{
file: string;
tuning: Record<string, number>;
}>;Keeps values from the tuning panel in the game's tuning.json, which the game reads as its defaults (layTuning)
scaffolds
scaffolds(game: string): Promise<{
kinds: ScaffoldKind[];
folders: string[];
}>;What new code the dev server can write for a game (scaffoldStub): the folders the project lists for it, none by default
scaffoldStub
scaffoldStub(game: string, stub: {
kind: ScaffoldKind;
id: string;
name?: string;
folder?: string;
}): Promise<{
file: string;
line: number;
}>;Writes a stub of code from the editor's templates into a folder the project lists (the first, or folder): where it is, from the project's root, and the line to open it at. Rejects with why not (a file of that name is there: it is never written over)
set
set(has: boolean): void;Says whether there is a project, in the place of asking: a page that keeps maps its own way says no
startScript
startScript(script: string): Promise<RunScript[]>;Starts a script of that list by its name. Rejects with why not (one not on the list, one running already)
stopScript
stopScript(script: string): Promise<RunScript[]>;Stops a script of that list, and all it started. Over when nothing of it is left