]> Chaos Git - vn/vndc.git/commitdiff
Implemented voice-stopping on quoted lines.
authorchaoskagami <chaos.kagami@gmail.com>
Mon, 25 Aug 2014 01:01:27 +0000 (21:01 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Mon, 25 Aug 2014 01:01:27 +0000 (21:01 -0400)
.gitignore
bin/vndc.x86_64
vndc/src/op_sound.cpp

index 83b2d3b104fc4cfe020effe0a9c0ddac74ee141d..de6a5760644aa7b3deaafb5a2a429b0f87e456eb 100644 (file)
@@ -9,4 +9,4 @@
 *.ttf
 
 # Prevent binary & lib dirs.
-./bin/
+./bin/*
index abae162e0ede4e70c795ccd6cbc9b9e4a7108b17..3523bfbc323b93fb6b961b7f5616c6e85221d493 100755 (executable)
Binary files a/bin/vndc.x86_64 and b/bin/vndc.x86_64 differ
index f6bd3139d43cef73ac0ace1027cd28622bb81ebc..e219cacec4cc276ddaecdabb630fb3551c0f413c 100644 (file)
@@ -18,27 +18,40 @@ void op_sound(char* file, int* times) {
                GetData()->ctx->Audio()->FlushSfx();
                return;
        }
-       // Play command
-       else {
-               int count = 1;
-               if (times != NULL)
-                       count = *times;
+       // Extension - Voiced auto-stop. If the next line contains quotes,
+       // it is voiced. We set a flag in response. If the flag is already
+       // set - e.g. the sound was a voice as well, we stop the previous
+       // sound before playing this one.
+
+       if(GetData()->vndc_enabled &&
+          (GetData()->next_line[6] == '"' ||
+           GetData()->next_line[strlen(GetData()->next_line) - 1] == '"')) {
+               if(GetData()->is_spoken_line == true) {
+                       GetData()->ctx->Audio()->FlushSfx();
+               }
+               GetData()->is_spoken_line = true;
+       }
+       else
+               GetData()->is_spoken_line = false;
+
 
-               char path[400];
-               memset(path, 0, 400);
+       // Play command
+       int count = 1;
+       if (times != NULL)
+               count = *times;
 
-               snprintf(path, 400, "sound/%s", file);
+       char path[400];
+       memset(path, 0, 400);
 
-               //printf("[op_sound] path: '%s'\n", path);
+       snprintf(path, 400, "sound/%s", file);
 
-               // Load displayable.
-               int sfxi = GetData()->ctx->Audio()->LoadSfx(path);
+       // Load sfx.
+       int sfxi = GetData()->ctx->Audio()->LoadSfx(path);
 
-               if (count == -1) {
-                       GetData()->ctx->Audio()->PlaySfx(sfxi, count);
-               }
-               else {
-                       GetData()->ctx->Audio()->PlaySfx(sfxi, count-1);
-               }
+       if (count == -1) {
+               GetData()->ctx->Audio()->PlaySfx(sfxi, count);
+       }
+       else {
+               GetData()->ctx->Audio()->PlaySfx(sfxi, count-1);
        }
 }