void MOpt_ImportConfig(void) { MOpt_configpage_mode = MOCPM_CHOOSECONFIG; if (cfg_use_home.value) FL_SetCurrentDir(&configs_filelist, com_homedir); else FL_SetCurrentDir(&configs_filelist, "./ezquake/configs"); }
void MOpt_ImportConfig(void) { MOpt_configpage_mode = MOCPM_CHOOSECONFIG; // hope few doubled trinary operator won't hurt your brains if (cfg_use_home.integer) FL_SetCurrentDir(&configs_filelist, (cfg_use_gamedir.integer) ? va("%s/%s", com_homedir, (strcmp(com_gamedirfile, "qw") == 0) ? "" : com_gamedirfile) : com_homedir); else FL_SetCurrentDir(&configs_filelist, (cfg_use_gamedir.integer) ? va("%s/%s/configs", com_basedir, (strcmp(com_gamedirfile, "qw") == 0) ? "ezquake" : com_gamedirfile) : va("%s/ezquake/configs", com_basedir)); }
// // Create list // void FL_Init(filelist_t *fl, char *initdir) { Sys_getcwd(fl->current_dir, MAX_PATH); FL_SetCurrentDir(fl, initdir); fl->error = false; fl->need_refresh = true; fl->num_entries = 0; fl->current_entry = 0; fl->num_filetypes = 0; fl->search_string[0] = 0; fl->last_page_size = 0; fl->search_valid = false; fl->cdup_find = false; fl->show_dirup = true; fl->show_dirs = true; fl->scrollbar = ScrollBar_Create(NULL); #ifdef WITH_ZIP fl->current_archive[0] = 0; fl->in_archive = false; #endif // WITH_ZIP }
// set new initial dir void Menu_Demo_NewHome(const char *homedir) { char buf[MAX_OSPATH]; strlcpy(buf, com_basedir, sizeof(buf)); strlcat(buf, "/", sizeof(buf)); strlcat(buf, homedir, sizeof(buf)); FL_SetCurrentDir(&demo_filelist, buf); }
void Demo_AddDirToPlaylist (char *dir_path) { extern void FL_ReadDir(filelist_t *fl); int i; filelist_t dir_filelist; if (!dir_path) { return; } // Bit of a hack, but we need values for cvars and what not for the FL_ functions to work // so borrow them from demo_filelist. memcpy (&dir_filelist, &demo_filelist, sizeof(dir_filelist)); FL_SetCurrentDir (&dir_filelist, dir_path); FL_ReadDir (&dir_filelist); // Find the demos and add them to the playlist. for (i = 0; i < dir_filelist.num_entries; i++) { filedesc_t *f = &dir_filelist.entries[i]; // Don't bother with zips and directories. if (f->is_directory #ifdef WITH_ZIP || f->is_archive #endif ) { // TODO: Make this recursive for dirs? continue; } Demo_AddDemoToPlaylist (f->display, f->name); } }
void MOpt_LoadScript(void) { MOpt_configpage_mode = MOCPM_CHOOSESCRIPT; FL_SetCurrentDir(&configs_filelist, "./ezquake/cfg"); }
// // keys handling // returns: true if processed, false if ignored // qbool FL_Key(filelist_t *fl, int key) { if (fl->mode != FL_MODE_NORMAL) { switch(key) { case 'y': case 'Y': case K_ENTER: if (!FL_IsCurrentDir(fl)) { if (fl->mode == FL_MODE_DELETE) { FL_DeleteFile(fl); } #ifdef WITH_ZIP else if (fl->mode == FL_MODE_COMPRESS) { FL_CompressFile(fl); // Compress file. } else if (fl->mode == FL_MODE_DECOMPRESS) { FL_DecompressFile(fl); // Decompress file. } #endif // WITH_ZIP } fl->mode = FL_MODE_NORMAL; return true; case 'n': case 'N': case K_ESCAPE: fl->mode = FL_MODE_NORMAL; return true; } return false; } // Check for search if ((key >= ' ' && key <= '~') && (fl->search_valid || (!isAltDown() && !isCtrlDown() && !isShiftDown()))) { int len; if (!fl->search_valid) { // Start searching fl->search_valid = true; fl->search_error = false; fl->search_string[0] = 0; } len = strlen(fl->search_string); if (len < MAX_SEARCH_STRING && !fl->search_error) { fl->search_string[len] = key; fl->search_string[len+1] = 0; fl->search_dirty = true; // Save the last time the user entered a char in the // search term, so that we know when to timeout the search prompt. // (See beginning of FL_Draw) last_search_enter_time = Sys_DoubleTime(); } return true; // handled } else { fl->search_valid = false; // finish search mode } // sorting mode / displaying columns if (key >= '1' && key <= '4') { if (isCtrlDown() && !isAltDown() && !isShiftDown()) { switch (key) { case '2': Cvar_Toggle(&file_browser_show_size); break; case '3': Cvar_Toggle(&file_browser_show_date); break; case '4': Cvar_Toggle(&file_browser_show_time); break; default: break; } return true; } else if (!isCtrlDown() && isAltDown() && !isShiftDown()) { char buf[128]; strlcpy(buf, file_browser_sort_mode.string, 32); // WTF? if (key == buf[0]) { // reverse order buf[0] ^= 128; } else { // add new memmove(buf+1, buf, strlen(buf)+1); buf[0] = key; } buf[8] = 0; Cvar_Set(&file_browser_sort_mode, buf); fl->need_resort = true; return true; } } // change drive #ifdef _WIN32 if (isAltDown() && isCtrlDown() && tolower(key) >= 'a' && tolower(key) <= 'z') { char newdir[MAX_PATH+1]; char olddir[MAX_PATH+1]; snprintf(newdir, sizeof (newdir), "%c:\\", tolower(key)); // validate if (Sys_getcwd(olddir, MAX_PATH+1) == 0) return true; if (Sys_chdir(newdir) == 0) return true; Sys_chdir(olddir); // and set FL_SetCurrentDir(fl, newdir); fl->need_refresh = true; return true; } #endif if (key == '\\' || key == '/') { FL_ChangeDir(fl, va("%c", PATH_SEPARATOR)); return true; } if (key == K_ENTER || key == K_MOUSE1) { if (FL_IsCurrentDir(fl)) { FL_ChangeDir(fl, FL_GetCurrentPath(fl)); return true; } #ifdef WITH_ZIP else if (FL_IsCurrentArchive(fl)) { FL_ChangeArchive(fl, FL_GetCurrentPath(fl)); return true; } #endif //WITH_ZIP else { return false; } } if (key == K_BACKSPACE) { if (fl->show_dirup) FL_ChangeDir(fl, ".."); return true; } if (key == K_UPARROW || key == K_MWHEELUP) { fl->current_entry--; FL_CheckDisplayPosition(fl); return true; } if (key == K_DOWNARROW || key == K_MWHEELDOWN) { fl->current_entry++; FL_CheckDisplayPosition(fl); return true; } if (key == K_PGUP) { fl->current_entry -= fl->last_page_size; FL_CheckDisplayPosition(fl); return true; } if (key == K_PGDN) { fl->current_entry += fl->last_page_size; FL_CheckDisplayPosition(fl); return true; } if (key == K_HOME) { fl->current_entry = 0; FL_CheckDisplayPosition(fl); return true; } if (key == K_END) { fl->current_entry = fl->num_entries - 1; FL_CheckDisplayPosition(fl); return true; } #ifdef WITH_ZIP // // Compress the current file. // if ((key == 'c' || key == 'C') && isAltDown()) { if (!FL_IsCurrentDir(fl)) { if (isShiftDown()) { // Alt + shift + c == Compress without confirming. FL_CompressFile(fl); } else { // Alt + c == Confirm before compressing. fl->mode = FL_MODE_COMPRESS; } } return true; } // // Decompress the current file. // if ((key == 'd' || key == 'D') && isAltDown()) { if (!strcmp(COM_FileExtension(FL_GetCurrentPath(fl)), "gz")) { FL_DecompressFile(fl); } } #endif // WITH_ZIP // // Delete the current file. // if (key == K_DEL) { if (!FL_IsCurrentDir(fl)) { if (isShiftDown()) { // Shift + del == Delete without confirming. FL_DeleteFile(fl); } else { // Del == Confirm before deleting. fl->mode = FL_MODE_DELETE; } } return true; } return false; }