mirror of
https://github.com/Relintai/MemR.git
synced 2024-12-23 14:06:54 +01:00
Implemented stepping through directories and images.
This commit is contained in:
parent
55e3bde2ce
commit
12745934ff
@ -14,7 +14,6 @@ config/name="MemR"
|
||||
run/main_scene="res://Main.tscn"
|
||||
run/low_processor_mode=true
|
||||
config/icon="res://icon.png"
|
||||
config/auto_accept_quit=false
|
||||
config/quit_on_go_back=false
|
||||
config/sort_folder=""
|
||||
config/target_folder=""
|
||||
|
@ -4,6 +4,7 @@ var sort_folder : String
|
||||
var target_folder : String
|
||||
|
||||
var _texture_rect : TextureRect
|
||||
var _error_label : Label
|
||||
var _categories_ob : OptionButton
|
||||
var _sub_categories_ob : OptionButton
|
||||
|
||||
@ -13,6 +14,12 @@ var _categories_popup_line_edit : LineEdit
|
||||
var _sub_categories_popup : ConfirmationDialog
|
||||
var _sub_categories_popup_line_edit : LineEdit
|
||||
|
||||
var _current_folder_index : int
|
||||
var _folders : PoolStringArray
|
||||
|
||||
var _current_file_index : int
|
||||
var _current_folder_files : PoolStringArray
|
||||
|
||||
func refresh_categories() -> void:
|
||||
_categories_ob.clear()
|
||||
|
||||
@ -84,11 +91,95 @@ func validate_folders() -> bool:
|
||||
|
||||
return true
|
||||
|
||||
func next_image() -> void:
|
||||
_current_file_index += 1
|
||||
|
||||
if _current_file_index >= _current_folder_files.size():
|
||||
next_folder()
|
||||
return
|
||||
|
||||
var img : Image = Image.new()
|
||||
if img.load(_current_folder_files[_current_file_index]) != OK:
|
||||
_error_label.text = "Error loading file: " + _current_folder_files[_current_file_index]
|
||||
_error_label.show()
|
||||
_texture_rect.hide()
|
||||
|
||||
return
|
||||
|
||||
_error_label.hide()
|
||||
_texture_rect.show()
|
||||
_texture_rect.texture.create_from_image(img, 0)
|
||||
|
||||
|
||||
|
||||
func evaluate_folders() -> void:
|
||||
_folders.clear()
|
||||
|
||||
evaluate_folder(sort_folder)
|
||||
|
||||
_folders.sort()
|
||||
|
||||
func evaluate_folder(folder : String) -> void:
|
||||
var d : Directory = Directory.new()
|
||||
|
||||
if d.open(folder) != OK:
|
||||
return
|
||||
|
||||
d.list_dir_begin(true)
|
||||
|
||||
var f : String = d.get_next()
|
||||
while !f.empty():
|
||||
if !d.current_is_dir():
|
||||
f = d.get_next()
|
||||
continue
|
||||
|
||||
var fp : String = folder.append_path(f)
|
||||
_folders.push_back(fp)
|
||||
evaluate_folder(fp)
|
||||
|
||||
f = d.get_next()
|
||||
|
||||
d.list_dir_end()
|
||||
|
||||
func next_folder() -> void:
|
||||
_current_folder_index += 1
|
||||
|
||||
if _current_folder_index >= _folders.size():
|
||||
return
|
||||
|
||||
_current_file_index = 0
|
||||
_current_folder_files.clear()
|
||||
|
||||
var curr_path : String = _folders[_current_folder_index]
|
||||
|
||||
var tf : Directory = Directory.new()
|
||||
if tf.open(curr_path) != OK:
|
||||
return
|
||||
|
||||
tf.list_dir_begin(true)
|
||||
|
||||
var f : String = tf.get_next()
|
||||
while !f.empty():
|
||||
if tf.current_is_dir():
|
||||
f = tf.get_next()
|
||||
continue
|
||||
|
||||
_current_folder_files.push_back(curr_path.append_path(f))
|
||||
f = tf.get_next()
|
||||
|
||||
tf.list_dir_end()
|
||||
|
||||
if _current_folder_files.size() == 0:
|
||||
next_folder()
|
||||
else:
|
||||
_current_file_index = -1
|
||||
next_image()
|
||||
|
||||
func _on_Apply_pressed() -> void:
|
||||
pass # Replace with function body.
|
||||
next_image()
|
||||
|
||||
func _on_Skip_pressed() -> void:
|
||||
pass # Replace with function body.
|
||||
next_image()
|
||||
|
||||
func _on_Categories_item_selected(index: int) -> void:
|
||||
refresh_sub_categories()
|
||||
@ -110,8 +201,6 @@ func _on_NewCategoryPopup_confirmed() -> void:
|
||||
|
||||
var folder : String = target_folder.append_path(_categories_popup_line_edit.text)
|
||||
|
||||
print(folder)
|
||||
|
||||
var d : Directory = Directory.new()
|
||||
d.make_dir_recursive(folder)
|
||||
|
||||
@ -127,8 +216,6 @@ func _on_NewSubCategoryPopup_confirmed() -> void:
|
||||
var folder : String = target_folder.append_path(_categories_ob.get_item_text(_categories_ob.selected))
|
||||
folder = folder.append_path(_sub_categories_popup_line_edit.text)
|
||||
|
||||
print(folder)
|
||||
|
||||
var d : Directory = Directory.new()
|
||||
d.make_dir_recursive(folder)
|
||||
|
||||
@ -137,7 +224,8 @@ func _on_NewSubCategoryPopup_confirmed() -> void:
|
||||
|
||||
func _notification(what: int) -> void:
|
||||
if what == NOTIFICATION_READY:
|
||||
_texture_rect = get_node("ScrollContainer/TextureRect") as TextureRect
|
||||
_texture_rect = get_node("ScrollContainer/VBoxContainer/TextureRect") as TextureRect
|
||||
_error_label = get_node("ScrollContainer/VBoxContainer/ErrorLabel") as Label
|
||||
_categories_ob = get_node("Categories/Categories") as OptionButton
|
||||
_sub_categories_ob = get_node("SubCategoies/SubCategoies") as OptionButton
|
||||
|
||||
@ -146,9 +234,16 @@ func _notification(what: int) -> void:
|
||||
|
||||
_sub_categories_popup = get_node("Control/NewSubCategoryPopup") as ConfirmationDialog
|
||||
_sub_categories_popup_line_edit = get_node("Control/NewSubCategoryPopup/VBoxContainer/LineEdit") as LineEdit
|
||||
|
||||
_texture_rect.texture = ImageTexture.new()
|
||||
elif what == NOTIFICATION_VISIBILITY_CHANGED:
|
||||
if is_visible_in_tree():
|
||||
sort_folder = ProjectSettings.get("application/config/sort_folder")
|
||||
target_folder = ProjectSettings.get("application/config/target_folder")
|
||||
refresh_categories()
|
||||
refresh_sub_categories()
|
||||
|
||||
evaluate_folders()
|
||||
_current_folder_index = -1
|
||||
next_folder()
|
||||
#next_image()
|
||||
|
@ -13,7 +13,14 @@ margin_bottom = 500.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="ScrollContainer"]
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="ScrollContainer"]
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="ScrollContainer/VBoxContainer"]
|
||||
|
||||
[node name="ErrorLabel" type="Label" parent="ScrollContainer/VBoxContainer"]
|
||||
visible = false
|
||||
margin_top = 4.0
|
||||
margin_bottom = 18.0
|
||||
|
||||
[node name="Categories" type="HBoxContainer" parent="."]
|
||||
margin_top = 504.0
|
||||
|
Loading…
Reference in New Issue
Block a user