mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-05 21:57:20 +00:00
Save filename in "doc" file
This commit is contained in:
parent
fddddf1342
commit
77ec6c9e17
@ -189,6 +189,8 @@ void SaveFileBaseCommand::saveAsDialog(const ContextReader& reader, const char*
|
||||
|
||||
if (documentWriter->isModified())
|
||||
documentWriter->setFilename(oldFilename);
|
||||
else
|
||||
documentWriter->incrementVersion();
|
||||
|
||||
update_screen_for_document(documentWriter);
|
||||
}
|
||||
|
@ -230,6 +230,7 @@ bool read_document_info(const std::string& dir, DocumentInfo& info)
|
||||
if (base::is_file(base::join_path(dir, "doc"))) {
|
||||
IFSTREAM(dir, s, "doc");
|
||||
sprId = read32(s);
|
||||
info.filename = read_string(s);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
@ -250,11 +251,16 @@ app::Document* read_document(const std::string& dir)
|
||||
|
||||
IFSTREAM(dir, s, "doc");
|
||||
ObjectId sprId = read32(s);
|
||||
std::string filename = read_string(s);
|
||||
|
||||
Reader reader(dir);
|
||||
Sprite* spr = reader.loadSprite(sprId);
|
||||
if (spr)
|
||||
return new app::Document(spr);
|
||||
if (spr) {
|
||||
app::Document* doc = new app::Document(spr);
|
||||
doc->setFilename(filename);
|
||||
doc->impossibleToBackToSavedState();
|
||||
return doc;
|
||||
}
|
||||
else {
|
||||
Console().printf("Unable to load sprite #%d\n", sprId);
|
||||
return nullptr;
|
||||
|
@ -23,6 +23,7 @@ namespace crash {
|
||||
int width;
|
||||
int height;
|
||||
doc::frame_t frames;
|
||||
std::string filename;
|
||||
};
|
||||
|
||||
bool read_document_info(const std::string& dir, DocumentInfo& info);
|
||||
|
@ -37,12 +37,14 @@ Session::Backup::Backup(const std::string& dir)
|
||||
read_document_info(dir, info);
|
||||
|
||||
std::vector<char> buf(1024);
|
||||
sprintf(&buf[0], "%s Sprite %dx%d with %d frame(s)",
|
||||
sprintf(&buf[0], "%s Sprite %dx%d, %d %s: %s",
|
||||
info.format == IMAGE_RGB ? "RGB":
|
||||
info.format == IMAGE_GRAYSCALE ? "Grayscale":
|
||||
info.format == IMAGE_INDEXED ? "Indexed":
|
||||
info.format == IMAGE_BITMAP ? "Bitmap": "Unknown",
|
||||
info.width, info.height, info.frames);
|
||||
info.width, info.height, info.frames,
|
||||
info.frames == 1 ? "frame": "frames",
|
||||
info.filename.c_str());
|
||||
m_desc = &buf[0];
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ void save_object(const char* prefix, T* obj, WriteFunc write_func, Versions& ver
|
||||
obj->incrementVersion();
|
||||
|
||||
if (versions[obj->id()] != obj->version()) {
|
||||
OFSTREAM(dir, s, prefix + base::convert_to<std::string>(obj->id()));
|
||||
OFSTREAM(dir, s, prefix ? prefix + base::convert_to<std::string>(obj->id()): "doc");
|
||||
write_func(s, obj);
|
||||
versions[obj->id()] = obj->version();
|
||||
|
||||
@ -75,6 +75,12 @@ void save_object(const char* prefix, T* obj, WriteFunc write_func, Versions& ver
|
||||
}
|
||||
}
|
||||
|
||||
void write_document_file(std::ofstream& s, app::Document* doc)
|
||||
{
|
||||
write32(s, doc->sprite()->id());
|
||||
write_string(s, doc->filename());
|
||||
}
|
||||
|
||||
void write_sprite(std::ofstream& s, Sprite* spr)
|
||||
{
|
||||
write8(s, spr->pixelFormat());
|
||||
@ -129,12 +135,7 @@ void write_document(const std::string& dir, app::Document* doc)
|
||||
Versions& versions = g_documentObjects[doc->id()];
|
||||
Sprite* spr = doc->sprite();
|
||||
|
||||
// Create a "doc" file with the main sprite ID
|
||||
if (!base::is_file(base::join_path(dir, "doc"))) {
|
||||
OFSTREAM(dir, s, "doc");
|
||||
write32(s, spr->id());
|
||||
}
|
||||
|
||||
save_object(nullptr, doc, write_document_file, versions, dir);
|
||||
save_object("spr", spr, write_sprite, versions, dir);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
Reference in New Issue
Block a user