17#include "background.h"
29#define conf_loadInt( env, n, i ) \
31 nlua_getenv( naevL, env, n ); \
32 if ( lua_isnumber( naevL, -1 ) ) { \
33 i = (int)lua_tonumber( naevL, -1 ); \
35 lua_pop( naevL, 1 ); \
38#define conf_loadFloat( env, n, f ) \
40 nlua_getenv( naevL, env, n ); \
41 if ( lua_isnumber( naevL, -1 ) ) { \
42 f = (double)lua_tonumber( naevL, -1 ); \
44 lua_pop( naevL, 1 ); \
47#define conf_loadBool( env, n, b ) \
49 nlua_getenv( naevL, env, n ); \
50 if ( lua_isnumber( naevL, -1 ) ) \
51 b = ( lua_tonumber( naevL, -1 ) != 0. ); \
52 else if ( !lua_isnil( naevL, -1 ) ) \
53 b = lua_toboolean( naevL, -1 ); \
54 lua_pop( naevL, 1 ); \
57#define conf_loadString( env, n, s ) \
59 nlua_getenv( naevL, env, n ); \
60 if ( lua_isstring( naevL, -1 ) ) { \
62 s = strdup( lua_tostring( naevL, -1 ) ); \
64 lua_pop( naevL, 1 ); \
78extern int indjoystick;
79extern char* namjoystick;
84static void print_usage(
void );
89static void print_usage(
void )
91 LOG( _(
"Usage: %s [OPTIONS] [DATA]" ), env.argv0 );
92 LOG(_(
"Options are:"));
93 LOG(_(
" -f, --fullscreen activate fullscreen"));
94 LOG(_(
" -F n, --fps n limit frames per second to n"));
95 LOG(_(
" -V, --vsync enable vsync"));
96 LOG(_(
" -W n set width to n"));
97 LOG(_(
" -H n set height to n"));
98 LOG(_(
" -j n, --joystick n use joystick n"));
99 LOG(_(
" -J s, --Joystick s use joystick whose name contains s"));
100 LOG(_(
" -M, --mute disables sound"));
101 LOG(_(
" -S, --sound forces sound"));
102 LOG(_(
" -m f, --mvol f sets the music volume to f"));
103 LOG(_(
" -s f, --svol f sets the sound volume to f"));
104 LOG(_(
" -d, --datapath adds a new datapath to be mounted (i.e., appends it to the search path for game assets)"));
105 LOG(_(
" -X, --scale defines the scale factor"));
107 LOG(_(
" --devmode enables dev mode perks like the editors"));
109 LOG(_(
" -h, --help display this message and exit"));
110 LOG(_(
" -v, --version print the version and exit"));
116void conf_setDefaults (
void)
158 conf_setGameplayDefaults();
161 conf_setAudioDefaults();
164 conf_setVideoDefaults();
181void conf_setGameplayDefaults (
void)
199void conf_setAudioDefaults (
void)
202 conf.
al_efx = USE_EFX_DEFAULT;
203 conf.
nosound = MUTE_SOUND_DEFAULT;
204 conf.
sound = SOUND_VOLUME_DEFAULT;
205 conf.
music = MUSIC_VOLUME_DEFAULT;
212void conf_setVideoDefaults (
void)
215 SDL_DisplayMode resolution;
219 if (SDL_GetCurrentDisplayMode( 0, &resolution ) == 0) {
221 w = RESOLUTION_W_DEFAULT;
222 h = RESOLUTION_H_DEFAULT;
225 if ((resolution.w <= w) || (resolution.h <= h)) {
228 f = FULLSCREEN_DEFAULT;
237 conf.
fsaa = FSAA_DEFAULT;
238 conf.
vsync = VSYNC_DEFAULT;
246 conf.
nebu_scale = NEBULA_SCALE_FACTOR_DEFAULT;
262 conf.
fps_max = FPS_MAX_DEFAULT;
271void conf_cleanup (
void)
279void conf_loadConfigPath(
void )
281 const char *file =
"datapath.lua";
286 nlua_env lEnv = nlua_newEnv();
287 if ( nlua_dofileenv( lEnv, file ) == 0 )
288 conf_loadString( lEnv,
"datapath", conf.
datapath );
290 nlua_freeEnv( lEnv );
296int conf_loadConfig (
const char* file )
299 const char *str, *mod;
312 nlua_env lEnv = nlua_newEnv();
313 if (nlua_dofileenv( lEnv, file ) == 0) {
316 conf_loadString( lEnv,
"data", conf.
ndata );
319 conf_loadString( lEnv,
"language", conf.
language );
322 conf_loadInt( lEnv,
"fsaa", conf.
fsaa );
323 conf_loadBool( lEnv,
"vsync", conf.
vsync );
327 conf_loadInt( lEnv,
"width", w );
328 conf_loadInt( lEnv,
"height", h );
337 conf_loadFloat( lEnv,
"scalefactor", conf.
scalefactor );
338 conf_loadFloat( lEnv,
"nebu_scale", conf.
nebu_scale );
339 conf_loadBool( lEnv,
"fullscreen", conf.
fullscreen );
340 conf_loadBool( lEnv,
"modesetting", conf.
modesetting );
341 conf_loadBool( lEnv,
"notresizable", conf.
notresizable );
342 conf_loadBool( lEnv,
"borderless", conf.
borderless );
343 conf_loadBool( lEnv,
"minimize", conf.
minimize );
344 conf_loadBool( lEnv,
"colorblind", conf.
colorblind );
345 conf_loadBool( lEnv,
"healthbars", conf.
healthbars );
357 conf_loadBool( lEnv,
"showfps", conf.
fps_show );
358 conf_loadInt( lEnv,
"maxfps", conf.
fps_max );
361 conf_loadBool( lEnv,
"showpause", conf.
pause_show );
364 conf_loadBool( lEnv,
"al_efx", conf.
al_efx );
365 conf_loadBool( lEnv,
"nosound", conf.
nosound );
366 conf_loadFloat( lEnv,
"sound", conf.
sound );
367 conf_loadFloat( lEnv,
"music", conf.
music );
368 conf_loadFloat( lEnv,
"engine_vol", conf.
engine_vol );
371 nlua_getenv( naevL, lEnv,
"joystick" );
372 if (lua_isnumber(naevL, -1))
374 else if (lua_isstring(naevL, -1))
379 conf_loadInt( lEnv,
"mesg_visible", conf.
mesg_visible );
384 conf_loadBool( lEnv,
"big_icons", conf.
big_icons );
385 conf_loadBool( lEnv,
"always_radar", conf.
always_radar );
388 conf_loadInt( lEnv,
"repeat_delay", conf.
repeat_delay );
389 conf_loadInt( lEnv,
"repeat_freq", conf.
repeat_freq );
392 conf_loadBool( lEnv,
"zoom_manual", conf.
zoom_manual );
393 conf_loadFloat( lEnv,
"zoom_far", conf.
zoom_far );
394 conf_loadFloat( lEnv,
"zoom_near", conf.
zoom_near );
395 conf_loadFloat( lEnv,
"zoom_speed", conf.
zoom_speed );
396 conf_loadFloat( lEnv,
"zoom_stars", conf.
zoom_stars );
405 conf_loadString( lEnv,
"difficulty", conf.
difficulty );
410 conf_loadInt( lEnv,
"doubletap_sensitivity", conf.
doubletap_sens );
411 conf_loadBool( lEnv,
"mouse_fly", conf.
mouse_fly );
412 conf_loadInt( lEnv,
"mouse_thrust", conf.
mouse_thrust );
416 conf_loadBool( lEnv,
"devmode", conf.
devmode );
417 conf_loadBool( lEnv,
"devautosave", conf.
devautosave );
418 conf_loadBool( lEnv,
"lua_enet", conf.
lua_enet );
419 conf_loadBool( lEnv,
"lua_repl", conf.
lua_repl );
420 conf_loadBool( lEnv,
"conf_nosave", conf.
nosave );
421 conf_loadString( lEnv,
"lastversion", conf.
lastversion );
423 conf_loadInt( lEnv,
"last_played", conf.
last_played );
426 conf_loadBool( lEnv,
"fpu_except", conf.
fpu_except );
429 conf_loadString( lEnv,
"dev_save_sys", conf.
dev_save_sys );
430 conf_loadString( lEnv,
"dev_save_map", conf.
dev_save_map );
431 conf_loadString( lEnv,
"dev_save_spob", conf.
dev_save_spob );
439 if (lua_isstring(naevL,-1)) {
440 str = lua_tostring(naevL,-1);
441 if (strcmp(str,
"none")==0) {
443 KEYBIND_NULL, SDLK_UNKNOWN, NMOD_NONE );
446 else if (lua_istable(naevL, -1)) {
448 lua_pushstring(naevL,
"type");
449 lua_gettable(naevL, -2);
450 if (lua_isstring(naevL, -1))
451 str = lua_tostring(naevL, -1);
452 else if (lua_isnil(naevL, -1)) {
453 WARN(_(
"Found keybind with no type field!"));
457 WARN(_(
"Found keybind with invalid type field!"));
463 lua_pushstring(naevL,
"key");
464 lua_gettable(naevL, -2);
465 t = lua_type(naevL, -1);
466 if (t == LUA_TNUMBER)
467 key = (int)lua_tonumber(naevL, -1);
468 else if (t == LUA_TSTRING)
470 else if (t == LUA_TNIL) {
471 WARN(_(
"Found keybind with no key field!"));
475 WARN(_(
"Found keybind with invalid key field!"));
481 lua_pushstring(naevL,
"mod");
482 lua_gettable(naevL, -2);
483 if (lua_isstring(naevL, -1))
484 mod = lua_tostring(naevL, -1);
491 if (strcmp(str,
"null")==0) type = KEYBIND_NULL;
492 else if (strcmp(str,
"keyboard")==0) type = KEYBIND_KEYBOARD;
493 else if (strcmp(str,
"jaxispos")==0) type = KEYBIND_JAXISPOS;
494 else if (strcmp(str,
"jaxisneg")==0) type = KEYBIND_JAXISNEG;
495 else if (strcmp(str,
"jbutton")==0) type = KEYBIND_JBUTTON;
496 else if (strcmp(str,
"jhat_up")==0) type = KEYBIND_JHAT_UP;
497 else if (strcmp(str,
"jhat_down")==0) type = KEYBIND_JHAT_DOWN;
498 else if (strcmp(str,
"jhat_left")==0) type = KEYBIND_JHAT_LEFT;
499 else if (strcmp(str,
"jhat_right")==0) type = KEYBIND_JHAT_RIGHT;
501 WARN(_(
"Unknown keybinding of type %s"), str);
506 if ((key == SDLK_UNKNOWN) && (type == KEYBIND_KEYBOARD)) {
507 WARN(_(
"Keybind for '%s' is invalid"),
keybind_info[i][0]);
513 if (strcmp(mod,
"ctrl")==0) m = NMOD_CTRL;
514 else if (strcmp(mod,
"shift")==0) m = NMOD_SHIFT;
515 else if (strcmp(mod,
"alt")==0) m = NMOD_ALT;
516 else if (strcmp(mod,
"meta")==0) m = NMOD_META;
517 else if (strcmp(mod,
"any")==0) m = NMOD_ANY;
518 else if (strcmp(mod,
"none")==0) m = NMOD_NONE;
520 WARN(_(
"Unknown keybinding mod of type %s"), mod);
531 WARN(_(
"Malformed keybind for '%s' in '%s'."),
keybind_info[i][0], file);
538 WARN(_(
"Config file '%s' has invalid syntax:"), file );
539 WARN(
" %s", lua_tostring(naevL,-1));
540 nlua_freeEnv( lEnv );
545 nlua_freeEnv( lEnv );
552void conf_parseCLI(
int argc,
char** argv )
554 static struct option long_options[] = {
555 {
"datapath", required_argument, 0,
'd' },
556 {
"fullscreen", no_argument, 0,
'f' },
557 {
"fps", required_argument, 0,
'F' },
558 {
"vsync", no_argument, 0,
'V' },
559 {
"joystick", required_argument, 0,
'j' },
560 {
"Joystick", required_argument, 0,
'J' },
561 {
"width", required_argument, 0,
'W' },
562 {
"height", required_argument, 0,
'H' },
563 {
"mute", no_argument, 0,
'M' },
564 {
"sound", no_argument, 0,
'S' },
565 {
"mvol", required_argument, 0,
'm' },
566 {
"svol", required_argument, 0,
's' },
567 {
"scale", required_argument, 0,
'X' },
569 {
"devmode", no_argument, 0,
'D' },
571 {
"help", no_argument, 0,
'h' },
572 {
"version", no_argument, 0,
'v' },
574 int option_index = 1;
582 while ((
c = getopt_long(argc, argv,
583 "fF:Vd:j:J:W:H:MSm:s:X:Nhv",
584 long_options, &option_index)) != -1) {
587 PHYSFS_mount( optarg, NULL, 1 );
605 conf.
width = atoi(optarg);
609 conf.
height = atoi(optarg);
619 conf.
music = atof(optarg);
622 conf.
sound = atof(optarg);
634 LOG(_(
"Enabling developer mode."));
650 conf.
ndata = strdup( argv[ optind ] );
662static size_t quoteLuaString(
char *str,
size_t size,
const char *text)
684 while ((ch = u8_nextchar( text, &i ))) {
687 case '#': slashescape =
'a';
break;
688 case '\b': slashescape =
'b';
break;
689 case '\f': slashescape =
'f';
break;
690 case '\n': slashescape =
'n';
break;
691 case '\r': slashescape =
'r';
break;
692 case '\t': slashescape =
't';
break;
693 case '\v': slashescape =
'v';
break;
694 case '\\': slashescape =
'\\';
break;
695 case '\"': slashescape =
'\"';
break;
696 case '\'': slashescape =
'\'';
break;
698 default: slashescape = 0;
break;
700 if (slashescape != 0) {
706 str[count++] = slashescape;
714 count += u8_toutf8( &str[count], size-count, &ch, 1 );
732#define conf_saveComment(t) \
733pos += scnprintf(&buf[pos], sizeof(buf)-pos, "-- %s\n", t);
735#define conf_saveEmptyLine() \
736if (sizeof(buf) != pos) \
739#define conf_saveInt(n,i) \
740pos += scnprintf(&buf[pos], sizeof(buf)-pos, "%s = %d\n", n, i);
742#define conf_saveULong(n,i) \
743pos += scnprintf(&buf[pos], sizeof(buf)-pos, "%s = %lu\n", n, i);
745#define conf_saveFloat(n,f) \
746pos += scnprintf(&buf[pos], sizeof(buf)-pos, "%s = %f\n", n, f);
748#define conf_saveBool(n,b) \
750 pos += scnprintf(&buf[pos], sizeof(buf)-pos, "%s = true\n", n); \
752 pos += scnprintf(&buf[pos], sizeof(buf)-pos, "%s = false\n", n);
754#define conf_saveString(n,s) \
755pos += scnprintf(&buf[pos], sizeof(buf)-pos, "%s = ", n); \
756pos += quoteLuaString(&buf[pos], sizeof(buf)-pos, s); \
757if (sizeof(buf) != pos) \
760#define GENERATED_START_COMMENT "START GENERATED SECTION"
761#define GENERATED_END_COMMENT "END GENERATED SECTION"
766int conf_saveConfig (
const char* file )
769 const char *oldfooter;
776 const char *
typename;
791 const char *tmp =
strnstr(old,
"-- "GENERATED_START_COMMENT
"\n", oldsize);
794 pos =
MIN(
sizeof(buf), (
size_t)(tmp - old));
795 memcpy(buf, old, pos);
798 tmp =
strnstr(tmp,
"-- "GENERATED_END_COMMENT
"\n", oldsize-pos);
801 oldfooter = tmp + strlen(
"-- "GENERATED_END_COMMENT
"\n");
802 oldsize -= (oldfooter - old);
814 conf_saveComment(_(
"Naev configuration file"));
815 conf_saveEmptyLine();
820 WARN(_(
"Not saving configuration."));
825 conf_saveComment(GENERATED_START_COMMENT);
826 conf_saveComment(_(
"The contents of this section will be rewritten by Naev!"));
827 conf_saveEmptyLine();
830 conf_saveComment(_(
"The location of Naev's data pack, usually called 'ndata'"));
831 conf_saveString(
"data",conf.
ndata);
832 conf_saveEmptyLine();
835 conf_saveComment(_(
"Language to use. Set to the two character identifier to the language (e.g., \"en\" for English), and nil for autodetect."));
836 conf_saveString(
"language",conf.
language);
837 conf_saveEmptyLine();
840 conf_saveComment(_(
"Global difficulty to set the game to. Can be overwritten by saved game settings. Has to match one of the difficulties defined in \"difficulty.xml\" in the data files."));
842 conf_saveComment(
"difficulty = nil");
845 conf_saveString(
"difficulty",conf.
difficulty);
847 conf_saveEmptyLine();
850 conf_saveComment(_(
"The factor to use in Full-Scene Anti-Aliasing"));
851 conf_saveComment(_(
"Anything lower than 2 will simply disable FSAA"));
852 conf_saveInt(
"fsaa",conf.
fsaa);
853 conf_saveEmptyLine();
855 conf_saveComment(_(
"Synchronize framebuffer updates with the vertical blanking interval"));
856 conf_saveBool(
"vsync",conf.
vsync);
857 conf_saveEmptyLine();
860 conf_saveComment(_(
"The window size or screen resolution"));
861 conf_saveComment(_(
"Set both of these to 0 to make Naev try the desktop resolution"));
863 conf_saveInt(
"width",conf.
width);
864 conf_saveInt(
"height",conf.
height);
866 conf_saveInt(
"width",0);
867 conf_saveInt(
"height",0);
869 conf_saveEmptyLine();
871 conf_saveComment(_(
"Factor used to divide the above resolution with"));
872 conf_saveComment(_(
"This is used to lower the rendering resolution, and scale to the above"));
874 conf_saveEmptyLine();
876 conf_saveComment(_(
"Scale factor for rendered nebula backgrounds."));
877 conf_saveComment(_(
"Larger values can save time but lead to a blurrier appearance."));
879 conf_saveEmptyLine();
881 conf_saveComment(_(
"Run Naev in full-screen mode"));
883 conf_saveEmptyLine();
885 conf_saveComment(_(
"Use video modesetting when fullscreen is enabled"));
887 conf_saveEmptyLine();
889 conf_saveComment(_(
"Disable allowing resizing the window."));
891 conf_saveEmptyLine();
893 conf_saveComment(_(
"Disable window decorations. Use with care and know the keyboard controls to quit and toggle fullscreen."));
895 conf_saveEmptyLine();
897 conf_saveComment(_(
"Minimize the game on focus loss."));
898 conf_saveBool(
"minimize",conf.
minimize);
899 conf_saveEmptyLine();
901 conf_saveComment(_(
"Enables colourblind mode. Good for simulating colourblindness."));
903 conf_saveEmptyLine();
905 conf_saveComment(_(
"Enable health bars. These show hostility/friendliness and health of pilots on screen."));
907 conf_saveEmptyLine();
909 conf_saveComment(_(
"Background brightness. 1 is normal brightness while setting it to 0 would make the backgrounds pitch black."));
911 conf_saveEmptyLine();
913 conf_saveComment(_(
"Nebula non-uniformity. 1 is normal nebula while setting it to 0 would make the nebula a solid colour."));
915 conf_saveEmptyLine();
917 conf_saveComment(_(
"Controls the intensity to which the screen fades when jumping. 1.0 would be pure white, while 0.0 would be pure black."));
919 conf_saveEmptyLine();
921 conf_saveComment(_(
"Gamma correction parameter. A value of 1 disables it (no curve)."))
922 conf_saveFloat("gamma_correction",conf.gamma_correction);
923 conf_saveEmptyLine();
925 conf_saveComment(_("Expensive high quality shaders for the background. Defaults to false."))
926 conf_saveBool("background_fancy",conf.background_fancy);
927 conf_saveEmptyLine();
930 conf_saveComment(_("Display a frame rate counter"));
931 conf_saveBool("showfps",conf.fps_show);
932 conf_saveEmptyLine();
934 conf_saveComment(_("Limit the rendering frame rate"));
935 conf_saveInt("maxfps",conf.fps_max);
936 conf_saveEmptyLine();
939 conf_saveComment(_("Show 'PAUSED' on screen while
paused"));
940 conf_saveBool("showpause",conf.pause_show);
941 conf_saveEmptyLine();
944 conf_saveComment(_("Enables EFX extension for OpenAL backend."));
945 conf_saveBool("al_efx",conf.al_efx);
946 conf_saveEmptyLine();
948 conf_saveComment(_("Disable all sound"));
949 conf_saveBool("nosound",conf.nosound);
950 conf_saveEmptyLine();
952 conf_saveComment(_("Volume of sound effects and music, between 0.0 and 1.0"));
955 conf_saveComment(_("Relative engine sound volume. Should be between 0.0 and 1.0"));
956 conf_saveFloat("engine_vol", conf.engine_vol);
957 conf_saveEmptyLine();
960 conf_saveComment(_("The name or numeric index of the
joystick to use"));
961 conf_saveComment(_("Setting this to nil disables the
joystick support"));
962 if (conf.joystick_nam != NULL) {
969 conf_saveString(
"joystick",NULL);
971 conf_saveEmptyLine();
974 conf_saveComment(_(
"Number of lines visible in the comm window."));
976 conf_saveComment(_(
"Opacity fraction (0-1) for the overlay map."));
978 conf_saveComment(_(
"Use bigger icons in the outfit, shipyard, and other lists."));
979 conf_saveBool(
"big_icons", conf.
big_icons);
980 conf_saveComment(_(
"Always show the radar and don't hide it when the overlay is active."));
982 conf_saveEmptyLine();
985 conf_saveComment(_(
"Delay in ms before starting to repeat (0 disables)"));
987 conf_saveComment(_(
"Delay in ms between repeats once it starts to repeat"));
989 conf_saveEmptyLine();
992 conf_saveComment(_(
"Minimum and maximum zoom factor to use in-game"));
993 conf_saveComment(_(
"At 1.0, no sprites are scaled"));
994 conf_saveComment(_(
"zoom_far should be less then zoom_near"));
996 conf_saveFloat(
"zoom_far",conf.
zoom_far);
997 conf_saveFloat(
"zoom_near",conf.
zoom_near);
998 conf_saveEmptyLine();
1000 conf_saveComment(_(
"Zooming speed in factor increments per second"));
1001 conf_saveFloat(
"zoom_speed",conf.
zoom_speed);
1002 conf_saveEmptyLine();
1004 conf_saveComment(_(
"Zooming modulation factor for the starry background"));
1005 conf_saveFloat(
"zoom_stars",conf.
zoom_stars);
1006 conf_saveEmptyLine();
1009 conf_saveComment(_(
"Font sizes (in pixels) for Naev"));
1010 conf_saveComment(_(
"Warning, setting to other than the default can cause visual glitches!"));
1011 pos +=
scnprintf(&buf[pos],
sizeof(buf)-pos, _(
"-- Console default: %d\n"), FONT_SIZE_CONSOLE_DEFAULT);
1013 pos +=
scnprintf(&buf[pos],
sizeof(buf)-pos, _(
"-- Intro default: %d\n"), FONT_SIZE_INTRO_DEFAULT);
1015 pos +=
scnprintf(&buf[pos],
sizeof(buf)-pos, _(
"-- Default size: %d\n"), FONT_SIZE_DEF_DEFAULT);
1017 pos +=
scnprintf(&buf[pos],
sizeof(buf)-pos, _(
"-- Small size: %d\n"), FONT_SIZE_SMALL_DEFAULT);
1021 conf_saveComment(_(
"Sets the velocity (px/s) to compress up to when time compression is enabled."));
1023 conf_saveEmptyLine();
1025 conf_saveComment(_(
"Sets the multiplier to compress up to when time compression is enabled."));
1027 conf_saveEmptyLine();
1029 conf_saveComment(_(
"Redirects log and error output to files"));
1031 conf_saveEmptyLine();
1033 conf_saveComment(_(
"Enables compression on saved games"));
1035 conf_saveEmptyLine();
1037 conf_saveComment(_(
"Doubletap sensitivity (used for double tap accel for afterburner or double tap reverse for cooldown)"));
1039 conf_saveEmptyLine();
1041 conf_saveComment(_(
"Whether or not clicking the middle mouse button toggles mouse flying mode."));
1042 conf_saveBool(
"mouse_fly",conf.
mouse_fly);
1043 conf_saveEmptyLine();
1045 conf_saveComment(_(
"Mouse-flying thrust control"));
1047 conf_saveEmptyLine();
1049 conf_saveComment(_(
"Maximum interval to count as a double-click (0 disables)."));
1051 conf_saveEmptyLine();
1053 conf_saveComment(_(
"Enemy distance at which autonav speed resets."));
1055 conf_saveEmptyLine();
1057 conf_saveComment(_(
"Shield value at which autonav speed resets."));
1059 conf_saveEmptyLine();
1061 conf_saveComment(_(
"Enables developer mode (universe editor and the likes)"));
1062 conf_saveBool(
"devmode",conf.
devmode);
1063 conf_saveEmptyLine();
1065 conf_saveComment(_(
"Automatic saving for when using the universe editor whenever an edit is done"));
1067 conf_saveEmptyLine();
1069 conf_saveComment(_(
"Enable the lua-enet library, for use by online/multiplayer mods (CAUTION: online Lua scripts may have security vulnerabilities!)"));
1070 conf_saveBool(
"lua_enet",conf.
lua_enet);
1071 conf_saveComment(_(
"Enable the experimental CLI based on lua-repl."));
1072 conf_saveBool(
"lua_repl",conf.
lua_repl);
1073 conf_saveEmptyLine();
1075 conf_saveComment(_(
"Save the config every time game exits (rewriting this bit)"));
1076 conf_saveInt(
"conf_nosave",conf.
nosave);
1077 conf_saveEmptyLine();
1079 conf_saveComment(_(
"Indicates the last version the game has run in before"));
1081 conf_saveEmptyLine();
1083 conf_saveComment(_(
"Indicates whether we've already warned about incomplete game translations."));
1085 conf_saveEmptyLine();
1087 conf_saveComment(_(
"Time Naev was last played. This gets refreshed each time you exit Naev."));
1088 conf_saveULong(
"last_played",time(NULL));
1089 conf_saveEmptyLine();
1092 conf_saveComment(_(
"Enables FPU exceptions - only works on DEBUG builds"));
1094 conf_saveEmptyLine();
1097 conf_saveComment(_(
"Paths for saving different files from the editor"));
1101 conf_saveEmptyLine();
1106 conf_saveEmptyLine();
1107 conf_saveComment(_(
"Keybindings"));
1108 conf_saveEmptyLine();
1111 keyname[
sizeof(keyname)-1] =
'\0';
1123 case KEYBIND_KEYBOARD:
typename =
"keyboard";
break;
1124 case KEYBIND_JAXISPOS:
typename =
"jaxispos";
break;
1125 case KEYBIND_JAXISNEG:
typename =
"jaxisneg";
break;
1126 case KEYBIND_JBUTTON:
typename =
"jbutton";
break;
1127 case KEYBIND_JHAT_UP:
typename =
"jhat_up";
break;
1128 case KEYBIND_JHAT_DOWN:
typename =
"jhat_down";
break;
1129 case KEYBIND_JHAT_LEFT:
typename =
"jhat_left";
break;
1130 case KEYBIND_JHAT_RIGHT:
typename =
"jhat_right";
break;
1131 default:
typename = NULL;
break;
1134 if ((
typename == NULL) || (key == SDLK_UNKNOWN && type == KEYBIND_KEYBOARD)) {
1141 case NMOD_CTRL: modname =
"ctrl";
break;
1142 case NMOD_SHIFT: modname =
"shift";
break;
1143 case NMOD_ALT: modname =
"alt";
break;
1144 case NMOD_META: modname =
"meta";
break;
1145 case NMOD_ANY: modname =
"any";
break;
1146 default: modname =
"none";
break;
1150 if (type == KEYBIND_KEYBOARD)
1151 quoteLuaString(keyname,
sizeof(keyname)-1, SDL_GetKeyName(key));
1153 if (type != KEYBIND_KEYBOARD || strcmp(keyname,
"\"unknown key\"") == 0)
1154 scnprintf(keyname,
sizeof(keyname)-1,
"%d", key);
1157 pos +=
scnprintf(&buf[pos],
sizeof(buf)-pos,
"%s = { type = \"%s\", mod = \"%s\", key = %s }\n",
1160 conf_saveEmptyLine();
1163 conf_saveComment(GENERATED_END_COMMENT);
1166 if (oldfooter != NULL) {
1168 oldsize =
MIN((
size_t)oldsize,
sizeof(buf)-pos);
1169 memcpy(&buf[pos], oldfooter, oldsize);
1176 WARN(_(
"Failed to write configuration! You'll most likely have to restore it by copying your backup configuration over your current configuration."));
1190#define STRDUP(s) dest->s = ((src->s==NULL)?NULL:strdup(src->s))
1194 STRDUP(joystick_nam);
1195 STRDUP(lastversion);
1196 STRDUP(dev_save_sys);
1197 STRDUP(dev_save_map);
1198 STRDUP(dev_save_spob);
1209 free(config->
ndata);
int background_load(const char *name)
Loads a background script by name.
static SDL_Joystick * joystick
double music_getVolume(void)
Gets the current music volume (linear).
Header file with generic functions and naev-specifics.
int nfile_writeFile(const char *data, size_t len, const char *path)
Tries to write a file.
char * nfile_readFile(size_t *filesize, const char *path)
Tries to read a file.
int nfile_backupIfExists(const char *path)
Backup a file, if it exists.
int nfile_fileExists(const char *path)
Checks to see if a file exists.
int nfile_touch(const char *path)
Tries to create the file if it doesn't exist.
char * strnstr(const char *haystack, const char *needle, size_t size)
A bounded version of strstr. Conforms to BSD semantics.
int scnprintf(char *text, size_t maxlen, const char *fmt,...)
Like snprintf(), but returns the number of characters ACTUALLY "printed" into the buffer....
void gl_colorblind(int enable)
Enables or disables the colorblind shader.
double sound_getVolume(void)
Gets the current sound volume (linear).
Struct containing player options.
double autonav_reset_shield
double compression_velocity
double autonav_reset_dist
unsigned int repeat_delay
unsigned int doubletap_sens
double map_overlay_opacity
double nebu_nonuniformity
int translation_warning_seen