changeset 657:c04425caeab5

ups, missing file
author Sam <sam@basx.dev>
date Sun, 07 May 2023 01:30:38 +0700
parents f06a781e798d
children 8549373571aa
files src/semicongine/buildconfig.nim src/semicongine/resources.nim
diffstat 2 files changed, 50 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/semicongine/buildconfig.nim	Sun May 07 01:02:06 2023 +0700
+++ b/src/semicongine/buildconfig.nim	Sun May 07 01:30:38 2023 +0700
@@ -44,3 +44,6 @@
 # log level
 const LOGLEVEL {.strdefine.}: string = (when DEBUG: "lvlAll" else: "lvlWarn")
 const ENGINE_LOGLEVEL* = parseEnum[Level](LOGLEVEL)
+
+const MODROOT* {.strdefine.}: string = "mods"
+const BUNDLETYPE* {.strdefine.}: string = "Dir" # zip, exe
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/semicongine/resources.nim	Sun May 07 01:30:38 2023 +0700
@@ -0,0 +1,47 @@
+{. error: "do resources" .}
+
+import std/strutils
+import std/os
+
+import ./buildconfig
+
+type
+  ResourceBundlingType* = enum
+    Dir # Directories
+    Zip # Zip files
+    Exe # Embeded in executable
+  Resource = ref object of RootObj
+    name: string
+    data: seq[uint8]
+
+const thebundletype = parseEnum[ResourceBundlingType](BUNDLETYPE)
+
+proc loadResourceDirectory(path: string): Resource =
+  var fullpath = joinPath(MODROOT, path)
+  result
+proc loadResourceZip(path: string): Resource =
+  var fullpath = joinPath(MODROOT, path)
+  result
+proc loadResourceExecutable(path: string): Resource =
+  result
+proc loadResource*(path: string): Resource =
+  case thebundletype
+  of Dir: return loadResourceDirectory(path)
+  of Zip: return loadResourceZip(path)
+  of Exe: return loadResourceExecutable(path)
+
+proc bundleResourcesDirectory() {.compiletime.} =
+  # copy resource files to output directory
+  discard
+proc bundleResourcesZip() {.compiletime.} =
+  # copy resource files to zip in output directory
+  discard
+proc bundleResourcesExecutable() {.compiletime.} =
+  # put resource contents into variable here
+  discard
+proc bundleResources() {.compiletime.} =
+  when thebundletype == Dir: bundleResourcesDirectory()
+  elif thebundletype == Zip: bundleResourcesZip()
+  elif thebundletype == Exe: bundleResourcesExecutable()
+
+static: bundleResources()