indexing description: "[ Remote High Score ]" date: "$Date$" revision: "$Revision$" class BB_REMOTE_HIGHSCORE inherit BB_HIGHSCORE redefine back_button_pressed end create make feature -- Initialization make is -- Initialize `Current' local button: BB_MENU_BUTTON a_label: EM_LABEL a_font: EM_COLOR_TTF_FONT do init_menu highscore.set_url ("eiffelmedia.origo.ethz.ch/highscore/submithighscore.php") create button.make ("Back") button.pressed_event.subscribe (agent back_button_pressed) button.set_position (100, 550) add_button (button) create a_font.make_from_ttf_font (standard_ttf_fonts.bitstream_vera_sans (16)) a_font.set_color (create {EM_COLOR}.make_white) create a_label.make_from_text ("See eiffelmedia.origo.ethz.ch/highscore/?gi=brick_breaker_ce for the complete list") a_label.set_font (a_font) a_label.resize_to_optimal_dimension a_label.set_position (bb_window_width // 2 - a_label.width // 2, 520) add_widget (a_label) create button.make ("Local") button.pressed_event.subscribe (agent local_button_pressed) button.set_position (bb_window_width - 100 - button.width, 550) add_button (button) -- 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) create status_message.make_from_text ("Connecting...") status_message.set_font (highscore_font) status_message.resize_to_optimal_dimension status_message.set_position (bb_window_width // 2 - status_message.width // 2, bb_window_height // 2) add_widget (status_message) is_connecting := True highscore.set_num_of_remote_entries (number_of_entries) highscore.synchronize_with_server end feature -- Events on_failure is -- connection failed do status_message.set_text ("Connection failed") status_message.resize_to_optimal_dimension status_message.set_position (bb_window_width // 2 - status_message.width // 2, bb_window_height // 2) is_connecting := False end on_connection_closed is -- connection closed do status_message.hide is_connecting := False highscore_list := highscore.remote_highscore add_highscore_list end on_connection_established is -- connection established do status_message.set_text ("Receiving highscore...") status_message.resize_to_optimal_dimension status_message.set_position (bb_window_width // 2 - status_message.width // 2, bb_window_height // 2) end local_button_pressed is -- go back to local highscore do if is_connecting and not highscore.connection_cancelled then highscore.cancel_connection is_connecting := False end set_next_scene (create {BB_LOCAL_HIGHSCORE}.make) start_next_scene end back_button_pressed is -- back button pressed do if is_connecting and not highscore.connection_cancelled then highscore.cancel_connection is_connecting := False end Precursor end feature {NONE} -- Impelementation status_message: EM_LABEL -- status message is_connecting: BOOLEAN -- are network processes in progress? end