mirror of
https://github.com/ApfelTeeSaft/PlanetFleet.git
synced 2026-08-26 19:33:38 +00:00
implemented toggle-debug command
This commit is contained in:
+1
-1
@@ -28,7 +28,7 @@ set(GUI tooltip.cpp concreteGuiManager.cpp ${BUTTONS} ${LISTBOXES})
|
||||
set(STATES activeGameState.cpp inGameAppState.cpp guiAppState.cpp mapEditorAppState.cpp)
|
||||
set(UTIL util.cpp binds.h)
|
||||
set(CONTROLLERS gameObjectFrameController.cpp cameraController.cpp)
|
||||
set(CONSOLE console.cpp abstractCommand.cpp addUnitCommand.cpp addResourceCommand.cpp addTechnologyCommand.cpp)
|
||||
set(CONSOLE console.cpp abstractCommand.cpp addUnitCommand.cpp addResourceCommand.cpp addTechnologyCommand.cpp toggleDebugCommand.cpp)
|
||||
set(CORE gameManager.cpp game.cpp fxManager.cpp defConfigs.cpp ${CONSOLE} ${CONTROLLERS})
|
||||
set(PROJECTILES projectile.cpp cruiseMissile.cpp)
|
||||
set(VEHICLES vehicle.cpp engineer.cpp resourceRover.cpp)
|
||||
|
||||
+4
-1
@@ -2,13 +2,14 @@
|
||||
#include "addUnitCommand.h"
|
||||
#include "addResourceCommand.h"
|
||||
#include "addTechnologyCommand.h"
|
||||
#include "toggleDebugCommand.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace battleship{
|
||||
void Console::execute(string cmdStr) {
|
||||
int space = cmdStr.find(" ");
|
||||
string cmdName, argsStr;
|
||||
string cmdName = cmdStr, argsStr = "";
|
||||
|
||||
if(space != -1){
|
||||
cmdName = cmdStr.substr(0, space);
|
||||
@@ -21,5 +22,7 @@ namespace battleship{
|
||||
AddResourceCommand(argsStr).execute();
|
||||
else if(cmdName == "add-technology")
|
||||
AddTechnologyCommand(argsStr).execute();
|
||||
else if(cmdName == "toggle-debug")
|
||||
ToggleDebugCommand(argsStr).execute();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,22 +118,24 @@ namespace battleship{
|
||||
AssetManager::getSingleton()->load(gm->getPath() + gop, true);
|
||||
AssetManager::getSingleton()->load(gm->getPath() + vfxp, true);
|
||||
|
||||
vector<GameObject*> gameObjs;
|
||||
if(debug){
|
||||
vector<GameObject*> gameObjs;
|
||||
|
||||
for(Player *pl : Game::getSingleton()->getPlayers()){
|
||||
for(Unit *u : pl->getUnits())
|
||||
gameObjs.push_back((GameObject*)u);
|
||||
for(Player *pl : Game::getSingleton()->getPlayers()){
|
||||
for(Unit *u : pl->getUnits())
|
||||
gameObjs.push_back((GameObject*)u);
|
||||
|
||||
for(Projectile *proj : pl->getProjectiles())
|
||||
gameObjs.push_back((GameObject*)proj);
|
||||
for(Projectile *proj : pl->getProjectiles())
|
||||
gameObjs.push_back((GameObject*)proj);
|
||||
|
||||
for(ResourceDeposit *dep : pl->getResourceDeposits())
|
||||
gameObjs.push_back((GameObject*)dep);
|
||||
for(ResourceDeposit *dep : pl->getResourceDeposits())
|
||||
gameObjs.push_back((GameObject*)dep);
|
||||
}
|
||||
|
||||
for(GameObject *obj : gameObjs)
|
||||
obj->reinit();
|
||||
}
|
||||
|
||||
for(GameObject *obj : gameObjs)
|
||||
obj->reinit();
|
||||
|
||||
gm->getStateManager()->attachAppState(activeState);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,10 @@ namespace battleship{
|
||||
float calcAbilFromTech(Ability::Type, std::vector<int>, int, int);
|
||||
bool isUnitUnlocked(std::vector<int>, int);
|
||||
std::vector<TradeOffer*> findTradeOffers(Player*, Player*);
|
||||
inline void setDebug(bool d){this->debug = d;}
|
||||
inline void addTradeOffer(TradeOffer *to){tradeOffers.push_back(to);}
|
||||
inline void addPlayer(Player *pl){players.push_back(pl);}
|
||||
inline bool isDebug(){return debug;}
|
||||
inline std::vector<Player*>& getPlayers(){return players;}
|
||||
inline Player* getPlayer(int id){return players[id];}
|
||||
inline int getNumPlayers(){return players.size();}
|
||||
@@ -41,7 +43,7 @@ namespace battleship{
|
||||
void endGame(bool);
|
||||
std::vector<int> parseTechTable(int, std::string, std::string, std::string);
|
||||
|
||||
bool paused = false, ended = false;
|
||||
bool paused = false, ended = false, debug = false;
|
||||
std::vector<Technology> technologies;
|
||||
std::vector<Ability> abilities;
|
||||
std::vector<Player*> players;
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#include "toggleDebugCommand.h"
|
||||
#include "game.h"
|
||||
|
||||
namespace battleship{
|
||||
void ToggleDebugCommand::validate(){
|
||||
if(!arguments.empty()) return;
|
||||
}
|
||||
|
||||
void ToggleDebugCommand::execute(){
|
||||
AbstractCommand::handle();
|
||||
validate();
|
||||
|
||||
Game *game = Game::getSingleton();
|
||||
game->setDebug(!game->isDebug());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef TOGGLE_DEBUG_COMMAND_H
|
||||
#define TOGGLE_DEBUG_COMMAND_H
|
||||
|
||||
#include "abstractCommand.h"
|
||||
|
||||
namespace battleship{
|
||||
class ToggleDebugCommand : public AbstractCommand{
|
||||
public:
|
||||
ToggleDebugCommand(std::string str) : AbstractCommand(str){}
|
||||
void validate();
|
||||
void execute();
|
||||
private:
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user