1 /** @file mapdef.cpp Resource manifest for a map.
2 *
3 * @authors Copyright © 2014-2015 Daniel Swanson <danij@dengine.net>
4 *
5 * @par License
6 * GPL: http://www.gnu.org/licenses/gpl.html
7 *
8 * <small>This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version. This program is distributed in the hope that it
12 * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
14 * Public License for more details. You should have received a copy of the GNU
15 * General Public License along with this program; if not, write to the Free
16 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
17 * 02110-1301 USA</small>
18 */
19
20 #include "doomsday/resource/mapmanifest.h"
21 #include <de/NativePath>
22
23 using namespace de;
24
25 namespace res {
26
MapManifest(PathTree::NodeArgs const & args)27 MapManifest::MapManifest(PathTree::NodeArgs const &args)
28 : Node(args), Record(), _sourceFile(nullptr)
29 {}
30
description(de::Uri::ComposeAsTextFlags uriCompositionFlags) const31 String MapManifest::description(de::Uri::ComposeAsTextFlags uriCompositionFlags) const
32 {
33 String info = String("%1").arg(composeUri().compose(uriCompositionFlags | de::Uri::DecodePath),
34 ( uriCompositionFlags.testFlag(de::Uri::OmitScheme)? -14 : -22 ) );
35 if (_sourceFile)
36 {
37 info += String(" " _E(C) "\"%1\"" _E(.)).arg(NativePath(sourceFile()->composePath()).pretty());
38 }
39 return info;
40 }
41
composeUniqueId(Game const & currentGame) const42 String MapManifest::composeUniqueId(Game const ¤tGame) const
43 {
44 return String("%1|%2|%3|%4")
45 .arg(gets("id").fileNameWithoutExtension())
46 .arg(sourceFile()->name().fileNameWithoutExtension())
47 .arg(sourceFile()->hasCustom()? "pwad" : "iwad")
48 .arg(currentGame.id())
49 .toLower();
50 }
51
setSourceFile(File1 * newSourceFile)52 MapManifest &MapManifest::setSourceFile(File1 *newSourceFile)
53 {
54 _sourceFile = newSourceFile;
55 return *this;
56 }
57
sourceFile() const58 File1 *MapManifest::sourceFile() const
59 {
60 return _sourceFile;
61 }
62
setRecognizer(Id1MapRecognizer * newRecognizer)63 MapManifest &MapManifest::setRecognizer(Id1MapRecognizer *newRecognizer)
64 {
65 _recognized.reset(newRecognizer);
66 return *this;
67 }
68
recognizer() const69 Id1MapRecognizer const &MapManifest::recognizer() const
70 {
71 DENG2_ASSERT(bool(_recognized));
72 return *_recognized;
73 }
74
75 } // namespace res
76