HUD displays the correct name of LIFE particles in the HUD, show mouse position in HUD on the edges of the screen
This commit is contained in:
parent
fcff2ecc7f
commit
3aac957e50
@ -1381,10 +1381,10 @@ void Renderer::render_parts()
|
||||
else
|
||||
continue;
|
||||
|
||||
if (mousePosX>(nx-3) && mousePosX<(nx+3) && mousePosY<(ny+3) && mousePosY>(ny-3)) //If mouse is in the head
|
||||
if (mousePos.X>(nx-3) && mousePos.X<(nx+3) && mousePos.Y<(ny+3) && mousePos.Y>(ny-3)) //If mouse is in the head
|
||||
{
|
||||
sprintf(buff, "%3d", sim->parts[i].life); //Show HP
|
||||
drawtext(mousePosX-8-2*(sim->parts[i].life<100)-2*(sim->parts[i].life<10), mousePosY-12, buff, 255, 255, 255, 255);
|
||||
drawtext(mousePos.X-8-2*(sim->parts[i].life<100)-2*(sim->parts[i].life<10), mousePos.Y-12, buff, 255, 255, 255, 255);
|
||||
}
|
||||
|
||||
if (colour_mode!=COLOUR_HEAT)
|
||||
@ -1890,7 +1890,7 @@ void Renderer::render_parts()
|
||||
}
|
||||
if (pixel_mode & EFFECT_DBGLINES)
|
||||
{
|
||||
if (mousePosX == nx && mousePosY == ny && debugLines)//draw lines connecting wifi/portal channels
|
||||
if (mousePos.X == nx && mousePos.Y == ny && debugLines)//draw lines connecting wifi/portal channels
|
||||
{
|
||||
int z;
|
||||
int type = parts[i].type;
|
||||
@ -2407,8 +2407,7 @@ Renderer::Renderer(Graphics * g, Simulation * sim):
|
||||
decorations_enable(1),
|
||||
gravityFieldEnabled(false),
|
||||
gravityZonesEnabled(false),
|
||||
mousePosX(-1),
|
||||
mousePosY(-1),
|
||||
mousePos(0, 0),
|
||||
display_mode(0),
|
||||
render_mode(0),
|
||||
colour_mode(0),
|
||||
|
@ -66,7 +66,7 @@ public:
|
||||
pixel sampleColor;
|
||||
|
||||
//Mouse position for debug information
|
||||
int mousePosX, mousePosY;
|
||||
ui::Point mousePos;
|
||||
|
||||
//Zoom window
|
||||
ui::Point zoomWindowPosition;
|
||||
|
@ -834,12 +834,11 @@ void GameController::LoadRenderPreset(int presetNum)
|
||||
void GameController::Update()
|
||||
{
|
||||
ui::Point pos = gameView->GetMousePosition();
|
||||
if(pos.X >= 0 && pos.Y >= 0 && pos.X < XRES && pos.Y < YRES)
|
||||
{
|
||||
gameModel->GetRenderer()->mousePosX = pos.X;
|
||||
gameModel->GetRenderer()->mousePosY = pos.Y;
|
||||
gameView->SetSample(gameModel->GetSimulation()->Get(pos.X, pos.Y));
|
||||
}
|
||||
gameModel->GetRenderer()->mousePos = PointTranslate(pos);
|
||||
if (pos.X < XRES && pos.Y < YRES)
|
||||
gameView->SetSample(gameModel->GetSimulation()->GetSample(PointTranslate(pos).X, PointTranslate(pos).Y));
|
||||
else
|
||||
gameView->SetSample(gameModel->GetSimulation()->GetSample(pos.X, pos.Y));
|
||||
|
||||
gameModel->GetSimulation()->update_particles();
|
||||
if(renderOptions && renderOptions->HasExited)
|
||||
@ -1353,10 +1352,15 @@ void GameController::ReloadSim()
|
||||
}
|
||||
}
|
||||
|
||||
std::string GameController::ElementResolve(int type)
|
||||
std::string GameController::ElementResolve(int type, int ctype)
|
||||
{
|
||||
if(gameModel && gameModel->GetSimulation() && gameModel->GetSimulation()->elements && type >= 0 && type < PT_NUM)
|
||||
return std::string(gameModel->GetSimulation()->elements[type].Name);
|
||||
if(gameModel && gameModel->GetSimulation())
|
||||
{
|
||||
if (type == PT_LIFE && ctype >= 0 && ctype < NGOL && gameModel->GetSimulation()->gmenu)
|
||||
return gameModel->GetSimulation()->gmenu[ctype].name;
|
||||
else if (type >= 0 && type < PT_NUM && gameModel->GetSimulation()->elements)
|
||||
return std::string(gameModel->GetSimulation()->elements[type].Name);
|
||||
}
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ public:
|
||||
void TransformSave(matrix2d transform);
|
||||
ui::Point PointTranslate(ui::Point point);
|
||||
ui::Point NormaliseBlockCoord(ui::Point point);
|
||||
std::string ElementResolve(int type);
|
||||
std::string ElementResolve(int type, int ctype);
|
||||
std::string WallName(int type);
|
||||
|
||||
void ResetAir();
|
||||
|
@ -606,7 +606,7 @@ bool GameView::GetDebugHUD()
|
||||
|
||||
ui::Point GameView::GetMousePosition()
|
||||
{
|
||||
return mousePosition;
|
||||
return currentMouse;
|
||||
}
|
||||
|
||||
void GameView::NotifyActiveToolsChanged(GameModel * sender)
|
||||
@ -2025,21 +2025,22 @@ void GameView::OnDraw()
|
||||
sampleInfo.precision(2);
|
||||
if(sample.particle.type)
|
||||
{
|
||||
int ctype = sample.particle.ctype;
|
||||
if (sample.particle.type == PT_PIPE || sample.particle.type == PT_PPIP)
|
||||
ctype = sample.particle.tmp&0xFF;
|
||||
if(showDebug)
|
||||
{
|
||||
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);
|
||||
sampleInfo << "Molten " << c->ElementResolve(ctype, -1);
|
||||
else if ((sample.particle.type == PT_PIPE || sample.particle.type == PT_PPIP) && ctype > 0 && ctype < PT_NUM)
|
||||
sampleInfo << c->ElementResolve(sample.particle.type, -1) << " with " << c->ElementResolve(ctype, (int)sample.particle.pavg[1]);
|
||||
else if (sample.particle.type == PT_LIFE)
|
||||
sampleInfo << c->ElementResolve(sample.particle.type, sample.particle.ctype);
|
||||
else
|
||||
{
|
||||
sampleInfo << c->ElementResolve(sample.particle.type);
|
||||
sampleInfo << c->ElementResolve(sample.particle.type, sample.particle.ctype);
|
||||
if(ctype > 0 && ctype < PT_NUM)
|
||||
sampleInfo << " (" << c->ElementResolve(ctype) << ")";
|
||||
sampleInfo << " (" << c->ElementResolve(ctype, -1) << ")";
|
||||
else
|
||||
sampleInfo << " ()";
|
||||
}
|
||||
@ -2051,11 +2052,13 @@ void GameView::OnDraw()
|
||||
else
|
||||
{
|
||||
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);
|
||||
sampleInfo << "Molten " << c->ElementResolve(sample.particle.ctype, -1);
|
||||
else if ((sample.particle.type == PT_PIPE || sample.particle.type == PT_PPIP) && ctype > 0 && ctype < PT_NUM)
|
||||
sampleInfo << c->ElementResolve(sample.particle.type, -1) << " with " << c->ElementResolve(ctype, (int)sample.particle.pavg[1]);
|
||||
else if (sample.particle.type == PT_LIFE)
|
||||
sampleInfo << c->ElementResolve(sample.particle.type, sample.particle.ctype);
|
||||
else
|
||||
sampleInfo << c->ElementResolve(sample.particle.type);
|
||||
sampleInfo << c->ElementResolve(sample.particle.type, sample.particle.ctype);
|
||||
sampleInfo << ", Temp: " << std::fixed << sample.particle.temp -273.15f;
|
||||
sampleInfo << ", Pressure: " << std::fixed << sample.AirPressure;
|
||||
}
|
||||
@ -2067,10 +2070,14 @@ void GameView::OnDraw()
|
||||
sampleInfo << c->WallName(sample.WallType);
|
||||
sampleInfo << ", Pressure: " << std::fixed << sample.AirPressure;
|
||||
}
|
||||
else
|
||||
else if (sample.isMouseInSim)
|
||||
{
|
||||
sampleInfo << "Empty, Pressure: " << std::fixed << sample.AirPressure;
|
||||
}
|
||||
else
|
||||
{
|
||||
sampleInfo << "Empty";
|
||||
}
|
||||
|
||||
int textWidth = Graphics::textwidth((char*)sampleInfo.str().c_str());
|
||||
g->fillrect(XRES-20-textWidth, 12, textWidth+8, 15, 0, 0, 0, 255*0.5);
|
||||
|
@ -22,8 +22,9 @@ public:
|
||||
float GravityVelocityY;
|
||||
|
||||
int NumParts;
|
||||
bool isMouseInSim;
|
||||
|
||||
SimulationSample() : PositionX(0), PositionY(0), ParticleID(0), particle(), AirPressure(0), AirVelocityX(0), AirVelocityY(0), WallType(0), Gravity(0), GravityVelocityX(0), GravityVelocityY(0), AirTemperature(0), NumParts(0) {}
|
||||
SimulationSample() : PositionX(0), PositionY(0), ParticleID(0), particle(), AirPressure(0), AirVelocityX(0), AirVelocityY(0), WallType(0), Gravity(0), GravityVelocityX(0), GravityVelocityY(0), AirTemperature(0), NumParts(0), isMouseInSim(true) {}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -478,36 +478,41 @@ int Simulation::flood_prop(int x, int y, size_t propoffset, void * propvalue, St
|
||||
return 0;
|
||||
}
|
||||
|
||||
SimulationSample Simulation::Get(int x, int y)
|
||||
SimulationSample Simulation::GetSample(int x, int y)
|
||||
{
|
||||
SimulationSample sample;
|
||||
sample.PositionX = x;
|
||||
sample.PositionY = y;
|
||||
if (photons[y][x])
|
||||
if (x >= 0 && x < XRES && y >= 0 && y < YRES)
|
||||
{
|
||||
sample.particle = parts[photons[y][x]>>8];
|
||||
sample.ParticleID = photons[y][x]>>8;
|
||||
}
|
||||
else if (pmap[y][x])
|
||||
{
|
||||
sample.particle = parts[pmap[y][x]>>8];
|
||||
sample.ParticleID = pmap[y][x]>>8;
|
||||
}
|
||||
if (bmap[y/CELL][x/CELL])
|
||||
{
|
||||
sample.WallType = bmap[y/CELL][x/CELL];
|
||||
}
|
||||
sample.AirPressure = pv[y/CELL][x/CELL];
|
||||
sample.AirTemperature = hv[y/CELL][x/CELL];
|
||||
sample.AirVelocityX = vx[y/CELL][x/CELL];
|
||||
sample.AirVelocityY = vy[y/CELL][x/CELL];
|
||||
if (photons[y][x])
|
||||
{
|
||||
sample.particle = parts[photons[y][x]>>8];
|
||||
sample.ParticleID = photons[y][x]>>8;
|
||||
}
|
||||
else if (pmap[y][x])
|
||||
{
|
||||
sample.particle = parts[pmap[y][x]>>8];
|
||||
sample.ParticleID = pmap[y][x]>>8;
|
||||
}
|
||||
if (bmap[y/CELL][x/CELL])
|
||||
{
|
||||
sample.WallType = bmap[y/CELL][x/CELL];
|
||||
}
|
||||
sample.AirPressure = pv[y/CELL][x/CELL];
|
||||
sample.AirTemperature = hv[y/CELL][x/CELL];
|
||||
sample.AirVelocityX = vx[y/CELL][x/CELL];
|
||||
sample.AirVelocityY = vy[y/CELL][x/CELL];
|
||||
|
||||
if(grav->ngrav_enable)
|
||||
{
|
||||
sample.Gravity = gravp[(y/CELL)*(XRES/CELL)+(x/CELL)];
|
||||
sample.GravityVelocityX = gravx[(y/CELL)*(XRES/CELL)+(x/CELL)];
|
||||
sample.GravityVelocityY = gravy[(y/CELL)*(XRES/CELL)+(x/CELL)];
|
||||
if(grav->ngrav_enable)
|
||||
{
|
||||
sample.Gravity = gravp[(y/CELL)*(XRES/CELL)+(x/CELL)];
|
||||
sample.GravityVelocityX = gravx[(y/CELL)*(XRES/CELL)+(x/CELL)];
|
||||
sample.GravityVelocityY = gravy[(y/CELL)*(XRES/CELL)+(x/CELL)];
|
||||
}
|
||||
}
|
||||
else
|
||||
sample.isMouseInSim = false;
|
||||
|
||||
sample.NumParts = NUM_PARTS;
|
||||
return sample;
|
||||
|
@ -120,7 +120,7 @@ public:
|
||||
int Load(int x, int y, GameSave * save);
|
||||
GameSave * Save();
|
||||
GameSave * Save(int x1, int y1, int x2, int y2);
|
||||
SimulationSample Get(int x, int y);
|
||||
SimulationSample GetSample(int x, int y);
|
||||
|
||||
Snapshot * CreateSnapshot();
|
||||
void Restore(const Snapshot & snap);
|
||||
|
Loading…
Reference in New Issue
Block a user