Skip to content

Commit

Permalink
Cleanup|ResourceSystem|MapDef: Moved MapDef impl to resource/mapdef.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Jul 1, 2014
1 parent e457a41 commit 521f7f0
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 37 deletions.
1 change: 1 addition & 0 deletions doomsday/client/client.pro
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,7 @@ SOURCES += \
src/resource/hq2x.cpp \
src/resource/image.cpp \
src/resource/manifest.cpp \
src/resource/mapdef.cpp \
src/resource/material.cpp \
src/resource/materialanimation.cpp \
src/resource/materialarchive.cpp \
Expand Down
46 changes: 9 additions & 37 deletions doomsday/client/include/resource/mapdef.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @file mapdef.h Map asset/resource definition.
/** @file mapdef.h Map asset/resource definition/manifest.
*
* @authors Copyright © 2014 Daniel Swanson <danij@dengine.net>
*
Expand Down Expand Up @@ -28,31 +28,21 @@
#include "Game"

/**
* Definition for a map asset/resource.
* Definition/manifeset for a map asset/resource.
*
* @ingroup resource
*/
class MapDef : public de::PathTree::Node, public de::Record
{
public:
MapDef(de::PathTree::NodeArgs const &args)
: Node(args), Record()
{}
MapDef(de::PathTree::NodeArgs const &args);

/**
* Returns a textual description of the map definition.
*
* @return Human-friendly description the map definition.
*/
de::String description(de::Uri::ComposeAsTextFlags uriCompositionFlags = de::Uri::DefaultComposeAsTextFlags) const {
de::String info = de::String("%1").arg(composeUri().compose(uriCompositionFlags | de::Uri::DecodePath),
( uriCompositionFlags.testFlag(de::Uri::OmitScheme)? -14 : -22 ) );
if(_sourceFile)
{
info += de::String(" " _E(C) "\"%1\"" _E(.)).arg(de::NativePath(sourceFile()->composePath()).pretty());
}
return info;
}
de::String description(de::Uri::ComposeAsTextFlags uriCompositionFlags = de::Uri::DefaultComposeAsTextFlags) const;

/**
* Returns the URI this resource will be known by.
Expand All @@ -62,33 +52,15 @@ class MapDef : public de::PathTree::Node, public de::Record
/**
* Returns the id used to uniquely reference the map in some (old) definitions.
*/
de::String composeUniqueId(de::Game const &currentGame) const {
return de::String("%1|%2|%3|%4")
.arg(gets("id").fileNameWithoutExtension())
.arg(sourceFile()->name().fileNameWithoutExtension())
.arg(sourceFile()->hasCustom()? "pwad" : "iwad")
.arg(currentGame.identityKey())
.toLower();
}
de::String composeUniqueId(de::Game const &currentGame) const;

MapDef &setSourceFile(de::File1 *newSourceFile) {
_sourceFile = newSourceFile;
return *this;
}
MapDef &setSourceFile(de::File1 *newSourceFile);

de::File1 *sourceFile() const {
return _sourceFile;
}
de::File1 *sourceFile() const;

MapDef &setRecognizer(de::Id1MapRecognizer *newRecognizer) {
_recognized.reset(newRecognizer);
return *this;
}
MapDef &setRecognizer(de::Id1MapRecognizer *newRecognizer);

de::Id1MapRecognizer const &recognizer() const {
DENG2_ASSERT(!_recognized.isNull());
return *_recognized;
}
de::Id1MapRecognizer const &recognizer() const;

private:
//String cachePath;
Expand Down
70 changes: 70 additions & 0 deletions doomsday/client/src/resource/mapdef.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/** @file mapdef.cpp Map asset/resource definition/manifest.
*
* @authors Copyright © 2014 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA</small>
*/

#include "resource/mapdef.h"
#include <de/NativePath>

using namespace de;

MapDef::MapDef(PathTree::NodeArgs const &args) : Node(args), Record()
{}

String MapDef::description(de::Uri::ComposeAsTextFlags uriCompositionFlags) const
{
String info = String("%1").arg(composeUri().compose(uriCompositionFlags | de::Uri::DecodePath),
( uriCompositionFlags.testFlag(de::Uri::OmitScheme)? -14 : -22 ) );
if(_sourceFile)
{
info += String(" " _E(C) "\"%1\"" _E(.)).arg(NativePath(sourceFile()->composePath()).pretty());
}
return info;
}

String MapDef::composeUniqueId(Game const &currentGame) const
{
return String("%1|%2|%3|%4")
.arg(gets("id").fileNameWithoutExtension())
.arg(sourceFile()->name().fileNameWithoutExtension())
.arg(sourceFile()->hasCustom()? "pwad" : "iwad")
.arg(currentGame.identityKey())
.toLower();
}

MapDef &MapDef::setSourceFile(File1 *newSourceFile)
{
_sourceFile = newSourceFile;
return *this;
}

File1 *MapDef::sourceFile() const
{
return _sourceFile;
}

MapDef &MapDef::setRecognizer(Id1MapRecognizer *newRecognizer)
{
_recognized.reset(newRecognizer);
return *this;
}

Id1MapRecognizer const &MapDef::recognizer() const
{
DENG2_ASSERT(!_recognized.isNull());
return *_recognized;
}
1 change: 1 addition & 0 deletions doomsday/server/server.pro
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ SOURCES += \
$$SRC/src/resource/hq2x.cpp \
$$SRC/src/resource/image.cpp \
$$SRC/src/resource/manifest.cpp \
$$SRC/src/resource/mapdef.cpp \
$$SRC/src/resource/material.cpp \
$$SRC/src/resource/materialarchive.cpp \
$$SRC/src/resource/materialmanifest.cpp \
Expand Down

0 comments on commit 521f7f0

Please sign in to comment.