remove PARTICLEDEBUG define and replace it with tpt.setdebug(0x8) to activate the key shortcuts
This commit is contained in:
parent
983ed4eb53
commit
10262b87da
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "gui/interface/Point.h"
|
#include "gui/interface/Point.h"
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
class DebugInfo
|
class DebugInfo
|
||||||
{
|
{
|
||||||
@ -9,4 +10,6 @@ public:
|
|||||||
virtual ~DebugInfo() { }
|
virtual ~DebugInfo() { }
|
||||||
unsigned int ID;
|
unsigned int ID;
|
||||||
virtual void Draw() {}
|
virtual void Draw() {}
|
||||||
|
// currentMouse doesn't belong but I don't want to create more hooks at the moment
|
||||||
|
virtual bool KeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt, ui::Point currentMouse) { return true; }
|
||||||
};
|
};
|
||||||
|
106
src/debug/ParticleDebug.cpp
Normal file
106
src/debug/ParticleDebug.cpp
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
#include <sstream>
|
||||||
|
#include "ParticleDebug.h"
|
||||||
|
#include "gui/interface/Engine.h"
|
||||||
|
#include "gui/game/GameView.h"
|
||||||
|
#include "gui/game/GameController.h"
|
||||||
|
|
||||||
|
ParticleDebug::ParticleDebug(unsigned int id, Simulation * sim, GameModel * model):
|
||||||
|
DebugInfo(id),
|
||||||
|
sim(sim),
|
||||||
|
model(model)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ParticleDebug::Debug(int mode, int x, int y)
|
||||||
|
{
|
||||||
|
int debug_currentParticle = sim->debug_currentParticle;
|
||||||
|
int i;
|
||||||
|
std::stringstream logmessage;
|
||||||
|
|
||||||
|
if (mode == 0)
|
||||||
|
{
|
||||||
|
if (!sim->NUM_PARTS)
|
||||||
|
return;
|
||||||
|
i = debug_currentParticle;
|
||||||
|
while (i < NPART && !sim->parts[i].type)
|
||||||
|
i++;
|
||||||
|
if (i == NPART)
|
||||||
|
logmessage << "End of particles reached, updated sim";
|
||||||
|
else
|
||||||
|
logmessage << "Updated particle #" << i;
|
||||||
|
}
|
||||||
|
else if (mode == 1)
|
||||||
|
{
|
||||||
|
if (x < 0 || x >= XRES || y < 0 || y >= YRES || !(i = (sim->pmap[y][x]>>8)) || i < debug_currentParticle)
|
||||||
|
{
|
||||||
|
i = NPART;
|
||||||
|
logmessage << "Updated particles from #" << debug_currentParticle << " to end, updated sim";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
logmessage << "Updated particles #" << debug_currentParticle << " through #" << i;
|
||||||
|
}
|
||||||
|
model->Log(logmessage.str(), false);
|
||||||
|
|
||||||
|
sim->UpdateParticles(debug_currentParticle, i);
|
||||||
|
if (i < NPART-1)
|
||||||
|
sim->debug_currentParticle = i+1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sim->AfterSim();
|
||||||
|
sim->framerender = 1;
|
||||||
|
sim->BeforeSim();
|
||||||
|
sim->framerender = 0;
|
||||||
|
sim->debug_currentParticle = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ParticleDebug::KeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt, ui::Point currentMouse)
|
||||||
|
{
|
||||||
|
if (key == 'f')
|
||||||
|
{
|
||||||
|
if (alt)
|
||||||
|
{
|
||||||
|
Debug(0, 0, 0);
|
||||||
|
}
|
||||||
|
else if (shift)
|
||||||
|
{
|
||||||
|
ui::Point mouse = currentMouse;
|
||||||
|
if (mouse.X >= XRES)
|
||||||
|
mouse.X = XRES-1;
|
||||||
|
else if (mouse.X < 0)
|
||||||
|
mouse.X = 0;
|
||||||
|
if (mouse.Y >= YRES)
|
||||||
|
mouse.Y = YRES-1;
|
||||||
|
else if (mouse.Y < 0)
|
||||||
|
mouse.Y = 0;
|
||||||
|
|
||||||
|
mouse = model->AdjustZoomCoords(mouse);
|
||||||
|
Debug(1, mouse.X, mouse.Y);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (sim->debug_currentParticle > 0)
|
||||||
|
{
|
||||||
|
sim->UpdateParticles(sim->debug_currentParticle, NPART);
|
||||||
|
sim->AfterSim();
|
||||||
|
std::stringstream logmessage;
|
||||||
|
logmessage << "Updated particles from #" << sim->debug_currentParticle << " to end, updated sim";
|
||||||
|
model->Log(logmessage.str(), false);
|
||||||
|
sim->debug_currentParticle = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
model->FrameStep(1);
|
||||||
|
}
|
||||||
|
model->SetPaused(1);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ParticleDebug::~ParticleDebug()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
19
src/debug/ParticleDebug.h
Normal file
19
src/debug/ParticleDebug.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#ifndef PARTICLE_DEBUG_H
|
||||||
|
#define PARTICLE_DEBUG_H
|
||||||
|
|
||||||
|
#include "DebugInfo.h"
|
||||||
|
|
||||||
|
class Simulation;
|
||||||
|
class GameModel;
|
||||||
|
class ParticleDebug : public DebugInfo
|
||||||
|
{
|
||||||
|
Simulation * sim;
|
||||||
|
GameModel * model;
|
||||||
|
public:
|
||||||
|
ParticleDebug(unsigned int id, Simulation * sim, GameModel * model);
|
||||||
|
void Debug(int mode, int x, int y);
|
||||||
|
virtual bool KeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt, ui::Point currentMouse);
|
||||||
|
virtual ~ParticleDebug();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -30,6 +30,7 @@
|
|||||||
#include "debug/DebugParts.h"
|
#include "debug/DebugParts.h"
|
||||||
#include "debug/ElementPopulation.h"
|
#include "debug/ElementPopulation.h"
|
||||||
#include "debug/DebugLines.h"
|
#include "debug/DebugLines.h"
|
||||||
|
#include "debug/ParticleDebug.h"
|
||||||
#ifdef LUACONSOLE
|
#ifdef LUACONSOLE
|
||||||
#include "lua/LuaScriptInterface.h"
|
#include "lua/LuaScriptInterface.h"
|
||||||
#else
|
#else
|
||||||
@ -162,6 +163,7 @@ GameController::GameController():
|
|||||||
debugInfo.push_back(new DebugParts(0x1, gameModel->GetSimulation()));
|
debugInfo.push_back(new DebugParts(0x1, gameModel->GetSimulation()));
|
||||||
debugInfo.push_back(new ElementPopulationDebug(0x2, gameModel->GetSimulation()));
|
debugInfo.push_back(new ElementPopulationDebug(0x2, gameModel->GetSimulation()));
|
||||||
debugInfo.push_back(new DebugLines(0x4, gameView, this));
|
debugInfo.push_back(new DebugLines(0x4, gameView, this));
|
||||||
|
debugInfo.push_back(new ParticleDebug(0x8, gameModel->GetSimulation(), gameModel));
|
||||||
}
|
}
|
||||||
|
|
||||||
GameController::~GameController()
|
GameController::~GameController()
|
||||||
@ -639,7 +641,7 @@ bool GameController::MouseWheel(int x, int y, int d)
|
|||||||
bool GameController::KeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
|
bool GameController::KeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
|
||||||
{
|
{
|
||||||
bool ret = commandInterface->OnKeyPress(key, character, shift, ctrl, alt);
|
bool ret = commandInterface->OnKeyPress(key, character, shift, ctrl, alt);
|
||||||
if(ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
Simulation * sim = gameModel->GetSimulation();
|
Simulation * sim = gameModel->GetSimulation();
|
||||||
if (key == KEY_RIGHT)
|
if (key == KEY_RIGHT)
|
||||||
@ -691,6 +693,13 @@ bool GameController::KeyPress(int key, Uint16 character, bool shift, bool ctrl,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(std::vector<DebugInfo*>::iterator iter = debugInfo.begin(), end = debugInfo.end(); iter != end; iter++)
|
||||||
|
{
|
||||||
|
if ((*iter)->ID & debugFlags)
|
||||||
|
if (!(*iter)->KeyPress(key, character, shift, ctrl, alt, gameView->GetMousePosition()))
|
||||||
|
ret = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -698,7 +707,7 @@ bool GameController::KeyPress(int key, Uint16 character, bool shift, bool ctrl,
|
|||||||
bool GameController::KeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt)
|
bool GameController::KeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt)
|
||||||
{
|
{
|
||||||
bool ret = commandInterface->OnKeyRelease(key, character, shift, ctrl, alt);
|
bool ret = commandInterface->OnKeyRelease(key, character, shift, ctrl, alt);
|
||||||
if(ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
Simulation * sim = gameModel->GetSimulation();
|
Simulation * sim = gameModel->GetSimulation();
|
||||||
if (key == KEY_RIGHT || key == KEY_LEFT)
|
if (key == KEY_RIGHT || key == KEY_LEFT)
|
||||||
@ -1425,52 +1434,6 @@ void GameController::ReloadSim()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PARTICLEDEBUG
|
|
||||||
void GameController::ParticleDebug(int mode, int x, int y)
|
|
||||||
{
|
|
||||||
Simulation *sim = gameModel->GetSimulation();
|
|
||||||
int debug_currentParticle = sim->debug_currentParticle;
|
|
||||||
int i;
|
|
||||||
std::stringstream logmessage;
|
|
||||||
|
|
||||||
if (mode == 0)
|
|
||||||
{
|
|
||||||
if (!sim->NUM_PARTS)
|
|
||||||
return;
|
|
||||||
i = debug_currentParticle;
|
|
||||||
while (i < NPART && !sim->parts[i].type)
|
|
||||||
i++;
|
|
||||||
if (i == NPART)
|
|
||||||
logmessage << "End of particles reached, updated sim";
|
|
||||||
else
|
|
||||||
logmessage << "Updated particle #" << i;
|
|
||||||
}
|
|
||||||
else if (mode == 1)
|
|
||||||
{
|
|
||||||
if (x < 0 || x >= XRES || y < 0 || y >= YRES || !(i = (sim->pmap[y][x]>>8)) || i < debug_currentParticle)
|
|
||||||
{
|
|
||||||
i = NPART;
|
|
||||||
logmessage << "Updated particles from #" << debug_currentParticle << " to end, updated sim";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
logmessage << "Updated particles #" << debug_currentParticle << " through #" << i;
|
|
||||||
}
|
|
||||||
gameModel->Log(logmessage.str(), false);
|
|
||||||
|
|
||||||
sim->UpdateParticles(debug_currentParticle, i);
|
|
||||||
if (i < NPART-1)
|
|
||||||
sim->debug_currentParticle = i+1;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sim->Aftersim();
|
|
||||||
sim->framerender = 1;
|
|
||||||
sim->BeforeSim();
|
|
||||||
sim->framerender = 0;
|
|
||||||
sim->debug_currentParticle = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::string GameController::ElementResolve(int type, int ctype)
|
std::string GameController::ElementResolve(int type, int ctype)
|
||||||
{
|
{
|
||||||
if(gameModel && gameModel->GetSimulation())
|
if(gameModel && gameModel->GetSimulation())
|
||||||
|
@ -132,9 +132,6 @@ public:
|
|||||||
void PlaceSave(ui::Point position);
|
void PlaceSave(ui::Point position);
|
||||||
void ClearSim();
|
void ClearSim();
|
||||||
void ReloadSim();
|
void ReloadSim();
|
||||||
#ifdef PARTICLEDEBUG
|
|
||||||
void ParticleDebug(int mode, int x, int y);
|
|
||||||
#endif
|
|
||||||
void Vote(int direction);
|
void Vote(int direction);
|
||||||
void ChangeBrush();
|
void ChangeBrush();
|
||||||
void ShowConsole();
|
void ShowConsole();
|
||||||
|
@ -1431,19 +1431,6 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
|||||||
c->OpenElementSearch();
|
c->OpenElementSearch();
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
#ifdef PARTICLEDEBUG
|
|
||||||
if (ctrl)
|
|
||||||
{
|
|
||||||
c->ParticleDebug(0, 0, 0);
|
|
||||||
}
|
|
||||||
else if (shift)
|
|
||||||
{
|
|
||||||
ui::Point mouse = c->PointTranslate(currentMouse);
|
|
||||||
c->ParticleDebug(1, mouse.X, mouse.Y);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
c->FrameStep();
|
|
||||||
#else
|
|
||||||
if (ctrl)
|
if (ctrl)
|
||||||
{
|
{
|
||||||
Tool *active = c->GetActiveTool(0);
|
Tool *active = c->GetActiveTool(0);
|
||||||
@ -1454,7 +1441,6 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
c->FrameStep();
|
c->FrameStep();
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case 'g':
|
case 'g':
|
||||||
if (ctrl)
|
if (ctrl)
|
||||||
|
Reference in New Issue
Block a user