diff --git a/src/game/GameModel.cpp b/src/game/GameModel.cpp index c56c195d4..91d6a4f22 100644 --- a/src/game/GameModel.cpp +++ b/src/game/GameModel.cpp @@ -171,6 +171,10 @@ void GameModel::BuildMenus() { tempTool = new Element_LIGH_Tool(i, sim->elements[i].Name, sim->elements[i].Description, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour), sim->elements[i].IconGenerator); } + else if(i == PT_TESC) + { + tempTool = new Element_TESC_Tool(i, sim->elements[i].Name, sim->elements[i].Description, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour), sim->elements[i].IconGenerator); + } else if(i == PT_STKM || i == PT_FIGH || i == PT_STKM2) { tempTool = new PlopTool(i, sim->elements[i].Name, sim->elements[i].Description, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour), sim->elements[i].IconGenerator); diff --git a/src/game/Tool.cpp b/src/game/Tool.cpp index 3a9fc1e3d..10b7b0d0b 100644 --- a/src/game/Tool.cpp +++ b/src/game/Tool.cpp @@ -176,6 +176,27 @@ void Element_LIGH_Tool::Draw(Simulation * sim, Brush * brush, ui::Point position } } +Element_TESC_Tool::Element_TESC_Tool(int id, string name, string description, int r, int g, int b, VideoBuffer * (*textureGen)(int, int, int)): + ElementTool(id, name, description, r, g, b, textureGen) + { + } +void Element_TESC_Tool::Draw(Simulation * sim, Brush * brush, ui::Point position){ + int radiusInfo = brush->GetRadius().X*4+brush->GetRadius().Y*4+7; + sim->CreateParts(position.X, position.Y, toolID | (radiusInfo << 8), brush); +} +void Element_TESC_Tool::DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2, bool dragging) { + int radiusInfo = brush->GetRadius().X*4+brush->GetRadius().Y*4+7; + sim->CreateLine(position1.X, position1.Y, position2.X, position2.Y, toolID | (radiusInfo << 8), brush); +} +void Element_TESC_Tool::DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) { + int radiusInfo = brush->GetRadius().X*4+brush->GetRadius().Y*4+7; + sim->CreateBox(position1.X, position1.Y, position2.X, position2.Y, toolID | (radiusInfo << 8), 0); +} +void Element_TESC_Tool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) { + int radiusInfo = brush->GetRadius().X*4+brush->GetRadius().Y*4+7; + sim->FloodParts(position.X, position.Y, toolID | (radiusInfo << 8), -1, -1, 0); +} + void PlopTool::Click(Simulation * sim, Brush * brush, ui::Point position) { sim->create_part(-1, position.X, position.Y, toolID); diff --git a/src/game/Tool.h b/src/game/Tool.h index aa021fc01..bee1fd849 100644 --- a/src/game/Tool.h +++ b/src/game/Tool.h @@ -86,6 +86,7 @@ public: virtual void DrawFill(Simulation * sim, Brush * brush, ui::Point position) { } }; + class ElementTool: public Tool { public: @@ -97,6 +98,17 @@ public: virtual void DrawFill(Simulation * sim, Brush * brush, ui::Point position); }; +class Element_TESC_Tool: public ElementTool +{ +public: + Element_TESC_Tool(int id, string name, string description, int r, int g, int b, VideoBuffer * (*textureGen)(int, int, int) = NULL); + virtual ~Element_TESC_Tool() {} + virtual void Draw(Simulation * sim, Brush * brush, ui::Point position); + virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2, bool dragging = false); + virtual void DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2); + virtual void DrawFill(Simulation * sim, Brush * brush, ui::Point position); +}; + class PlopTool: public ElementTool { public: diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 6b781841b..4fb9ac290 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -2443,12 +2443,14 @@ void Simulation::part_change_type(int i, int x, int y, int t)//changes the type } } -int Simulation::create_part(int p, int x, int y, int tv)//the function for creating a particle, use p=-1 for creating a new particle, -2 is from a brush, or a particle number to replace a particle. +//the function for creating a particle, use p=-1 for creating a new particle, -2 is from a brush, or a particle number to replace a particle. +//tv = Type (8 bits) + Var (24 bits), var is usually 0 +int Simulation::create_part(int p, int x, int y, int tv) { int i; int t = tv & 0xFF; - int v = (tv >> 8) & 0xFF; + int v = (tv >> 8) & 0xFFFFFF; if (x<0 || y<0 || x>=XRES || y>=YRES || ((t<=0 || t>=PT_NUM)&&t!=SPC_HEAT&&t!=SPC_COOL&&t!=SPC_AIR&&t!=SPC_VACUUM&&t!=SPC_PGRV&&t!=SPC_NGRV)) return -1; @@ -2749,6 +2751,11 @@ int Simulation::create_part(int p, int x, int y, int tv)//the function for creat case PT_EMBR: parts[i].life = 50; break; + case PT_TESC: + parts[i].tmp = v; + if (parts[i].tmp > 300) + parts[i].tmp=300; + break; case PT_STKM: if (player.spwn==0) {