Index: edit.c ================================================================== --- edit.c +++ edit.c @@ -17,11 +17,12 @@ Uint16 class; Uint8 img,dir; Value misc1,misc2,misc3; } MRU; -static MRU mru[32]; +#define MRUCOUNT 32 +static MRU mru[MRUCOUNT]; static int curmru; static void redraw_editor(void) { char buf[32]; SDL_Rect r; @@ -71,26 +72,26 @@ x=x>=left_margin?(x-left_margin)/picture_size+1:0; y=y/picture_size+1; if(x>0 && y>0 && x<=pfwidth && y<=pfheight) snprintf(buf,8,"(%2d,%2d)",x,y); else strcpy(buf," "); draw_text(0,40,buf,0xF0,0xF3); - for(x=0;x<32;x++) { + for(x=0;xscreen->h) break; if(x==curmru) draw_text(0,y,">",0xF0,0xFE); if(mru[x].misc1.u|mru[x].misc1.t|mru[x].misc2.u|mru[x].misc2.t|mru[x].misc3.u|mru[x].misc3.t) draw_text(picture_size+16,y,"*",0xF0,0xFB); } SDL_UnlockSurface(screen); r.w=r.h=picture_size; r.x=8; - for(x=0;x<32;x++) { + for(x=0;xscreen->h) break; if(mru[x].class) { r.y=y; SDL_FillRect(screen,&r,0x00); - draw_picture(8,y,classes[mru[x].class]->images[mru[x].img]); + draw_picture(8,y,classes[mru[x].class]->images[mru[x].img]&0x7FFF); } } SDL_Flip(screen); } @@ -124,10 +125,20 @@ } s=sqlite3_str_finish(m); if(s) SDL_WM_SetCaption(s,s); else SDL_WM_SetCaption("Free Hero Mesh","Free Hero Mesh"); sqlite3_free(s); } + +static void add_mru(int cl,int img) { + int i; + for(i=0;inimages;i++) if(classes[cl]->images[i]&0x8000) imglist[imgcount++]=i; img=*imglist; - goto redraw; } else { i=imgscroll+ev.button.y/picture_size; if(i<0 || i>=imgcount) break; img=imglist[i]; - goto redraw; } - break; + if(ev.button.button==3 || ev.button.button==2) add_mru(cl,img); + if(ev.button.button==2) return; + goto redraw; case SDL_KEYDOWN: switch(ev.key.keysym.sym) { case SDLK_HOME: clscroll=0; goto redraw; case SDLK_END: clscroll=clcount-screen->h/8; goto redraw; case SDLK_PAGEDOWN: clscroll+=screen->h/8; goto redraw; case SDLK_PAGEUP: clscroll-=screen->h/8; goto redraw; case SDLK_ESCAPE: return; - case SDLK_TAB: namei=0; goto redraw; + case SDLK_CLEAR: case SDLK_DELETE: namei=0; goto redraw; case SDLK_BACKSPACE: if(namei) --namei; goto redraw; + case SDLK_TAB: + if(!cl) break; + strncpy(name,classes[cl]->name,254); + for(j=0;jname[namei]) { + for(i=j+1;iname,namei)) { + // The first part of the name doesn't match; all others did, so accept the next letter. + break; + } else { + if(sqlite3_strnicmp(classes[cl]->name+namei,classes[cllist[i]]->name+namei,1)) { + // The first part of the name matches but the next letter doesn't. + goto redraw; + } else { + // The first part and next letter are both matching; see if the next one also matches. + continue; + } + } + } + ++namei; + } + goto redraw; default: j=ev.key.keysym.unicode; + if(j=='$' || j==21) { + namei=0; + goto redraw; + } if(j>32 && j<127 && namei<254) { name[namei++]=j; for(i=0;iname,namei)) { ev.button.button=1;