mirror of https://github.com/sm64pc/sm64pc.git
Add a `--configfile` CLI option
Usage: `--configfile yahoo.ini` will load up a file named yahoo.ini as the configuration file.
This commit is contained in:
parent
69ff11e459
commit
7bf7b34c57
|
@ -16,6 +16,7 @@
|
||||||
#include "game/game_init.h"
|
#include "game/game_init.h"
|
||||||
#include "game/ingame_menu.h"
|
#include "game/ingame_menu.h"
|
||||||
#include "game/options_menu.h"
|
#include "game/options_menu.h"
|
||||||
|
#include "pc/cliopts.h"
|
||||||
#include "pc/configfile.h"
|
#include "pc/configfile.h"
|
||||||
#include "pc/controller/controller_api.h"
|
#include "pc/controller/controller_api.h"
|
||||||
|
|
||||||
|
@ -424,7 +425,7 @@ void optmenu_toggle(void) {
|
||||||
newcam_init_settings(); // load bettercam settings from config vars
|
newcam_init_settings(); // load bettercam settings from config vars
|
||||||
#endif
|
#endif
|
||||||
controller_reconfigure(); // rebind using new config values
|
controller_reconfigure(); // rebind using new config values
|
||||||
configfile_save(CONFIG_FILE);
|
configfile_save(gCLIOpts.ConfigFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "cliopts.h"
|
#include "cliopts.h"
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
struct PCCLIOptions gCLIOpts;
|
struct PCCLIOptions gCLIOpts;
|
||||||
|
|
||||||
|
@ -8,6 +9,8 @@ void parse_cli_opts(int argc, char* argv[])
|
||||||
// Initialize options with false values.
|
// Initialize options with false values.
|
||||||
gCLIOpts.SkipIntro = 0;
|
gCLIOpts.SkipIntro = 0;
|
||||||
gCLIOpts.FullScreen = 0;
|
gCLIOpts.FullScreen = 0;
|
||||||
|
gCLIOpts.ConfigFile = malloc(31);
|
||||||
|
strncpy(gCLIOpts.ConfigFile, "sm64config.txt", strlen("sm64config.txt"));
|
||||||
|
|
||||||
// Scan arguments for options
|
// Scan arguments for options
|
||||||
if (argc > 1)
|
if (argc > 1)
|
||||||
|
@ -20,6 +23,19 @@ void parse_cli_opts(int argc, char* argv[])
|
||||||
|
|
||||||
if (strcmp(argv[i], "--fullscreen") == 0) // Open game in fullscreen
|
if (strcmp(argv[i], "--fullscreen") == 0) // Open game in fullscreen
|
||||||
gCLIOpts.FullScreen = 1;
|
gCLIOpts.FullScreen = 1;
|
||||||
|
|
||||||
|
if (strncmp(argv[i], "--configfile", strlen("--configfile")) == 0)
|
||||||
|
{
|
||||||
|
if (i+1 < argc)
|
||||||
|
{
|
||||||
|
if (strlen(argv[i]) > 30) {
|
||||||
|
fprintf(stderr, "Configuration file supplied has a name too long.\n");
|
||||||
|
} else {
|
||||||
|
memset(gCLIOpts.ConfigFile, 0, 30);
|
||||||
|
strncpy(gCLIOpts.ConfigFile, argv[i+1], strlen(argv[i+1]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,8 +3,6 @@
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#define CONFIG_FILE "sm64config.txt"
|
|
||||||
|
|
||||||
#define MAX_BINDS 3
|
#define MAX_BINDS 3
|
||||||
#define MAX_VOLUME 127
|
#define MAX_VOLUME 127
|
||||||
#define VOLUME_SHIFT 7
|
#define VOLUME_SHIFT 7
|
||||||
|
|
|
@ -92,7 +92,7 @@ void audio_shutdown(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void game_shutdown(void) {
|
void game_shutdown(void) {
|
||||||
configfile_save(CONFIG_FILE);
|
configfile_save(gCLIOpts.ConfigFile);;
|
||||||
controller_shutdown();
|
controller_shutdown();
|
||||||
audio_shutdown();
|
audio_shutdown();
|
||||||
gfx_shutdown();
|
gfx_shutdown();
|
||||||
|
@ -136,7 +136,7 @@ void main_func(void) {
|
||||||
main_pool_init(pool, pool + sizeof(pool) / sizeof(pool[0]));
|
main_pool_init(pool, pool + sizeof(pool) / sizeof(pool[0]));
|
||||||
gEffectsMemoryPool = mem_pool_init(0x4000, MEMORY_POOL_LEFT);
|
gEffectsMemoryPool = mem_pool_init(0x4000, MEMORY_POOL_LEFT);
|
||||||
|
|
||||||
configfile_load(CONFIG_FILE);
|
configfile_load(gCLIOpts.ConfigFile);
|
||||||
atexit(game_shutdown);
|
atexit(game_shutdown);
|
||||||
|
|
||||||
#ifdef TARGET_WEB
|
#ifdef TARGET_WEB
|
||||||
|
|
Loading…
Reference in New Issue