How can I deploy game without exposing assets(.png)?

Hi I’m using the Ruge Deploy Tool for Monogame (you can find it here: https://github.com/MetaSmug/MonoGame.Ruge.DeployTool).

It’s fantastic, it does everything I need to deploy really fast and easily. However, I want to deploy my game so that it doesn’t show all my .png files in the Content folder. Is there somehow a way I can secure that?

Also I don’t thinkt his is Ruge’s problem, it does this when I use ClickOnce as well. I tried going into Properties, Publish, and Application files, and setting each file’s Publish Status to “Data File”, but it still did the .png thing.

There are multiple methods available, starting with converting to xnb’s to put the amateurs off the scent, to creating your own ZIP pack with password lock which you then manage yourself at runtime…

As I said there are many methods, someone might chime in with a more descript method or even a useful solution for use with MonoGame :slight_smile:

You need to decide to what extent you want to prevent people access, as mentioned already you can just put people off trying when they fail to bring anything up with a simple folder search for image files by converting to xnb files or develop a custom method… but a word of caution, if someone wants it that badly, they will find a way… so I personally would suggest just convert to xnb, and leave it there…

Don’t waste time and resources on something so basic, make your game a good one :slight_smile:

Remember the time rule…

10% of your time spent on coding,
the other 100% of your time spent on making it a good game

:wink:

How do I convert it to .xnb? Because when I build .xnb files and try to replace the .png files with them, it gives me an error saying “Cannot find texture.png in Content!”

Did you forget to change the load calls? you don’t need any extension on them…

Because I did not use the content pipeline, but the raw .pngs, if you wish I can send you how I extracted the png data and saved it into a custom file type, then load it, extract the data as Texture2D. I created a small importer/exporter that loads the pngs from a folder, then exports them as custom file.

yes please that would be nice @KuzDeveloper

what does that mean?..

Is there anyway I can use the .deploy files instead? Because .xnb takes up WAY too much space. My game is in alpha stage it’s already over 1.5 GB, it shouldn’t even be near a GB

The project was written in VS2013. After building it, you only need to add your png files to the New folder next to the executable, and when the export finished your files will be in the Processed folder. Change the extension from avd to something else. :smiley:

it says GZipStream, CompressionMode, and FileStream don’t exist in the current context.

Obviously, you need to add the references to the using section for these classes. Click on them, press shift+alt+F10 and in the popup select the one with ‘using …’.

Alright, I did that and that’s fixed. I put the method in my project, but I don’t know what to do with it or what it does…

I’m really sorry to ask this, but could you give me more clear instructions?

If I open the ContentExporter project in VS and build it, I just get these errors

I’m really not sure what to do here. I really appreciate your help.

Edit: actually ignore what i said above

You can probably creating a custom importer for assets you want to secure. By doing it that way you’ll offload the duty to the pipeline and you can use Content.Load. Check out http://dylanwilson.net/creating-custom-content-importers-for-the-monogame-pipeline

You can implement something like https://www.codeandweb.com/texturepacker/contentprotection for Monogame. It would be a nice thing to add. I’ll do some preliminary work on it and put it on Github.

Apparently TexturePacker support Monogame so that’s an alternative if you don’t want to do the work yourself. You can use their app and use their custom loader.

Okay so I figured out how to convert the .png’s to avd! :smiley:

But… one problem , you said change the extension to something else. What do I change it to? I replaced the picture.png with the picture.avd, and now the game just crashes before it starts… :confused:

Sorry for the missing files, I simply deleted them before zipping the project and forget to remove them from the references! :slight_smile:

Ok, so…

The ContentExporter project simply creates a binary file from a png. I chose the extension “avd” because that my initials. :smiley: If you change it to something else, obviously you need to change it both in the ContentExporter and in your game!

The binary file contents are:

  • the original width of the png.
  • the original height of the png.
  • the color data (rgba) of each pixel.

The LoadAvd simply reads an avd, loads the first two values as integers (so the width and the height of the original png), creates a Texture2d, then loads the color data into it.

What do you need to do with this loaded Texture2d? Whatever you want. :smiley: I loaded it into my engine’s texture manager, but that was my project, you may want to do something different.

Basically, the ContentExporter could be used for other files as well. Even for xnb, if you do not want other Monogame developers to use your xnb. Just simply add your logic and encode/decode your xnb, after all only you know what is inside the avd file, right? For anyone else the avd is simply a zipped file. If you add your custom naming of types, you can use only avd for everything, from png to wav. Your importer should know about how to properly read an avd (e.g. you can save the type as string and your importer will read a string first, then by creating the type from the string realtime, you can load the rest of the avd as png, or wav, or txt, or xnb, or whatever you saved into it).

Thank you for that :slight_smile:

Although I’m still at a loss here,

I have the method in my project,

But I’m not sure how to use it.

My goal: Just load content into the game

Same as LoadContent(), but with .avd files instead.

Do I write the LoadAvd() for every single texture in LoadContent? Or…

In your project there is a Content folder. Create some well-separated folder structure and add the avd files to the corresponding folders (same as you did previously with pngs). Dont forget to change to Copy if newer! Something like:

[Content]
   [Graphics]
      [MainMenu]
         MainMenuBackground.avd
         QuitButtonImage.avd

Iterate through the contents in the Graphics folder and all of its sub-folders. When you find an avd file, call LoadAvd and at the end of the LoadAvd store your Texture2d as you wish (in a static array, or in a more complex manager class).

Here is a short code from my game how I did it:

string[] contentDirectories = new 
{
    ".\\Content\\Graphics\\Avatars\\",    
    ".\\Content\\Graphics\\Common\\"
};

foreach (string folder in contentDirectories)
{
   foreach (string fileWithPath in Directory.GetFiles(
             folder, "*.avd", SearchOption.AllDirectories)) 
   {
      LoadAvd(fileWithPath, true);
   }
}