solid progress

This commit is contained in:
Tabby 2025-05-31 13:03:59 +10:00
parent 8eb17bc565
commit 25aba0028d
28 changed files with 642 additions and 2 deletions

4
.editorconfig Normal file
View file

@ -0,0 +1,4 @@
root = true
[*]
charset = utf-8

4
.gitattributes vendored
View file

@ -1,2 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
# Normalize EOL for all files that Git considers text files.
* text=auto eol=lf

3
.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
# Godot 4+ specific ignores
.godot/
/android/

BIN
Sprites/Pause.pdn Normal file

Binary file not shown.

BIN
Sprites/offTask.pdn Normal file

Binary file not shown.

BIN
Sprites/offTask.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 441 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://brljmipci58rq"
path="res://.godot/imported/offTask.png-4088ef42c4e956c24345f79ce068106b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/offTask.png"
dest_files=["res://.godot/imported/offTask.png-4088ef42c4e956c24345f79ce068106b.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

BIN
Sprites/offTaskHover.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://duvep02qg1u5d"
path="res://.godot/imported/offTaskHover.png-204a2399884ee63b4217e3d29749aa85.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/offTaskHover.png"
dest_files=["res://.godot/imported/offTaskHover.png-204a2399884ee63b4217e3d29749aa85.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

BIN
Sprites/offTaskPressed.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 441 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c2hn0uem08y1x"
path="res://.godot/imported/offTaskPressed.png-62dd4b8b127a98f8dd4490862ecc477b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/offTaskPressed.png"
dest_files=["res://.godot/imported/offTaskPressed.png-62dd4b8b127a98f8dd4490862ecc477b.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

BIN
Sprites/paused.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 B

34
Sprites/paused.png.import Normal file
View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://buemgq8amjorw"
path="res://.godot/imported/paused.png-ea3edd41c02e88690e5027d82af3c668.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/paused.png"
dest_files=["res://.godot/imported/paused.png-ea3edd41c02e88690e5027d82af3c668.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

BIN
Sprites/pausedHover.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 402 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cdmqqnh3ofp8u"
path="res://.godot/imported/pausedHover.png-58a8e779a35e62cd8e888592ae048e05.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/pausedHover.png"
dest_files=["res://.godot/imported/pausedHover.png-58a8e779a35e62cd8e888592ae048e05.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

BIN
Sprites/pausedPressed.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b7kxpcujq3cqn"
path="res://.godot/imported/pausedPressed.png-e86f1d6be1518ed430556c08151d3173.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/pausedPressed.png"
dest_files=["res://.godot/imported/pausedPressed.png-e86f1d6be1518ed430556c08151d3173.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

BIN
Sprites/statusIcon.pdn Normal file

Binary file not shown.

BIN
Sprites/statusIcon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b502wtiwv20em"
path="res://.godot/imported/statusIcon.png-56aff46cca01790c3229dbdd9ca30440.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/statusIcon.png"
dest_files=["res://.godot/imported/statusIcon.png-56aff46cca01790c3229dbdd9ca30440.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

26
TitleBar.gd Normal file
View file

@ -0,0 +1,26 @@
extends Control
var following = false
var dragging_start_position : Vector2i = Vector2i()
func _on_TitleBar_gui_input(event):
if event is InputEventMouseButton:
#print(event)
if event.get_button_index() == 1:
following = !following
dragging_start_position = get_local_mouse_position()
func _process(_delta):
if following:
get_window().position = get_window().position + Vector2i(get_global_mouse_position()) - dragging_start_position
#OS.set_window_position(OS.window_position + get_global_mouse_position() - dragging_start_position)
#
#func _on_CloseButton_pressed():
#get_tree().quit()
#func _on_MinimizeButton_pressed():
#OS.set_window_minimized(true)

1
TitleBar.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://njpp5gvmxi7f

1
icon.svg Normal file
View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128"><rect width="124" height="124" x="2" y="2" fill="#363d52" stroke="#212532" stroke-width="4" rx="14"/><g fill="#fff" transform="translate(12.322 12.322)scale(.101)"><path d="M105 673v33q407 354 814 0v-33z"/><path fill="#478cbf" d="m105 673 152 14q12 1 15 14l4 67 132 10 8-61q2-11 15-15h162q13 4 15 15l8 61 132-10 4-67q3-13 15-14l152-14V427q30-39 56-81-35-59-83-108-43 20-82 47-40-37-88-64 7-51 8-102-59-28-123-42-26 43-46 89-49-7-98 0-20-46-46-89-64 14-123 42 1 51 8 102-48 27-88 64-39-27-82-47-48 49-83 108 26 42 56 81zm0 33v39c0 276 813 276 814 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H446l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z"/><path d="M483 600c0 34 58 34 58 0v-86c0-34-58-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042" transform="translate(12.322 12.322)scale(.101)"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></svg>

After

Width:  |  Height:  |  Size: 994 B

37
icon.svg.import Normal file
View file

@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dlnt7jmsgs8x2"
path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://icon.svg"
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

126
logic.gd Normal file
View file

@ -0,0 +1,126 @@
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):
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
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
# 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
# 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
logic.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://q31pnijofl0q

173
main.tscn Normal file
View file

@ -0,0 +1,173 @@
[gd_scene load_steps=10 format=3 uid="uid://df4wh83ypl085"]
[ext_resource type="Script" uid="uid://q31pnijofl0q" path="res://logic.gd" id="1_0xm2m"]
[ext_resource type="Script" uid="uid://njpp5gvmxi7f" path="res://TitleBar.gd" id="1_ig7tw"]
[ext_resource type="Texture2D" uid="uid://brljmipci58rq" path="res://Sprites/offTask.png" id="3_7mycd"]
[ext_resource type="Texture2D" uid="uid://b502wtiwv20em" path="res://Sprites/statusIcon.png" id="3_h2yge"]
[ext_resource type="Texture2D" uid="uid://c2hn0uem08y1x" path="res://Sprites/offTaskPressed.png" id="4_272bh"]
[ext_resource type="Texture2D" uid="uid://duvep02qg1u5d" path="res://Sprites/offTaskHover.png" id="5_5vw27"]
[ext_resource type="Texture2D" uid="uid://buemgq8amjorw" path="res://Sprites/paused.png" id="6_kek77"]
[ext_resource type="Texture2D" uid="uid://b7kxpcujq3cqn" path="res://Sprites/pausedPressed.png" id="7_4c57u"]
[ext_resource type="Texture2D" uid="uid://cdmqqnh3ofp8u" path="res://Sprites/pausedHover.png" id="8_efxa6"]
[node name="Control" type="Control" node_paths=PackedStringArray("on_task_panel", "off_task_panel", "break_panel", "background", "on_clock", "off_clock", "break_clock", "next_break_text", "time_spent_text")]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_0xm2m")
colors = Array[Color]([Color(0.321569, 0.321569, 0.321569, 1), Color(0.612149, 0, 0.151715, 1), Color(3.36915e-07, 0.391146, 0.157066, 1)])
on_task_panel = NodePath("VBoxContainer/MainContent/OnTask")
off_task_panel = NodePath("VBoxContainer/MainContent/OffTask")
break_panel = NodePath("VBoxContainer/MainContent/Break")
background = NodePath("Background")
on_clock = NodePath("VBoxContainer/MainContent/OnTask/OnTaskClock")
off_clock = NodePath("VBoxContainer/MainContent/OffTask/OffTaskTimer")
break_clock = NodePath("VBoxContainer/MainContent/Break/BreakTimer")
next_break_text = NodePath("VBoxContainer/MainContent/OnTask/NextBreakText")
time_spent_text = NodePath("VBoxContainer/MainContent/OnTask/TimeSpentWorking")
[node name="Background" type="ColorRect" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0.321728, 0.321728, 0.321728, 1)
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="TitleBar" type="PanelContainer" parent="VBoxContainer"]
layout_mode = 2
script = ExtResource("1_ig7tw")
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/TitleBar"]
layout_mode = 2
alignment = 1
[node name="Label" type="Label" parent="VBoxContainer/TitleBar/HBoxContainer"]
layout_mode = 2
text = "Focus Tool"
[node name="MainContent" type="Control" parent="VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3
[node name="OnTask" type="VBoxContainer" parent="VBoxContainer/MainContent"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_vertical = 3
alignment = 1
[node name="OnTaskClock" type="RichTextLabel" parent="VBoxContainer/MainContent/OnTask"]
layout_mode = 2
theme_override_font_sizes/normal_font_size = 52
text = "2:32"
fit_content = true
horizontal_alignment = 1
vertical_alignment = 1
[node name="NextBreakText" type="RichTextLabel" parent="VBoxContainer/MainContent/OnTask"]
layout_mode = 2
text = "Until Lunch"
fit_content = true
horizontal_alignment = 1
[node name="TimeSpentWorking" type="RichTextLabel" parent="VBoxContainer/MainContent/OnTask"]
layout_mode = 2
theme_override_colors/default_color = Color(0.564962, 0.564962, 0.564962, 1)
text = "2:00 Spent working"
fit_content = true
horizontal_alignment = 1
[node name="OffTask" type="VBoxContainer" parent="VBoxContainer/MainContent"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_vertical = 3
alignment = 1
[node name="OffTaskTimer" type="RichTextLabel" parent="VBoxContainer/MainContent/OffTask"]
layout_mode = 2
theme_override_font_sizes/normal_font_size = 52
bbcode_enabled = true
text = "2:32"
fit_content = true
horizontal_alignment = 1
vertical_alignment = 1
[node name="Label" type="RichTextLabel" parent="VBoxContainer/MainContent/OffTask"]
layout_mode = 2
text = "Off Task"
fit_content = true
horizontal_alignment = 1
[node name="Break" type="VBoxContainer" parent="VBoxContainer/MainContent"]
visible = false
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_vertical = 3
alignment = 1
[node name="BreakTimer" type="RichTextLabel" parent="VBoxContainer/MainContent/Break"]
layout_mode = 2
theme_override_font_sizes/normal_font_size = 52
text = "2:32"
fit_content = true
horizontal_alignment = 1
vertical_alignment = 1
[node name="Label" type="RichTextLabel" parent="VBoxContainer/MainContent/Break"]
layout_mode = 2
text = "On Break"
fit_content = true
horizontal_alignment = 1
[node name="Buttons" type="HBoxContainer" parent="VBoxContainer"]
layout_mode = 2
[node name="OffTaskButton" type="TextureButton" parent="VBoxContainer/Buttons"]
layout_mode = 2
texture_normal = ExtResource("3_7mycd")
texture_pressed = ExtResource("4_272bh")
texture_hover = ExtResource("5_5vw27")
[node name="PauseButton" type="TextureButton" parent="VBoxContainer/Buttons"]
layout_mode = 2
texture_normal = ExtResource("6_kek77")
texture_pressed = ExtResource("7_4c57u")
texture_hover = ExtResource("8_efxa6")
[node name="StatusIndicator" type="StatusIndicator" parent="."]
icon = ExtResource("3_h2yge")
menu = NodePath("PopupMenu")
[node name="PopupMenu" type="PopupMenu" parent="StatusIndicator"]
item_count = 1
item_0/text = "Exit"
item_0/id = 0
[connection signal="gui_input" from="VBoxContainer/TitleBar" to="VBoxContainer/TitleBar" method="_on_TitleBar_gui_input"]
[connection signal="pressed" from="VBoxContainer/Buttons/OffTaskButton" to="." method="_on_off_task_button_pressed"]
[connection signal="pressed" from="VBoxContainer/Buttons/PauseButton" to="." method="_on_pause_button_pressed"]
[connection signal="id_pressed" from="StatusIndicator/PopupMenu" to="." method="_on_popup_menu_id_pressed"]

30
project.godot Normal file
View file

@ -0,0 +1,30 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=5
[application]
config/name="Focus Tool"
run/main_scene="uid://df4wh83ypl085"
config/features=PackedStringArray("4.4", "GL Compatibility")
config/icon="res://icon.svg"
[display]
window/size/viewport_width=200
window/size/viewport_height=180
window/size/resizable=false
window/size/borderless=true
window/size/always_on_top=true
[rendering]
textures/canvas_textures/default_texture_filter=0
renderer/rendering_method="gl_compatibility"
renderer/rendering_method.mobile="gl_compatibility"