diff options
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/GameController.cpp | 22 | ||||
| -rw-r--r-- | src/game/GameModel.cpp | 23 | ||||
| -rw-r--r-- | src/game/GameModel.h | 6 | ||||
| -rw-r--r-- | src/game/GameView.cpp | 35 | ||||
| -rw-r--r-- | src/game/GameView.h | 4 | ||||
| -rw-r--r-- | src/game/QuickOptions.h | 29 | ||||
| -rw-r--r-- | src/game/SignTool.cpp | 2 |
7 files changed, 94 insertions, 27 deletions
diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp index a1c4965..99315b0 100644 --- a/src/game/GameController.cpp +++ b/src/game/GameController.cpp @@ -146,6 +146,7 @@ GameController::GameController(): { gameView = new GameView(); gameModel = new GameModel(); + gameModel->BuildQuickOptionMenu(this); gameView->AttachController(this); gameModel->AddObserver(gameView); @@ -536,7 +537,7 @@ bool GameController::MouseUp(int x, int y, unsigned button) (*iter).pos(signx, signy, signw, signh); if (x>=signx && x<=signx+signw && y>=signy && y<=signy+signh) { - if (sregexp((*iter).text.c_str(), "^{c:[0-9]*|.*}$")==0) + if (sregexp((*iter).text.c_str(), "^{[c|t]:[0-9]*|.*}$")==0) { const char * signText = (*iter).text.c_str(); char buff[256]; @@ -550,8 +551,17 @@ bool GameController::MouseUp(int x, int y, unsigned button) buff[sldr-3] = '\0'; int tempSaveID = format::StringToNumber<int>(std::string(buff)); - if(tempSaveID) - OpenSavePreview(tempSaveID, 0); + if (tempSaveID) + { + if ((*iter).text.c_str()[1] == 'c') + OpenSavePreview(tempSaveID, 0); + else if ((*iter).text.c_str()[1] == 't') + { + char url[256]; + sprintf(url, "http://powdertoy.co.uk/Discussions/Thread/View.html?Thread=%i", tempSaveID); + OpenURI(url); + } + } break; } } @@ -744,8 +754,7 @@ void GameController::SwitchAir() void GameController::ToggleAHeat() { - gameModel->GetSimulation()->aheat_enable = !gameModel->GetSimulation()->aheat_enable; - gameModel->UpdateQuickOptions(); + gameModel->SetAHeatEnable(!gameModel->GetAHeatEnable()); } @@ -1101,8 +1110,7 @@ void GameController::SaveAsCurrent() virtual ~SaveUploadedCallback() {}; virtual void SaveUploaded(SaveInfo save) { - //Don't do anything - //c->LoadSave(&save); + c->LoadSave(&save); } }; diff --git a/src/game/GameModel.cpp b/src/game/GameModel.cpp index 6f30b5e..49e031f 100644 --- a/src/game/GameModel.cpp +++ b/src/game/GameModel.cpp @@ -98,7 +98,6 @@ GameModel::GameModel(): } BuildMenus(); - BuildQuickOptionMenu(); //Set default decoration colour unsigned char colourR = min(Client::Ref().GetPrefInteger("Decoration.Red", 200), 255); @@ -173,7 +172,7 @@ void GameModel::UpdateQuickOptions() } } -void GameModel::BuildQuickOptionMenu() +void GameModel::BuildQuickOptionMenu(GameController * controller) { for(std::vector<QuickOption*>::iterator iter = quickOptions.begin(), end = quickOptions.end(); iter != end; ++iter) { @@ -186,6 +185,7 @@ void GameModel::BuildQuickOptionMenu() quickOptions.push_back(new DecorationsOption(this)); quickOptions.push_back(new NGravityOption(this)); quickOptions.push_back(new AHeatOption(this)); + quickOptions.push_back(new ConsoleShowOption(this, controller)); notifyQuickOptionsChanged(); UpdateQuickOptions(); @@ -754,6 +754,10 @@ void GameModel::SetDecoration(bool decorationState) ren->decorations_enable = decorationState?1:0; notifyDecorationChanged(); UpdateQuickOptions(); + if (decorationState) + SetInfoTip("Decorations Layer: On"); + else + SetInfoTip("Decorations Layer: Off"); } bool GameModel::GetDecoration() @@ -761,6 +765,21 @@ bool GameModel::GetDecoration() return ren->decorations_enable?true:false; } +void GameModel::SetAHeatEnable(bool aHeat) +{ + sim->aheat_enable = aHeat; + UpdateQuickOptions(); + if (aHeat) + SetInfoTip("Ambient Heat: On"); + else + SetInfoTip("Ambient Heat: Off"); +} + +bool GameModel::GetAHeatEnable() +{ + return sim->aheat_enable; +} + void GameModel::FrameStep(int frames) { sim->framerender += frames; diff --git a/src/game/GameModel.h b/src/game/GameModel.h index 61d0c93..311f89c 100644 --- a/src/game/GameModel.h +++ b/src/game/GameModel.h @@ -8,6 +8,7 @@ #include "interface/Colour.h" #include "graphics/Renderer.h" #include "GameView.h" +#include "GameController.h" #include "Brush.h" #include "client/User.h" #include "Notification.h" @@ -18,6 +19,7 @@ using namespace std; class GameView; +class GameController; class Simulation; class Renderer; @@ -126,7 +128,7 @@ public: std::string GetInfoTip(); void BuildMenus(); - void BuildQuickOptionMenu(); + void BuildQuickOptionMenu(GameController * controller); std::deque<Snapshot*> GetHistory(); void SetHistory(std::deque<Snapshot*> newHistory); @@ -156,6 +158,8 @@ public: void SetPaused(bool pauseState); bool GetDecoration(); void SetDecoration(bool decorationState); + bool GetAHeatEnable(); + void SetAHeatEnable(bool aHeat); void ClearSimulation(); vector<Menu*> GetMenuList(); vector<Tool*> GetUnlistedTools(); diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp index 74a2b5a..7ba1fe7 100644 --- a/src/game/GameView.cpp +++ b/src/game/GameView.cpp @@ -1629,10 +1629,7 @@ void GameView::enableShiftBehaviour() shiftBehaviour = true; if(isMouseDown) { - if(!ctrlBehaviour) - c->SetToolStrength(10.0f); - else - c->SetToolStrength(1.0f); + c->SetToolStrength(10.0f); } } } @@ -1681,7 +1678,7 @@ void GameView::enableCtrlBehaviour() if(!shiftBehaviour) c->SetToolStrength(.1f); else - c->SetToolStrength(1.0f); + c->SetToolStrength(10.0f); } } } @@ -1885,11 +1882,22 @@ void GameView::OnDraw() { if(showDebug) { - sampleInfo << c->ElementResolve(sample.particle.type); - if(sample.particle.ctype > 0 && sample.particle.ctype < PT_NUM) - sampleInfo << " (" << c->ElementResolve(sample.particle.ctype) << ")"; + int ctype = sample.particle.ctype; + if (sample.particle.type == PT_PIPE || sample.particle.type == PT_PPIP) + ctype = sample.particle.tmp; + + if (sample.particle.type == PT_LAVA && ctype > 0 && ctype < PT_NUM) + sampleInfo << "Molten " << c->ElementResolve(ctype); + else if((sample.particle.type == PT_PIPE || sample.particle.type == PT_PPIP) && ctype > 0 && ctype < PT_NUM) + sampleInfo << c->ElementResolve(sample.particle.type) << " with " << c->ElementResolve(ctype); else - sampleInfo << " ()"; + { + sampleInfo << c->ElementResolve(sample.particle.type); + if(ctype > 0 && ctype < PT_NUM) + sampleInfo << " (" << c->ElementResolve(ctype) << ")"; + else + sampleInfo << " ()"; + } sampleInfo << ", Temp: " << std::fixed << sample.particle.temp -273.15f; sampleInfo << ", Life: " << sample.particle.life; sampleInfo << ", Tmp: " << sample.particle.tmp; @@ -1897,8 +1905,10 @@ void GameView::OnDraw() } else { - if(sample.particle.type == PT_LAVA && sample.particle.ctype > 0 && sample.particle.ctype < PT_NUM) + if (sample.particle.type == PT_LAVA && sample.particle.ctype > 0 && sample.particle.ctype < PT_NUM) sampleInfo << "Molten " << c->ElementResolve(sample.particle.ctype); + else if((sample.particle.type == PT_PIPE || sample.particle.type == PT_PPIP) && sample.particle.tmp > 0 && sample.particle.tmp < PT_NUM) + sampleInfo << c->ElementResolve(sample.particle.type) << " with " << c->ElementResolve(sample.particle.tmp); else sampleInfo << c->ElementResolve(sample.particle.type); sampleInfo << ", Temp: " << std::fixed << sample.particle.temp -273.15f; @@ -1987,6 +1997,11 @@ void GameView::OnDraw() #endif fpsInfo << "FPS: " << std::fixed << ui::Engine::Ref().GetFps(); + if (showDebug) + fpsInfo << " Parts: " << sample.NumParts; + if (ren->GetGridSize()) + fpsInfo << " [GRID: " << ren->GetGridSize() << "]"; + textWidth = Graphics::textwidth((char*)fpsInfo.str().c_str()); g->fillrect(12, 12, textWidth+8, 15, 0, 0, 0, 255*0.5); g->drawtext(16, 16, (const char*)fpsInfo.str().c_str(), 32, 216, 255, 255*0.75); diff --git a/src/game/GameView.h b/src/game/GameView.h index 7c77dc0..f36aef3 100644 --- a/src/game/GameView.h +++ b/src/game/GameView.h @@ -62,7 +62,7 @@ private: std::string infoTip; int toolTipPresence; -queue<ui::Point> pointQueue; + queue<ui::Point> pointQueue; GameController * c; Renderer * ren; Brush * activeBrush; @@ -168,7 +168,7 @@ public: virtual void OnDraw(); virtual void OnBlur(); - //Top-level handers, for Lua interface + //Top-level handlers, 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); diff --git a/src/game/QuickOptions.h b/src/game/QuickOptions.h index 61a6de8..5455051 100644 --- a/src/game/QuickOptions.h +++ b/src/game/QuickOptions.h @@ -47,11 +47,11 @@ public: } virtual bool GetToggle() { - return m->GetRenderer()->decorations_enable; + return m->GetDecoration(); } virtual void perform() { - m->GetRenderer()->decorations_enable = !m->GetRenderer()->decorations_enable; + m->SetDecoration(!m->GetDecoration()); } }; @@ -72,10 +72,12 @@ public: if(m->GetSimulation()->grav->ngrav_enable) { m->GetSimulation()->grav->stop_grav_async(); + m->SetInfoTip("Newtonian Gravity: Off"); } else { m->GetSimulation()->grav->start_grav_async(); + m->SetInfoTip("Newtonian Gravity: On"); } } }; @@ -90,10 +92,29 @@ public: } virtual bool GetToggle() { - return m->GetSimulation()->aheat_enable; + return m->GetAHeatEnable(); } virtual void perform() { - m->GetSimulation()->aheat_enable = !m->GetSimulation()->aheat_enable; + m->SetAHeatEnable(!m->GetAHeatEnable()); + } +}; + +class ConsoleShowOption: public QuickOption +{ + GameController * c; +public: + ConsoleShowOption(GameModel * m, GameController * c_): + QuickOption("C", "Show Console", m, Toggle) + { + c = c_; + } + virtual bool GetToggle() + { + return 0; + } + virtual void perform() + { + c->ShowConsole(); } }; diff --git a/src/game/SignTool.cpp b/src/game/SignTool.cpp index 4a5fc69..eb1ef57 100644 --- a/src/game/SignTool.cpp +++ b/src/game/SignTool.cpp @@ -199,7 +199,7 @@ void SignWindow::DoDraw() sprintf(buff, "Temp: 0.00"); //...temperature g->drawtext(x+3, y+3, buff, 255, 255, 255, 255); } - else if (sregexp(currentSign.text.c_str(), "^{c:[0-9]*|.*}$")==0) + else if (sregexp(currentSign.text.c_str(), "^{[c|t]:[0-9]*|.*}$")==0) { int sldr, startm; memset(buff, 0, sizeof(buff)); |
