[10059] | 1 | /* |
---|
| 2 | orxonox - the future of 3D-vertical-scrollers |
---|
[10051] | 3 | |
---|
[10059] | 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
| 10 | |
---|
| 11 | ### File Specific |
---|
| 12 | main-programmer: Patrick Boenzli patrick@orxonox.net |
---|
| 13 | co-programmer: |
---|
| 14 | */ |
---|
| 15 | |
---|
[10051] | 16 | #include "resource_oif.h" |
---|
| 17 | |
---|
| 18 | #include "substring.h" |
---|
| 19 | #include "multi_type.h" |
---|
| 20 | #include "debug.h" |
---|
| 21 | |
---|
| 22 | |
---|
[10052] | 23 | ResourceOIF::ResourceOIF(const std::string& fileName, const Resources::KeepLevel& keepLevel) |
---|
[10051] | 24 | : Resource(&ResourceOIF::type) |
---|
| 25 | { |
---|
[10052] | 26 | Resources::StorePointer* ptr = this->acquireResource(fileName); |
---|
[10051] | 27 | |
---|
[10314] | 28 | |
---|
[10051] | 29 | if (ptr) |
---|
| 30 | { |
---|
[10314] | 31 | PRINTF(5)("FOUND OIF: %s\n", fileName.c_str()); |
---|
| 32 | this->acquireData(static_cast<ResourceOIF::OIFResourcePointer*>(ptr)->ptr()); |
---|
[10051] | 33 | } |
---|
| 34 | else |
---|
| 35 | { |
---|
[10314] | 36 | PRINTF(5)("NOT FOUND OIF: %s\n", fileName.c_str()); |
---|
| 37 | std::string fullName = this->Resource::locateFile(fileName); |
---|
| 38 | PRINTF(5)("trying loading of: %s\n", fullName.c_str()); |
---|
| 39 | this->load(fullName); |
---|
| 40 | this->Resource::addResource(new ResourceOIF::OIFResourcePointer(fileName, keepLevel, this->ObjectInformationFile::dataPointer())); |
---|
[10051] | 41 | } |
---|
| 42 | |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | ResourceOIF ResourceOIF::createFromString(const std::string& loadString, const Resources::KeepLevel& keepLevel) |
---|
| 46 | { |
---|
| 47 | SubString loadValues(loadString, ','); |
---|
[10052] | 48 | std::string fileName; |
---|
[10051] | 49 | if (loadValues.size() > 0) |
---|
[10052] | 50 | fileName = loadValues[0]; |
---|
[10051] | 51 | |
---|
[10052] | 52 | return ResourceOIF(fileName); |
---|
[10051] | 53 | } |
---|
| 54 | |
---|
| 55 | |
---|
| 56 | |
---|
| 57 | Resources::tType<ResourceOIF> ResourceOIF::type("OIF"); |
---|
| 58 | |
---|
| 59 | |
---|
| 60 | |
---|
| 61 | |
---|
| 62 | |
---|
| 63 | ResourceOIF::OIFResourcePointer::OIFResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const OIFData::Pointer& data) |
---|
| 64 | : Resources::StorePointer(loadString, keepLevel) , pointer(data) |
---|
| 65 | {} |
---|
| 66 | |
---|
| 67 | |
---|