indexing description: "Objects that saves an UC puzzle" author: "Markus Neidhart and UC TEAM" date: "$Date$" revision: "$Revision$" class SAVE_GAME inherit MENU redefine initialize_scene end feature -- Initialize save: UC_SAVE_PUZZLE initialize_scene is -- Initialize the scene local bitmap: EM_BITMAP title: EM_STRING do Precursor -- Build the menu entries create menu_entries.make (1, 1) menu_entries.put (create {EM_STRING}.make ("Back", normal_font), 1) menu_entries.item (1).set_x_y (512 - menu_entries.item (1).width // 2, 650) -- 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) selected_nr := 1 menu_entries.item (selected_nr).set_font (select_font) add_menu_entries_to_scene -- Build the title create title.make ("Save your puzzle!", normal_font) scene.extend (title) title.set_x_y ((width - title.width) // 2, 10) -- Build the text field create text_field.make (event_loop) text_field.start_cursor_animation scene.extend (text_field) text_field.set_x_y (150, 250) -- Build the `save'-Button create save_button.make_with_name ("Save Puzzle", event_loop) scene.extend (save_button) save_button.set_x_y (500, 252) -- subscribe the event for saving the puzzle text_field.return_key_pressed_event.subscribe (agent save_puzzle) save_button.button_clicked_event.subscribe (agent save_button_clicked) end set_situation (sit: PUZZLE_START_WINDOW) is -- set situation to `sit' require sit_not_void: sit /= Void do situation := sit ensure situation_set: situation = sit end feature {NONE} -- Implementation situation: PUZZLE_START_WINDOW -- actual situation, will be set in UC_INTERFACE, which have it as last_scene text_field: TEXT_FIELD save_button: BUTTON feature {NONE} -- Event handler save_puzzle (val: STRING) is -- save the puzzle require val_not_Void: val /= Void do create save.make (val, situation) event_loop.stop on_select end save_button_clicked is -- click on save button do save_puzzle (text_field.value) end on_select is -- Set the `next_scene' according to `selected_nr' here local menu: MENU do if selected_nr = 1 then -- Back menu ?= last_scene menu.set_next_scene (Void) menu.restart_event_loop menu.empty_main_container next_scene := last_scene end end end -- class SAVE_GAME