ChiefOfGxBxL / WC3MapTranslator

Translate war3map ⇄ json formats for WarCraft III .w3x maps
https://www.npmjs.com/package/wc3maptranslator
MIT License
73 stars 31 forks source link

Typescript support? #24

Closed ttay24 closed 4 years ago

ttay24 commented 4 years ago

Are there any plans/has work been done for typescript support? Is that something that is wanted?

ChiefOfGxBxL commented 4 years ago

No work has been done on Typescript support. It would be interesting to be able to enforce the structures of things like units, doodads, etc. and would require minimal work, but for now I do not plan on working on it. If you'd like to work on it, the Wiki documents all the definitions.

rufreakde commented 4 years ago

Hi, I use tsc Version 3.7.2 (Typescript latest)

Just cloned your project added a tsconfig.json

{
  "compilerOptions": {
    "types": [],
    "traceResolution": true,
    "declaration": true,
    "declarationMap": true,
    "target": "es2016",
    "module": "commonjs",
    "outDir": "./",
    "rootDir": "./",
    "sourceMap": true,
    "incremental": true,
    "tsBuildInfoFile": "./.tsbuildinfo",
    "esModuleInterop": true,
    "allowJs": true,
    "checkJs": true,
    "noEmit": false,
    "emitDeclarationOnly": true,
  },
  "exclude": [],
  "include": [
    "./**/*"
  ]
}

Run the command: tsc -p tsconfig.json

And it created all the d.ts files for me. Maybe you can check this out. There are some type failures/missmatches.

Edit. tried some stuff with it today but does not help much. I think I fork you project and rewrite it to ts. 👍

https://github.com/rufreakde/WC3MapTranslator (TS) there are some tests failing atm I might have accidently used wrong types.

rufreakde commented 4 years ago

Update: nvm the tests https://github.com/ChiefOfGxBxL/WC3MapTranslator/issues/19

rufreakde commented 4 years ago

@ChiefOfGxBxL did you think about switching your development from js to ts? We could merge my fork into your master with a PR and some intensive reviews and testing. ;)

Have a nice weekend, rufreakde

(ps: I found a typo in your //UNSUPORTED section where you used a getChar() instead of getChars(1) on a W3Buffer.)

ChiefOfGxBxL commented 4 years ago

@rufreakde I appreciate you working on this! 😃

I glanced through your fork and things are looking good so far -- the interfaces definitely help. I'll clone your work and take it for a spin next weekend (Dec 7th - 8th).

rufreakde commented 4 years ago

:D Nice Glad I could help! looking forward to it. If you need some help just let me know.

rufreakde commented 4 years ago

Should I create a PR? Or do you want to check the code out yourself and create on yourself?

ChiefOfGxBxL commented 4 years ago

Yes, please create a PR.

I have built the TS on my end and tested it out. I'll leave some comments on improvements, but the core TS upgrade is good!

rufreakde commented 4 years ago

PR: https://github.com/ChiefOfGxBxL/WC3MapTranslator/pull/28 👍

Also a question from my side. Do you know where the lua code is stored? Is it also in .j files like the jass ones? Did not find any list files for this... Or is there a listfile example in some wiki for the newest w3m extracted (lua enabled) reforged map? I am new to this stuff.

rufreakde commented 4 years ago

I will change the readme back to its original form later but it is to late right now just so you know ;)

ChiefOfGxBxL commented 4 years ago

PR: #28 👍

Also a question from my side. Do you know where the lua code is stored? Is it also in .j files like the jass ones? Did not find any list files for this... Or is there a listfile example in some wiki for the newest w3m extracted (lua enabled) reforged map? I am new to this stuff.

Honestly I haven't upgraded WarCraft III in a while, so I wouldn't know. My plan was to buy Reforged once Beta has had its run and all the bugs/inconsistencies are worked out, since they could change their stuff at any time and then we'd have to re-do work on this project.

I could, however, see if there are newer maps on HiveWorkshop that are made with the newer patches, and use an MPQ editor to poke around. Will get back to you on this within 2 weeks - need more time due to holidays and other events going on. 🎅

I am excited about the Lua support; it's going to offer a lot more to developers! So digging into this question will be fun.

ttay24 commented 4 years ago

This PR is exciting, I love typescript (I’ve been using it for WC3 map development actually).

When you use lua, it’s just like the JASS file, but in lua. I believe it’s called war3map.lua or something like that.

ttay24 commented 4 years ago

You could use this tool called ceres for this. It can take a lua file (external) and resolve “dependencies” (using require), bundle it together, and inject it into the war3map.lua. I use a similar process with typescript, but you have to transpile ts to lua first.

I’m not sure. I’ve been creating MPQs with Zezula’s tool for the beta and that seemed to work. I’m on Discord

rufreakde commented 4 years ago

Found the informations I needed (writing now a ts programm to do all the commands automatically and creating a npm package for it later):

https://github.com/rufreakde/Wc3MapWorker

ChiefOfGxBxL commented 4 years ago

Closed by #28 being merged in.