Results 1 to 4 of 4

Thread: Loading files using custom resource types

  1. #1
    Peasant
    Join Date
    Dec 2008
    Posts
    7

    Default Loading files using custom resource types

    I am trying to use resources to load data from a file in a datafile using a custom resource type. The resource definition file would look something like this:
    Code:
    <resources>
      <surface name="tileset" file="tileset.png">
      <level name="my_level" width="128" height="256" file="level.gld"/>
    </resources>
    And then I would load it like this:
    Code:
    CL_Zip_Archive datafile("level.zip");
    CL_ResourceManager resources("level.xml", datafile, true);
    CL_Surface tileset("tileset", &resources);
    Level my_level("my_level", &resources);
    I know how to get the values of width and height, but I want to know if there is a way to load the level data from the context of the resource file, in the same way that the tileset would be loaded from within the datafile.

  2. #2
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Bergen, Norway
    Posts
    588

    Default

    Check out the Resources example - it does some simple loading for a custom type.

    We also have the ResourceCustom example, but I'm not sure I would recommend it - the resource system is complex in 0.8, and you'll get far by the simpler method in Resources example.

  3. #3
    Peasant
    Join Date
    Dec 2008
    Posts
    7

    Default

    Thanks for that, the examples helped me to fix some of the problems I was having. However, I'm still not sure how to load the data from "level.gld". I guess I could access it using a CL_Zip_Archive but I'm not sure how to access the datafile of a particular resource and the Custom Resource Types overview seems to suggest that there is a way to do this within the resource manager system but the tutorial hasn't been written yet.

  4. #4
    Peasant
    Join Date
    Dec 2008
    Posts
    7

    Default

    I now have a working example, using:
    Code:
    level_data = get_resource().get_manager().get_resource_provider()->open_source(handle);
    I'm not sure if this is the best way to do this, but it works for me.

Similar Threads

  1. Loading
    By Cobra in forum Novashell Game Creation System
    Replies: 2
    Last Post: 06-26-2008, 09:43 AM
  2. error in custom pallette window...
    By harrio in forum Novashell Game Creation System
    Replies: 1
    Last Post: 04-06-2008, 01:16 AM
  3. custom resource
    By oilen in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 12-07-2007, 12:12 PM
  4. Custom resource combined with sprite
    By tompawarrior in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 07-17-2007, 05:30 PM
  5. brain types list
    By rabidwolf9 in forum Dink Smallwood HD
    Replies: 2
    Last Post: 01-08-2005, 08:32 PM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •