- if(le_world == NULL)
- return;
-
- int mini_tile_width;
- if(screen->w - 64 > le_world->get_level()->width * 4)
- mini_tile_width = 4;
- else if(screen->w - 64 > le_world->get_level()->width * 2)
- mini_tile_width = 2;
- else
- mini_tile_width = 1;
- int left_offset = (screen->w - 64 - le_world->get_level()->width*mini_tile_width) / 2;
-
- int mini_tile_height;
- if(screen->h - 64 > le_world->get_level()->height * 4)
- mini_tile_height = 4;
- else if(screen->h - 64 > le_world->get_level()->height * 2)
- mini_tile_height = 2;
- else
- mini_tile_height = 1;
-
- Level* level = le_world->get_level();
- for (int y = 0; y < le_world->get_level()->height; ++y)
- for (int x = 0; x < le_world->get_level()->width; ++x)
- {
-
- Tile::draw_stretched(left_offset + mini_tile_width*x, y * 4,
- mini_tile_width , 4, level->bg_tiles[y * level->width + x]);
-
- Tile::draw_stretched(left_offset + mini_tile_width*x, y * 4,
- mini_tile_width , 4, level->ia_tiles[y * level->width + x]);
-
- Tile::draw_stretched(left_offset + mini_tile_width*x, y * 4,
- mini_tile_width , 4, level->fg_tiles[y + level->width + x]);
-
- }
-
- fillrect(left_offset, 0, le_world->get_level()->width*mini_tile_width, le_world->get_level()->height*mini_tile_height, 200, 200, 200, 128);
-
- fillrect(left_offset + (pos_x/32)*mini_tile_width, 0, 19*mini_tile_width, 2, 200, 200, 200, 200);
- fillrect(left_offset + (pos_x/32)*mini_tile_width, 0, 2, le_world->get_level()->height*mini_tile_height, 200, 200, 200, 200);
- fillrect(left_offset + (pos_x/32)*mini_tile_width + 19*mini_tile_width - 2, 0, 2, le_world->get_level()->height*mini_tile_height, 200, 200, 200, 200);
- fillrect(left_offset + (pos_x/32)*mini_tile_width, le_world->get_level()->height*mini_tile_height-2, 19*mini_tile_width, 2, 200, 200, 200, 200);
-
-}
-
-void le_drawinterface()
-{
- int x,y;
- char str[80];
-
- if(le_world != NULL)
- {
- /* draw a grid (if selected) */
- if(le_show_grid)
- {
- 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 < VISIBLE_TILES_Y; y++)
- fillrect(0, y*32 - ((int)pos_y % 32), screen->w, 1, 225, 225, 225,255);
- }
- }
-
- if(show_minimap) // use_gl because the minimap isn't shown correctly in software mode. Any idea? FIXME Possible reasons: SDL_SoftStretch is a hack itsself || an alpha blitting issue SDL can't handle in software mode
- le_drawminimap();
-
- if(show_selections && MouseCursor::current() != mouse_select_object)
- {
- if(le_selection_mode == CURSOR)
- {
- if(le_current.IsTile())
- le_selection->draw(cursor_x - pos_x, cursor_y - pos_y);
- }
- else if(le_selection_mode == SQUARE)
- {
- int w, h;
- le_highlight_selection();
- /* draw current selection */
- w = selection.x2 - selection.x1;
- h = selection.y2 - selection.y1;
- fillrect(selection.x1 - pos_x, selection.y1 - pos_y, w, SELECT_W, SELECT_CLR);
- fillrect(selection.x1 - pos_x + w, selection.y1 - pos_y, SELECT_W, h, SELECT_CLR);
- fillrect(selection.x1 - pos_x, selection.y1 - pos_y + h, w, SELECT_W, SELECT_CLR);
- fillrect(selection.x1 - pos_x, selection.y1 - pos_y, SELECT_W, h, SELECT_CLR);
- }
- }
-
-
- /* draw button bar */
- fillrect(screen->w - 64, 0, 64, screen->h, 50, 50, 50,255);
-
- if(le_current.IsTile())
- {
- 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( screen->w - 32, screen->h - 32);
- }
- if(le_current.IsObject() && MouseCursor::current() != mouse_select_object)
- {
- le_current.obj->draw_on_screen(screen->w - 32, screen->h - 32);
- le_current.obj->draw_on_screen(cursor_x,cursor_y);
- }
-
- if(mouse_select_object && selected_game_object != NULL)
- {
- fillrect(selected_game_object->base.x-pos_x,selected_game_object->base.y-pos_y,selected_game_object->base.width,3,255,0,0,255);
- fillrect(selected_game_object->base.x-pos_x,selected_game_object->base.y-pos_y,3,selected_game_object->base.height,255,0,0,255);
- fillrect(selected_game_object->base.x-pos_x,selected_game_object->base.y-pos_y+selected_game_object->base.height,selected_game_object->base.width,3,255,0,0,255);
- fillrect(selected_game_object->base.x-pos_x+selected_game_object->base.width,selected_game_object->base.y-pos_y,3,selected_game_object->base.height,255,0,0,255);
- }
-
- if(le_world != NULL)
- {
- le_save_level_bt->draw();
- le_exit_bt->draw();
- le_test_level_bt->draw();
- le_next_level_bt->draw();
- le_previous_level_bt->draw();
- le_rubber_bt->draw();
- if(le_selection_mode == SQUARE)
- le_select_mode_one_bt->draw();
- else if(le_selection_mode == CURSOR)
- le_select_mode_two_bt->draw();
- le_settings_bt->draw();
- le_move_right_bt->draw();
- le_move_left_bt->draw();
- le_move_up_bt->draw();
- le_move_down_bt->draw();
- le_tilegroup_bt->draw();
- le_objects_bt->draw();
- if(!cur_tilegroup.empty())
- tilegroups_map[cur_tilegroup]->draw();
- else if(!cur_objects.empty())
- {
- objects_map[cur_objects]->draw();
- }
-
- le_tilemap_panel->draw();
-
- if(!cur_objects.empty())
- {
- le_object_select_bt->draw();
- le_object_properties_bt->draw();
- }
-
- sprintf(str, "%d/%d", le_level,le_level_subset->levels);
- white_text->drawf(str, (le_level_subset->levels < 10) ? -10 : 0, 16, A_RIGHT, A_TOP, 0);
-
- if(!le_help_shown)
- white_small_text->draw("F1 for Help", 10, 430, 1);
-
- if(display_level_info.check())
- white_text->drawf(le_world->get_level()->name.c_str(), 0, 0, A_HMIDDLE, A_TOP, 0);
- }
- else
- {
- if(!Menu::current())
- white_small_text->draw("No Level Subset loaded - Press ESC and choose one in the menu", 10, 430, 1);
- else
- white_small_text->draw("No Level Subset loaded", 10, 430, 1);
- }
-
-}
-
-void le_drawlevel()
-{
- unsigned int y,x;
- Uint8 a;
-
- /* Draw the real background */
- le_world->get_level()->draw_bg();
-
- if(le_current.IsTile())
- {
- Tile::draw(cursor_x-pos_x, cursor_y-pos_y,le_current.tile,128);
- if(!TileManager::instance()->get(le_current.tile)->images.empty())
- fillrect(cursor_x-pos_x,cursor_y-pos_y,TileManager::instance()->get(le_current.tile)->images[0]->w,TileManager::instance()->get(le_current.tile)->images[0]->h,50,50,50,50);
- }
- if(le_current.IsObject())
- {
- le_current.obj->move_to(cursor_x, cursor_y);
- }
-
- /* clearscreen(current_level.bkgd_red, current_level.bkgd_green, current_level.bkgd_blue); */
-
- Level* level = le_world->get_level();
- for (y = 0; y < VISIBLE_TILES_Y && y < (unsigned)le_world->get_level()->height; ++y)
- for (x = 0; x < (unsigned)VISIBLE_TILES_X - 2; ++x)
- {
-
- if(active_tm == TM_BG)
- a = 255;
- else
- a = 128;
-
- Tile::draw(32*x - fmodf(pos_x, 32), y*32 - fmodf(pos_y, 32),
- level->bg_tiles[ (y + (int)(pos_y / 32)) * level->width +
- (x + (int)(pos_x / 32))],a);
-
- if(active_tm == TM_IA)
- a = 255;
- else
- a = 128;
-
- Tile::draw(32*x - fmodf(pos_x, 32), y*32 - fmodf(pos_y, 32),
- level->ia_tiles[ (y + (int)(pos_y / 32)) * level->width +
- (x + (int)(pos_x / 32))],a);
-
-
- if(active_tm == TM_FG)
- a = 255;
- else
- a = 128;
-
- Tile::draw(32*x - fmodf(pos_x, 32), y*32 - fmodf(pos_y, 32),
- level->fg_tiles[ (y + (int)(pos_y / 32)) * level->width +
- (x + (int)(pos_x / 32))],a);
-
- /* draw whats inside stuff when cursor is selecting those */
- /* (draw them all the time - is this the right behaviour?) */
- Tile* edit_image = TileManager::instance()->get(
- level->ia_tiles
- [ (y + (int)(pos_y / 32)) * level->width + (x + (int)(pos_x / 32))]);
- if(edit_image && !edit_image->editor_images.empty())
- edit_image->editor_images[0]->draw( x * 32 - ((int)pos_x % 32), y*32 - ((int)pos_y % 32));
-
- }
-
- /* Draw the Bad guys: */
- for (std::vector<_GameObject*>::iterator it = le_world->gameobjects.begin();
- it != le_world->gameobjects.end(); ++it)
- {
- BadGuy* badguy = dynamic_cast<BadGuy*> (*it);
- if(badguy == 0)
- continue;
-
- /* to support frames: img_bsod_left[(frame / 5) % 4] */
- ViewPort viewport;
- viewport.set_translation(Vector(pos_x, pos_y));
- badguy->draw(viewport, 0);
- }
-
- /* Draw the player: */
- /* for now, the position is fixed at (100, 240) */
- largetux.walk_right->draw( 100 - pos_x, 240 - pos_y);
-}
-
-void le_change_object_properties(_GameObject *pobj)
-{
- Surface* cap_screen = Surface::CaptureScreen();
- Menu* object_properties_menu = new Menu();
- bool loop = true;
-
- object_properties_menu->additem(MN_LABEL,pobj->type() + " Properties",0,0);
- object_properties_menu->additem(MN_HL,"",0,0);
-
- BadGuy* pbad = dynamic_cast<BadGuy*>(pobj);
- if(pobj != 0)
- {
- object_properties_menu->additem(MN_STRINGSELECT,"Kind",0,0,1);
- for(int i = 0; i < NUM_BadGuyKinds; ++i)
- {
- string_list_add_item(object_properties_menu->get_item_by_id(1).list,
- badguykind_to_string(static_cast<BadGuyKind>(i)).c_str());
- if(pbad->kind == i)
- object_properties_menu->get_item_by_id(1).list->active_item = i;
- }
- object_properties_menu->additem(MN_TOGGLE,"StayOnPlatform",pbad->stay_on_platform,0,2);
- }
-
- object_properties_menu->additem(MN_HL,"",0,0);
- object_properties_menu->additem(MN_ACTION,"Ok",0,0,3);
-
- Menu::set_current(object_properties_menu);
-
- while(loop)
- {
- SDL_Event event;
-
- while (SDL_PollEvent(&event))
- {
- object_properties_menu->event(event);
- }
-
- cap_screen->draw(0,0);
-
- object_properties_menu->draw();
- object_properties_menu->action();
-
- switch (object_properties_menu->check())
- {
- case 3:
- {
- BadGuy* pbad = dynamic_cast<BadGuy*>(pobj);
- if(pbad != 0) {
- BadGuy* pbad = dynamic_cast<BadGuy*>(pobj);
- pbad->kind = badguykind_from_string(string_list_active(object_properties_menu->get_item_by_id(1).list));
- pbad->stay_on_platform = object_properties_menu->get_item_by_id(2).toggled;
- }
- loop = false;
- break;
- }
- default:
- break;
- }
-
- if(Menu::current() == NULL)
- loop = false;
-
- mouse_cursor->draw();
- flipscreen();
- SDL_Delay(25);
- }
-
- delete cap_screen;
- Menu::set_current(0);
- delete object_properties_menu;
-}
-
-
-void le_checkevents()
-{
- SDLKey key;
- SDLMod keymod;
- Button* pbutton;
- int x,y;
-
- keymod = SDL_GetModState();
-
- while(SDL_PollEvent(&event))
+DrawingContext context;
+
+bool show_grid_t = show_grid;
+show_grid = false;
+mouse_cursor->set_state(MC_HIDE);
+
+
+char str[1024];
+const char *text1[] = {
+ _("This is the built-in level editor. Its aim is to be intuitive\n"
+ "and simple to use, so it should be pretty straightforward.\n"
+ "\n"
+ "To open a level, first you'll have to select a level subset from\n"
+ "the menu (or create your own).\n"
+ "A level subset is basically a collection of levels.\n"
+ "They can then be played from the Contrib menu.\n"
+ "\n"
+ "To access the menu from the level editor, just press Esc.\n"
+ "\n"
+ "You are currently looking at the level. To scroll it, just\n"
+ "press the right mouse button and drag the mouse. It will move like\n"
+ "a strategy game.\n"
+ "You can also use the arrow keys and Page Up/Down.\n"
+ "\n"
+ "'+' and '-' keys can be used to zoom the level in/out.\n"
+ "\n"
+ "You probably already noticed those floating groups of buttons.\n"
+ "Each one serves a different purpose. To select a certain button\n"
+ "just press the Left mouse button on it. A few buttons have key\n"
+ "shortcuts. You can find them by pressing the Right mouse button on\n"
+ "a button. That will also show what that button does.\n"
+ "Groups of buttons can also be moved around by just dragging them,\n"
+ "while pressing the Left mouse button.\n"
+ "\n"
+ "Let's learn a bit of what each group of buttons does, shall we?\n"
+ "\n"
+ "To starting putting tiles and objects around use the bigger group\n"
+ "of buttons. Each button is a different tile. To put it on the level,\n"
+ "just press it and then left click in the level.\n"
+ "You can also copy tiles from the level by using the middle mouse button.\n"
+ "Use the mouse wheel to scroll that group of buttons. You will find\n"
+ "enemies and game objects in the bottom.\n")
+ };
+
+const char *text2[] = {
+ _("The Foreground/Interactive/Background buttons may be used to\n"
+ "see and edit the respective layer. Levels have three tiles layers:\n"
+ "Foreground - tiles are drawn on top of everything and have no contact\n"
+ "with the player.\n"
+ "Interactive - these are the tiles that have contact with the player.\n"
+ "Background - tiles are drawn underneath everything and have no contact\n"
+ "with the player.\n"
+ "The unselected layers will be drawn semi-transparently.\n"
+ "\n"
+ "Last, but not least, the group of buttons that's left serves\n"
+ "to do related actions with the level.\n"
+ "From left to right:\n"
+ "Mini arrows - can be used to choose other sectors.\n"
+ "Sectors are mini-levels, so to speak, that can be accessed using a door.\n"
+ "Big arrows - choose other level in the same level subset.\n"
+ "Diskette - save the level\n"
+ "Tux - test the level\n"
+ "Tools - set a few settings for the level, including resizing it.\n"
+ "\n"
+ "We have reached the end of this Howto.\n"
+ "\n"
+ "Don't forget to send us a few cool levels. :)\n"
+ "\n"
+ "Enjoy,\n"
+ " SuperTux development team\n"
+ "\n"
+ "PS: If you are looking for something more powerful, you might like to\n"
+ "try FlexLay. FlexLay is a level editor that supports several games,\n"
+ "including SuperTux. It is an independent project.\n"
+ "Webpage: http://pingus.seul.org/~grumbel/flexlay/")
+ };
+
+const char **text[] = { text1, text2 };
+
+
+bool done;
+for(unsigned int i = 0; i < sizeof(text) / sizeof(text[0]); i++)