indexing description: "Main Menu for Game UC." author: "Team UC with thanks to Benno Baumgartner" date: "$Date$" revision: "$Revision$" class UC_INTERFACE inherit MENU redefine initialize_scene end feature -- commands initialize_scene is -- Initialize the scene local bitmap: EM_BITMAP i, y: INTEGER do Precursor -- build the menu entries create menu_entries.make (1, 6) menu_entries.put (create {EM_STRING}.make ("New Game", normal_font), 1) menu_entries.put (create {EM_STRING}.make ("Resume Game", normal_font), 2) menu_entries.put (create {EM_STRING}.make ("Load Game", normal_font), 3) menu_entries.put (create {EM_STRING}.make ("Save Game", normal_font), 4) menu_entries.put (create {EM_STRING}.make ("Credits", normal_font), 5) menu_entries.put (create {EM_STRING}.make ("Quit", normal_font), 6) y := 350 from i := 1 until i > menu_entries.upper 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 selected_nr := 1 menu_entries.item (selected_nr).set_font (select_font) -- add menu entries add_menu_entries_to_scene -- make logo bitmap_factory.create_bitmap_from_image ("./image/uc_logo.png") bitmap := bitmap_factory.last_bitmap bitmap.set_x_y (400,95) scene.extend(bitmap) end feature {NONE} -- Event handler on_select is -- Set the `next_scene' according to `selected_nr' here local l: LOAD_GAME s: SAVE_GAME p: PUZZLE_START_WINDOW c: CREDITS sel: SELECT_GAME do if selected_nr = 1 then -- start create sel sel.set_last_scene (Current) next_scene := sel elseif selected_nr = 2 then -- Resume Game p ?= last_scene if p /= Void then -- here if last scene is an instance of puzzle_start_window, then resume the game p.set_next_scene (Void) p.restart_event_loop next_scene := p p.set_initialized (True) else event_loop.start -- else do nothing end elseif selected_nr = 3 then -- Load Game create l l.set_last_scene(Current) next_scene := l elseif selected_nr = 4 then -- Save Game p ?= last_scene if p /= Void then -- here if last scene is an instance of puzzle_start_window, then save this puzzle create s s.set_situation (p) s.set_last_scene (Current) next_scene := s else event_loop.start -- else do nothing end elseif selected_nr = 5 then -- credits create c c.set_last_scene (Current) next_scene := c elseif selected_nr = 6 then -- quit next_scene := void end end end