Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UI|Home: Load game title pictures from the WAD files of each game
- Loading branch information
Showing
5 changed files
with
191 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** @file idtech1image.h | ||
* | ||
* @authors Copyright (c) 2016 Jaakko Keränen <jaakko.keranen@iki.fi> | ||
* | ||
* @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, see: | ||
* http://www.gnu.org/licenses</small> | ||
*/ | ||
|
||
#ifndef DENG_CLIENT_RESOURCE_IDTECH1IMAGE_H | ||
#define DENG_CLIENT_RESOURCE_IDTECH1IMAGE_H | ||
|
||
#include <de/Image> | ||
|
||
/** | ||
* Image that imports its content using Id Tech 1 graphics formats. | ||
*/ | ||
class IdTech1Image : public de::Image | ||
{ | ||
public: | ||
enum Format { | ||
Automatic, | ||
RawVGAScreen, | ||
Patch | ||
}; | ||
|
||
public: | ||
/** | ||
* Constructs a new Id Tech 1 image. The Image object gets initialized with the | ||
* RGBA_8888 contents of the image. | ||
* | ||
* @param data Image data. Format detected automatically. | ||
* @param palette RGB palette containing color triplets. The size of the palette | ||
* must be big enough to contain all the color indices used in the | ||
* image data. | ||
*/ | ||
IdTech1Image(de::IByteArray const &data, de::IByteArray const &palette, | ||
Format format = Automatic); | ||
|
||
de::Vector2i origin() const; | ||
|
||
/** | ||
* Size of the image data as declared in its metadata. May not match the actual | ||
* image size. | ||
*/ | ||
Size nominalSize() const; | ||
|
||
private: | ||
DENG2_PRIVATE(d) | ||
}; | ||
|
||
#endif // DENG_CLIENT_RESOURCE_IDTECH1IMAGE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/** @file idtech1image.cpp | ||
* | ||
* @authors Copyright (c) 2016 Jaakko Keränen <jaakko.keranen@iki.fi> | ||
* | ||
* @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, see: | ||
* http://www.gnu.org/licenses</small> | ||
*/ | ||
|
||
#include "resource/idtech1image.h" | ||
|
||
#include <doomsday/resource/patch.h> | ||
|
||
using namespace de; | ||
using namespace res; | ||
|
||
DENG2_PIMPL_NOREF(IdTech1Image) | ||
{ | ||
Vector2i origin; | ||
Size nominalSize; | ||
}; | ||
|
||
IdTech1Image::IdTech1Image(IByteArray const &data, IByteArray const &palette, Format format) | ||
: d(new Instance) | ||
{ | ||
Size const rawSize(320, 200); | ||
|
||
if(format == Automatic) | ||
{ | ||
// Try to guess which format the data uses. | ||
if(data.size() == rawSize.x * rawSize.y) | ||
{ | ||
format = RawVGAScreen; | ||
} | ||
else | ||
{ | ||
format = Patch; | ||
} | ||
} | ||
|
||
if(format == RawVGAScreen) | ||
{ | ||
d->nominalSize = rawSize; | ||
Image::operator = (fromIndexedData(rawSize, data, palette)); | ||
} | ||
else | ||
{ | ||
auto const metadata = Patch::loadMetadata(data); | ||
d->nominalSize = metadata.logicalDimensions; | ||
d->origin = metadata.origin; | ||
|
||
Image::operator = (Image::fromMaskedIndexedData(metadata.dimensions, | ||
Patch::load(data), palette)); | ||
} | ||
} | ||
|
||
Vector2i IdTech1Image::origin() const | ||
{ | ||
return d->origin; | ||
} | ||
|
||
Image::Size IdTech1Image::nominalSize() const | ||
{ | ||
return d->nominalSize; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters