diff --git a/_mirror b/_mirror index 5daf19e..be43196 160000 --- a/_mirror +++ b/_mirror @@ -1 +1 @@ -Subproject commit 5daf19e6b5579dfba7d5bc83d4b2c7db02e4c3a0 +Subproject commit be43196a3d33412a5dbad92983af7e149b1b066d diff --git a/engine/art/audio/coin.wav b/engine/art/audio/coin.wav deleted file mode 100644 index b0ca3e8..0000000 Binary files a/engine/art/audio/coin.wav and /dev/null differ diff --git a/engine/art/audio/larry.mid b/engine/art/audio/larry.mid deleted file mode 100644 index 3b886aa..0000000 Binary files a/engine/art/audio/larry.mid and /dev/null differ diff --git a/engine/art/audio/larry.txt b/engine/art/audio/larry.txt deleted file mode 100644 index 63987f6..0000000 --- a/engine/art/audio/larry.txt +++ /dev/null @@ -1,38 +0,0 @@ - SIERRA ON-LINE, INC. - 3-D Animated Adventure Game Soundtrack Series - =============================================== - LEISURE SUIT LARRY III: PASSIONATE PATTI- - IN PURSUIT OF THE PULSATING PECTORALS - - - "TAWNI AT THE BEACH" - Mike Dana - =============================================== - Copyright (c)1989 Sierra On-Line, Inc. - =============================================== - - GENERAL MIDI VERSION - -System Requirements: - -- MIDI Playback Software capable of reading Type 1 Standard - MIDI File format -- General MIDI sound device (Wave Table or better recommended) - - -This Standard MIDI File was recorded directly from Sierra's "Leisure Suit -Larry 3" adventure game. It has been converted from the MT-32 version for -playback on General MIDI sound cards. A Wave Table or better sound card is -highly recommended for optimal playback. - -Recorded/converted for General MIDI by Tom Lewandowski. -Address questions or comments to: - - QUEST STUDIOS - Tom Lewandowski - tom@queststudios.com - - www.QuestStudios.com - - - diff --git a/engine/art/audio/monkey1.mid b/engine/art/audio/monkey1.mid deleted file mode 100644 index aef79ef..0000000 Binary files a/engine/art/audio/monkey1.mid and /dev/null differ diff --git a/engine/art/audio/monkey1.txt b/engine/art/audio/monkey1.txt deleted file mode 100644 index e3f8294..0000000 --- a/engine/art/audio/monkey1.txt +++ /dev/null @@ -1,43 +0,0 @@ - QUEST STUDIOS - SOFTWARE SOUNDTRACK SERIES - ==================================================== - THE SECRET OF MONKEY ISLAND - - - "INTRODUCTION/OPENING THEMES" - Michael Z. Land - ==================================================== - Copyright (c)1989 LucasArts Entertainment Co. - ==================================================== - - G E N E R A L M I D I V E R S I O N - - - -System Requirements: - -- MIDI Playback Software capable of reading Type 1 Standard - MIDI File format -- General MIDI sound device (Wave Table recommended.) - - -This Standard MIDI File was recorded directly from LucasFilm Game's -"The Secret of Monkey Island" adventure game. It has been converted -from the MT-32 version for playback on General MIDI sound cards. A -Wave Table sound card is highly recommended for optimal playback. - -Recorded/Converted to Standard MIDI File format by Tom Lewandowski. -Address questions or comments to: - - QUEST STUDIOS - Tom Lewandowski - tom+di@netnet.net - - - - THE ROLAND MT-32 SOUND MODULE RESOURCE CENTER - THE SIERRA SOUNDTRACK SERIES/SOFTWARE SOUNDTRACK SERIES - http://bayland.net/~tom+di/sierra/roland.html - - - diff --git a/engine/art/audio/pew.sfxr b/engine/art/audio/pew.sfxr deleted file mode 100644 index 4689701..0000000 Binary files a/engine/art/audio/pew.sfxr and /dev/null differ diff --git a/engine/art/audio/waterworld-map.fur b/engine/art/audio/waterworld-map.fur deleted file mode 100644 index 2bf8a7a..0000000 Binary files a/engine/art/audio/waterworld-map.fur and /dev/null differ diff --git a/engine/art/audio/wrath_of_the_djinn.txt b/engine/art/audio/wrath_of_the_djinn.txt deleted file mode 100644 index b359515..0000000 --- a/engine/art/audio/wrath_of_the_djinn.txt +++ /dev/null @@ -1,3 +0,0 @@ -Licensed under the Public Domain license -Registered Artist(s): - Drozerix diff --git a/engine/art/audio/wrath_of_the_djinn.xm b/engine/art/audio/wrath_of_the_djinn.xm deleted file mode 100644 index 84c16b0..0000000 Binary files a/engine/art/audio/wrath_of_the_djinn.xm and /dev/null differ diff --git a/engine/joint/v4k.h b/engine/joint/v4k.h index f886324..3cc65d0 100644 --- a/engine/joint/v4k.h +++ b/engine/joint/v4k.h @@ -14757,7 +14757,7 @@ API void (map_clear)(map* m); API char *cc4str(unsigned cc); API char *cc8str(uint64_t cc); -enum { ///- +enum { # define _(a,b,c,d,e) cc__##a, cc__##b, cc__##c, cc__##d, cc__##e cc__1 = '1', _(2,3,4,5,6),_(7,8,9,0,_), cc__ = ' ', cc__A = 'A', _(B,C,D,E,F),_(G,H,I,J,K),_(L,M,N,O,P),_(Q,R,S,T,U),_(V,W,X,Y,Z), @@ -253747,8 +253747,9 @@ int dir_yield(dir *d, const char *pathfile, char *name, int namelen) { snprintf(name, namelen, "%s/*", pathfile); for( HANDLE h = FindFirstFileA(name, &fdata ); h != INVALID_HANDLE_VALUE; ok = (FindClose( h ), h = INVALID_HANDLE_VALUE, 1)) { for( int next = 1; next; next = FindNextFileA(h, &fdata) != 0 ) { - if( fdata.cFileName[0] == '.' ) continue; int is_dir = (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) > 0; + if( is_dir && fdata.cFileName[0] == '.' ) continue; + snprintf(name, namelen, "%s/%s%s", pathfile, fdata.cFileName, is_dir ? "/" : ""); struct stat st; if( !is_dir ) if(stat(name, &st) < 0) continue; // add @@ -253763,10 +253764,11 @@ int dir_yield(dir *d, const char *pathfile, char *name, int namelen) { snprintf(name, namelen, "%s/", pathfile); for( DIR *dir = opendir(name); dir; ok = (closedir(dir), dir = 0, 1)) { for( struct dirent *ep; (ep = readdir(dir)) != NULL; ) { - if( ep->d_name[0] == '.' ) continue; snprintf(name, namelen, "%s/%s", pathfile, ep->d_name); struct stat st; if( stat(name, &st) < 0 ) continue; - DIR *tmp = opendir(/*ep->d_*/name); int is_dir = !!tmp; if(tmp) closedir(tmp); + DIR *tmp = opendir(/*ep->d_*/name); int is_dir = !!tmp; if(tmp) closedir(tmp); // @todo:optimizeme (maybe use stat instead) + if( is_dir && ep->d_name[0] == '.' ) continue; + // add dir_entry de = { STRDUP(name), is_dir ? 0 : st.st_size, is_dir }; d->entry = (dir_entry*)REALLOC(d->entry, ++d->count * sizeof(dir_entry)); @@ -586455,7 +586457,6 @@ int cook_jobs() { return clampi(num_jobs, 0, cook_disabled?0:max_jobs); } - void cook_config( const char *pathfile_to_cook_ini ) { // @todo: test run-from-"bin/" case on Linux. COOK_INI = pathfile_to_cook_ini; ASSERT( file_exist(COOK_INI) ); @@ -587012,36 +587013,30 @@ const char** file_list(const char *cwd, const char *masks) { } array_resize(list, 0);//array_free(list); - for each_substring(masks,";",it) { - int recurse = !!strstr(it, "**"); - #if is(win32) - char *glob = va("dir %s/b/o:n \"%s\\%s\" 2> NUL", recurse ? "/s":"", cwd, it); - #else // linux, osx - char *glob = va("find %s %s -name \"%s\" | sort", cwd, !recurse ? "-maxdepth 1":"-type f", it); - #endif - for( FILE *in = popen(glob, "r"); in; pclose(in), in = 0) { - char buf[1024], *line = buf; - while( fgets(buf, sizeof(buf), in) ) { - // clean up - if( strstr(line, arg0) ) line = buf + larg0; - if( !memcmp(line, "./", 2) ) line += 2; - int len = strlen(line); while( len > 0 && line[len-1] < 32 ) line[--len] = 0; - if( line[0] == '\0' ) continue; - // do not insert system folders/files - for(int i = 0; i < len; ++i ) if(line[i] == '\\') line[i] = '/'; - if( line[0] == '.' ) if( !strcmp(line,".git") || !strcmp(line,".vs") || !strcmp(line,".") || !strcmp(line,"..") ) continue; - if( strstr(line, "/.") ) continue; + dir *d = dir_open(cwd, "rb"); + if( d ) { + for( int i = 0; i < dir_count(d); ++i ) { + if( dir_file(d,i) ) { + // dir_name() should return full normalized paths "C:/prj/v4k/demos/art/fx/fxBloom.fs". should exclude system dirs as well + char *entry = dir_name(d,i); + char *fname = file_name(entry); + + int allowed = 0; + for each_substring(masks,";",mask) { + allowed |= strmatch(fname, mask); + } + if( !allowed ) continue; + + // if( strstr(fname, "/.") ) continue; // @fixme: still needed? useful? + // insert copy - #if is(win32) - char *copy = STRDUP(line); // full path already provided - #else - // while(line[0] == '/') ++line; - char *copy = STRDUP(va("%s%s", cwd, line)); // need to prepend path - #endif + char *copy = STRDUP(entry); array_push(list, copy); } } + dir_close(d); } + array_push(list, 0); // terminator return (const char**)list; } @@ -587578,12 +587573,14 @@ if( found && *found == 0 ) { base = file_name(pathfile); if(base[0] == '\0') return 0; // it's a dir folder = file_path(pathfile); - // make folder variable easier to read in logs: /home/rlyeh/prj/v4k/art/demos/audio/coin.wav -> demos/audio/coin.wav - // static int ART_LEN = 0; do_once ART_LEN = strlen(ART); - // if( !strncmp(folder, ART, ART_LEN) ) { - // folder += ART_LEN; - // } - char* pretty_folder = folder && strlen(folder) >= ART_LEN ? folder + ART_LEN : ""; + // ease folders reading by shortening them: /home/rlyeh/prj/v4k/art/demos/audio/coin.wav -> demos/audio/coin.wav + // or C:/prj/v4k/engine/art/fonts/B612-BoldItalic.ttf -> fonts/B612-BoldItalic.ttf + static array(char*) art_paths = 0; + do_once for each_substring(ART,",",stem) array_push(art_paths, STRDUP(stem)); + char* pretty_folder = ""; + if( folder ) for( int i = 0; i < array_count(art_paths); ++i ) { + if( strbeg(folder, art_paths[i]) ) { pretty_folder = folder + strlen(art_paths[i]); break; } + } //} int size = 0; @@ -591809,7 +591806,7 @@ bool invert44(mat44 T, const mat44 M) { // !!! ok, i guess } vec4 transform444(const mat44, const vec4); -bool unproject44(vec3 *out, vec3 xyd, vec4 viewport, mat44 mvp) { +bool unproject44(vec3 *out, vec3 xyd, vec4 viewport, mat44 mvp) { // @fixme: this function is broken (verified by @zpl-zak) // xyd: usually x:mouse_x,y:window_height()-mouse_y,d:0=znear/1=zfar // src: https://www.khronos.org/opengl/wiki/GluProject_and_gluUnProject_code mat44 inv_mvp; @@ -600273,7 +600270,7 @@ void camera_fov(camera_t *cam, float fov) { float DIMETRIC = 30.000f; float ISOMETRIC = 35.264f; - float aspect = window_width() / ((float)window_height()+!!window_height()); + float aspect = window_width() / ((float)window_height()+!window_height()); orthogonal(cam->proj, 45, aspect, -1000, 1000); // why -1000? // cam->yaw = 45; cam->pitch = -ISOMETRIC; @@ -601991,7 +601988,7 @@ bool app_open_folder(const char *file) { #ifdef _WIN32 snprintf(buf, sizeof(buf), "start \"\" \"%s\"", file); #elif __APPLE__ - snprintf(buf, sizeof(buf), "%s \"%s\"", is_directory(file) ? "open" : "open --reveal", file); + snprintf(buf, sizeof(buf), "%s \"%s\"", file_directory(file) ? "open" : "open --reveal", file); #else snprintf(buf, sizeof(buf), "xdg-open \"%s\"", file); #endif @@ -606805,6 +606802,14 @@ char *editor_path(const char *path) { } vec3 editor_pick(float mouse_x, float mouse_y) { +#if 0 + // unproject 2d coord as 3d coord + camera_t *camera = camera_get_active(); + vec3 out, xyd = vec3(mouse_x,window_height()-mouse_y,1); // usually x:mouse_x,y:window_height()-mouse_y,d:0=znear/1=zfar + mat44 mvp, model; identity44(model); multiply44x3(mvp, camera->proj, camera->view, model); + bool ok = unproject44(&out, xyd, vec4(0,0,window_width(),window_height()), mvp); + return out; +#else // unproject 2d coord as 3d coord camera_t *camera = camera_get_active(); float x = (2.0f * mouse_x) / window_width() - 1.0f; @@ -606818,6 +606823,7 @@ vec3 editor_pick(float mouse_x, float mouse_y) { vec4 eye = vec4(p.x, p.y, -1.0, 0.0); vec4 wld = norm4(transform444(inv_view, eye)); return vec3(wld.x, wld.y, wld.z); +#endif } int editor_ui_bits8(const char *label, uint8_t *enabled) { // @to deprecate diff --git a/engine/split/3rd_archive.h b/engine/split/3rd_archive.h index 4d808a3..6f3fd2a 100644 --- a/engine/split/3rd_archive.h +++ b/engine/split/3rd_archive.h @@ -1471,8 +1471,9 @@ int dir_yield(dir *d, const char *pathfile, char *name, int namelen) { snprintf(name, namelen, "%s/*", pathfile); for( HANDLE h = FindFirstFileA(name, &fdata ); h != INVALID_HANDLE_VALUE; ok = (FindClose( h ), h = INVALID_HANDLE_VALUE, 1)) { for( int next = 1; next; next = FindNextFileA(h, &fdata) != 0 ) { - if( fdata.cFileName[0] == '.' ) continue; int is_dir = (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) > 0; + if( is_dir && fdata.cFileName[0] == '.' ) continue; + snprintf(name, namelen, "%s/%s%s", pathfile, fdata.cFileName, is_dir ? "/" : ""); struct stat st; if( !is_dir ) if(stat(name, &st) < 0) continue; // add @@ -1487,10 +1488,11 @@ int dir_yield(dir *d, const char *pathfile, char *name, int namelen) { snprintf(name, namelen, "%s/", pathfile); for( DIR *dir = opendir(name); dir; ok = (closedir(dir), dir = 0, 1)) { for( struct dirent *ep; (ep = readdir(dir)) != NULL; ) { - if( ep->d_name[0] == '.' ) continue; snprintf(name, namelen, "%s/%s", pathfile, ep->d_name); struct stat st; if( stat(name, &st) < 0 ) continue; - DIR *tmp = opendir(/*ep->d_*/name); int is_dir = !!tmp; if(tmp) closedir(tmp); + DIR *tmp = opendir(/*ep->d_*/name); int is_dir = !!tmp; if(tmp) closedir(tmp); // @todo:optimizeme (maybe use stat instead) + if( is_dir && ep->d_name[0] == '.' ) continue; + // add dir_entry de = { STRDUP(name), is_dir ? 0 : st.st_size, is_dir }; d->entry = (dir_entry*)REALLOC(d->entry, ++d->count * sizeof(dir_entry)); diff --git a/engine/split/v4k_cooker.c b/engine/split/v4k_cooker.c index 26d7f7e..c56d921 100644 --- a/engine/split/v4k_cooker.c +++ b/engine/split/v4k_cooker.c @@ -817,7 +817,6 @@ int cook_jobs() { return clampi(num_jobs, 0, cook_disabled?0:max_jobs); } - void cook_config( const char *pathfile_to_cook_ini ) { // @todo: test run-from-"bin/" case on Linux. COOK_INI = pathfile_to_cook_ini; ASSERT( file_exist(COOK_INI) ); diff --git a/engine/split/v4k_ds.h b/engine/split/v4k_ds.h index dbcb47d..03b53d1 100644 --- a/engine/split/v4k_ds.h +++ b/engine/split/v4k_ds.h @@ -433,7 +433,7 @@ API void (map_clear)(map* m); API char *cc4str(unsigned cc); API char *cc8str(uint64_t cc); -enum { ///- +enum { # define _(a,b,c,d,e) cc__##a, cc__##b, cc__##c, cc__##d, cc__##e cc__1 = '1', _(2,3,4,5,6),_(7,8,9,0,_), cc__ = ' ', cc__A = 'A', _(B,C,D,E,F),_(G,H,I,J,K),_(L,M,N,O,P),_(Q,R,S,T,U),_(V,W,X,Y,Z), diff --git a/engine/split/v4k_editor.c b/engine/split/v4k_editor.c index 300b202..5cb221b 100644 --- a/engine/split/v4k_editor.c +++ b/engine/split/v4k_editor.c @@ -6,6 +6,14 @@ char *editor_path(const char *path) { } vec3 editor_pick(float mouse_x, float mouse_y) { +#if 0 + // unproject 2d coord as 3d coord + camera_t *camera = camera_get_active(); + vec3 out, xyd = vec3(mouse_x,window_height()-mouse_y,1); // usually x:mouse_x,y:window_height()-mouse_y,d:0=znear/1=zfar + mat44 mvp, model; identity44(model); multiply44x3(mvp, camera->proj, camera->view, model); + bool ok = unproject44(&out, xyd, vec4(0,0,window_width(),window_height()), mvp); + return out; +#else // unproject 2d coord as 3d coord camera_t *camera = camera_get_active(); float x = (2.0f * mouse_x) / window_width() - 1.0f; @@ -19,6 +27,7 @@ vec3 editor_pick(float mouse_x, float mouse_y) { vec4 eye = vec4(p.x, p.y, -1.0, 0.0); vec4 wld = norm4(transform444(inv_view, eye)); return vec3(wld.x, wld.y, wld.z); +#endif } int editor_ui_bits8(const char *label, uint8_t *enabled) { // @to deprecate diff --git a/engine/split/v4k_file.c b/engine/split/v4k_file.c index 48d8b39..47d45b4 100644 --- a/engine/split/v4k_file.c +++ b/engine/split/v4k_file.c @@ -212,36 +212,30 @@ const char** file_list(const char *cwd, const char *masks) { } array_resize(list, 0);//array_free(list); - for each_substring(masks,";",it) { - int recurse = !!strstr(it, "**"); - #if is(win32) - char *glob = va("dir %s/b/o:n \"%s\\%s\" 2> NUL", recurse ? "/s":"", cwd, it); - #else // linux, osx - char *glob = va("find %s %s -name \"%s\" | sort", cwd, !recurse ? "-maxdepth 1":"-type f", it); - #endif - for( FILE *in = popen(glob, "r"); in; pclose(in), in = 0) { - char buf[1024], *line = buf; - while( fgets(buf, sizeof(buf), in) ) { - // clean up - if( strstr(line, arg0) ) line = buf + larg0; - if( !memcmp(line, "./", 2) ) line += 2; - int len = strlen(line); while( len > 0 && line[len-1] < 32 ) line[--len] = 0; - if( line[0] == '\0' ) continue; - // do not insert system folders/files - for(int i = 0; i < len; ++i ) if(line[i] == '\\') line[i] = '/'; - if( line[0] == '.' ) if( !strcmp(line,".git") || !strcmp(line,".vs") || !strcmp(line,".") || !strcmp(line,"..") ) continue; - if( strstr(line, "/.") ) continue; + dir *d = dir_open(cwd, "rb"); + if( d ) { + for( int i = 0; i < dir_count(d); ++i ) { + if( dir_file(d,i) ) { + // dir_name() should return full normalized paths "C:/prj/v4k/demos/art/fx/fxBloom.fs". should exclude system dirs as well + char *entry = dir_name(d,i); + char *fname = file_name(entry); + + int allowed = 0; + for each_substring(masks,";",mask) { + allowed |= strmatch(fname, mask); + } + if( !allowed ) continue; + + // if( strstr(fname, "/.") ) continue; // @fixme: still needed? useful? + // insert copy - #if is(win32) - char *copy = STRDUP(line); // full path already provided - #else - // while(line[0] == '/') ++line; - char *copy = STRDUP(va("%s%s", cwd, line)); // need to prepend path - #endif + char *copy = STRDUP(entry); array_push(list, copy); } } + dir_close(d); } + array_push(list, 0); // terminator return (const char**)list; } @@ -778,12 +772,14 @@ if( found && *found == 0 ) { base = file_name(pathfile); if(base[0] == '\0') return 0; // it's a dir folder = file_path(pathfile); - // make folder variable easier to read in logs: /home/rlyeh/prj/v4k/art/demos/audio/coin.wav -> demos/audio/coin.wav - // static int ART_LEN = 0; do_once ART_LEN = strlen(ART); - // if( !strncmp(folder, ART, ART_LEN) ) { - // folder += ART_LEN; - // } - char* pretty_folder = folder && strlen(folder) >= ART_LEN ? folder + ART_LEN : ""; + // ease folders reading by shortening them: /home/rlyeh/prj/v4k/art/demos/audio/coin.wav -> demos/audio/coin.wav + // or C:/prj/v4k/engine/art/fonts/B612-BoldItalic.ttf -> fonts/B612-BoldItalic.ttf + static array(char*) art_paths = 0; + do_once for each_substring(ART,",",stem) array_push(art_paths, STRDUP(stem)); + char* pretty_folder = ""; + if( folder ) for( int i = 0; i < array_count(art_paths); ++i ) { + if( strbeg(folder, art_paths[i]) ) { pretty_folder = folder + strlen(art_paths[i]); break; } + } //} int size = 0; diff --git a/engine/split/v4k_math.c b/engine/split/v4k_math.c index 85ecbc1..bf23946 100644 --- a/engine/split/v4k_math.c +++ b/engine/split/v4k_math.c @@ -821,7 +821,7 @@ bool invert44(mat44 T, const mat44 M) { // !!! ok, i guess } vec4 transform444(const mat44, const vec4); -bool unproject44(vec3 *out, vec3 xyd, vec4 viewport, mat44 mvp) { +bool unproject44(vec3 *out, vec3 xyd, vec4 viewport, mat44 mvp) { // @fixme: this function is broken (verified by @zpl-zak) // xyd: usually x:mouse_x,y:window_height()-mouse_y,d:0=znear/1=zfar // src: https://www.khronos.org/opengl/wiki/GluProject_and_gluUnProject_code mat44 inv_mvp; diff --git a/engine/split/v4k_scene.c b/engine/split/v4k_scene.c index 3c2da04..86dd766 100644 --- a/engine/split/v4k_scene.c +++ b/engine/split/v4k_scene.c @@ -109,7 +109,7 @@ void camera_fov(camera_t *cam, float fov) { float DIMETRIC = 30.000f; float ISOMETRIC = 35.264f; - float aspect = window_width() / ((float)window_height()+!!window_height()); + float aspect = window_width() / ((float)window_height()+!window_height()); orthogonal(cam->proj, 45, aspect, -1000, 1000); // why -1000? // cam->yaw = 45; cam->pitch = -ISOMETRIC; diff --git a/engine/split/v4k_system.c b/engine/split/v4k_system.c index a3cb685..979feff 100644 --- a/engine/split/v4k_system.c +++ b/engine/split/v4k_system.c @@ -823,7 +823,7 @@ bool app_open_folder(const char *file) { #ifdef _WIN32 snprintf(buf, sizeof(buf), "start \"\" \"%s\"", file); #elif __APPLE__ - snprintf(buf, sizeof(buf), "%s \"%s\"", is_directory(file) ? "open" : "open --reveal", file); + snprintf(buf, sizeof(buf), "%s \"%s\"", file_directory(file) ? "open" : "open --reveal", file); #else snprintf(buf, sizeof(buf), "xdg-open \"%s\"", file); #endif diff --git a/engine/v4k b/engine/v4k index e63fd7a..e9dae6e 100644 --- a/engine/v4k +++ b/engine/v4k @@ -235686,8 +235686,9 @@ int dir_yield(dir *d, const char *pathfile, char *name, int namelen) { snprintf(name, namelen, "%s/*", pathfile); for( HANDLE h = FindFirstFileA(name, &fdata ); h != INVALID_HANDLE_VALUE; ok = (FindClose( h ), h = INVALID_HANDLE_VALUE, 1)) { for( int next = 1; next; next = FindNextFileA(h, &fdata) != 0 ) { - if( fdata.cFileName[0] == '.' ) continue; int is_dir = (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) > 0; + if( is_dir && fdata.cFileName[0] == '.' ) continue; + snprintf(name, namelen, "%s/%s%s", pathfile, fdata.cFileName, is_dir ? "/" : ""); struct stat st; if( !is_dir ) if(stat(name, &st) < 0) continue; // add @@ -235702,10 +235703,11 @@ int dir_yield(dir *d, const char *pathfile, char *name, int namelen) { snprintf(name, namelen, "%s/", pathfile); for( DIR *dir = opendir(name); dir; ok = (closedir(dir), dir = 0, 1)) { for( struct dirent *ep; (ep = readdir(dir)) != NULL; ) { - if( ep->d_name[0] == '.' ) continue; snprintf(name, namelen, "%s/%s", pathfile, ep->d_name); struct stat st; if( stat(name, &st) < 0 ) continue; - DIR *tmp = opendir(/*ep->d_*/name); int is_dir = !!tmp; if(tmp) closedir(tmp); + DIR *tmp = opendir(/*ep->d_*/name); int is_dir = !!tmp; if(tmp) closedir(tmp); // @todo:optimizeme (maybe use stat instead) + if( is_dir && ep->d_name[0] == '.' ) continue; + // add dir_entry de = { STRDUP(name), is_dir ? 0 : st.st_size, is_dir }; d->entry = (dir_entry*)REALLOC(d->entry, ++d->count * sizeof(dir_entry)); diff --git a/engine/v4k.c b/engine/v4k.c index 2440ecb..3cb40b3 100644 --- a/engine/v4k.c +++ b/engine/v4k.c @@ -4631,7 +4631,6 @@ int cook_jobs() { return clampi(num_jobs, 0, cook_disabled?0:max_jobs); } - void cook_config( const char *pathfile_to_cook_ini ) { // @todo: test run-from-"bin/" case on Linux. COOK_INI = pathfile_to_cook_ini; ASSERT( file_exist(COOK_INI) ); @@ -5188,36 +5187,30 @@ const char** file_list(const char *cwd, const char *masks) { } array_resize(list, 0);//array_free(list); - for each_substring(masks,";",it) { - int recurse = !!strstr(it, "**"); - #if is(win32) - char *glob = va("dir %s/b/o:n \"%s\\%s\" 2> NUL", recurse ? "/s":"", cwd, it); - #else // linux, osx - char *glob = va("find %s %s -name \"%s\" | sort", cwd, !recurse ? "-maxdepth 1":"-type f", it); - #endif - for( FILE *in = popen(glob, "r"); in; pclose(in), in = 0) { - char buf[1024], *line = buf; - while( fgets(buf, sizeof(buf), in) ) { - // clean up - if( strstr(line, arg0) ) line = buf + larg0; - if( !memcmp(line, "./", 2) ) line += 2; - int len = strlen(line); while( len > 0 && line[len-1] < 32 ) line[--len] = 0; - if( line[0] == '\0' ) continue; - // do not insert system folders/files - for(int i = 0; i < len; ++i ) if(line[i] == '\\') line[i] = '/'; - if( line[0] == '.' ) if( !strcmp(line,".git") || !strcmp(line,".vs") || !strcmp(line,".") || !strcmp(line,"..") ) continue; - if( strstr(line, "/.") ) continue; + dir *d = dir_open(cwd, "rb"); + if( d ) { + for( int i = 0; i < dir_count(d); ++i ) { + if( dir_file(d,i) ) { + // dir_name() should return full normalized paths "C:/prj/v4k/demos/art/fx/fxBloom.fs". should exclude system dirs as well + char *entry = dir_name(d,i); + char *fname = file_name(entry); + + int allowed = 0; + for each_substring(masks,";",mask) { + allowed |= strmatch(fname, mask); + } + if( !allowed ) continue; + + // if( strstr(fname, "/.") ) continue; // @fixme: still needed? useful? + // insert copy - #if is(win32) - char *copy = STRDUP(line); // full path already provided - #else - // while(line[0] == '/') ++line; - char *copy = STRDUP(va("%s%s", cwd, line)); // need to prepend path - #endif + char *copy = STRDUP(entry); array_push(list, copy); } } + dir_close(d); } + array_push(list, 0); // terminator return (const char**)list; } @@ -5754,12 +5747,14 @@ if( found && *found == 0 ) { base = file_name(pathfile); if(base[0] == '\0') return 0; // it's a dir folder = file_path(pathfile); - // make folder variable easier to read in logs: /home/rlyeh/prj/v4k/art/demos/audio/coin.wav -> demos/audio/coin.wav - // static int ART_LEN = 0; do_once ART_LEN = strlen(ART); - // if( !strncmp(folder, ART, ART_LEN) ) { - // folder += ART_LEN; - // } - char* pretty_folder = folder && strlen(folder) >= ART_LEN ? folder + ART_LEN : ""; + // ease folders reading by shortening them: /home/rlyeh/prj/v4k/art/demos/audio/coin.wav -> demos/audio/coin.wav + // or C:/prj/v4k/engine/art/fonts/B612-BoldItalic.ttf -> fonts/B612-BoldItalic.ttf + static array(char*) art_paths = 0; + do_once for each_substring(ART,",",stem) array_push(art_paths, STRDUP(stem)); + char* pretty_folder = ""; + if( folder ) for( int i = 0; i < array_count(art_paths); ++i ) { + if( strbeg(folder, art_paths[i]) ) { pretty_folder = folder + strlen(art_paths[i]); break; } + } //} int size = 0; @@ -9985,7 +9980,7 @@ bool invert44(mat44 T, const mat44 M) { // !!! ok, i guess } vec4 transform444(const mat44, const vec4); -bool unproject44(vec3 *out, vec3 xyd, vec4 viewport, mat44 mvp) { +bool unproject44(vec3 *out, vec3 xyd, vec4 viewport, mat44 mvp) { // @fixme: this function is broken (verified by @zpl-zak) // xyd: usually x:mouse_x,y:window_height()-mouse_y,d:0=znear/1=zfar // src: https://www.khronos.org/opengl/wiki/GluProject_and_gluUnProject_code mat44 inv_mvp; @@ -18449,7 +18444,7 @@ void camera_fov(camera_t *cam, float fov) { float DIMETRIC = 30.000f; float ISOMETRIC = 35.264f; - float aspect = window_width() / ((float)window_height()+!!window_height()); + float aspect = window_width() / ((float)window_height()+!window_height()); orthogonal(cam->proj, 45, aspect, -1000, 1000); // why -1000? // cam->yaw = 45; cam->pitch = -ISOMETRIC; @@ -20167,7 +20162,7 @@ bool app_open_folder(const char *file) { #ifdef _WIN32 snprintf(buf, sizeof(buf), "start \"\" \"%s\"", file); #elif __APPLE__ - snprintf(buf, sizeof(buf), "%s \"%s\"", is_directory(file) ? "open" : "open --reveal", file); + snprintf(buf, sizeof(buf), "%s \"%s\"", file_directory(file) ? "open" : "open --reveal", file); #else snprintf(buf, sizeof(buf), "xdg-open \"%s\"", file); #endif @@ -24981,6 +24976,14 @@ char *editor_path(const char *path) { } vec3 editor_pick(float mouse_x, float mouse_y) { +#if 0 + // unproject 2d coord as 3d coord + camera_t *camera = camera_get_active(); + vec3 out, xyd = vec3(mouse_x,window_height()-mouse_y,1); // usually x:mouse_x,y:window_height()-mouse_y,d:0=znear/1=zfar + mat44 mvp, model; identity44(model); multiply44x3(mvp, camera->proj, camera->view, model); + bool ok = unproject44(&out, xyd, vec4(0,0,window_width(),window_height()), mvp); + return out; +#else // unproject 2d coord as 3d coord camera_t *camera = camera_get_active(); float x = (2.0f * mouse_x) / window_width() - 1.0f; @@ -24994,6 +24997,7 @@ vec3 editor_pick(float mouse_x, float mouse_y) { vec4 eye = vec4(p.x, p.y, -1.0, 0.0); vec4 wld = norm4(transform444(inv_view, eye)); return vec3(wld.x, wld.y, wld.z); +#endif } int editor_ui_bits8(const char *label, uint8_t *enabled) { // @to deprecate diff --git a/engine/v4k.h b/engine/v4k.h index 78e11ec..e171346 100644 --- a/engine/v4k.h +++ b/engine/v4k.h @@ -824,7 +824,7 @@ API void (map_clear)(map* m); API char *cc4str(unsigned cc); API char *cc8str(uint64_t cc); -enum { ///- +enum { # define _(a,b,c,d,e) cc__##a, cc__##b, cc__##c, cc__##d, cc__##e cc__1 = '1', _(2,3,4,5,6),_(7,8,9,0,_), cc__ = ' ', cc__A = 'A', _(B,C,D,E,F),_(G,H,I,J,K),_(L,M,N,O,P),_(Q,R,S,T,U),_(V,W,X,Y,Z),