mirror of
https://github.com/okalachev/flix.git
synced 2026-06-27 21:46:38 +00:00
Make p command show all parameters starting with the arg
This commit is contained in:
+3
-5
@@ -31,7 +31,7 @@ const char* motd =
|
|||||||
"Commands:\n\n"
|
"Commands:\n\n"
|
||||||
"help - show help\n"
|
"help - show help\n"
|
||||||
"p - show all parameters\n"
|
"p - show all parameters\n"
|
||||||
"p <name> - show parameter\n"
|
"p <str> - show parameters starting with str\n"
|
||||||
"p <name> <value> - set parameter\n"
|
"p <name> <value> - set parameter\n"
|
||||||
"preset - reset parameters\n"
|
"preset - reset parameters\n"
|
||||||
"time - show time info\n"
|
"time - show time info\n"
|
||||||
@@ -92,10 +92,8 @@ void doCommand(String str, bool echo = false) {
|
|||||||
// execute command
|
// execute command
|
||||||
if (command == "help" || command == "motd") {
|
if (command == "help" || command == "motd") {
|
||||||
print("%s\n", motd);
|
print("%s\n", motd);
|
||||||
} else if (command == "p" && arg0 == "") {
|
} else if (command == "p" && arg1 == "") {
|
||||||
printParameters();
|
printParameters(arg0.c_str());
|
||||||
} else if (command == "p" && arg0 != "" && arg1 == "") {
|
|
||||||
print("%s = %g\n", arg0.c_str(), getParameter(arg0.c_str()));
|
|
||||||
} else if (command == "p") {
|
} else if (command == "p") {
|
||||||
bool success = setParameter(arg0.c_str(), arg1.toFloat());
|
bool success = setParameter(arg0.c_str(), arg1.toFloat());
|
||||||
if (success) {
|
if (success) {
|
||||||
|
|||||||
+2
-1
@@ -188,8 +188,9 @@ void syncParameters() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void printParameters() {
|
void printParameters(const char *filter) {
|
||||||
for (auto ¶meter : parameters) {
|
for (auto ¶meter : parameters) {
|
||||||
|
if (strncasecmp(parameter.name, filter, strlen(filter))) continue;
|
||||||
print("%s = %g\n", parameter.name, parameter.getValue());
|
print("%s = %g\n", parameter.name, parameter.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -68,7 +68,7 @@ const char *getParameterName(int index);
|
|||||||
float getParameter(int index);
|
float getParameter(int index);
|
||||||
float getParameter(const char *name);
|
float getParameter(const char *name);
|
||||||
bool setParameter(const char *name, const float value);
|
bool setParameter(const char *name, const float value);
|
||||||
void printParameters();
|
void printParameters(const char *filter);
|
||||||
void resetParameters();
|
void resetParameters();
|
||||||
|
|
||||||
// mocks
|
// mocks
|
||||||
|
|||||||
Reference in New Issue
Block a user