-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tool: agf2autoash, agf2glvar - generate scripts out of Game.agf #1264
Tool: agf2autoash, agf2glvar - generate scripts out of Game.agf #1264
Conversation
b212bdc
to
a3d11b3
Compare
Added separate agf2glvar tool which generates global variables from same project file (Game.agf). |
i'd be interested to see output of the latter tool, especially contents of .asc file |
Here's an artificial example: Contains:
To clarify, these "global variables" are created in a separate dialog inside the editor, this is done purely for convenience of beginner users who may have trouble with properly declaring and importing/exporting them. But in the end these variables are of course just same kind of variables, only declared in automatically generated script. asc contains "function game_start" for initializing String variables, because these are dynamic objects and cannot be assigned on the declaration. |
thanks. interesting, i wasn't aware of special game_start func. oddly enough, your game last n'furious contains a different version of it in gamescript5,8,14-18.s and globalscript.s (as disassembled by agsutils). btw autogen.ash contains this which looks like a bug |
There are several special callbacks with hardcoded names, they are allowed to be present in each script module and are called in an order:
True, this carried over from C# formatting which uses {x} for placeholders, I fixed it in the latest commit. |
96f37a5
to
4f7e472
Compare
Original repository: https://github.com/leethomason/tinyxml2 taken from tag 8.0.0
4f7e472
to
6964668
Compare
agf2autoash - stands for "AGF to Autogenerated ASH" - parses the game project file (*.agf), which basically is XML, and generates a script header (*.ash) containing game's script declarations necessary for compiling all the scripts. Input: game project (*.agf). Output: generated script header with game declarations. Usage: `agf2autoash Game.agf _AutoGenerated.ash`
6964668
to
820fd4e
Compare
Made an update to this. Restructured code, now there's a clear separation between reading from xml to temporary data structs and generating scripts. Script generation is done using structs instead of continuously reading xml document. I think this makes these functions more flexible. Fixed missing Views in auto header. |
agf2glvar - parses the game project file (*.agf), and generates a script header (*.ash) and body (*.asc) containing project's global variable declarations and initialization. Input: game project (*.agf). Output: generated header and body. Usage: `agf2glvar Game.agf _GlobalVariables.ash _GlobalVariables.asc`
5cd3d15
to
28edb98
Compare
+ corrected String::Replace(char, char) to not clone the string unless there's an actual change + in String::ReplaceMid() don't call memmove without actual need
28edb98
to
bfb2d22
Compare
Resolves #1146 .
agf2autoash - stands for "AGF to Autogenerated ASH" - parses Game.agf (xml) and generates main game header with all the entities and arrays declarations.
Input: game project (*.agf).
Output: generated script header with game declarations.
Usage:
agf2autoash Game.agf _AutoGenerated.ash
agf2glvar - parses Game.agf and generates ash/asc with user's global variables declarations and initialization.
Input: game project (*.agf).
Output: generated script header and body.
Usage: :
agf2glvar Game.agf _GlobalVariables.ash _GlobalVariables.asc
XML parsing is done by a tinyxml2 library - a C++ library consisting of 1 header and 1 cpp file. I placed it inside the repository in this PR, but guess it may be done as a submodule too, since it's present on github (idk if worth the hassle, and we have other lib sources there already).
NOTE: tinyxml2's readme sais it works exclusively with utf-8; Editor still saves user text in ANSI encoding in game.agf. This may not be a problem if the library reads the element values as-is not trying to convert it to something, but it's best to double check this.
AGF reading is done by a small library of "parser classes" which are currently barebones, as this tool required mostly entity script names. Their composition is not final, and likely change when more sophisticated tools are made (e.g. #1188).
Builds on Windows and Linux. For MSVS it uses "Tools" solution. For Linux there are separate Makefiles per tool.