Added ProgressBar for showing update progress (Real data\!)
This commit is contained in:
		| @ -104,6 +104,8 @@ func _download_request_completed(_result, _response_code, _headers, body): | ||||
| 	 | ||||
| 	# Enable (Un-disable?) the Play_button | ||||
| 	$Panel/Play_button.disabled = false | ||||
| 	$Panel/ProgressBar.hide() | ||||
| 	$Panel/ProgressBar.value = 0 | ||||
|  | ||||
| # When the play button is pressed, | ||||
| func _on_Play_button_pressed(): | ||||
| @ -130,6 +132,8 @@ func _on_Play_button_pressed(): | ||||
| 		 | ||||
| 		# Send an HTTP request to the url | ||||
| 		var error = download.request(url) | ||||
| 		$Panel/ProgressBar.show() | ||||
| 		$Panel/ProgressBar.request = download | ||||
| 		 | ||||
| 		# If the request was *created* successfully (Not neccessarily saying the server responded positively), | ||||
| 		if error == OK: | ||||
| @ -138,7 +142,7 @@ func _on_Play_button_pressed(): | ||||
| 		# If not, | ||||
| 		else: | ||||
| 			# Debug message! | ||||
| 			print("Failed to send HTTP request to server! Error: "+error) | ||||
| 			notice("Failed to send HTTP request to server! Error: "+error, "") | ||||
| 		 | ||||
| 	# If not, | ||||
| 	#  Play the game | ||||
|  | ||||
| @ -1,10 +1,12 @@ | ||||
| [gd_scene load_steps=10 format=2] | ||||
| [gd_scene load_steps=13 format=2] | ||||
|  | ||||
| [ext_resource path="res://textures/backgrounds/background1.png" type="Texture" id=1] | ||||
| [ext_resource path="res://fonts/SPACEBAR.ttf" type="DynamicFontData" id=2] | ||||
| [ext_resource path="res://Main_menu.gd" type="Script" id=3] | ||||
| [ext_resource path="res://fonts/Title-font.tres" type="DynamicFont" id=4] | ||||
| [ext_resource path="res://themes/Base_theme.tres" type="Theme" id=5] | ||||
| [ext_resource path="res://fonts/SPACE.tres" type="DynamicFont" id=6] | ||||
| [ext_resource path="res://ProgressBar.gd" type="Script" id=7] | ||||
|  | ||||
| [sub_resource type="Theme" id=1] | ||||
| default_font = ExtResource( 4 ) | ||||
| @ -28,6 +30,14 @@ corner_detail = 16 | ||||
| size = 32 | ||||
| font_data = ExtResource( 2 ) | ||||
|  | ||||
| [sub_resource type="StyleBoxFlat" id=6] | ||||
| bg_color = Color( 0.0509804, 0.0666667, 0.227451, 1 ) | ||||
| border_color = Color( 0.219608, 0.211765, 0.227451, 1 ) | ||||
| corner_radius_top_left = 8 | ||||
| corner_radius_top_right = 8 | ||||
| corner_radius_bottom_right = 8 | ||||
| corner_radius_bottom_left = 8 | ||||
|  | ||||
| [node name="Main_menu" type="Control"] | ||||
| anchor_right = 1.0 | ||||
| anchor_bottom = 1.0 | ||||
| @ -64,13 +74,24 @@ custom_styles/panel = SubResource( 4 ) | ||||
|  | ||||
| [node name="Play_button" type="Button" parent="Panel"] | ||||
| margin_left = 288.0 | ||||
| margin_top = 32.0 | ||||
| margin_top = 16.0 | ||||
| margin_right = 621.0 | ||||
| margin_bottom = 85.0 | ||||
| margin_bottom = 69.0 | ||||
| rect_scale = Vector2( 0.962016, 0.91427 ) | ||||
| custom_fonts/font = SubResource( 5 ) | ||||
| text = "play" | ||||
|  | ||||
| [node name="ProgressBar" type="ProgressBar" parent="Panel"] | ||||
| visible = false | ||||
| margin_left = 296.0 | ||||
| margin_top = 72.0 | ||||
| margin_right = 600.0 | ||||
| margin_bottom = 97.0 | ||||
| custom_fonts/font = ExtResource( 6 ) | ||||
| custom_styles/fg = SubResource( 6 ) | ||||
| value = 20.0 | ||||
| script = ExtResource( 7 ) | ||||
|  | ||||
| [node name="Notices" type="VBoxContainer" parent="."] | ||||
| margin_top = 80.0 | ||||
| margin_right = 192.0 | ||||
|  | ||||
							
								
								
									
										8
									
								
								ProgressBar.gd
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								ProgressBar.gd
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,8 @@ | ||||
| extends ProgressBar | ||||
|  | ||||
| var request | ||||
|  | ||||
| func _process(delta): | ||||
| 	if request: | ||||
| 		max_value = request.get_body_size() | ||||
| 		value = request.get_downloaded_bytes() | ||||
		Reference in New Issue
	
	Block a user