finish first version
This commit is contained in:
parent
6c119e9c83
commit
34882c3d4b
23 changed files with 814 additions and 110 deletions
.gitignoreMakefile
assets
components
data
export_presets.cfgmain.gdmain.tscnpages
project.godotsave_manager
styles
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -1,2 +1,7 @@
|
|||
# Godot 4+ specific ignores
|
||||
.godot/
|
||||
|
||||
# Android
|
||||
android/
|
||||
*.apk
|
||||
*.apk.idsig
|
||||
|
|
14
Makefile
Normal file
14
Makefile
Normal file
|
@ -0,0 +1,14 @@
|
|||
ANDROID_PACKAGE_NAME = ru.pleshevski.boronotes
|
||||
ANDROID_DEBUG_FILE = Boronotes.apk
|
||||
|
||||
help:
|
||||
cat Makefile
|
||||
|
||||
android-build-debug:
|
||||
godot4 --headless --export-debug "Android" $(ANDROID_DEBUG_FILE)
|
||||
|
||||
android-install: android-build
|
||||
adb install $(ANDROID_DEBUG_FILE)
|
||||
|
||||
android-uninstall:
|
||||
adb shell pm uninstall $(ANDROID_PACKAGE_NAME)
|
BIN
assets/add.png
Normal file
BIN
assets/add.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 10 KiB |
34
assets/add.png.import
Normal file
34
assets/add.png.import
Normal file
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://b5djp0ut3b0ck"
|
||||
path="res://.godot/imported/add.png-49fe8db0fedbecae82b656c4501f68bc.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/add.png"
|
||||
dest_files=["res://.godot/imported/add.png-49fe8db0fedbecae82b656c4501f68bc.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
assets/close.png
Normal file
BIN
assets/close.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 8.2 KiB |
34
assets/close.png.import
Normal file
34
assets/close.png.import
Normal file
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://c56dek8bl3vq0"
|
||||
path="res://.godot/imported/close.png-5dfda58792925f4ecef1b7dd0e814906.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/close.png"
|
||||
dest_files=["res://.godot/imported/close.png-5dfda58792925f4ecef1b7dd0e814906.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
assets/save.png
Normal file
BIN
assets/save.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 6.9 KiB |
34
assets/save.png.import
Normal file
34
assets/save.png.import
Normal file
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cwnsbx7xl0syt"
|
||||
path="res://.godot/imported/save.png-9622b5303508ebb9968ebd80fc3666f1.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/save.png"
|
||||
dest_files=["res://.godot/imported/save.png-9622b5303508ebb9968ebd80fc3666f1.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
|
25
components/edit_note_item/edit_note_item.gd
Normal file
25
components/edit_note_item/edit_note_item.gd
Normal file
|
@ -0,0 +1,25 @@
|
|||
class_name EditNoteItem
|
||||
extends PanelContainer
|
||||
|
||||
signal deleted(note: Note)
|
||||
|
||||
@export var note: Note :
|
||||
set(new_note):
|
||||
if note != new_note:
|
||||
note = new_note
|
||||
if line_edit:
|
||||
line_edit.text = note.title
|
||||
|
||||
@onready var line_edit: LineEdit = %LineEdit
|
||||
|
||||
|
||||
func _ready():
|
||||
line_edit.text = note.title
|
||||
|
||||
|
||||
func _on_line_edit_text_changed(new_text: String):
|
||||
note.title = new_text
|
||||
|
||||
|
||||
func _on_delete_button_pressed():
|
||||
deleted.emit(note)
|
41
components/edit_note_item/edit_note_item.tscn
Normal file
41
components/edit_note_item/edit_note_item.tscn
Normal file
|
@ -0,0 +1,41 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://cy7qciptrj71w"]
|
||||
|
||||
[ext_resource type="Script" path="res://components/edit_note_item/edit_note_item.gd" id="1_0fnc8"]
|
||||
[ext_resource type="Texture2D" uid="uid://c56dek8bl3vq0" path="res://assets/close.png" id="2_gotov"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_q7ab1"]
|
||||
bg_color = Color(1, 1, 1, 0.784314)
|
||||
corner_radius_top_left = 6
|
||||
corner_radius_top_right = 6
|
||||
corner_radius_bottom_right = 6
|
||||
corner_radius_bottom_left = 6
|
||||
|
||||
[node name="EditNoteItem" type="PanelContainer"]
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_q7ab1")
|
||||
script = ExtResource("1_0fnc8")
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 9
|
||||
theme_override_constants/margin_top = 6
|
||||
theme_override_constants/margin_right = 9
|
||||
theme_override_constants/margin_bottom = 6
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="LineEdit" type="LineEdit" parent="MarginContainer/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
placeholder_text = "Введите заметку"
|
||||
|
||||
[node name="DeleteButton" type="Button" parent="MarginContainer/HBoxContainer"]
|
||||
custom_minimum_size = Vector2(32, 32)
|
||||
layout_mode = 2
|
||||
icon = ExtResource("2_gotov")
|
||||
flat = true
|
||||
expand_icon = true
|
||||
|
||||
[connection signal="text_changed" from="MarginContainer/HBoxContainer/LineEdit" to="." method="_on_line_edit_text_changed"]
|
||||
[connection signal="pressed" from="MarginContainer/HBoxContainer/DeleteButton" to="." method="_on_delete_button_pressed"]
|
|
@ -17,5 +17,8 @@ func _ready():
|
|||
button.text = note.title
|
||||
|
||||
|
||||
|
||||
func _on_button_pressed():
|
||||
pressed.emit(note)
|
||||
|
||||
|
||||
|
|
15
data/change_note.gd
Normal file
15
data/change_note.gd
Normal file
|
@ -0,0 +1,15 @@
|
|||
class_name ChangeNote
|
||||
extends Resource
|
||||
|
||||
enum Kind {
|
||||
ADDED,
|
||||
CHANGED,
|
||||
DELETED,
|
||||
}
|
||||
|
||||
@export var kind: Kind
|
||||
@export var note: Note
|
||||
|
||||
func _init(change_kind: Kind, change_note: Note):
|
||||
kind = change_kind
|
||||
note = change_note
|
11
data/note.gd
11
data/note.gd
|
@ -8,8 +8,9 @@ const uuid = preload("res://utils/uuid.gd")
|
|||
@export var title: String
|
||||
|
||||
|
||||
func _init(note_title: String, note_parent_id: String = ""):
|
||||
id = uuid.v4()
|
||||
title = note_title
|
||||
parent_id = note_parent_id
|
||||
|
||||
static func create(note_title: String, note_parent_id: String = "") -> Note:
|
||||
var note = Note.new()
|
||||
note.id = uuid.v4()
|
||||
note.title = note_title
|
||||
note.parent_id = note_parent_id
|
||||
return note
|
||||
|
|
239
export_presets.cfg
Normal file
239
export_presets.cfg
Normal file
|
@ -0,0 +1,239 @@
|
|||
[preset.0]
|
||||
|
||||
name="Android"
|
||||
platform="Android"
|
||||
runnable=true
|
||||
dedicated_server=false
|
||||
custom_features=""
|
||||
export_filter="all_resources"
|
||||
include_filter=""
|
||||
exclude_filter=""
|
||||
export_path=""
|
||||
encryption_include_filters=""
|
||||
encryption_exclude_filters=""
|
||||
encrypt_pck=false
|
||||
encrypt_directory=false
|
||||
|
||||
[preset.0.options]
|
||||
|
||||
custom_template/debug=""
|
||||
custom_template/release=""
|
||||
gradle_build/use_gradle_build=false
|
||||
gradle_build/export_format=0
|
||||
gradle_build/min_sdk=""
|
||||
gradle_build/target_sdk=""
|
||||
architectures/armeabi-v7a=false
|
||||
architectures/arm64-v8a=true
|
||||
architectures/x86=false
|
||||
architectures/x86_64=false
|
||||
version/code=1
|
||||
version/name=""
|
||||
package/unique_name="com.example.$genname"
|
||||
package/name=""
|
||||
package/signed=true
|
||||
package/app_category=2
|
||||
package/retain_data_on_uninstall=false
|
||||
package/exclude_from_recents=false
|
||||
package/show_in_android_tv=false
|
||||
package/show_in_app_library=true
|
||||
package/show_as_launcher_app=false
|
||||
launcher_icons/main_192x192=""
|
||||
launcher_icons/adaptive_foreground_432x432=""
|
||||
launcher_icons/adaptive_background_432x432=""
|
||||
graphics/opengl_debug=false
|
||||
xr_features/xr_mode=0
|
||||
screen/immersive_mode=true
|
||||
screen/support_small=true
|
||||
screen/support_normal=true
|
||||
screen/support_large=true
|
||||
screen/support_xlarge=true
|
||||
user_data_backup/allow=false
|
||||
command_line/extra_args=""
|
||||
apk_expansion/enable=false
|
||||
apk_expansion/SALT=""
|
||||
apk_expansion/public_key=""
|
||||
permissions/custom_permissions=PackedStringArray()
|
||||
permissions/access_checkin_properties=false
|
||||
permissions/access_coarse_location=false
|
||||
permissions/access_fine_location=false
|
||||
permissions/access_location_extra_commands=false
|
||||
permissions/access_mock_location=false
|
||||
permissions/access_network_state=false
|
||||
permissions/access_surface_flinger=false
|
||||
permissions/access_wifi_state=false
|
||||
permissions/account_manager=false
|
||||
permissions/add_voicemail=false
|
||||
permissions/authenticate_accounts=false
|
||||
permissions/battery_stats=false
|
||||
permissions/bind_accessibility_service=false
|
||||
permissions/bind_appwidget=false
|
||||
permissions/bind_device_admin=false
|
||||
permissions/bind_input_method=false
|
||||
permissions/bind_nfc_service=false
|
||||
permissions/bind_notification_listener_service=false
|
||||
permissions/bind_print_service=false
|
||||
permissions/bind_remoteviews=false
|
||||
permissions/bind_text_service=false
|
||||
permissions/bind_vpn_service=false
|
||||
permissions/bind_wallpaper=false
|
||||
permissions/bluetooth=false
|
||||
permissions/bluetooth_admin=false
|
||||
permissions/bluetooth_privileged=false
|
||||
permissions/brick=false
|
||||
permissions/broadcast_package_removed=false
|
||||
permissions/broadcast_sms=false
|
||||
permissions/broadcast_sticky=false
|
||||
permissions/broadcast_wap_push=false
|
||||
permissions/call_phone=false
|
||||
permissions/call_privileged=false
|
||||
permissions/camera=false
|
||||
permissions/capture_audio_output=false
|
||||
permissions/capture_secure_video_output=false
|
||||
permissions/capture_video_output=false
|
||||
permissions/change_component_enabled_state=false
|
||||
permissions/change_configuration=false
|
||||
permissions/change_network_state=false
|
||||
permissions/change_wifi_multicast_state=false
|
||||
permissions/change_wifi_state=false
|
||||
permissions/clear_app_cache=false
|
||||
permissions/clear_app_user_data=false
|
||||
permissions/control_location_updates=false
|
||||
permissions/delete_cache_files=false
|
||||
permissions/delete_packages=false
|
||||
permissions/device_power=false
|
||||
permissions/diagnostic=false
|
||||
permissions/disable_keyguard=false
|
||||
permissions/dump=false
|
||||
permissions/expand_status_bar=false
|
||||
permissions/factory_test=false
|
||||
permissions/flashlight=false
|
||||
permissions/force_back=false
|
||||
permissions/get_accounts=false
|
||||
permissions/get_package_size=false
|
||||
permissions/get_tasks=false
|
||||
permissions/get_top_activity_info=false
|
||||
permissions/global_search=false
|
||||
permissions/hardware_test=false
|
||||
permissions/inject_events=false
|
||||
permissions/install_location_provider=false
|
||||
permissions/install_packages=false
|
||||
permissions/install_shortcut=false
|
||||
permissions/internal_system_window=false
|
||||
permissions/internet=false
|
||||
permissions/kill_background_processes=false
|
||||
permissions/location_hardware=false
|
||||
permissions/manage_accounts=false
|
||||
permissions/manage_app_tokens=false
|
||||
permissions/manage_documents=false
|
||||
permissions/manage_external_storage=false
|
||||
permissions/master_clear=false
|
||||
permissions/media_content_control=false
|
||||
permissions/modify_audio_settings=false
|
||||
permissions/modify_phone_state=false
|
||||
permissions/mount_format_filesystems=false
|
||||
permissions/mount_unmount_filesystems=false
|
||||
permissions/nfc=false
|
||||
permissions/persistent_activity=false
|
||||
permissions/process_outgoing_calls=false
|
||||
permissions/read_calendar=false
|
||||
permissions/read_call_log=false
|
||||
permissions/read_contacts=false
|
||||
permissions/read_external_storage=false
|
||||
permissions/read_frame_buffer=false
|
||||
permissions/read_history_bookmarks=false
|
||||
permissions/read_input_state=false
|
||||
permissions/read_logs=false
|
||||
permissions/read_phone_state=false
|
||||
permissions/read_profile=false
|
||||
permissions/read_sms=false
|
||||
permissions/read_social_stream=false
|
||||
permissions/read_sync_settings=false
|
||||
permissions/read_sync_stats=false
|
||||
permissions/read_user_dictionary=false
|
||||
permissions/reboot=false
|
||||
permissions/receive_boot_completed=false
|
||||
permissions/receive_mms=false
|
||||
permissions/receive_sms=false
|
||||
permissions/receive_wap_push=false
|
||||
permissions/record_audio=false
|
||||
permissions/reorder_tasks=false
|
||||
permissions/restart_packages=false
|
||||
permissions/send_respond_via_message=false
|
||||
permissions/send_sms=false
|
||||
permissions/set_activity_watcher=false
|
||||
permissions/set_alarm=false
|
||||
permissions/set_always_finish=false
|
||||
permissions/set_animation_scale=false
|
||||
permissions/set_debug_app=false
|
||||
permissions/set_orientation=false
|
||||
permissions/set_pointer_speed=false
|
||||
permissions/set_preferred_applications=false
|
||||
permissions/set_process_limit=false
|
||||
permissions/set_time=false
|
||||
permissions/set_time_zone=false
|
||||
permissions/set_wallpaper=false
|
||||
permissions/set_wallpaper_hints=false
|
||||
permissions/signal_persistent_processes=false
|
||||
permissions/status_bar=false
|
||||
permissions/subscribed_feeds_read=false
|
||||
permissions/subscribed_feeds_write=false
|
||||
permissions/system_alert_window=false
|
||||
permissions/transmit_ir=false
|
||||
permissions/uninstall_shortcut=false
|
||||
permissions/update_device_stats=false
|
||||
permissions/use_credentials=false
|
||||
permissions/use_sip=false
|
||||
permissions/vibrate=false
|
||||
permissions/wake_lock=false
|
||||
permissions/write_apn_settings=false
|
||||
permissions/write_calendar=false
|
||||
permissions/write_call_log=false
|
||||
permissions/write_contacts=false
|
||||
permissions/write_external_storage=false
|
||||
permissions/write_gservices=false
|
||||
permissions/write_history_bookmarks=false
|
||||
permissions/write_profile=false
|
||||
permissions/write_secure_settings=false
|
||||
permissions/write_settings=false
|
||||
permissions/write_sms=false
|
||||
permissions/write_social_stream=false
|
||||
permissions/write_sync_settings=false
|
||||
permissions/write_user_dictionary=false
|
||||
|
||||
[preset.1]
|
||||
|
||||
name="Web"
|
||||
platform="Web"
|
||||
runnable=false
|
||||
dedicated_server=false
|
||||
custom_features=""
|
||||
export_filter="all_resources"
|
||||
include_filter=""
|
||||
exclude_filter=""
|
||||
export_path="web/Boronotes.html"
|
||||
encryption_include_filters=""
|
||||
encryption_exclude_filters=""
|
||||
encrypt_pck=false
|
||||
encrypt_directory=false
|
||||
|
||||
[preset.1.options]
|
||||
|
||||
custom_template/debug=""
|
||||
custom_template/release=""
|
||||
variant/extensions_support=false
|
||||
vram_texture_compression/for_desktop=false
|
||||
vram_texture_compression/for_mobile=false
|
||||
html/export_icon=true
|
||||
html/custom_html_shell=""
|
||||
html/head_include="<script src=\"coi-serviceworker.min.js\"></script>"
|
||||
html/canvas_resize_policy=2
|
||||
html/focus_canvas_on_start=true
|
||||
html/experimental_virtual_keyboard=false
|
||||
progressive_web_app/enabled=true
|
||||
progressive_web_app/offline_page=""
|
||||
progressive_web_app/display=1
|
||||
progressive_web_app/orientation=2
|
||||
progressive_web_app/icon_144x144=""
|
||||
progressive_web_app/icon_180x180=""
|
||||
progressive_web_app/icon_512x512=""
|
||||
progressive_web_app/background_color=Color(0, 0, 0, 1)
|
113
main.gd
113
main.gd
|
@ -1,65 +1,96 @@
|
|||
class_name Main
|
||||
extends Control
|
||||
|
||||
@onready var note_page: NotePage = %NotePage
|
||||
@onready var edit_note_page: EditNotePage = %EditNotePage
|
||||
@onready var save_manager = $Utils/SaveManager
|
||||
|
||||
var editing: bool = false :
|
||||
set(value):
|
||||
editing = value
|
||||
note_page.visible = not editing
|
||||
edit_note_page.visible = editing
|
||||
|
||||
var notes: Array[Note] = []
|
||||
var previous_notes: Array[Note] = []
|
||||
var current_note: Note
|
||||
|
||||
@onready var back_button: Button = %BackButton
|
||||
@onready var page_title: Label = %PageTitle
|
||||
@onready var notes_container: VBoxContainer = %NotesContainer
|
||||
const NOTE_ITEM = preload("res://components/note_item/note_item.tscn")
|
||||
|
||||
|
||||
func display_note() -> void:
|
||||
back_button.disabled = previous_notes.size() == 0
|
||||
|
||||
page_title.text = current_note.title if current_note else "Главная"
|
||||
|
||||
for child in notes_container.get_children():
|
||||
notes_container.remove_child(child)
|
||||
|
||||
func display_page() -> void:
|
||||
var note_title = current_note.title if current_note else "Главная"
|
||||
var display_notes = notes.filter(func (note): return note.parent_id == (current_note.id if current_note else ""))
|
||||
|
||||
for note in display_notes:
|
||||
var note_item = NOTE_ITEM.instantiate()
|
||||
note_item.note = note
|
||||
notes_container.add_child(note_item)
|
||||
note_item.pressed.connect(_on_note_item_pressed)
|
||||
if editing:
|
||||
edit_note_page.display(
|
||||
current_note.id if current_note else "",
|
||||
note_title,
|
||||
display_notes
|
||||
)
|
||||
else:
|
||||
note_page.display(note_title, display_notes)
|
||||
|
||||
|
||||
func _ready():
|
||||
var note_1 = Note.new("Тест 1")
|
||||
var note_2 = Note.new("Тест 2")
|
||||
var note_3 = Note.new("Тест 3")
|
||||
var note_1_1 = Note.new("Тест 1 1", note_1.id)
|
||||
var note_1_2 = Note.new("Тест 1 2", note_1.id)
|
||||
var note_1_2_1 = Note.new("Тест 1 2 1", note_1_2.id)
|
||||
var note_2_1 = Note.new("Тест 2 1", note_2.id)
|
||||
save_manager.load_data()
|
||||
|
||||
notes = [
|
||||
note_1,
|
||||
note_2,
|
||||
note_3,
|
||||
note_1_1,
|
||||
note_1_2,
|
||||
note_1_2_1,
|
||||
note_2_1,
|
||||
]
|
||||
|
||||
display_note()
|
||||
display_page()
|
||||
|
||||
|
||||
func _on_back_button_pressed():
|
||||
func _on_note_page_back_pressed():
|
||||
current_note = previous_notes.pop_back()
|
||||
display_note()
|
||||
note_page.back_button.disabled = previous_notes.size() == 0
|
||||
display_page()
|
||||
|
||||
|
||||
func _on_note_item_pressed(note: Note) -> void:
|
||||
func _on_note_page_edit_pressed():
|
||||
editing = true
|
||||
display_page()
|
||||
|
||||
|
||||
func _on_note_page_note_pressed(note: Note) -> void:
|
||||
previous_notes.append(current_note)
|
||||
current_note = note
|
||||
display_note()
|
||||
note_page.back_button.disabled = false
|
||||
display_page()
|
||||
|
||||
|
||||
func _on_save_manager_load_notes(loaded_notes):
|
||||
editing = false
|
||||
notes = loaded_notes
|
||||
print(loaded_notes)
|
||||
display_page()
|
||||
|
||||
|
||||
func _on_edit_button_pressed():
|
||||
editing = true
|
||||
display_page()
|
||||
|
||||
|
||||
func _on_edit_note_page_canceled():
|
||||
editing = false
|
||||
|
||||
|
||||
func _on_edit_note_page_saved(changed_notes: Array[ChangeNote]):
|
||||
editing = false
|
||||
for changed_note in changed_notes:
|
||||
match changed_note.kind:
|
||||
ChangeNote.Kind.ADDED:
|
||||
if changed_note.note.title.strip_edges():
|
||||
notes.append(changed_note.note)
|
||||
ChangeNote.Kind.DELETED:
|
||||
notes.erase(changed_note.note)
|
||||
display_page()
|
||||
save_manager.save_data(notes)
|
||||
|
||||
|
||||
func _notification(what: int) -> void:
|
||||
match what:
|
||||
NOTIFICATION_WM_GO_BACK_REQUEST:
|
||||
if editing:
|
||||
editing = false
|
||||
elif previous_notes.size():
|
||||
_on_note_page_back_pressed()
|
||||
else:
|
||||
get_tree().quit()
|
||||
|
||||
|
||||
|
||||
|
|
74
main.tscn
74
main.tscn
|
@ -1,8 +1,8 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://3snttmw814qx"]
|
||||
|
||||
[ext_resource type="Script" path="res://main.gd" id="1_nrdxj"]
|
||||
[ext_resource type="Texture2D" uid="uid://byohq4ewrecgx" path="res://assets/back.png" id="1_rigm4"]
|
||||
[ext_resource type="Texture2D" uid="uid://bel5s26rbieoi" path="res://assets/edit.png" id="2_grsek"]
|
||||
[ext_resource type="PackedScene" uid="uid://cfqcqoc8kxmde" path="res://pages/note_page/note_page.tscn" id="2_jvvy0"]
|
||||
[ext_resource type="PackedScene" uid="uid://bjv84skijj764" path="res://pages/edit_note_page/edit_note_page.tscn" id="3_801py"]
|
||||
[ext_resource type="Script" path="res://save_manager/save_manager.gd" id="5_o2kvf"]
|
||||
|
||||
[node name="Main" type="Control"]
|
||||
|
@ -14,73 +14,23 @@ grow_horizontal = 2
|
|||
grow_vertical = 2
|
||||
script = ExtResource("1_nrdxj")
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="."]
|
||||
[node name="NotePage" parent="." instance=ExtResource("2_jvvy0")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="PanelContainer/VBoxContainer/PanelContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 16
|
||||
theme_override_constants/margin_top = 16
|
||||
theme_override_constants/margin_right = 16
|
||||
theme_override_constants/margin_bottom = 16
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="PanelContainer/VBoxContainer/PanelContainer/MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="BackButton" type="Button" parent="PanelContainer/VBoxContainer/PanelContainer/MarginContainer/HBoxContainer"]
|
||||
[node name="EditNotePage" parent="." instance=ExtResource("3_801py")]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(64, 64)
|
||||
layout_mode = 2
|
||||
icon = ExtResource("1_rigm4")
|
||||
flat = true
|
||||
expand_icon = true
|
||||
|
||||
[node name="PageTitle" type="Label" parent="PanelContainer/VBoxContainer/PanelContainer/MarginContainer/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Главная"
|
||||
|
||||
[node name="EditButton" type="Button" parent="PanelContainer/VBoxContainer/PanelContainer/MarginContainer/HBoxContainer"]
|
||||
custom_minimum_size = Vector2(64, 64)
|
||||
layout_mode = 2
|
||||
icon = ExtResource("2_grsek")
|
||||
flat = true
|
||||
expand_icon = true
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="PanelContainer/VBoxContainer/ScrollContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/margin_left = 16
|
||||
theme_override_constants/margin_top = 16
|
||||
theme_override_constants/margin_right = 16
|
||||
theme_override_constants/margin_bottom = 16
|
||||
|
||||
[node name="NotesContainer" type="VBoxContainer" parent="PanelContainer/VBoxContainer/ScrollContainer/MarginContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 8
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
|
||||
[node name="Utils" type="Node" parent="."]
|
||||
|
||||
[node name="SaveManager" type="Node" parent="Utils"]
|
||||
script = ExtResource("5_o2kvf")
|
||||
|
||||
[connection signal="pressed" from="PanelContainer/VBoxContainer/PanelContainer/MarginContainer/HBoxContainer/BackButton" to="." method="_on_back_button_pressed"]
|
||||
[connection signal="back_pressed" from="NotePage" to="." method="_on_note_page_back_pressed"]
|
||||
[connection signal="edit_pressed" from="NotePage" to="." method="_on_note_page_edit_pressed"]
|
||||
[connection signal="note_pressed" from="NotePage" to="." method="_on_note_page_note_pressed"]
|
||||
[connection signal="canceled" from="EditNotePage" to="." method="_on_edit_note_page_canceled"]
|
||||
[connection signal="saved" from="EditNotePage" to="." method="_on_edit_note_page_saved"]
|
||||
[connection signal="load_notes" from="Utils/SaveManager" to="." method="_on_save_manager_load_notes"]
|
||||
|
|
58
pages/edit_note_page/edit_note_page.gd
Normal file
58
pages/edit_note_page/edit_note_page.gd
Normal file
|
@ -0,0 +1,58 @@
|
|||
class_name EditNotePage
|
||||
extends PanelContainer
|
||||
|
||||
signal canceled()
|
||||
signal saved(changed_notes: Array[ChangeNote])
|
||||
|
||||
@onready var page_title: Label = %PageTitle
|
||||
@onready var notes_container: VBoxContainer = %NotesContainer
|
||||
|
||||
const EDIT_NOTE_ITEM = preload("res://components/edit_note_item/edit_note_item.tscn")
|
||||
|
||||
var _current_note_id: String
|
||||
var _changes: Array[ChangeNote] = []
|
||||
|
||||
|
||||
func display_notes():
|
||||
for child in notes_container.get_children():
|
||||
notes_container.remove_child(child)
|
||||
|
||||
for change_note in _changes:
|
||||
if change_note.kind == ChangeNote.Kind.DELETED:
|
||||
continue
|
||||
var note_item = EDIT_NOTE_ITEM.instantiate()
|
||||
note_item.note = change_note.note
|
||||
notes_container.add_child(note_item)
|
||||
note_item.deleted.connect(_on_edit_node_item_deleted)
|
||||
|
||||
|
||||
func display(current_note_id: String, title: String, notes: Array[Note]):
|
||||
_current_note_id = current_note_id
|
||||
page_title.text = title
|
||||
|
||||
_changes = []
|
||||
for note in notes:
|
||||
_changes.append(ChangeNote.new(ChangeNote.Kind.CHANGED, note))
|
||||
|
||||
display_notes()
|
||||
|
||||
|
||||
func _on_edit_node_item_deleted(note: Note):
|
||||
for changed_note in _changes:
|
||||
if changed_note.note == note:
|
||||
changed_note.kind = ChangeNote.Kind.DELETED
|
||||
display_notes()
|
||||
break
|
||||
|
||||
|
||||
func _on_cancel_button_pressed():
|
||||
canceled.emit()
|
||||
|
||||
|
||||
func _on_save_button_pressed():
|
||||
saved.emit(_changes)
|
||||
|
||||
|
||||
func _on_add_note_button_pressed():
|
||||
_changes.append(ChangeNote.new(ChangeNote.Kind.ADDED, Note.create("", _current_note_id)))
|
||||
display_notes()
|
83
pages/edit_note_page/edit_note_page.tscn
Normal file
83
pages/edit_note_page/edit_note_page.tscn
Normal file
|
@ -0,0 +1,83 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://bjv84skijj764"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://c56dek8bl3vq0" path="res://assets/close.png" id="1_4wdhj"]
|
||||
[ext_resource type="Script" path="res://pages/edit_note_page/edit_note_page.gd" id="1_41gfg"]
|
||||
[ext_resource type="Texture2D" uid="uid://cwnsbx7xl0syt" path="res://assets/save.png" id="2_pkfdj"]
|
||||
[ext_resource type="Texture2D" uid="uid://b5djp0ut3b0ck" path="res://assets/add.png" id="3_ca8sq"]
|
||||
|
||||
[node name="EditNotePage" type="PanelContainer"]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_41gfg")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer/PanelContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 32
|
||||
theme_override_constants/margin_top = 32
|
||||
theme_override_constants/margin_right = 32
|
||||
theme_override_constants/margin_bottom = 32
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/PanelContainer/MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="CancelButton" type="Button" parent="VBoxContainer/PanelContainer/MarginContainer/HBoxContainer"]
|
||||
custom_minimum_size = Vector2(64, 64)
|
||||
layout_mode = 2
|
||||
icon = ExtResource("1_4wdhj")
|
||||
flat = true
|
||||
expand_icon = true
|
||||
|
||||
[node name="PageTitle" type="Label" parent="VBoxContainer/PanelContainer/MarginContainer/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Главная"
|
||||
|
||||
[node name="SaveButton" type="Button" parent="VBoxContainer/PanelContainer/MarginContainer/HBoxContainer"]
|
||||
custom_minimum_size = Vector2(64, 64)
|
||||
layout_mode = 2
|
||||
icon = ExtResource("2_pkfdj")
|
||||
flat = true
|
||||
expand_icon = true
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer/ScrollContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/margin_left = 32
|
||||
theme_override_constants/margin_top = 32
|
||||
theme_override_constants/margin_right = 32
|
||||
theme_override_constants/margin_bottom = 32
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/ScrollContainer/MarginContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 16
|
||||
|
||||
[node name="NotesContainer" type="VBoxContainer" parent="VBoxContainer/ScrollContainer/MarginContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 16
|
||||
|
||||
[node name="AddNoteButton" type="Button" parent="VBoxContainer/ScrollContainer/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Добавить Запись"
|
||||
icon = ExtResource("3_ca8sq")
|
||||
alignment = 0
|
||||
expand_icon = true
|
||||
|
||||
[connection signal="pressed" from="VBoxContainer/PanelContainer/MarginContainer/HBoxContainer/CancelButton" to="." method="_on_cancel_button_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/PanelContainer/MarginContainer/HBoxContainer/SaveButton" to="." method="_on_save_button_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/ScrollContainer/MarginContainer/VBoxContainer/AddNoteButton" to="." method="_on_add_note_button_pressed"]
|
38
pages/note_page/note_page.gd
Normal file
38
pages/note_page/note_page.gd
Normal file
|
@ -0,0 +1,38 @@
|
|||
class_name NotePage
|
||||
extends PanelContainer
|
||||
|
||||
signal edit_pressed()
|
||||
signal back_pressed()
|
||||
signal note_pressed(note: Note)
|
||||
|
||||
const NOTE_ITEM = preload("res://components/note_item/note_item.tscn")
|
||||
|
||||
@onready var back_button = %BackButton
|
||||
|
||||
@onready var page_title: Label = %PageTitle
|
||||
@onready var notes_container: VBoxContainer = %NotesContainer
|
||||
|
||||
|
||||
func display(title: String, notes: Array[Note]) -> void:
|
||||
page_title.text = title
|
||||
|
||||
for child in notes_container.get_children():
|
||||
notes_container.remove_child(child)
|
||||
|
||||
for note in notes:
|
||||
var note_item = NOTE_ITEM.instantiate()
|
||||
note_item.note = note
|
||||
notes_container.add_child(note_item)
|
||||
note_item.pressed.connect(_on_note_item_pressed)
|
||||
|
||||
|
||||
func _on_note_item_pressed(note: Note) -> void:
|
||||
note_pressed.emit(note)
|
||||
|
||||
|
||||
func _on_back_button_pressed():
|
||||
back_pressed.emit()
|
||||
|
||||
|
||||
func _on_edit_button_pressed():
|
||||
edit_pressed.emit()
|
72
pages/note_page/note_page.tscn
Normal file
72
pages/note_page/note_page.tscn
Normal file
|
@ -0,0 +1,72 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://cfqcqoc8kxmde"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://byohq4ewrecgx" path="res://assets/back.png" id="1_oquw8"]
|
||||
[ext_resource type="Script" path="res://pages/note_page/note_page.gd" id="1_toc5b"]
|
||||
[ext_resource type="Texture2D" uid="uid://bel5s26rbieoi" path="res://assets/edit.png" id="2_gvek1"]
|
||||
|
||||
[node name="NotePage" type="PanelContainer"]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_toc5b")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer/PanelContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 32
|
||||
theme_override_constants/margin_top = 32
|
||||
theme_override_constants/margin_right = 32
|
||||
theme_override_constants/margin_bottom = 32
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/PanelContainer/MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="BackButton" type="Button" parent="VBoxContainer/PanelContainer/MarginContainer/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(64, 64)
|
||||
layout_mode = 2
|
||||
disabled = true
|
||||
icon = ExtResource("1_oquw8")
|
||||
flat = true
|
||||
expand_icon = true
|
||||
|
||||
[node name="PageTitle" type="Label" parent="VBoxContainer/PanelContainer/MarginContainer/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Главная"
|
||||
|
||||
[node name="EditButton" type="Button" parent="VBoxContainer/PanelContainer/MarginContainer/HBoxContainer"]
|
||||
custom_minimum_size = Vector2(64, 64)
|
||||
layout_mode = 2
|
||||
icon = ExtResource("2_gvek1")
|
||||
flat = true
|
||||
expand_icon = true
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer/ScrollContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/margin_left = 32
|
||||
theme_override_constants/margin_top = 32
|
||||
theme_override_constants/margin_right = 32
|
||||
theme_override_constants/margin_bottom = 32
|
||||
|
||||
[node name="NotesContainer" type="VBoxContainer" parent="VBoxContainer/ScrollContainer/MarginContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 16
|
||||
|
||||
[connection signal="pressed" from="VBoxContainer/PanelContainer/MarginContainer/HBoxContainer/BackButton" to="." method="_on_back_button_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/PanelContainer/MarginContainer/HBoxContainer/EditButton" to="." method="_on_edit_button_pressed"]
|
|
@ -13,6 +13,7 @@ config_version=5
|
|||
config/name="Boronotes"
|
||||
config/version="0.0.1"
|
||||
run/main_scene="res://main.tscn"
|
||||
config/quit_on_go_back=false
|
||||
config/features=PackedStringArray("4.2", "Mobile")
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
|
@ -22,6 +23,7 @@ window/size/viewport_width=900
|
|||
window/size/viewport_height=1600
|
||||
window/size/resizable=false
|
||||
window/stretch/mode="canvas_items"
|
||||
window/stretch/aspect="expand"
|
||||
window/handheld/orientation=1
|
||||
|
||||
[gui]
|
||||
|
@ -31,3 +33,4 @@ theme/custom="res://styles/app_theme.tres"
|
|||
[rendering]
|
||||
|
||||
renderer/rendering_method="mobile"
|
||||
textures/vram_compression/import_etc2_astc=true
|
||||
|
|
|
@ -8,6 +8,7 @@ var file_name: String = "user://save_notes.tres"
|
|||
|
||||
func save_data(notes: Array[Note]) -> void:
|
||||
var saved_data = SavedData.new()
|
||||
print(notes.size())
|
||||
saved_data.notes = notes
|
||||
ResourceSaver.save(saved_data, file_name)
|
||||
|
||||
|
@ -15,5 +16,6 @@ func save_data(notes: Array[Note]) -> void:
|
|||
func load_data() -> void:
|
||||
if ResourceLoader.exists(file_name):
|
||||
var saved_data = ResourceLoader.load(file_name) as SavedData
|
||||
print(saved_data.notes.size())
|
||||
load_notes.emit(saved_data.notes)
|
||||
|
||||
|
|
|
@ -1,7 +1,24 @@
|
|||
[gd_resource type="Theme" load_steps=2 format=3 uid="uid://dhg5k56ynipbp"]
|
||||
[gd_resource type="Theme" load_steps=4 format=3 uid="uid://dhg5k56ynipbp"]
|
||||
|
||||
[ext_resource type="StyleBox" uid="uid://bfvw2cfuiduki" path="res://styles/white_panel_flat.tres" id="1_rasl3"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_3hlj0"]
|
||||
bg_color = Color(1, 1, 1, 0.784314)
|
||||
border_width_left = 8
|
||||
border_width_top = 8
|
||||
border_width_right = 8
|
||||
border_width_bottom = 8
|
||||
border_color = Color(1, 1, 1, 0.784314)
|
||||
corner_radius_top_left = 8
|
||||
corner_radius_top_right = 8
|
||||
corner_radius_bottom_right = 8
|
||||
corner_radius_bottom_left = 8
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_r70c8"]
|
||||
bg_color = Color(1, 1, 1, 0.784314)
|
||||
border_width_bottom = 2
|
||||
border_color = Color(0, 0.309804, 0.819608, 1)
|
||||
|
||||
[resource]
|
||||
Button/colors/font_color = Color(0, 0, 0, 1)
|
||||
Button/colors/font_focus_color = Color(0, 0, 0, 1)
|
||||
|
@ -10,7 +27,12 @@ Button/colors/font_hover_pressed_color = Color(0, 0, 0, 1)
|
|||
Button/colors/font_outline_color = Color(0, 0, 0, 1)
|
||||
Button/colors/font_pressed_color = Color(0, 0, 0, 1)
|
||||
Button/font_sizes/font_size = 18
|
||||
Button/styles/normal = null
|
||||
Button/styles/normal = SubResource("StyleBoxFlat_3hlj0")
|
||||
Label/colors/font_color = Color(0, 0, 0, 1)
|
||||
Label/font_sizes/font_size = 30
|
||||
LineEdit/colors/caret_color = Color(0.521569, 0.521569, 0.521569, 1)
|
||||
LineEdit/colors/clear_button_color = Color(0.521569, 0.521569, 0.521569, 1)
|
||||
LineEdit/colors/font_color = Color(0, 0, 0, 1)
|
||||
LineEdit/colors/font_placeholder_color = Color(0.54902, 0.54902, 0.54902, 0.6)
|
||||
LineEdit/styles/normal = SubResource("StyleBoxFlat_r70c8")
|
||||
PanelContainer/styles/panel = ExtResource("1_rasl3")
|
||||
|
|
Loading…
Add table
Reference in a new issue