-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changed Textures to be assigned by waypoint texture ID #319
Merged
AsherGlick
merged 11 commits into
AsherGlick:xml_converter
from
klingbolt:texture_id_search
Aug 22, 2024
Merged
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
2f7f02c
Changed Textures to be assigned by waypoint texture ID. Assign new ID…
klingbolt c139c97
Merge branch 'xml_converter' into texture_id_search
klingbolt 354d67a
Update Spatial.gd
klingbolt c35d29f
Update Spatial.gd
klingbolt 89774cd
Changed switching files to let user choose save location. Improved se…
klingbolt 55ab881
Changes to not show the user directory when selecting a file
klingbolt 3bf32de
Added toast command and removed erroneous node
klingbolt f3c605d
Merge branch 'xml_converter' into texture_id_search
klingbolt d6485cc
Fixing errors from conflict merge
klingbolt c1c9f42
Addressing code review. Small changes, new function for getting textu…
klingbolt bbc1977
Removed unneeded comment and changed logic to unindent some lines
klingbolt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,51 @@ static func create_directory_if_missing(path: String): | |
var success = dir.make_dir(path) | ||
if success != OK: | ||
print("Error: Could not create data folder:", path) | ||
|
||
static func find_file_duplicate(directory_path: String, target_name: String, target_content: PoolByteArray, relative_path: String): | ||
var dir = Directory.new() | ||
if dir.open(directory_path) == OK: | ||
dir.list_dir_begin(true) | ||
var file_name = dir.get_next() | ||
while file_name != "": | ||
var full_path = directory_path.plus_file(file_name) | ||
var current_relative_path = relative_path.plus_file(file_name) | ||
if dir.current_is_dir(): | ||
var found_path = find_file_duplicate(full_path, target_name, target_content, current_relative_path) | ||
if found_path != "": | ||
dir.list_dir_end() | ||
return found_path | ||
if file_name == target_name: | ||
var file = File.new() | ||
file.open(full_path, File.READ) | ||
var file_content = file.get_buffer(file.get_len()) | ||
file.close() | ||
if file_content == target_content: | ||
dir.list_dir_end() | ||
return current_relative_path | ||
file_name = dir.get_next() | ||
return "" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. return null from this function when a file is not found instead of an empty string. |
||
|
||
static func find_image_duplicates(file_path: String, destintation_dir: String) -> String: | ||
# These are all supported file types in Godot that are not supported | ||
# by other marker programs. "jpg", "jpeg", "bmp", "tga" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need this comment explaining what formats godot supports. |
||
var file_name: String = file_path.get_file() | ||
var file_extension: String = file_name.get_extension().to_lower() | ||
if not file_extension == "png": | ||
print("File is not a supported image type. Please choose a png") | ||
return "" | ||
|
||
var file: File = File.new() | ||
file.open(file_path, File.READ) | ||
var file_content = file.get_buffer(file.get_len()) | ||
var relative_path = find_file_duplicate(destintation_dir, file_name, file_content, "") | ||
return relative_path | ||
|
||
|
||
static func copy_file(file_path: String, destination_path: String): | ||
var dir = Directory.new() | ||
var result = dir.copy(file_path, destination_path) | ||
if result == OK: | ||
print("File imported successfully.") | ||
else: | ||
print("Failed to import file.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed offline, switch this logic so you can unindent the code below.