-
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: Generate script files from Game.agf #1146
Comments
I can write this. The best way in my view is to remove Winforms bits from AGS Types, since AGS Types has the rules for Game.agf, and write the thing in C# already. If maintaining the rules for Game.agf in two places is not a problem, to quickly write the code I do have a .xsd schema for Game.agf, and boost has tools to generate the plain cpp classes for each .xml object/tag and it can then have the serialization/desserialization be switched to use Cereal to avoid boost - Cereal is tiny. Then it's about navigating the class objects at runtime and writing the needed header files and script. For this, I would separate the core functionality from the command line front end and allowing to return the needed files as string in the core and as files in the front end.
This allows for validation when desserializing the Game.agf data. If I didn't make sense in a sentence please ask about. I can also roll a little example of the above in the weekend if it would make clear to explain. But I still think the best approach is fixing #1092 and using C# since most of the code is already written and would be shared with the current Editor, easing future maintenance. |
This tool does not need to read whole objects. It practically needs one field from xml per object: the script name. Second piece of data is total number of objects. That's enough to generate the script headers. For "global variables" it does need full data though (they consist of 3 fields). I missed the previous discussion, what was the everyone's opinion on the language? Maybe I got wrong impression that C++ was chosen for this in the end. Is the primary reason for suggesting C# is existing code? |
ivan, thanks for opening this ticket.
please, could we try not to pull in yet more huge dependencies into the project ? |
indeed, this seemed to be the consensus |
Rofl0r, it's a single step once in a lifetime code generation to avoid writing code by hand. |
you mean you'd use boost only for generation of some temporary data in a throw-away "script" ? and later that data is used instead of boost ? |
It writes plain classes with validation of the data if they are present in the xsd schema. The resulting code has no boost in the classes but it has a little boost helper for serialization and desserialization of such classes, which can be cut out easily. I would then use a library to provide the serialization and desserialization instead (striping out any boost dependency) - there are a bunch with pros and cons, some sell themselves as reflection libraries instead of serialization/desserialization libraries. So the rest of the code just navigates plain cpp classes to obtain the data and doesn't have to know about the original data - let's say .xml is switched to yaml, or single big file is switched for multiple smaller files, it's easy to adapt. The big con of this approach is maintain these classes. In Java we use POJO (plain java objects) for describing these type of classes that are only meant to store data, but I don't know how to name these in cpp. :/ Anyway, maybe the plain text processing approach is preferable but I just thought to clarify what I wrote - not sure I did hahaha. |
Ah, no, I forgot ofcourse. This particular tool only needs couple of fields from the xml, but this is only for script compilation. If we aim to do full game compilation with command line tools, then there will be next tool which must parse whole xml and write "main game data" from it. That tool will definitely need to have full knowledge of Game.agf. PS. Please ignore close/reopen issue, I misclicked... |
No, only C# code does this in the Editor.
I have these on github: |
In the past I used oxygen when I was studying the Game.agf format in the past and made this visualization: It has some missing fields and I never hand corrected the |
If this isn't C# then presumably it is OK if an additional input to the tool is a symbol representing a set of engine limits for a given engine version? All the constants used to define the array sizes are in AGS.Types. |
Sorry, looks like I did not get notification of the last couple commits for some reason...
I did not think about that... Perhaps it could be a list of constants to parse instead? even if also in form of xml (since it parses xml anyway), or other simplier text format. |
this is actually something i looked into recently with regard to recompiling old games. agsedit version 2.72 created a header for internal use that had roughly these contents: #define AGS_MAX_CHARACTERS 300
#define AGS_MAX_INV_ITEMS 301
#define AGS_MAX_GUIS 50
enum CursorMode {
eModeWalkto = 0,
...
};
import Character character[1];
#define EGO 0
import Character cEgo;
import Hotspot hotspot[30]; etc. full list in commit message here: rofl0r/agsutils@10e16bf ags 2.62 otoh exported only a much smaller list of macros: #define EGO 0
#define STATUSLINE FindGUIID("STATUSLINE")
#define ICONBAR FindGUIID("ICONBAR")
#define INVENTORY FindGUIID("INVENTORY")
#define VIEW1 1
#define VIEW2 2 this header was created in memory and then sent to the compiler. does anything speak against creating the same kind of header to include by the build tools? |
I am unsure if I understand the question; are you referring to including overall header when compiling game script, or suggest to make a precreated header with fixed set of macros for these tools? |
yeah, this |
There seem to be two general alternatives here:
First is ofcourse trivial and may as well be used as a starting solution. |
there are some generic parts in that header, like limits, but most of the generated code is game specific - view names, character names, etc. if the latter is still required then i don't think a generic version of the header can be provided. btw, i've seen references to "_BuiltinScriptHeader.ash" somewhere, and i think that's what this is. |
I think we are talking about different things then.
This very ticket is about tool that should generate game specific symbols. I explained where to get and how to generate this information in the first post. PS. _BuiltinScriptHeader.ash is the file that contains script API, and it corresponds to this file from editor resources: So the first variant is basically to put all missing generic declarations there as well, as it already has many of them. |
Summary
A stand-alone tool which may be run from command-line (no GUI), which parses Game.agf xml and generates script files necessary for game compilation.
Presumably C++ is better choice here, as it's more portable than C#.
NOTE: this task is exclusively in writing this tool, adjusting Editor is a separate task, so no need to concern yourself with that if you are doing this. In fact it's best to assume that Editor will not be present to ensure tool's work result has no reliance on it.
Input:
Output:
Optionally?
<Dialogs> - <Dialog> - <Script>
xml sections, excluding<![CDATA[
tag; need to figure out how to call these temporary files to avoid conflicts.Details
_AutoGenerated.ash
Process could be found in the Editor code:
https://github.com/adventuregamestudio/ags/blob/master/Editor/AGS.Editor/Tasks.cs#L526
(RegenerateScriptHeader function)
Note that the header takes global declarations from game data itself (read from Game.agf), but also room declarations from the given room. This is because room scripts need both.
My proposal is to ignore room declarations for the purpose of this tool, and only make it work with global ones. The generated _AutoGenerated.ash may then be used everywhere, and for room scripts there will be a separate tool (or separate task) which reads room files (CRM) and creates additional headers per room.
_GlobalVariables.ash/asc
Process could be found in the Editor code:
ash: https://github.com/adventuregamestudio/ags/blob/master/Editor/AGS.Editor/Components/GlobalVariablesComponent.cs#L89
asc: https://github.com/adventuregamestudio/ags/blob/master/Editor/AGS.Editor/Components/GlobalVariablesComponent.cs#L57
(UpdateScriptHeader and GenerateGlobalVariablesScriptModule functions)
To be amended.
See Also
#1007 - a previous ticket on subject, I guess it may be treated as a separate task for replacing Editor's code that does all the above with calls to standalone tool(s) when it's ready.
General overview of the game building process: https://github.com/adventuregamestudio/ags/wiki/AGS-Game-Build-process-(3.5.*)
The text was updated successfully, but these errors were encountered: