Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Xeeynamo authored Feb 16, 2020
2 parents b2d2695 + 760edf1 commit e057e62
Show file tree
Hide file tree
Showing 335 changed files with 11,312 additions and 1,903 deletions.
1 change: 1 addition & 0 deletions CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
openkh.dev
50 changes: 27 additions & 23 deletions CODE_GUIDELINE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,51 @@

## Do not re-invent the wheel

The main goal of the project is to have a central point for everything related to Kingdom Hearts. If you want to use a functionality, do not start to code it before to check if it already exists. If you are not happy with the code, you do not understand how you can re-use it or if you want to improve it, check the [contributing guide](CONTRIBUTING.md).
The main goal of the project is to have a central point for everything related to Kingdom Hearts. If you want to add functionality, do not start coding something unless you've checked and made sure it doesn't already exist. If you are not happy with the code, do not understand how you can use it, or if you want to improve upon it, check the [contributing guide](CONTRIBUTING.md) or ask for assistance from other maintainers.

## The power of refactoring

It is okay to not strictly respect the content below this document (however it is a best practice to follow it in order to achieve optimal and comformant code). Regardless the technology, the programming language used or the coding style, as long as something works it is fine; it can be always optimized and refactored later.
It is okay to not strictly respect the content below this document (however it is a best practice to follow it in order to achieve optimal and comformant code). Regardless of the technology, the programming language used, or the coding style, as long as something works, it is fine; it can be always optimized and refactored later if needed.

## Property of the code

Any portion of code committed to the repository belong to OpenKH and its community and it is subject to the specified [license](LICENSE).
Any portion of code committed to the repository belongs to OpenKH and its community and it is subject to the [specified license](LICENSE).

# Naming convention

Pascal case is used everywhere in the code. When it is using a short version of a name (eg. from Kingdom Hearts to KH), only the first letter is capitalized (eg. Kh).
Pascal case is used everywhere in the code. When it is using a short version of a name (E.g. from Kingdom Hearts to KH), only the first letter is capitalized (E.g. Kh).

## Libraries

Every library should start with `OpenKh.*`, where `*` is the short name of the game (eg. `Kh1`, `KhBbs`, `KhReCom` etc.). If the content is more related to a specific engine, use the name of the engine instead (eg. `Osaka` for KhBbs and Kh3d, `Unreal` for Kh02 and Kh3). If the content is generic, it has to be placed in `Common`, `Imaging`, `Messages` or other classes that defines a common group.
Every library should start with `OpenKh.*`, where `*` is the short name of the game (E.g. `Kh1`, `KhBbs`, `KhReCom` etc.). If the content is more related to a specific engine, use the name of the engine instead (E.g. `Tokyo` for Kh1 and Kh2, `Osaka` for KhBbs and Kh3d, `Unreal` for Kh02 and Kh3). If the content is generic, it should be placed in `Common`, `Imaging`, `Messages` or other classes that defines a common group shared between games.

## Graphics tools

Every GUI tool should start with `OpenKh.Tools.*`, where `*` is a short name of the application. It is preferrable to use a verb at the end of the name to give an idea of the capability of the tool (eg. `Viewer`, `Converter`, `Editor`). All the common logic for the GUI tools should be placed in `OpenKh.Tools.Common`
Every GUI tool should start with `OpenKh.Tools.*`, where `*` is a short name of the application. It is preferrable to use an appropriate short description at the end of the name to give an idea of the capability of the tool (E.g. `Viewer`, `Converter`, `Editor`). All the common logic for the GUI tools should be placed in `OpenKh.Tools.Common`

## Command tools

Every command line tool should start with `OpenKh.Command.*`, where `*` is a short name of the application. There are no particular restrictions about how to name a command line tool.
Every command line tool should start with `OpenKh.Command.*`, where `*` is a short name of the application. There are no particular restrictions about how to name a command line tool otherwise.

# Technology

## Programming language

Right now, all the code base is written in C# 7.0.
Currently, the entire codebase is written in C# 7.0.

The framework used for the common libraries is .Net Standard 2.0, which is compatible with .Net Core 2.0, .Net Framework 4.6.1, Mono 5.4 and others.

The framework used for the tools is .Net Framework 4.7.1, which currently works only on Windows.
The framework used for the tools is .Net Framework 4.7.1, which currently only works on Windows. There are plans to rectify this over time as the project progresses.

## Third party libraries

The main framework for GUI is `WPF`. For the rendering engine in the tools, `SharpDx` is currently used. As a game engine it is preferrable to use `MonoGame`.
The main framework for GUI is `WPF`. For the rendering engine in the tools, `SharpDx` is currently used. `Monogame` will be preferred for the game engine.

# Coding style

## Casting

Avoid hard type casting like `(Foo)obj` since it can easily throw a `InvalidCastException` on runtime. Prefer to use `obj is Foo` to check if `obj` is or inhert the type `Foo`. Use `obj as Foo` to cast on type `Foo`, which returns `null` if `obj` is not or does not inhert `Foo`, instead of throwing a runtime exception.
Avoid hard type casting like `(Foo)obj` since it can easily throw an `InvalidCastException` on runtime. Preferably, use `obj is Foo` to check if `obj` is or inhert the type `Foo`. Use `obj as Foo` to cast on type `Foo`, which returns `null` if `obj` is not or does not inhert `Foo`, instead of throwing a runtime exception.

To avoid reduntant code and use both `is` and `as` operators, it is possible to use the following statement:
```csharp
Expand All @@ -58,23 +58,23 @@ else

## Interfaces

They are a powerful instrument used for **inversion of control** and **contract** definition.
Interfaces are a powerful instrument used for **inversion of control** and **contract** definition.

A good example is [`OpenKh.Imaging.IImage`](https://github.com/Xeeynamo/OpenKh/blob/master/OpenKh.Imaging/IImage.cs), which defines the minimum amount of information to represent an image. All the methods that accepts a `IImage` as parameter can accept any image class that implements `IImage` interface.
A good example is [`OpenKh.Imaging.IImage`](https://github.com/Xeeynamo/OpenKh/blob/master/OpenKh.Imaging/IImage.cs), which defines the minimum amount of information to represent an image. All the methods that accept `IImage` as a parameter can accept any image class that implements the `IImage` interface.
## Helper methods

C# comes with this excellent feature called [extension methods](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/extension-methods) that allows to add any member to existing class or interfaces.
C# comes with this excellent feature called [extension methods](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/extension-methods) that allow the addition of any member to existing classes or interfaces.
Taking [`OpenKh.Imaging.IImageRead`](https://github.com/Xeeynamo/OpenKh/blob/master/OpenKh.Imaging/IImageRead.cs), which is a super set of `IImage`, the class [`OpenKh.Imaging.ImageHelpers`](https://github.com/Xeeynamo/OpenKh/blob/master/OpenKh.Imaging/ImageHelpers.cs) contains a bunch of methods that can be used with any ``IImageRead`.
If we take `public static void SaveImage(this IImageRead imageRead, string fileName)` as an example, it is possible to invoke `IImageRead.SaveImage(fileName)` without having that method implemented in any of the interface implementations. Now, all the classes that implements `IImageRead` can use `SaveImage` (eg. `new Imgd(input).SaveImage(output)`).
If we take `public static void SaveImage(this IImageRead imageRead, string fileName)` as an example, it is possible to invoke `IImageRead.SaveImage(fileName)` without having that method implemented in any of the interface implementations. Now, all the classes that implement `IImageRead` can use `SaveImage` (E.g. `new Imgd(input).SaveImage(output)`).

## Lambda functions

In C# it is possible to use functions as first class citizens. This becomes really useful to inject some logic into a method.
In C# it is possible to use functions as first class citizens. This is really useful for injecting logic into a method.

Eg.
E.g.

```csharp
var funcFilterBarFiles = fileName => Path.GetExtension(fileName) == ".bar";
Expand All @@ -87,9 +87,9 @@ IEnumerable<Entry> GetFiles(Func<string, bool> filter) =>

## LINQ

This is one of the most powerful libraries of C# that comes for free. With [LINQ](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/linq/basic-linq-query-operations) it is possible to perform operations to list of data in a SQL/NoSQL way, filtering, transforming, aggregating and manipulating lists. It can completely replace for loops and can dramatically reduces lines of code.
This is one of the most powerful libraries of C# that can be used for free. With [LINQ](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/linq/basic-linq-query-operations) it is possible to perform operations to list data in a SQL/NoSQL way, filtering, transforming, aggregating, and manipulating lists. It can completely replace loops and can dramatically reduce lines of code.

Eg. This is a portion of code using a common for loop:
This is a portion of code using a common for a loop:

```csharp
List<Foo> GetList(Entry[] entries)
Expand All @@ -114,12 +114,16 @@ IEnumerable<Foo> GetList(IEnumerable<Entries> entries) => entries

## Paradigm

It is preferrable to use a functional approach, which removes the over usage of branch conditions, protective code and null checking, while adding code readability.
It is preferrable to use a functional approach, which removes the overuse of branch conditions, protective code, and null checking, while supplementing code readability.

The functional paradigm comes with the concept of immutable objects rather than classes full of conditional logic. Imagine that as the `string` or `DateTime` type in C#, where once the object is created it cannot be modified.
The functional paradigm comes with the concept of immutable objects rather than classes full of conditional logic. Imagine the `string` or `DateTime` type in C#, where once the object is created it cannot be modified.

## Testing

Every line of code is supposed to be covered by unit testing. The approach used is TDD ([Test Driven Development](https://www.amazon.com/dp/0321146530)), where the tests are written before the implementation, as requirement or check list.
Every line of code is supposed to be covered by unit testing. The approach used is TDD ([Test Driven Development](https://www.amazon.com/dp/0321146530)), where the tests are written before the implementation, as requirements or a checklist.

The advantage of it is to be 100% sure that everything is working as expected, giving more confidence when refactoring. Since the tests are automated, they just requires few seconds to run.
The advantage of this method is it allows us to be 100% sure that everything works as expected. This gives more confidence in the event of refactoring. Since tests are automated, they require only seconds to run.

## Conclusion

While it may be the best practice to follow these guidelines to make code more readable, easy to use, extensive, and portable, they're not necessarily strictly enforced! We recognize that everyone has their own coding style and preferences, so taking that into account is important for a project of this scope. As such, discussion and questions regarding someone's syntax in comparison to another's is perfectly fine as long as it remains civil and provides a good experience for everyone involved. [Built by a friendly community, for a friendly community!](CODE_OF_CONDUCT.md)
41 changes: 27 additions & 14 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,21 @@

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
our community a harassment-free experience for everyone, regardless of:
* Age
* Body size
* Disability
* Ethnicity
* Sex characteristics
* Gender identity and expression
* Level of experience
* Education
* Socio-economic status
* Nationality
* Personal appearance
* Race
* Religion
* Sexual identity and orientation

## Our Standards

Expand All @@ -17,7 +28,7 @@ include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Focusing on what is best for the community and each other as a whole
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:
Expand All @@ -27,7 +38,7 @@ Examples of unacceptable behavior by participants include:
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
addresses, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

Expand All @@ -39,9 +50,9 @@ response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
that are not aligned to this Code of Conduct, or to temporarily or permanently
ban any contributor for other behaviors that they deem inappropriate, threatening,
offensive, or harmful.

## Scope

Expand All @@ -54,12 +65,14 @@ a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team to [Discord](https://discord.gg/MgTaQgf). All
Instances of harassment, abusive, or otherwise unacceptable behavior may be
reported by contacting the project team at [Discord](https://discord.gg/GVtG3Zu). All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
is deemed necessary and appropriate given the circumstances. The project team is
obligated to maintain confidentiality in regards to the reporter of an incident,
meaning details of reports and the one who reported another user will not be
named or otherwise openly shared where others can see. Further details of specific
enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
Expand Down
12 changes: 6 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ The project involves code and documentation. There is no need for you to have co

## Ask questions

Asking is the most important part when it comes to helping the project. If there is any aspect that you would like to help improve, feel free to discuss it openly!
Your curiosity is the most important part when it comes to helping the project. If there is any aspect that you would like to help improve, feel free to ask about it and otherwise discuss it openly!

There are multiple ways to open a discussion. You can [open a new issue](https://github.com/Xeeynamo/OpenKh/issues/new) or [join to our Discord server](https://discord.gg/MgTaQgf). There is even a [Trello board](https://trello.com/b/xUMpsGBE/openkh) showing an organized list of objectives that need to be worked on, have been completed, or are currently being worked on.
There are multiple ways to open a discussion. You can [open a new issue](https://github.com/Xeeynamo/OpenKh/issues/new) or [join our Discord server](https://discord.gg/GVtG3Zu). There is even a [Trello board](https://trello.com/b/xUMpsGBE/openkh) (currently unmaintained) showing an organized list of objectives that need to be worked on, have been completed, or are currently being worked on.

## Bug report

To report bugs and errors, [open a new issue](https://github.com/Xeeynamo/OpenKh/issues/new) and specify the steps to reproduce the bug, including the stack trace, messages, and the files that the tools or libraries were trying to open.
To report bugs and errors, [open a new issue](https://github.com/Xeeynamo/OpenKh/issues/new) and specify the steps taken to reproduce the bug, including the stack trace, messages, and the files that the tools or libraries were trying to open.

## Feature request

To request a feature, [open a new issue](https://github.com/Xeeynamo/OpenKh/issues/new) detailing your request. This can be anything from optimizations to new features.
To request a feature, [open a new issue](https://github.com/Xeeynamo/OpenKh/issues/new) detailing your request. This can be anything from code or format optimizations to new features.

## Code guideline

[This](CODE_GUIDELINE.md) is a document that gives an idea on the code requirements to have your content merged into the master branch. For the most part, as long as the code works as intended and can be cleaned up later if needed, it's more than welcome!
[This](CODE_GUIDELINE.md) is a document that gives an idea of the code requirements to have your content merged into the master branch. For the most part, as long as the code works as intended and can be cleaned up later if needed, it's more than welcome! While C# is the primary language, other languages are welcome as long as they do not compromise the usability or readability of the toolchain or codebase!

## Documents contribution

Documentation is really important, since it is what everyone (including non-coders) can read and understand. It includes every technical research done for all the games in the series, like file formats, differences between each version of the game, unused content, how to use the libraries, tools, or modding tutorials. RAM hacking content is more than welcome too.
Documentation is really important, as it is what everyone (including non-coders) can read and understand. It includes all technical research done for the games in the series, such as file formats, differences between various version of the game in question, unused content, how to use the libraries, tools, or modding tutorials, etc. RAM hacking content is more than welcome too.
Loading

0 comments on commit e057e62

Please sign in to comment.