]> Chaos Git - vn/vndc.git/commitdiff
Miscellaneous tweaks. Mainly, added a line of lookahead so I can determine whether...
authorchaoskagami <chaos.kagami@gmail.com>
Mon, 25 Aug 2014 00:47:15 +0000 (20:47 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Mon, 25 Aug 2014 00:47:15 +0000 (20:47 -0400)
bin/vndc.x86_64
vndc/include/Data.hpp
vndc/src/Loop.cpp
vndc/src/Parse.cpp
vndc/src/op_choice.cpp
vndc/src/op_jump.cpp
vndc/src/op_text.cpp

index ffa73125a0ff9d0a827a1a0c750549190646fadd..abae162e0ede4e70c795ccd6cbc9b9e4a7108b17 100755 (executable)
Binary files a/bin/vndc.x86_64 and b/bin/vndc.x86_64 differ
index f17a5694d92d82349440b857b8cb6dff86b8b401..48883a00358614470c460d0041d5d5f95edfd715 100644 (file)
@@ -35,6 +35,8 @@ class DataContainer {
                int currentLine = 0;
                bool skip_key_on = false;
                char* window_name;
+               char* next_line = NULL; // Used for voice-detect.
+                                       // It's impossible to parse without lookahead.
 };
 
 DataContainer* GetData();
index 7be1d01afbc54005c20b408130d040f2ec8ba401..aa7c8a672b3d0ee42f3757e9d6365d235acf80c7 100644 (file)
@@ -9,7 +9,7 @@ void Wait() {
        // If the line is spoken, then halt previous spoken lines.
        // If the skip key is held, just gogogo
 
-       bool stop_voice = GetData()->wait_input && GetData()->vndc_enabled;
+       // bool stop_voice = GetData()->wait_input && GetData()->vndc_enabled && GetData()->is_spoken_line;
 
        while((GetData()->wait_input && !GetData()->ctx->GetQuit())) {
                GetData()->ctx->Input();
@@ -21,10 +21,6 @@ void Wait() {
 
                if(GetData()->ctx->GetInput(1)) break;
        }
-
-       if(stop_voice)
-               op_sound((char*)"~", NULL);
-
 }
 
 void Loop() {
index b0396cfced54b45d3f2e1d18df595b986ee45b3d..a4accd472be64a297e117d16725fa7f49fea687d 100644 (file)
@@ -221,33 +221,42 @@ void Parse() {
                exit(-8);
        }
 
-       char *line = (char*)calloc(sizeof(char), 400);
+       // Load the next line to this one.
+       char* line = GetData()->next_line;
 
-       fgets(line, 400, GetData()->accessScriptHandle);
+       if(line == NULL) {
+               // We've reached EOF.
+               op_jump(GetData()->main_scr[0], NULL, true);
+       }
+
+       GetData()->next_line = (char*)calloc(sizeof(char), 400);
+       // Load the next line.
+       fgets(GetData()->next_line, 400, GetData()->accessScriptHandle);
 
-       char* line_copy = line;
+       char* line_copy = GetData()->next_line;
 
        while(line_copy[0] == ' ' || line_copy[0] == '\t') {
                line_copy[0] = '\0';
                line_copy = &line_copy[1];
        }
 
-       // Remove all '\n' from this string
+       // Remove all '\n' from the buffer line
        for(int i=0; i < (int)strlen(line_copy); i++) {
                if (line_copy[i] == '\n')
                        line_copy[i] = '\0';
        }
 
-       //printf("%lu\n", strlen(line_copy));
-
-       if(strlen(line_copy) != 0) {
-               ParseCmd(line_copy);
+       // Execute the current line.
+       if(strlen(line) != 0) {
+               ParseCmd(line);
        }
 
        free(line);
 
+       // The next line is null, because the file is finished.
        if(feof(GetData()->accessScriptHandle)) {
-               op_jump(GetData()->main_scr[0], NULL, true);
+               free(GetData()->next_line);
+               GetData()->next_line = NULL;
        }
 
        return;
index fa3182c628f94a10df39e6bc5887ca65e5630d19..08000bb50fa10a77e33b162e414c1450c07a5bd7 100644 (file)
@@ -58,6 +58,8 @@ void op_choice(char* line) {
                strncpy(varname, "selected", 400);
        }
 
+       op_cleartext();
+
        // For each choice, we need to print text and make a click area. This will use the text function.
        int *choices = (int*)calloc(sizeof(int), num * 2);
 
index 3770ff32ad7928e5fd99d0607d6e67149e0350db..a58b4d96af159f91a35cd59d9538a95b12508731 100644 (file)
@@ -44,4 +44,22 @@ void op_jump(char* file, int* lineTo, bool isSave) {
        else {
                GetData()->currentLine = 0;
        }
+
+       // Read the first line into next_line.
+       GetData()->next_line = (char*)calloc(sizeof(char), 400);
+       // Load the next line.
+       fgets(GetData()->next_line, 400, GetData()->accessScriptHandle);
+
+       char* line_copy = GetData()->next_line;
+
+       while(line_copy[0] == ' ' || line_copy[0] == '\t') {
+               line_copy[0] = '\0';
+               line_copy = &line_copy[1];
+       }
+
+       // Remove all '\n' from the buffer line
+       for(int i=0; i < (int)strlen(line_copy); i++) {
+               if (line_copy[i] == '\n')
+                       line_copy[i] = '\0';
+       }
 }
index 647dddb271c945d2f09228b555856b742f4a90c3..4bf8f7b130505802804e65d06cff58866b9f89f8 100644 (file)
@@ -22,20 +22,24 @@ void op_text(char* string) {
 
        // Improvised linebreak. Also, an extension.
        if(GetData()->vndc_enabled && string[1] == '-' && string[2] == '-' && string[3] == '-') {
-                       op_cleartext();
+               op_cleartext();
        }
-       // Improvised voice detect. Extension.
-       // This is based on toggling.
-       // If the quote is incomplete, it will be stopped on end.
-       // If not, it will continue voice until the next quoted line.
-       if(GetData()->vndc_enabled) {
-               GetData()->is_spoken_line = false;
-
-               int quotes = 0;
-               for(int i=0; i < (int)strlen(string); i++) {
-                       if(string[i] == '"') quotes++;
-               }
-               if(quotes > 0) GetData()->is_spoken_line = true;
+       // Improvised Tag display. Extension.
+       if(GetData()->vndc_enabled && string[0] == '<' && string[strlen(string)-1] == '>') {
+               string[strlen(string)-1] = '\0';
+               string = &string[1];
+               
+               GetData()->ctx->ClearOverlay();
+
+               TextManager* txt = GetData()->ctx->Text();
+
+               int xloc = ( GetData()->screen_w - txt->TestLen(string) - GetData()->render_x1 );
+               
+               txt->Render(string, xloc, GetData()->render_y1);
+
+               Wait();
+
+               op_cleartext();
        }
        // Wait for input, then blank
        if(!strcmp(string, "!")) {