Skip to content
Snippets Groups Projects
CONTRIBUTING.md 8.65 KiB
Newer Older
# Contributing to FC: Pregmod
Arkerthan's avatar
Arkerthan committed

First off, thanks for taking the time to contribute!

If there is anything you don't understand feel free to ask. The advanced tooling is not required for
fixing small typos or simple bugs.
Arkerthan's avatar
Arkerthan committed

## Environment

DCoded's avatar
DCoded committed
### Requirements
Arkerthan's avatar
Arkerthan committed

To effectively work on the project the following tools are required:

DCoded's avatar
DCoded committed
* [Git](https://git-scm.com)
DCoded's avatar
DCoded committed
* [Node.js](https://nodejs.org/en/) or another npm client
* a code editor/IDE
DCoded's avatar
DCoded committed
  * [VSCode](https://code.visualstudio.com/) is a popular option

While these tools make working on FC easier, they are not actually required.
Arkerthan's avatar
Arkerthan committed

DCoded's avatar
DCoded committed
### Setting everything up
Arkerthan's avatar
Arkerthan committed

DCoded's avatar
DCoded committed
1. Clone the project from GitGud.io ([Detailed Git setup and work cycle](devNotes/gitSetup.md))
DCoded's avatar
DCoded committed
2. Navigate to the `fc-pregmod` root directory.
   * Windows: Run `Windows Powershell` or `Command Prompt` and execute `cd C:\path\to\project\fc-pregmod`
   * Mac/Linux: Open a terminal and execute `cd /path/to/project/fc-pregmod/`
3. Run `setup.bat` (Windows) or `setup.sh` (Mac/Linux) in your terminal
4. Follow the install steps until you get to the `Welcome to FC development!...` menu and then select `Exit`
5. Open the directory in your preferred editor/IDE
DCoded's avatar
DCoded committed

**Make sure you have an extension for ESLint installed in your preferred editor/IDE to catch formatting errors**
DCoded's avatar
DCoded committed

<details><summary>Recommended editor/IDE plugins/extensions</summary>
The list below is for VSCode. If you are not using VSCode but want some of these extensions functionality, then do some research. Many of these extensions exist or have alternatives in most common editors/IDEs.
DCoded's avatar
DCoded committed

* [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
  * Catches formatting problems and lets you know when your code doesn't conform to our standards
DCoded's avatar
DCoded committed
* [Code Spell Checker](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker)
  * Catches most spelling issues
* [Error Lens](https://marketplace.visualstudio.com/items?itemName=usernamehw.errorlens)
  * Highlights lines that ESLint and Code Spell Checker have marked as having problems
* [Git Extension Pack](https://marketplace.visualstudio.com/items?itemName=donjayamanne.git-extension-pack)
  * Adds a few of tools that make working with git easier
* [IntelliCode](https://marketplace.visualstudio.com/items?itemName=VisualStudioExptTeam.vscodeintellicode)
  * Will make your day easier by suggesting functions and properties for autocompletion
  * Will also show you documentation for those suggested functions and properties
* [TODO Highlight](https://marketplace.visualstudio.com/items?itemName=wayou.vscode-todo-highlight)
  * Makes TODO comments stand out better
* [Todo Tree](https://marketplace.visualstudio.com/items?itemName=Gruntfuggly.todo-tree)
  * Adds a tab to the left sidebar that lists all TODO comments in the current project
</details>
Arkerthan's avatar
Arkerthan committed

DCoded's avatar
DCoded committed
### Compiling
Arkerthan's avatar
Arkerthan committed

Use either the simple or advanced compiler. See the `Compile the game yourself` section in the [readme](README.md) for more information.
Arkerthan's avatar
Arkerthan committed
## Code style

The coding style is based on our `.eslintrc.json`. If your editor/IDE has ESLint support it will let you know when your code doesn't conform to our standards.
  * Most editors/IDEs don't have native ESLint support and will need you to install an ESLint plugin/extension.
Arkerthan's avatar
Arkerthan committed

### Documentation
Arkerthan's avatar
Arkerthan committed

It's a good idea to provide meaningful documentation for new functions and classes where possible. We follow
Typescript's [JSDoc](https://jsdoc.app) type dialect for the most part (and we provide a Typescript configuration and
DCoded's avatar
DCoded committed
auxiliary type definition files if you'd like to use it yourself – it's pretty nifty). Don't worry too much about
specific type syntax if you can't make TS work or don't understand it, someone else will probably fix it for you as long
as you've made the intent clear in some form of JSDoc.
Arkerthan's avatar
Arkerthan committed

### Naming conventions
Arkerthan's avatar
Arkerthan committed

* JavaScript variable and function names should be `camelCase`.

```js
// good
let fooBar;

// bad
let foobar;
let Foobar;
let FooBar;
* JavaScript classes and namespaces should be `PascalCase`.

```js
class Foo {}
App.Foo.bar();

// bad
class foo {}
class FOO {}
App.foo.bar();
* Enum members should be `ALLCAPS`.

```ts
// good
enum Foo {
  BAR = 'bar',
  BAZ = 'baz',
}

// bad
enum Foo {
  bar = 'bar',
  Baz = 'baz',
}
```

This also applies to JavaScript objects that are used as enums.
/** @enum {string} */
const Foo = {
  BAR: 'bar',
  BAZ: 'baz',
}

/** @enum {string} */
const foo = {
  BAR: 'bar',
  BAZ: 'baz',
}
// worse
/** @enum {string} */
const foo = {
  bar: 'bar',
  Baz: 'baz',
}
```

* CSS classes are `kebob-case`.

```css
/* good */
.foo-bar {}

/* bad */
.fooBar {}
.FOO-BAR {}
```
Arkerthan's avatar
Arkerthan committed

Arkerthan's avatar
Arkerthan committed
New code should generally get organized into the `App` namespace. See [fc-js-init.js](js/002-config/fc-js-init.js) for a rough outline.
Arkerthan's avatar
Arkerthan committed

DCoded's avatar
DCoded committed
### JavaScript Features
DCoded's avatar
DCoded committed

Frankly George's avatar
Frankly George committed
Use modern JavaScript features when possible. We are currently targeting ECMAScript 2022, and aren't trying to support Internet Explorer or anything stupid like that (it isn't 2010 anymore). For example, use `let`/`const` rather than `var`, prefer [`Arrow function expressions`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions) to inline long-form functions, use [`nullish coalescing`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing) and [`optional chaining`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining), etc.
Arkerthan's avatar
Arkerthan committed

DCoded's avatar
DCoded committed
### Code quality
Arkerthan's avatar
Arkerthan committed

Contributions should generally not add any new sanity check errors. You can check for errors by running `sanityCheck.bat` (Windows) or `sanityCheck.sh` (Mac/Linux).
  * With the default settings this will (mostly) show you just the errors that were caused by your changes.
  * If you are not using the advanced tooling then use `legacySanityCheck.bat` or `legacySanityCheck.sh` instead.
Arkerthan's avatar
Arkerthan committed

## Project Structure

### Source files

* `src/` is the main directory for source code. It also contains the embedded art files. Since it is inside an `eval()` statement debugging and minification is more complicated than for `js/`.
* `js/` is loaded before SugarCube and therefore outside SugarCube's eval which `src/` is contained in. This means accessing SugarCube features (like `SugarCube.Engine`) is more complicated however it other than `src/` it can be minified and is easier to debug. Currently, contains mainly static data, however new code not relying on SC2 should be sorted in here too.
* `css/` contains all CSS files. The internal structure is explained [here](css/css.md).
* `themes/` contains [custom themes](themes/themes.md) which are built separately.

DCoded's avatar
DCoded committed
### Developer Files

* `devNotes/` contains various wiki files and other potentially interesting files.
* `devTools/` contains various scripts and executables needed for working with the project or compiling.
  * TypeScript typing files are stored here as well in the `types/` subdirectory.
DCoded's avatar
DCoded committed
* `submodules/` contains Git submodules
  * currently only a custom version of SugarCube 2
DCoded's avatar
DCoded committed
* `artTools/`contains files for creating and updating [vector art](artTools/README.md)
* `resources/` contains various [art related files](resources/ReadmeBeforeAddingArt.md)

### External Programs
DCoded's avatar
DCoded committed

DCoded's avatar
DCoded committed
* `docker/` contains Docker files from which the docker containers for GitLabs CI are created
* `FCHost/` contains the sources for [FCHost](FCHost/README.md)
DCoded's avatar
DCoded committed
* `saveTools/` contains tools for [editing save files](saveTools/README.md)
DCoded's avatar
DCoded committed
## Further Reading
Arkerthan's avatar
Arkerthan committed

DCoded's avatar
DCoded committed
### Wiki Files
Arkerthan's avatar
Arkerthan committed

* Event Writing Guides
  * [Twine<sup>1</sup>](devNotes/sceneGuide.md)
DCoded's avatar
DCoded committed
  * [JavaScript](devNotes/jsEventCreationGuide.md)
Arkerthan's avatar
Arkerthan committed
* [Exception handling](devNotes/exceptions.md)
* [Sanity check<sup>2</sup>](devNotes/sanityCheck.md)
Arkerthan's avatar
Arkerthan committed
* [Slave List](devNotes/slaveListing.md)
* [Pronouns](devNotes/Pronouns.md)
* External function documentation
  * [Eyes](devNotes/eyeFunctions.md)
  * [Limbs](devNotes/limbFunctions.md)
  * [Some potentially useful JS functions](devNotes/usefulJSFunctionDocumentation.md)
DCoded's avatar
DCoded committed
  * [Content embedding chart](devNotes/contentEmbeddingChart.png) (for more details refer to [this issue](https://gitgud.io/pregmodfan/fc-pregmod/-/merge_requests/7453#note_118616))
Arkerthan's avatar
Arkerthan committed

DCoded's avatar
DCoded committed
<sup>1. Twine is being phased out of the project and should not be used in new code, but the basic concepts found here still apply.</sup>

<sup>2. Only applies to the legacy sanity checks.</sup>

DCoded's avatar
DCoded committed
### Useful issues
Arkerthan's avatar
Arkerthan committed

DCoded's avatar
DCoded committed
* [Setting up VS Code](https://gitgud.io/pregmodfan/fc-pregmod/-/issues/2448)
* [Classes in Game State](https://gitgud.io/pregmodfan/fc-pregmod/-/issues/696)
* [Self executing functions](https://gitgud.io/pregmodfan/fc-pregmod/-/issues/2325)
* [Sort a map](https://gitgud.io/pregmodfan/fc-pregmod/-/issues/2642)
* [How to create a Merge Request (MR)](https://gitgud.io/pregmodfan/fc-pregmod/-/issues/3903)