Skip to content

Commit 3041609

Browse files
committed
once again revamped help system, also changed particle color
1 parent 177be87 commit 3041609

File tree

4 files changed

+46
-11
lines changed

4 files changed

+46
-11
lines changed

src/guiconsole/console.cpp

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,15 @@ void ConsoleManager::handleCommand()
129129
App::procClose();
130130
break;
131131
case consolecommands::HELP:
132-
printToConsole("list of available commands:% get% set% reset% exit%%type help <command> for additional information");
132+
printToConsole("list of available commands:% get% set% reset% exit% vars%%type help <command> for additional information");
133133
handleHelpCommand(command);
134134
break;
135135
case consolecommands::RESET:
136136
d_particle_manager->resetParticles();
137137
break;
138+
case consolecommands::VARS:
139+
printToConsole("Invalid Command");
140+
break;
138141
}
139142
}
140143
}
@@ -257,6 +260,12 @@ void ConsoleManager::handleSetCommand(const std::string& str)
257260
case consolecommands::COLOR_A:
258261
d_particle_manager->setColorA(numeric_value);
259262
break;
263+
case consolecommands::COLOR_RAND:
264+
d_particle_manager->setColorRand(numeric_value);
265+
break;
266+
case consolecommands::COLORS:
267+
printToConsole("cannot set command 'colors', specify each value with color_r/g/b");
268+
break;
260269
}
261270
}
262271
}
@@ -310,6 +319,13 @@ void ConsoleManager::handleGetCommand(const std::string& str)
310319
case consolecommands::COLOR_A:
311320
ss << d_particle_manager->getColorA();
312321
break;
322+
case consolecommands::COLOR_RAND:
323+
ss << "cannot get color_rand, command is specific to set";
324+
break;
325+
case consolecommands::COLORS:
326+
ss << "R " << d_particle_manager->getColorR()
327+
<< "%G " << d_particle_manager->getColorG()
328+
<< "%B " << d_particle_manager->getColorB();
313329
}
314330
printToConsole(ss.str());
315331
}
@@ -341,17 +357,20 @@ void ConsoleManager::handleHelpCommand(const std::string& str)
341357
}else{
342358
switch(key) {
343359
case consolecommands::GET:
344-
printToConsole("get:% retrieve variable values, list of var's:% mass,drag,mouseforce% particlecount,color_r/g/b/a");
360+
printToConsole("get:% retrieve variable values, to list of vars:% help vars");
345361
break;
346362
case consolecommands::SET:
347-
printToConsole("set:% set value of variable, list of var's allowed:% mass,drag,mouseforce% color_r/g/b/a");
363+
printToConsole("set:% set value of variable, to list of vars:% help vars");
348364
break;
349365
case consolecommands::RESET:
350366
printToConsole("reset:% remove all acting force on particles and% position them at the center of the screen");
351367
break;
352368
case consolecommands::EXIT:
353369
printToConsole("exit:% exit the program, esc will also exit the% program");
354370
break;
371+
case consolecommands::VARS:
372+
printToConsole("list of available program variables:% drag,mass,mouseforce,particlecount% color_r/g/b/a,colors,color_rand");
373+
break;
355374
}
356375
}
357376
}

src/guiconsole/consolecommands.hpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ namespace consolecommands {
1111
"set",
1212
"get",
1313
"help",
14-
"reset"
14+
"reset",
15+
"vars"
1516
};
1617

1718
std::string valid_variables[] = {
@@ -22,15 +23,18 @@ namespace consolecommands {
2223
"color_r",
2324
"color_g",
2425
"color_b",
25-
"color_a"
26+
"color_a",
27+
"color_rand",
28+
"colors"
2629
};
2730

2831
enum Key {
2932
EXIT=0,
3033
SET,
3134
GET,
3235
HELP,
33-
RESET
36+
RESET,
37+
VARS
3438
};
3539

3640
enum VarKey {
@@ -41,7 +45,9 @@ namespace consolecommands {
4145
COLOR_R,
4246
COLOR_G,
4347
COLOR_B,
44-
COLOR_A
48+
COLOR_A,
49+
COLOR_RAND,
50+
COLORS
4551
};
4652

4753
bool isValidCommandKey(const std::string& key, Key& k)

src/particlemanager.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ const GLfloat ParticleManager::g_vertex_buffer_data[] = {
2323
ParticleManager::ParticleManager(sf::Window* parent_window, int maxparticles, float drag,
2424
float mass, float size, float mouseforce):
2525
d_MAXPARTICLES(maxparticles), d_DRAG(drag), d_MASS(mass),
26-
d_SIZE(size), d_MOUSEFORCE(mouseforce), d_R(120), d_G(200),
27-
d_B(10), d_A(255)
26+
d_SIZE(size), d_MOUSEFORCE(mouseforce), d_R(15), d_G(200),
27+
d_B(75), d_A(255)
2828
{
2929
d_parent_window = parent_window;
3030

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

5959
particle.life = 1000.0f;
@@ -355,6 +355,14 @@ void ParticleManager::setColorA(const unsigned char& val)
355355
d_A = val;
356356
}
357357

358+
void ParticleManager::setColorRand(const int& val)
359+
{
360+
if(val > 255 || val < 0) return;
361+
d_R = std::rand() % 255 - val;
362+
d_G = std::rand() % 255 - val;
363+
d_B = std::rand() % 255 - val;
364+
}
365+
358366
void ParticleManager::resetParticles()
359367
{
360368
d_particles_container.clear();
@@ -416,4 +424,5 @@ int ParticleManager::getColorB()
416424
int ParticleManager::getColorA()
417425
{
418426
return d_A;
419-
}
427+
}
428+

src/particlemanager.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class ParticleManager{
4646
void setColorG(const unsigned char& val);
4747
void setColorB(const unsigned char& val);
4848
void setColorA(const unsigned char& val);
49+
void setColorRand(const int& val);
4950

5051

5152
//get functions

0 commit comments

Comments
 (0)