diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-04-04 20:47:58 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-04-04 20:47:58 (GMT) |
| commit | ea51cde1f07d2a63f824e78c44adad0993115853 (patch) | |
| tree | a6afee4bafb5de2f91caf1235351b7cc6fc2e606 /src/game | |
| parent | 89cdeef9ad9c164e9f484cded3096bcbc72b7207 (diff) | |
| download | powder-ea51cde1f07d2a63f824e78c44adad0993115853.zip powder-ea51cde1f07d2a63f824e78c44adad0993115853.tar.gz | |
Change brush size with [ and ] keys, change order of drawing for Lua, Fix print and tpt.log so they log to the console when it is open
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/GameController.cpp | 22 | ||||
| -rw-r--r-- | src/game/GameController.h | 5 | ||||
| -rw-r--r-- | src/game/GameView.cpp | 28 | ||||
| -rw-r--r-- | src/game/GameView.h | 1 |
4 files changed, 44 insertions, 12 deletions
diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp index b8f60f5..dfdc12d 100644 --- a/src/game/GameController.cpp +++ b/src/game/GameController.cpp @@ -174,9 +174,13 @@ void GameController::PlaceClipboard(ui::Point position) } } -void GameController::AdjustBrushSize(int direction) +void GameController::AdjustBrushSize(int direction, bool logarithmic) { - ui::Point newSize = gameModel->GetBrush()->GetRadius() + ui::Point(direction, direction); + ui::Point newSize(0, 0); + if(logarithmic) + newSize = gameModel->GetBrush()->GetRadius() + ui::Point(direction * ((gameModel->GetBrush()->GetRadius().X/10)>0?gameModel->GetBrush()->GetRadius().X/10:1), direction * ((gameModel->GetBrush()->GetRadius().Y/10)>0?gameModel->GetBrush()->GetRadius().Y/10:1)); + else + newSize = gameModel->GetBrush()->GetRadius() + ui::Point(direction, direction); if(newSize.X<0) newSize.X = 0; if(newSize.Y<0) @@ -184,9 +188,13 @@ void GameController::AdjustBrushSize(int direction) gameModel->GetBrush()->SetRadius(newSize); } -void GameController::AdjustZoomSize(int direction) +void GameController::AdjustZoomSize(int direction, bool logarithmic) { - int newSize = gameModel->GetZoomSize()+direction; + int newSize; + if(logarithmic) + newSize = gameModel->GetZoomSize()+direction; + else + newSize = gameModel->GetZoomSize()+(((gameModel->GetZoomSize()/10)>0?(gameModel->GetZoomSize()/10):1)*direction); if(newSize<5) newSize = 5; if(newSize>64) @@ -333,9 +341,13 @@ bool GameController::KeyRelease(int key, Uint16 character, bool shift, bool ctrl return commandInterface->OnKeyRelease(key, character, shift, ctrl, alt); } +void GameController::Tick() +{ + commandInterface->OnTick(); +} + void GameController::Update() { - commandInterface->OnTick(1.0f); gameModel->GetSimulation()->update_particles(); if(renderOptions && renderOptions->HasExited) { diff --git a/src/game/GameController.h b/src/game/GameController.h index 3b5ff88..fffe26a 100644 --- a/src/game/GameController.h +++ b/src/game/GameController.h @@ -54,11 +54,12 @@ public: bool MouseWheel(int x, int y, int d); bool KeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt); bool KeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt); + void Tick(); void SetZoomEnabled(bool zoomEnable); void SetZoomPosition(ui::Point position); - void AdjustBrushSize(int direction); - void AdjustZoomSize(int direction); + void AdjustBrushSize(int direction, bool logarithmic = false); + void AdjustZoomSize(int direction, bool logarithmic = false); void DrawPoints(int toolSelection, queue<ui::Point*> & pointQueue); void DrawRect(int toolSelection, ui::Point point1, ui::Point point2); void DrawLine(int toolSelection, ui::Point point1, ui::Point point2); diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp index 2ccf2e4..d8ea4b8 100644 --- a/src/game/GameView.cpp +++ b/src/game/GameView.cpp @@ -693,6 +693,12 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool selectPoint1 = selectPoint2; c->OpenStamps(); break; + case ']': + c->AdjustBrushSize(1, true); + break; + case '[': + c->AdjustBrushSize(-1, true); + break; } } @@ -739,6 +745,8 @@ void GameView::OnTick(float dt) c->DrawFill(toolIndex, currentMouse); } c->Update(); + if(lastLogEntry > -0.1f) + lastLogEntry -= 0.16*dt; } void GameView::DoMouseMove(int x, int y, int dx, int dy) @@ -777,6 +785,13 @@ void GameView::DoKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bo Window::DoKeyRelease(key, character, shift, ctrl, alt); } +void GameView::DoDraw() +{ + Window::DoDraw(); + c->Tick(); +} + + void GameView::NotifyZoomChanged(GameModel * sender) { zoomEnabled = sender->GetZoomEnabled(); @@ -786,7 +801,7 @@ void GameView::NotifyLogChanged(GameModel * sender, string entry) { logEntries.push_front(entry); lastLogEntry = 100.0f; - if(logEntries.size()>10) + if(logEntries.size()>20) logEntries.pop_back(); } @@ -900,15 +915,18 @@ void GameView::OnDraw() int startX = 20; int startY = YRES-20; - if(lastLogEntry>0.1 && logEntries.size()) + int startAlpha; + if(lastLogEntry>0.1f && logEntries.size()) { + startAlpha = 2.55f*lastLogEntry; deque<string>::iterator iter; - for(iter = logEntries.begin(); iter != logEntries.end(); iter++) + for(iter = logEntries.begin(); iter != logEntries.end() && startAlpha>0; iter++) { string message = (*iter); - startY -= 14; + startY -= 13; 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, 255); + g->drawtext(startX, startY, message.c_str(), 255, 255, 255, startAlpha); + startAlpha-=14; } } } diff --git a/src/game/GameView.h b/src/game/GameView.h index 9658184..9843743 100644 --- a/src/game/GameView.h +++ b/src/game/GameView.h @@ -101,6 +101,7 @@ public: virtual void OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt); //Top-level handers, for Lua interface + virtual void DoDraw(); virtual void DoMouseMove(int x, int y, int dx, int dy); virtual void DoMouseDown(int x, int y, unsigned button); virtual void DoMouseUp(int x, int y, unsigned button); |
