Better directory structure

This commit is contained in:
Steel Titanium 2019-09-08 01:29:09 -04:00
parent c6af108d8c
commit 8ee0a9309b
No known key found for this signature in database
GPG Key ID: 924BA411F18DFDBE
7 changed files with 101 additions and 43 deletions

View File

@ -129,6 +129,7 @@ char srb2home[256] = ".";
char srb2path[256] = ".";
boolean usehome = true;
const char *pandf = "%s" PATHSEP "%s";
static char addonsdir[MAX_WADPATH];
//
// EVENT HANDLING
@ -1038,7 +1039,6 @@ void D_SRB2Main(void)
// can't use sprintf since there is %u in savegamename
strcatbf(savegamename, srb2home, PATHSEP);
I_mkdir(srb2home, 0700);
#else
snprintf(srb2home, sizeof srb2home, "%s", userhome);
snprintf(downloaddir, sizeof downloaddir, "%s", userhome);
@ -1055,6 +1055,10 @@ void D_SRB2Main(void)
configfile[sizeof configfile - 1] = '\0';
}
// Create addons dir
snprintf(addonsdir, sizeof addonsdir, "%s%s%s", srb2home, PATHSEP, "addons");
I_mkdir(addonsdir, 0755);
// rand() needs seeded regardless of password
srand((unsigned int)time(NULL));

View File

@ -630,6 +630,8 @@ void D_RegisterClientCommands(void)
CV_RegisterVar(&cv_screenshot_folder);
CV_RegisterVar(&cv_screenshot_colorprofile);
CV_RegisterVar(&cv_moviemode);
CV_RegisterVar(&cv_movie_option);
CV_RegisterVar(&cv_movie_folder);
// PNG variables
CV_RegisterVar(&cv_zlib_level);
CV_RegisterVar(&cv_zlib_memory);

View File

@ -1353,36 +1353,39 @@ static menuitem_t OP_ScreenshotOptionsMenu[] =
{
{IT_HEADER, NULL, "General", NULL, 0},
{IT_STRING|IT_CVAR, NULL, "Use color profile", &cv_screenshot_colorprofile, 6},
{IT_STRING|IT_CVAR, NULL, "Storage Location", &cv_screenshot_option, 11},
{IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Custom Folder", &cv_screenshot_folder, 16},
{IT_HEADER, NULL, "Screenshots (F8)", NULL, 30},
{IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memory, 36},
{IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_level, 41},
{IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategy, 46},
{IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bits, 51},
{IT_HEADER, NULL, "Screenshots (F8)", NULL, 16},
{IT_STRING|IT_CVAR, NULL, "Storage Location", &cv_screenshot_option, 22},
{IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Custom Folder", &cv_screenshot_folder, 27},
{IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memory, 42},
{IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_level, 47},
{IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategy, 52},
{IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bits, 57},
{IT_HEADER, NULL, "Movie Mode (F9)", NULL, 60},
{IT_STRING|IT_CVAR, NULL, "Capture Mode", &cv_moviemode, 66},
{IT_HEADER, NULL, "Movie Mode (F9)", NULL, 64},
{IT_STRING|IT_CVAR, NULL, "Storage Location", &cv_movie_option, 70},
{IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Custom Folder", &cv_movie_folder, 75},
{IT_STRING|IT_CVAR, NULL, "Capture Mode", &cv_moviemode, 90},
{IT_STRING|IT_CVAR, NULL, "Region Optimizing", &cv_gif_optimize, 71},
{IT_STRING|IT_CVAR, NULL, "Downscaling", &cv_gif_downscale, 76},
{IT_STRING|IT_CVAR, NULL, "Region Optimizing", &cv_gif_optimize, 95},
{IT_STRING|IT_CVAR, NULL, "Downscaling", &cv_gif_downscale, 100},
{IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memorya, 71},
{IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_levela, 76},
{IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategya, 81},
{IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bitsa, 86},
{IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memorya, 95},
{IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_levela, 100},
{IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategya, 105},
{IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bitsa, 110},
};
enum
{
op_screenshot_colorprofile = 1,
op_screenshot_folder = 3,
op_screenshot_capture = 10,
op_screenshot_gif_start = 11,
op_screenshot_gif_end = 12,
op_screenshot_apng_start = 13,
op_screenshot_apng_end = 16,
op_screenshot_folder = 4,
op_movie_folder = 11,
op_screenshot_capture = 12,
op_screenshot_gif_start = 13,
op_screenshot_gif_end = 14,
op_screenshot_apng_start = 15,
op_screenshot_apng_end = 18,
};
static menuitem_t OP_EraseDataMenu[] =
@ -2200,6 +2203,12 @@ void Addons_option_Onchange(void)
(cv_addons_option.value == 3 ? IT_CVAR|IT_STRING|IT_CV_STRING : IT_DISABLED);
}
void Moviemode_option_Onchange(void)
{
OP_ScreenshotOptionsMenu[op_movie_folder].status =
(cv_movie_option.value == 3 ? IT_CVAR|IT_STRING|IT_CV_STRING : IT_DISABLED);
}
// ==========================================================================
// END ORGANIZATION STUFF.
// ==========================================================================

View File

@ -397,6 +397,9 @@ void Screenshot_option_Onchange(void);
// Addons menu updating
void Addons_option_Onchange(void);
// Moviemode menu updating
void Moviemode_option_Onchange(void);
// These defines make it a little easier to make menus
#define DEFAULTMENUSTYLE(id, header, source, prev, x, y)\
{\

View File

@ -108,6 +108,9 @@ consvar_t cv_screenshot_colorprofile = {"screenshot_colorprofile", "Yes", CV_SAV
static CV_PossibleValue_t moviemode_cons_t[] = {{MM_GIF, "GIF"}, {MM_APNG, "aPNG"}, {MM_SCREENSHOT, "Screenshots"}, {0, NULL}};
consvar_t cv_moviemode = {"moviemode_mode", "GIF", CV_SAVE|CV_CALL, moviemode_cons_t, Moviemode_mode_Onchange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_movie_option = {"movie_option", "Default", CV_SAVE|CV_CALL, screenshot_cons_t, Moviemode_option_Onchange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_movie_folder = {"movie_folder", "", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t zlib_mem_level_t[] = {
{1, "(Min Memory) 1"},
{2, "2"}, {3, "3"}, {4, "4"}, {5, "5"}, {6, "6"}, {7, "7"},
@ -1124,19 +1127,25 @@ static inline moviemode_t M_StartMovieGIF(const char *pathname)
void M_StartMovie(void)
{
#if NUMSCREENS > 2
const char *pathname = ".";
char pathname[MAX_WADPATH];
if (moviemode)
return;
if (cv_screenshot_option.value == 0)
pathname = usehome ? srb2home : srb2path;
else if (cv_screenshot_option.value == 1)
pathname = srb2home;
else if (cv_screenshot_option.value == 2)
pathname = srb2path;
else if (cv_screenshot_option.value == 3 && *cv_screenshot_folder.string != '\0')
pathname = cv_screenshot_folder.string;
if (cv_movie_option.value == 0)
strcpy(pathname, usehome ? srb2home : srb2path);
else if (cv_movie_option.value == 1)
strcpy(pathname, srb2home);
else if (cv_movie_option.value == 2)
strcpy(pathname, srb2path);
else if (cv_movie_option.value == 3 && *cv_movie_folder.string != '\0')
strcpy(pathname, cv_screenshot_folder.string);
if (cv_movie_option.value != 3)
{
strcat(pathname, PATHSEP"movies"PATHSEP);
I_mkdir(pathname, 0755);
}
if (rendermode == render_none)
I_Error("Can't make a movie without a render system\n");
@ -1474,7 +1483,8 @@ void M_ScreenShot(void)
void M_DoScreenShot(void)
{
#if NUMSCREENS > 2
const char *freename = NULL, *pathname = ".";
const char *freename = NULL;
char pathname[MAX_WADPATH];
boolean ret = false;
UINT8 *linear = NULL;
@ -1486,13 +1496,19 @@ void M_DoScreenShot(void)
return;
if (cv_screenshot_option.value == 0)
pathname = usehome ? srb2home : srb2path;
strcpy(pathname, usehome ? srb2home : srb2path);
else if (cv_screenshot_option.value == 1)
pathname = srb2home;
strcpy(pathname, srb2home);
else if (cv_screenshot_option.value == 2)
pathname = srb2path;
strcpy(pathname, srb2path);
else if (cv_screenshot_option.value == 3 && *cv_screenshot_folder.string != '\0')
pathname = cv_screenshot_folder.string;
strcpy(pathname, cv_screenshot_folder.string);
if (cv_screenshot_option.value != 3)
{
strcat(pathname, PATHSEP"screenshots"PATHSEP);
I_mkdir(pathname, 0755);
}
#ifdef USE_PNG
freename = Newsnapshotfile(pathname,"png");

View File

@ -30,7 +30,7 @@ typedef enum {
extern moviemode_t moviemode;
extern consvar_t cv_screenshot_option, cv_screenshot_folder, cv_screenshot_colorprofile;
extern consvar_t cv_moviemode;
extern consvar_t cv_moviemode, cv_movie_folder, cv_movie_option;
extern consvar_t cv_zlib_memory, cv_zlib_level, cv_zlib_strategy, cv_zlib_window_bits;
extern consvar_t cv_zlib_memorya, cv_zlib_levela, cv_zlib_strategya, cv_zlib_window_bitsa;
extern consvar_t cv_apng_delay;

View File

@ -26,6 +26,8 @@
#include <unistd.h>
#endif
#include "time.h" // For log timestamps
#ifdef HAVE_SDL
#ifdef HAVE_TTF
@ -114,6 +116,7 @@ int main(int argc, char **argv)
#endif
{
const char *logdir = NULL;
char logfile[MAX_WADPATH];
myargc = argc;
myargv = argv; /// \todo pull out path to exe from this string
@ -125,15 +128,35 @@ int main(int argc, char **argv)
#endif
#endif
logdir = D_Home();
#ifdef LOGMESSAGES
if (!M_CheckParm("-nolog"))
{
logdir = D_Home();
time_t my_time;
struct tm * timeinfo;
char buf[26];
my_time = time(NULL);
timeinfo = localtime(&my_time);
strftime(buf, 26, "%Y-%m-%d %H-%M-%S", timeinfo);
strcpy(logfile, va("log-%s.txt", buf));
#ifdef DEFAULTDIR
if (logdir)
logstream = fopen(va("%s/"DEFAULTDIR"/log.txt",logdir), "wt");
else
if (logdir)
{
// Create dirs here because D_SRB2Main() is too late.
I_mkdir(va("%s%s"DEFAULTDIR, logdir, PATHSEP), 0755);
I_mkdir(va("%s%s"DEFAULTDIR"%slogs",logdir, PATHSEP, PATHSEP), 0755);
logstream = fopen(va("%s%s"DEFAULTDIR"%slogs%s%s",logdir, PATHSEP, PATHSEP, PATHSEP, logfile), "wt");
}
else
#endif
logstream = fopen("./log.txt", "wt");
{
I_mkdir("."PATHSEP"logs"PATHSEP, 0755);
logstream = fopen(va("."PATHSEP"logs"PATHSEP"%s", logfile), "wt");
}
}
#endif
//I_OutputMsg("I_StartupSystem() ...\n");
@ -161,6 +184,7 @@ int main(int argc, char **argv)
CONS_Printf("Setting up SRB2...\n");
D_SRB2Main();
CONS_Printf("Entering main game loop...\n");
CONS_Printf("%s\n", logfile);
// never return
D_SRB2Loop();