diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-01-29 17:12:35 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-01-29 17:12:35 (GMT) |
| commit | 80aa7219a2d47632efa5d72b79bbb4fc65721631 (patch) | |
| tree | 257086419a3380872195415ffffb47ec52fff972 /src/preview | |
| parent | 680a36549adaed0c3ce7e8906fadbdf190b0b3b0 (diff) | |
| download | powder-80aa7219a2d47632efa5d72b79bbb4fc65721631.zip powder-80aa7219a2d47632efa5d72b79bbb4fc65721631.tar.gz | |
Vote view in save preview, better handling of controller destruction
Diffstat (limited to 'src/preview')
| -rw-r--r-- | src/preview/PreviewController.cpp | 5 | ||||
| -rw-r--r-- | src/preview/PreviewModel.cpp | 2 | ||||
| -rw-r--r-- | src/preview/PreviewView.cpp | 22 | ||||
| -rw-r--r-- | src/preview/PreviewView.h | 2 |
4 files changed, 28 insertions, 3 deletions
diff --git a/src/preview/PreviewController.cpp b/src/preview/PreviewController.cpp index ac68e07..558d705 100644 --- a/src/preview/PreviewController.cpp +++ b/src/preview/PreviewController.cpp @@ -55,7 +55,10 @@ void PreviewController::Exit() } PreviewController::~PreviewController() { - delete previewView; + if(ui::Engine::Ref().GetWindow() == previewView) + { + ui::Engine::Ref().CloseWindow(); + } delete previewModel; } diff --git a/src/preview/PreviewModel.cpp b/src/preview/PreviewModel.cpp index 658a767..dba7aa1 100644 --- a/src/preview/PreviewModel.cpp +++ b/src/preview/PreviewModel.cpp @@ -118,6 +118,7 @@ void PreviewModel::Update() { if(updateSavePreviewFinished) { + updateSavePreviewWorking = false; pthread_join(updateSavePreviewThread, (void**)(&savePreview)); notifyPreviewChanged(); } @@ -127,6 +128,7 @@ void PreviewModel::Update() { if(updateSaveInfoFinished) { + updateSaveInfoWorking = false; pthread_join(updateSaveInfoThread, (void**)(&save)); notifySaveChanged(); } diff --git a/src/preview/PreviewView.cpp b/src/preview/PreviewView.cpp index de58692..68a224b 100644 --- a/src/preview/PreviewView.cpp +++ b/src/preview/PreviewView.cpp @@ -31,11 +31,11 @@ PreviewView::PreviewView(): openButton->SetActionCallback(new OpenAction(this)); AddComponent(openButton); - saveNameLabel = new ui::Label(ui::Point(5, (YRES/2)+5), ui::Point(100, 16), ""); + saveNameLabel = new ui::Label(ui::Point(5, (YRES/2)+15), ui::Point(100, 16), ""); saveNameLabel->SetAlignment(AlignLeft, AlignBottom); AddComponent(saveNameLabel); - authorDateLabel = new ui::Label(ui::Point(5, (YRES/2)+5+14), ui::Point(100, 16), ""); + authorDateLabel = new ui::Label(ui::Point(5, (YRES/2)+15+14), ui::Point(100, 16), ""); authorDateLabel->SetAlignment(AlignLeft, AlignBottom); AddComponent(authorDateLabel); } @@ -55,6 +55,20 @@ void PreviewView::OnDraw() } g->drawrect(Position.X, Position.Y, XRES/2, YRES/2, 255, 255, 255, 100); g->draw_line(Position.X+XRES/2, Position.Y, Position.X+XRES/2, Position.Y+Size.Y, 255, 255, 255, XRES+BARSIZE); + + + g->draw_line(Position.X+1, Position.Y+10+YRES/2, Position.X-2+XRES/2, Position.Y+10+YRES/2, 100, 100, 100, XRES+BARSIZE); + float factor; + if(!votesUp && !votesDown) + return; + else + factor = (float)(((float)(XRES/2))/((float)(votesUp+votesDown))); + g->fillrect(Position.X, Position.Y+YRES/2, XRES/2, 10, 200, 50, 50, 255); + g->fillrect(Position.X, Position.Y+YRES/2, (int)(((float)votesUp)*factor), 10, 50, 200, 50, 255); + g->fillrect(Position.X, Position.Y+(YRES/2), 14, 10, 0, 0, 0, 100); + g->fillrect(Position.X+(XRES/2)-14, Position.Y+(YRES/2), 14, 10, 0, 0, 0, 100); + g->draw_icon(Position.X+2, Position.Y+(YRES/2)+2, IconVoteUp); + g->draw_icon(Position.X+(XRES/2)-12, Position.Y+(YRES/2), IconVoteDown); } void PreviewView::OnTick(float dt) @@ -73,11 +87,15 @@ void PreviewView::NotifySaveChanged(PreviewModel * sender) Save * save = sender->GetSave(); if(save) { + votesUp = save->votesUp; + votesDown = save->votesDown; saveNameLabel->SetText(save->name); authorDateLabel->SetText("\bgAuthor:\bw " + save->userName + " \bgDate:\bw "); } else { + votesUp = 0; + votesDown = 0; saveNameLabel->SetText(""); authorDateLabel->SetText(""); } diff --git a/src/preview/PreviewView.h b/src/preview/PreviewView.h index a526ef7..dbc3248 100644 --- a/src/preview/PreviewView.h +++ b/src/preview/PreviewView.h @@ -22,6 +22,8 @@ class PreviewView: public ui::Window { ui::Button * openButton; ui::Label * saveNameLabel; ui::Label * authorDateLabel; + int votesUp; + int votesDown; public: void AttachController(PreviewController * controller) { c = controller;} PreviewView(); |
