Orx Packager

edited April 2015 in Projects - Tools
Hi, :)

I was doing a tool for another game engine, MOAI.
It used to be packaged into a single file all game data (image, audio, etc).
capturadepantalla2015-04-0800-58-29.png

Then I thought, how do I do it in Orx?

Then I read this: Custom Zip archive resource

I could do it :)
orxpack.gif

Test:
capturadepantalla2015-04-0902-21-42.png

Note:I am developing on Linux with gtk theme "Win7", is not Windows.

As I do not speak English, I put images :P

Current situation:
1 - Works as described.
2 - The application is written in Tcl/Tk, so it's multiplatform.
3 - Currently, I only tested on Linux :(

Do not use this application, very soon I will create an exclusive version Orx
Link to moai-self-container repository

I know orx only in 15% :lol: I hope you will help me to continue:
Todo:
1 - The file .ini inside de binary file

Regards.

Edit 1:
In the images I have shown, the dynamic libraries are not visible. This is because I have them installed on the system side. The engine dynamic libraries are needed.

Edit 2:
To try orxpack-test-x86_64-Linux.tar.xz
md5 : 0fa27e73202f8f363eb54d0b1ba48266

Edit 3:
A small patch to 01_Object.c and orxArchive.c that I use for this example.

Comments

  • edited April 2015
    Nice work, daltomi!

    I think you're the first one looking into custom resource support, or at least no one else mentioned it previously. :)

    Thanks for the patch also, which reminds me that the version posted on the newsgroup is slightly outdated, I did a couple of changes, including the typedef since I posted it.

    I also wrote a quick "tutorial" a while ago, but never found the time to make a proper entry in the wiki: https://bitbucket.org/iarwain/resource

    It was basically the based I used to write orxArchive.c, so you won't learn much from it now. :)

    The external initial .ini can't be packed inside orx at the moment. The issue is that some systems need config information to initialize, but at no point the user was given the hand before this happens. I should probably provide a bootstrap for that case. It's been bugging me for quite a while as well, but I haven't found a "clean" way of doing it. If you have any suggestions, please lemme know!

    Now regarding the packing of the other resources, you can also define your own storage scheme, like doing some memory mapped resources for small-to-medium sized projects.
    My initial thought was to have something like this:

    - Use bin2c, or equivalent, to binarize the files and get a code source data table.
    - In your custom Locate function, when you find a matching resource,
    you can return a string that contains simply the tab + table index (or pointer), something like: mem:<ID>
    - In Open, allocate a small descriptor that looks a bit like the one used in orxArchive.c: a pointer to the data in memory + a read cursor
    - In Close you'd deallocate the descriptor

    That's about it. Any thoughts/comments?
  • edited April 2015
    Well, actually I just added a way to support the main config file as part of an archive by letting users add a bootstrap function that will get called when the orxConfig module is ready but before any config file is loaded. Here's a small example that would allow the game to load its main config file directly from a zip file called game.pak:
    #include "orxArchive.c"
    
    orxSTATUS orxFASTCALL MyBootstrap()
    {
      // Inits orxArchive that allows us to store data in zip files
      orxArchive_Init();
    
      // Adds "game.pak" as storage for config resources
      orxResource_AddStorage(orxCONFIG_KZ_RESOURCE_GROUP, "game.pak", orxFALSE);
    
      // If we returned orxSTATUS_FAILURE, the default config file loading would be skipped entirely
      return orxSTATUS_SUCCESS;
    }
    
    int main(int argc, char **argv)
    {
      // Sets bootstrap function
      orxConfig_SetBootstrap(&MyBootstrap);
    
      // Executes orx
      orx_Execute(argc, argv, Init, Run, Exit);
    }
    

    Now I can store my game.ini that contains all the default config directly into game.pak. Of course, the bootstrap allows for more advanced schemes as well, such as adding networked resource support, etc... or even registering to events.
  • edited April 2015
    Perfect, thank you, is what I was looking for :)

    This is what I did:
    orxResource_AddStorage(orxCONFIG_KZ_RESOURCE_GROUP, "MyGame", orxFALSE);
    

    Then, as before I want my file .ini:
    [Resource]
    Texture = MyGame
    Sound	= MyGame
    

    Result (to better understand this thread) :
    orxpackager.gif


    Regards.

    PS: Sorry for delay in replying, was on a trip.
  • edited April 2015
    Nice! :)
  • edited April 2015
    Here is the link to the repository orx_pack.
    Here is the link to a video showing how to use it

    Todo: Do all that, but orx pure. :)

    Regards.
Sign In or Register to comment.