| 1 | /* |
|---|
| 2 | orxonox - the future of 3D-vertical-scrollers |
|---|
| 3 | |
|---|
| 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 | |
|---|
| 16 | #include "resource_oif.h" |
|---|
| 17 | |
|---|
| 18 | #include "substring.h" |
|---|
| 19 | #include "multi_type.h" |
|---|
| 20 | #include "debug.h" |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | ResourceOIF::ResourceOIF(const std::string& fileName, const Resources::KeepLevel& keepLevel) |
|---|
| 24 | : Resource(&ResourceOIF::type) |
|---|
| 25 | { |
|---|
| 26 | Resources::StorePointer* ptr = this->acquireResource(fileName); |
|---|
| 27 | |
|---|
| 28 | |
|---|
| 29 | if (ptr) |
|---|
| 30 | { |
|---|
| 31 | PRINTF(5)("FOUND OIF: %s\n", fileName.c_str()); |
|---|
| 32 | this->acquireData(static_cast<ResourceOIF::OIFResourcePointer*>(ptr)->ptr()); |
|---|
| 33 | } |
|---|
| 34 | else |
|---|
| 35 | { |
|---|
| 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())); |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | } |
|---|
| 44 | |
|---|
| 45 | ResourceOIF ResourceOIF::createFromString(const std::string& loadString, const Resources::KeepLevel& keepLevel) |
|---|
| 46 | { |
|---|
| 47 | SubString loadValues(loadString, ','); |
|---|
| 48 | std::string fileName; |
|---|
| 49 | if (loadValues.size() > 0) |
|---|
| 50 | fileName = loadValues[0]; |
|---|
| 51 | |
|---|
| 52 | return ResourceOIF(fileName); |
|---|
| 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 | |
|---|