/[enigma]/enigma/src/menus.cc
ViewVC logotype

Diff of /enigma/src/menus.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.19 by reallysoft, Sat Mar 29 17:05:24 2003 UTC revision 1.20 by mhawlisch, Thu Apr 3 11:10:27 2003 UTC
# Line 263  LevelWidget::next_unsolved() Line 263  LevelWidget::next_unsolved()
263  void  void
264  LevelWidget::draw (px::GC &gc, const px::Rect &r)  LevelWidget::draw (px::GC &gc, const px::Rect &r)
265  {  {
     areas.clear();  
   
266      const int imgw = 120; //238;      const int imgw = 120; //238;
267      const int imgh = 78;      const int imgh = 78;
268      const int hgap = 30, vgap=40;      const int hgap = 30, vgap=40;
# Line 282  LevelWidget::draw (px::GC &gc, const px: Line 280  LevelWidget::draw (px::GC &gc, const px:
280      {      {
281          for (int x=0; x<width; x++, i++)          for (int x=0; x<width; x++, i++)
282          {          {
283              if (i >= level_pack->size())              if (i >= level_pack->size()) {
284                    for( ; (i-ifirst) <= areas.size(); areas.pop_back())  // remove unused areas from the list
285                  goto done_painting;                  goto done_painting;
286                }
287    
288              int xpos = x0 + x*(imgw + hgap);              int xpos = x0 + x*(imgw + hgap);
289              int ypos = y0 + y*(imgh + vgap);              int ypos = y0 + y*(imgh + vgap);
290              areas.push_back(Rect(xpos-10, ypos-10, imgw+20, imgh+35));              if( r.overlaps(Rect(xpos-10, ypos-10, imgw+20, imgh+35))    // This area is requested
291                    || r.w == 0)    // repaint whole screen
292                {
293                    if( (i-ifirst) >= areas.size())
294                        areas.push_back(Rect(xpos-10, ypos-10, imgw+20, imgh+35));
295                    else
296                        areas[(i-ifirst)] = Rect(xpos-10, ypos-10, imgw+20, imgh+35);
297    
298  //             if (i == (unsigned) iselected) {  //             if (i == (unsigned) iselected) {
299  //                 set_color(gc, 255,0,0);  //                 set_color(gc, 255,0,0);
# Line 299  LevelWidget::draw (px::GC &gc, const px: Line 305  LevelWidget::draw (px::GC &gc, const px:
305    
306              if (i == (unsigned) iselected) {              if (i == (unsigned) iselected) {
307  //                Rect imgr (xpos,ypos,imgw, imgh);  //                Rect imgr (xpos,ypos,imgw, imgh);
308                  Rect imgr = areas.back();                  Rect imgr = areas[(i-ifirst)];
309    
310                  px::TintRect (video::GetScreen(), intersect(imgr, r),                  px::TintRect (video::GetScreen(), intersect(imgr, r),
311                                120,120,120,120);                                120,120,120,120);
312                  set_color(gc, 200,200,200);                  set_color(gc, 200,200,200);
313                  Rect a=areas.back();                  Rect a = areas[(i-ifirst)];
314                  frame(gc, a);                  frame(gc, a);
315              }              }
316    
317              info = level_pack->get_info(i);              info = level_pack->get_info(i);
318              string fname = string("levels/") + info->filename + ".png";              string fname = string("levels/") + info->filename + ".png";
319              if (Surface *img = cache.get(enigma::FindDataFile(fname)))              Surface *img = cache.get(enigma::FindDataFile(fname));
320                if( !img) {
321                    img = LevelPreview( level_pack, i);
322                    if( img) {
323                        fprintf(stderr,"ZOOM!\n");
324                        img = img->zoom( imgw,imgh);
325                    } else img = 0;
326                }
327                if (img )
328                  blit (gc, xpos, ypos, img);                  blit (gc, xpos, ypos, img);
329    
   
   
330              options::LevelStatus *ls;              options::LevelStatus *ls;
331    
332              if ((ls=options::GetLevelStatus(level_pack->name(),              if ((ls=options::GetLevelStatus(level_pack->name(),
# Line 330  LevelWidget::draw (px::GC &gc, const px: Line 342  LevelWidget::draw (px::GC &gc, const px:
342                                ypos+imgh+1,                                ypos+imgh+1,
343                                tstr.c_str());                                tstr.c_str());
344          }          }
345            }
346      }      }
347    done_painting:    done_painting:
348    
# Line 352  LevelWidget::set_selected (int newfirst, Line 365  LevelWidget::set_selected (int newfirst,
365          sound::PlaySound("menumove");          sound::PlaySound("menumove");
366          ifirst = newfirst;          ifirst = newfirst;
367          iselected = Max(Min(newsel, numlevels-1), 0);          iselected = Max(Min(newsel, numlevels-1), 0);
368          redraw();          redraw();   // Scroll the level list -> redraw whole screen
369      }      }
370      else if (newsel!=iselected && newsel>=0 && newsel<numlevels)      else if (newsel!=iselected && newsel>=0 && newsel<numlevels)
371      {      {
372          sound::PlaySound("menumove");          sound::PlaySound("menumove");
373    
374            int oldfirst = ifirst;
375            int oldsel = iselected;
376    
377          while (newsel < ifirst)          while (newsel < ifirst)
378              ifirst -= width;              ifirst -= width;
379          while (newsel >= ifirst+width*height)          while (newsel >= ifirst+width*height)
380              ifirst += width;              ifirst += width;
381    
382          iselected = newsel;          iselected = newsel;
383          redraw();  
384            if( oldfirst != ifirst)
385                redraw();   // Scroll the level list -> redraw whole screen
386            else
387            {
388                redraw(Rect(5,460,400,19)); // level name at the bottom line
389                redraw(areas[oldsel-ifirst]);      // old selection
390                redraw(areas[iselected-ifirst]);   // new selection
391            }
392      }      }
393  }  }
394    
# Line 380  LevelWidget::on_event(const SDL_Event &e Line 406  LevelWidget::on_event(const SDL_Event &e
406                      newsel = ifirst+i;                      newsel = ifirst+i;
407                      break;                      break;
408                  }                  }
409              if (newsel != iselected) {                  set_current(newsel);
                 redraw(areas[newsel-ifirst]);  
                 redraw(areas[iselected-ifirst]);  
                 redraw(Rect(5,460,400,19));  
                 iselected=newsel;  
410                  h=true;                  h=true;
             }  
411          }          }
412          break;          break;
413      case SDL_MOUSEBUTTONDOWN:      case SDL_MOUSEBUTTONDOWN:

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.20

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26