Skip to content

Commit

Permalink
once again revamped help system, also changed particle color
Browse files Browse the repository at this point in the history
  • Loading branch information
Syntaf committed Sep 11, 2014
1 parent 177be87 commit 3041609
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 11 deletions.
25 changes: 22 additions & 3 deletions src/guiconsole/console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,15 @@ void ConsoleManager::handleCommand()
App::procClose();
break;
case consolecommands::HELP:
printToConsole("list of available commands:% get% set% reset% exit%%type help <command> for additional information");
printToConsole("list of available commands:% get% set% reset% exit% vars%%type help <command> for additional information");
handleHelpCommand(command);
break;
case consolecommands::RESET:
d_particle_manager->resetParticles();
break;
case consolecommands::VARS:
printToConsole("Invalid Command");
break;
}
}
}
Expand Down Expand Up @@ -257,6 +260,12 @@ void ConsoleManager::handleSetCommand(const std::string& str)
case consolecommands::COLOR_A:
d_particle_manager->setColorA(numeric_value);
break;
case consolecommands::COLOR_RAND:
d_particle_manager->setColorRand(numeric_value);
break;
case consolecommands::COLORS:
printToConsole("cannot set command 'colors', specify each value with color_r/g/b");
break;
}
}
}
Expand Down Expand Up @@ -310,6 +319,13 @@ void ConsoleManager::handleGetCommand(const std::string& str)
case consolecommands::COLOR_A:
ss << d_particle_manager->getColorA();
break;
case consolecommands::COLOR_RAND:
ss << "cannot get color_rand, command is specific to set";
break;
case consolecommands::COLORS:
ss << "R " << d_particle_manager->getColorR()
<< "%G " << d_particle_manager->getColorG()
<< "%B " << d_particle_manager->getColorB();
}
printToConsole(ss.str());
}
Expand Down Expand Up @@ -341,17 +357,20 @@ void ConsoleManager::handleHelpCommand(const std::string& 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");
printToConsole("get:% retrieve variable values, to list of vars:% help vars");
break;
case consolecommands::SET:
printToConsole("set:% set value of variable, list of var's allowed:% mass,drag,mouseforce% color_r/g/b/a");
printToConsole("set:% set value of variable, to list of vars:% help vars");
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;
case consolecommands::VARS:
printToConsole("list of available program variables:% drag,mass,mouseforce,particlecount% color_r/g/b/a,colors,color_rand");
break;
}
}
}
14 changes: 10 additions & 4 deletions src/guiconsole/consolecommands.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ namespace consolecommands {
"set",
"get",
"help",
"reset"
"reset",
"vars"
};

std::string valid_variables[] = {
Expand All @@ -22,15 +23,18 @@ namespace consolecommands {
"color_r",
"color_g",
"color_b",
"color_a"
"color_a",
"color_rand",
"colors"
};

enum Key {
EXIT=0,
SET,
GET,
HELP,
RESET
RESET,
VARS
};

enum VarKey {
Expand All @@ -41,7 +45,9 @@ namespace consolecommands {
COLOR_R,
COLOR_G,
COLOR_B,
COLOR_A
COLOR_A,
COLOR_RAND,
COLORS
};

bool isValidCommandKey(const std::string& key, Key& k)
Expand Down
17 changes: 13 additions & 4 deletions src/particlemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ const GLfloat ParticleManager::g_vertex_buffer_data[] = {
ParticleManager::ParticleManager(sf::Window* parent_window, int maxparticles, float drag,
float mass, float size, float mouseforce):
d_MAXPARTICLES(maxparticles), d_DRAG(drag), d_MASS(mass),
d_SIZE(size), d_MOUSEFORCE(mouseforce), d_R(120), d_G(200),
d_B(10), d_A(255)
d_SIZE(size), d_MOUSEFORCE(mouseforce), d_R(15), d_G(200),
d_B(75), d_A(255)
{
d_parent_window = parent_window;

Expand Down Expand Up @@ -53,7 +53,7 @@ void ParticleManager::initParticles()
for(int i=0; i<(int)sqrt(d_MAXPARTICLES); i++) {
for(int j=0; j<(int)sqrt(d_MAXPARTICLES); j++) {
Particle particle;
glm::vec2 d2Pos = glm::vec2(j*0.06, i*0.06) + glm::vec2(-20.0f,-20.0f);
glm::vec2 d2Pos = glm::vec2(j*0.06, i*0.06) + glm::vec2(-17.0f,-17.0f);
particle.pos = glm::vec3(d2Pos.x,d2Pos.y,-70);

particle.life = 1000.0f;
Expand Down Expand Up @@ -355,6 +355,14 @@ void ParticleManager::setColorA(const unsigned char& val)
d_A = val;
}

void ParticleManager::setColorRand(const int& val)
{
if(val > 255 || val < 0) return;
d_R = std::rand() % 255 - val;
d_G = std::rand() % 255 - val;
d_B = std::rand() % 255 - val;
}

void ParticleManager::resetParticles()
{
d_particles_container.clear();
Expand Down Expand Up @@ -416,4 +424,5 @@ int ParticleManager::getColorB()
int ParticleManager::getColorA()
{
return d_A;
}
}

1 change: 1 addition & 0 deletions src/particlemanager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class ParticleManager{
void setColorG(const unsigned char& val);
void setColorB(const unsigned char& val);
void setColorA(const unsigned char& val);
void setColorRand(const int& val);


//get functions
Expand Down

0 comments on commit 3041609

Please sign in to comment.