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_loadTime( env, n, i ) \
49 nlua_getenv( naevL, env, n ); \
50 if ( lua_isnumber( naevL, -1 ) ) { \
51 i = (time_t)lua_tonumber( naevL, -1 ); \
53 lua_pop( naevL, 1 ); \
56#define conf_loadBool( env, n, b ) \
58 nlua_getenv( naevL, env, n ); \
59 if ( lua_isnumber( naevL, -1 ) ) \
60 b = ( lua_tonumber( naevL, -1 ) != 0. ); \
61 else if ( !lua_isnil( naevL, -1 ) ) \
62 b = lua_toboolean( naevL, -1 ); \
63 lua_pop( naevL, 1 ); \
66#define conf_loadString( env, n, s ) \
68 nlua_getenv( naevL, env, n ); \
69 if ( lua_isstring( naevL, -1 ) ) { \
71 s = strdup( lua_tostring( naevL, -1 ) ); \
73 lua_pop( naevL, 1 ); \
87extern int indjoystick;
88extern char* namjoystick;
93static void print_usage(
void );
98static void print_usage(
void )
100 LOG( _(
"Usage: %s [OPTIONS] [DATA]" ), env.argv0 );
101 LOG(_(
"Options are:"));
102 LOG(_(
" -f, --fullscreen activate fullscreen"));
103 LOG(_(
" -F n, --fps n limit frames per second to n"));
104 LOG(_(
" -V, --vsync enable vsync"));
105 LOG(_(
" -W n set width to n"));
106 LOG(_(
" -H n set height to n"));
107 LOG(_(
" -j n, --joystick n use joystick n"));
108 LOG(_(
" -J s, --Joystick s use joystick whose name contains s"));
109 LOG(_(
" -M, --mute disables sound"));
110 LOG(_(
" -S, --sound forces sound"));
111 LOG(_(
" -m f, --mvol f sets the music volume to f"));
112 LOG(_(
" -s f, --svol f sets the sound volume to f"));
113 LOG(_(
" -d, --datapath adds a new datapath to be mounted (i.e., appends it to the search path for game assets)"));
114 LOG(_(
" -X, --scale defines the scale factor"));
115 LOG(_(
" --devmode enables dev mode perks like the editors"));
116 LOG(_(
" -h, --help display this message and exit"));
117 LOG(_(
" -v, --version print the version and exit"));
123void conf_setDefaults (
void)
164 conf_setGameplayDefaults();
167 conf_setAudioDefaults();
170 conf_setVideoDefaults();
187void conf_setGameplayDefaults (
void)
202void conf_setAudioDefaults (
void)
205 conf.
al_efx = USE_EFX_DEFAULT;
206 conf.
nosound = MUTE_SOUND_DEFAULT;
207 conf.
sound = SOUND_VOLUME_DEFAULT;
208 conf.
music = MUSIC_VOLUME_DEFAULT;
215void conf_setVideoDefaults (
void)
218 SDL_DisplayMode resolution;
222 if (SDL_GetCurrentDisplayMode( 0, &resolution ) == 0) {
224 w = RESOLUTION_W_DEFAULT;
225 h = RESOLUTION_H_DEFAULT;
228 if ((resolution.w <= w) || (resolution.h <= h)) {
231 f = FULLSCREEN_DEFAULT;
240 conf.
fsaa = FSAA_DEFAULT;
241 conf.
vsync = VSYNC_DEFAULT;
249 conf.
nebu_scale = NEBULA_SCALE_FACTOR_DEFAULT;
265 conf.
fps_max = FPS_MAX_DEFAULT;
274void conf_cleanup (
void)
282void conf_loadConfigPath(
void )
284 const char *file =
"datapath.lua";
289 nlua_env lEnv = nlua_newEnv();
290 if ( nlua_dofileenv( lEnv, file ) == 0 )
291 conf_loadString( lEnv,
"datapath", conf.
datapath );
293 nlua_freeEnv( lEnv );
299int conf_loadConfig (
const char* file )
302 const char *str, *mod;
315 nlua_env lEnv = nlua_newEnv();
316 if (nlua_dofileenv( lEnv, file ) == 0) {
319 conf_loadString( lEnv,
"data", conf.
ndata );
322 conf_loadString( lEnv,
"language", conf.
language );
325 conf_loadInt( lEnv,
"fsaa", conf.
fsaa );
326 conf_loadBool( lEnv,
"vsync", conf.
vsync );
330 conf_loadInt( lEnv,
"width", w );
331 conf_loadInt( lEnv,
"height", h );
340 conf_loadFloat( lEnv,
"scalefactor", conf.
scalefactor );
341 conf_loadFloat( lEnv,
"nebu_scale", conf.
nebu_scale );
342 conf_loadBool( lEnv,
"fullscreen", conf.
fullscreen );
343 conf_loadBool( lEnv,
"modesetting", conf.
modesetting );
344 conf_loadBool( lEnv,
"notresizable", conf.
notresizable );
345 conf_loadBool( lEnv,
"borderless", conf.
borderless );
346 conf_loadBool( lEnv,
"minimize", conf.
minimize );
347 conf_loadBool( lEnv,
"colourblind", conf.
colourblind );
348 conf_loadBool( lEnv,
"healthbars", conf.
healthbars );
360 conf_loadBool( lEnv,
"showfps", conf.
fps_show );
361 conf_loadInt( lEnv,
"maxfps", conf.
fps_max );
364 conf_loadBool( lEnv,
"showpause", conf.
pause_show );
367 conf_loadBool( lEnv,
"al_efx", conf.
al_efx );
368 conf_loadBool( lEnv,
"nosound", conf.
nosound );
369 conf_loadFloat( lEnv,
"sound", conf.
sound );
370 conf_loadFloat( lEnv,
"music", conf.
music );
371 conf_loadFloat( lEnv,
"engine_vol", conf.
engine_vol );
374 nlua_getenv( naevL, lEnv,
"joystick" );
375 if (lua_isnumber(naevL, -1))
377 else if (lua_isstring(naevL, -1))
382 conf_loadInt( lEnv,
"mesg_visible", conf.
mesg_visible );
387 conf_loadBool( lEnv,
"big_icons", conf.
big_icons );
388 conf_loadBool( lEnv,
"always_radar", conf.
always_radar );
391 conf_loadInt( lEnv,
"repeat_delay", conf.
repeat_delay );
392 conf_loadInt( lEnv,
"repeat_freq", conf.
repeat_freq );
395 conf_loadBool( lEnv,
"zoom_manual", conf.
zoom_manual );
396 conf_loadFloat( lEnv,
"zoom_far", conf.
zoom_far );
397 conf_loadFloat( lEnv,
"zoom_near", conf.
zoom_near );
398 conf_loadFloat( lEnv,
"zoom_speed", conf.
zoom_speed );
407 conf_loadString( lEnv,
"difficulty", conf.
difficulty );
412 conf_loadInt( lEnv,
"doubletap_sensitivity", conf.
doubletap_sens );
413 conf_loadFloat( lEnv,
"mouse_hide", conf.
mouse_hide );
414 conf_loadBool( lEnv,
"mouse_fly", conf.
mouse_fly );
415 conf_loadInt( lEnv,
"mouse_thrust", conf.
mouse_accel );
416 conf_loadInt( lEnv,
"mouse_accel", conf.
mouse_accel );
420 conf_loadBool( lEnv,
"devmode", conf.
devmode );
421 conf_loadBool( lEnv,
"devautosave", conf.
devautosave );
422 conf_loadBool( lEnv,
"lua_enet", conf.
lua_enet );
423 conf_loadBool( lEnv,
"lua_repl", conf.
lua_repl );
424 conf_loadBool( lEnv,
"conf_nosave", conf.
nosave );
425 conf_loadString( lEnv,
"lastversion", conf.
lastversion );
427 conf_loadTime( lEnv,
"last_played", conf.
last_played );
430 conf_loadBool( lEnv,
"fpu_except", conf.
fpu_except );
433 conf_loadString( lEnv,
"dev_save_sys", conf.
dev_save_sys );
434 conf_loadString( lEnv,
"dev_save_map", conf.
dev_save_map );
435 conf_loadString( lEnv,
"dev_save_spob", conf.
dev_save_spob );
443 if (lua_isstring(naevL,-1)) {
444 str = lua_tostring(naevL,-1);
445 if (strcmp(str,
"none")==0) {
447 KEYBIND_NULL, SDLK_UNKNOWN, NMOD_NONE );
450 else if (lua_istable(naevL, -1)) {
452 lua_pushstring(naevL,
"type");
453 lua_gettable(naevL, -2);
454 if (lua_isstring(naevL, -1))
455 str = lua_tostring(naevL, -1);
456 else if (lua_isnil(naevL, -1)) {
457 WARN(_(
"Found keybind with no type field!"));
461 WARN(_(
"Found keybind with invalid type field!"));
467 lua_pushstring(naevL,
"key");
468 lua_gettable(naevL, -2);
469 t = lua_type(naevL, -1);
470 if (t == LUA_TNUMBER)
471 key = (int)lua_tonumber(naevL, -1);
472 else if (t == LUA_TSTRING)
474 else if (t == LUA_TNIL) {
475 WARN(_(
"Found keybind with no key field!"));
479 WARN(_(
"Found keybind with invalid key field!"));
485 lua_pushstring(naevL,
"mod");
486 lua_gettable(naevL, -2);
487 if (lua_isstring(naevL, -1))
488 mod = lua_tostring(naevL, -1);
495 if (strcmp(str,
"null")==0) type = KEYBIND_NULL;
496 else if (strcmp(str,
"keyboard")==0) type = KEYBIND_KEYBOARD;
497 else if (strcmp(str,
"jaxispos")==0) type = KEYBIND_JAXISPOS;
498 else if (strcmp(str,
"jaxisneg")==0) type = KEYBIND_JAXISNEG;
499 else if (strcmp(str,
"jbutton")==0) type = KEYBIND_JBUTTON;
500 else if (strcmp(str,
"jhat_up")==0) type = KEYBIND_JHAT_UP;
501 else if (strcmp(str,
"jhat_down")==0) type = KEYBIND_JHAT_DOWN;
502 else if (strcmp(str,
"jhat_left")==0) type = KEYBIND_JHAT_LEFT;
503 else if (strcmp(str,
"jhat_right")==0) type = KEYBIND_JHAT_RIGHT;
505 WARN(_(
"Unknown keybinding of type %s"), str);
510 if ((key == SDLK_UNKNOWN) && (type == KEYBIND_KEYBOARD)) {
511 WARN(_(
"Keybind for '%s' is invalid"),
keybind_info[i][0]);
517 if (strcmp(mod,
"ctrl")==0) m = NMOD_CTRL;
518 else if (strcmp(mod,
"shift")==0) m = NMOD_SHIFT;
519 else if (strcmp(mod,
"alt")==0) m = NMOD_ALT;
520 else if (strcmp(mod,
"meta")==0) m = NMOD_META;
521 else if (strcmp(mod,
"any")==0) m = NMOD_ANY;
522 else if (strcmp(mod,
"none")==0) m = NMOD_NONE;
524 WARN(_(
"Unknown keybinding mod of type %s"), mod);
535 WARN(_(
"Malformed keybind for '%s' in '%s'."),
keybind_info[i][0], file);
542 WARN(_(
"Config file '%s' has invalid syntax:"), file );
543 WARN(
" %s", lua_tostring(naevL,-1));
544 nlua_freeEnv( lEnv );
549 nlua_freeEnv( lEnv );
556void conf_parseCLI(
int argc,
char** argv )
558 static struct option long_options[] = {
559 {
"datapath", required_argument, 0,
'd' },
560 {
"fullscreen", no_argument, 0,
'f' },
561 {
"fps", required_argument, 0,
'F' },
562 {
"vsync", no_argument, 0,
'V' },
563 {
"joystick", required_argument, 0,
'j' },
564 {
"Joystick", required_argument, 0,
'J' },
565 {
"width", required_argument, 0,
'W' },
566 {
"height", required_argument, 0,
'H' },
567 {
"mute", no_argument, 0,
'M' },
568 {
"sound", no_argument, 0,
'S' },
569 {
"mvol", required_argument, 0,
'm' },
570 {
"svol", required_argument, 0,
's' },
571 {
"scale", required_argument, 0,
'X' },
572 {
"devmode", no_argument, 0,
'D' },
573 {
"help", no_argument, 0,
'h' },
574 {
"version", no_argument, 0,
'v' },
576 int option_index = 1;
584 while ((
c = getopt_long(argc, argv,
585 "fF:Vd:j:J:W:H:MSm:s:X:Nhv",
586 long_options, &option_index)) != -1) {
589 PHYSFS_mount( optarg, NULL, 1 );
607 conf.
width = atoi(optarg);
611 conf.
height = atoi(optarg);
621 conf.
music = atof(optarg);
624 conf.
sound = atof(optarg);
635 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_saveTime(n,i) \
746pos += scnprintf(&buf[pos], sizeof(buf)-pos, "%s = %llu\n", n, (unsigned long long) i);
748#define conf_saveFloat(n,f) \
749pos += scnprintf(&buf[pos], sizeof(buf)-pos, "%s = %f\n", n, f);
751#define conf_saveBool(n,b) \
753 pos += scnprintf(&buf[pos], sizeof(buf)-pos, "%s = true\n", n); \
755 pos += scnprintf(&buf[pos], sizeof(buf)-pos, "%s = false\n", n);
757#define conf_saveString(n,s) \
758pos += scnprintf(&buf[pos], sizeof(buf)-pos, "%s = ", n); \
759pos += quoteLuaString(&buf[pos], sizeof(buf)-pos, s); \
760if (sizeof(buf) != pos) \
763#define GENERATED_START_COMMENT "START GENERATED SECTION"
764#define GENERATED_END_COMMENT "END GENERATED SECTION"
769int conf_saveConfig (
const char* file )
772 const char *oldfooter;
788 const char *tmp =
strnstr(old,
"-- "GENERATED_START_COMMENT
"\n", oldsize);
791 pos =
MIN(
sizeof(buf), (
size_t)(tmp - old));
792 memcpy(buf, old, pos);
795 tmp =
strnstr(tmp,
"-- "GENERATED_END_COMMENT
"\n", oldsize-pos);
798 oldfooter = tmp + strlen(
"-- "GENERATED_END_COMMENT
"\n");
799 oldsize -= (oldfooter - old);
811 conf_saveComment(_(
"Naev configuration file"));
812 conf_saveEmptyLine();
817 WARN(_(
"Not saving configuration."));
822 conf_saveComment(GENERATED_START_COMMENT);
823 conf_saveComment(_(
"The contents of this section will be rewritten by Naev!"));
824 conf_saveEmptyLine();
827 conf_saveComment(_(
"The location of Naev's data pack, usually called 'ndata'"));
828 conf_saveString(
"data",conf.
ndata);
829 conf_saveEmptyLine();
832 conf_saveComment(_(
"Language to use. Set to the two character identifier to the language (e.g., \"en\" for English), and nil for autodetect."));
833 conf_saveString(
"language",conf.
language);
834 conf_saveEmptyLine();
837 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."));
839 conf_saveComment(
"difficulty = nil");
842 conf_saveString(
"difficulty",conf.
difficulty);
844 conf_saveEmptyLine();
847 conf_saveComment(_(
"The factor to use in Full-Scene Anti-Aliasing"));
848 conf_saveComment(_(
"Anything lower than 2 will simply disable FSAA"));
849 conf_saveInt(
"fsaa",conf.
fsaa);
850 conf_saveEmptyLine();
852 conf_saveComment(_(
"Synchronize framebuffer updates with the vertical blanking interval"));
853 conf_saveBool(
"vsync",conf.
vsync);
854 conf_saveEmptyLine();
857 conf_saveComment(_(
"The window size or screen resolution"));
858 conf_saveComment(_(
"Set both of these to 0 to make Naev try the desktop resolution"));
860 conf_saveInt(
"width",conf.
width);
861 conf_saveInt(
"height",conf.
height);
863 conf_saveInt(
"width",0);
864 conf_saveInt(
"height",0);
866 conf_saveEmptyLine();
868 conf_saveComment(_(
"Factor used to divide the above resolution with"));
869 conf_saveComment(_(
"This is used to lower the rendering resolution, and scale to the above"));
871 conf_saveEmptyLine();
873 conf_saveComment(_(
"Scale factor for rendered nebula backgrounds."));
874 conf_saveComment(_(
"Larger values can save time but lead to a blurrier appearance."));
876 conf_saveEmptyLine();
878 conf_saveComment(_(
"Run Naev in full-screen mode"));
880 conf_saveEmptyLine();
882 conf_saveComment(_(
"Use video modesetting when fullscreen is enabled"));
884 conf_saveEmptyLine();
886 conf_saveComment(_(
"Disable allowing resizing the window."));
888 conf_saveEmptyLine();
890 conf_saveComment(_(
"Disable window decorations. Use with care and know the keyboard controls to quit and toggle fullscreen."));
892 conf_saveEmptyLine();
894 conf_saveComment(_(
"Minimize the game on focus loss."));
895 conf_saveBool(
"minimize",conf.
minimize);
896 conf_saveEmptyLine();
898 conf_saveComment(_(
"Enables colourblind mode. Good for simulating colourblindness."));
900 conf_saveEmptyLine();
902 conf_saveComment(_(
"Enable health bars. These show hostility/friendliness and health of pilots on screen."));
904 conf_saveEmptyLine();
906 conf_saveComment(_(
"Background brightness. 1 is normal brightness while setting it to 0 would make the backgrounds pitch black."));
908 conf_saveEmptyLine();
910 conf_saveComment(_(
"Nebula non-uniformity. 1 is normal nebula while setting it to 0 would make the nebula a solid colour."));
912 conf_saveEmptyLine();
914 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."));
916 conf_saveEmptyLine();
918 conf_saveComment(_(
"Gamma correction parameter. A value of 1 disables it (no curve)."))
919 conf_saveFloat("gamma_correction",conf.gamma_correction);
920 conf_saveEmptyLine();
922 conf_saveComment(_("Expensive high quality shaders for the background. Defaults to false."))
923 conf_saveBool("background_fancy",conf.background_fancy);
924 conf_saveEmptyLine();
927 conf_saveComment(_("Display a frame rate counter"));
928 conf_saveBool("showfps",conf.fps_show);
929 conf_saveEmptyLine();
931 conf_saveComment(_("Limit the rendering frame rate"));
932 conf_saveInt("maxfps",conf.fps_max);
933 conf_saveEmptyLine();
936 conf_saveComment(_("Show 'PAUSED' on screen while
paused"));
937 conf_saveBool("showpause",conf.pause_show);
938 conf_saveEmptyLine();
941 conf_saveComment(_("Enables EFX extension for OpenAL backend."));
942 conf_saveBool("al_efx",conf.al_efx);
943 conf_saveEmptyLine();
945 conf_saveComment(_("Disable all sound"));
946 conf_saveBool("nosound",conf.nosound);
947 conf_saveEmptyLine();
949 conf_saveComment(_("Volume of sound effects and music, between 0.0 and 1.0"));
952 conf_saveComment(_("Relative engine sound volume. Should be between 0.0 and 1.0"));
953 conf_saveFloat("engine_vol", conf.engine_vol);
954 conf_saveEmptyLine();
957 conf_saveComment(_("The name or numeric index of the
joystick to use"));
958 conf_saveComment(_("Setting this to nil disables the
joystick support"));
959 if (conf.joystick_nam != NULL) {
966 conf_saveString(
"joystick",NULL);
968 conf_saveEmptyLine();
971 conf_saveComment(_(
"Number of lines visible in the comm window."));
973 conf_saveComment(_(
"Opacity fraction (0-1) for the overlay map."));
975 conf_saveComment(_(
"Use bigger icons in the outfit, shipyard, and other lists."));
976 conf_saveBool(
"big_icons", conf.
big_icons);
977 conf_saveComment(_(
"Always show the radar and don't hide it when the overlay is active."));
979 conf_saveEmptyLine();
982 conf_saveComment(_(
"Delay in ms before starting to repeat (0 disables)"));
984 conf_saveComment(_(
"Delay in ms between repeats once it starts to repeat"));
986 conf_saveEmptyLine();
989 conf_saveComment(_(
"Minimum and maximum zoom factor to use in-game"));
990 conf_saveComment(_(
"At 1.0, no sprites are scaled"));
991 conf_saveComment(_(
"zoom_far should be less then zoom_near"));
993 conf_saveFloat(
"zoom_far",conf.
zoom_far);
994 conf_saveFloat(
"zoom_near",conf.
zoom_near);
995 conf_saveEmptyLine();
997 conf_saveComment(_(
"Zooming speed in factor increments per second"));
999 conf_saveEmptyLine();
1002 conf_saveComment(_(
"Font sizes (in pixels) for Naev"));
1003 conf_saveComment(_(
"Warning, setting to other than the default can cause visual glitches!"));
1004 pos +=
scnprintf(&buf[pos],
sizeof(buf)-pos, _(
"-- Console default: %d\n"), FONT_SIZE_CONSOLE_DEFAULT);
1006 pos +=
scnprintf(&buf[pos],
sizeof(buf)-pos, _(
"-- Intro default: %d\n"), FONT_SIZE_INTRO_DEFAULT);
1008 pos +=
scnprintf(&buf[pos],
sizeof(buf)-pos, _(
"-- Default size: %d\n"), FONT_SIZE_DEF_DEFAULT);
1010 pos +=
scnprintf(&buf[pos],
sizeof(buf)-pos, _(
"-- Small size: %d\n"), FONT_SIZE_SMALL_DEFAULT);
1014 conf_saveComment(_(
"Redirects log and error output to files"));
1016 conf_saveEmptyLine();
1018 conf_saveComment(_(
"Enables compression on saved games"));
1020 conf_saveEmptyLine();
1022 conf_saveComment(_(
"Doubletap sensitivity (used for double tap accel for afterburner or double tap reverse for cooldown)"));
1024 conf_saveEmptyLine();
1026 conf_saveComment(_(
"Time (in seconds) to wait until hiding mouse when not used."));
1028 conf_saveEmptyLine();
1030 conf_saveComment(_(
"Whether or not clicking the middle mouse button toggles mouse flying mode."));
1031 conf_saveBool(
"mouse_fly",conf.
mouse_fly);
1032 conf_saveEmptyLine();
1034 conf_saveComment(_(
"Mouse-flying accel control"));
1036 conf_saveEmptyLine();
1038 conf_saveComment(_(
"Maximum interval to count as a double-click (0 disables)."));
1040 conf_saveEmptyLine();
1042 conf_saveComment(_(
"Enables developer mode (universe editor and the likes)"));
1043 conf_saveBool(
"devmode",conf.
devmode);
1044 conf_saveEmptyLine();
1046 conf_saveComment(_(
"Automatic saving for when using the universe editor whenever an edit is done"));
1048 conf_saveEmptyLine();
1050 conf_saveComment(_(
"Enable the lua-enet library, for use by online/multiplayer mods (CAUTION: online Lua scripts may have security vulnerabilities!)"));
1051 conf_saveBool(
"lua_enet",conf.
lua_enet);
1052 conf_saveComment(_(
"Enable the experimental CLI based on lua-repl."));
1053 conf_saveBool(
"lua_repl",conf.
lua_repl);
1054 conf_saveEmptyLine();
1056 conf_saveComment(_(
"Save the config every time game exits (rewriting this bit)"));
1057 conf_saveInt(
"conf_nosave",conf.
nosave);
1058 conf_saveEmptyLine();
1060 conf_saveComment(_(
"Indicates the last version the game has run in before"));
1062 conf_saveEmptyLine();
1064 conf_saveComment(_(
"Indicates whether we've already warned about incomplete game translations."));
1066 conf_saveEmptyLine();
1068 conf_saveComment(_(
"Time Naev was last played. This gets refreshed each time you exit Naev."));
1069 conf_saveTime(
"last_played",time(NULL));
1070 conf_saveEmptyLine();
1073 conf_saveComment(_(
"Enables FPU exceptions - only works on DEBUG builds"));
1075 conf_saveEmptyLine();
1078 conf_saveComment(_(
"Paths for saving different files from the editor"));
1082 conf_saveEmptyLine();
1085 conf_saveComment(_(
"The following are for legacy purposes and will be removed in 0.12.0."))
1086 conf_saveFloat("compression_velocity",conf.compression_velocity);
1087 conf_saveFloat("compression_mult",conf.compression_mult);
1088 conf_saveFloat("autonav_reset_dist",conf.autonav_reset_dist);
1089 conf_saveFloat("autonav_reset_shield",conf.autonav_reset_shield);
1094 conf_saveEmptyLine();
1095 conf_saveComment(_("Keybindings"));
1096 conf_saveEmptyLine();
1102 const char *
typename;
1104 const char *modname;
1108 keyname[
sizeof(keyname)-1] =
'\0';
1118 case KEYBIND_KEYBOARD:
typename =
"keyboard";
break;
1119 case KEYBIND_JAXISPOS:
typename =
"jaxispos";
break;
1120 case KEYBIND_JAXISNEG:
typename =
"jaxisneg";
break;
1121 case KEYBIND_JBUTTON:
typename =
"jbutton";
break;
1122 case KEYBIND_JHAT_UP:
typename =
"jhat_up";
break;
1123 case KEYBIND_JHAT_DOWN:
typename =
"jhat_down";
break;
1124 case KEYBIND_JHAT_LEFT:
typename =
"jhat_left";
break;
1125 case KEYBIND_JHAT_RIGHT:
typename =
"jhat_right";
break;
1126 default:
typename = NULL;
break;
1129 if ((
typename == NULL) || (key == SDLK_UNKNOWN && type == KEYBIND_KEYBOARD)) {
1136 case NMOD_CTRL: modname =
"ctrl";
break;
1137 case NMOD_SHIFT: modname =
"shift";
break;
1138 case NMOD_ALT: modname =
"alt";
break;
1139 case NMOD_META: modname =
"meta";
break;
1140 case NMOD_ANY: modname =
"any";
break;
1141 default: modname =
"none";
break;
1145 if (type == KEYBIND_KEYBOARD)
1146 quoteLuaString(keyname,
sizeof(keyname)-1, SDL_GetKeyName(key));
1148 if (type != KEYBIND_KEYBOARD || strcmp(keyname,
"\"unknown key\"") == 0)
1149 scnprintf(keyname,
sizeof(keyname)-1,
"%d", key);
1152 pos +=
scnprintf(&buf[pos],
sizeof(buf)-pos,
"%s = { type = \"%s\", mod = \"%s\", key = %s }\n",
1155 conf_saveEmptyLine();
1158 conf_saveComment(GENERATED_END_COMMENT);
1161 if (oldfooter != NULL) {
1163 oldsize =
MIN((
size_t)oldsize,
sizeof(buf)-pos);
1164 memcpy(&buf[pos], oldfooter, oldsize);
1171 WARN(_(
"Failed to write configuration! You'll most likely have to restore it by copying your backup configuration over your current configuration."));
1185#define STRDUP(s) dest->s = ((src->s==NULL)?NULL:strdup(src->s))
1189 STRDUP(joystick_nam);
1190 STRDUP(lastversion);
1191 STRDUP(dev_save_sys);
1192 STRDUP(dev_save_map);
1193 STRDUP(dev_save_spob);
1204 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_colourblind(int enable)
Enables or disables the colourblind 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