diff options
Diffstat (limited to 'src/command.c')
-rw-r--r-- | src/command.c | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/src/command.c b/src/command.c index c6b64e7..62c047b 100644 --- a/src/command.c +++ b/src/command.c @@ -205,16 +205,56 @@ static void show_tokens(struct token *tokens, int n, struct nanolight *nl) } +static void set_level(struct nanolight *nl, int val, enum attr_class cls) +{ + int i; + + if ( cls == ATT_INTENSITY ) { + val *= 255; + val /= 100; + } + + for ( i=0; i<nl->n_sel; i++ ) { + int j; + struct fixture *fix = &nl->fixtures[nl->selection[i]]; + for ( j=0; j<fix->cls->n_attrs; j++ ) { + if ( fix->cls->attrs[j].cls == cls ) { + fix->attr_vals[j] = val; + break; + } + } + } +} + + int command_run(const char *cmd, struct nanolight *nl) { struct token tokens[1024]; - int n; + int i, n; n = find_tokens(cmd, tokens, nl); if ( n == 0 ) return 1; show_tokens(tokens, n, nl); + i = 0; + if ( tokens[i].type == TK_FIXTURE ) { + nl->n_sel = 0; + for ( i=0; i<n; i++ ) { + if ( tokens[i].type == TK_FIXTURE ) { + nl->selection[nl->n_sel++] = tokens[i].fixture_index; + } else { + break; + } + } + } + + if ( tokens[i].type == TK_AT ) { + if ( tokens[i+1].type == TK_LEVEL ) { + set_level(nl, tokens[i+1].val, ATT_INTENSITY); + } + } + return 0; } |