Draw gravity zones when using grav wall

This commit is contained in:
Simon Robertshaw 2012-08-05 15:26:17 +01:00
parent 351ce1525f
commit ed270d8dbf
6 changed files with 40 additions and 7 deletions

View File

@ -653,6 +653,14 @@ void GameController::SetActiveMenu(Menu * menu)
void GameController::SetActiveTool(int toolSelection, Tool * tool) void GameController::SetActiveTool(int toolSelection, Tool * tool)
{ {
gameModel->SetActiveTool(toolSelection, tool); gameModel->SetActiveTool(toolSelection, tool);
gameModel->GetRenderer()->gravityZonesEnabled = false;
for(int i = 0; i < 3; i++)
{
if(gameModel->GetActiveTool(i) == gameModel->GetMenuList().at(SC_WALL)->GetToolList().at(WL_GRAV))
{
gameModel->GetRenderer()->gravityZonesEnabled = true;
}
}
} }
void GameController::OpenSearch() void GameController::OpenSearch()

View File

@ -138,6 +138,7 @@ void GameModel::BuildQuickOptionMenu()
quickOptions.push_back(new DecorationsOption(this)); quickOptions.push_back(new DecorationsOption(this));
quickOptions.push_back(new NGravityOption(this)); quickOptions.push_back(new NGravityOption(this));
quickOptions.push_back(new AHeatOption(this)); quickOptions.push_back(new AHeatOption(this));
quickOptions.push_back(new DrawGravWallOption(this));
notifyQuickOptionsChanged(); notifyQuickOptionsChanged();
UpdateQuickOptions(); UpdateQuickOptions();

View File

@ -29,11 +29,11 @@ public:
} }
virtual bool GetToggle() virtual bool GetToggle()
{ {
return m->GetRenderer()->gravifyFieldEnabled; return m->GetRenderer()->gravityFieldEnabled;
} }
virtual void perform() virtual void perform()
{ {
m->GetRenderer()->gravifyFieldEnabled = !m->GetRenderer()->gravifyFieldEnabled; m->GetRenderer()->gravityFieldEnabled = !m->GetRenderer()->gravityFieldEnabled;
} }
}; };
@ -97,3 +97,21 @@ public:
m->GetSimulation()->aheat_enable = !m->GetSimulation()->aheat_enable; m->GetSimulation()->aheat_enable = !m->GetSimulation()->aheat_enable;
} }
}; };
class DrawGravWallOption: public QuickOption
{
public:
DrawGravWallOption(GameModel * m):
QuickOption("Z", "Draw gravity zones", m, Toggle)
{
}
virtual bool GetToggle()
{
return m->GetRenderer()->gravityZonesEnabled;
}
virtual void perform()
{
m->GetRenderer()->gravityZonesEnabled = !m->GetRenderer()->gravityZonesEnabled;
}
};

View File

@ -43,6 +43,7 @@ void Renderer::RenderBegin()
render_parts(); render_parts();
render_fire(); render_fire();
DrawWalls(); DrawWalls();
draw_grav_zones();
DrawSigns(); DrawSigns();
#ifndef OGLR #ifndef OGLR
FinaliseParts(); FinaliseParts();
@ -1901,7 +1902,7 @@ void Renderer::draw_grav()
int x, y, i, ca; int x, y, i, ca;
float nx, ny, dist; float nx, ny, dist;
if(!gravifyFieldEnabled) if(!gravityFieldEnabled)
return; return;
for (y=0; y<YRES/CELL; y++) for (y=0; y<YRES/CELL; y++)
@ -2062,12 +2063,15 @@ void Renderer::draw_air()
void Renderer::draw_grav_zones() void Renderer::draw_grav_zones()
{ {
if(!gravityZonesEnabled)
return;
int x, y, i, j; int x, y, i, j;
for (y=0; y<YRES/CELL; y++) for (y=0; y<YRES/CELL; y++)
{ {
for (x=0; x<XRES/CELL; x++) for (x=0; x<XRES/CELL; x++)
{ {
//if(sim->gravmask[y*(XRES/CELL)+x]) if(sim->grav->gravmask[y*(XRES/CELL)+x])
{ {
for (j=0; j<CELL; j++)//draws the colors for (j=0; j<CELL; j++)//draws the colors
for (i=0; i<CELL; i++) for (i=0; i<CELL; i++)
@ -2102,7 +2106,8 @@ Renderer::Renderer(Graphics * g, Simulation * sim):
ZFACTOR(8), ZFACTOR(8),
zoomEnabled(false), zoomEnabled(false),
decorations_enable(1), decorations_enable(1),
gravifyFieldEnabled(false) gravityFieldEnabled(false),
gravityZonesEnabled(false)
{ {
this->g = g; this->g = g;
this->sim = sim; this->sim = sim;

View File

@ -42,7 +42,8 @@ public:
char * plasma_data; char * plasma_data;
int emp_decor; int emp_decor;
// //
bool gravifyFieldEnabled; bool gravityZonesEnabled;
bool gravityFieldEnabled;
int decorations_enable; int decorations_enable;
Simulation * sim; Simulation * sim;
Graphics * g; Graphics * g;

View File

@ -43,7 +43,6 @@ typedef struct mask_el mask_el;
class Gravity class Gravity
{ {
private: private:
unsigned *gravmask;
float *th_ogravmap; float *th_ogravmap;
float *th_gravmap; float *th_gravmap;
@ -68,6 +67,7 @@ private:
//Simulation * sim; //Simulation * sim;
public: public:
unsigned *gravmask;
float *gravmap; float *gravmap;
float *gravp; float *gravp;
float *gravy; float *gravy;