mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-25 21:45:12 +00:00
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
4 changed files with 20 additions and 5 deletions
|
@ -16,6 +16,7 @@
|
|||
#include "game/game_init.h"
|
||||
#include "game/ingame_menu.h"
|
||||
#include "game/options_menu.h"
|
||||
#include "pc/cliopts.h"
|
||||
#include "pc/configfile.h"
|
||||
#include "pc/controller/controller_api.h"
|
||||
|
||||
|
@ -424,7 +425,7 @@ void optmenu_toggle(void) {
|
|||
newcam_init_settings(); // load bettercam settings from config vars
|
||||
#endif
|
||||
controller_reconfigure(); // rebind using new config values
|
||||
configfile_save(CONFIG_FILE);
|
||||
configfile_save(gCLIOpts.ConfigFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "cliopts.h"
|
||||
#include <strings.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
struct PCCLIOptions gCLIOpts;
|
||||
|
||||
|
@ -8,6 +9,8 @@ void parse_cli_opts(int argc, char* argv[])
|
|||
// Initialize options with false values.
|
||||
gCLIOpts.SkipIntro = 0;
|
||||
gCLIOpts.FullScreen = 0;
|
||||
gCLIOpts.ConfigFile = malloc(31);
|
||||
strncpy(gCLIOpts.ConfigFile, "sm64config.txt", strlen("sm64config.txt"));
|
||||
|
||||
// Scan arguments for options
|
||||
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
|
||||
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>
|
||||
|
||||
#define CONFIG_FILE "sm64config.txt"
|
||||
|
||||
#define MAX_BINDS 3
|
||||
#define MAX_VOLUME 127
|
||||
#define VOLUME_SHIFT 7
|
||||
|
|
|
@ -92,7 +92,7 @@ void audio_shutdown(void) {
|
|||
}
|
||||
|
||||
void game_shutdown(void) {
|
||||
configfile_save(CONFIG_FILE);
|
||||
configfile_save(gCLIOpts.ConfigFile);;
|
||||
controller_shutdown();
|
||||
audio_shutdown();
|
||||
gfx_shutdown();
|
||||
|
@ -136,7 +136,7 @@ void main_func(void) {
|
|||
main_pool_init(pool, pool + sizeof(pool) / sizeof(pool[0]));
|
||||
gEffectsMemoryPool = mem_pool_init(0x4000, MEMORY_POOL_LEFT);
|
||||
|
||||
configfile_load(CONFIG_FILE);
|
||||
configfile_load(gCLIOpts.ConfigFile);
|
||||
atexit(game_shutdown);
|
||||
|
||||
#ifdef TARGET_WEB
|
||||
|
|
Loading…
Reference in a new issue