/[enigma]/enigma/display.cc
ViewVC logotype

Diff of /enigma/display.cc

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

revision 1.9 by dheck, Wed Oct 23 19:21:39 2002 UTC revision 1.10 by dheck, Sat Oct 26 23:51:00 2002 UTC
# Line 64  static void define_model(const char *nam Line 64  static void define_model(const char *nam
64  static Model2d *make_model2d(const string &name);  static Model2d *make_model2d(const string &name);
65  static void draw_sprites(SpriteLayer l, bool shades, GC &gc);  static void draw_sprites(SpriteLayer l, bool shades, GC &gc);
66    
67    static void follow_center();
68    
69  namespace  namespace
70  {  {
71      class Window {      class Window {
# Line 230  StatusBarImpl::tick (double dtime) Line 232  StatusBarImpl::tick (double dtime)
232          m_changedp = m_textview.has_changed();          m_changedp = m_textview.has_changed();
233      }      }
234    
235        double oldtime=m_leveltime;
236      m_leveltime += dtime;      m_leveltime += dtime;
237        if (m_showtime_p && int(m_leveltime) - int(oldtime) >= 1)
238            m_changedp = true;      // update clock
239  }  }
240    
241  void  void
# Line 769  display::Shutdown() Line 774  display::Shutdown()
774  void  void
775  display::NewWorld(int w, int h)  display::NewWorld(int w, int h)
776  {  {
777        SetFollowMode(FOLLOW_NONE);
778      delete level;      delete level;
779      level = new Level(w, h);      level = new Level(w, h);
780    
# Line 781  display::NewWorld(int w, int h) Line 787  display::NewWorld(int w, int h)
787      NumEffectSprites = 0;      NumEffectSprites = 0;
788    
789      sprites.clear();      sprites.clear();
     mark_redraw_screen();  
790      status_bar->new_world();      status_bar->new_world();
791        mark_redraw_screen();
792  }  }
793    
794  //----------------------------------------------------------------------  //----------------------------------------------------------------------
# Line 795  namespace Line 801  namespace
801      public:      public:
802          virtual ~Follow() {}          virtual ~Follow() {}
803          virtual void tick(double dtime) = 0;          virtual void tick(double dtime) = 0;
804            virtual void center() =0;
805      };      };
806    
807      class Follow_Screen : public Follow {      class Follow_Screen : public Follow {
808      public:      public:
809          void tick(double dtime);          void tick(double dtime);
810            void center();
811      };      };
812    
813      class Follow_Scrolling : public Follow {      class Follow_Scrolling : public Follow {
814      public:      public:
815          Follow_Scrolling();          Follow_Scrolling();
816          void tick(double dtime);          void tick(double dtime);
817            void center();
818      private:      private:
819          bool currently_scrolling;          bool currently_scrolling;
820          V3 curpos, destpos;          V3 curpos, destpos;
# Line 863  SetScreenOffset(double xoff, double yoff Line 872  SetScreenOffset(double xoff, double yoff
872      }      }
873  }  }
874    
875    
876    void
877    Follow_Screen::center()
878    {
879        tick(0);
880    }
881    
882  /* Determine whether the screen must be scrolled or not, and change  /* Determine whether the screen must be scrolled or not, and change
883     the coordinate origin of the screen accordingly. */     the coordinate origin of the screen accordingly. */
884  void  void
# Line 908  Follow_Scrolling::Follow_Scrolling() Line 924  Follow_Scrolling::Follow_Scrolling()
924        scrollspeed(0), resttime(0)        scrollspeed(0), resttime(0)
925  {}  {}
926    
927    void
928    Follow_Scrolling::center()
929    {
930        tick(1000);
931        tick(1000);
932    }
933    
934  void  void
935  Follow_Scrolling::tick(double dtime)  Follow_Scrolling::tick(double dtime)
# Line 968  follow_doit(double dtime) Line 990  follow_doit(double dtime)
990      }      }
991  }  }
992    
993    static void
994    follow_center()
995    {
996        if (follow_mode == FOLLOW_NONE)
997            SetFollowMode(FOLLOW_SCREEN);
998        if (follow_sprite != magic_spriteid) {
999            follower->center();
1000        }
1001    }
1002    
1003  void  void
1004  display::FollowSprite(SpriteId id)  display::FollowSprite(SpriteId id)
1005  {  {
1006      follow_sprite = id;      follow_sprite = id;
1007  //     follow_screen();      follow_center();
1008  }  }
1009    
1010  void  FollowMode
1011  display::SetFollowMode(FollowMode m)  display::SetFollowMode(FollowMode m)
1012  {  {
1013        FollowMode old=follow_mode;
1014      if (m != follow_mode)      if (m != follow_mode)
1015      {      {
1016          delete follower;          delete follower;
# Line 988  display::SetFollowMode(FollowMode m) Line 1021  display::SetFollowMode(FollowMode m)
1021          case FOLLOW_SCREEN: follower = new Follow_Screen; break;          case FOLLOW_SCREEN: follower = new Follow_Screen; break;
1022          };          };
1023      }      }
1024        return old;
1025  }  }
1026    
1027  //----------------------------------------  //----------------------------------------
# Line 1319  display::ToggleFlag(DisplayFlags flag) Line 1353  display::ToggleFlag(DisplayFlags flag)
1353      display_flags = DisplayFlags(display_flags ^ flag);      display_flags = DisplayFlags(display_flags ^ flag);
1354  }  }
1355    
 void  
 display::RedrawAll(Screen *scr, bool update_screenp)  
 {  
     mark_redraw_screen();  
     Redraw(scr, update_screenp);  
 }  
   
 static void  
 update_field(int x, int y)  
 {  
     shadow_layer->update(x,y);  
 }      
   
1356  static inline void  static inline void
1357  draw_model(GC &gc, int x, int y, Model2d *m)  draw_model(GC &gc, int x, int y, Model2d *m)
1358  {  {
# Line 1364  draw_field(GC &gc, Field &f, int x, int Line 1385  draw_field(GC &gc, Field &f, int x, int
1385  static Uint32 last_frame_time = 0;  static Uint32 last_frame_time = 0;
1386    
1387  void  void
1388  display::Redraw(Screen *screen, bool update_screenp)  display::DrawAll(px::GC &gc)
1389    {
1390        WorldArea wa = screen_to_world (gamearea);
1391    
1392        int x2 = wa.x+wa.w;
1393        int y2 = wa.y+wa.h;
1394        for (int x=wa.x; x<x2; x++) {
1395            for (int y=wa.y; y<y2; y++) {
1396                Field &f = fields(x,y);
1397                if (f.updatep) {
1398                    shadow_layer->update(x,y);
1399                    f.updatep = false;
1400                }
1401                ScreenArea sa(int((x-ScrollX)*TileWidth),
1402                              int((y-ScrollY)*TileHeight),
1403                              TileWidth,
1404                              TileHeight);
1405                sa.intersect(gamearea);
1406                clip(gc, sa);
1407                draw_field(gc, f, x,y);
1408            }
1409        }
1410        status_bar->redraw (gc, inventoryarea);
1411    }
1412    
1413    void
1414    display::RedrawAll(Screen *scr)
1415    {
1416        mark_redraw_screen();
1417        Redraw(scr);
1418    }
1419    
1420    void
1421    display::Redraw(Screen *screen)
1422  {  {
1423      GC gc(screen->get_drawable());      GC gc(screen);
1424      clip(gc, gamearea);      clip(gc, gamearea);
1425      WorldArea wa = screen_to_world (gamearea);      WorldArea wa = screen_to_world (gamearea);
1426    
1427      int x2 = Min(level->width, wa.x+wa.w);      int x2 = wa.x+wa.w;
1428      int y2 = Min(level->height, wa.y+wa.h);      int y2 = wa.y+wa.h;
1429      for (int x=wa.x; x<x2; x++) {      for (int x=wa.x; x<x2; x++) {
1430          for (int y=wa.y; y<y2; y++) {          for (int y=wa.y; y<y2; y++) {
1431              Field &f = fields(x,y);              Field &f = fields(x,y);
1432              if (f.updatep) {              if (f.updatep) {
1433                  update_field(x,y);                  shadow_layer->update(x,y);
1434                  f.redrawp = true;                  f.redrawp = true;
1435                  f.updatep = false;                  f.updatep = false;
1436              }              }
# Line 1393  display::Redraw(Screen *screen, bool upd Line 1447  display::Redraw(Screen *screen, bool upd
1447              }              }
1448          }          }
1449      }      }
1450      if (status_bar->has_changed())      if (status_bar->has_changed()) {
     {  
1451          status_bar->redraw (gc, inventoryarea);          status_bar->redraw (gc, inventoryarea);
1452          screen->update_rect(inventoryarea);          screen->update_rect(inventoryarea);
1453      }      }
# Line 1412  display::Redraw(Screen *screen, bool upd Line 1465  display::Redraw(Screen *screen, bool upd
1465                            
1466          screen->update_rect(area);          screen->update_rect(area);
1467      }      }
1468      if (update_screenp)      screen->flush_updates();
         screen->flush_updates();  
1469  }  }

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

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