bunch of new options, removed other project data
This commit is contained in:
parent
733a8fd6c0
commit
bfee9448f5
11 changed files with 96 additions and 225 deletions
8
Tools.gd
Normal file
8
Tools.gd
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
extends Node
|
||||
|
||||
func time_to_seconds(hours_value : int, seconds_value : int) -> int:
|
||||
return 0
|
||||
|
||||
func seconds_to_time(seconds : int) -> Dictionary:
|
||||
return {"Hours":0,"Seconds":0}
|
||||
|
||||
1
Tools.gd.uid
Normal file
1
Tools.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cqik2vpkasxsr
|
||||
8
clock.gd
8
clock.gd
|
|
@ -5,6 +5,7 @@ var taskbar_height : int = 50
|
|||
@export var bar: TextureProgressBar
|
||||
@export var label: Label
|
||||
@export var options_window: Window
|
||||
@export var background: ColorRect
|
||||
|
||||
#
|
||||
#@export var bar_position : Position
|
||||
|
|
@ -48,6 +49,9 @@ func setup_window():
|
|||
position.x = Data.save.size
|
||||
rotation_degrees = 90
|
||||
|
||||
background.color = Data.save.background_color
|
||||
modulate = Color(1,1,1,Data.save.bar_transparency)
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
var unix : float = Time.get_unix_time_from_system()
|
||||
|
|
@ -100,9 +104,9 @@ func _process(delta: float) -> void:
|
|||
#print(current_day)
|
||||
|
||||
if (seconds_left <= 3600):
|
||||
bar.modulate = Color.RED
|
||||
bar.modulate = Data.save.warning_color
|
||||
else:
|
||||
bar.modulate = Color.DODGER_BLUE
|
||||
bar.modulate = Data.save.bar_color
|
||||
|
||||
#var screen_size : Vector2i = DisplayServer.screen_get_size()
|
||||
#DisplayServer.window_set_size(Vector2i(screen_size.x, 10))
|
||||
|
|
|
|||
131
logic.gd
131
logic.gd
|
|
@ -1,131 +0,0 @@
|
|||
extends Control
|
||||
|
||||
enum State{
|
||||
Working,
|
||||
OffTask,
|
||||
Break
|
||||
}
|
||||
|
||||
@export var colors : Array[Color]
|
||||
|
||||
@export_group("Node References")
|
||||
@export var on_task_panel : Control
|
||||
@export var off_task_panel : Control
|
||||
@export var break_panel : Control
|
||||
@export var background : ColorRect
|
||||
@export var on_clock : RichTextLabel
|
||||
@export var off_clock : RichTextLabel
|
||||
@export var break_clock : RichTextLabel
|
||||
@export var next_break_text : RichTextLabel
|
||||
@export var time_spent_text : RichTextLabel
|
||||
|
||||
var state : State = State.Working
|
||||
var total_working_time : float = 0
|
||||
var total_off_time : float = 0
|
||||
var off_time : float = 0
|
||||
var break_time : float = 0
|
||||
var update : float = 0.5
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
print(get_next_break_time())
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
update -= delta
|
||||
background.color = colors[state]
|
||||
on_task_panel.visible = state == State.Working
|
||||
off_task_panel.visible = state == State.OffTask
|
||||
break_panel.visible = state == State.Break
|
||||
if(state == State.Working):
|
||||
total_working_time += delta
|
||||
time_spent_text.text = seconds_to_time(total_working_time) + " Spent working"
|
||||
on_clock.text = get_next_break_time()
|
||||
next_break_text.text = "Until " + get_next_break_name()
|
||||
elif(state == State.OffTask):
|
||||
off_time += delta
|
||||
total_off_time += delta
|
||||
#off_clock.text = "[wave amp="+str(off_time/5)+" freq="+str(off_time/20)+"]"
|
||||
#off_clock.text += seconds_to_time(off_time,false)
|
||||
elif(state == State.Break):
|
||||
break_time += delta
|
||||
break_clock.text = seconds_to_time(break_time,false)
|
||||
|
||||
if(update <= 0): #every time the clock is updated it resets the animation, this prevent sit from updating too often
|
||||
update += 0.5
|
||||
off_clock.text = "[shake rate="+str(off_time/5)+" level="+str(off_time/20)+"]"
|
||||
off_clock.text += seconds_to_time(off_time,false)
|
||||
|
||||
|
||||
func _on_popup_menu_id_pressed(id: int) -> void:
|
||||
# 0 = exit
|
||||
if id == 0:
|
||||
get_tree().quit()
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
func _on_off_task_button_pressed() -> void:
|
||||
if state == State.OffTask:
|
||||
state = State.Working
|
||||
off_time = 0
|
||||
else:
|
||||
state = State.OffTask
|
||||
off_time = 0
|
||||
|
||||
|
||||
func _on_pause_button_pressed() -> void:
|
||||
if state == State.Break:
|
||||
state = State.Working
|
||||
else:
|
||||
state = State.Break
|
||||
break_time = 0
|
||||
|
||||
func get_next_break_name() -> String:
|
||||
var currentUnix : int = Time.get_unix_time_from_system()
|
||||
var timezone : Dictionary = Time.get_time_zone_from_system()
|
||||
var todaysUnix : int = (currentUnix % 86400) + 60 * timezone.bias
|
||||
if(todaysUnix > 86400):
|
||||
todaysUnix -= 86400
|
||||
# lunch at 46800
|
||||
# dinner at 64800
|
||||
if(todaysUnix < 46800):
|
||||
return "Lunch"
|
||||
elif(todaysUnix < 64800):
|
||||
return "Dinner"
|
||||
else:
|
||||
return "Midnight"
|
||||
|
||||
# returns the time reaming until next break int he format H:SS
|
||||
func get_next_break_time() -> String:
|
||||
# get current unix time
|
||||
# use % to get the time since midnight - 86400 seconds in one day
|
||||
var currentUnix : int = Time.get_unix_time_from_system()
|
||||
var timezone : Dictionary = Time.get_time_zone_from_system()
|
||||
var todaysUnix : int = (currentUnix % 86400) + 60 * timezone.bias
|
||||
if(todaysUnix > 86400):
|
||||
todaysUnix -= 86400
|
||||
# lunch at 46800
|
||||
# dinner at 64800
|
||||
var seconds_to_break : int = 0
|
||||
if(todaysUnix < 46800):
|
||||
seconds_to_break = 46800 - todaysUnix
|
||||
elif(todaysUnix < 64800):
|
||||
seconds_to_break = 64800 - todaysUnix
|
||||
else:
|
||||
seconds_to_break = 86400 - todaysUnix
|
||||
|
||||
#print("Seconds " + str(seconds_to_break))
|
||||
return seconds_to_time(seconds_to_break)
|
||||
|
||||
func seconds_to_time(seconds : int, has_hours : bool = true) -> String:
|
||||
if(has_hours):
|
||||
var hours : int = seconds / 3600
|
||||
var minutes : int = (seconds / 60) - hours * 60
|
||||
return str(hours).pad_zeros(2) + ":" + str(minutes).pad_zeros(2)
|
||||
else:
|
||||
var minutes : int = (seconds / 60)
|
||||
var dSeconds : int = seconds - minutes * 60
|
||||
return str(minutes).pad_zeros(2) + ":" + str(dSeconds).pad_zeros(2)
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://q31pnijofl0q
|
||||
83
main.gd
83
main.gd
|
|
@ -1,83 +0,0 @@
|
|||
extends Control
|
||||
|
||||
var cell_tag = "MIAW"
|
||||
|
||||
@export var player_name: Label
|
||||
@export var player_rank: Label
|
||||
@export var player_score: Label
|
||||
@export var cell_rank: Label
|
||||
@export var cell_score: Label
|
||||
@export var player_request: HTTPRequest
|
||||
@export var cell_request: HTTPRequest
|
||||
@export var cell_name: Label
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
get_data()
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
func get_data():
|
||||
#var http_client : HTTPClient = HTTPClient.new()
|
||||
#http_client.connect_to_host("https://payphonetag.com/")
|
||||
|
||||
|
||||
var body = JSON.stringify({"pin": "98409"})
|
||||
var error = player_request.request("https://payphonetag.com/api/player-snapshot", [], HTTPClient.METHOD_POST, body)
|
||||
print(error)
|
||||
|
||||
|
||||
var body2 = JSON.stringify({"pin": "98409"})
|
||||
var error2 = cell_request.request("https://payphonetag.com/api/cell/leaderboard", [], HTTPClient.METHOD_GET, body2)
|
||||
print(error2)
|
||||
|
||||
#var fields = { }
|
||||
#var query_string = http_client.query_string_from_dict(fields)
|
||||
#var headers = ["pin : 98409" ,"Content-Type: application/x-www-form-urlencoded", "Content-Length: " + str(query_string.length())]
|
||||
#var player_data = http_client.request(http_client.METHOD_POST, "https://payphonetag.com/api/player-snapshot", headers, '"pin" : "98409"')
|
||||
|
||||
#print(player_data)
|
||||
|
||||
# Called when the HTTP request is completed.
|
||||
func player_request_completed(result, response_code, headers, body):
|
||||
var json = JSON.new()
|
||||
json.parse(body.get_string_from_utf8())
|
||||
var response : Dictionary = json.get_data()
|
||||
|
||||
# Will print the user agent string used by the HTTPRequest node (as recognized by httpbin.org).
|
||||
#print(response.headers["rank"])
|
||||
#print(response.headers["total_score"])
|
||||
print(response.get("rank"))
|
||||
print(response.get("total_score"))
|
||||
player_rank.text = "#" + str(int(response.get("rank")))
|
||||
player_score.text = str(int(response.get("total_score")))
|
||||
|
||||
func cell_request_completed(result, response_code, headers, body):
|
||||
var json = JSON.new()
|
||||
json.parse(body.get_string_from_utf8())
|
||||
var response : Array = json.get_data()
|
||||
|
||||
# Will print the user agent string used by the HTTPRequest node (as recognized by httpbin.org).
|
||||
#print(response.headers["rank"])
|
||||
#print(response.headers["total_score"])
|
||||
#print(response.get("rank"))
|
||||
#print(response.get("total_score"))
|
||||
#print(response)
|
||||
print("meow")
|
||||
for i : int in range(response.size()):
|
||||
if (response[i].get("CellTag") == cell_tag):
|
||||
cell_name.text = response[i].get("CellName") + " [" + response[i].get("CellTag") + "]"
|
||||
cell_rank.text = "#" + str(i+1)
|
||||
cell_score.text = str(int(response[i].get("TotalScore")))
|
||||
return
|
||||
|
||||
|
||||
func _on_popup_menu_id_pressed(id: int) -> void:
|
||||
# 0 = exit
|
||||
if id == 0:
|
||||
get_tree().quit()
|
||||
pass # Replace with function body.
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://dblnpuq85tsmq
|
||||
48
main.tscn
48
main.tscn
|
|
@ -18,7 +18,7 @@ font_size = 11
|
|||
[sub_resource type="LabelSettings" id="LabelSettings_1bvp3"]
|
||||
font_color = Color(0.63375676, 0.6337568, 0.63375676, 1)
|
||||
|
||||
[node name="SleepyClock" type="Control" unique_id=577067945 node_paths=PackedStringArray("bar", "label", "options_window")]
|
||||
[node name="SleepyClock" type="Control" unique_id=577067945 node_paths=PackedStringArray("bar", "label", "options_window", "background")]
|
||||
modulate = Color(1, 1, 1, 0.42745098)
|
||||
top_level = true
|
||||
layout_mode = 3
|
||||
|
|
@ -33,6 +33,7 @@ script = ExtResource("1_h2yge")
|
|||
bar = NodePath("VBoxContainer/MainContent/bar")
|
||||
label = NodePath("VBoxContainer/MainContent/Label")
|
||||
options_window = NodePath("Options Window")
|
||||
background = NodePath("Background")
|
||||
|
||||
[node name="Bar" type="Window" parent="." unique_id=714499816]
|
||||
transparent_bg = true
|
||||
|
|
@ -127,7 +128,7 @@ grow_vertical = 2
|
|||
text = "12:34 Remaining Until Sleepy time, there is alot of space for text you can work with here meow meow meow meow"
|
||||
label_settings = SubResource("LabelSettings_h2yge")
|
||||
|
||||
[node name="Options Window" type="Window" parent="." unique_id=1651073981 node_paths=PackedStringArray("sleep_h", "sleep_m", "duration_h", "duration_m", "size_label", "size_slider")]
|
||||
[node name="Options Window" type="Window" parent="." unique_id=1651073981 node_paths=PackedStringArray("sleep_h", "sleep_m", "duration_h", "duration_m", "size_label", "size_slider", "bar_color", "background_color", "warning_color", "trans_label", "trans_slider")]
|
||||
oversampling_override = 1.0
|
||||
title = "SleepyClock Options"
|
||||
initial_position = 1
|
||||
|
|
@ -143,6 +144,11 @@ duration_h = NodePath("MarginContainer/VBoxContainer/GridContainer/HBoxContainer
|
|||
duration_m = NodePath("MarginContainer/VBoxContainer/GridContainer/HBoxContainer2/durationM")
|
||||
size_label = NodePath("MarginContainer/VBoxContainer/GridContainer/HBoxContainer3/sizeLabel")
|
||||
size_slider = NodePath("MarginContainer/VBoxContainer/GridContainer/HBoxContainer3/sizeSlider")
|
||||
bar_color = NodePath("MarginContainer/VBoxContainer/GridContainer/barColor")
|
||||
background_color = NodePath("MarginContainer/VBoxContainer/GridContainer/backgroundColor")
|
||||
warning_color = NodePath("MarginContainer/VBoxContainer/GridContainer/HBoxContainer4/warningColor")
|
||||
trans_label = NodePath("MarginContainer/VBoxContainer/GridContainer/HBoxContainer7/transLabel")
|
||||
trans_slider = NodePath("MarginContainer/VBoxContainer/GridContainer/HBoxContainer7/transSlider")
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="Options Window" unique_id=426909220]
|
||||
anchors_preset = 15
|
||||
|
|
@ -251,6 +257,30 @@ value = 10.0
|
|||
tick_count = 5
|
||||
ticks_on_borders = true
|
||||
|
||||
[node name="Label11" type="Label" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=1879012879]
|
||||
layout_mode = 2
|
||||
tooltip_text = "How transparent should the bar be"
|
||||
mouse_filter = 1
|
||||
text = "Bar Transparency 🛈"
|
||||
|
||||
[node name="HBoxContainer7" type="HBoxContainer" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=1690404152]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="transLabel" type="Label" parent="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer7" unique_id=1732819966]
|
||||
custom_minimum_size = Vector2(45, 0)
|
||||
layout_mode = 2
|
||||
text = "100%"
|
||||
|
||||
[node name="transSlider" type="HSlider" parent="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer7" unique_id=2119026733]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 4
|
||||
max_value = 1.0
|
||||
step = 0.01
|
||||
value = 1.0
|
||||
tick_count = 10
|
||||
ticks_on_borders = true
|
||||
|
||||
[node name="Label6" type="Label" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=1332307585]
|
||||
layout_mode = 2
|
||||
tooltip_text = "Color that the bar should be under normal conditions"
|
||||
|
|
@ -286,6 +316,8 @@ size_flags_horizontal = 3
|
|||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
max_value = 23.0
|
||||
value = 1.0
|
||||
editable = false
|
||||
suffix = "h"
|
||||
select_all_on_focus = true
|
||||
|
||||
|
|
@ -293,6 +325,7 @@ select_all_on_focus = true
|
|||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
max_value = 59.0
|
||||
editable = false
|
||||
suffix = "m"
|
||||
select_all_on_focus = true
|
||||
|
||||
|
|
@ -305,6 +338,7 @@ text = "flash bar when time ends 🛈"
|
|||
[node name="flashCheck" type="CheckButton" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=1168112585]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
disabled = true
|
||||
|
||||
[node name="Label8" type="Label" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=280072151]
|
||||
layout_mode = 2
|
||||
|
|
@ -343,7 +377,7 @@ select_all_on_focus = true
|
|||
[node name="Label2" type="Label" parent="Options Window/MarginContainer/VBoxContainer" unique_id=201796106]
|
||||
layout_mode = 2
|
||||
text = "todo:
|
||||
- red threshold
|
||||
- warning threshold
|
||||
- display before/after time
|
||||
- text to display inside bar"
|
||||
label_settings = SubResource("LabelSettings_1bvp3")
|
||||
|
|
@ -372,9 +406,9 @@ text = "Save"
|
|||
[connection signal="value_changed" from="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer2/durationM" to="Options Window" method="_on_duration_value_changed"]
|
||||
[connection signal="item_selected" from="Options Window/MarginContainer/VBoxContainer/GridContainer/positionDropdown" to="Options Window" method="_on_position_dropdown_item_selected"]
|
||||
[connection signal="value_changed" from="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer3/sizeSlider" to="Options Window" method="_on_size_slider_value_changed"]
|
||||
[connection signal="value_changed" from="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer4/warningH" to="Options Window" method="_on_duration_value_changed"]
|
||||
[connection signal="value_changed" from="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer4/warningM" to="Options Window" method="_on_duration_value_changed"]
|
||||
[connection signal="value_changed" from="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer5/beforeM" to="Options Window" method="_on_duration_value_changed"]
|
||||
[connection signal="value_changed" from="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer6/afterM" to="Options Window" method="_on_duration_value_changed"]
|
||||
[connection signal="value_changed" from="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer7/transSlider" to="Options Window" method="_on_trans_slider_value_changed"]
|
||||
[connection signal="color_changed" from="Options Window/MarginContainer/VBoxContainer/GridContainer/barColor" to="Options Window" method="_on_bar_color_color_changed"]
|
||||
[connection signal="color_changed" from="Options Window/MarginContainer/VBoxContainer/GridContainer/backgroundColor" to="Options Window" method="_on_background_color_color_changed"]
|
||||
[connection signal="color_changed" from="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer4/warningColor" to="Options Window" method="_on_warning_color_color_changed"]
|
||||
[connection signal="pressed" from="Options Window/MarginContainer/VBoxContainer/HBoxContainer/cancelButton" to="Options Window" method="_on_cancel_button_pressed"]
|
||||
[connection signal="pressed" from="Options Window/MarginContainer/VBoxContainer/HBoxContainer/saveButton" to="Options Window" method="_on_save_button_pressed"]
|
||||
|
|
|
|||
|
|
@ -8,6 +8,15 @@ signal options_changed
|
|||
@export var duration_m: SpinBox
|
||||
@export var size_label: Label
|
||||
@export var size_slider: HSlider
|
||||
@export var bar_color: ColorPickerButton
|
||||
@export var background_color: ColorPickerButton
|
||||
@export var warning_color: ColorPickerButton
|
||||
@export var trans_label: Label
|
||||
@export var trans_slider: HSlider
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
hide()
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
|
|
@ -19,6 +28,7 @@ func _process(delta: float) -> void:
|
|||
#validate inputs?, disable save button if somehow invalid?
|
||||
if visible:
|
||||
size_label.text = str(Data.save.size)+"px"
|
||||
trans_label.text = str(roundi(Data.save.bar_transparency*100))+"%"
|
||||
pass
|
||||
|
||||
|
||||
|
|
@ -31,6 +41,7 @@ func _on_close_requested() -> void:
|
|||
|
||||
func _on_cancel_button_pressed() -> void:
|
||||
Data.load_data()
|
||||
options_changed.emit()
|
||||
hide()
|
||||
|
||||
|
||||
|
|
@ -51,6 +62,10 @@ func _on_visibility_changed() -> void:
|
|||
duration_h.value = int(Data.save.duration/(60*60))
|
||||
duration_m.value = int((Data.save.duration-duration_h.value*60*60)/60)
|
||||
size_slider.value = Data.save.size
|
||||
bar_color.color = Data.save.bar_color
|
||||
background_color.color = Data.save.background_color
|
||||
warning_color.color = Data.save.warning_color
|
||||
trans_slider.value = Data.save.bar_transparency
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
|
|
@ -81,3 +96,23 @@ func _on_position_dropdown_item_selected(index: int) -> void:
|
|||
elif index == 1:
|
||||
Data.save.position = Data.Position.Right
|
||||
options_changed.emit()
|
||||
|
||||
|
||||
func _on_bar_color_color_changed(color: Color) -> void:
|
||||
Data.save.bar_color = color
|
||||
options_changed.emit()
|
||||
|
||||
|
||||
func _on_background_color_color_changed(color: Color) -> void:
|
||||
Data.save.background_color = color
|
||||
options_changed.emit()
|
||||
|
||||
|
||||
func _on_warning_color_color_changed(color: Color) -> void:
|
||||
Data.save.warning_color = color
|
||||
options_changed.emit()
|
||||
|
||||
|
||||
func _on_trans_slider_value_changed(value: float) -> void:
|
||||
Data.save.bar_transparency = value
|
||||
options_changed.emit()
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ config/windows_native_icon="res://Logo/logo taskbar.ico"
|
|||
[autoload]
|
||||
|
||||
Data="*uid://dhp4epdaeuqug"
|
||||
Tools="*uid://cqik2vpkasxsr"
|
||||
|
||||
[display]
|
||||
|
||||
|
|
|
|||
|
|
@ -6,3 +6,7 @@ class_name SleepyclockSave
|
|||
#@export var position : int = 0
|
||||
@export var size : int = 10
|
||||
@export var position : Data.Position = Data.Position.Bottom
|
||||
@export var background_color : Color = Color("51006b")
|
||||
@export var bar_color : Color = Color.DODGER_BLUE
|
||||
@export var warning_color : Color = Color.RED
|
||||
@export var bar_transparency : float = 0.5
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue