mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-02-03 10:04:01 +00:00
save savefile previews as png. this finally kills .zga format, but it's kept for backwards compat
This commit is contained in:
parent
fb1f31e3b5
commit
b7eb5777ae
4 changed files with 39 additions and 21 deletions
|
@ -24,6 +24,33 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
bool AquariaSaveSlot::closed = false;
|
bool AquariaSaveSlot::closed = false;
|
||||||
|
|
||||||
|
static std::string getSavePreviewBaseName(unsigned slot)
|
||||||
|
{
|
||||||
|
const char *pre="./";
|
||||||
|
#ifndef BBGE_BUILD_WINDOWS
|
||||||
|
pre = "";
|
||||||
|
#endif
|
||||||
|
std::ostringstream os;
|
||||||
|
os << pre << dsq->getSaveDirectory() << "/screen-" << numToZeroString(slot, 4);
|
||||||
|
return os.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static std::string getSavePreviewImageName(unsigned slot)
|
||||||
|
{
|
||||||
|
std::string base = getSavePreviewBaseName(slot);
|
||||||
|
std::string fn = base + ".png";
|
||||||
|
if(exists(fn))
|
||||||
|
return fn;
|
||||||
|
fn = base + ".zga";
|
||||||
|
if(exists(fn))
|
||||||
|
return fn;
|
||||||
|
fn = base + ".tga";
|
||||||
|
if(exists(fn))
|
||||||
|
return fn;
|
||||||
|
return base; // whatev
|
||||||
|
}
|
||||||
|
|
||||||
AquariaSaveSlot::AquariaSaveSlot(int slot) : AquariaGuiQuad()
|
AquariaSaveSlot::AquariaSaveSlot(int slot) : AquariaGuiQuad()
|
||||||
{
|
{
|
||||||
done = false;
|
done = false;
|
||||||
|
@ -86,21 +113,8 @@ AquariaSaveSlot::AquariaSaveSlot(int slot) : AquariaGuiQuad()
|
||||||
|
|
||||||
if (dsq->user.video.saveSlotScreens)
|
if (dsq->user.video.saveSlotScreens)
|
||||||
{
|
{
|
||||||
std::ostringstream os,os2;
|
std::string tex = getSavePreviewImageName(slot);
|
||||||
std::string tex, tex2;
|
screen->setTexture(tex);
|
||||||
std::string pre="./";
|
|
||||||
#ifndef BBGE_BUILD_WINDOWS
|
|
||||||
pre = "";
|
|
||||||
#endif
|
|
||||||
os << pre << dsq->getSaveDirectory() << "/screen-" << numToZeroString(slot, 4) << ".tga";
|
|
||||||
os2 << pre << dsq->getSaveDirectory() << "/screen-" << numToZeroString(slot, 4) << ".zga";
|
|
||||||
tex = os.str();
|
|
||||||
tex2 = os2.str();
|
|
||||||
|
|
||||||
if (exists(tex2))
|
|
||||||
screen->setTexture(tex2);
|
|
||||||
else
|
|
||||||
screen->setTexture(tex);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -2822,16 +2822,18 @@ void DSQ::doSaveSlotMenu(SaveSlotMode ssm, const Vector &position)
|
||||||
if (user.video.saveSlotScreens && scrShotData != 0)
|
if (user.video.saveSlotScreens && scrShotData != 0)
|
||||||
{
|
{
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << getSaveDirectory() << "/screen-" << numToZeroString(selectedSaveSlot->getSlotIndex(), 4) << ".zga";
|
os << getSaveDirectory() << "/screen-" << numToZeroString(selectedSaveSlot->getSlotIndex(), 4) << ".png";
|
||||||
|
|
||||||
// Cut off top and bottom to get a 4:3 aspect ratio.
|
// Cut off top and bottom to get a 4:3 aspect ratio.
|
||||||
/*int adjHeight = (scrShotWidth * 3.0f) / 4.0f;
|
int adjHeight = (scrShotWidth * 3.0f) / 4.0f;
|
||||||
int imageDataSize = scrShotWidth * scrShotHeight * 4;
|
int imageDataSize = scrShotWidth * scrShotHeight * 4;
|
||||||
int adjImageSize = scrShotWidth * adjHeight * 4;
|
int adjImageSize = scrShotWidth * adjHeight * 4;
|
||||||
int adjOffset = scrShotWidth * ((scrShotHeight-adjHeight)/2) * 4;
|
int adjOffset = scrShotWidth * ((scrShotHeight-adjHeight)/2) * 4;
|
||||||
memmove(scrShotData, scrShotData + adjOffset, adjImageSize);
|
memmove(scrShotData, scrShotData + adjOffset, adjImageSize);
|
||||||
memset(scrShotData + adjImageSize, 0, imageDataSize - adjImageSize);*/
|
memset(scrShotData + adjImageSize, 0, imageDataSize - adjImageSize);
|
||||||
zgaSaveRGBA(os.str().c_str(), scrShotWidth, scrShotHeight, scrShotData);
|
|
||||||
|
//zgaSaveRGBA(os.str().c_str(), scrShotWidth, scrShotHeight, scrShotData);
|
||||||
|
pngSaveRGBA(os.str().c_str(), scrShotWidth, adjHeight, scrShotData, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
PlaySfx sfx;
|
PlaySfx sfx;
|
||||||
|
|
|
@ -21,6 +21,8 @@ bool tgaSaveRGBA(const char *filename, size_t width, size_t height, unsigned cha
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
// No longer used -- kept for reference
|
||||||
// Aquaria special: zlib-compressed TGA
|
// Aquaria special: zlib-compressed TGA
|
||||||
bool zgaSaveRGBA(const char *filename, size_t w, size_t h, unsigned char *data)
|
bool zgaSaveRGBA(const char *filename, size_t w, size_t h, unsigned char *data)
|
||||||
{
|
{
|
||||||
|
@ -75,7 +77,7 @@ bool zgaSaveRGBA(const char *filename, size_t w, size_t h, unsigned char *data)
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static VFILE *imageLoadOpenFile(const char *filename)
|
static VFILE *imageLoadOpenFile(const char *filename)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
bool tgaSaveRGBA(const char *filename, size_t width, size_t height, unsigned char *data);
|
bool tgaSaveRGBA(const char *filename, size_t width, size_t height, unsigned char *data);
|
||||||
bool zgaSaveRGBA(const char *filename, size_t width, size_t height, unsigned char *data);
|
//bool zgaSaveRGBA(const char *filename, size_t width, size_t height, unsigned char *data);
|
||||||
bool pngSaveRGBA(const char *filename, size_t width, size_t height, unsigned char *data, unsigned compressLevel);
|
bool pngSaveRGBA(const char *filename, size_t width, size_t height, unsigned char *data, unsigned compressLevel);
|
||||||
|
|
||||||
struct ImageData
|
struct ImageData
|
||||||
|
|
Loading…
Add table
Reference in a new issue