diff options
| author | jacob1 <jfu614@gmail.com> | 2013-03-04 20:27:51 (GMT) |
|---|---|---|
| committer | jacob1 <jfu614@gmail.com> | 2013-03-04 20:27:51 (GMT) |
| commit | 38573cc30e0d2dea191ad061020de399931dead9 (patch) | |
| tree | cf7ac33d3c0c7a1c033a7398a9b07ae47eb62053 /src/game/GameView.cpp | |
| parent | 0f5b4a9ec83b8c6d2bb9448b6e58f841a875a636 (diff) | |
| download | powder-38573cc30e0d2dea191ad061020de399931dead9.zip powder-38573cc30e0d2dea191ad061020de399931dead9.tar.gz | |
by date turns white like my own does when selected
Diffstat (limited to 'src/game/GameView.cpp')
| -rw-r--r-- | src/game/GameView.cpp | 388 |
1 files changed, 194 insertions, 194 deletions
diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp index d1986fd..a1f3fca 100644 --- a/src/game/GameView.cpp +++ b/src/game/GameView.cpp @@ -52,14 +52,14 @@ public: void SetSplitActionCallback(SplitButtonAction * newAction) { splitActionCallback = newAction; } virtual void OnMouseUnclick(int x, int y, unsigned int button) { - if(isButtonDown) - { - if(leftDown) + if(isButtonDown) + { + if(leftDown) DoLeftAction(); else if(rightDown) DoRightAction(); - } - ui::Button::OnMouseUnclick(x, y, button); + } + ui::Button::OnMouseUnclick(x, y, button); } virtual void OnMouseMovedInside(int x, int y, int dx, int dy) @@ -81,7 +81,7 @@ public: } virtual void OnMouseEnter(int x, int y) { - isMouseInside = true; + isMouseInside = true; if(!Enabled) return; if(x >= splitPosition || !showSplit) @@ -218,170 +218,170 @@ GameView::GameView(): searchButton->SetActionCallback(new SearchAction(this)); AddComponent(searchButton); - class ReloadAction : public ui::ButtonAction - { - GameView * v; - public: - ReloadAction(GameView * _v) { v = _v; } - void ActionCallback(ui::Button * sender) - { - v->c->ReloadSim(); - } - void AltActionCallback(ui::Button * sender) - { - v->c->OpenSavePreview(); - } - }; - reloadButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(17, 15), "", "Reload the simulation"); - reloadButton->SetIcon(IconReload); - reloadButton->Appearance.Margin.Left+=2; - currentX+=18; - reloadButton->SetActionCallback(new ReloadAction(this)); - AddComponent(reloadButton); - - class SaveSimulationAction : public SplitButtonAction - { - GameView * v; - public: - SaveSimulationAction(GameView * _v) { v = _v; } - void ActionCallbackRight(ui::Button * sender) - { - if(v->CtrlBehaviour()) - v->c->OpenLocalSaveWindow(false); - else - v->c->OpenSaveWindow(); - } - void ActionCallbackLeft(ui::Button * sender) - { - if(v->CtrlBehaviour()) - v->c->OpenLocalSaveWindow(true); - else - v->c->SaveAsCurrent(); - } - }; - saveSimulationButton = new SplitButton(ui::Point(currentX, Size.Y-16), ui::Point(150, 15), "[untitled simulation]", "Save game as current name", "Save game as new name", 19); + class ReloadAction : public ui::ButtonAction + { + GameView * v; + public: + ReloadAction(GameView * _v) { v = _v; } + void ActionCallback(ui::Button * sender) + { + v->c->ReloadSim(); + } + void AltActionCallback(ui::Button * sender) + { + v->c->OpenSavePreview(); + } + }; + reloadButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(17, 15), "", "Reload the simulation"); + reloadButton->SetIcon(IconReload); + reloadButton->Appearance.Margin.Left+=2; + currentX+=18; + reloadButton->SetActionCallback(new ReloadAction(this)); + AddComponent(reloadButton); + + class SaveSimulationAction : public SplitButtonAction + { + GameView * v; + public: + SaveSimulationAction(GameView * _v) { v = _v; } + void ActionCallbackRight(ui::Button * sender) + { + if(v->CtrlBehaviour()) + v->c->OpenLocalSaveWindow(false); + else + v->c->OpenSaveWindow(); + } + void ActionCallbackLeft(ui::Button * sender) + { + if(v->CtrlBehaviour()) + v->c->OpenLocalSaveWindow(true); + else + v->c->SaveAsCurrent(); + } + }; + saveSimulationButton = new SplitButton(ui::Point(currentX, Size.Y-16), ui::Point(150, 15), "[untitled simulation]", "Save game as current name", "Save game as new name", 19); saveSimulationButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; - saveSimulationButton->SetIcon(IconSave); - currentX+=151; - ((SplitButton*)saveSimulationButton)->SetSplitActionCallback(new SaveSimulationAction(this)); - AddComponent(saveSimulationButton); - - class UpVoteAction : public ui::ButtonAction - { - GameView * v; - public: - UpVoteAction(GameView * _v) { v = _v; } - void ActionCallback(ui::Button * sender) - { - v->c->Vote(1); - } - }; - upVoteButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(15, 15), "", "Like this save"); - upVoteButton->SetIcon(IconVoteUp); - upVoteButton->Appearance.Margin.Top+=2; - upVoteButton->Appearance.Margin.Left+=2; - currentX+=14; - upVoteButton->SetActionCallback(new UpVoteAction(this)); - AddComponent(upVoteButton); - - class DownVoteAction : public ui::ButtonAction - { - GameView * v; - public: - DownVoteAction(GameView * _v) { v = _v; } - void ActionCallback(ui::Button * sender) - { - v->c->Vote(-1); - } - }; - downVoteButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(15, 15), "", "Dislike this save"); - downVoteButton->SetIcon(IconVoteDown); - downVoteButton->Appearance.Margin.Bottom+=2; - downVoteButton->Appearance.Margin.Left+=2; - currentX+=16; - downVoteButton->SetActionCallback(new DownVoteAction(this)); - AddComponent(downVoteButton); - - class TagSimulationAction : public ui::ButtonAction - { - GameView * v; - public: - TagSimulationAction(GameView * _v) { v = _v; } - void ActionCallback(ui::Button * sender) - { - v->c->OpenTags(); - } - }; - tagSimulationButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(251, 15), "[no tags set]", "Add simulation tags"); + saveSimulationButton->SetIcon(IconSave); + currentX+=151; + ((SplitButton*)saveSimulationButton)->SetSplitActionCallback(new SaveSimulationAction(this)); + AddComponent(saveSimulationButton); + + class UpVoteAction : public ui::ButtonAction + { + GameView * v; + public: + UpVoteAction(GameView * _v) { v = _v; } + void ActionCallback(ui::Button * sender) + { + v->c->Vote(1); + } + }; + upVoteButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(15, 15), "", "Like this save"); + upVoteButton->SetIcon(IconVoteUp); + upVoteButton->Appearance.Margin.Top+=2; + upVoteButton->Appearance.Margin.Left+=2; + currentX+=14; + upVoteButton->SetActionCallback(new UpVoteAction(this)); + AddComponent(upVoteButton); + + class DownVoteAction : public ui::ButtonAction + { + GameView * v; + public: + DownVoteAction(GameView * _v) { v = _v; } + void ActionCallback(ui::Button * sender) + { + v->c->Vote(-1); + } + }; + downVoteButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(15, 15), "", "Dislike this save"); + downVoteButton->SetIcon(IconVoteDown); + downVoteButton->Appearance.Margin.Bottom+=2; + downVoteButton->Appearance.Margin.Left+=2; + currentX+=16; + downVoteButton->SetActionCallback(new DownVoteAction(this)); + AddComponent(downVoteButton); + + class TagSimulationAction : public ui::ButtonAction + { + GameView * v; + public: + TagSimulationAction(GameView * _v) { v = _v; } + void ActionCallback(ui::Button * sender) + { + v->c->OpenTags(); + } + }; + tagSimulationButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(251, 15), "[no tags set]", "Add simulation tags"); tagSimulationButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; - tagSimulationButton->SetIcon(IconTag); - currentX+=252; - tagSimulationButton->SetActionCallback(new TagSimulationAction(this)); - AddComponent(tagSimulationButton); - - class ClearSimAction : public ui::ButtonAction - { - GameView * v; - public: - ClearSimAction(GameView * _v) { v = _v; } - void ActionCallback(ui::Button * sender) - { - v->c->ClearSim(); - } - }; - clearSimButton = new ui::Button(ui::Point(Size.X-159, Size.Y-16), ui::Point(17, 15), "", "Erase everything"); - clearSimButton->SetIcon(IconNew); - clearSimButton->Appearance.Margin.Left+=2; - clearSimButton->SetActionCallback(new ClearSimAction(this)); - AddComponent(clearSimButton); - - class LoginAction : public ui::ButtonAction - { - GameView * v; - public: - LoginAction(GameView * _v) { v = _v; } - void ActionCallback(ui::Button * sender) - { - v->c->OpenLogin(); - } - }; - loginButton = new ui::Button(ui::Point(Size.X-141, Size.Y-16), ui::Point(92, 15), "[sign in]", "Sign into simulation server"); + tagSimulationButton->SetIcon(IconTag); + currentX+=252; + tagSimulationButton->SetActionCallback(new TagSimulationAction(this)); + AddComponent(tagSimulationButton); + + class ClearSimAction : public ui::ButtonAction + { + GameView * v; + public: + ClearSimAction(GameView * _v) { v = _v; } + void ActionCallback(ui::Button * sender) + { + v->c->ClearSim(); + } + }; + clearSimButton = new ui::Button(ui::Point(Size.X-159, Size.Y-16), ui::Point(17, 15), "", "Erase everything"); + clearSimButton->SetIcon(IconNew); + clearSimButton->Appearance.Margin.Left+=2; + clearSimButton->SetActionCallback(new ClearSimAction(this)); + AddComponent(clearSimButton); + + class LoginAction : public ui::ButtonAction + { + GameView * v; + public: + LoginAction(GameView * _v) { v = _v; } + void ActionCallback(ui::Button * sender) + { + v->c->OpenLogin(); + } + }; + loginButton = new ui::Button(ui::Point(Size.X-141, Size.Y-16), ui::Point(92, 15), "[sign in]", "Sign into simulation server"); loginButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; - loginButton->SetIcon(IconLogin); - loginButton->SetActionCallback(new LoginAction(this)); - AddComponent(loginButton); - - class SimulationOptionAction : public ui::ButtonAction - { - GameView * v; - public: - SimulationOptionAction(GameView * _v) { v = _v; } - void ActionCallback(ui::Button * sender) - { - v->c->OpenOptions(); - } - }; - simulationOptionButton = new ui::Button(ui::Point(Size.X-48, Size.Y-16), ui::Point(15, 15), "", "Simulation options"); - simulationOptionButton->SetIcon(IconSimulationSettings); - simulationOptionButton->Appearance.Margin.Left+=2; - simulationOptionButton->SetActionCallback(new SimulationOptionAction(this)); - AddComponent(simulationOptionButton); - - class DisplayModeAction : public ui::ButtonAction - { - GameView * v; - public: - DisplayModeAction(GameView * _v) { v = _v; } - void ActionCallback(ui::Button * sender) - { - v->c->OpenRenderOptions(); - } - }; - displayModeButton = new ui::Button(ui::Point(Size.X-32, Size.Y-16), ui::Point(15, 15), "", "Renderer options"); - displayModeButton->SetIcon(IconRenderSettings); - displayModeButton->Appearance.Margin.Left+=2; - displayModeButton->SetActionCallback(new DisplayModeAction(this)); - AddComponent(displayModeButton); + loginButton->SetIcon(IconLogin); + loginButton->SetActionCallback(new LoginAction(this)); + AddComponent(loginButton); + + class SimulationOptionAction : public ui::ButtonAction + { + GameView * v; + public: + SimulationOptionAction(GameView * _v) { v = _v; } + void ActionCallback(ui::Button * sender) + { + v->c->OpenOptions(); + } + }; + simulationOptionButton = new ui::Button(ui::Point(Size.X-48, Size.Y-16), ui::Point(15, 15), "", "Simulation options"); + simulationOptionButton->SetIcon(IconSimulationSettings); + simulationOptionButton->Appearance.Margin.Left+=2; + simulationOptionButton->SetActionCallback(new SimulationOptionAction(this)); + AddComponent(simulationOptionButton); + + class DisplayModeAction : public ui::ButtonAction + { + GameView * v; + public: + DisplayModeAction(GameView * _v) { v = _v; } + void ActionCallback(ui::Button * sender) + { + v->c->OpenRenderOptions(); + } + }; + displayModeButton = new ui::Button(ui::Point(Size.X-32, Size.Y-16), ui::Point(15, 15), "", "Renderer options"); + displayModeButton->SetIcon(IconRenderSettings); + displayModeButton->Appearance.Margin.Left+=2; + displayModeButton->SetActionCallback(new DisplayModeAction(this)); + AddComponent(displayModeButton); class PauseAction : public ui::ButtonAction { @@ -1609,33 +1609,33 @@ void GameView::DoDraw() 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); - } + 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); + } void AltActionCallback(ui::Button * sender) - { - v->c->RemoveNotification(notification); - } - }; + { + v->c->RemoveNotification(notification); + } + }; for(std::vector<ui::Component*>::const_iterator iter = notificationComponents.begin(), end = notificationComponents.end(); iter != end; ++iter) { ui::Component * cNotification = *iter; @@ -1942,7 +1942,7 @@ void GameView::OnDraw() { string message = (*iter); startY -= 13; - g->fillrect(startX-3, startY-3, Graphics::textwidth((char*)message.c_str())+6 , 14, 0, 0, 0, 100); + g->fillrect(startX-3, startY-3, Graphics::textwidth((char*)message.c_str())+6 , 14, 0, 0, 0, 100); g->drawtext(startX, startY, message.c_str(), 255, 255, 255, startAlpha); startAlpha-=14; } |
