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();
// 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();
if(GetData()->ctx->GetInput(1)) break;
}
-
- if(stop_voice)
- op_sound((char*)"~", NULL);
-
}
void Loop() {
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;
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);
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';
+ }
}
// 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, "!")) {