From e70b45b1aa3949c60260fd4845e9af4f5cc54098 Mon Sep 17 00:00:00 2001 From: ZILtoid1991 Date: Sun, 11 Feb 2024 20:53:04 +0100 Subject: [PATCH] Path handling fixes --- .../src/pixelperfectengine/audio/base/config.d | 2 ++ .../src/pixelperfectengine/system/config.d | 12 +++++++----- .../src/pixelperfectengine/system/file.d | 1 - test1/app.d | 1 + test3/app.d | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/pixelperfectengine/src/pixelperfectengine/audio/base/config.d b/pixelperfectengine/src/pixelperfectengine/audio/base/config.d index f4cd424b..780ce130 100644 --- a/pixelperfectengine/src/pixelperfectengine/audio/base/config.d +++ b/pixelperfectengine/src/pixelperfectengine/audio/base/config.d @@ -4,6 +4,7 @@ import sdlang; import pixelperfectengine.audio.base.handler; import pixelperfectengine.audio.base.modulebase; +import pixelperfectengine.system.file : getPathToAsset; import collections.commons : defaultHash; @@ -262,6 +263,7 @@ public class ModuleConfig { */ protected void loadAudioFile(AudioModule mod, int waveID, string path, string dataPak = null) { import std.path : extension; + path = getPathToAsset(path); switch (extension(path)) { case ".wav": loadWaveFile(mod, waveID, path, dataPak); diff --git a/pixelperfectengine/src/pixelperfectengine/system/config.d b/pixelperfectengine/src/pixelperfectengine/system/config.d index 30332b6b..071819d5 100644 --- a/pixelperfectengine/src/pixelperfectengine/system/config.d +++ b/pixelperfectengine/src/pixelperfectengine/system/config.d @@ -14,6 +14,7 @@ import std.conv; //import std.csv; import pixelperfectengine.system.input.handler; +import pixelperfectengine.system.file; import pixelperfectengine.system.exc; import pixelperfectengine.system.etc; import pixelperfectengine.system.dictionary; @@ -88,7 +89,7 @@ public class ConfigurationProfile { public this() { path = vaultPath ~ "config.sdl"; if(!exists(path)) - std.file.copy("../system/defaultConfig.sdl",path); + std.file.copy(getPathToAsset("%PATH%/system/defaultConfig.sdl"),path); restore(); } /// Initializes a basic configuration profile with user supplied values. @@ -108,8 +109,8 @@ public class ConfigurationProfile { devicetypeStrings = [Devicetype.Joystick: "joystick", Devicetype.Keyboard: "keyboard", Devicetype.Mouse: "mouse", Devicetype.Touchscreen: "touchscreen" ]; //keyNameDict = new Dictionary("../system/keycodeNamings.sdl"); - keyNameDict = new Dictionary(parseFile("../system/scancodes.sdl")); - Tag xinput = parseFile("../system/xinputCodes.sdl"); + keyNameDict = new Dictionary(parseFile(getPathToAsset("%PATH%/system/scancodes.sdl"))); + Tag xinput = parseFile(getPathToAsset("%PATH%/system/xinputCodes.sdl")); joyButtonNameDict = new Dictionary(xinput.expectTag("button")); joyAxisNameDict = new Dictionary(xinput.expectTag("axis")); } @@ -401,8 +402,9 @@ public class ConfigurationProfile { * If ../_debug/ folder exists, it'll be used instead for emulation purposes. */ public static void setVaultPath(const char* developer, const char* application){ - if (exists("../_debug/")) { - vaultPath = "../_debug/" ~ fromStringz(developer).idup ~ "_" ~ fromStringz(application).idup ~ "/"; + if (exists(getPathToAsset("%PATH%/_debug/"))) { + vaultPath = getPathToAsset("%PATH%/_debug/") ~ "/" ~ fromStringz(developer).idup ~ "_" ~ + fromStringz(application).idup ~ "/"; if (!std.file.exists(vaultPath)) std.file.mkdir(vaultPath); } else { diff --git a/pixelperfectengine/src/pixelperfectengine/system/file.d b/pixelperfectengine/src/pixelperfectengine/system/file.d index 1be42446..9ba935fe 100644 --- a/pixelperfectengine/src/pixelperfectengine/system/file.d +++ b/pixelperfectengine/src/pixelperfectengine/system/file.d @@ -289,7 +289,6 @@ public string getPathToAsset (string path) @safe pure { if (startsWith(path, "%PATH%")) path = path[6..$]; else if (startsWith(path, "../", "..\\")) path = path[3..$]; //else if (startsWith(path, ["./", ".\\"])) path = path[2..$]; - return buildNormalizedPath(pathRoot ~ dirSeparator ~ path); } /** diff --git a/test1/app.d b/test1/app.d index b6e5dcf7..e2766edf 100644 --- a/test1/app.d +++ b/test1/app.d @@ -271,6 +271,7 @@ public class AudioDevKit : InputListener, SystemEventListener { ih.test(); timer.test(); } + version (linux) midiIn.stop(); if (mm !is null) { synchronized writeln(mm.suspendAudioThread()); diff --git a/test3/app.d b/test3/app.d index bef657dd..342e66e6 100644 --- a/test3/app.d +++ b/test3/app.d @@ -42,7 +42,7 @@ public class TestElements : InputListener, SystemEventListener { outScrn = new OutputScreen("Test nr. 3",1696,960); mainRaster = new Raster(848,480,outScrn,0,1); mainRaster.addLayer(sprtL,0); - mainRaster.loadPalette(loadPaletteFromFile(getPathToAsset("/system/ConcreteGUIE1.tga"))); + mainRaster.loadPalette(loadPaletteFromFile(getPathToAsset("/system/concreteGUIE1.tga"))); wh = new WindowHandler(1696,960,848,480,sprtL); ih = new InputHandler(); ih.inputListener = this;