indexing description: "[ Scene where local highscore is sent to the server and remote highscore is received ]" date: "$Date$" revision: "$Revision$" class SUBMIT_SCENE inherit EM_WIDGET_SCENE redefine initialize_scene end SHARED_HIGHSCORE create make_widget_scene feature -- Initialization initialize_scene is -- initialize the scene do Precursor set_frame_counter_visibility (true) set_background_color (theme_colors.window_background) setup_widgets highscore.set_url ("eiffelmedia.origo.ethz.ch/highscore/submithighscore.php") -- Subscribe events to know when data transfer is finished -- You don't have to care about unsubscribing these highscore.connection_failed_event.subscribe (agent on_failure) highscore.connection_closed_event.subscribe (agent on_connection_closed) highscore.connection_established_event.subscribe (agent on_connection_established) highscore.set_num_of_remote_entries (15) highscore.synchronize_with_server end feature {NONE} -- Implementation on_cancel is -- handle click on 'cancel' button do canceled := true -- This is important, if you don't cancel the connection, all subscribtions are still valid -- and will be called (at a time you probably don't want them to be called anymore) highscore.cancel_connection set_next_scene (create {LOCAL_HIGHSCORE_SCENE}.make_widget_scene) start_next_scene end on_failure is -- handle connection failure do status.set_text ("Connection failed") end on_connection_closed is -- handle closed connection (i.e., transfer has finished) do if not canceled then set_next_scene (create {REMOTE_HIGHSCORE_SCENE}.make_widget_scene) start_next_scene end end on_connection_established is -- handle established connection do status.set_text ("Status: Connected") end feature {NONE} -- Implementation setup_widgets is -- set up widgets for the scene do create title.make_from_text ("Submit local highscore, receive remote highscore") title.set_position (100, 50) add_widget (title) create status.make_from_text ("Status: Connecting") status.set_position (100, 200) create cancel_button.make_from_dimension (180, 40) cancel_button.set_position (300, 400) cancel_button.set_text ("Cancel") cancel_button.clicked_event.subscribe (agent on_cancel) add_widget (status) add_widget (cancel_button) end canceled: BOOLEAN title: EM_LABEL status: EM_LABEL cancel_button: EM_BUTTON end