add button to dl lldb

godot
Fabien Freling 2022-05-20 17:52:59 +02:00
parent 62c5adc267
commit e3f7ffa5e1
3 changed files with 54 additions and 0 deletions

26
godot-impl/Main.gd Normal file
View File

@ -0,0 +1,26 @@
extends Control
# Called when the node enters the scene tree for the first time.
func _ready():
$HTTPRequest.connect("request_completed", self._on_request_completed)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
var bodySize = $HTTPRequest.get_body_size()
var downloadedBytes = $HTTPRequest.get_downloaded_bytes()
var percent = downloadedBytes * 100 / bodySize
$Label.text = "Progress: %d %%" % percent
pass
func download_cpp_dap():
var url = "https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.0/clang+llvm-14.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz"
$HTTPRequest.download_file = "user://lldb.tar.xz"
$HTTPRequest.request(url)
func _on_request_completed(result, response_code, headers, body):
# TODO: decompress archive
# OS.execute("")
pass

27
godot-impl/Main.tscn Normal file
View File

@ -0,0 +1,27 @@
[gd_scene load_steps=2 format=3 uid="uid://cirquj62osi4v"]
[ext_resource type="Script" path="res://Main.gd" id="1_6lnje"]
[node name="Control" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( "1_6lnje" )
[node name="Button" type="Button" parent="."]
offset_left = 148.0
offset_top = 70.0
offset_right = 296.0
offset_bottom = 162.0
text = "Download C++ DAP (lldb)"
[node name="HTTPRequest" type="HTTPRequest" parent="."]
use_threads = true
[node name="Label" type="Label" parent="."]
offset_left = 359.0
offset_top = 90.0
offset_right = 598.0
offset_bottom = 136.0
text = "Progress: 0%"
[connection signal="pressed" from="Button" to="." method="download_cpp_dap"]

View File

@ -11,5 +11,6 @@ config_version=5
[application]
config/name="Doggo"
run/main_scene="res://Main.tscn"
config/icon="res://icon.png"
config/features=PackedStringArray("4.0", "Vulkan Clustered")