Skip to content

Commit

Permalink
print current directory when loading config.json
Browse files Browse the repository at this point in the history
  • Loading branch information
Gargaj committed May 20, 2019
1 parent fa8053b commit a0cf67b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@ For the OpenGL version (for any platform), at least OpenGL 4.1 is required.
On recent macOS, to allow sound input to be captured (for FFT textures to be generated), you need to: Open up System Preferences, click on Security & Privacy, click on the Privacy tab then click on the Microphone menu item. Make sure Bonzomatic.app is in the list and ticked.

## Configuration
Create a `config.json` and place it next to the executable with e.g. the following contents: (all fields are optional)
You can configure Bonzomatic by creating a `config.json` and placing it next to the binary executable you're planning to run in the working directory for the binary; Bonzomatic will helpfully print this directory out for you when you run it, and you can also pass a file (with absolute or relative path, whichever you want) to load any other file as `config.json`. This allows you to have multiple configurations for multiple situations.

The file can have the following contents: (all fields are optional)
``` javascript
{
"window":{ // default window size / state, if there's a setup dialog, it will override it
"width":1920,
"height":1080,
"fullscreen":true,
},
"font":{
"font":{ // all paths in the file are also relative to the binary, but again, can be absolute paths if that's more convenient
"file":"Input-Regular_(InputMono-Medium).ttf",
"size":16,
},
Expand Down
22 changes: 21 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
#include <string.h>
#include <assert.h>

#ifdef _WIN32
#include <direct.h>
#define getcwd _getcwd
#endif

#include "ShaderEditor.h"
#include "Renderer.h"
#include "FFT.h"
Expand Down Expand Up @@ -45,8 +50,23 @@ int main(int argc, const char *argv[])
{
Misc::PlatformStartup();

const char * configFile = "config.json";
if ( argc > 1 )
{
configFile = argv[ 1 ];
printf( "Loading config file '%s'...\n", configFile );
}
else
{
char configPath[ 256 ] = { 0 };
if ( getcwd( configPath, 255 ) )
{
printf( "Looking for config.json in '%s'...\n", configPath );
}
}

jsonxx::Object options;
FILE * fConf = fopen( (argc > 1) ? argv[1] : "config.json","rb");
FILE * fConf = fopen( configFile, "rb" );
if (fConf)
{
printf("Config file found, parsing...\n");
Expand Down

0 comments on commit a0cf67b

Please sign in to comment.