diff options
Diffstat (limited to 'library/resources.cpp')
-rw-r--r-- | library/resources.cpp | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/library/resources.cpp b/library/resources.cpp index 68eeb4d6..9169bf85 100644 --- a/library/resources.cpp +++ b/library/resources.cpp @@ -3,6 +3,7 @@ #include <wx/zipstrm.h> #include <wx/image.h> #include <wx/icon.h> +#include <wx/mstream.h> #include "globalFunctions.h" #ifdef FFS_WIN @@ -111,6 +112,24 @@ GlobalResources::~GlobalResources() } +void loadAnimFromZip(wxZipInputStream& zipInput, wxAnimation* animation) +{ + //Workaround for wxWidgets: + //construct seekable input stream (zip-input stream is non-seekable) for wxAnimation::Load() + //luckily this method call is very fast: below measurement precision! + vector<unsigned char> data; + data.reserve(10000); + + int newValue = 0; + while ((newValue = zipInput.GetC()) != wxEOF) + data.push_back(newValue); + + wxMemoryInputStream seekAbleStream(&data.front(), data.size()); //stream does not take ownership of data + + animation->Load(seekAbleStream, wxANIMATION_TYPE_GIF); +} + + void GlobalResources::load() { wxFileInputStream input(wxT("Resources.dat")); @@ -121,21 +140,22 @@ void GlobalResources::load() wxZipInputStream resourceFile(input); - wxZipEntry* entry; + wxZipEntry* entry = NULL; map<wxString, wxBitmap*>::iterator bmp; while ((entry = resourceFile.GetNextEntry())) { wxString name = entry->GetName(); - //just to be sure: search if entry is available in map + //search if entry is available in map if ((bmp = bitmapResource.find(name)) != bitmapResource.end()) *(bmp->second) = wxBitmap(wxImage(resourceFile, wxBITMAP_TYPE_PNG)); + else if (name == wxT("money.gif")) + loadAnimFromZip(resourceFile, animationMoney); + else if (name == wxT("working.gif")) + loadAnimFromZip(resourceFile, animationSync); } } - animationMoney->LoadFile(wxT("Resources.a01")); - animationSync->LoadFile(wxT("Resources.a02")); - #ifdef FFS_WIN programIcon = new wxIcon(wxT("ffsIcon1")); #else |