Skip to content

Commit

Permalink
Path handling fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ZILtoid1991 committed Feb 11, 2024
1 parent 5f72dc5 commit e70b45b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
2 changes: 2 additions & 0 deletions pixelperfectengine/src/pixelperfectengine/audio/base/config.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
12 changes: 7 additions & 5 deletions pixelperfectengine/src/pixelperfectengine/system/config.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand All @@ -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"));
}
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion pixelperfectengine/src/pixelperfectengine/system/file.d
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
/**
Expand Down
1 change: 1 addition & 0 deletions test1/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion test3/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e70b45b

Please sign in to comment.