Add trial-mode without save functionality

This commit is contained in:
David Capello 2014-04-10 00:33:28 -03:00
parent db29932857
commit 30af4e2620
15 changed files with 79 additions and 26 deletions

View File

@ -42,6 +42,7 @@ option(USE_SHARED_ALLEGRO4 "Use shared Allegro 4 library (without resize support
option(ENABLE_MEMLEAK "Enable memory-leaks detector (only for developers)" off)
option(ENABLE_UPDATER "Enable automatic check for updates" on)
option(ENABLE_WEBSERVER "Enable support to run a webserver (for HTML5 gamedev)" off)
option(ENABLE_TRIAL_MODE "Compile the trial version" off)
option(FULLSCREEN_PLATFORM "Enable fullscreen by default" off)
######################################################################

View File

@ -124,6 +124,13 @@ if(ENABLE_WEBSERVER)
add_subdirectory(webserver)
endif()
# Full-version or trial-mode?
if(NOT ENABLE_TRIAL_MODE)
add_definitions(-DENABLE_SAVE)
else()
add_definitions(-DENABLE_TRIAL_MODE)
endif()
if(USE_SHARED_ALLEGRO4)
# Find the shared Allegro 4 library
find_library(LIBALLEGRO4_LIBRARY alleg)

View File

@ -126,8 +126,10 @@ class AseFormat : public FileFormat {
FILE_SUPPORT_PALETTES;
}
bool onLoad(FileOp* fop);
bool onSave(FileOp* fop);
bool onLoad(FileOp* fop) OVERRIDE;
#ifdef ENABLE_SAVE
bool onSave(FileOp* fop) OVERRIDE;
#endif
};
FileFormat* CreateAseFormat()
@ -283,6 +285,7 @@ bool AseFormat::onLoad(FileOp *fop)
}
}
#ifdef ENABLE_SAVE
bool AseFormat::onSave(FileOp *fop)
{
Sprite* sprite = fop->document->getSprite();
@ -342,6 +345,7 @@ bool AseFormat::onSave(FileOp *fop)
return true;
}
}
#endif
static bool ase_file_read_header(FILE *f, ASE_Header *header)
{

View File

@ -69,8 +69,10 @@ class BmpFormat : public FileFormat {
FILE_SUPPORT_SEQUENCES;
}
bool onLoad(FileOp* fop);
bool onSave(FileOp* fop);
bool onLoad(FileOp* fop) OVERRIDE;
#ifdef ENABLE_SAVE
bool onSave(FileOp* fop) OVERRIDE;
#endif
};
FileFormat* CreateBmpFormat()
@ -719,6 +721,7 @@ bool BmpFormat::onLoad(FileOp *fop)
return true;
}
#ifdef ENABLE_SAVE
bool BmpFormat::onSave(FileOp *fop)
{
Image *image = fop->seq.image;
@ -812,5 +815,6 @@ bool BmpFormat::onSave(FileOp *fop)
return true;
}
}
#endif
} // namespace app

View File

@ -546,6 +546,7 @@ void fop_operate(FileOp *fop, IFileOpProgress* progress)
else if (fop->type == FileOpSave &&
fop->format != NULL &&
fop->format->support(FILE_SUPPORT_SAVE)) {
#ifdef ENABLE_SAVE
// Save a sequence
if (fop->is_sequence()) {
ASSERT(fop->format->support(FILE_SUPPORT_SEQUENCES));
@ -596,6 +597,11 @@ void fop_operate(FileOp *fop, IFileOpProgress* progress)
fop_error(fop, "Error saving the sprite in the file \"%s\"\n",
fop->filename.c_str());
}
#else
fop_error(fop,
"Save operation is not supported in trial version.\n"
"Go to " WEBSITE_DOWNLOAD " and get the full-version.");
#endif
}
// Progress = 100%

View File

@ -51,11 +51,13 @@ bool FileFormat::load(FileOp* fop)
return onLoad(fop);
}
#ifdef ENABLE_SAVE
bool FileFormat::save(FileOp* fop)
{
ASSERT(support(FILE_SUPPORT_SAVE));
return onSave(fop);
}
#endif
bool FileFormat::postLoad(FileOp* fop)
{

View File

@ -54,7 +54,9 @@ namespace app {
const char* name() const; // File format name
const char* extensions() const; // Extensions (e.g. "jpeg,jpg")
bool load(FileOp* fop);
#ifdef ENABLE_SAVE
bool save(FileOp* fop);
#endif
// Does post-load operation which require user intervention.
// Returns false cancelled the operation.
@ -81,7 +83,9 @@ namespace app {
virtual bool onLoad(FileOp* fop) = 0;
virtual bool onPostLoad(FileOp* fop) { return true; }
#ifdef ENABLE_SAVE
virtual bool onSave(FileOp* fop) = 0;
#endif
virtual void onDestroyData(FileOp* fop) { }
virtual SharedPtr<FormatOptions> onGetFormatOptions(FileOp* fop) {

View File

@ -50,8 +50,10 @@ class FliFormat : public FileFormat {
FILE_SUPPORT_PALETTES;
}
bool onLoad(FileOp* fop);
bool onSave(FileOp* fop);
bool onLoad(FileOp* fop) OVERRIDE;
#ifdef ENABLE_SAVE
bool onSave(FileOp* fop) OVERRIDE;
#endif
};
FileFormat* CreateFliFormat()
@ -179,6 +181,7 @@ bool FliFormat::onLoad(FileOp* fop)
return true;
}
#ifdef ENABLE_SAVE
bool FliFormat::onSave(FileOp* fop)
{
Sprite* sprite = fop->document->getSprite();
@ -261,6 +264,7 @@ bool FliFormat::onSave(FileOp* fop)
return true;
}
#endif
static int get_time_precision(Sprite *sprite)
{

View File

@ -90,7 +90,9 @@ class GifFormat : public FileFormat {
bool onLoad(FileOp* fop);
bool onPostLoad(FileOp* fop) OVERRIDE;
void onDestroyData(FileOp* fop) OVERRIDE;
bool onSave(FileOp* fop);
#ifdef ENABLE_SAVE
bool onSave(FileOp* fop) OVERRIDE;
#endif
};
FileFormat* CreateGifFormat()
@ -487,6 +489,7 @@ void GifFormat::onDestroyData(FileOp* fop)
}
}
#ifdef ENABLE_SAVE
bool GifFormat::onSave(FileOp* fop)
{
UniquePtr<GifFileType, int(*)(GifFileType*)> gif_file
@ -681,5 +684,6 @@ bool GifFormat::onSave(FileOp* fop)
return true;
}
#endif
} // namespace app

View File

@ -48,8 +48,10 @@ class IcoFormat : public FileFormat {
FILE_SUPPORT_INDEXED;
}
bool onLoad(FileOp* fop);
bool onSave(FileOp* fop);
bool onLoad(FileOp* fop) OVERRIDE;
#ifdef ENABLE_SAVE
bool onSave(FileOp* fop) OVERRIDE;
#endif
};
FileFormat* CreateIcoFormat()
@ -234,6 +236,7 @@ bool IcoFormat::onLoad(FileOp* fop)
return true;
}
#ifdef ENABLE_SAVE
bool IcoFormat::onSave(FileOp* fop)
{
Sprite* sprite = fop->document->getSprite();
@ -393,5 +396,6 @@ bool IcoFormat::onSave(FileOp* fop)
return true;
}
#endif
} // namespace app

View File

@ -63,8 +63,10 @@ class JpegFormat : public FileFormat {
FILE_SUPPORT_GET_FORMAT_OPTIONS;
}
bool onLoad(FileOp* fop);
bool onSave(FileOp* fop);
bool onLoad(FileOp* fop) OVERRIDE;
#ifdef ENABLE_SAVE
bool onSave(FileOp* fop) OVERRIDE;
#endif
SharedPtr<FormatOptions> onGetFormatOptions(FileOp* fop) OVERRIDE;
};
@ -236,6 +238,7 @@ bool JpegFormat::onLoad(FileOp* fop)
return true;
}
#ifdef ENABLE_SAVE
bool JpegFormat::onSave(FileOp* fop)
{
struct jpeg_compress_struct cinfo;
@ -350,6 +353,7 @@ bool JpegFormat::onSave(FileOp* fop)
// All fine.
return true;
}
#endif
// Shows the JPEG configuration dialog.
SharedPtr<FormatOptions> JpegFormat::onGetFormatOptions(FileOp* fop)

View File

@ -48,8 +48,10 @@ class PcxFormat : public FileFormat {
FILE_SUPPORT_SEQUENCES;
}
bool onLoad(FileOp* fop);
bool onSave(FileOp* fop);
bool onLoad(FileOp* fop) OVERRIDE;
#ifdef ENABLE_SAVE
bool onSave(FileOp* fop) OVERRIDE;
#endif
};
FileFormat* CreatePcxFormat()
@ -186,6 +188,7 @@ bool PcxFormat::onLoad(FileOp* fop)
}
}
#ifdef ENABLE_SAVE
bool PcxFormat::onSave(FileOp* fop)
{
Image *image = fop->seq.image;
@ -304,5 +307,6 @@ bool PcxFormat::onSave(FileOp* fop)
return true;
}
}
#endif
} // namespace app

View File

@ -53,8 +53,10 @@ class PngFormat : public FileFormat {
FILE_SUPPORT_SEQUENCES;
}
bool onLoad(FileOp* fop);
bool onSave(FileOp* fop);
bool onLoad(FileOp* fop) OVERRIDE;
#ifdef ENABLE_SAVE
bool onSave(FileOp* fop) OVERRIDE;
#endif
};
FileFormat* CreatePngFormat()
@ -327,6 +329,7 @@ bool PngFormat::onLoad(FileOp* fop)
return true;
}
#ifdef ENABLE_SAVE
bool PngFormat::onSave(FileOp* fop)
{
Image *image = fop->seq.image;
@ -543,5 +546,6 @@ bool PngFormat::onSave(FileOp* fop)
/* all right */
return true;
}
#endif
} // namespace app

View File

@ -50,8 +50,10 @@ class TgaFormat : public FileFormat {
FILE_SUPPORT_SEQUENCES;
}
bool onLoad(FileOp* fop);
bool onSave(FileOp* fop);
bool onLoad(FileOp* fop) OVERRIDE;
#ifdef ENABLE_SAVE
bool onSave(FileOp* fop) OVERRIDE;
#endif
};
FileFormat* CreateTgaFormat()
@ -195,11 +197,9 @@ static void rle_tga_read16(uint32_t* address, int w, FILE *f)
} while (c < w);
}
/* load_tga:
* Loads a 256 color or 24 bit uncompressed TGA file, returning a bitmap
* structure and storing the palette data in the specified palette (this
* should be an array of at least 256 RGB structures).
*/
// Loads a 256 color or 24 bit uncompressed TGA file, returning a bitmap
// structure and storing the palette data in the specified palette (this
// should be an array of at least 256 RGB structures).
bool TgaFormat::onLoad(FileOp* fop)
{
unsigned char image_id[256], image_palette[256][3], rgb[4];
@ -389,10 +389,9 @@ bool TgaFormat::onLoad(FileOp* fop)
}
}
/* save_tga:
* Writes a bitmap into a TGA file, using the specified palette (this
* should be an array of at least 256 RGB structures).
*/
#ifdef ENABLE_SAVE
// Writes a bitmap into a TGA file, using the specified palette (this
// should be an array of at least 256 RGB structures).
bool TgaFormat::onSave(FileOp* fop)
{
Image *image = fop->seq.image;
@ -474,5 +473,6 @@ bool TgaFormat::onSave(FileOp* fop)
return true;
}
}
#endif
} // namespace app

View File

@ -35,6 +35,7 @@
#define PACKAGE "Aseprite"
#define VERSION "0.9.6-dev"
#define WEBSITE "http://www.aseprite.org/"
#define WEBSITE_DOWNLOAD WEBSITE "download/"
#define COPYRIGHT "Copyright (C) 2001-2014 David Capello"
#define PRINTF verbose_printf