summaryrefslogtreecommitdiff
path: root/src/game/GameView.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-06-20 12:40:18 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-06-20 12:40:18 (GMT)
commit2be9c925088c16beb144dd9932202416d00ff581 (patch)
tree51f8ccbf2b0b051890c5f5d12fa28a67635c06c2 /src/game/GameView.cpp
parent9769239af69695e9a7f8cf103a197695ecf691e0 (diff)
downloadpowder-2be9c925088c16beb144dd9932202416d00ff581.zip
powder-2be9c925088c16beb144dd9932202416d00ff581.tar.gz
OpenGL canvas for Windows, Notifications for main Game, Update checker in Client (+ other client triggered events)
Diffstat (limited to 'src/game/GameView.cpp')
-rw-r--r--src/game/GameView.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp
index 8abcca6..4900603 100644
--- a/src/game/GameView.cpp
+++ b/src/game/GameView.cpp
@@ -846,6 +846,58 @@ void GameView::DoDraw()
c->Tick();
}
+void GameView::NotifyNotificationsChanged(GameModel * sender)
+{
+ class NotificationButtonAction : public ui::ButtonAction
+ {
+ GameView * v;
+ Notification * notification;
+ public:
+ NotificationButtonAction(GameView * v, Notification * notification) : v(v), notification(notification) { }
+ void ActionCallback(ui::Button * sender)
+ {
+ notification->Action();
+ //v->c->RemoveNotification(notification);
+ }
+ };
+ class CloseNotificationButtonAction : public ui::ButtonAction
+ {
+ GameView * v;
+ Notification * notification;
+ public:
+ CloseNotificationButtonAction(GameView * v, Notification * notification) : v(v), notification(notification) { }
+ void ActionCallback(ui::Button * sender)
+ {
+ v->c->RemoveNotification(notification);
+ }
+ };
+
+ for(std::vector<ui::Component*>::iterator iter = notificationComponents.begin(); iter != notificationComponents.end(); ++iter) {
+ RemoveComponent(*iter);
+ delete *iter;
+ }
+ notificationComponents.clear();
+
+ std::vector<Notification*> notifications = sender->GetNotifications();
+
+ int currentY = YRES-17;
+ for(std::vector<Notification*>::iterator iter = notifications.begin(); iter != notifications.end(); ++iter)
+ {
+ int width = (Graphics::textwidth((*iter)->Message.c_str()))+8;
+ ui::Button * tempButton = new ui::Button(ui::Point(XRES-width-22, currentY), ui::Point(width, 15), (*iter)->Message);
+ tempButton->SetActionCallback(new NotificationButtonAction(this, *iter));
+ AddComponent(tempButton);
+ notificationComponents.push_back(tempButton);
+
+ tempButton = new ui::Button(ui::Point(XRES-20, currentY), ui::Point(15, 15));
+ tempButton->SetIcon(IconDelete);
+ tempButton->SetActionCallback(new CloseNotificationButtonAction(this, *iter));
+ AddComponent(tempButton);
+ notificationComponents.push_back(tempButton);
+
+ currentY -= 17;
+ }
+}
void GameView::NotifyZoomChanged(GameModel * sender)
{