void wordcloud_mouse(mmask_t buttons, int x, int y) { if (get_cursor_mode() != CM_WC) set_cursor_mode(CM_WC); else if (buttons & BUTTON1_CLICKED) { if (wc_offset + y < wc_list_n) { int ar_index = wc_offset + y; char *temp = strdup(wc_list[ar_index]); search_in_wc(temp); free(temp); } else { wrong_key(); } } else { wrong_key(); } }
void help_system(struct world *mzx_world) { char file[13], file2[13], label[13]; int where, offs, size, t1, t2; enum cursor_mode_types old_cmode; FILE *fp; fp = mzx_world->help_file; if(!fp) return; old_cmode = get_cursor_mode(); rewind(fp); t1 = fgetw(fp); fseek(fp, t1 * 21 + 4 + get_context() * 12, SEEK_SET); // At proper context info where = fgetd(fp); // Where file to load is size = fgetd(fp); // Size of file to load offs = fgetd(fp); // Offset within file of link // Jump to file fseek(fp, where, SEEK_SET); // Read it in fread(help, 1, size, fp); // Display it cursor_off(); labelled: help_display(mzx_world, help, offs, file, label); // File? if(file[0]) { // Yep. Search for file. fseek(fp, 2, SEEK_SET); for(t2 = 0; t2 < t1; t2++) { fread(file2, 1, 13, fp); if(!strcmp(file, file2)) break; fseek(fp, 8, SEEK_CUR); } if(t2 < t1) { // Found file. where = fgetd(fp); size = fgetd(fp); fseek(fp, where, SEEK_SET); fread(help, 1, size, fp); // Search for label for(t2 = 0; t2 < size; t2++) { if(help[t2] != 255) continue; if(help[t2 + 1] != ':') continue; if(!strcmp(help + t2 + 3, label)) break; // Found label! } if(t2 < size) { // Found label. t2 is offset. offs = t2; goto labelled; } } } set_cursor_mode(old_cmode); }