doc
|
@ -0,0 +1,7 @@
|
|||
![Image text](image/file1.png)
|
||||
![Image text](image/file2.png)
|
||||
![Image text](image/file3.png)
|
||||
![Image text](image/file4.png)
|
||||
![Image text](image/file5.png)
|
||||
![Image text](image/file6.png)
|
||||
![Image text](image/file7.png)
|
After Width: | Height: | Size: 2.1 MiB |
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/file1.png-3ffac0800e2b7d2118a19b3247b2f5f3.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://doc/demo14_file/image/file1.png"
|
||||
dest_files=[ "res://.import/file1.png-3ffac0800e2b7d2118a19b3247b2f5f3.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
After Width: | Height: | Size: 1.6 MiB |
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/file2.png-9be676ae73e6dabfdab5d47c9de45c66.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://doc/demo14_file/image/file2.png"
|
||||
dest_files=[ "res://.import/file2.png-9be676ae73e6dabfdab5d47c9de45c66.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
After Width: | Height: | Size: 2.7 MiB |
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/file3.png-4715757aa35beafa52c92a7ec377c917.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://doc/demo14_file/image/file3.png"
|
||||
dest_files=[ "res://.import/file3.png-4715757aa35beafa52c92a7ec377c917.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
After Width: | Height: | Size: 2.4 MiB |
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/file4.png-4c3824af11de46cee4f62f82384e3ad1.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://doc/demo14_file/image/file4.png"
|
||||
dest_files=[ "res://.import/file4.png-4c3824af11de46cee4f62f82384e3ad1.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
After Width: | Height: | Size: 2.4 MiB |
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/file5.png-f467d0f434db1a5e887c11898e394d30.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://doc/demo14_file/image/file5.png"
|
||||
dest_files=[ "res://.import/file5.png-f467d0f434db1a5e887c11898e394d30.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
After Width: | Height: | Size: 1.5 MiB |
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/file6.png-7ee5371775966a7dd9cbd95182678b43.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://doc/demo14_file/image/file6.png"
|
||||
dest_files=[ "res://.import/file6.png-7ee5371775966a7dd9cbd95182678b43.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
After Width: | Height: | Size: 2.4 MiB |
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/file7.png-6229bdb707266ee67d8fb0937efe4845.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://doc/demo14_file/image/file7.png"
|
||||
dest_files=[ "res://.import/file7.png-6229bdb707266ee67d8fb0937efe4845.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
|
@ -0,0 +1,6 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://script/demo14_file/file.gd" type="Script" id=1]
|
||||
|
||||
[node name="Node2D" type="Node2D"]
|
||||
script = ExtResource( 1 )
|
|
@ -0,0 +1,35 @@
|
|||
extends Node2D
|
||||
|
||||
const TimeUtils = preload("res://zfoo/scheduler/TimeUtils.gd")
|
||||
const FileUtils = preload("res://zfoo/util/FileUtils.gd")
|
||||
|
||||
|
||||
# Dictionary
|
||||
var content = "hello file!!!"
|
||||
|
||||
# path string
|
||||
var filePath: String = "user://playerData.txt"
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
print("Original Data: ", content)
|
||||
self.loadData()
|
||||
print("Altered Data: ", content)
|
||||
|
||||
|
||||
func saveData() -> void:
|
||||
|
||||
|
||||
FileUtils.writeStringToFile(filePath, content)
|
||||
|
||||
|
||||
func loadData() -> void:
|
||||
|
||||
content = FileUtils.readFileToString(filePath)
|
||||
|
||||
|
||||
func _notification(what):
|
||||
if what == MainLoop.NOTIFICATION_WM_QUIT_REQUEST:
|
||||
content = content + TimeUtils.currentTimeMillis() as String
|
||||
self.saveData()
|
||||
get_tree().quit() # quitting the game
|
|
@ -0,0 +1,26 @@
|
|||
extends Object
|
||||
|
||||
const StringUtils = preload("res://zfoo/util/StringUtils.gd")
|
||||
|
||||
# 以追加的方式写入一个content
|
||||
static func writeStringToFile(filePath: String, content: String) -> void:
|
||||
var file = File.new()
|
||||
file.open(filePath, File.WRITE)
|
||||
# bread and butter
|
||||
file.store_string(content)
|
||||
file.close()
|
||||
|
||||
|
||||
# 读取文件
|
||||
static func readFileToString(filePath: String) -> String:
|
||||
var file = File.new()
|
||||
# make sure our file exists on users system
|
||||
if !file.file_exists(filePath):
|
||||
return StringUtils.EMPTY
|
||||
|
||||
# allow reading only for file
|
||||
file.open(filePath, File.READ)
|
||||
|
||||
var content = file.get_as_text()
|
||||
file.close()
|
||||
return content
|