void SingleBrowser::on_file_select(const Filename& filename) { if (hardware.get_mrh() || button_edit.get_clicked()) { set_exit_with(EXIT_WITH_EDIT); useR->single_last_level = get_current_file(); } else { Level l(filename); if (l.get_status() == Level::GOOD) { set_exit_with(EXIT_WITH_OKAY); useR->single_last_level = get_current_file(); } } }
void EditorFileDialog::_post_popup() { ConfirmationDialog::_post_popup(); if (invalidated) { update_file_list(); invalidated=false; } if (mode==MODE_SAVE_FILE) file->grab_focus(); else item_list->grab_focus(); if (is_visible() && get_current_file()!="") _request_single_thumbnail(get_current_dir().plus_file(get_current_file())); if (is_visible()) { Ref<Texture> folder = get_icon("folder","FileDialog"); recent->clear(); bool res = access==ACCESS_RESOURCES; Vector<String> recentd = EditorSettings::get_singleton()->get_recent_dirs(); for(int i=0;i<recentd.size();i++) { bool cres = recentd[i].begins_with("res://"); if (cres!=res) continue; String name = recentd[i]; if (res && name=="res://") { name="/"; } else { name=name.get_file()+"/"; } //print_line("file: "+name); recent->add_item(name,folder); recent->set_item_metadata( recent->get_item_count()-1,recentd[i]); } local_history.clear(); local_history_pos=-1; _push_history(); _update_favorites(); } set_process_unhandled_input(true); }
/** Openat system call * * \todo Implement flags and mode tests. */ int sys_openat(int dirfd, uaddr_t u_pathname, int flags, mode_t mode) { int fd; char pathname[ MAX_PATHLEN ]; struct file *file; struct inode * root_inode = NULL; if( strncpy_from_user( pathname, (void*) u_pathname, sizeof(pathname) ) < 0 ) return -EFAULT; //printk("sys_openat(%s): %d %08x %03x\n", pathname, dirfd, flags, mode); dbg( "name='%s' dirfd=%d flags %x mode %x\n", pathname, dirfd, flags, mode); //_KDBG( "name='%s' flags %x mode %x\n", pathname, flags, mode); if ((pathname[0] == '/') || (dirfd == AT_FDCWD)) { root_inode = kfs_root; } else { struct file * root_file = get_current_file(dirfd); if (!root_file) { return -EBADF; } root_inode = root_file->inode; } // FIX ME __lock(&_lock); if ( ! kfs_lookup( root_inode, pathname, 0 ) && ( flags & O_CREAT ) ) { extern struct kfs_fops in_mem_fops; extern struct inode_operations in_mem_iops; if ( kfs_create_at( root_inode, pathname, &in_mem_iops, &in_mem_fops, 0777, 0, 0 ) == NULL ) { fd = -EFAULT; goto out; } } if((fd = kfs_open_path_at(root_inode, pathname, flags, mode, &file)) < 0) { //printk("sys_openat failed : %s (%d)\n",pathname,fd); goto out; } fd = fdTableGetUnused( current->fdTable ); fdTableInstallFd( current->fdTable, fd, file ); // TODO XXX - check to see if the file's path identifies it as a pipe, and set the pipe stuff dbg("name=`%s` fd=%d \n", pathname, fd ); out: __unlock(&_lock); return fd; }
void SingleBrowser::calc_self() { BrowserBig::calc_self(); if (box_delete) { box_delete->set_draw_required(); // Damit Buttons eingedrueckt werd. switch (box_delete->get_button_clicked()) { case 1: { Filename to_delete = get_current_file(); highlight_neighboring_level_before_deletion(); ::delete_file(to_delete.get_rootful().c_str()); } load_dir(get_current_file(), true); // falls through case 2: delete box_delete; box_delete = 0; set_draw_required(); break; default: ; } } else { // No additional windows open if (button_edit.get_clicked()) { on_file_select(get_current_file()); } else if (button_export.get_clicked()) { Level l(get_current_file()); std::string s = get_current_file().get_rootless(); for (size_t i = 0; i < s.size(); ++i) if (s[i] == '/') s[i] = '-'; s += ".png"; l.export_image(Filename(s)); button_export.set_text(Language::browser_export_image_done); Sound::play_loud(Sound::DISKSAVE); } else if (button_delete.get_clicked()) { if (exists(get_current_file().get_rootful().c_str())) { std::string s1 = Language::editor_file_name + ' ' + get_current_file().get_rootless(); std::string s2 = Language::editor_level_name + ' ' + LevelMetaData(get_current_file()).get_name(); box_delete = new Api::BoxMessage(500, 3, Language::browser_box_delete_tit_lev); box_delete->add_text(Language::browser_box_delete_que_lev); box_delete->add_text(s1); box_delete->add_text(s2); box_delete->add_button(Language::common_yes,useR->key_me_okay); box_delete->add_button(Language::common_no, useR->key_me_exit); Manager::add_focus(box_delete); } } } // end of windows open/not open }
SingleBrowser::SingleBrowser() : BrowserBig(Language::browser_single_title, gloB->dir_levels, useR->single_last_level, true, false), // Checkmark-Stil, aber kein Replay-Stil button_edit (but_x, 40+but_yl, but_xl, but_yl), button_export(but_x, 360, but_xl), button_delete(but_x, 380, but_xl), info_author (but_x, stats_y, but_xl), info_initial (but_x, stats_y + 20, but_xl), rec_saved (but_x, stats_y + 40, but_xl), rec_skills (but_x, stats_y + 60, but_xl), rec_updates (but_x, stats_y + 80, but_xl), rec_altered_1(but_x, stats_y + 60, Language::browser_info_result_old_1), rec_altered_2(but_x, stats_y + 80, Language::browser_info_result_old_2), browser_save(0), box_delete (0) { add_child(button_edit); add_child(button_export); add_child(button_delete); add_child(info_author); add_child(info_initial); add_child(rec_saved); add_child(rec_skills); add_child(rec_updates); add_child(rec_altered_1); add_child(rec_altered_2); info_author .set_desc(Language::browser_info_author); info_author .set_value_not_blocky(); info_initial .set_desc(Language::browser_info_initgoal); rec_saved .set_desc(Language::browser_info_result_saved); rec_skills .set_desc(Language::browser_info_result_skills); rec_updates .set_desc(Language::browser_info_result_time); info_author .set_undraw_color(color[COL_API_M]); info_initial .set_undraw_color(color[COL_API_M]); rec_saved .set_undraw_color(color[COL_API_M]); rec_skills .set_undraw_color(color[COL_API_M]); rec_updates .set_undraw_color(color[COL_API_M]); button_export.set_undraw_color(color[COL_API_M]); button_delete.set_undraw_color(color[COL_API_M]); set_button_play_text (Language::browser_play); button_edit .set_text (Language::browser_edit); button_edit .set_hotkey(useR->key_me_edit); button_export.set_hotkey(useR->key_me_export); button_delete.set_text (Language::browser_delete); button_delete.set_hotkey(useR->key_me_delete); set_preview_y (40 + but_yl * 2 + but_y_spacing); set_preview_yl(88); on_file_highlight(get_current_file()); }
ReplayBrowser::ReplayBrowser() : BrowserBig(Language::browser_replay_title, gloB->dir_replay, useR->replay_last_level, false, true), // kein Checkmark-Stil, aber Replay-Stil button_extract(but_x, LEMSCR_Y - 180, but_xl, but_yl), button_delete (but_x, LEMSCR_Y - 120, but_xl, but_yl), label_info_player (but_x, get_info_y()), desc_info_player (but_x, get_info_y()), label_info_version(but_x, get_info_y() + 40), desc_info_version (but_x, get_info_y() + 40), label_info_built (but_x, get_info_y() + 60), desc_info_built (but_x, get_info_y() + 60), browser_save(0), box_delete (0) { add_child(button_extract); add_child(button_delete); add_child(desc_info_player); add_child(label_info_player); add_child(desc_info_version); add_child(label_info_version); add_child(desc_info_built); add_child(label_info_built); label_info_player.set_color(::color[COL_WHITE]); label_info_version.set_color(::color[COL_WHITE]); label_info_built.set_color(::color[COL_WHITE]); label_info_player .set_undraw_color(color[COL_API_M]); desc_info_player .set_undraw_color(color[COL_API_M]); label_info_version.set_undraw_color(color[COL_API_M]); desc_info_version .set_undraw_color(color[COL_API_M]); label_info_built .set_undraw_color(color[COL_API_M]); desc_info_built .set_undraw_color(color[COL_API_M]); set_button_play_text(Language::browser_replay); button_extract.set_text(Language::browser_extract); button_extract.set_hotkey(useR->key_me_export); button_extract.set_undraw_color(color[COL_API_M]); button_extract.hide(); button_delete .set_text(Language::browser_delete); button_delete .set_hotkey(useR->key_me_delete); button_delete .set_undraw_color(color[COL_API_M]); button_delete .hide(); on_file_highlight(get_current_file()); }
static inline int lwip_from_fd( int fd ) { struct file * file = get_current_file( fd ); if( !file ) return -1; //if( file->fops != &kfs_socket_fops ) //return -1; return lwip_connection( file ); }
void EditorFileDialog::set_current_file(const String &p_file) { file->set_text(p_file); update_dir(); invalidate(); int lp = p_file.find_last("."); if (lp != -1) { file->select(0, lp); file->grab_focus(); } if (is_visible_in_tree()) _request_single_thumbnail(get_current_dir().plus_file(get_current_file())); }
void EditorFileDialog::_item_selected(int p_item) { int current = p_item; if (current<0 || current>=item_list->get_item_count()) return; Dictionary d=item_list->get_item_metadata(current); if (!d["dir"]) { file->set_text(d["name"]); _request_single_thumbnail(get_current_dir().plus_file(get_current_file())); } }
int sys_fstat(int fd, uaddr_t buf) { int ret = -EBADF; struct file * const file = get_current_file( fd ); if( !file ) goto out; __lock(&_lock); if(file->inode) ret = kfs_stat(file->inode, buf); else printk(KERN_WARNING "Attempting fstat() on fd %d with no backing inode.\n", fd); out: __unlock(&_lock); return ret; }
ssize_t sys_writev(int fd, uaddr_t uvec, int count) { //int orig_fd = fd; struct iovec vector; struct file * const file = get_current_file( fd ); ssize_t ret = 0, tret; //if (file != NULL && file->pipe_end_type == PIPE_END_WRITE) { // fd = file->pipe_other_fd; // file = get_current_file( fd ); //} if(!file) return -EBADF; if(count < 0) return -EINVAL; if(!file->f_op->write) { printk( KERN_WARNING "%s: fd %d (%s) has no write operation\n", __func__, fd, file->inode->name); return -EINVAL; } while(count-- > 0) { if(copy_from_user(&vector, (char *)uvec, sizeof(struct iovec))) return -EFAULT; uvec += sizeof(struct iovec); tret = file->f_op->write(file, (char *)vector.iov_base, vector.iov_len, NULL); if(tret < 0) return -tret; else if(tret == 0) break; else ret += tret; } return ret; }
int sys_ioctl(unsigned int fd, unsigned int request, unsigned long arg) { int ret = -EBADF; struct file * const file = get_current_file( fd ); if( !file ) goto out; if( file->f_op->unlocked_ioctl ) ret = file->f_op->unlocked_ioctl( file, request, arg ); else if( file->f_op->ioctl ) ret = file->f_op->ioctl( file, request, arg ); else { printk("sys_ioctl %s : no ioctl!\n",file->inode->name); ret = -ENOTTY; } out: return ret; }
int sys_fcntl(int fd, int cmd, long arg) { int ret = -EBADF; struct file * const file = get_current_file( fd ); dbg( "%d %x %lx\n", fd, cmd, arg ); if(NULL == file) goto out; switch(cmd) { case F_GETFL: ret = file->f_flags; break; case F_SETFL: /* TODO: implement; currently we need at least O_NONBLOCK for IB verbs interface */ file->f_flags = arg; ret = 0; break; case F_GETFD: case F_SETFD: /* TODO: implement; we do need a place for per-fd flags first, though */ ret = 0; break; default: ret = -EINVAL; break; } out: return ret; /* not reached */ }
long sys_mmap( unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags, unsigned long fd, unsigned long off ) { struct aspace *as = current->aspace; struct file *file; struct vm_area_struct vma; unsigned long mmap_brk; int rv; if (len != round_up(len, PAGE_SIZE)) return -EINVAL; /* we only support anonymous private mapping; file-backed private mapping has copy-on-write semantics, which we don't want due to complete lack of any pagefaulting resolution */ if((flags & MAP_PRIVATE) && !(flags & MAP_ANONYMOUS)) return -EINVAL; /* anonymous mappings (not backed by a file) are handled specially */ if(flags & MAP_ANONYMOUS) { /* anonymous mmap()ed memory is put at the top of the heap region, and grows from high to low addresses, i.e. down towards the current heap end. */ spin_lock(&as->lock); mmap_brk = round_down(as->mmap_brk - len, PAGE_SIZE); /* Protect against extending into the UNIX data segment, or becoming negative (which wraps around to large addr) */ if ((mmap_brk <= as->brk) || (mmap_brk >= as->mmap_brk)) { spin_unlock(&as->lock); return -ENOMEM; } as->mmap_brk = mmap_brk; spin_unlock(&as->lock); paddr_t phys; if ( __aspace_virt_to_phys( as, mmap_brk, & phys ) ) { panic("sys_mmap() failed to get physical address\n"); } memset( __va(phys), 0, len ); return mmap_brk; } /* file-backed mappings */ /* TODO: add a million checks here that we'll simply ignore now */ file = get_current_file(fd); if(NULL == file) return -EBADF; if(NULL == file->f_op || NULL == file->f_op->mmap) return -ENODEV; spin_lock(&as->lock); if ((rv = __aspace_find_hole(as, addr, len, PAGE_SIZE, &addr))) { spin_unlock(&as->lock); return -ENOMEM; } if ((rv = __aspace_add_region(as, addr, len, VM_READ|VM_WRITE|VM_USER, PAGE_SIZE, "mmap"))) { /* assuming there is no race between find_hole and add_region, as we're holding the as->lock, this failure can't be due to someone adding our region in between */ spin_unlock(&as->lock); return -ENOMEM; } spin_unlock(&as->lock); /* fill the vm_area_struct to keep compatible with linux layer */ vma.vm_start = addr; vma.vm_end = addr + len; vma.vm_page_prot = __pgprot(VM_READ|VM_WRITE); vma.vm_pgoff = 0; rv = file->f_op->mmap(file, &vma); if(rv) { spin_lock(&as->lock); __aspace_del_region(as, addr, len); spin_unlock(&as->lock); return rv; } return vma.vm_start; }
ssize_t sys_read(int fd, char __user * buf, size_t len) { char buffer[PIPE_BUFFER_MAX+1]; char temp[PIPE_BUFFER_MAX+1]; unsigned long flags; //int orig_fd = fd; ssize_t ret; struct file * file = get_current_file(fd); if (!file) { ret = -EBADF; } else if (file->pipe != NULL) { int result = min((size_t)PIPE_BUFFER_MAX, len); //printk("sys_read(%d): trying to read %d\n", orig_fd, result); buffer[0] = 0; // make sure it's null-terminated int n = 0; //printk("sys_read(%d): LOCKING reading via pipe\n", orig_fd); spin_lock_irqsave(&file->pipe->buffer_lock, flags); while (n < result) { // If the buffer is empty, wait until it fills a bit while (pipe_buffer_empty(file->pipe)) { //printk("sys_read: UNLOCKING and WAITING\n"); spin_unlock_irqrestore(&file->pipe->buffer_lock, flags); if (wait_event_interruptible(file->pipe->buffer_wait, (!pipe_buffer_empty(file->pipe)))) return -ERESTARTSYS; //printk("sys_read: LOCKING\n"); spin_lock_irqsave(&file->pipe->buffer_lock, flags); } int num_to_read = min(result-n, file->pipe->amount); //printk("sys_read(): read %d = '%s'\n", num_to_read, file->pipe->buffer); strncat(buffer+n, file->pipe->buffer, num_to_read); strncpy(temp, file->pipe->buffer+num_to_read, PIPE_BUFFER_MAX+1-num_to_read); // XXX strncpy(file->pipe->buffer, temp, PIPE_BUFFER_MAX+1); buffer[num_to_read] = 0; // make sure it's null-terminated n += num_to_read; // notify everybody about our deletion from the buffer file->pipe->amount -= num_to_read; waitq_wakeup(&file->pipe->buffer_wait); break; } result = n; int rc = copy_to_user(buf, buffer, result); //printk("sys_read(%d): pipe buffer: '%s'\n", orig_fd, file->pipe->buffer); //printk("sys_read: UNLOCKING\n"); spin_unlock_irqrestore(&file->pipe->buffer_lock, flags); ret = rc ? -EFAULT : result; } else if (file->f_op->read) { ret = file->f_op->read( file, (char *)buf, len, NULL ); } else { printk( KERN_WARNING "%s: fd %d (%s) has no read operation\n", __func__, fd, file->inode->name ); ret = -EBADF; } //printk("sys_read(%d): returning %d\n", fd, ret); return ret; }
static int browser(void* param) { int ret_val; #ifdef HAVE_TAGCACHE struct tree_context* tc = tree_get_context(); #endif int filter = SHOW_SUPPORTED; char folder[MAX_PATH] = "/"; /* stuff needed to remember position in file browser */ static char last_folder[MAX_PATH] = "/"; /* and stuff for the database browser */ #ifdef HAVE_TAGCACHE static int last_db_dirlevel = 0, last_db_selection = 0; #endif switch ((intptr_t)param) { case GO_TO_FILEBROWSER: filter = global_settings.dirfilter; if (global_settings.browse_current && last_screen == GO_TO_WPS && current_track_path[0]) { strcpy(folder, current_track_path); } else if (!strcmp(last_folder, "/")) { strcpy(folder, global_settings.start_directory); } else { #ifdef HAVE_HOTSWAP bool in_hotswap = false; /* handle entering an ejected drive */ int i; for (i = 0; i < NUM_VOLUMES; i++) { char vol_string[VOL_ENUM_POS + 8]; if (!storage_removable(i)) continue; /* VOL_NAMES contains a %d */ snprintf(vol_string, sizeof(vol_string), "/"VOL_NAMES, i); /* test whether we would browse the external card */ if (!storage_present(i) && (strstr(last_folder, vol_string) #ifdef HAVE_HOTSWAP_STORAGE_AS_MAIN || (i == 0) #endif )) { /* leave folder as "/" to avoid crash when trying * to access an ejected drive */ strcpy(folder, "/"); in_hotswap = true; break; } } if (!in_hotswap) #endif strcpy(folder, last_folder); } break; #ifdef HAVE_TAGCACHE case GO_TO_DBBROWSER: if (!tagcache_is_usable()) { bool reinit_attempted = false; /* Now display progress until it's ready or the user exits */ while(!tagcache_is_usable()) { struct tagcache_stat *stat = tagcache_get_stat(); /* Allow user to exit */ if (action_userabort(HZ/2)) break; /* Maybe just needs to reboot due to delayed commit */ if (stat->commit_delayed) { splash(HZ*2, ID2P(LANG_PLEASE_REBOOT)); break; } /* Check if ready status is known */ if (!stat->readyvalid) { splash(0, str(LANG_TAGCACHE_BUSY)); continue; } /* Re-init if required */ if (!reinit_attempted && !stat->ready && stat->processed_entries == 0 && stat->commit_step == 0) { /* Prompt the user */ reinit_attempted = true; static const char *lines[]={ ID2P(LANG_TAGCACHE_BUSY), ID2P(LANG_TAGCACHE_FORCE_UPDATE)}; static const struct text_message message={lines, 2}; if(gui_syncyesno_run(&message, NULL, NULL) == YESNO_NO) break; int i; FOR_NB_SCREENS(i) screens[i].clear_display(); /* Start initialisation */ tagcache_rebuild(); } /* Display building progress */ static long talked_tick = 0; if(global_settings.talk_menu && (talked_tick == 0 || TIME_AFTER(current_tick, talked_tick+7*HZ))) { talked_tick = current_tick; if (stat->commit_step > 0) { talk_id(LANG_TAGCACHE_INIT, false); talk_number(stat->commit_step, true); talk_id(VOICE_OF, true); talk_number(tagcache_get_max_commit_step(), true); } else if(stat->processed_entries) { talk_number(stat->processed_entries, false); talk_id(LANG_BUILDING_DATABASE, true); } } if (stat->commit_step > 0) { if (lang_is_rtl()) { splashf(0, "[%d/%d] %s", stat->commit_step, tagcache_get_max_commit_step(), str(LANG_TAGCACHE_INIT)); } else { splashf(0, "%s [%d/%d]", str(LANG_TAGCACHE_INIT), stat->commit_step, tagcache_get_max_commit_step()); } } else { splashf(0, str(LANG_BUILDING_DATABASE), stat->processed_entries); } } } if (!tagcache_is_usable()) return GO_TO_PREVIOUS; filter = SHOW_ID3DB; tc->dirlevel = last_db_dirlevel; tc->selected_item = last_db_selection; break; #endif case GO_TO_BROWSEPLUGINS: filter = SHOW_PLUGINS; strlcpy(folder, PLUGIN_DIR, MAX_PATH); break; } ret_val = rockbox_browse(folder, filter); switch ((intptr_t)param) { case GO_TO_FILEBROWSER: if (!get_current_file(last_folder, MAX_PATH) || (!strchr(&last_folder[1], '/') && global_settings.start_directory[1] != '\0')) { last_folder[0] = '/'; last_folder[1] = '\0'; } break; #ifdef HAVE_TAGCACHE case GO_TO_DBBROWSER: last_db_dirlevel = tc->dirlevel; last_db_selection = tc->selected_item; break; #endif } return ret_val; }
/* main loop, handles key events */ static int dirbrowse(void) { int numentries=0; char buf[MAX_PATH]; int button, oldbutton; bool reload_root = false; int lastfilter = *tc.dirfilter; bool lastsortcase = global_settings.sort_case; bool exit_func = false; char* currdir = tc.currdir; /* just a shortcut */ #ifdef HAVE_TAGCACHE bool id3db = *tc.dirfilter == SHOW_ID3DB; if (id3db) curr_context=CONTEXT_ID3DB; else #endif curr_context=CONTEXT_TREE; if (tc.selected_item < 0) tc.selected_item = 0; #ifdef HAVE_TAGCACHE tc.firstpos = 0; lasttable = -1; lastextra = -1; lastfirstpos = 0; #endif start_wps = false; numentries = update_dir(); reload_dir = false; if (numentries == -1) return GO_TO_PREVIOUS; /* currdir is not a directory */ if (*tc.dirfilter > NUM_FILTER_MODES && numentries==0) { splash(HZ*2, ID2P(LANG_NO_FILES)); return GO_TO_PREVIOUS; /* No files found for rockbox_browse() */ } gui_synclist_draw(&tree_lists); while(1) { bool restore = false; if (tc.dirlevel < 0) tc.dirlevel = 0; /* shouldnt be needed.. this code needs work! */ button = get_action(CONTEXT_TREE, list_do_action_timeout(&tree_lists, HZ/2)); oldbutton = button; gui_synclist_do_button(&tree_lists, &button,LIST_WRAP_UNLESS_HELD); tc.selected_item = gui_synclist_get_sel_pos(&tree_lists); switch ( button ) { case ACTION_STD_OK: /* nothing to do if no files to display */ if ( numentries == 0 ) break; short attr = tree_get_entry_at(&tc, tc.selected_item)->attr; if ((tc.browse->flags & BROWSE_SELECTONLY) && !(attr & ATTR_DIRECTORY)) { tc.browse->flags |= BROWSE_SELECTED; get_current_file(tc.browse->buf, tc.browse->bufsize); return GO_TO_PREVIOUS; } #ifdef HAVE_TAGCACHE switch (id3db?tagtree_enter(&tc):ft_enter(&tc)) #else switch (ft_enter(&tc)) #endif { case GO_TO_FILEBROWSER: reload_dir = true; break; case GO_TO_WPS: return GO_TO_WPS; #if CONFIG_TUNER case GO_TO_FM: return GO_TO_FM; #endif case GO_TO_ROOT: exit_func = true; break; default: break; } restore = true; break; case ACTION_STD_CANCEL: if (*tc.dirfilter > NUM_FILTER_MODES && tc.dirlevel < 1) { exit_func = true; break; } if ((*tc.dirfilter == SHOW_ID3DB && tc.dirlevel == 0) || ((*tc.dirfilter != SHOW_ID3DB && !strcmp(currdir,"/")))) { #ifdef HAVE_LCD_BITMAP /* charcell doesnt have ACTION_TREE_PGLEFT so this isnt needed */ if (oldbutton == ACTION_TREE_PGLEFT) break; else #endif return GO_TO_ROOT; } #ifdef HAVE_TAGCACHE if (id3db) tagtree_exit(&tc); else #endif if (ft_exit(&tc) == 3) exit_func = true; restore = true; break; case ACTION_TREE_STOP: if (list_stop_handler()) restore = true; break; case ACTION_STD_MENU: return GO_TO_ROOT; break; #ifdef HAVE_RECORDING case ACTION_STD_REC: return GO_TO_RECSCREEN; #endif case ACTION_TREE_WPS: return GO_TO_PREVIOUS_MUSIC; break; #ifdef HAVE_QUICKSCREEN case ACTION_STD_QUICKSCREEN: /* don't enter f2 from plugin browser */ if (*tc.dirfilter < NUM_FILTER_MODES) { if (quick_screen_quick(button)) reload_dir = true; restore = true; } break; #endif #ifdef BUTTON_F3 case ACTION_F3: /* don't enter f3 from plugin browser */ if (*tc.dirfilter < NUM_FILTER_MODES) { if (quick_screen_f3(ACTION_F3)) reload_dir = true; restore = true; } break; #endif #ifdef HAVE_HOTKEY case ACTION_TREE_HOTKEY: if (!global_settings.hotkey_tree) break; /* fall through */ #endif case ACTION_STD_CONTEXT: { bool hotkey = button == ACTION_TREE_HOTKEY; int onplay_result; int attr = 0; if (tc.browse->flags & BROWSE_NO_CONTEXT_MENU) break; if(!numentries) onplay_result = onplay(NULL, 0, curr_context, hotkey); else { #ifdef HAVE_TAGCACHE if (id3db) { if (tagtree_get_attr(&tc) == FILE_ATTR_AUDIO) { attr = FILE_ATTR_AUDIO; tagtree_get_filename(&tc, buf, sizeof(buf)); } else attr = ATTR_DIRECTORY; } else #endif { struct entry *entry = tree_get_entry_at(&tc, tc.selected_item); attr = entry->attr; if (currdir[1]) /* Not in / */ snprintf(buf, sizeof buf, "%s/%s", currdir, entry->name); else /* In / */ snprintf(buf, sizeof buf, "/%s", entry->name); } onplay_result = onplay(buf, attr, curr_context, hotkey); } switch (onplay_result) { case ONPLAY_MAINMENU: return GO_TO_ROOT; case ONPLAY_OK: restore = true; break; case ONPLAY_RELOAD_DIR: reload_dir = true; break; case ONPLAY_START_PLAY: return GO_TO_WPS; break; } break; } #ifdef HAVE_HOTSWAP case SYS_FS_CHANGED: #ifdef HAVE_TAGCACHE if (!id3db) #endif reload_dir = true; /* The 'dir no longer valid' situation will be caught later * by checking the showdir() result. */ break; #endif default: if (default_event_handler(button) == SYS_USB_CONNECTED) { if(*tc.dirfilter > NUM_FILTER_MODES) /* leave sub-browsers after usb, doing otherwise might be confusing to the user */ exit_func = true; else reload_dir = true; } break; } if (start_wps) return GO_TO_WPS; if (button && !IS_SYSEVENT(button)) { storage_spin(); } check_rescan: /* do we need to rescan dir? */ if (reload_dir || reload_root || lastfilter != *tc.dirfilter || lastsortcase != global_settings.sort_case) { if (reload_root) { strcpy(currdir, "/"); tc.dirlevel = 0; #ifdef HAVE_TAGCACHE tc.currtable = 0; tc.currextra = 0; lasttable = -1; lastextra = -1; #endif reload_root = false; } if (!reload_dir) { gui_synclist_select_item(&tree_lists, 0); gui_synclist_draw(&tree_lists); tc.selected_item = 0; lastdir[0] = 0; } lastfilter = *tc.dirfilter; lastsortcase = global_settings.sort_case; restore = true; } if (exit_func) return GO_TO_PREVIOUS; if (restore || reload_dir) { /* restore display */ numentries = update_dir(); reload_dir = false; if (currdir[1] && (numentries < 0)) { /* not in root and reload failed */ reload_root = true; /* try root */ goto check_rescan; } } } return true; }
void ReplayBrowser::calc_self() { BrowserBig::calc_self(); if (browser_save) { browser_save->set_draw_required(); if (browser_save->get_exit()) { if (browser_save->get_exit_with()) { useR->single_last_level = browser_save->get_current_file(); // Replay-Verzeichnis und -Datei wurden aktualisiert, als // auf den Extraktions-Button gedrueckt wurde // Extract exactly the replay, not the level it points to! Level l(get_current_file()); l.save_to_file(browser_save->get_current_file()); Sound::play_loud(Sound::DISKSAVE); load_dir(get_current_file()); } delete browser_save; browser_save = 0; set_draw_required(); } } else if (box_delete) { box_delete->set_draw_required(); // Damit Buttons eingedrueckt werd. switch (box_delete->get_button_clicked()) { case 1: { Filename to_delete = get_current_file(); highlight_neighboring_level_before_deletion(); ::delete_file(to_delete.get_rootful().c_str()); } load_dir(get_current_file()); // falls through case 2: delete box_delete; box_delete = 0; set_draw_required(); break; default: ; } } // Replaybrowser normal, also ohne Extraktionsdialog else { if (!button_extract.get_hidden() && button_extract.get_clicked()) { useR->replay_last_level = get_current_file(); browser_save = new Api::SaveBrowser(gloB->dir_levels, gloB->ext_level, useR->single_last_level, Api::SaveBrowser::search_criterion_level, Api::SaveBrowser::new_box_overwrite_level); browser_save->set_y(50); // mittig, nicht der Editor-Standard browser_save->set_info_level_name(LevelMetaData( useR->replay_last_level).get_name()); browser_save->set_info_filename(useR->replay_last_level); Manager::add_focus(browser_save); } else if (!button_delete.get_hidden() && button_delete.get_clicked()) { if (exists(get_current_file().get_rootful().c_str())) { Replay r(get_current_file()); std::string s1 = Language::editor_file_name + ' ' + get_current_file().get_rootless(); std::string s2 = Language::editor_level_name + ' ' + LevelMetaData(r.get_level_filename()).get_name(); box_delete = new Api::BoxMessage(500, 3, Language::browser_box_delete_tit_rep); box_delete->add_text(Language::browser_box_delete_que_rep); box_delete->add_text(s1); box_delete->add_text(s2); box_delete->add_button(Language::common_yes,useR->key_me_okay); box_delete->add_button(Language::common_no, useR->key_me_exit); Manager::add_focus(box_delete); } } // Den normalen Dialog-Siedler-2-Rechtsklick realisieren: else if (hardware.get_mr()) { set_exit_with(EXIT_WITH_EXIT); } } }