diff options
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/DecorationTool.h | 6 | ||||
| -rw-r--r-- | src/game/GameModel.cpp | 18 | ||||
| -rw-r--r-- | src/game/GameView.cpp | 30 | ||||
| -rw-r--r-- | src/game/GameView.h | 4 |
4 files changed, 46 insertions, 12 deletions
diff --git a/src/game/DecorationTool.h b/src/game/DecorationTool.h index be79e6b..e2e4758 100644 --- a/src/game/DecorationTool.h +++ b/src/game/DecorationTool.h @@ -7,7 +7,7 @@ class DecorationTool: public Tool { public: - enum ToolType { BlendAdd = DECO_ADD, BlendRemove = DECO_SUBTRACT, BlendMultiply = DECO_MULTIPLY, BlendDivide = DECO_DIVIDE, BlendSet = DECO_DRAW, BlendSmudge = DECO_SMUDGE }; + enum ToolType { BlendAdd = DECO_ADD, BlendRemove = DECO_SUBTRACT, BlendMultiply = DECO_MULTIPLY, BlendDivide = DECO_DIVIDE, BlendSet = DECO_DRAW, BlendSmudge = DECO_SMUDGE, Remove = DECO_CLEAR }; ToolType decoMode; @@ -27,10 +27,10 @@ public: } virtual ~DecorationTool() {} virtual void Draw(Simulation * sim, Brush * brush, ui::Point position){ - sim->ApplyDecorationPoint(position.X, position.Y, 1, 1, Red, Green, Blue, Alpha, decoMode, brush); + sim->ApplyDecorationPoint(position.X, position.Y, Red, Green, Blue, Alpha, decoMode, brush); } virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) { - sim->ApplyDecorationLine(position1.X, position1.Y, position2.X, position2.Y, 1, 1, Red, Green, Blue, Alpha, decoMode, brush); + sim->ApplyDecorationLine(position1.X, position1.Y, position2.X, position2.Y, Red, Green, Blue, Alpha, decoMode, brush); } virtual void DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) { sim->ApplyDecorationBox(position1.X, position1.Y, position2.X, position2.Y, Red, Green, Blue, Alpha, decoMode); diff --git a/src/game/GameModel.cpp b/src/game/GameModel.cpp index 29d13ce..f3ce1bc 100644 --- a/src/game/GameModel.cpp +++ b/src/game/GameModel.cpp @@ -20,7 +20,8 @@ GameModel::GameModel(): colourSelector(false), clipboard(NULL), stamp(NULL), - placeSave(NULL) + placeSave(NULL), + colour(255, 0, 0, 255) { sim = new Simulation(); ren = new Renderer(ui::Engine::Ref().g, sim); @@ -108,6 +109,7 @@ GameModel::GameModel(): menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendDivide, "DIV", "Colour blending: Divide" , 0, 0, 0)); menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendSmudge, "SMDG", "Smudge colour", 0, 0, 0)); menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendSet, "SET", "Set colour (No blending)", 0, 0, 0)); + menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::Remove, "CLR", "Clear any set decoration", 0, 0, 0)); //Set default brush palette brushList.push_back(new EllipseBrush(ui::Point(4, 4))); @@ -135,6 +137,15 @@ GameModel::GameModel(): if(stampFile && stampFile->GetGameSave()) stamp = stampFile->GetGameSave(); } + + + //Set default decoration colour + unsigned char colourR = min(Client::Ref().GetPrefInteger("Decoration.Red", 200), 255); + unsigned char colourG = min(Client::Ref().GetPrefInteger("Decoration.Green", 100), 255); + unsigned char colourB = min(Client::Ref().GetPrefInteger("Decoration.Blue", 50), 255); + unsigned char colourA = min(Client::Ref().GetPrefInteger("Decoration.Alpha", 255), 255); + + SetColourSelectorColour(ui::Colour(colourR, colourG, colourB, colourA)); } GameModel::~GameModel() @@ -148,6 +159,11 @@ GameModel::~GameModel() std::vector<unsigned int> renderModes = ren->GetRenderMode(); Client::Ref().SetPref("Renderer.RenderModes", std::vector<double>(renderModes.begin(), renderModes.end())); + Client::Ref().SetPref("Decoration.Red", (int)colour.Red); + Client::Ref().SetPref("Decoration.Green", (int)colour.Green); + Client::Ref().SetPref("Decoration.Blue", (int)colour.Blue); + Client::Ref().SetPref("Decoration.Alpha", (int)colour.Alpha); + for(int i = 0; i < menuList.size(); i++) { delete menuList[i]; diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp index ac718c3..6b50d31 100644 --- a/src/game/GameView.cpp +++ b/src/game/GameView.cpp @@ -375,7 +375,7 @@ void GameView::NotifyMenuListChanged(GameModel * sender) } } -void GameView::SetSample(Particle sample) +void GameView::SetSample(SimulationSample sample) { this->sample = sample; } @@ -1251,18 +1251,36 @@ void GameView::OnDraw() } } + //Draw info about simulation under cursor std::stringstream sampleInfo; sampleInfo.precision(2); - if(sample.type) - sampleInfo << c->ElementResolve(sample.type) << ", Temp: " << std::fixed << sample.temp -273.15f; + if(sample.particle.type) + sampleInfo << c->ElementResolve(sample.particle.type) << ", Temp: " << std::fixed << sample.particle.temp -273.15f; else sampleInfo << "Empty"; - if(sample.ctype && sample.ctype>0 && sample.ctype<PT_NUM) - sampleInfo << ", Ctype: " << c->ElementResolve(sample.ctype); + sampleInfo << ", Pressure: " << std::fixed << sample.AirPressure; - g->drawtext(XRES+BARSIZE-(10+Graphics::textwidth((char*)sampleInfo.str().c_str())), 10, (const char*)sampleInfo.str().c_str(), 255, 255, 255, 255); + int textWidth = Graphics::textwidth((char*)sampleInfo.str().c_str()); + g->fillrect(XRES-20-textWidth, 12, textWidth+8, 15, 0, 0, 0, 255*0.5); + g->drawtext(XRES-16-textWidth, 16, (const char*)sampleInfo.str().c_str(), 255, 255, 255, 255*0.75); + + //FPS and some version info +#ifndef DEBUG //In debug mode, the Engine will draw FPS and other info instead + std::stringstream fpsInfo; + fpsInfo.precision(2); +#ifdef SNAPSHOT + fpsInfo << "Snapshot " << SNAPSHOT_ID << ". "; +#endif + fpsInfo << "FPS: " << std::fixed << ui::Engine::Ref().GetFps(); +#endif + + 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); + + //Tooltips if(infoTipPresence) { int infoTipAlpha = (infoTipPresence>50?50:infoTipPresence)*5; diff --git a/src/game/GameView.h b/src/game/GameView.h index 4a841c1..ad9e095 100644 --- a/src/game/GameView.h +++ b/src/game/GameView.h @@ -87,7 +87,7 @@ private: Thumbnail * placeSaveThumb; - Particle sample; + SimulationSample sample; int lastOffset; void setToolButtonOffset(int offset); @@ -99,7 +99,7 @@ public: //Breaks MVC, but any other way is going to be more of a mess. ui::Point GetMousePosition(); - void SetSample(Particle sample); + void SetSample(SimulationSample sample); void AttachController(GameController * _c){ c = _c; } void NotifyRendererChanged(GameModel * sender); |
