Mercurial > games > semicongine
annotate semiconginev2/old/resources.nim @ 1238:03634915bbdb
add: tests for updating texts, does not pass validation atm
author | sam <sam@basx.dev> |
---|---|
date | Sun, 21 Jul 2024 11:31:11 +0700 |
parents | 56781cc0fc7c |
children |
rev | line source |
---|---|
912 | 1 import std/parsecfg |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
2 import std/streams |
912 | 3 import std/algorithm |
911 | 4 import std/json |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
5 import std/strutils |
872
1ee397815b0b
did: image & font refactoring, add texture-atlas-packing
Sam <sam@basx.dev>
parents:
840
diff
changeset
|
6 import std/sequtils |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
7 import std/strformat |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
8 import std/os |
899 | 9 import std/sets |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
10 import std/unicode |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
11 |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
12 import ./core |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
13 import ./resources/image |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
14 import ./resources/audio |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
15 import ./resources/mesh |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
16 import ./resources/font |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
17 import ./mesh |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
18 import ./material |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
19 |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
20 export image |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
21 export audio |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
22 export mesh |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
23 |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
24 type |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
25 ResourceBundlingType = enum |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
26 Dir # Directories |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
27 Zip # Zip files |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
28 Exe # Embeded in executable |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
29 |
872
1ee397815b0b
did: image & font refactoring, add texture-atlas-packing
Sam <sam@basx.dev>
parents:
840
diff
changeset
|
30 const |
899 | 31 thebundletype = parseEnum[ResourceBundlingType](PACKAGETYPE.toLowerAscii().capitalizeAscii()) |
872
1ee397815b0b
did: image & font refactoring, add texture-atlas-packing
Sam <sam@basx.dev>
parents:
840
diff
changeset
|
32 ASCII_CHARSET = PrintableChars.toSeq.toRunes |
899 | 33 DEFAULT_PACKAGE = "default" |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
34 |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
35 # resource loading |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
36 |
899 | 37 func normalizeDir(dir: string): string = |
38 result = dir | |
39 if result.startsWith("./"): | |
40 result = result[2 .. ^1] | |
41 if result.startsWith("/"): | |
42 result = result[1 .. ^1] | |
43 result = dir.replace('\\', '/') | |
44 if not result.endsWith("/") and result != "": | |
45 result = result & "/" | |
46 | |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
47 when thebundletype == Dir: |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
48 |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
49 proc resourceRoot(): string = |
899 | 50 getAppDir().absolutePath().joinPath(RESOURCEROOT) |
51 proc packageRoot(package: string): string = | |
52 resourceRoot().joinPath(package) | |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
53 |
899 | 54 proc loadResource_intern(path: string, package: string): Stream = |
55 let realpath = package.packageRoot().joinPath(path) | |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
56 if not realpath.fileExists(): |
899 | 57 raise newException(Exception, &"Resource {path} not found (checked {realpath})") |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
58 newFileStream(realpath, fmRead) |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
59 |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
60 proc modList_intern(): seq[string] = |
882
5392cbd9db41
fix: material handlinge, did: formatting, add: support for multi-material texts
Sam <sam@basx.dev>
parents:
872
diff
changeset
|
61 for kind, file in walkDir(resourceRoot(), relative = true): |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
62 if kind == pcDir: |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
63 result.add file |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
64 |
899 | 65 iterator walkResources_intern(dir: string, package = DEFAULT_PACKAGE): string = |
66 for file in walkDirRec(package.packageRoot().joinPath(dir), relative = true): | |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
67 yield file |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
68 |
899 | 69 iterator ls_intern(dir: string, package: string): tuple[kind: PathComponent, path: string] = |
70 for i in walkDir(package.packageRoot().joinPath(dir), relative = true): | |
71 yield i | |
72 | |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
73 elif thebundletype == Zip: |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
74 |
1013 | 75 import ./thirdparty/zippy/zippy/ziparchives |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
76 |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
77 proc resourceRoot(): string = |
899 | 78 absolutePath(getAppDir()).joinPath(RESOURCEROOT) |
79 proc packageRoot(package: string): string = | |
80 resourceRoot().joinPath(package) | |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
81 |
899 | 82 proc loadResource_intern(path: string, package: string): Stream = |
83 let archive = openZipArchive(package.packageRoot() & ".zip") | |
84 try: | |
85 result = newStringStream(archive.extractFile(path)) | |
86 except ZippyError: | |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
87 raise newException(Exception, &"Resource {path} not found") |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
88 archive.close() |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
89 |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
90 proc modList_intern(): seq[string] = |
882
5392cbd9db41
fix: material handlinge, did: formatting, add: support for multi-material texts
Sam <sam@basx.dev>
parents:
872
diff
changeset
|
91 for kind, file in walkDir(resourceRoot(), relative = true): |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
92 if kind == pcFile and file.endsWith(".zip"): |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
93 result.add file[0 ..< ^4] |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
94 |
899 | 95 iterator walkResources_intern(dir: string, package = DEFAULT_PACKAGE): string = |
96 let archive = openZipArchive(package.packageRoot() & ".zip") | |
97 let normDir = dir.normalizeDir() | |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
98 for i in archive.walkFiles: |
899 | 99 if i.startsWith(normDir): |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
100 yield i |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
101 archive.close() |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
102 |
899 | 103 iterator ls_intern(dir: string, package: string): tuple[kind: PathComponent, path: string] = |
104 let archive = openZipArchive(package.packageRoot() & ".zip") | |
105 let normDir = dir.normalizeDir() | |
106 var yielded: HashSet[string] | |
107 | |
108 for i in archive.walkFiles: | |
109 if i.startsWith(normDir): | |
110 let components = i[normDir.len .. ^1].split('/', maxsplit = 1) | |
111 if components.len == 1: | |
112 if not (components[0] in yielded): | |
113 yield (kind: pcFile, path: components[0]) | |
114 else: | |
115 if not (components[0] in yielded): | |
116 yield (kind: pcDir, path: components[0]) | |
900 | 117 yielded.incl components[0] |
899 | 118 archive.close() |
119 | |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
120 elif thebundletype == Exe: |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
121 |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
122 import std/tables |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
123 |
898 | 124 const BUILD_RESOURCEROOT* {.strdefine.}: string = "" |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
125 |
898 | 126 proc loadResources(): Table[string, Table[string, string]] {.compileTime.} = |
995
2a1de6cb5282
fix: packaging fails if there are no resources, fix: zip-generation
sam <sam@basx.dev>
parents:
983
diff
changeset
|
127 when BUILD_RESOURCEROOT == "": |
2a1de6cb5282
fix: packaging fails if there are no resources, fix: zip-generation
sam <sam@basx.dev>
parents:
983
diff
changeset
|
128 {.warning: "BUILD_RESOURCEROOT is empty, no resources will be packaged".} |
2a1de6cb5282
fix: packaging fails if there are no resources, fix: zip-generation
sam <sam@basx.dev>
parents:
983
diff
changeset
|
129 return |
2a1de6cb5282
fix: packaging fails if there are no resources, fix: zip-generation
sam <sam@basx.dev>
parents:
983
diff
changeset
|
130 else: |
2a1de6cb5282
fix: packaging fails if there are no resources, fix: zip-generation
sam <sam@basx.dev>
parents:
983
diff
changeset
|
131 for kind, packageDir in walkDir(BUILD_RESOURCEROOT): |
2a1de6cb5282
fix: packaging fails if there are no resources, fix: zip-generation
sam <sam@basx.dev>
parents:
983
diff
changeset
|
132 if kind == pcDir: |
2a1de6cb5282
fix: packaging fails if there are no resources, fix: zip-generation
sam <sam@basx.dev>
parents:
983
diff
changeset
|
133 let package = packageDir.splitPath.tail |
2a1de6cb5282
fix: packaging fails if there are no resources, fix: zip-generation
sam <sam@basx.dev>
parents:
983
diff
changeset
|
134 result[package] = Table[string, string]() |
2a1de6cb5282
fix: packaging fails if there are no resources, fix: zip-generation
sam <sam@basx.dev>
parents:
983
diff
changeset
|
135 for resourcefile in walkDirRec(packageDir, relative = true): |
2a1de6cb5282
fix: packaging fails if there are no resources, fix: zip-generation
sam <sam@basx.dev>
parents:
983
diff
changeset
|
136 result[package][resourcefile.replace('\\', '/')] = staticRead(packageDir.joinPath(resourcefile)) |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
137 const bundledResources = loadResources() |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
138 |
899 | 139 proc loadResource_intern(path: string, package: string): Stream = |
140 if not (path in bundledResources[package]): | |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
141 raise newException(Exception, &"Resource {path} not found") |
899 | 142 newStringStream(bundledResources[package][path]) |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
143 |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
144 proc modList_intern(): seq[string] = |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
145 result = bundledResources.keys().toSeq() |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
146 |
899 | 147 iterator walkResources_intern(dir: string, package = DEFAULT_PACKAGE): string = |
148 for i in bundledResources[package].keys: | |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
149 yield i |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
150 |
899 | 151 iterator ls_intern(dir: string, package: string): tuple[kind: PathComponent, path: string] = |
152 let normDir = dir.normalizeDir() | |
153 var yielded: HashSet[string] | |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
154 |
899 | 155 for i in bundledResources[package].keys: |
156 if i.startsWith(normDir): | |
157 let components = i[normDir.len .. ^1].split('/', maxsplit = 1) | |
158 if components.len == 1: | |
159 if not (components[0] in yielded): | |
160 yield (kind: pcFile, path: components[0]) | |
161 else: | |
162 if not (components[0] in yielded): | |
163 yield (kind: pcDir, path: components[0]) | |
900 | 164 yielded.incl components[0] |
899 | 165 |
1139
114f395b9144
did: finish refactoring and updated all tests accordingly
sam <sam@basx.dev>
parents:
1138
diff
changeset
|
166 proc LoadResource*(path: string, package = DEFAULT_PACKAGE): Stream = |
899 | 167 loadResource_intern(path, package = package) |
168 | |
1139
114f395b9144
did: finish refactoring and updated all tests accordingly
sam <sam@basx.dev>
parents:
1138
diff
changeset
|
169 proc LoadImage*[T](path: string, package = DEFAULT_PACKAGE): Image[RGBAPixel] = |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
170 if path.splitFile().ext.toLowerAscii == ".bmp": |
1139
114f395b9144
did: finish refactoring and updated all tests accordingly
sam <sam@basx.dev>
parents:
1138
diff
changeset
|
171 loadResource_intern(path, package = package).ReadBMP() |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
172 elif path.splitFile().ext.toLowerAscii == ".png": |
1139
114f395b9144
did: finish refactoring and updated all tests accordingly
sam <sam@basx.dev>
parents:
1138
diff
changeset
|
173 loadResource_intern(path, package = package).ReadPNG() |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
174 else: |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
175 raise newException(Exception, "Unsupported image file type: " & path) |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
176 |
1139
114f395b9144
did: finish refactoring and updated all tests accordingly
sam <sam@basx.dev>
parents:
1138
diff
changeset
|
177 proc LoadAudio*(path: string, package = DEFAULT_PACKAGE): Sound = |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
178 if path.splitFile().ext.toLowerAscii == ".au": |
1138 | 179 loadResource_intern(path, package = package).ReadAU() |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
180 elif path.splitFile().ext.toLowerAscii == ".ogg": |
1138 | 181 loadResource_intern(path, package = package).ReadVorbis() |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
182 else: |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
183 raise newException(Exception, "Unsupported audio file type: " & path) |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
184 |
1139
114f395b9144
did: finish refactoring and updated all tests accordingly
sam <sam@basx.dev>
parents:
1138
diff
changeset
|
185 proc LoadJson*(path: string, package = DEFAULT_PACKAGE): JsonNode = |
911 | 186 path.loadResource_intern(package = package).readAll().parseJson() |
187 | |
1139
114f395b9144
did: finish refactoring and updated all tests accordingly
sam <sam@basx.dev>
parents:
1138
diff
changeset
|
188 proc LoadConfig*(path: string, package = DEFAULT_PACKAGE): Config = |
912 | 189 path.loadResource_intern(package = package).loadConfig(filename = path) |
190 | |
1139
114f395b9144
did: finish refactoring and updated all tests accordingly
sam <sam@basx.dev>
parents:
1138
diff
changeset
|
191 proc LoadFont*( |
872
1ee397815b0b
did: image & font refactoring, add texture-atlas-packing
Sam <sam@basx.dev>
parents:
840
diff
changeset
|
192 path: string, |
882
5392cbd9db41
fix: material handlinge, did: formatting, add: support for multi-material texts
Sam <sam@basx.dev>
parents:
872
diff
changeset
|
193 name = "", |
5392cbd9db41
fix: material handlinge, did: formatting, add: support for multi-material texts
Sam <sam@basx.dev>
parents:
872
diff
changeset
|
194 lineHeightPixels = 80'f32, |
5392cbd9db41
fix: material handlinge, did: formatting, add: support for multi-material texts
Sam <sam@basx.dev>
parents:
872
diff
changeset
|
195 additional_codepoints: openArray[Rune] = [], |
899 | 196 charset = ASCII_CHARSET, |
197 package = DEFAULT_PACKAGE | |
872
1ee397815b0b
did: image & font refactoring, add texture-atlas-packing
Sam <sam@basx.dev>
parents:
840
diff
changeset
|
198 ): Font = |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
199 var thename = name |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
200 if thename == "": |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
201 thename = path.splitFile().name |
1138 | 202 loadResource_intern(path, package = package).ReadTrueType(name, charset & additional_codepoints.toSeq, lineHeightPixels) |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
203 |
1139
114f395b9144
did: finish refactoring and updated all tests accordingly
sam <sam@basx.dev>
parents:
1138
diff
changeset
|
204 proc LoadMeshes*(path: string, defaultMaterial: MaterialType, package = DEFAULT_PACKAGE): seq[MeshTree] = |
1138 | 205 loadResource_intern(path, package = package).ReadglTF(defaultMaterial) |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
206 |
1139
114f395b9144
did: finish refactoring and updated all tests accordingly
sam <sam@basx.dev>
parents:
1138
diff
changeset
|
207 proc LoadFirstMesh*(path: string, defaultMaterial: MaterialType, package = DEFAULT_PACKAGE): Mesh = |
1138 | 208 loadResource_intern(path, package = package).ReadglTF(defaultMaterial)[0].toSeq[0] |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
209 |
1139
114f395b9144
did: finish refactoring and updated all tests accordingly
sam <sam@basx.dev>
parents:
1138
diff
changeset
|
210 proc Packages*(): seq[string] = |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
211 modList_intern() |
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
212 |
1139
114f395b9144
did: finish refactoring and updated all tests accordingly
sam <sam@basx.dev>
parents:
1138
diff
changeset
|
213 proc WalkResources*(dir = "", package = DEFAULT_PACKAGE): seq[string] = |
899 | 214 for i in walkResources_intern(dir, package = package): |
840
44ec744fbedc
did: package restructuring according to nimble recommendation for libraries
Sam <sam@basx.dev>
parents:
diff
changeset
|
215 if i.startsWith(dir): |
899 | 216 result.add i |
217 result.sort() | |
218 | |
1139
114f395b9144
did: finish refactoring and updated all tests accordingly
sam <sam@basx.dev>
parents:
1138
diff
changeset
|
219 proc List*(dir: string, package = DEFAULT_PACKAGE): seq[tuple[kind: PathComponent, path: string]] = |
899 | 220 for i in ls_intern(dir = dir, package = package): |
221 result.add i | |
222 result.sort() |