Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/docs/editor/adapt-a-project.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ description: 'What the editor changes so it can edit a game made without it, sho

A game written before the editor, or by hand, works in it as it is. Some ways of writing it, though, keep parts of the game out of the panels. The **Project** screen counts them under **Adapt to the editor**, and **Show suggestions** lists them: one card each, saying what the editor can't do and why the change helps.

Nothing changes on its own. A card's button shows the change first: every file it creates, changes or removes, with its lines. **Apply** makes it as one step: `Ctrl+Z` on the Project screen puts every file back. When the project is a Git repository, the preview reminds you to commit first, so you can compare afterwards. A file with unsaved changes is never overwritten: save it first.
Nothing changes on its own. Most cards have a button ending in `…` (**Move to files of their own…**, **Add the editor library…**) that shows the change first: every file it creates, changes or removes, with its lines. **Apply** makes it as one step, and `Ctrl+Z` on the Project screen puts every file back. When the project is a Git repository, the preview reminds you to commit first, so you can compare afterwards. A file with unsaved changes is never overwritten: save it first.

The install cards are the exception: **Install dependencies** runs the package manager at once, with no preview and no undo.

**Dismiss** puts a card away for this project. _Settings › Editor › Project › Dismissed suggestions_ brings it back.

Expand Down
12 changes: 8 additions & 4 deletions docs/docs/editor/code-editor.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: 'Edit the game code with types, errors and formatting'

The **Script** screen is a code editor with what an IDE has: completion, types of your code and of the engine, errors as you type, go to definition, rename, formatting.

![The code editor](../images/code-editor.png)
![The Script screen: a TypeScript file open in the code editor, with tabs above it](../images/code-editor.png)

## Tabs and split

Expand Down Expand Up @@ -38,6 +38,8 @@ _Settings › Editor › Code editor_ has the automatic options, under _Saving_
| Rename a symbol everywhere | `F2` |
| Format the file | `Shift+Alt+F` |
| Organize imports | `Shift+Alt+O` |
| Split the editor | `Ctrl+\` |
| Close the tab | `Alt+W` |

Definitions inside engine packages (`@nanoforge-dev/*`) and installed packages open read-only.

Expand All @@ -47,12 +49,14 @@ TypeScript errors are underlined in the code and listed in the **Problems** pane

## Formatting

Formatting uses **the project's own Prettier**, with its configuration and plugins. A hosted editor uses a built-in Prettier with the project's `.prettierrc`.
Formatting uses **the project's own Prettier**, with its configuration and plugins. A hosted editor, or a folder you have not trusted, uses a built-in Prettier with the project's `.prettierrc`.

_Settings › Editor › Code editor › Display_ sets the font size, the minimap and the wrapping of long lines.

## When a file changes on disk

A file without unsaved changes reloads silently. A file **with** unsaved changes shows a banner: **Compare** (your version next to the one on disk), **Keep mine**, or **Load disk version**.
A file without unsaved changes reloads silently. A file **with** unsaved changes shows a banner: **Compare** (your version next to the one on disk), **Keep mine**, or **Load disk version**. When the file was deleted on disk, the banner offers **Keep mine** only.

## Panels beside the code

When the open file defines a component, a **Component** panel can show next to the code (a toggle in the editor's toolbar): see [Components](components#how-a-component-looks-in-the-inspector).
When the open file defines a component, **Show the Component panel** (a button at the right edge of the editor) opens a panel next to the code: see [Components](components#how-a-component-looks-in-the-inspector).
18 changes: 9 additions & 9 deletions docs/docs/editor/components.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ export class Position {

## The Components panel

![The Components panel](../images/ecs-components.png)
![The Components panel: components and systems grouped by app, shared library and installed package, with the details of the selected one](../images/ecs-components.png)

The panel lists the components (**C**) and systems (**S**) the selected app can use, grouped by where they come from:

- **App**: the app's own;
- **Shared library**: code shared by the client and the server;
- **Installed packages**: read-only, with a lock.
- **App** [name]: the app's own;
- **Shared library** [name]: code shared by the client and the server;
- **Installed package** [name]: read-only, with a lock.

Select one to read its description, its parameters and where it is defined. The search box filters by name.
Select one to read its description, its parameters and where it is defined. Double-click it, or click **Open in code**, to open its file. The search box filters by name.

An item marked _untagged_ was recognized from the code but has no `@component` or `@system` tag: add the tag to make it explicit.

## Create a component

**New › New component in app**, then a name. The file is created in the app's components folder, with its tags, and opens in the code editor.
**New › New component in app** [app], then a name. The file is created in the app's components folder, with its tags, and opens in the code editor. The **New** menu has one entry for the selected app and one per shared library.

## Add it to an entity

Expand All @@ -49,7 +49,7 @@ Select an entity in the **Hierarchy**, select the component in the panel and cli
A **shared library** holds components and systems that both apps use.

- **New › New shared library…** creates it (a folder in `libs/` and a package name such as `@my-game/shared`).
- **New › New component in shared library** creates a component there.
- **New › New component in shared library** [library] creates a component there.
- **Move to shared library** moves an app's component into it and rewrites every import in the project, in one step you can undo.

Apps import shared code by package name: `@my-game/shared/components/player`.
Expand Down Expand Up @@ -98,8 +98,8 @@ export class Position {

### Without writing tags

Open the component's file: the **Component** panel beside the code (a toggle in the editor's toolbar, or _Edit layout_ in the inspector's ⋯ menu and in the Components panel) has a control for each of these, and a preview. It writes the tags for you. A tag that can't apply (a preset missing a slot) is a warning on the component, in the panel, in the code and in **Problems**.
Open the component's file: the **Component** panel beside the code (**Show the Component panel** at the right edge of the code editor, or _Edit layout_ in the Inspector's ⋯ menu and in the Components panel) has a control for each of these, and a preview. It writes the tags for you. A tag that can't apply (a preset missing a slot) is a warning on the component, in the panel, in the code and in **Problems**.

## Two components with the same name

The engine finds a component by its `name`. When an app can use two components with the same name (yours and a package's), the panel warns, and the app's own is the one used.
The engine finds a component by its `name`. When an app can use two components with the same name (yours and a package's), the Components panel warns: rename one of them.
4 changes: 2 additions & 2 deletions docs/docs/editor/entities.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: 'The entities of an app: hierarchy, inspector and the Scene screen'

Entities are the objects of your game: the player, the ball, the background. An entity is only a name; **components** give it data, and **systems** make it act.

In NanoForge, entities are created in the app's `main.ts`: In a game made of [scenes](scenes), each scene creates its own in its `setup`, edited the same way.
In NanoForge, entities are created in the app's `main.ts`. In a game made of [scenes](scenes), each scene creates its own in its `setup`, edited the same way.

```ts
const ball = registry.spawnEntity();
Expand Down Expand Up @@ -45,7 +45,7 @@ Select an entity: the **Inspector** shows its components, with one field per par

- Change a value: only that value changes in the code.
- **Add component…** lists the components the app can use. The import is added for you.
- The **⋯** menu of a component removes it, opens its code, or edits how it is laid out.
- The **⋯** menu of a component moves it up or down, removes it, opens its source, or edits how it is laid out (_Edit layout_).

Fields follow the parameter's type: numbers, text, lists of choices, switches, colors. A value the editor has no field for (an engine object such as `new Rect(…)`) is shown as code, which you can edit.

Expand Down
24 changes: 13 additions & 11 deletions docs/docs/editor/files.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ icon: 'folder-tree'
description: 'Browse and organize the project files'
---

The **Files** panel shows the project's folders as a tree and, below it, the selected folder as a grid with thumbnails of images. The buttons at the top switch between the tree alone and the tree with the grid. In the grid, the arrow keys move between files, `Enter` opens one, `Space` selects it (`Ctrl+Space` adds it to the selection) and `Backspace` goes to the parent folder.
The **Files** panel shows the project's folders as a tree and, below it, the selected folder as a grid with thumbnails of images. **Hide the grid** (at the top of the panel) leaves the tree alone; **Show the grid** brings it back.

In the grid, the arrow keys, `Home` and `End` move between files, `Enter` opens one, `Space` selects it (`Ctrl+Space` adds it to the selection), and `Backspace` or `Alt+Up` goes to the parent folder.

## Open

Expand All @@ -16,15 +18,15 @@ The **+** button, or right-click a folder and **New**: a file, a folder, or a te

## Organize

| To | Do |
| ------------ | --------------------------------------------------------------------------------------------- |
| Rename | `F2`, or right-click › Rename |
| Move | Drag the file onto a folder, or cut and paste |
| Copy | `Ctrl+C` then `Ctrl+V`; `Ctrl+D` duplicates in place |
| Delete | `Delete`. A folder or several files ask first. |
| Import | Drop files from your computer onto a folder, or the import button |
| Download | Right-click › Download. A folder downloads as a `.zip` (without `nf_modules`, 1 GiB at most). |
| Show on disk | Right-click › Reveal in file manager (local editors) |
| To | Do |
| ------------ | ------------------------------------------------------------------------------------------------- |
| Rename | `F2`, or right-click › Rename |
| Move | Drag the file onto a folder, or cut and paste |
| Copy | `Ctrl+C` then `Ctrl+V`; `Ctrl+D` duplicates in place |
| Delete | `Delete`. A folder or several files ask first. |
| Import | Drop files from your computer onto a folder, or the import button |
| Download | Right-click › Download, or › Download as .zip for a folder (without `nf_modules`, 1 GiB at most). |
| Show on disk | Right-click › Reveal in file manager (local editors) |

Every one of these can be undone with `Ctrl+Z` while the Files panel has focus. A deleted file goes to the editor's trash and comes back on undo; the trash is emptied of what was deleted over 30 days ago.

Expand All @@ -34,7 +36,7 @@ The box at the top filters by name. Letters only need to be in order, and the ma

## Hidden files

- The panel hides `node_modules`, `dist`, and files starting with a dot (except `.env`). The eye button shows them; _Settings › Editor › Files_ changes the list.
- The panel hides `node_modules`, `dist`, `.turbo`, `coverage`, and files starting with a dot (except `.env`). **Show hidden files** (the eye button) shows them; _Settings › Editor › Files › Hidden files_ changes the list.
- A `.nfignore` file at the project root (same syntax as `.gitignore`) hides files from the **whole editor**: this panel, the file pickers and the code analysis. Builds and the game still see them.

## Packages
Expand Down
25 changes: 13 additions & 12 deletions docs/docs/editor/git.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@ The **Commit** panel on the left lists what changed since the last commit, as fi
2. Write a message.
3. **Commit**, or **Commit and push…**

**Amend** replaces the last commit instead of adding one.

| To | Do |
| -------------------------- | ------------------------------------------------------------------- |
| See what changed in a file | Double-click it: the diff opens in the code editor. |
| Undo your changes to files | Select them, then **Rollback**. It asks first: it cannot be undone. |
| Start tracking a new file | Right-click › Add to VCS |
| Ignore a file | Right-click › Add to .gitignore |
| Copy a file's path | Right-click › Copy path |
| Put changes aside | The **Stash** tab: Stash changes, then Apply, Pop or Drop |
Tick **Amend** to replace the last commit instead of adding one. The history button beside the message brings back an earlier message. The toolbar above the list has **Refresh**, **Show diff** (`Ctrl+D`), **Expand all** and **Collapse all**.

| To | Do |
| -------------------------- | ----------------------------------------------------------------------------------- |
| See what changed in a file | Double-click it: the diff opens in the code editor. |
| Undo your changes to files | Select them, then **Rollback…** (`Ctrl+Alt+Z`). It asks first: it cannot be undone. |
| Open the file | Right-click › Jump to source (`F4`) |
| Start tracking a new file | Right-click › Add to VCS |
| Ignore a file | Right-click › Add to .gitignore |
| Copy a file's path | Right-click › Copy path |
| Put changes aside | The **Stash** tab: **Stash changes**, then Apply, Pop or Drop |

Checking a file only chooses what is committed. Selecting rows (click, `Ctrl`+click, `Shift`+click, or a click on a group to select all its files) is what Rollback and the other actions act on.

Expand All @@ -46,8 +47,8 @@ The status bar shows the branch and what is ahead and behind (`main ↑1 ↓2`).

The **Git** panel at the bottom has three parts:

- **Branches**: the current one, local ones, and remote ones. Double-click a branch to check it out. Right-click for _New branch from…_, _Update_, _Push…_, _Delete_.
- **Commits** of the selected branch, with a filter by text, author and date.
- **Branches**: _HEAD (Current Branch)_, _Local_ and _Remote_. Double-click a branch to check it out. Right-click for _Checkout_, _New branch from…_, _Update_, _Push…_ and _Delete_.
- **Commits** of the selected branch, with a filter by text, author and date. **Show more** loads older ones; right-click › _Copy revision number_ copies a hash.
- **Changed files** of the selected commit, and its details: the whole message, hash, author, date. Double-click a file to compare. The panel keeps the selected branch and commit.

_VCS › New branch…_ creates a branch from the current commit and switches to it.
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/editor/layout.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ In a row of tabs or panel icons, the arrow keys move between them, `Enter` shows

_View › Layouts_:

- **Save layout** keeps the current arrangement under a name;
- **Save layout as…** keeps the current arrangement under a name;
- the saved layouts are listed there: choose one to switch to it;
- **Simple layout** shows the main panels only (Files, Hierarchy, Scenes, Inspector, Console), **All panels** every one; each puts the layout back to that default, and becomes the default of _Reset layout_ (the setting _Default layout_). A new editor starts with the simple one.
- **Simple layout** shows the main panels only (Files, Hierarchy, Scenes, Inspector, Console), and **All panels** shows every one. Each resets the layout to that set and makes it the default (the _Default layout_ setting). A new editor starts with the simple one.
- **Reset layout** goes back to the default.

Moving, closing, floating and resizing a panel are steps you can undo: `Ctrl+Z` with the focus on the layout, or in the **History** panel under _Layout_.
Expand All @@ -51,4 +51,4 @@ With _Settings › Editor › Game view › Maximize on play_, the docks and str

## Theme

The editor follows the light or dark mode of your system until you choose a theme (_Match the system_ in _Settings › Appearance_). _View › Toggle light/dark theme_, or _Settings › Appearance_ to choose one. Plugins can add themes.
The editor follows the light or dark mode of your system (_Match the system_) until you choose a theme. Switch with _View › Toggle light/dark theme_, or choose one in _Settings › Editor › Appearance_. Plugins can add themes: see [Settings](settings#appearance).
Loading
Loading