This repository has been archived by the owner on Oct 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Progress bar, static typing, comments
- Loading branch information
Showing
7 changed files
with
117 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
extends ProgressBar | ||
|
||
var progress_file := "progress" #File with progress from 0 to 100 | ||
var progress_button: Button | ||
var file := FileAccess | ||
|
||
var prev_prog: float = 0 | ||
|
||
func _ready(): | ||
self.value = 0 | ||
progress_button = $"../HBoxContainerProgress/ProgressButton" | ||
|
||
func _process(delta): | ||
if file.file_exists(progress_file): #File to be removed after script is done | ||
var file := FileAccess.open(progress_file, FileAccess.READ) | ||
var _progress := float(file.get_as_text()) | ||
if prev_prog != _progress: #To not rewrite every frame | ||
self.value = _progress | ||
print("boom", _progress) | ||
prev_prog = _progress | ||
else: | ||
if prev_prog == 100: | ||
progress_button.disabled = false #Reenable progress button | ||
prev_prog = 0 | ||
|
||
|
||
func _on_check_button_toggled(button_pressed): | ||
var _fill_color := Color("999999") | ||
if button_pressed: | ||
_fill_color = Color("FF0000") | ||
self.get("theme_override_styles/fill").set_bg_color(_fill_color) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
extends Button | ||
|
||
var thread: Thread | ||
|
||
func _ready(): | ||
self.pressed.connect(self._button_pressed) | ||
|
||
func _button_pressed(): | ||
thread = Thread.new() | ||
thread.start(_execute_bash.bind(["progress_file.sh"])) #Need to bind | ||
self.disabled = true #To prevent multiple launches | ||
# thread.wait_to_finish() #Should be done somewhere | ||
|
||
func _execute_bash(filename): | ||
var output := [] | ||
var exit_code := OS.execute("bash", filename, output) | ||
print(exit_code) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
extends Control | ||
|
||
func _ready(): | ||
$VBoxContainerButtons/Button.grab_focus() | ||
$VBoxContainerButtons/Button.grab_focus() #Required to enable controller focusing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
progress_file="progress" | ||
echo "0" > "$progress_file" | ||
|
||
for ((i=1; i<=100; i++)); do | ||
echo -ne "$i" > "$progress_file" | ||
# echo $i | ||
# sleep 0.1 | ||
sleep $((RANDOM / 30000)) | ||
done | ||
|
||
sleep 1 | ||
|
||
rm "$progress_file" |