From 5b508df088db18616f9280bca2f0eb3a95cee63a Mon Sep 17 00:00:00 2001 From: kdx Date: Mon, 30 Oct 2023 13:25:44 +0100 Subject: time tracker --- Helvetica.ttf | Bin 0 -> 312960 bytes Helvetica.ttf.import | 33 ++++ addons/project-time-tracker/LICENSE | 21 +++ addons/project-time-tracker/SectionGraph.gd | 44 +++++ addons/project-time-tracker/TrackerDock.gd | 209 +++++++++++++++++++++ addons/project-time-tracker/TrackerDock.tscn | 98 ++++++++++ addons/project-time-tracker/TrackerSection.gd | 74 ++++++++ addons/project-time-tracker/TrackerSection.tscn | 45 +++++ addons/project-time-tracker/TrackerSectionColor.gd | 14 ++ .../project-time-tracker/TrackerSectionColor.tscn | 25 +++ addons/project-time-tracker/icon.png | Bin 0 -> 3644 bytes addons/project-time-tracker/icon.png.import | 34 ++++ addons/project-time-tracker/plugin.cfg | 7 + .../project-time-tracker/project-time-tracker.gd | 79 ++++++++ dicaprio.gd | 2 +- dicaprio.tscn | 6 +- project.godot | 4 + project_time_traker.json | 6 + score_points.tscn | 3 + 19 files changed, 700 insertions(+), 4 deletions(-) create mode 100644 Helvetica.ttf create mode 100644 Helvetica.ttf.import create mode 100644 addons/project-time-tracker/LICENSE create mode 100644 addons/project-time-tracker/SectionGraph.gd create mode 100644 addons/project-time-tracker/TrackerDock.gd create mode 100644 addons/project-time-tracker/TrackerDock.tscn create mode 100644 addons/project-time-tracker/TrackerSection.gd create mode 100644 addons/project-time-tracker/TrackerSection.tscn create mode 100644 addons/project-time-tracker/TrackerSectionColor.gd create mode 100644 addons/project-time-tracker/TrackerSectionColor.tscn create mode 100644 addons/project-time-tracker/icon.png create mode 100644 addons/project-time-tracker/icon.png.import create mode 100644 addons/project-time-tracker/plugin.cfg create mode 100644 addons/project-time-tracker/project-time-tracker.gd create mode 100644 project_time_traker.json create mode 100644 score_points.tscn diff --git a/Helvetica.ttf b/Helvetica.ttf new file mode 100644 index 0000000..b8c2f99 Binary files /dev/null and b/Helvetica.ttf differ diff --git a/Helvetica.ttf.import b/Helvetica.ttf.import new file mode 100644 index 0000000..b14d233 --- /dev/null +++ b/Helvetica.ttf.import @@ -0,0 +1,33 @@ +[remap] + +importer="font_data_dynamic" +type="FontFile" +uid="uid://bickqwuayvvpb" +path="res://.godot/imported/Helvetica.ttf-4ae88ce366a656e3058759be76b64bdc.fontdata" + +[deps] + +source_file="res://Helvetica.ttf" +dest_files=["res://.godot/imported/Helvetica.ttf-4ae88ce366a656e3058759be76b64bdc.fontdata"] + +[params] + +Rendering=null +antialiasing=1 +generate_mipmaps=false +multichannel_signed_distance_field=false +msdf_pixel_range=8 +msdf_size=48 +allow_system_fallback=true +force_autohinter=false +hinting=1 +subpixel_positioning=1 +oversampling=0.0 +Fallbacks=null +fallbacks=[] +Compress=null +compress=true +preload=[] +language_support={} +script_support={} +opentype_features={} diff --git a/addons/project-time-tracker/LICENSE b/addons/project-time-tracker/LICENSE new file mode 100644 index 0000000..f626efc --- /dev/null +++ b/addons/project-time-tracker/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Yuri Sizov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/addons/project-time-tracker/SectionGraph.gd b/addons/project-time-tracker/SectionGraph.gd new file mode 100644 index 0000000..6353889 --- /dev/null +++ b/addons/project-time-tracker/SectionGraph.gd @@ -0,0 +1,44 @@ +@tool +extends HBoxContainer + + +# Public properties +var section_colors : Dictionary = {} + + +var sections : Dictionary = {}: + set(value): + sections = value + _update_sections() + + +func _update_sections() -> void: + if (!is_inside_tree()): + return + + var total = 0.0 + for section in sections: + if (section != "Editor"): + total += sections[section] + + for section in sections: + if (section == "Editor"): + continue + + if (get_node_or_null(section)): + get_node(section).size_flags_stretch_ratio = sections[section] / total + else: + var new_section = preload("res://addons/project-time-tracker/TrackerSectionColor.tscn").instantiate() + new_section.name = section + if section_colors.has(section): + new_section.color = section_colors[section] + else: + new_section.color = section_colors["default"] + new_section.size_flags_stretch_ratio = floor(sections[section]) / floor(sections["Editor"]) + add_child(new_section) + + +func clear(): + for child_node in get_children(): + remove_child(child_node) + child_node.queue_free() diff --git a/addons/project-time-tracker/TrackerDock.gd b/addons/project-time-tracker/TrackerDock.gd new file mode 100644 index 0000000..df4825c --- /dev/null +++ b/addons/project-time-tracker/TrackerDock.gd @@ -0,0 +1,209 @@ +@tool +extends Control + + +# Node references +@onready var status_label : Label = $Margin/Layout/Status/StatusLabel +@onready var status_value_label : Label = $Margin/Layout/Status/StatusValue +@onready var pause_button : Button = $Margin/Layout/Controls/PauseButton +@onready var resume_button : Button = $Margin/Layout/Controls/ResumeButton +@onready var clear_button : Button = $Margin/Layout/Status/ClearButton +@onready var section_list : Control = $Margin/Layout/SectionList +@onready var section_graph : Control = $Margin/Layout/SectionGraph +@onready var clear_confirm_dialog : ConfirmationDialog = $ClearConfirmDialog +@onready var clear_section_confirm_dialog : ConfirmationDialog = $ClearSectionConfirmDialog +@onready var timer_update : Timer = $TimerUpdate + + +# Private properties +var _active_tracking : bool = false +var _tracker_started : float = 0.0 +var _tracker_main_view : String = "" +var _tracker_sections : Dictionary = {} +var _section_to_remove : String = "" + +var _section_colors : Dictionary = { + "2D": Color.DEEP_SKY_BLUE, + "3D": Color.CORAL, + "Script": Color.YELLOW, + "AssetLib": Color.MEDIUM_SEA_GREEN, + "default": Color.WHITE +} + + +# Scene references +@onready var section_scene = preload("res://addons/project-time-tracker/TrackerSection.tscn") + + +func _ready() -> void: + _update_theme() + + section_graph.section_colors = _section_colors + + pause_button.pressed.connect(_pause_tracking) + resume_button.pressed.connect(_resume_tracking) + clear_button.pressed.connect(_on_clear_records_requested) + clear_confirm_dialog.confirmed.connect(_on_clear_records_confirmed) + clear_section_confirm_dialog.confirmed.connect(_on_clear_section_confirmed) + timer_update.timeout.connect(_on_timer_update_timeout) + + _tracker_started = Time.get_unix_time_from_system() + + _set_active_tracking(true) + + timer_update.start() + + +func _process(delta: float) -> void: + if (!_active_tracking): + return + + var time_elapsed = 0.0 + for section in _tracker_sections: + if section != "Editor": + time_elapsed += _tracker_sections[section] + + _tracker_sections["Editor"] = time_elapsed + status_value_label.text = "Working for " + Time.get_time_string_from_unix_time(_tracker_sections["Editor"]) + + +# Helpers +func _update_theme() -> void: + if (!Engine.is_editor_hint || !is_inside_tree()): + return + + pause_button.icon = get_theme_icon("Pause", "EditorIcons") + resume_button.icon = get_theme_icon("PlayStart", "EditorIcons") + clear_button.icon = get_theme_icon("Remove", "EditorIcons") + status_label.add_theme_color_override("font_color", get_theme_color("contrast_color_2", "Editor")) + + +func _create_section(section_name: String) -> bool: + if (!Engine.is_editor_hint || !is_inside_tree()): + return false + + if (section_name.is_empty()): + return false + + if section_list.get_node_or_null(section_name): + return true + + var new_section = section_scene.instantiate() + new_section.name = section_name + new_section.section_name = section_name + new_section.on_clear_button_pressed.connect(_on_clear_section_requested) + if _section_colors.has(section_name): + new_section.section_color = _section_colors[section_name] + else: + new_section.section_color = _section_colors["default"] + section_list.add_child(new_section) + + _tracker_sections[section_name] = 0 + + return true + + +func _update_sections() -> void: + if (!Engine.is_editor_hint || !is_inside_tree()): + return + + for section in _tracker_sections: + var node = section_list.get_node_or_null(section) + if (node): + node.elapsed_time = _tracker_sections[section] + + section_graph.sections = _tracker_sections + + +# Tracker functions +func _resume_tracking() -> void: + _set_active_tracking(true) + _tracker_started = Time.get_unix_time_from_system() + + +func _pause_tracking() -> void: + _set_active_tracking(false) + if (_create_section(_tracker_main_view)): + var elapsed_time = Time.get_unix_time_from_system() - _tracker_started + _tracker_sections[_tracker_main_view] += elapsed_time + status_value_label.text = "Pause (" + Time.get_time_string_from_unix_time(_tracker_sections["Editor"]) + ")" + + +# Properties +func set_main_view(view_name: String) -> void: + if (_tracker_main_view == view_name): + return + + #Save only for an minimum elasped time + var elapsed_time = Time.get_unix_time_from_system() - _tracker_started + + if (_active_tracking and elapsed_time >= 1 and _create_section(_tracker_main_view)): + _tracker_sections[_tracker_main_view] += elapsed_time + _tracker_started = Time.get_unix_time_from_system() + + _tracker_main_view = view_name + + +func _set_active_tracking(value: bool) -> void: + _active_tracking = value + + if (_active_tracking): + pause_button.disabled = false + resume_button.disabled = true + else: + pause_button.disabled = true + resume_button.disabled = false + + +func restore_tracked_sections(sections : Dictionary) -> void: + for section in sections: + if (section != "Editor"): + _create_section(section) + _tracker_sections[section] = sections[section] + _update_sections() + + +func get_tracked_sections() -> Dictionary: + return _tracker_sections + + +# Event handlers +func _on_clear_records_requested() -> void: + clear_confirm_dialog.popup_centered(clear_confirm_dialog.size) + + +func _on_clear_records_confirmed() -> void: + _tracker_sections.clear() + for child_node in section_list.get_children(): + section_list.remove_child(child_node) + child_node.queue_free() + section_graph.clear() + + +func _on_timer_update_timeout(): + if (_active_tracking and _create_section(_tracker_main_view)): + var elapsed_time = Time.get_unix_time_from_system() - _tracker_started + _tracker_sections[_tracker_main_view] += elapsed_time + _tracker_started = Time.get_unix_time_from_system() + _update_sections() + + +func _on_clear_section_requested(section_name): + _section_to_remove = section_name + clear_section_confirm_dialog.dialog_text = "This action will remove " + section_name + " section from memory.\n\nDo you want to continue?" + clear_section_confirm_dialog.popup_centered(clear_section_confirm_dialog.size) + + +func _on_clear_section_confirmed(): + _tracker_sections.erase(_section_to_remove) + + if (_tracker_main_view == _section_to_remove): + _tracker_started = Time.get_unix_time_from_system() + + var child_node = section_list.get_node(_section_to_remove) + section_list.remove_child(child_node) + child_node.queue_free() + + _section_to_remove = "" + section_graph.clear() + _update_sections() diff --git a/addons/project-time-tracker/TrackerDock.tscn b/addons/project-time-tracker/TrackerDock.tscn new file mode 100644 index 0000000..3c85475 --- /dev/null +++ b/addons/project-time-tracker/TrackerDock.tscn @@ -0,0 +1,98 @@ +[gd_scene load_steps=5 format=3 uid="uid://bnpcoyrwqfprq"] + +[ext_resource type="Script" path="res://addons/project-time-tracker/TrackerDock.gd" id="1_7v1fu"] +[ext_resource type="Script" path="res://addons/project-time-tracker/SectionGraph.gd" id="2_0xje5"] + +[sub_resource type="Image" id="Image_2rpds"] +data = { +"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0), +"format": "RGBA8", +"height": 16, +"mipmaps": false, +"width": 16 +} + +[sub_resource type="ImageTexture" id="ImageTexture_8wfe8"] +image = SubResource("Image_2rpds") + +[node name="TrackerDock" type="Control"] +layout_mode = 3 +anchors_preset = 0 +script = ExtResource("1_7v1fu") + +[node name="Margin" type="MarginContainer" parent="."] +layout_mode = 0 +anchor_right = 1.0 +anchor_bottom = 1.0 + +[node name="Layout" type="VBoxContainer" parent="Margin"] +layout_mode = 2 + +[node name="Status" type="HBoxContainer" parent="Margin/Layout"] +layout_mode = 2 + +[node name="StatusLabel" type="Label" parent="Margin/Layout/Status"] +layout_mode = 2 +theme_override_colors/font_color = Color(0, 0, 0, 1) +text = "Status: " + +[node name="StatusValue" type="Label" parent="Margin/Layout/Status"] +layout_mode = 2 +size_flags_horizontal = 3 +text = "Working for 00:00:00" + +[node name="ClearButton" type="Button" parent="Margin/Layout/Status"] +layout_mode = 2 +icon = SubResource("ImageTexture_8wfe8") +flat = true + +[node name="Padding1" type="Control" parent="Margin/Layout"] +layout_mode = 2 + +[node name="Controls" type="HBoxContainer" parent="Margin/Layout"] +layout_mode = 2 + +[node name="ResumeButton" type="Button" parent="Margin/Layout/Controls"] +layout_mode = 2 +size_flags_horizontal = 3 +disabled = true +text = "Resume" +icon = SubResource("ImageTexture_8wfe8") + +[node name="PauseButton" type="Button" parent="Margin/Layout/Controls"] +layout_mode = 2 +size_flags_horizontal = 3 +text = "Pause" +icon = SubResource("ImageTexture_8wfe8") + +[node name="Padding2" type="Control" parent="Margin/Layout"] +layout_mode = 2 + +[node name="SectionList" type="VBoxContainer" parent="Margin/Layout"] +layout_mode = 2 + +[node name="Padding3" type="Control" parent="Margin/Layout"] +layout_mode = 2 + +[node name="SectionGraph" type="HBoxContainer" parent="Margin/Layout"] +custom_minimum_size = Vector2(0, 15) +layout_mode = 2 +theme_override_constants/separation = 0 +script = ExtResource("2_0xje5") + +[node name="ClearConfirmDialog" type="ConfirmationDialog" parent="."] +size = Vector2i(400, 200) +dialog_text = "This action will clear all recorded sections from memory. + +Do you want to continue?" +dialog_autowrap = true + +[node name="ClearSectionConfirmDialog" type="ConfirmationDialog" parent="."] +size = Vector2i(400, 200) +dialog_text = "This action will clear all recorded sessions from memory. + +Do you want to continue?" +dialog_autowrap = true + +[node name="TimerUpdate" type="Timer" parent="."] +autostart = true diff --git a/addons/project-time-tracker/TrackerSection.gd b/addons/project-time-tracker/TrackerSection.gd new file mode 100644 index 0000000..6880060 --- /dev/null +++ b/addons/project-time-tracker/TrackerSection.gd @@ -0,0 +1,74 @@ +@tool +extends VBoxContainer + +signal on_clear_button_pressed(section_name) + +# Node references +@onready var icon_texture : TextureRect = $Information/IconContainer/Icon +@onready var name_label : Label = $Information/NameLabel +@onready var elapsed_time_label : Label = $Information/ElapsedLabel +@onready var clear_button : Button = $Information/ClearButton + +# Public properties +@export var section_name : String = "" : + set(value) : + section_name = value + _update_name() + +@export var section_color : Color = Color.WHITE : + set(value) : + section_color = value + _update_icon() + +@export var elapsed_time : int = 0 : + set(value) : + elapsed_time = value + _update_elapsed_time() + +# Private properties +var _section_icon : Texture + + +func _ready() -> void: + + clear_button.pressed.connect(_on_clear_button_pressed) + + _update_theme() + _update_icon() + _update_name() + _update_elapsed_time() + + +# Helpers +func _update_theme() -> void: + if (!Engine.is_editor_hint || !is_inside_tree()): + return + + _section_icon = get_theme_icon("Node", "EditorIcons") + clear_button.icon = get_theme_icon("Remove", "EditorIcons") + + +func _update_icon() -> void: + if (!is_inside_tree()): + return + + icon_texture.texture = _section_icon + icon_texture.modulate = section_color + + +func _update_name() -> void: + if (!is_inside_tree()): + return + + name_label.text = section_name + + +func _update_elapsed_time() -> void: + if (!is_inside_tree()): + return + + elapsed_time_label.text = Time.get_time_string_from_unix_time(elapsed_time) + + +func _on_clear_button_pressed(): + on_clear_button_pressed.emit(section_name) diff --git a/addons/project-time-tracker/TrackerSection.tscn b/addons/project-time-tracker/TrackerSection.tscn new file mode 100644 index 0000000..c6cdbed --- /dev/null +++ b/addons/project-time-tracker/TrackerSection.tscn @@ -0,0 +1,45 @@ +[gd_scene load_steps=4 format=3 uid="uid://rmi3joaeeoc"] + +[ext_resource type="Script" path="res://addons/project-time-tracker/TrackerSection.gd" id="1_qrte8"] + +[sub_resource type="Image" id="Image_6n100"] +data = { +"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0), +"format": "RGBA8", +"height": 16, +"mipmaps": false, +"width": 16 +} + +[sub_resource type="ImageTexture" id="ImageTexture_mmcci"] +image = SubResource("Image_6n100") + +[node name="TrackerSection" type="VBoxContainer"] +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +size_flags_horizontal = 3 +script = ExtResource("1_qrte8") + +[node name="Information" type="HBoxContainer" parent="."] +layout_mode = 2 + +[node name="IconContainer" type="CenterContainer" parent="Information"] +layout_mode = 2 + +[node name="Icon" type="TextureRect" parent="Information/IconContainer"] +layout_mode = 2 +texture = SubResource("ImageTexture_mmcci") + +[node name="NameLabel" type="Label" parent="Information"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="ElapsedLabel" type="Label" parent="Information"] +layout_mode = 2 +text = "00:00:00" + +[node name="ClearButton" type="Button" parent="Information"] +layout_mode = 2 +icon = SubResource("ImageTexture_mmcci") +flat = true diff --git a/addons/project-time-tracker/TrackerSectionColor.gd b/addons/project-time-tracker/TrackerSectionColor.gd new file mode 100644 index 0000000..19ff078 --- /dev/null +++ b/addons/project-time-tracker/TrackerSectionColor.gd @@ -0,0 +1,14 @@ +@tool +extends ColorRect + + +func _process(delta: float) -> void: + if (!Engine.is_editor_hint || !is_inside_tree()): + return + + var percent = floor(size_flags_stretch_ratio * 100) + + if (percent >= 10): + $Percent.text = str(percent) + "%" + else: + $Percent.text = "" diff --git a/addons/project-time-tracker/TrackerSectionColor.tscn b/addons/project-time-tracker/TrackerSectionColor.tscn new file mode 100644 index 0000000..d58dfc7 --- /dev/null +++ b/addons/project-time-tracker/TrackerSectionColor.tscn @@ -0,0 +1,25 @@ +[gd_scene load_steps=2 format=3 uid="uid://bi6q1vpo6pn0i"] + +[ext_resource type="Script" path="res://addons/project-time-tracker/TrackerSectionColor.gd" id="1_t3kj1"] + +[node name="TrackerSectionColor" type="ColorRect"] +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +size_flags_horizontal = 3 +color = Color(0, 0, 0, 1) +script = ExtResource("1_t3kj1") + +[node name="Percent" type="Label" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_colors/font_color = Color(0, 0, 0, 1) +text = "100%" +horizontal_alignment = 1 +vertical_alignment = 1 diff --git a/addons/project-time-tracker/icon.png b/addons/project-time-tracker/icon.png new file mode 100644 index 0000000..2994e26 Binary files /dev/null and b/addons/project-time-tracker/icon.png differ diff --git a/addons/project-time-tracker/icon.png.import b/addons/project-time-tracker/icon.png.import new file mode 100644 index 0000000..01707ae --- /dev/null +++ b/addons/project-time-tracker/icon.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://oo5r5lubxdep" +path="res://.godot/imported/icon.png-43a6e44349f3cba4404c1b2f96ce1c90.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/project-time-tracker/icon.png" +dest_files=["res://.godot/imported/icon.png-43a6e44349f3cba4404c1b2f96ce1c90.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 diff --git a/addons/project-time-tracker/plugin.cfg b/addons/project-time-tracker/plugin.cfg new file mode 100644 index 0000000..f768fd3 --- /dev/null +++ b/addons/project-time-tracker/plugin.cfg @@ -0,0 +1,7 @@ +[plugin] + +name="Project Time Tracker" +description="Project Time Tracker by Fifut" +author="Fifut" +version="2.0.0" +script="project-time-tracker.gd" diff --git a/addons/project-time-tracker/project-time-tracker.gd b/addons/project-time-tracker/project-time-tracker.gd new file mode 100644 index 0000000..7854213 --- /dev/null +++ b/addons/project-time-tracker/project-time-tracker.gd @@ -0,0 +1,79 @@ +@tool +extends EditorPlugin + +const STORED_SECTIONS_PATH : String = "res://project_time_traker.json" + +var _dock_instance : Control + + +func _enter_tree(): + _dock_instance = preload("res://addons/project-time-tracker/TrackerDock.tscn").instantiate() + _dock_instance.name = "ProjectTimeTracker" + add_control_to_dock(EditorPlugin.DOCK_SLOT_RIGHT_BL, _dock_instance) + + _load_sections() + + main_screen_changed.connect(_on_main_screen_changed) + get_editor_interface().set_main_screen_editor("3D") + + +func _exit_tree(): + remove_control_from_docks(_dock_instance) + _dock_instance.queue_free() + + +func _make_visible(visible): + if _dock_instance: + _dock_instance.visible = visible + + +func _save_external_data(): + _store_sections() + + +func _get_plugin_icon(): + return preload("res://addons/project-time-tracker/icon.png") + + +func _load_sections() -> void: + if (!FileAccess.file_exists(STORED_SECTIONS_PATH)): + return + + var file = FileAccess.open(STORED_SECTIONS_PATH, FileAccess.READ) + var error = FileAccess.get_open_error() + if (error != OK): + printerr("Failed to open file '" + STORED_SECTIONS_PATH + "' for reading: Error code " + str(error)) + return + + var json = JSON.new() + var parse_result = json.parse_string(file.get_as_text()) + var parse_error = json.get_error_message() + if (parse_error != ""): + printerr("Failed to parse tracked sections: Error code " + parse_error) + else: + _dock_instance.restore_tracked_sections(parse_result) + + file.close() + + +func _store_sections() -> void: + var tracked_sections = _dock_instance.get_tracked_sections() + var stored_string = JSON.stringify(tracked_sections, " ") + + var file = FileAccess.open(STORED_SECTIONS_PATH, FileAccess.WRITE) + var error = FileAccess.get_open_error() + if (error != OK): + printerr("Failed to open file '" + STORED_SECTIONS_PATH + "' for writing: Error code " + str(error)) + return + + file.store_string(stored_string) + error = file.get_error() + if (error != OK): + printerr("Failed to store tracked sections: Error code " + str(error)) + + file.close() + + +func _on_main_screen_changed(main_screen: String) -> void: + if (_dock_instance && is_instance_valid(_dock_instance)): + _dock_instance.set_main_view(main_screen) diff --git a/dicaprio.gd b/dicaprio.gd index bddbe40..fa298b7 100644 --- a/dicaprio.gd +++ b/dicaprio.gd @@ -21,7 +21,7 @@ func _on_area_entered(area: Area2D) -> void: "arrow": area.damage(self) "dicaprio": - position -= (area.position - position).normalized() * 8 + position -= (area.position - position).normalized() * speed * 2 func damage(x: float) -> void: diff --git a/dicaprio.tscn b/dicaprio.tscn index 976a401..41e3cde 100644 --- a/dicaprio.tscn +++ b/dicaprio.tscn @@ -10,9 +10,6 @@ height = 174.0 [node name="Area2D" type="Area2D"] script = ExtResource("1_wrbpo") -[node name="CollisionShape2D" type="CollisionShape2D" parent="."] -shape = SubResource("CapsuleShape2D_sakix") - [node name="Sprite2D" type="Sprite2D" parent="."] scale = Vector2(0.5, 0.5) texture = ExtResource("1_6cbbs") @@ -21,4 +18,7 @@ texture = ExtResource("1_6cbbs") scale = Vector2(0.5, 0.5) texture = ExtResource("1_6cbbs") +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("CapsuleShape2D_sakix") + [connection signal="area_entered" from="." to="." method="_on_area_entered"] diff --git a/project.godot b/project.godot index 80cbbfd..1b128b8 100644 --- a/project.godot +++ b/project.godot @@ -27,6 +27,10 @@ window/size/viewport_height=960 window/stretch/mode="canvas_items" mouse_cursor/custom_image="res://cursor.png" +[editor_plugins] + +enabled=PackedStringArray("res://addons/project-time-tracker/plugin.cfg") + [input] 1={ diff --git a/project_time_traker.json b/project_time_traker.json new file mode 100644 index 0000000..81ed0e6 --- /dev/null +++ b/project_time_traker.json @@ -0,0 +1,6 @@ +{ + "2D": 3.02399969100952, + "3D": 3.99900007247925, + "Editor": 301.720999956131, + "Script": 294.698000192642 +} \ No newline at end of file diff --git a/score_points.tscn b/score_points.tscn new file mode 100644 index 0000000..14cc060 --- /dev/null +++ b/score_points.tscn @@ -0,0 +1,3 @@ +[gd_scene format=3 uid="uid://d0kjmjo87gpv3"] + +[node name="ScorePoints" type="Node2D"] -- cgit v1.2.3