indexing description: "play a predefined game" author: "Markus Neidhart and UC Team" date: "$Date$" revision: "$Revision$" class PREDEFINED_GAME inherit MENU redefine initialize_scene end feature -- Initialize initialize_scene is -- Initialize the scene local bitmap: EM_BITMAP title: EM_STRING i,y: INTEGER do Precursor -- Build the menu entries create menu_entries.make (1, 4) menu_entries.put (create {EM_STRING}.make ("ETH Main Building", normal_font), 1) menu_entries.put (create {EM_STRING}.make ("ETH Train", normal_font), 2) menu_entries.put (create {EM_STRING}.make ("Welcome Tomorrow", normal_font), 3) menu_entries.put (create {EM_STRING}.make ("Back", normal_font), 4) y := 350 from i := 1 until i > menu_entries.count loop menu_entries.item (i).set_x_y (512 - menu_entries.item (i).width // 2, y) y := y + menu_entries.item (i).height i := i + 1 end -- Build the background bitmap_factory.create_empty_bitmap (width, height) check todo_proper_error_handling: bitmap_factory.last_bitmap /= Void end bitmap := bitmap_factory.last_bitmap bitmap.fill (uc_background_color) bitmap.set_x_y (1, 1) scene.extend (bitmap) -- Build the title create title.make ("Predefined puzzle!", normal_font) scene.extend (title) title.set_x_y ((width - title.width) // 2, 10) selected_nr := 1 menu_entries.item (selected_nr).set_font (select_font) add_menu_entries_to_scene end feature {NONE} -- Event handler on_select is -- Set the `next_scene' according to `selected_nr' here local menu: MENU n: NEW_GAME pg: PREDEFINED_GAME psw: PUZZLE_START_WINDOW do if selected_nr = 1 then -- main building create psw psw.set_image_file_name ("image/predefined1.jpg") psw.set_number_of_parts (150) next_scene := psw psw.set_initialized (False) elseif selected_nr = 2 then -- train create psw psw.set_image_file_name ("image/predefined2.jpg") psw.set_number_of_parts (150) next_scene := psw psw.set_initialized (False) elseif selected_nr = 3 then -- welcome tomorrow create psw psw.set_image_file_name ("image/predefined3.jpg") psw.set_number_of_parts (150) next_scene := psw psw.set_initialized (False) elseif selected_nr = 4 then -- Back menu ?= last_scene menu.set_next_scene (Void) menu.restart_event_loop menu.empty_main_container next_scene := menu end end end -- class PREDEFINED_GAME