# HG changeset patch # User Sam # Date 1683397838 -25200 # Node ID c04425caeab51c9b0e95061fadea4f6707bd446d # Parent f06a781e798d5e3f5ea324e0af1461db1ed36867 ups, missing file diff -r f06a781e798d -r c04425caeab5 src/semicongine/buildconfig.nim --- 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 diff -r f06a781e798d -r c04425caeab5 src/semicongine/resources.nim --- /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()