mirror of
https://github.com/hobbesjaap/time-sampling-form.git
synced 2025-04-19 14:05:41 +00:00
tidied the code some more
This commit is contained in:
parent
255942f8bf
commit
6df90dc006
@ -1,20 +1,14 @@
|
|||||||
extends CanvasLayer
|
extends CanvasLayer
|
||||||
|
|
||||||
@onready var gi = $"/root/GlobalInts"
|
|
||||||
@onready var global_ints = gi
|
|
||||||
@onready var main_window = $"../../AppWindow"
|
@onready var main_window = $"../../AppWindow"
|
||||||
|
|
||||||
func _ready():
|
|
||||||
pass # Replace with function body.
|
|
||||||
|
|
||||||
|
func _on_CancelButton_pressed() -> void:
|
||||||
func _on_CancelButton_pressed():
|
|
||||||
main_window.refresh_descriptors()
|
main_window.refresh_descriptors()
|
||||||
$"%EditScreen".visible = false
|
$"%EditScreen".visible = false
|
||||||
|
|
||||||
|
|
||||||
func _on_OKButton_pressed():
|
func _on_OKButton_pressed() -> void:
|
||||||
|
|
||||||
global_ints.one_acronym = $"%1AcronymE".text
|
global_ints.one_acronym = $"%1AcronymE".text
|
||||||
global_ints.two_acronym = $"%2AcronymE".text
|
global_ints.two_acronym = $"%2AcronymE".text
|
||||||
global_ints.three_acronym = $"%3AcronymE".text
|
global_ints.three_acronym = $"%3AcronymE".text
|
||||||
@ -33,12 +27,12 @@ func _on_OKButton_pressed():
|
|||||||
global_ints.four_explanation = $"%4ExplanationE".text
|
global_ints.four_explanation = $"%4ExplanationE".text
|
||||||
global_ints.five_explanation = $"%5ExplanationE".text
|
global_ints.five_explanation = $"%5ExplanationE".text
|
||||||
|
|
||||||
$"%EditScreen".visible = false
|
$"%EditScreen".hide()
|
||||||
|
|
||||||
main_window.refresh_descriptors()
|
main_window.refresh_descriptors()
|
||||||
|
|
||||||
|
|
||||||
func _on_ClearAll_pressed():
|
func _on_ClearAll_pressed() -> void:
|
||||||
$"%1AcronymE".text = ""
|
$"%1AcronymE".text = ""
|
||||||
$"%1ItemE".text = ""
|
$"%1ItemE".text = ""
|
||||||
$"%1ExplanationE".text = ""
|
$"%1ExplanationE".text = ""
|
||||||
|
@ -1,16 +1,13 @@
|
|||||||
extends Panel
|
extends Panel
|
||||||
|
|
||||||
|
|
||||||
@onready var global_ints = $"/root/GlobalInts"
|
func _on_OkButton_pressed() -> void:
|
||||||
|
|
||||||
|
|
||||||
func _on_OkButton_pressed():
|
|
||||||
if $"%NameLine".text and $"NameContainer/ObserverLine".text and $"NameContainer/ObservedActivity".text != "":
|
if $"%NameLine".text and $"NameContainer/ObserverLine".text and $"NameContainer/ObservedActivity".text != "":
|
||||||
$"%InstructionPanel".visible = true
|
$"%InstructionPanel".show()
|
||||||
$"%NameChangePanel".visible = false
|
$"%NameChangePanel".hide()
|
||||||
global_ints.observed_person_name = $"%NameLine".text
|
global_ints.observed_person_name = $"%NameLine".text
|
||||||
global_ints.observer_person_name = $"NameContainer/ObserverLine".text
|
global_ints.observer_person_name = $"NameContainer/ObserverLine".text
|
||||||
global_ints.observed_activity = $"NameContainer/ObservedActivity".text
|
global_ints.observed_activity = $"NameContainer/ObservedActivity".text
|
||||||
else:
|
else:
|
||||||
$"%ObservedNameLabel".visible = false
|
$"%ObservedNameLabel".hide()
|
||||||
$"%WarningLabel".visible = true
|
$"%WarningLabel".show()
|
||||||
|
@ -1,29 +1,25 @@
|
|||||||
extends CanvasLayer
|
extends CanvasLayer
|
||||||
|
|
||||||
|
|
||||||
@onready var global_ints = $"/root/GlobalInts"
|
|
||||||
|
|
||||||
|
|
||||||
var time_lefts : int
|
var time_lefts : int
|
||||||
var toggle_observation : bool = false
|
var toggle_observation : bool = false
|
||||||
var observation_button_pressed : bool = false
|
var observation_button_pressed : bool = false
|
||||||
|
|
||||||
|
|
||||||
func _ready():
|
func _ready() -> void:
|
||||||
$"Panel/BehaviourButtons".visible = false
|
$"Panel/BehaviourButtons".hide()
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
func _process(_delta):
|
func _process(_delta) -> void:
|
||||||
time_lefts = $"TwentySecondTimer".time_left
|
time_lefts = $"TwentySecondTimer".time_left
|
||||||
$"Panel/TimeRemaining".text = str(time_lefts)
|
$"Panel/TimeRemaining".text = str(time_lefts)
|
||||||
if time_lefts == 5 && toggle_observation == false:
|
if time_lefts == 5 && toggle_observation == false:
|
||||||
print("We're at the five second mark!")
|
print("We're at the five second mark!")
|
||||||
toggle_observation = true
|
toggle_observation = true
|
||||||
$"Panel/BehaviourButtons".visible = true
|
$"Panel/BehaviourButtons".show()
|
||||||
|
|
||||||
|
|
||||||
func calculate_percentages():
|
func calculate_percentages() -> void:
|
||||||
global_ints.total_observed_time = global_ints.total_behaviours / 3
|
global_ints.total_observed_time = global_ints.total_behaviours / 3
|
||||||
|
|
||||||
global_ints.one_behaviour_percent = int((float(global_ints.one_behaviour_score) / global_ints.total_behaviours) * 100)
|
global_ints.one_behaviour_percent = int((float(global_ints.one_behaviour_score) / global_ints.total_behaviours) * 100)
|
||||||
@ -36,14 +32,14 @@ func calculate_percentages():
|
|||||||
|
|
||||||
global_ints.five_behaviour_percent = int((float(global_ints.five_behaviour_score) / global_ints.total_behaviours) * 100)
|
global_ints.five_behaviour_percent = int((float(global_ints.five_behaviour_score) / global_ints.total_behaviours) * 100)
|
||||||
|
|
||||||
func on_interval_moment():
|
func on_interval_moment() -> void:
|
||||||
print("Timer reaches 0 - Let's check if buttons have been pressed and count something")
|
print("Timer reaches 0 - Let's check if buttons have been pressed and count something")
|
||||||
toggle_observation = false
|
toggle_observation = false
|
||||||
# Otherwise - a 6 is registered (nothing selected)
|
# Otherwise - a 6 is registered (nothing selected)
|
||||||
# Buttons are to become visible again
|
# Buttons are to become visible again
|
||||||
global_ints.locked_observations_intervals_remaining -= 1
|
global_ints.locked_observations_intervals_remaining -= 1
|
||||||
global_ints.locked_observations_completed += 1
|
global_ints.locked_observations_completed += 1
|
||||||
$"Panel/BehaviourButtons".visible = false
|
$"Panel/BehaviourButtons".hide()
|
||||||
|
|
||||||
if observation_button_pressed == false:
|
if observation_button_pressed == false:
|
||||||
global_ints.six_behaviour_score += 1
|
global_ints.six_behaviour_score += 1
|
||||||
@ -55,7 +51,7 @@ func on_interval_moment():
|
|||||||
$"Panel/DescriptorBox/ObservationsRemaining".text = str(global_ints.locked_observations_intervals_remaining)
|
$"Panel/DescriptorBox/ObservationsRemaining".text = str(global_ints.locked_observations_intervals_remaining)
|
||||||
|
|
||||||
|
|
||||||
func _on_TwentySecondTimer_timeout():
|
func _on_TwentySecondTimer_timeout() -> void:
|
||||||
if global_ints.locked_observations_intervals_remaining == 1:
|
if global_ints.locked_observations_intervals_remaining == 1:
|
||||||
on_interval_moment()
|
on_interval_moment()
|
||||||
print("We're completely done - no intervals remain")
|
print("We're completely done - no intervals remain")
|
||||||
@ -71,49 +67,49 @@ func _on_TwentySecondTimer_timeout():
|
|||||||
$"TwentySecondTimer".stop()
|
$"TwentySecondTimer".stop()
|
||||||
global_ints.generate_results = true
|
global_ints.generate_results = true
|
||||||
calculate_percentages()
|
calculate_percentages()
|
||||||
$"../Results".visible = true
|
$"../Results".show()
|
||||||
|
|
||||||
if global_ints.locked_observations_intervals_remaining > 1:
|
if global_ints.locked_observations_intervals_remaining > 1:
|
||||||
on_interval_moment()
|
on_interval_moment()
|
||||||
|
|
||||||
|
|
||||||
func _on_BehaviourOne_pressed():
|
func _on_BehaviourOne_pressed() -> void:
|
||||||
global_ints.one_behaviour_score += 1
|
global_ints.one_behaviour_score += 1
|
||||||
global_ints.total_behaviours += 1
|
global_ints.total_behaviours += 1
|
||||||
observation_button_pressed = true
|
observation_button_pressed = true
|
||||||
$"Panel/BehaviourButtons".visible = false
|
$"Panel/BehaviourButtons".hide()
|
||||||
print(str(global_ints.one_behaviour_score))
|
print(str(global_ints.one_behaviour_score))
|
||||||
|
|
||||||
|
|
||||||
func _on_BehaviourTwo_pressed():
|
func _on_BehaviourTwo_pressed() -> void:
|
||||||
global_ints.two_behaviour_score += 1
|
global_ints.two_behaviour_score += 1
|
||||||
global_ints.total_behaviours += 1
|
global_ints.total_behaviours += 1
|
||||||
observation_button_pressed = true
|
observation_button_pressed = true
|
||||||
$"Panel/BehaviourButtons".visible = false
|
$"Panel/BehaviourButtons".hide()
|
||||||
|
|
||||||
|
|
||||||
func _on_BehaviourThree_pressed():
|
func _on_BehaviourThree_pressed() -> void:
|
||||||
global_ints.three_behaviour_score += 1
|
global_ints.three_behaviour_score += 1
|
||||||
global_ints.total_behaviours += 1
|
global_ints.total_behaviours += 1
|
||||||
observation_button_pressed = true
|
observation_button_pressed = true
|
||||||
$"Panel/BehaviourButtons".visible = false
|
$"Panel/BehaviourButtons".hide()
|
||||||
|
|
||||||
|
|
||||||
func _on_BehaviourFour_pressed():
|
func _on_BehaviourFour_pressed() -> void:
|
||||||
global_ints.four_behaviour_score += 1
|
global_ints.four_behaviour_score += 1
|
||||||
global_ints.total_behaviours += 1
|
global_ints.total_behaviours += 1
|
||||||
observation_button_pressed = true
|
observation_button_pressed = true
|
||||||
$"Panel/BehaviourButtons".visible = false
|
$"Panel/BehaviourButtons".hide()
|
||||||
|
|
||||||
|
|
||||||
func _on_BehaviourFive_pressed():
|
func _on_BehaviourFive_pressed() -> void:
|
||||||
global_ints.five_behaviour_score += 1
|
global_ints.five_behaviour_score += 1
|
||||||
global_ints.total_behaviours += 1
|
global_ints.total_behaviours += 1
|
||||||
observation_button_pressed = true
|
observation_button_pressed = true
|
||||||
$"Panel/BehaviourButtons".visible = false
|
$"Panel/BehaviourButtons".hide()
|
||||||
|
|
||||||
|
|
||||||
func _on_Button_pressed():
|
func _on_Button_pressed() -> void:
|
||||||
on_interval_moment()
|
on_interval_moment()
|
||||||
print("We're aborting, so deal with as completely done - no intervals remain")
|
print("We're aborting, so deal with as completely done - no intervals remain")
|
||||||
|
|
||||||
@ -130,4 +126,4 @@ func _on_Button_pressed():
|
|||||||
$"TwentySecondTimer".stop()
|
$"TwentySecondTimer".stop()
|
||||||
global_ints.generate_results = true
|
global_ints.generate_results = true
|
||||||
calculate_percentages()
|
calculate_percentages()
|
||||||
$"../Results".visible = true
|
$"../Results".show()
|
||||||
|
@ -1,13 +1,6 @@
|
|||||||
extends ProgressBar
|
extends ProgressBar
|
||||||
|
|
||||||
|
|
||||||
@onready var global_ints = $"/root/GlobalInts"
|
func _process(_delta) -> void:
|
||||||
|
|
||||||
|
|
||||||
func _ready():
|
|
||||||
pass # Replace with function body.
|
|
||||||
|
|
||||||
|
|
||||||
func _process(_delta):
|
|
||||||
value = global_ints.locked_observations_intervals_remaining
|
value = global_ints.locked_observations_intervals_remaining
|
||||||
max_value = global_ints.locked_observation_intervals
|
max_value = global_ints.locked_observation_intervals
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
extends CanvasLayer
|
extends CanvasLayer
|
||||||
|
|
||||||
|
|
||||||
@onready var global_ints = $"/root/GlobalInts"
|
|
||||||
|
|
||||||
var js_interface;
|
var js_interface;
|
||||||
var image : Image
|
var image : Image
|
||||||
var fileName : String = "results.png"
|
var fileName : String = "results.png"
|
||||||
|
|
||||||
func _ready():
|
func _ready() -> void:
|
||||||
if OS.get_name() == "Web":
|
if OS.get_name() == "Web":
|
||||||
_define_js()
|
_define_js()
|
||||||
js_interface = JavaScriptBridge.get_interface("_HTML5FileExchange");
|
js_interface = JavaScriptBridge.get_interface("_HTML5FileExchange");
|
||||||
|
|
||||||
|
|
||||||
func _define_js()->void:
|
func _define_js()->void:
|
||||||
#Define JS script
|
#Define JS script
|
||||||
JavaScriptBridge.eval("""
|
JavaScriptBridge.eval("""
|
||||||
@ -40,10 +39,8 @@ func _define_js()->void:
|
|||||||
}
|
}
|
||||||
""", true)
|
""", true)
|
||||||
|
|
||||||
func _process(_delta):
|
|
||||||
pass
|
|
||||||
|
|
||||||
func take_screenshot():
|
func take_screenshot() -> void:
|
||||||
image = get_viewport().get_texture().get_image()
|
image = get_viewport().get_texture().get_image()
|
||||||
|
|
||||||
if OS.get_name() == "Web" or OS.has_feature('JavaScript'):
|
if OS.get_name() == "Web" or OS.has_feature('JavaScript'):
|
||||||
@ -77,23 +74,24 @@ func take_screenshot():
|
|||||||
var _openfolder = OS.shell_open("file://" + docs)
|
var _openfolder = OS.shell_open("file://" + docs)
|
||||||
|
|
||||||
|
|
||||||
func _on_SaveReport_pressed():
|
func _on_SaveReport_pressed() -> void:
|
||||||
await get_tree().process_frame
|
await get_tree().process_frame
|
||||||
$"%SaveReport".visible = false
|
$"%SaveReport".hide()
|
||||||
$"%BackMainMenu".visible = false
|
$"%BackMainMenu".hide()
|
||||||
await get_tree().process_frame
|
await get_tree().process_frame
|
||||||
|
|
||||||
take_screenshot()
|
take_screenshot()
|
||||||
|
|
||||||
$"%SaveReport".visible = true
|
$"%SaveReport".show()
|
||||||
$"%BackMainMenu".visible = true
|
$"%BackMainMenu".show()
|
||||||
|
|
||||||
func _on_BackMainMenu_pressed():
|
|
||||||
|
func _on_BackMainMenu_pressed() -> void:
|
||||||
global_ints.reset_all_vars()
|
global_ints.reset_all_vars()
|
||||||
var _ignore = get_tree().reload_current_scene()
|
var _ignore = get_tree().reload_current_scene()
|
||||||
|
|
||||||
|
|
||||||
func _on_Results_visibility_changed():
|
func _on_Results_visibility_changed() -> void:
|
||||||
if global_ints.generate_results == true:
|
if global_ints.generate_results == true:
|
||||||
global_ints.generate_results = false
|
global_ints.generate_results = false
|
||||||
|
|
||||||
|
@ -1,14 +1,9 @@
|
|||||||
extends ProgressBar
|
extends ProgressBar
|
||||||
|
|
||||||
|
|
||||||
@onready var global_ints = $"/root/GlobalInts"
|
|
||||||
|
|
||||||
var time_lefts : int
|
var time_lefts : int
|
||||||
|
|
||||||
func _ready():
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
func _process(_delta) -> void:
|
||||||
func _process(_delta):
|
|
||||||
time_lefts = $"%TwentySecondTimer".time_left
|
time_lefts = $"%TwentySecondTimer".time_left
|
||||||
value = time_lefts
|
value = time_lefts
|
||||||
|
@ -65,7 +65,7 @@ var three_behaviour_percent : float
|
|||||||
var four_behaviour_percent : float
|
var four_behaviour_percent : float
|
||||||
var five_behaviour_percent : float
|
var five_behaviour_percent : float
|
||||||
|
|
||||||
func reset_all_vars():
|
func reset_all_vars() -> void:
|
||||||
observation_minutes = 15
|
observation_minutes = 15
|
||||||
|
|
||||||
generate_results = false
|
generate_results = false
|
||||||
|
@ -8,7 +8,6 @@ var update_text : String
|
|||||||
var text_buffer : String
|
var text_buffer : String
|
||||||
|
|
||||||
@onready var date_time_display = $"%CurrentTime"
|
@onready var date_time_display = $"%CurrentTime"
|
||||||
@onready var global_ints = $"/root/GlobalInts"
|
|
||||||
@onready var minute_label = $"StartScreen/InstructionPanel/MinuteBox/MinuteLabel"
|
@onready var minute_label = $"StartScreen/InstructionPanel/MinuteBox/MinuteLabel"
|
||||||
|
|
||||||
|
|
||||||
@ -78,7 +77,7 @@ func set_language() -> void:
|
|||||||
print(TranslationServer.get_locale())
|
print(TranslationServer.get_locale())
|
||||||
if TranslationServer.get_locale() != "nl":
|
if TranslationServer.get_locale() != "nl":
|
||||||
print("We're not Dutch")
|
print("We're not Dutch")
|
||||||
global_ints.manual_url = "https://docs.internationalsengroup.org/tsf.html"
|
global_ints.manual_url = "https://docs.jaapmarsman.com/tsf.html"
|
||||||
if TranslationServer.get_locale() == "nl":
|
if TranslationServer.get_locale() == "nl":
|
||||||
print("We're Dutch")
|
print("We're Dutch")
|
||||||
global_ints.manual_url = "https://www.lerenleukermaken.nl/"
|
global_ints.manual_url = "https://www.lerenleukermaken.nl/"
|
||||||
@ -93,14 +92,14 @@ func _ready() -> void:
|
|||||||
minute_label.text = str(global_ints.observation_minutes)
|
minute_label.text = str(global_ints.observation_minutes)
|
||||||
global_ints.observed_person_name = ""
|
global_ints.observed_person_name = ""
|
||||||
refresh_descriptors()
|
refresh_descriptors()
|
||||||
$"StartScreen".visible = true
|
$"StartScreen".show()
|
||||||
$"%NameChangePanel".visible = true
|
$"%NameChangePanel".show()
|
||||||
$"%InstructionScreen".visible = true
|
$"%InstructionScreen".show()
|
||||||
$"%WarningLabel".visible = false
|
$"%WarningLabel".hide()
|
||||||
$"ObservationWindow".visible = false
|
$"ObservationWindow".hide()
|
||||||
$"Results".visible = false
|
$"Results".hide()
|
||||||
$"EditScreen".visible = false
|
$"EditScreen".hide()
|
||||||
$"%UpdatePanel".visible = false
|
$"%UpdatePanel".hide()
|
||||||
update_date()
|
update_date()
|
||||||
set_language()
|
set_language()
|
||||||
check_for_updates()
|
check_for_updates()
|
||||||
@ -176,14 +175,15 @@ func _on_Start_pressed() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_ChangeItems_pressed() -> void:
|
func _on_ChangeItems_pressed() -> void:
|
||||||
$"EditScreen".visible = true
|
$"EditScreen".show()
|
||||||
|
|
||||||
|
|
||||||
func _on_InsOkButton_pressed() -> void:
|
func _on_InsOkButton_pressed() -> void:
|
||||||
$"%InstructionScreen".visible = false
|
$"%InstructionScreen".hide()
|
||||||
|
|
||||||
|
|
||||||
func _on_MinuteMinus_button_down() -> void:
|
func _on_MinuteMinus_button_down() -> void:
|
||||||
|
# Holding it down makes it work too - not yet
|
||||||
# if global_ints.observation_minutes >= 2:
|
# if global_ints.observation_minutes >= 2:
|
||||||
# global_ints.observation_minutes -= 1
|
# global_ints.observation_minutes -= 1
|
||||||
# minute_label.text = str(global_ints.observation_minutes)
|
# minute_label.text = str(global_ints.observation_minutes)
|
||||||
@ -195,4 +195,4 @@ func _on_GoToUpdate_pressed() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_IgnoreUpdate_pressed() -> void:
|
func _on_IgnoreUpdate_pressed() -> void:
|
||||||
$"%UpdatePanel".visible = false
|
$"%UpdatePanel".hide()
|
||||||
|
@ -25,7 +25,7 @@ config/windows_native_icon="res://Assets/icons/icon.ico"
|
|||||||
|
|
||||||
[autoload]
|
[autoload]
|
||||||
|
|
||||||
GlobalInts="*res://global_ints.gd"
|
global_ints="*res://global_ints.gd"
|
||||||
|
|
||||||
[display]
|
[display]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user