diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-07-31 18:49:08 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-07-31 18:49:08 (GMT) |
| commit | 1d258eab6b0ec3740d634f014af5dbff882e0069 (patch) | |
| tree | 956d446f144415d4f188dcca17c7dffba08851c2 /src/interface/SaveButton.cpp | |
| parent | 303b546ceb134df48763730cbfd8ce7b6df008a2 (diff) | |
| download | powder-1d258eab6b0ec3740d634f014af5dbff882e0069.zip powder-1d258eab6b0ec3740d634f014af5dbff882e0069.tar.gz | |
ThumbnailBroker for background retrieval and rendering
Diffstat (limited to 'src/interface/SaveButton.cpp')
| -rw-r--r-- | src/interface/SaveButton.cpp | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/src/interface/SaveButton.cpp b/src/interface/SaveButton.cpp index b312d3a..18e382d 100644 --- a/src/interface/SaveButton.cpp +++ b/src/interface/SaveButton.cpp @@ -4,7 +4,7 @@ #include "client/SaveInfo.h" #include "graphics/Graphics.h" #include "Engine.h" -#include "client/Client.h" +#include "client/ThumbnailBroker.h" #include "simulation/SaveRenderer.h" namespace ui { @@ -62,7 +62,8 @@ SaveButton::SaveButton(Point position, Point size, SaveFile * file): voteColour(255, 0, 0), selectable(false), selected(false), - wantsDraw(false) + wantsDraw(false), + waitingForThumb(false) { if(file) { @@ -78,6 +79,8 @@ SaveButton::SaveButton(Point position, Point size, SaveFile * file): SaveButton::~SaveButton() { + ThumbnailBroker::Ref().DetachThumbnailListener(this); + if(thumbnail) delete thumbnail; if(actionCallback) @@ -88,11 +91,43 @@ SaveButton::~SaveButton() delete file; } +void SaveButton::OnThumbnailReady(Thumbnail * thumb) +{ + if(thumb) + { + if(thumbnail) + delete thumbnail; + thumbnail = thumb; + waitingForThumb = false; + } +} + void SaveButton::Tick(float dt) { - Thumbnail * tempThumb; + if(!thumbnail && !waitingForThumb) + { + if(save) + { + if(save->GetGameSave()) + { + waitingForThumb = true; + ThumbnailBroker::Ref().RenderThumbnail(save->GetGameSave(), Size.X-3, Size.Y-25, this); + } + else if(save->GetID()) + { + waitingForThumb = true; + ThumbnailBroker::Ref().RetrieveThumbnail(save->GetID() , Size.X-3, Size.Y-25, this); + } + } + else if(file && file->GetGameSave()) + { + waitingForThumb = true; + ThumbnailBroker::Ref().RenderThumbnail(file->GetGameSave(), Size.X-3, Size.Y-25, this); + } + } + /*Thumbnail * tempThumb; float scaleFactorY = 1.0f, scaleFactorX = 1.0f; - if(!thumbnail/* && wantsDraw*/) + if(!thumbnail) { if(save) { @@ -148,7 +183,7 @@ void SaveButton::Tick(float dt) free(thumbData); } } - } + }*/ } void SaveButton::Draw(const Point& screenPos) |
