Skip to content

Commit

Permalink
always save .txt file
Browse files Browse the repository at this point in the history
  • Loading branch information
rainlizard committed Dec 4, 2023
1 parent bcbc6c6 commit 451bb07
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 20 deletions.
3 changes: 2 additions & 1 deletion Autoload/Filetypes.gd
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ func write(filePath, EXT):
var err = file.open(filePath,File.WRITE)
if err == OK:
file.store_buffer(buffer.data_array)
file.close()
print('.'+EXT+' wrote in '+str(OS.get_ticks_msec()-CODETIME_START)+'ms')
file.close()

return err

func file_path_to_buffer(filePath):
Expand Down
7 changes: 3 additions & 4 deletions Scenes/GamePaths.gd
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,13 @@ func get_main_subdirectories(path):
return array

func test_write_permissions():

# Test write permissions of DK directory
var testPath = EXECUTABLE_PATH.get_base_dir().plus_file('testing_write_permissions.test')

print(testPath)
var testPath = EXECUTABLE_PATH.get_base_dir().plus_file('test.txt')

var file = File.new()
var err = file.open(testPath, File.WRITE)
if err == OK:
file.store_string("Testing write permissions.")
file.close()

var dir = Directory.new()
Expand Down
17 changes: 2 additions & 15 deletions Scenes/SaveMap.gd
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,6 @@ func save_map(filePath): # auto opens other files

var saveToFilePath = map + '.' + EXT.to_lower()

# Skip saving over existing script file unless it has been edited
if EXT == "TXT":
# print('hi')
if File.new().file_exists(saveToFilePath) == true:
# print('file exists')
if oScriptEditor.scriptHasBeenEditedInUnearth == false:
# print('script has NOT been edited in unearth')
# print('skip saving')
continue
else:
# print("file doesn't exist")
pass

var err = Filetypes.write(saveToFilePath, EXT.to_upper())
if err != OK:
writeFailure = true
Expand Down Expand Up @@ -77,13 +64,13 @@ func delete_existing_files(map):
# Important for Linux to delete all files otherwise duplicates can be created. (Lowercase files can be saved without replacing the uppercase files)
fileTypesToDelete = Filetypes.FILE_TYPES
else:
# Also important to delete files of the other format (TNG and TNGFX shouldn't exist at the same time), if switching formats.
# If switching formats, then it's important to delete files of the other format (TNG and TNGFX shouldn't exist at the same time)
if oCurrentFormat.selected == 0: # Classic format
# Do not delete LOF because Classic format can be used with LOF multiplayer levels
fileTypesToDelete = ["TNGFX", "APTFX", "LGTFX"]
elif oCurrentFormat.selected == 1: # KFX format
fileTypesToDelete = ["LIF", "TNG", "APT", "LGT"]

var baseDirectory = map.get_base_dir()
var MAP_NAME = map.get_basename().get_file().to_upper()
var dir = Directory.new()
Expand Down

0 comments on commit 451bb07

Please sign in to comment.