Author Topic: VSCode OpenXcom Modding Tools  (Read 2179 times)

Offline pedroterzero

  • Sergeant
  • **
  • Posts: 19
    • View Profile
VSCode OpenXcom Modding Tools
« on: December 14, 2020, 03:17:24 pm »
Hi there!

I recently started work on a visual studio code extension that works in addition to the existing excellent Ruleset Validator by SupSuper.

My aim is to make a bit more of modding IDE experience for OpenXcom (Extended) rulesets by adding some IDE like features to the ruleset editing itself. The goal is to increase the quality of life during modding even more by solving a few of the problems that I saw myself while doing some work on mods. It should also raise the general quality of the rulesets themselves by pointing out issues that are easily overlooked if they're only inspected manually.

Some of the more interesting features are:

  • Jump from a string ID or sprite ID to its definition. This saves a lot switching back and forth manually between files
  • Y-script syntax highlighting/colouring
  • See translations for string IDs by hovering on them
  • Reference checking. This means that it checks automatically whether a string ID you've entered actually exists and whether it is of the right type (so if something expects a research entry, it checks that it is)
  • Documentation hover. The tool integrates the documentation from the ruleset wiki page into the tool itself, so you can hover over a rule to see what it means and what the options are.
  • Preview extraSprites by hovering over them in the ruleset file itself
  • Finds duplicate string ids and sprite ids. That way if you inadvertently defined something twice, you can easily see it in an overview (this feature is disabled by default)

Some features I hope to add in the future:

  • Show missing translations
  • Detect common problems that may lead to crashes or segmentation faults and prevent them before they happen
  • Context aware autocomplete across files: offer autocomplete on items that are in other files, and also of the correct type (so if a research entry is required, only offer those and not manufacture rules for example)
  • and more

Where to get it and more information
The extension and instructions how to install it, and a lot more information can be found on the visual studio marketplace: https://marketplace.visualstudio.com/items?itemName=pedroterzero.oxc-yaml-helper

Some demos of what this looks like:

Jump to definition


Syntax highlighting/colouring


Reference checking:


Documentation hover:

« Last Edit: February 28, 2021, 12:27:23 am by pedroterzero »

Offline pedroterzero

  • Sergeant
  • **
  • Posts: 19
    • View Profile
Re: VSCode OpenXcom Modding Tools
« Reply #1 on: December 14, 2020, 04:28:43 pm »
Making a second post so I can link (sorry :()

Offline Finnik

  • Colonel
  • ****
  • Posts: 218
    • View Profile
Re: VSCode OpenXcom Modding Tools
« Reply #2 on: December 14, 2020, 05:18:23 pm »
This a great tool I was using for a while (as I was honored to be an alpha tester), it is invaluable for making big mods, so I refuse to do modding without it, and this thing is in my must-have list (together with ruleset tools and map editor), so I recommend to use it to everyone!

Offline Yankes

  • Commander
  • *****
  • Posts: 2480
    • View Profile
Re: VSCode OpenXcom Modding Tools
« Reply #3 on: December 14, 2020, 05:47:37 pm »
Making a second post so I can link (sorry :()
how could you! :>

y-scripts syntax highlighting
I would be very grateful, how much syntax could you highlighting? Line know function names? I make in my script code option to dump all know symbols.
Right now format is not very parser friendly, but I could alter it to return some format that could be used by human and machines.

Offline Finnik

  • Colonel
  • ****
  • Posts: 218
    • View Profile
Re: VSCode OpenXcom Modding Tools
« Reply #4 on: December 14, 2020, 08:35:57 pm »
I would be very grateful, how much syntax could you highlighting? Line know function names? I make in my script code option to dump all know symbols.
Right now format is not very parser friendly, but I could alter it to return some format that could be used by human and machines.

I think it would be great!
And also auto-suggest of it, like how IDE does, I'm casting `itemRule.get` and it suggests what can I get based on what hook I am scripting. Highlighting variables, tag names, remembering variables to warn it is not defined in the beginning of the script or there is no such tag.
I am sure that would really help to populate y-scripting to people if there would be a good helper around.

Offline pedroterzero

  • Sergeant
  • **
  • Posts: 19
    • View Profile
Re: VSCode OpenXcom Modding Tools
« Reply #5 on: December 14, 2020, 09:00:48 pm »
This a great tool I was using for a while (as I was honored to be an alpha tester), it is invaluable for making big mods, so I refuse to do modding without it, and this thing is in my must-have list (together with ruleset tools and map editor), so I recommend to use it to everyone!

Thank you for your kind words!

I would be very grateful, how much syntax could you highlighting? Line know function names? I make in my script code option to dump all know symbols.
Right now format is not very parser friendly, but I could alter it to return some format that could be used by human and machines.

For now it would probably mostly about colouring the code in VSCode. I was hoping to base it an another language and add some specific stuff. What language would be a good pick for this?

I was hoping to use this as a basis: https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide -- VSCode uses TextMate internally. I have never done it before so it'll take a bit of experimentation ;)
It would help to have all symbols, that way I can possibly even add some semantic highlighting later, if the syntax highlighting works.

I think it would be great!
And also auto-suggest of it, like how IDE does, I'm casting `itemRule.get` and it suggests what can I get based on what hook I am scripting. Highlighting variables, tag names, remembering variables to warn it is not defined in the beginning of the script or there is no such tag.
I am sure that would really help to populate y-scripting to people if there would be a good helper around.

This is a more advanced topic I think. This would require me to actually parse the code probably, but we'll see. First I'll start with the colouring at some point, that's probably complicated enough ;)
« Last Edit: December 14, 2020, 09:02:47 pm by pedroterzero »

Offline Yankes

  • Commander
  • *****
  • Posts: 2480
    • View Profile
Re: VSCode OpenXcom Modding Tools
« Reply #6 on: December 14, 2020, 09:19:37 pm »
y-scripts are most close to assembler, one operation per line (more accurately per `;` as it could be in one line if split by `;`). There are some exceptions like `if` blocks that can combine multiple comparison and create scope.
Variable for now can be defined only on top of script, `var TYPE NAME VALUE;` in far future I plan allow variables defined in each scope.
Each line look like
Code: [Select]
TypeAName.funcName valueOfTypeA arg1 arg2;or
Code: [Select]
valueOfTypeA.funcName  arg1 arg2;Both mean same.

Offline pedroterzero

  • Sergeant
  • **
  • Posts: 19
    • View Profile
Re: VSCode OpenXcom Modding Tools
« Reply #7 on: December 14, 2020, 09:57:45 pm »
y-scripts are most close to assembler, one operation per line (more accurately per `;` as it could be in one line if split by `;`). There are some exceptions like `if` blocks that can combine multiple comparison and create scope.

Thanks. That helps. I'll try to get it in a test version sometime (I am currently working on some other features, improved logic checking and context aware autocomplete). If I get anywhere I'll let you know!

Offline pedroterzero

  • Sergeant
  • **
  • Posts: 19
    • View Profile
Re: VSCode OpenXcom Modding Tools
« Reply #8 on: January 25, 2021, 03:25:51 pm »
I just released v0.6.0 on marketplace. This is quite a big release, although it maybe doesn't seem like it.

Most importantly I added a mechanism to do specific logic checking on rulesets. This allows for checking and preventing some common (and uncommon) crashes and segmentation faults that might occur. Some occur when starting OXCE, others happen only when the specific rule triggers.

Having them show up as problems in vscode should be big time-saver and QA improvement. Many thanks to Filip H and Finnik for providing me with input on these. I hope to add more detection as I become aware of the possible problems that could occur. Feel free to let me know when there's something the extension isn't picking up.

I am currently working on finishing a few other features too, namely scripting highlighting, context aware autocomplete (only completes the correct types, and works across files) and scripting parsing (so you can tell if you've made mistakes in the script in vscode itself).

A preview of the highlighting in action:
« Last Edit: January 25, 2021, 03:37:41 pm by pedroterzero »

Offline Yankes

  • Commander
  • *****
  • Posts: 2480
    • View Profile
Re: VSCode OpenXcom Modding Tools
« Reply #9 on: January 25, 2021, 07:15:27 pm »
Praise colors!




Offline Finnik

  • Colonel
  • ****
  • Posts: 218
    • View Profile
Re: VSCode OpenXcom Modding Tools
« Reply #10 on: February 23, 2021, 05:06:03 pm »
Can we pin this post?

Offline pedroterzero

  • Sergeant
  • **
  • Posts: 19
    • View Profile
Re: VSCode OpenXcom Modding Tools
« Reply #11 on: February 28, 2021, 12:25:54 am »
I just released version v0.7.0 with the syntax highlighting to the marketplace, so it's now ready for use!

Offline pedroterzero

  • Sergeant
  • **
  • Posts: 19
    • View Profile
Re: VSCode OpenXcom Modding Tools
« Reply #12 on: April 26, 2021, 11:53:27 am »
Over the weekend I released 0.8.0 with a new feature and a quite some fixes. It now has context aware autocomplete, across files. From the readme:

Quote
Go to where you would like to insert a reference to another rule, then type CTRL+space. This will you show you approppriate suggestions; for example when adding an item to requiresBuy in items, it will only show research rules. It will also work across files, making life easier.

This is what it looks like:



Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 10164
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: VSCode OpenXcom Modding Tools
« Reply #13 on: April 26, 2021, 04:42:42 pm »
Sounds useful. Many thanks for your work!

Offline efrenespartano

  • Commander
  • *****
  • Posts: 668
  • I know a lot about the law and other lawyerings.
    • View Profile
Re: VSCode OpenXcom Modding Tools
« Reply #14 on: April 26, 2021, 04:48:48 pm »
Over the weekend I released 0.8.0 with a new feature and a quite some fixes. It now has context aware autocomplete, across files. From the readme: