Asset Modularization

Reporter: RobertBColton  |  Status: open  |  Last Modified: July 14, 2019, 02:12:21 PM

Ok, so the goal here is to modularize the code we use for writing assets to the exe and launching the game. In addition, we also want to write the new code to accept a proto instead of the old backend structures. This pull request creates a new library called libAssets to house this code.


One thing we should talk about is having output from libAssets show in the IDE's output window. Because I didn't want to move any of the output/logging stuff from CompilerSource yet, libAssets has all of its logging code commented out. This is complicated by the fact that currently RGM is only reading output from CompileReply which is populated from EnigmaCallback. Since RGM links directly to libAssets it would need to hook into its log methods directly somehow.

Summary of Changes

  • Added plugin_CompileEGMRaw which functions the same as the old plugin_CompileEGM except it doesn't write the asset data for sprites and sounds onto the exe. For that reason, it also doesn't launch the game when it finishes. I did it this way, because changing the signature of plugin_CompileEGM would break LateralGM binary compatibility, which we're not ready to do yet.
  • Changed the signature of EnigmaPlugin::BuildGame to accept the exe and project paths as well as a boolean controlling whether to write the assets. Because the method now accepts the project's file path, the working_directory in run and debug mode will be compatible with GM8 again. This is done because emake obviously needs to write the assets and sometimes launch the game, but the GRPC server only needs to build the game and leave these tasks up to the IDE.
  • Added an overload for EnigmaPlugin::BuildGame for when the exe path is the same as the project path (e.g, empty game because there is no project file).
  • Moved the OptionsParser instance from emake main to the global scope so that it can be accessed by EnigmaPlugin::BuildGame to determine when the --run option has been specified.
  • Removed emake's double linkage of libEGM because I didn't see any reasoning for it and it may also have been bloating the size of it.
  • Added linkage of libAssets to emake so it can use it to write assets to the game and launch the game.
  • Disabled the code in Proto2ES that loads, converts, and compresses the data files for sounds, sprites, and backgrounds because it is no longer needed. Because libAssets has new code to write the assets, I changed the logic for it to do the loading.
  • Created libAssets with a makefile and a CMakeLists so it can be built in MSYS2 and by RGM's AppVeyor. It contains a new method game_write_assets which is based on Josh's code I extracted from CompilerSource but it's slightly different in that it accepts the new proto instead of the old EnigmaStruct. The library also has a game_launch method which was extracted from CompilerSource and is used by emake and LGM to launch the game consistently.
  • Tweaked the libEGM makefile to rename SHARED_SOURCES to SHARED_SRC_DIR which is more consistent with the other makefiles we have that use the shared code. The directory variable is supposed to be SHARED_SRC_DIR and SHARED_SOURCES is supposed to be a list of the actual sources to compile.
  • Moved bettersystem to the shared/ folder so that it can be compiled into libAssets so that game_launch is able to call e_execs.
  • Cleaned up a few redundant string_replace_all implementations by moving it to bettersystem in the shared folder.
  • Extracted compile_write_assets and compile_run_game in compile.cpp so I could easily copy it to libAssets and so I could make plugin_CompileEGMRaw not call it.
  • Updated the main makefile to include rules for libAssets so it gets built by make all. At this point, emake now depends on libAssets to write assets to and launch games that are protos.
  • Updated the AppVeyor job to include libAssets.dll in the blobs zip since emake now depends on it.
  • Moved the includes of windows.h and unistd.h to the top of bettersystem.cpp before the using namespace std; since the using causes issues when compiling with MSVC and C++17.
  • <
>Codecov Report

Merging #1432 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1432   +/-   ##
  Coverage   17.19%   17.19%           
  Files         164      164           
  Lines       17103    17103           
  Hits         2941     2941           
  Misses      14162    14162

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c622812...dbd36a4. Read the comment docs.


@JoshDreamland alright, this is ready to go for review!
Please sign in to post comments, or you can view this issue on GitHub.