Skip to content

Commit

Permalink
Merge 7ba33bc into 73a04df
Browse files Browse the repository at this point in the history
  • Loading branch information
rufreakde committed Dec 9, 2019
2 parents 73a04df + 7ba33bc commit 04a8b43
Show file tree
Hide file tree
Showing 44 changed files with 7,250 additions and 2,118 deletions.
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,18 @@ examples/warToJson/files/output/other/*.json
coverage/
.nyc_output/
test/.output
**/*d.ts
**/*d.ts.map
**/*js.map


### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

### VisualStudioCode Patch ###
# Ignore all local history of files
.history
2,435 changes: 2,435 additions & 0 deletions .tsbuildinfo

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Mocha",
"skipFiles": [
"<node_internals>/**"
],
"preLaunchTask": "build_ts",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"stopOnEntry": false,
"args": [
"test/**/*.js",
"--no-timeouts"
],
"cwd": "${workspaceRoot}",
"runtimeExecutable": null,
"env": {
"NODE_ENV": "testing"
}
}
]
}
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"files.exclude": {
"**/*.js": true,
"**/*d.ts": true,
"**/*d.ts.map": true,
"node_modules/": true,
"**/*js.map": true
}
}
13 changes: 13 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build_ts",
"command": "tsc", // Could be any other shell command
"args": [
"--build"
],
"type": "shell"
}
]
}
30 changes: 23 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,42 @@ WC3MapTranslator is a module to convert a JSON representation of WarCraft III (.

This API is a core component of [Ice Sickle](https://github.com/ChiefOfGxBxL/Ice-Sickle), the next-generation world editor. Ice Sickle stores data in a JSON format, and then generates all the necessary files to assemble a .w3x MPQ archive to build a map.

WC3MapTranslator is written in `TypeScript` starting from verison `3.0.0` therefore supports build in types.

## Install
```js
```ts
npm install wc3maptranslator
```
**Requires Node >= 8**

## Usage
```js
## Usage JS (version < 3.0.0)
```ts
var Translator = require('wc3maptranslator'),
mapJson = { // Refer to "Specification"
units: [...],
doodads: [...],
...
};
var unitResult = new Translator.Units.jsonToWar(mapJson.units);
```
## Usage TS (version >= 3.0.0)
```ts
// JS import
const TranslatorLib = require('wc3maptranslator');
const Translator = new TranslatorLib.default();
console.log(Translator);

//... or TS import
import * as TranslatorLib from 'wc3maptranslator';
const Translator = new TranslatorLib.default();
console.log(Translator);

const unitResult = new Translator.Units.jsonToWar(mapJson.units);
// We can now write the `unitResult.buffer` content to a file named "war3mapUnits.doo" and put it in a .w3x archive!

// Using individual translators, we may convert JSON
// representation to generate a WC3 .w3x map file.
// See the Wiki for more information.

var unitResult = new Translator.Units.jsonToWar(mapJson.units);
// We can now write the `unitResult.buffer` content to a file named "war3mapUnits.doo" and put it in a .w3x archive!
```

## Examples
Expand Down Expand Up @@ -118,6 +133,7 @@ All output files are placed in the `output` directory.

| Type | Json → War | War → Json | File |
|-------------------------|:-----------:|:-----------:|---------------|
| LUA | ![times](https://cloud.githubusercontent.com/assets/4079034/25298707/7a883642-26c5-11e7-841c-cd3eb1425461.png) | ![times](https://cloud.githubusercontent.com/assets/4079034/25298707/7a883642-26c5-11e7-841c-cd3eb1425461.png) | war3map.lua |
| JASS | ![times](https://cloud.githubusercontent.com/assets/4079034/25298707/7a883642-26c5-11e7-841c-cd3eb1425461.png) | ![times](https://cloud.githubusercontent.com/assets/4079034/25298707/7a883642-26c5-11e7-841c-cd3eb1425461.png) | war3map.j |
| Strings | ![check](https://cloud.githubusercontent.com/assets/4079034/25298706/7a881946-26c5-11e7-896b-402f60a0f059.png) | ![check](https://cloud.githubusercontent.com/assets/4079034/25298706/7a881946-26c5-11e7-896b-402f60a0f059.png) | war3map.wts |

Expand Down Expand Up @@ -162,4 +178,4 @@ We encourage contributions! Generally, the process of making a change is:
A code review is required on your PR to be accepted into `master`. A project member will get back to you within one week. If you haven't heard from someone regarding your PR, feel free to ping @chiefofgxbxl.

## Special Thanks
We owe a lot of thanks to *Chocobo* on [TheHelper](http://www.thehelper.net/) for the detailed documentation of the files found in a .w3x archive. Two tutorials are [here (1)](http://www.thehelper.net/threads/guide-explanation-of-w3m-and-w3x-files.35292/) and [here (2)](http://world-editor-tutorials.thehelper.net/cat_usersubmit.php?view=42787).
We owe a lot of thanks to *Chocobo* on [TheHelper](http://www.thehelper.net/) for the detailed documentation of the files found in a .w3x archive. Two tutorials are [here (1)](http://www.thehelper.net/threads/guide-explanation-of-w3m-and-w3x-files.35292/) and [here (2)](http://world-editor-tutorials.thehelper.net/cat_usersubmit.php?view=42787).
36 changes: 19 additions & 17 deletions index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { DoodadsTranslator, StringsTranslator, TerrainTranslator, UnitsTranslator, RegionsTranslator, CamerasTranslator, SoundsTranslator, ObjectsTranslator, ImportsTranslator, InfoTranslator } from './lib/translators';

export default class Translator {

public Doodads: DoodadsTranslator;
public Strings: StringsTranslator;
public Terrain: TerrainTranslator;
public Units: UnitsTranslator;
public Regions: RegionsTranslator;
public Cameras: CamerasTranslator;
public Sounds: SoundsTranslator;

public Objects: ObjectsTranslator;

public Imports: ImportsTranslator;
public Info: InfoTranslator;

constructor() {
this.Doodads = new DoodadsTranslator();
this.Strings = new StringsTranslator();
this.Terrain = new TerrainTranslator();
this.Units = new UnitsTranslator();
this.Regions = new RegionsTranslator();
this.Cameras = new CamerasTranslator();
this.Sounds = new SoundsTranslator();

this.Objects = new ObjectsTranslator();

this.Imports = new ImportsTranslator();
this.Info = new InfoTranslator();
}

}
137 changes: 62 additions & 75 deletions lib/HexBuffer.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 04a8b43

Please sign in to comment.