Skip to content

Commit

Permalink
finished help commands, values can now be set to zero as well
Browse files Browse the repository at this point in the history
  • Loading branch information
Syntaf committed Sep 11, 2014
1 parent 314ce08 commit d688f4b
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 11 deletions.
48 changes: 45 additions & 3 deletions src/guiconsole/console.cpp
Expand Up @@ -129,7 +129,8 @@ void ConsoleManager::handleCommand()
App::procClose();
break;
case consolecommands::HELP:
printToConsole("get% return value of certain variable% mass,mouseforce,drag,particlecount,color_r/g/b/a");
printToConsole("list of available commands:% get% set% reset% exit%%type help <command> for additional information");
handleHelpCommand(command);
break;
case consolecommands::RESET:
d_particle_manager->resetParticles();
Expand Down Expand Up @@ -227,8 +228,8 @@ void ConsoleManager::handleSetCommand(const std::string& str)
ss << value;
float numeric_value;
ss >> numeric_value;
if(numeric_value <= 0) {
printToConsole("value cannot be negative or zero wtf");
if(numeric_value < 0) {
printToConsole("value cannot be negative wtf");
return;
}
switch(key) {
Expand Down Expand Up @@ -312,4 +313,45 @@ void ConsoleManager::handleGetCommand(const std::string& str)
}
printToConsole(ss.str());
}
}

void ConsoleManager::handleHelpCommand(const std::string& str)
{
//get substring holding just the str
std::string str_sub_string = str.substr(
0,
std::distance(
str.begin(),
std::find(str.begin(), str.end(), ' ')
)
);

if(str_sub_string.empty())
return;

consolecommands::Key key;
if(!consolecommands::isValidCommandKey(str_sub_string, key)) {
if(str_sub_string.empty())
printToConsole("no variable specififed");
else {
std::stringstream ss;
ss << "command " << str_sub_string << " not found";
printToConsole(ss.str());
}
}else{
switch(key) {
case consolecommands::GET:
printToConsole("get:% retrieve variable values, list of var's:% mass,drag,mouseforce% particlecount,color_r/g/b/a");
break;
case consolecommands::SET:
printToConsole("set:% set value of variable, list of var's allowed:% mass,drag,mouseforce% color_r/g/b/a");
break;
case consolecommands::RESET:
printToConsole("reset:% remove all acting force on particles and% position them at the center of the screen");
break;
case consolecommands::EXIT:
printToConsole("exit:% exit the program, esc will also exit the% program");
break;
}
}
}
1 change: 1 addition & 0 deletions src/guiconsole/console.hpp
Expand Up @@ -37,6 +37,7 @@ class ConsoleManager {
void translateCommandsUp();
void handleSetCommand(const std::string& str);
void handleGetCommand(const std::string& str);
void handleHelpCommand(const std::string& str);

tgui::Gui gui;
tgui::EditBox::Ptr d_console_edit_box;
Expand Down
16 changes: 8 additions & 8 deletions src/particlemanager.cpp
Expand Up @@ -59,10 +59,10 @@ void ParticleManager::initParticles()
particle.life = 1000.0f;
particle.cameradistance = -1.0f;

particle.r = 255;
particle.g = 0;
particle.b = 0;
particle.a = 255;
particle.r = d_R;
particle.g = d_G;
particle.b = d_B;
particle.a = d_A;

particle.size = d_SIZE;
d_particles_container.push_back(particle);
Expand Down Expand Up @@ -367,10 +367,10 @@ void ParticleManager::resetParticles()
particle.life = 1000.0f;
particle.cameradistance = -1.0f;

particle.r = 255;
particle.g = 0;
particle.b = 0;
particle.a = 255;
particle.r = d_R;
particle.g = d_G;
particle.b = d_B;
particle.a = d_A;

particle.size = d_SIZE;
d_particles_container.push_back(particle);
Expand Down

0 comments on commit d688f4b

Please sign in to comment.