mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-05-16 14:14:07 +00:00
find_file to find files in HYPERPATH
This commit is contained in:
parent
7be773ea03
commit
31b2bd9690
@ -1722,7 +1722,7 @@ auto hook = addHook(hooks_args, 100, readArgs);
|
|||||||
|
|
||||||
EX bool in() { return geometry == gArbitrary; }
|
EX bool in() { return geometry == gArbitrary; }
|
||||||
|
|
||||||
EX string tes = "tessellations/sample/marjorie-rice.tes";
|
EX string tes = find_file("tessellations/sample/marjorie-rice.tes");
|
||||||
|
|
||||||
EX bool linespattern(cell *c) {
|
EX bool linespattern(cell *c) {
|
||||||
return current.shapes[id_of(c->master)].flags & arcm::sfLINE;
|
return current.shapes[id_of(c->master)].flags & arcm::sfLINE;
|
||||||
|
@ -207,7 +207,7 @@ EX bool loadMusicInfo() {
|
|||||||
#endif
|
#endif
|
||||||
#ifdef FHS
|
#ifdef FHS
|
||||||
|| loadMusicInfo("/usr/share/hyperrogue/hyperrogue-music.txt")
|
|| loadMusicInfo("/usr/share/hyperrogue/hyperrogue-music.txt")
|
||||||
|| loadMusicInfo(s0 + getenv("HOME") + "/.hyperrogue-music.txt")
|
|| (getenv("HOME") && loadMusicInfo(s0 + getenv("HOME") + "/.hyperrogue-music.txt"))
|
||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,10 @@ struct textureinfo : basic_textureinfo {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if HDR
|
||||||
|
string find_file(string s);
|
||||||
|
#endif
|
||||||
|
|
||||||
EX namespace texture {
|
EX namespace texture {
|
||||||
|
|
||||||
#if HDR
|
#if HDR
|
||||||
@ -120,8 +124,8 @@ struct texture_config {
|
|||||||
|
|
||||||
texture_config() {
|
texture_config() {
|
||||||
// argh, no member initialization in some of my compilers
|
// argh, no member initialization in some of my compilers
|
||||||
texturename = "textures/hyperrogue-texture.png";
|
texturename = find_file("textures/hyperrogue-texture.png");
|
||||||
configname = "textures/hyperrogue.txc";
|
configname = find_file("textures/hyperrogue.txc");
|
||||||
itt = Id;
|
itt = Id;
|
||||||
grid_color = 0;
|
grid_color = 0;
|
||||||
mesh_color = 0;
|
mesh_color = 0;
|
||||||
|
13
util.cpp
13
util.cpp
@ -766,6 +766,19 @@ EX bool file_exists(string fname) {
|
|||||||
return access(fname.c_str(), F_OK) != -1;
|
return access(fname.c_str(), F_OK) != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** find a file named s, possibly in HYPERPATH */
|
||||||
|
EX string find_file(string s) {
|
||||||
|
string s1;
|
||||||
|
if(file_exists(s)) return s;
|
||||||
|
char *p = getenv("HYPERPATH");
|
||||||
|
if(p && file_exists(s1 = s0 + p + s)) return s1;
|
||||||
|
if(file_exists(s1 = HYPERPATH + s)) return s1;
|
||||||
|
#ifdef FHS
|
||||||
|
if(file_exists(s1 = "/usr/share/hyperrogue/" + s)) return s1;
|
||||||
|
#endif
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
EX void open_url(string s) {
|
EX void open_url(string s) {
|
||||||
#if ISWEB
|
#if ISWEB
|
||||||
EM_ASM_({
|
EM_ASM_({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user