Ryan was right, Tux was firing from the head :D
[supertux.git] / src / leveleditor.cpp
index ccb9b4b..9b4b100 100644 (file)
@@ -642,6 +642,7 @@ void apply_level_settings_menu()
 {
   int i;
   i = false;
+  le_level_changed = true;
 
   le_world->get_level()->name = level_settings_menu->get_item_by_id(MNID_NAME).input;
   le_world->get_level()->author = level_settings_menu->get_item_by_id(MNID_AUTHOR).input;
@@ -812,10 +813,10 @@ void le_drawinterface()
     /* draw a grid (if selected) */
     if(le_show_grid)
     {
-      for(x = 0; x < 19; x++)
+      for(x = 0; x < VISIBLE_TILES_X; x++)
         fillrect(x*32 - ((int)pos_x % 32), 0, 1, screen->h, 225, 225, 225,255);
-      for(y = 0; y < 16; y++)
-        fillrect(0, y*32 - ((int)pos_y % 32), screen->w - 32, 1, 225, 225, 225,255);
+      for(y = 0; y < VISIBLE_TILES_Y; y++)
+        fillrect(0, y*32 - ((int)pos_y % 32), screen->w, 1, 225, 225, 225,255);
     }
   }
 
@@ -849,13 +850,13 @@ void le_drawinterface()
 
   if(le_current.IsTile())
   {
-    Tile::draw(19 * 32, 14 * 32, le_current.tile);
+    Tile::draw(screen->w - 32, screen->h - 32, le_current.tile);
     if(TileManager::instance()->get(le_current.tile)->editor_images.size() > 0)
-      TileManager::instance()->get(le_current.tile)->editor_images[0]->draw( 19 * 32, 14 * 32);
+      TileManager::instance()->get(le_current.tile)->editor_images[0]->draw( screen->w - 32, screen->h - 32);
   }
   if(le_current.IsObject() && MouseCursor::current() != mouse_select_object)
   {
-    le_current.obj->draw_on_screen(19 * 32, 14 * 32);
+    le_current.obj->draw_on_screen(screen->w - 32, screen->h - 32);
     le_current.obj->draw_on_screen(cursor_x,cursor_y);
   }
 
@@ -922,22 +923,14 @@ void le_drawinterface()
 
 void le_drawlevel()
 {
-  unsigned int y,x,s;
+  unsigned int y,x;
   Uint8 a;
 
   /* Draw the real background */
-  if(le_world->get_level()->bkgd_image[0] != '\0')
-  {
-    s = (int)((float)pos_x * ((float)le_world->get_level()->bkgd_speed/100.0f)) % screen->w;
-    le_world->get_level()->img_bkgd->draw_part(s,0,0,0,
-        le_world->get_level()->img_bkgd->w - s - 32, le_world->get_level()->img_bkgd->h);
-    le_world->get_level()->img_bkgd->draw_part(0,0,screen->w - s - 32 ,0,s,
-        le_world->get_level()->img_bkgd->h);
-  }
+  if (le_world->get_level()->img_bkgd)
+    le_world->get_level()->draw_bg();
   else
-  {
     drawgradient(le_world->get_level()->bkgd_top, le_world->get_level()->bkgd_bottom);
-  }
 
   if(le_current.IsTile())
   {
@@ -953,7 +946,7 @@ void le_drawlevel()
   /*       clearscreen(current_level.bkgd_red, current_level.bkgd_green, current_level.bkgd_blue); */
 
   for (y = 0; y < VISIBLE_TILES_Y && y < (unsigned)le_world->get_level()->height; ++y)
-    for (x = 0; x < (unsigned)VISIBLE_TILES_X-80; ++x)
+    for (x = 0; x < (unsigned)VISIBLE_TILES_X - 2; ++x)
     {
 
       if(active_tm == TM_BG)
@@ -1579,8 +1572,8 @@ void le_checkevents()
     }
 
       /* checking if pos_x and pos_y is within the limits... */
-      if(pos_x > (le_world->get_level()->width * 32) - screen->w)
-        pos_x = (le_world->get_level()->width * 32) - screen->w;
+      if(pos_x > (le_world->get_level()->width * 32 + 32*2) - screen->w)
+        pos_x = (le_world->get_level()->width * 32 + 32*2) - screen->w;
       if(pos_x < 0)
         pos_x = 0;