Add shortcuts for things like gravity, air and air reset, issues #85 and #57

This commit is contained in:
Simon Robertshaw
2012-08-03 19:25:28 +01:00
parent 0e5c3da0f5
commit f586a5585f
3 changed files with 91 additions and 0 deletions

View File

@@ -406,6 +406,76 @@ void GameController::Exit()
HasDone = true;
}
void GameController::ResetAir()
{
gameModel->GetSimulation()->air->Clear();
}
void GameController::ResetSpark()
{
Simulation * sim = gameModel->GetSimulation();
for (int i = 0; i < NPART; i++)
if (sim->parts[i].type == PT_SPRK)
{
if (sim->parts[i].ctype >= 0 && sim->parts[i].ctype < PT_NUM && sim->elements[sim->parts[i].ctype].Enabled)
{
sim->parts[i].type = sim->parts[i].ctype;
sim->parts[i].life = 0;
}
else
sim->kill_part(i);
}
}
void GameController::SwitchGravity()
{
gameModel->GetSimulation()->gravityMode = (gameModel->GetSimulation()->gravityMode+1)%3;
switch (gameModel->GetSimulation()->gravityMode)
{
case 0:
gameModel->SetInfoTip("Gravity: Vertical");
break;
case 1:
gameModel->SetInfoTip("Gravity: Off");
break;
case 2:
gameModel->SetInfoTip("Gravity: Radial");
break;
}
}
void GameController::SwitchAir()
{
gameModel->GetSimulation()->air->airMode = (gameModel->GetSimulation()->air->airMode+1)%5;
switch (gameModel->GetSimulation()->air->airMode)
{
case 0:
gameModel->SetInfoTip("Air: On");
break;
case 1:
gameModel->SetInfoTip("Air: Pressure Off");
break;
case 2:
gameModel->SetInfoTip("Air: Velocity Off");
break;
case 3:
gameModel->SetInfoTip("Air: Off");
break;
case 4:
gameModel->SetInfoTip("Air: No Update");
break;
}
}
void GameController::ToggleAHeat()
{
gameModel->GetSimulation()->aheat_enable = !gameModel->GetSimulation()->aheat_enable;
gameModel->UpdateQuickOptions();
}
void GameController::LoadRenderPreset(RenderPreset preset)
{
Renderer * renderer = gameModel->GetRenderer();

View File

@@ -109,6 +109,12 @@ public:
ui::Point NormaliseBlockCoord(ui::Point point);
std::string ElementResolve(int type);
void ResetAir();
void ResetSpark();
void SwitchGravity();
void SwitchAir();
void ToggleAHeat();
void LoadClipboard();
void LoadStamp();

View File

@@ -1017,6 +1017,21 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
selectMode = SelectStamp;
selectPoint1 = ui::Point(-1, -1);
break;
case 'w':
c->SwitchGravity();
break;
case 'y':
c->SwitchAir();
break;
case 'u':
c->ToggleAHeat();
break;
case '=':
if(ctrl)
c->ResetSpark();
else
c->ResetAir();
break;
case 'c':
if(ctrl)
{