20#include "background.h"
24#include "difficulty.h"
39#define BUTTON_WIDTH 120
40#define BUTTON_HEIGHT 30
42#define OPT_WIN_GAMEPLAY 0
43#define OPT_WIN_ACCESSIBILITY 1
44#define OPT_WIN_VIDEO 2
45#define OPT_WIN_AUDIO 3
46#define OPT_WIN_INPUT 4
47#define OPT_WIN_PLUGINS 5
50#define AUTONAV_RESET_DIST_MAX 10e3
51#define LANG_CODE_START \
55static unsigned int opt_wid = 0;
56static unsigned int *opt_windows;
57static const char *opt_names[] = {
58 N_(
"Gameplay" ), N_(
"Accessibility" ), N_(
"Video" ),
59 N_(
"Audio" ), N_(
"Input" ), N_(
"Plugins" ),
61static_assert( (
sizeof( opt_names ) /
sizeof( opt_names[0] ) ) == OPT_WINDOWS,
62 "Options windows mismatch!" );
63static const glColour *cHeader = &cFontGrey;
65static int opt_restart = 0;
78static void opt_close(
unsigned int wid,
const char *name );
81static char **lang_list(
int *n );
84static void opt_OK(
unsigned int wid,
const char *str );
90static int opt_accessibilitySave(
unsigned int wid,
const char *str );
94static void opt_setSaturation(
unsigned int wid,
const char *str );
99static void opt_setGameSpeed(
unsigned int wid,
const char *str );
101static void opt_video(
unsigned int wid );
102static void opt_videoRes(
unsigned int wid,
const char *str );
103static int opt_videoSave(
unsigned int wid,
const char *str );
113static void opt_audio(
unsigned int wid );
114static int opt_audioSave(
unsigned int wid,
const char *str );
119static void opt_setEngineLevel(
unsigned int wid,
const char *str );
120static void opt_beep(
unsigned int wid,
const char *str );
124 int *lh,
int *bw,
int *bh );
130static void opt_setKey(
unsigned int wid,
const char *str );
131static void opt_unsetKey(
unsigned int wid,
const char *str );
134static void opt_plugins_regenList(
unsigned int wid );
135static void opt_plugins_add(
unsigned int wid,
const char *name );
136static void opt_plugins_update(
unsigned int wid,
const char *name );
147 conf_copy( &local_conf, &conf );
154 opt_wid =
window_create(
"wdwOptions", _(
"Options" ), -1, -1, w, h );
158 names = calloc( 1,
sizeof( opt_names ) );
159 for (
size_t i = 0; i <
sizeof( opt_names ) /
sizeof( opt_names[0] ); i++ )
160 names[i] = _( opt_names[i] );
161 opt_windows = window_addTabbedWindow( opt_wid, -1, -1, -1, -1,
"tabOpt",
162 OPT_WINDOWS, (
const char **)names, 0 );
166 for (
int i = 0; i < OPT_WINDOWS; i++ ) {
167 unsigned int wid = opt_windows[i];
170 window_addText( opt_windows[i], 20, 10,
172 "txtRestart", NULL, NULL, NULL );
191static void opt_OK(
unsigned int wid,
const char *str )
193 int ret, prompted_restart;
195 prompted_restart = opt_restart;
198 ret |= opt_accessibilitySave( opt_windows[OPT_WIN_ACCESSIBILITY], str );
202 if ( opt_restart && !prompted_restart )
204 _(
"Restart Naev for changes to take effect." ) );
209 conf_copy( &local_conf, &conf );
217static void opt_close(
unsigned int wid,
const char *name )
223 conf_copy( &conf, &local_conf );
229 render_setGamma( conf.gamma_correction );
235 conf_free( &local_conf );
243 int w, h, fullscreen;
252 snprintf( buf,
sizeof( buf ),
"%dx%d", w, h );
253 window_setInput( opt_windows[OPT_WIN_VIDEO],
"inpRes", buf );
259static char **lang_list(
int *n )
267 ls = malloc(
sizeof(
char * ) * 128 );
268 SDL_asprintf( &ls[0], _(
"system (%s[%3.0f%%] %s#0)" ),
269 ( syscoverage < 0.8 ) ?
"#r" :
"", 100. * syscoverage,
274 for (
int i = 0; i <
array_size( opts ); i++ ) {
275 char **item = &ls[( *n )++];
276 SDL_asprintf( item,
"%s[%3.0f%%] %s",
277 ( opts[i].coverage < 0.8 ) ?
"#r" :
"",
278 100. * opts[i].coverage, opts[i].language );
279 free( opts[i].language );
295 int w, h, y, x, by, l, n, i, p;
297 char **ls, **diff_text, **diff_alt;
298 const Difficulty *difficulty, *cur_difficulty;
314 window_addText( wid, x, y, cw, 20, 1,
"txtVersion", NULL, NULL,
318 snprintf( buf,
sizeof( buf ),
"#n%s#0%s (%s)", _(
"Platform Info: " ),
319 SDL_GetPlatform(), HOST );
320 window_addText( wid, x, y, cw, 20, 1,
"txtPlatInfo", NULL, NULL, buf );
323 snprintf( buf,
sizeof( buf ),
"#n%s#0%s" CONF_FILE, _(
"Config Path: " ),
325 window_addText( wid, x, y, cw, 20, 1,
"txtConfPath", NULL, NULL, buf );
330 cw = ( w - 60 ) / 2 - 40;
333 s = _(
"Language:" );
335 window_addText( wid, x, y, l, 20, 0,
"txtLanguage", NULL, NULL, s );
336 ls = lang_list( &n );
338 if ( conf.language != NULL ) {
339 for ( i = 1; i < n; i++ )
345 window_addList( wid, x + l + 20, y, cw - l - 50, 100,
"lstLanguage", ls, n,
350 difficulty = difficulty_getAll();
352 diff_text = malloc(
sizeof(
char *) * n );
353 diff_alt = malloc(
sizeof(
char *) * n );
356 difficulty_setLocal( NULL );
357 cur_difficulty = difficulty_cur();
358 for ( i = 0; i < n; i++ ) {
360 diff_text[i] = strdup( _(
d->name ) );
361 diff_alt[i] = difficulty_display(
d );
362 if ( strcmp(
d->name, cur_difficulty->
name ) == 0 )
366 s = _(
"Difficulty (this save):" );
368 s = _(
"Difficulty (global):" );
369 window_addText( wid, x, y, cw, 20, 0,
"txtDifficulty", NULL, NULL, s );
371 window_addList( wid, x, y, cw, 100,
"lstDifficulty", diff_text, n, p, NULL,
373 toolkit_setListAltText( wid,
"lstDifficulty", diff_alt );
377 window_addText( wid, x, y, cw, 20, 0,
"txtCompile", NULL, cHeader,
378 _(
"Compilation Flags:" ) );
380 window_addText( wid, x, y, cw, h + y - 20, 0,
"txtFlags", NULL, &cFontOrange,
401 window_addText( wid, x, y, cw, 20, 0,
"txtSettings", NULL, cHeader,
405 window_addCheckbox( wid, x, y, cw, 20,
"chkZoomManual",
406 _(
"Enable manual zoom control" ), NULL,
409 window_addCheckbox( wid, x, y, cw, 20,
"chkDoubletap",
410 _(
"Enable double-tap afterburn/cooldown" ), NULL,
411 conf.doubletap_sens );
413 window_addCheckbox( wid, x, y, cw, 20,
"chkMouseFly",
414 _(
"Enable mouse-flying (toggle with middle click)" ),
415 NULL, conf.mouse_fly );
417 window_addCheckbox( wid, x, y, cw, 20,
"chkMouseAccel",
418 _(
"Enable mouse-flying accel control" ), NULL,
421 s = _(
"Visible Messages" );
423 window_addText( wid, x, y, l, 20, 1,
"txtSMSG", NULL, NULL, s );
424 window_addInput( wid, -50, y, 40, 20,
"inpMSG", 4, 1, NULL );
438 const char *vmsg, *s;
442 p = toolkit_getListPos( wid,
"lstLanguage" );
443 s = ( p == 0 ) ? NULL : toolkit_getList( wid,
"lstLanguage" );
444 newlang = ( ( s != NULL ) != ( conf.language != NULL ) ) ||
448 free( conf.language );
450 LOG(
"conf.language set to %s", conf.language );
460 FONT_PATH_PREFIX, 0 );
462 FONT_PATH_PREFIX, 0 );
464 conf.font_size_def, FONT_PATH_PREFIX, 0 );
468 difficulty = difficulty_getAll();
469 p = toolkit_getListPos( wid,
"lstDifficulty" );
470 difficulty = &difficulty[p];
472 free( conf.difficulty );
473 if ( difficulty->
def ) {
474 conf.difficulty = NULL;
475 difficulty_setGlobal( NULL );
477 conf.difficulty = strdup( difficulty->
name );
478 difficulty_setGlobal( difficulty );
481 free(
player.difficulty );
482 if ( difficulty == difficulty_get( NULL ) ) {
484 difficulty_setLocal( NULL );
486 player.difficulty = strdup( difficulty->
name );
487 difficulty_setLocal( difficulty );
495 f = window_checkboxState( wid,
"chkDoubletap" );
496 if ( ( conf.doubletap_sens != 0 ) != f )
497 conf.doubletap_sens = ( f != 0 ) * 250;
499 conf.zoom_manual = window_checkboxState( wid,
"chkZoomManual" );
500 conf.mouse_accel = window_checkboxState( wid,
"chkMouseAccel" );
501 conf.mouse_fly = window_checkboxState( wid,
"chkMouseFly" );
504 if ( !conf.mouse_fly )
505 player_rmFlag( PLAYER_MFLY );
508 vmsg = window_getInput( wid,
"inpMSG" );
509 conf.mesg_visible = atoi( vmsg );
510 if ( conf.mesg_visible == 0 )
511 conf.mesg_visible = INPUT_MESSAGES_DEFAULT;
526 window_checkboxSet( wid,
"chkZoomManual", MANUAL_ZOOM_DEFAULT );
527 window_checkboxSet( wid,
"chkDoubletap", DOUBLETAP_SENSITIVITY_DEFAULT );
528 window_checkboxSet( wid,
"chkMouseFly", MOUSE_FLY_DEFAULT );
529 window_checkboxSet( wid,
"chkMouseAccel", MOUSE_ACCEL_DEFAULT );
532 snprintf( vmsg,
sizeof( vmsg ),
"%d", INPUT_MESSAGES_DEFAULT );
533 window_setInput( wid,
"inpMSG", vmsg );
545 window_checkboxSet( wid,
"chkZoomManual", conf.zoom_manual );
546 window_checkboxSet( wid,
"chkDoubletap", conf.doubletap_sens );
547 window_checkboxSet( wid,
"chkMouseFly", conf.mouse_fly );
548 window_checkboxSet( wid,
"chkMouseAccel", conf.mouse_accel );
551 snprintf( vmsg,
sizeof( vmsg ),
"%d", conf.mesg_visible );
552 window_setInput( wid,
"inpMSG", vmsg );
559 int *lh,
int *bw,
int *bh )
582 int w, h, lw, bw, bh;
592 window_addButton( wid, -20, 20 + 1 * (
BUTTON_HEIGHT + 20 ), bw, bh,
596 window_addText( wid, -20, -40, w - ( 20 + lw + 20 + 20 ), 30, 1,
"txtName",
597 NULL, cHeader, NULL );
598 window_addText( wid, -20, -90, w - ( 20 + lw + 20 + 20 ), h - 170 - 3 * bh,
599 0,
"txtDesc", NULL, NULL, NULL );
613 char **str, mod_text[64];
624 str = malloc(
sizeof(
char * ) * KST_END );
625 for (
int j = 0; j < KST_END; j++ ) {
632 str[j] = malloc( l );
635 case KEYBIND_KEYBOARD:
637 if ( mod == NMOD_ANY )
638 snprintf( mod_text,
sizeof( mod_text ), _(
"any+" ) );
642 if ( mod & NMOD_SHIFT )
643 p +=
scnprintf( &mod_text[p],
sizeof( mod_text ) - p,
645 if ( mod & NMOD_CTRL )
646 p +=
scnprintf( &mod_text[p],
sizeof( mod_text ) - p,
648 if ( mod & NMOD_ALT )
649 p +=
scnprintf( &mod_text[p],
sizeof( mod_text ) - p,
651 if ( mod & NMOD_META )
652 p +=
scnprintf( &mod_text[p],
sizeof( mod_text ) - p,
659 if ( key < 0x100 && isalpha( key ) )
660 snprintf( str[j], l,
"%s <%s%c>", short_desc, mod_text,
663 snprintf( str[j], l,
"%s <%s%s>", short_desc, mod_text,
666 case KEYBIND_JAXISPOS:
667 snprintf( str[j], l,
"%s <ja+%d>", short_desc, key );
669 case KEYBIND_JAXISNEG:
670 snprintf( str[j], l,
"%s <ja-%d>", short_desc, key );
672 case KEYBIND_JBUTTON:
673 snprintf( str[j], l,
"%s <jb%d>", short_desc, key );
675 case KEYBIND_JHAT_UP:
676 snprintf( str[j], l,
"%s <jh%d-up>", short_desc, key );
678 case KEYBIND_JHAT_DOWN:
679 snprintf( str[j], l,
"%s <jh%d-down>", short_desc, key );
681 case KEYBIND_JHAT_LEFT:
682 snprintf( str[j], l,
"%s <jh%d-left>", short_desc, key );
684 case KEYBIND_JHAT_RIGHT:
685 snprintf( str[j], l,
"%s <jh%d-right>", short_desc, key );
688 snprintf( str[j], l,
"%s", short_desc );
695 pos = toolkit_getListPos( wid,
"lstKeybinds" );
696 off = toolkit_getListOffset( wid,
"lstKeybinds" );
700 window_addList( wid, 20, -40, lw, lh,
"lstKeybinds", str, KST_END, 0,
704 toolkit_setListPos( wid,
"lstKeybinds", pos );
705 toolkit_setListOffset( wid,
"lstKeybinds", off );
719 KeySemanticType keybind;
724 char buf[STRMAX_SHORT];
728 selected = toolkit_getListPos( wid,
"lstKeybinds" );
742 snprintf( binding,
sizeof( binding ), _(
"Not bound" ) );
744 case KEYBIND_KEYBOARD:
747 if ( key < 0x100 && isalpha( key ) )
748 snprintf( binding,
sizeof( binding ), _(
"keyboard: %s%s%c" ),
750 ( mod != KMOD_NONE ) ?
" + " :
"", toupper( key ) );
752 snprintf( binding,
sizeof( binding ), _(
"keyboard: %s%s%s" ),
754 ( mod != KMOD_NONE ) ?
" + " :
"",
757 case KEYBIND_JAXISPOS:
758 snprintf( binding,
sizeof( binding ), _(
"joy axis pos: <%d>" ), key );
760 case KEYBIND_JAXISNEG:
761 snprintf( binding,
sizeof( binding ), _(
"joy axis neg: <%d>" ), key );
763 case KEYBIND_JBUTTON:
764 snprintf( binding,
sizeof( binding ), _(
"joy button: <%d>" ), key );
766 case KEYBIND_JHAT_UP:
767 snprintf( binding,
sizeof( binding ), _(
"joy hat up: <%d>" ), key );
769 case KEYBIND_JHAT_DOWN:
770 snprintf( binding,
sizeof( binding ), _(
"joy hat down: <%d>" ), key );
772 case KEYBIND_JHAT_LEFT:
773 snprintf( binding,
sizeof( binding ), _(
"joy hat left: <%d>" ), key );
775 case KEYBIND_JHAT_RIGHT:
776 snprintf( binding,
sizeof( binding ), _(
"joy hat right:<%d>" ), key );
781 snprintf( buf,
sizeof( buf ),
"%s\n\n%s\n", desc, binding );
782 window_modifyText( wid,
"txtDesc", buf );
791 const char *title, *caption;
796 const char *opts[] = { _(
"WASD" ), _(
"Arrow Keys" ), _(
"Cancel" ) };
798 title = _(
"Restore Defaults" );
799 caption = _(
"Which layout do you want to use?" );
803 for (
int i = 0; i < n; i++ )
812 for (
int i = 0; i < n; i++ )
813 if ( strcmp( ret, opts[i] ) == 0 ) {
830 _(
"Keybindings restored to defaults." ) );
833static void opt_setEngineLevel(
unsigned int wid,
const char *str )
836 double vol = window_getFaderValue( wid, str );
837 const char *label = _(
"Engine Volume" );
838 double logvol = 1. / pow( 2., ( 1. - vol ) * 8. );
839 conf.engine_vol = vol;
841 snprintf( buf,
sizeof( buf ), _(
"%s: %s" ), label, _(
"Muted" ) );
844 -48. / log( 0.00390625 );
846 snprintf( buf,
sizeof( buf ), _(
"%s: %.2f (%.0f dB)" ), label, vol,
847 log( logvol ) * magic );
849 window_modifyText( wid,
"txtEngine", buf );
860 char buf[32], *widget;
861 double vol = window_getFaderValue( wid, str );
862 if ( strcmp( str,
"fadSound" ) == 0 ) {
872 window_modifyText( wid, widget, buf );
885 const char *str = type ? _(
"Music Volume" ) : _(
"Sound Volume" );
889 snprintf( buf, max, _(
"%s: %s" ), str, _(
"Muted" ) );
892 -48. / log( 0.00390625 );
894 snprintf( buf, max, _(
"%s: %.2f (%.0f dB)" ), str, pos,
895 log( vol ) * magic );
920 window_addCheckbox( wid, x, y, cw, 20,
"chkNosound",
921 _(
"Disable all sound/music" ), NULL, conf.nosound );
924 window_addCheckbox( wid, x, y, cw, 20,
"chkEFX", _(
"EFX (More CPU)" ), NULL,
930 window_addText( wid, x, y, cw - 40, 20, 0,
"txtSVolume", NULL, cHeader,
931 _(
"Volume Levels:" ) );
935 window_addText( wid, x, y, cw, 20, 1,
"txtSound", NULL, NULL, NULL );
937 window_addFader( wid, x, y, cw, 20,
"fadSound", 0., 1.,
sound_getVolume(),
939 window_faderScrollDone( wid,
"fadSound", opt_beep );
943 window_addText( wid, x, y, cw, 20, 1,
"txtMusic", NULL, NULL, NULL );
945 window_addFader( wid, x, y, cw, 20,
"fadMusic", 0., 1.,
music_getVolume(),
950 window_addText( wid, x, y, cw, 20, 1,
"txtEngine", NULL, NULL, NULL );
952 window_addFader( wid, x, y, cw, 20,
"fadEngine", 0., 1., conf.engine_vol,
953 opt_setEngineLevel );
954 opt_setEngineLevel( wid,
"fadEngine" );
959static void opt_beep(
unsigned int wid,
const char *str )
974 f = window_checkboxState( wid,
"chkNosound" );
975 if ( conf.nosound != f ) {
980 f = window_checkboxState( wid,
"chkEFX" );
981 if ( conf.al_efx != f ) {
987 conf.sound = window_getFaderValue( wid,
"fadSound" );
988 conf.music = window_getFaderValue( wid,
"fadMusic" );
989 conf.engine_vol = window_getFaderValue( wid,
"fadEngine" );
1003 window_faderValue( wid,
"fadSound", SOUND_VOLUME_DEFAULT );
1004 window_faderValue( wid,
"fadMusic", MUSIC_VOLUME_DEFAULT );
1005 window_faderValue( wid,
"fadEngine", ENGINE_VOLUME_DEFAULT );
1008 window_checkboxSet( wid,
"chkNosound", MUTE_SOUND_DEFAULT );
1009 window_checkboxSet( wid,
"chkEFX", USE_EFX_DEFAULT );
1018 window_checkboxSet( wid,
"chkNosound", conf.nosound );
1019 window_checkboxSet( wid,
"chkEFX", conf.al_efx );
1022 window_faderValue( wid,
"fadSound", conf.sound );
1023 window_faderValue( wid,
"fadMusic", conf.music );
1024 window_faderValue( wid,
"fadEngine", conf.engine_vol );
1032 unsigned int parent;
1034 int key, test_key_event;
1036 KeySemanticType boundkey;
1039 switch ( event->type ) {
1041 key =
event->key.keysym.sym;
1043 test_key_event = ( key == SDLK_NUMLOCKCLEAR ) ||
1044 ( key == SDLK_CAPSLOCK ) || ( key == SDLK_SCROLLLOCK ) ||
1045 ( key == SDLK_RSHIFT ) || ( key == SDLK_LSHIFT ) ||
1046 ( key == SDLK_RCTRL ) || ( key == SDLK_LCTRL ) ||
1047 ( key == SDLK_RALT ) || ( key == SDLK_LALT ) ||
1048 ( key == SDLK_RGUI ) || ( key == SDLK_LGUI );
1053 type = KEYBIND_KEYBOARD;
1054 if ( window_checkboxState( wid,
"chkAny" ) )
1057 SDL_Keymod ev_mod =
event->key.keysym.mod;
1059 if ( ev_mod & ( KMOD_LSHIFT | KMOD_RSHIFT ) )
1061 if ( ev_mod & ( KMOD_LCTRL | KMOD_RCTRL ) )
1063 if ( ev_mod & ( KMOD_LALT | KMOD_RALT ) )
1065 if ( ev_mod & ( KMOD_LGUI | KMOD_RGUI ) )
1072 case SDL_JOYAXISMOTION:
1073 if ( event->jaxis.value > 0 )
1074 type = KEYBIND_JAXISPOS;
1075 else if ( event->jaxis.value < 0 )
1076 type = KEYBIND_JAXISNEG;
1079 key =
event->jaxis.axis;
1083 case SDL_JOYBUTTONDOWN:
1084 type = KEYBIND_JBUTTON;
1085 key =
event->jbutton.button;
1089 case SDL_JOYHATMOTION:
1090 switch ( event->jhat.value ) {
1092 type = KEYBIND_JHAT_UP;
1095 type = KEYBIND_JHAT_DOWN;
1098 type = KEYBIND_JHAT_LEFT;
1101 type = KEYBIND_JHAT_RIGHT;
1106 key =
event->jhat.hat;
1117 if ( ( boundkey >= 0 ) && ( boundkey < KST_END ) &&
1120 _(
"Key '#b%s#0' overlaps with key '#b%s#0' that was just set. "
1121 "You may want to correct this." ),
1145 unsigned int new_wid;
1154 new_wid =
window_create(
"wdwSetKey", _(
"Set Keybinding" ), -1, -1, w, h );
1160 new_wid, 20, -40, w - 40, 60, 0,
"txtInfo", NULL, NULL,
1161 _(
"To use a modifier key hit that key twice in a row, otherwise it "
1162 "will register as a modifier. To set with any modifier click the "
1174 window_addCheckbox( new_wid, -20, 20 +
BUTTON_HEIGHT + 20, w - 40, 20,
1175 "chkAny", _(
"Set any modifier" ), NULL, 0 );
1184 unsigned int parent;
1203 const char *colourblind_types[] = {
1204 _(
"Protanopia" ), _(
"Deuteranopia" ), _(
"Tritanopia" ),
1205 _(
"Rod Monochromacy" ), _(
"Cone Monochromacy" ),
1207 int ntypes =
sizeof( colourblind_types ) /
sizeof( colourblind_types[0] );
1208 char **types = malloc( ntypes *
sizeof(
char *) );
1209 for (
int i = 0; i < ntypes; i++ )
1210 types[i] = strdup( colourblind_types[i] );
1223 cw = ( w - 60 ) / 2;
1228 window_addText( wid, x, y, 100, 20, 0,
"txtSVideo", NULL, cHeader,
1231 window_addText( wid, x, y - 3, cw - 20, 20, 0,
"txtSaturation", NULL, NULL,
1234 window_addFader( wid, x + 20, y, cw - 60, 20,
"fadSaturation", 0., 1.,
1235 conf.nebu_saturation, opt_setSaturation );
1236 opt_setSaturation( wid,
"fadSaturation" );
1238 window_addText( wid, x, y - 3, cw - 20, 20, 0,
"txtNebuNonuniformity", NULL,
1241 window_addFader( wid, x + 20, y, cw - 60, 20,
"fadNebuNonuniformity", 0., 1.,
1245 window_addText( wid, x, y - 3, cw - 20, 20, 0,
"txtBGBrightness", NULL, NULL,
1248 window_addFader( wid, x + 20, y, cw - 60, 20,
"fadBGBrightness", 0., 1.,
1252 window_addText( wid, x, y - 3, cw - 20, 20, 0,
"txtJumpBrightness", NULL,
1255 window_addFader( wid, x + 20, y, cw - 60, 20,
"fadJumpBrightness", 0., 1.,
1264 window_addText( wid, x, y - 3, cw - 20, 20, 0,
"txtColourblind", NULL, NULL,
1265 _(
"Colourblind type:" ) );
1267 window_addList( wid, x, y, cw, 100,
"lstColourblind", (
char **)types, ntypes,
1270 window_addText( wid, x, y - 3, cw - 20, 20, 0,
"txtColourblindCorrect", NULL,
1273 window_addFader( wid, x + 20, y, cw - 60, 20,
"fadColourblindCorrect", 0.,
1277 window_addText( wid, x, y - 3, cw - 20, 20, 0,
"txtColourblindSimulate",
1280 window_addFader( wid, x + 20, y, cw - 60, 20,
"fadColourblindSimulate", 0.,
1285 window_addText( wid, x, y, cw - 20, 20, 0,
"txtSGameplay", NULL, cHeader,
1288 window_addCheckbox( wid, x, y, cw - 20, 20,
"chkPuzzleSkip",
1289 _(
"Allow skipping puzzles" ), NULL, conf.puzzle_skip );
1291 window_addText( wid, x, y - 3, cw - 20, 20, 0,
"txtGameSpeed", NULL, NULL,
1294 window_addFader( wid, x + 20, y, cw - 60, 20,
"fadGameSpeed", 0.1, 1.,
1295 conf.game_speed, opt_setGameSpeed );
1296 opt_setGameSpeed( wid,
"fadGameSpeed" );
1299static int opt_accessibilitySave(
unsigned int wid,
const char *str )
1305 conf.puzzle_skip = window_checkboxState( wid,
"chkPuzzleSkip" );
1319 window_faderSetBoundedValue( wid,
"fadNebuNonuniformity",
1320 NEBU_NONUNIFORMITY_DEFAULT );
1321 window_faderSetBoundedValue( wid,
"fadBGBrightness", BG_BRIGHTNESS_DEFAULT );
1322 window_faderSetBoundedValue( wid,
"fadJumpBrightness",
1323 JUMP_BRIGHTNESS_DEFAULT );
1324 window_faderSetBoundedValue( wid,
"fadColourblindCorrect",
1325 COLOURBLIND_CORRECT_DEFAULT );
1326 window_faderSetBoundedValue( wid,
"fadColourblindSimulate",
1327 COLOURBLIND_CORRECT_DEFAULT );
1330 window_checkboxSet( wid,
"chkPuzzleSkip", PUZZLE_SKIP_DEFAULT );
1341 int i, j, nres, res_def;
1343 int cw, w, h, y, x, l;
1358 cw = ( w - 60 ) / 2;
1361 window_addText( wid, x, y, 100, 20, 0,
"txtSRes", NULL, cHeader,
1362 _(
"Resolution:" ) );
1364 window_addInput( wid, x, y, 100, 20,
"inpRes", 16, 1, NULL );
1365 window_setInputFilter( wid,
"inpRes", INPUT_FILTER_RESOLUTION );
1366 window_addCheckbox( wid, x + 20 + 100, y, 100, 20,
"chkFullscreen",
1367 _(
"Fullscreen" ), NULL, conf.fullscreen );
1369 SDL_DisplayMode mode;
1371 int display_index = SDL_GetWindowDisplayIndex(
gl_screen.window );
1372 int n = SDL_GetNumDisplayModes( display_index );
1374 for ( i = 0; i < n; i++ ) {
1375 SDL_GetDisplayMode( display_index, i, &mode );
1376 if ( ( mode.w == conf.width ) && ( mode.h == conf.height ) )
1379 res = malloc(
sizeof(
char *) * ( i + j ) );
1383 SDL_asprintf( &res[0],
"%dx%d", conf.width, conf.height );
1386 for ( i = 0; i < n; i++ ) {
1387 SDL_GetDisplayMode( display_index, i, &mode );
1388 SDL_asprintf( &res[nres],
"%dx%d", mode.w, mode.h );
1391 for ( k = 0; k < nres; k++ )
1392 if ( strcmp( res[k], res[nres] ) == 0 )
1400 if ( ( mode.w == conf.width ) && ( mode.h == conf.height ) )
1404 window_addList( wid, x, y, 140, 100,
"lstRes", res, nres, -1,
opt_videoRes,
1407 window_addText( wid, x, y - 3, 130, 20, 0,
"txtScale", NULL, NULL, NULL );
1408 window_addFader( wid, x + 140, y, cw - 160, 20,
"fadScale", log( 1. ),
1412 window_addText( wid, x, y - 3, 130, 20, 0,
"txtZoomFar", NULL, NULL, NULL );
1413 window_addFader( wid, x + 140, y, cw - 160, 20,
"fadZoomFar", log1p( 0.1 ),
1416 window_addText( wid, x, y - 3, 130, 20, 0,
"txtZoomNear", NULL, NULL, NULL );
1417 window_addFader( wid, x + 140, y, cw - 160, 20,
"fadZoomNear", log1p( 0.1 ),
1422 window_addText( wid, x, y - 3, 130, 20, 0,
"txtGammaCorrection", NULL, NULL,
1424 window_addFader( wid, x + 140, y, cw - 160, 20,
"fadGammaCorrection",
1425 -log( 3. ), log( 3. ), log( conf.gamma_correction ),
1431 window_addText( wid, x, y, 100, 20, 0,
"txtFPSTitle", NULL, cHeader,
1432 _(
"FPS Control:" ) );
1434 s = _(
"FPS Limit" );
1436 window_addText( wid, x, y, l, 20, 1,
"txtSFPS", NULL, NULL, s );
1437 window_addInput( wid, x + l + 20, y, 40, 20,
"inpFPS", 4, 1, NULL );
1438 toolkit_setListPos( wid,
"lstRes", res_def );
1439 window_setInputFilter( wid,
"inpFPS", INPUT_FILTER_NUMBER );
1440 snprintf( buf,
sizeof( buf ),
"%d", conf.fps_max );
1441 window_setInput( wid,
"inpFPS", buf );
1442 window_addCheckbox( wid, x + l + 20 + 40 + 20, y, cw, 20,
"chkFPS",
1443 _(
"Show FPS" ), NULL, conf.fps_show );
1451 window_addText( wid, x, y, 100, 20, 0,
"txtSGL", NULL, cHeader,
1454 window_addCheckbox( wid, x, y, cw, 20,
"chkLowMemory",
1458 window_addCheckbox( wid, x, y, cw, 20,
"chkVSync", _(
"Vertical Sync" ),
1463 window_addText( wid, x, y, 100, 20, 0,
"txtSFeatures", NULL, cHeader,
1466 window_addCheckbox( wid, x, y, cw, 20,
"chkMinimize",
1467 _(
"Minimize on focus loss" ), NULL, conf.minimize );
1469 window_addCheckbox( wid, x, y, cw, 20,
"chkHealth",
1473 window_addText( wid, x, y - 3, cw - 20, 20, 0,
"txtMOpacity", NULL, NULL,
1476 window_addFader( wid, x + 20, y, cw - 60, 20,
"fadMapOverlayOpacity", 0., 1.,
1482 window_addText( wid, x, y, 100, 20, 0,
"txtSGUI", NULL, cHeader,
1485 window_addCheckbox( wid, x, y, cw, 20,
"chkBigIcons", _(
"Bigger icons" ),
1486 NULL, conf.big_icons );
1494 const char *s = _(
"#rRestart Naev for changes to take effect.#0" );
1498 for (
int i = 0; i < OPT_WINDOWS; i++ )
1499 window_modifyText( opt_windows[i],
"txtRestart", s );
1507 const char *buf = toolkit_getList( wid, str );
1508 window_setInput( wid,
"inpRes", buf );
1518 int ret, w, h, f, fullscreen;
1521 inp = window_getInput( wid,
"inpRes" );
1522 ret = sscanf( inp,
" %d %*[^0-9] %d", &w, &h );
1523 if ( ret != 2 || w <= 0 || h <= 0 ) {
1525 _(
"Height/Width invalid. Should be formatted like 1024x768." ) );
1530 fullscreen = window_checkboxState( wid,
"chkFullscreen" );
1533 if ( ( conf.width != w ) || ( conf.height != h ) ||
1534 ( fullscreen != conf.fullscreen ) ) {
1536 window_checkboxSet( wid,
"chkFullscreen", conf.fullscreen );
1542 conf.fps_show = window_checkboxState( wid,
"chkFPS" );
1543 inp = window_getInput( wid,
"inpFPS" );
1544 conf.fps_max = atoi( inp );
1547 f = window_checkboxState( wid,
"chkLowMemory" );
1548 if ( conf.low_memory != f ) {
1549 conf.low_memory = f;
1552 f = window_checkboxState( wid,
"chkVSync" );
1553 if ( conf.vsync != f ) {
1559 f = window_checkboxState( wid,
"chkMinimize" );
1560 if ( conf.minimize != f ) {
1562 SDL_SetHint( SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS,
1563 conf.minimize ?
"1" :
"0" );
1567 conf.big_icons = window_checkboxState( wid,
"chkBigIcons" );
1580 char buf[STRMAX_SHORT];
1581 conf.colourblind_correct = window_getFaderValue( wid, str );
1582 if ( conf.colourblind_correct > 0. )
1583 snprintf( buf,
sizeof( buf ), _(
"Colourblind correction: %.2f" ),
1584 conf.colourblind_correct );
1586 snprintf( buf,
sizeof( buf ), _(
"Colourblind correction: off" ) );
1587 window_modifyText( wid,
"txtColourblindCorrect", buf );
1596 char buf[STRMAX_SHORT];
1597 conf.colourblind_sim = window_getFaderValue( wid, str );
1598 if ( conf.colourblind_sim > 0. )
1599 snprintf( buf,
sizeof( buf ), _(
"Colourblind simulation: %.2f" ),
1600 conf.colourblind_sim );
1602 snprintf( buf,
sizeof( buf ), _(
"Colourblind simulation: off" ) );
1603 window_modifyText( wid,
"txtColourblindSimulate", buf );
1612 conf.colourblind_type = toolkit_getListPos( wid, str );
1621 int f = window_checkboxState( wid, str );
1622 conf.healthbars = f;
1648 int old_conf_w, old_conf_h, old_conf_f, status;
1649 int old_w, old_h, old_f, old_exp, new_w, new_h, new_f;
1650 int changed_size, maximized;
1653 old_conf_w = conf.width;
1654 old_conf_h = conf.height;
1655 old_conf_f = conf.fullscreen;
1656 old_exp = conf.explicit_dim;
1659 conf.fullscreen = fullscreen;
1661 conf.explicit_dim || ( w != old_conf_w ) || ( h != old_conf_h );
1664 if ( status == 0 && !fullscreen && ( w != old_w || h != old_h ) ) {
1665 SDL_SetWindowSize(
gl_screen.window, w, h );
1666 SDL_SetWindowPosition(
gl_screen.window, SDL_WINDOWPOS_CENTERED,
1667 SDL_WINDOWPOS_CENTERED );
1672 changed_size = ( new_w != old_w ) || ( new_h != old_h );
1673 maximized = !new_f && ( SDL_GetWindowFlags(
gl_screen.window ) &
1674 SDL_WINDOW_MAXIMIZED );
1676 if ( confirm && !changed_size && maximized )
1678 if ( confirm && ( ( status != 0 ) || ( new_f != fullscreen ) ) )
1681 if ( confirm && ( ( status != 0 ) || changed_size || ( new_f != old_f ) ) &&
1683 _(
"Do you want to keep running at %dx%d %s?" ), new_w,
1685 new_f ? _(
"fullscreen" ) : _(
"windowed" ) ) ) {
1688 conf.explicit_dim = old_exp;
1691 _(
"Resolution reset to %dx%d %s." ), old_w, old_h,
1692 conf.fullscreen ? _(
"fullscreen" ) : _(
"windowed" ) );
1712 SDL_DisplayMode mode;
1720 ( SDL_GetWindowFlags(
gl_screen.window ) & SDL_WINDOW_FULLSCREEN ) != 0;
1721 if ( *fullscreen && conf.modesetting ) {
1722 SDL_GetWindowDisplayMode(
gl_screen.window, &mode );
1726 SDL_GetWindowSize(
gl_screen.window, w, h );
1739 snprintf( buf,
sizeof( buf ),
"%dx%d", RESOLUTION_W_DEFAULT,
1740 RESOLUTION_H_DEFAULT );
1741 window_setInput( wid,
"inpRes", buf );
1742 snprintf( buf,
sizeof( buf ),
"%d", FPS_MAX_DEFAULT );
1743 window_setInput( wid,
"inpFPS", buf );
1746 window_checkboxSet( wid,
"chkFullscreen", FULLSCREEN_DEFAULT );
1747 window_checkboxSet( wid,
"chkVSync", VSYNC_DEFAULT );
1748 window_checkboxSet( wid,
"chkFPS", SHOW_FPS_DEFAULT );
1749 window_checkboxSet( wid,
"chkMinimize", MINIMIZE_DEFAULT );
1750 window_checkboxSet( wid,
"chkBigIcons", BIG_ICONS_DEFAULT );
1753 window_faderSetBoundedValue( wid,
"fadScale", log( SCALE_FACTOR_DEFAULT ) );
1754 window_faderSetBoundedValue( wid,
"fadZoomFar", log1p( ZOOM_FAR_DEFAULT ) );
1755 window_faderSetBoundedValue( wid,
"fadZoomNear",
1756 log1p( ZOOM_NEAR_DEFAULT ) );
1757 window_faderSetBoundedValue(
1758 wid,
"fadGammaCorrection",
1759 log( GAMMA_CORRECTION_DEFAULT ) );
1760 window_faderSetBoundedValue( wid,
"fadMapOverlayOpacity",
1761 MAP_OVERLAY_OPACITY_DEFAULT );
1772 char buf[STRMAX_SHORT];
1773 double scale = window_getFaderValue( wid, str );
1775 conf.scalefactor = exp( scale );
1776 snprintf( buf,
sizeof( buf ), _(
"Scaling: %.1fx" ), conf.scalefactor );
1777 window_modifyText( wid,
"txtScale", buf );
1778 if (
FABS( conf.scalefactor - local_conf.scalefactor ) > 1e-4 )
1790 char buf[STRMAX_SHORT];
1791 double scale = window_getFaderValue( wid, str );
1793 conf.zoom_far = expm1( scale );
1794 snprintf( buf,
sizeof( buf ), _(
"Far Zoom: %.1fx" ), conf.zoom_far );
1795 window_modifyText( wid,
"txtZoomFar", buf );
1796 if ( conf.zoom_far > conf.zoom_near ) {
1797 window_faderSetBoundedValue( wid,
"fadZoomNear", log1p( conf.zoom_far ) );
1800 if (
FABS( conf.zoom_far - local_conf.zoom_far ) > 1e-4 )
1812 char buf[STRMAX_SHORT];
1813 double scale = window_getFaderValue( wid, str );
1815 conf.zoom_near = expm1( scale );
1816 snprintf( buf,
sizeof( buf ), _(
"Near Zoom: %.1fx" ), conf.zoom_near );
1817 window_modifyText( wid,
"txtZoomNear", buf );
1818 if ( conf.zoom_near < conf.zoom_far ) {
1819 window_faderSetBoundedValue( wid,
"fadZoomFar", log1p( conf.zoom_near ) );
1822 if (
FABS( conf.zoom_near - local_conf.zoom_near ) > 1e-4 )
1834 char buf[STRMAX_SHORT];
1835 double scale = window_getFaderValue( wid, str );
1836 conf.gamma_correction = exp( scale );
1837 snprintf( buf,
sizeof( buf ), _(
"Gamma: %.1f" ), conf.gamma_correction );
1838 window_modifyText( wid,
"txtGammaCorrection", buf );
1839 render_setGamma( conf.gamma_correction );
1850 char buf[STRMAX_SHORT];
1851 double fad = window_getFaderValue( wid, str );
1852 conf.bg_brightness = fad;
1853 snprintf( buf,
sizeof( buf ), _(
"BG (Stars, etc.) brightness: %.0f%%" ),
1855 window_modifyText( wid,
"txtBGBrightness", buf );
1858static void opt_setSaturation(
unsigned int wid,
const char *str )
1860 char buf[STRMAX_SHORT];
1861 double fad = window_getFaderValue( wid, str );
1862 conf.nebu_saturation = fad;
1864 nebu_updateColour();
1867 snprintf( buf,
sizeof( buf ), _(
"Nebula saturation: %.0f%%" ), 100. * fad );
1868 window_modifyText( wid,
"txtSaturation", buf );
1879 char buf[STRMAX_SHORT];
1880 double fad = window_getFaderValue( wid, str );
1881 conf.nebu_nonuniformity = fad;
1882 snprintf( buf,
sizeof( buf ), _(
"Nebula non-uniformity: %.0f%%" ),
1884 window_modifyText( wid,
"txtNebuNonuniformity", buf );
1895 char buf[STRMAX_SHORT];
1896 double fad = window_getFaderValue( wid, str );
1897 conf.jump_brightness = fad;
1898 snprintf( buf,
sizeof( buf ), _(
"Jump brightness: %.0f%%" ), 100. * fad );
1899 window_modifyText( wid,
"txtJumpBrightness", buf );
1902static void opt_setGameSpeed(
unsigned int wid,
const char *str )
1904 char buf[STRMAX_SHORT];
1905 double prevspeed = conf.game_speed;
1906 conf.game_speed = window_getFaderValue( wid, str );
1907 player.speed *= conf.game_speed / prevspeed;
1909 snprintf( buf,
sizeof( buf ), _(
"Game speed: %.0f%%" ),
1910 100. * conf.game_speed );
1911 window_modifyText( wid,
"txtGameSpeed", buf );
1922 char buf[STRMAX_SHORT];
1923 double fad = window_getFaderValue( wid, str );
1924 conf.map_overlay_opacity = fad;
1925 snprintf( buf,
sizeof( buf ), _(
"Map Overlay Opacity: %.0f%%" ),
1927 window_modifyText( wid,
"txtMOpacity", buf );
1936 char buf[STRMAX_SHORT];
1941 lw = w - 40 - 2 * ( bw + 20 );
1944 snprintf( buf,
sizeof( buf ),
"#n%s#0%s%s", _(
"Plugins Directory: " ),
1945 PHYSFS_getRealDir(
"plugins" ),
"plugins" );
1946 window_addText( wid, 20, -30, w - 40, 30, 1,
"txtPath", NULL, NULL, buf );
1947 window_addText( wid, -20, -70, w - ( 20 + lw + 20 + 20 ), h - 100, 0,
1948 "txtDesc", NULL, NULL, NULL );
1950 opt_plugins_regenList( wid );
1968static void opt_plugins_regenList(
unsigned int wid )
1970 int w, h, lw, lh, bw, n, p;
1977 lw = w - 40 - 2 * ( bw + 20 );
1982 p = toolkit_getListPos( wid,
"lstPlugins" );
1988 str = malloc(
sizeof(
char *) * 1 );
1989 str[0] = strdup( _(
"No Plugins Found" ) );
1992 str = malloc(
sizeof(
char * ) * n );
1993 for (
int i = 0; i < n; i++ )
1996 window_addList( wid, 20, -70, lw, lh,
"lstPlugins", str, n, p,
1997 opt_plugins_update, NULL );
2000static void opt_plugins_add_callback(
void *userdata,
2001 const char *
const *filelist,
int filter )
2004 unsigned int wid = *(
unsigned int *)userdata;
2006 char buf[STRMAX], buf_susp[STRMAX], path[
PATH_MAX], *fname;
2010 if ( filelist == NULL ) {
2011 WARN( _(
"Error calling %s: %s" ),
"SDL_ShowOpenFileDialog",
2014 }
else if ( filelist[0] == NULL ) {
2021 if ( plg == NULL ) {
2022 dialogue_alert( _(
"'%s' is not a valid plugin!" ), filelist[0] );
2027 for (
int i = 0; i <
array_size( plgs ); i++ ) {
2030 plg_susp = &plgs[i];
2031 snprintf( buf_susp,
sizeof( buf_susp ),
2035 "#nDescription:#0 %s" ),
2043 fname = strdup( filelist[0] );
2044 nfile_concatPaths( path,
sizeof( path ),
plugin_dir(), basename( fname ) );
2048 snprintf( buf,
sizeof( buf ),
2052 "#nDescription:#0 %s" ),
2059 _(
"Update plugin?" ),
2060 _(
"Are you sure you want to update the plugin '%s'? This "
2061 "will require a restart to take full "
2062 "effect.\n\n#nNew Plugin Details#0\n%s\n\n#nOld Plugin "
2070 fname = strdup( filelist[0] );
2072 _(
"Overwrite plugin?" ),
2073 _(
"Are you sure you want to add '%s' to your list of active "
2074 "plugins? This will overwrite a plugin with the same file "
2075 "name (%s), but not same plug in name. This will require a "
2076 "restart to take full "
2077 "effect.\n\n#nNew Plugin Details#0\n%s" ),
2086 }
else if ( !suspicious ) {
2089 _(
"Are you sure you want to add '%s' to your list of active "
2090 "plugins? This will require a restart to take full "
2091 "effect.\n\n#nNew Plugin Details#0\n%s" ),
2100 _(
"Are you sure you want to add '%s' to your list of active "
2101 "plugins? #rThis plugin has the same name as one of your "
2102 "existing plugins and make cause issues#0. This will require "
2103 "a restart to take full effect.\n\n#nNew Plugin "
2104 "Details#0\n%s\n\n#nSame name Plugin Details#0\n%s" ),
2114 dialogue_alert( _(
"Failed to copy '%s' to '%s'!" ), filelist[0], path );
2124 opt_plugins_regenList( wid );
2126static void opt_plugins_add(
unsigned int wid,
const char *name )
2130 { .name = _(
"Naev Plugin File" ), .pattern =
"zip" },
2134 SDL_ShowOpenFileDialog( opt_plugins_add_callback, &wid,
gl_screen.window,
2135 filter, conf.dev_data_dir, 0 );
2138static void opt_plugins_update(
unsigned int wid,
const char *name )
2142 int pos = toolkit_getListPos( wid, name );
2149 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"#n%s#0\n",
2150 p_(
"plugins",
"Name:" ) );
2151 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
" %s\n",
2153 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"#n%s#0\n",
2154 p_(
"plugins",
"Author(s):" ) );
2155 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
" %s\n", _( plg->
author ) );
2156 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"#n%s#0\n",
2157 p_(
"plugins",
"Version:" ) );
2159 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"#n%s#0\n",
2160 p_(
"plugins",
"Description:" ) );
2164 scnprintf( &buf[l],
sizeof( buf ) - l,
"#g%s#0",
2165 _(
"Total Conversion" ) );
2167 window_modifyText( wid,
"txtDesc", buf );
Provides macros to work with dynamic arrays.
#define array_free(ptr_array)
Frees memory allocated and sets array to NULL.
static ALWAYS_INLINE int array_size(const void *array)
Returns number of elements in the array.
int background_load(const char *name)
Loads a background script by name.
char * dialogue_runChoice(void)
Run the dialog and return the clicked string.
void dialogue_alert(const char *fmt,...)
Displays an alert popup with only an ok button and a message.
void dialogue_msg(const char *caption, const char *fmt,...)
Opens a dialogue window with an ok button and a message.
void dialogue_addChoice(const char *caption, const char *msg, const char *opt)
Add a choice to the dialog.
void dialogue_alertRaw(const char *msg)
Displays an alert popup with only an ok button and a message.
void dialogue_makeChoice(const char *caption, const char *msg, int opts)
Create the choice dialog. Need to add choices with below method.
void dialogue_msgRaw(const char *caption, const char *msg)
Opens a dialogue window with an ok button and a fixed message.
int dialogue_YesNo(const char *caption, const char *fmt,...)
Runs a dialogue with both yes and no options.
int gl_printWidthRaw(const glFont *ft_font, const char *text)
Gets the width that it would take to print some text.
void gl_freeFont(glFont *font)
Frees a loaded font. Caution: its glFontStash still has a slot in avail_fonts. At the time of writing...
int gl_fontInit(glFont *font, const char *fname, const unsigned int h, const char *prefix, unsigned int flags)
Initializes a font.
double gettext_languageCoverage(const char *lang)
Return the fraction of strings which have a translation into the given language.
void gettext_setLanguage(const char *lang)
Set the translation language.
const char * pgettext_var(const char *msgctxt, const char *msgid)
LanguageOption * gettext_languageOptions(void)
List the available languages, with completeness statistics.
const char * gettext_getSystemLanguage(void)
Gets the current system language as detected by Naev.
double music_getVolumeLog(void)
Gets the current music volume (logarithmic).
double music_getVolume(void)
Gets the current music volume (linear).
int music_volume(double vol)
Sets the music volume from a linear value.
void naev_resize(void)
Wrapper for gl_resize that handles non-GL reinitialization.
Header file with generic functions and naev-specifics.
const char * naev_version(int long_version)
Returns the version in a human readable string.
int nfile_copyIfExists(const char *file1, const char *file2)
Copy a file, if it exists.
const char * nfile_configPath(void)
Gets Naev's config path (for user preferences such as conf.lua)
int nfile_fileExists(const char *path)
Checks to see if a file exists.
int scnprintf(char *text, size_t maxlen, const char *fmt,...)
Like snprintf(), but returns the number of characters ACTUALLY "printed" into the buffer....
int strsort_reverse(const void *p1, const void *p2)
Order-reversed version of strsort().
void gl_colourblind(void)
Enables or disables the colourblind shader.
int gl_setupFullscreen(void)
Tries to apply the configured display mode to the window.
static void opt_gameplay(unsigned int wid)
Opens the gameplay menu.
int opt_setVideoMode(int w, int h, int fullscreen, int confirm)
Applies new video-mode options.
static void opt_listColourblind(unsigned int wid, const char *str)
Handles the colourblind mode change.
static void opt_keyDefaults(unsigned int wid, const char *str)
Restores the key defaults.
static void opt_accessibilityDefaults(unsigned int wid, const char *str)
Sets video defaults.
static void menuKeybinds_getDim(unsigned int wid, int *w, int *h, int *lw, int *lh, int *bw, int *bh)
Gets the keybind menu dimensions.
static void opt_needRestart(void)
Marks that needs restart.
static void opt_checkRestart(unsigned int wid, const char *str)
Basically flags for needing a restart.
static void opt_getVideoMode(int *w, int *h, int *fullscreen)
Detects the video-mode options corresponding to the gl_screen we have set up.
static void opt_checkHealth(unsigned int wid, const char *str)
Handles the health bar checkbox.
static void opt_setAudioLevel(unsigned int wid, const char *str)
Callback to set the sound or music level.
static void opt_audioUpdate(unsigned int wid)
Updates the gameplay options.
static void opt_setZoomNear(unsigned int wid, const char *str)
Callback to set the far zoom.
void opt_resize(void)
Handles resize events for the options menu.
static void opt_setNebuNonuniformity(unsigned int wid, const char *str)
Callback to set the nebula non-uniformity parameter.
static void opt_setJumpBrightness(unsigned int wid, const char *str)
Callback to set the background brightness.
static void opt_OK(unsigned int wid, const char *str)
Saves all options and closes the options screen.
static void opt_videoDefaults(unsigned int wid, const char *str)
Sets video defaults.
static void opt_audioDefaults(unsigned int wid, const char *str)
Sets the audio defaults.
static void opt_setBGBrightness(unsigned int wid, const char *str)
Callback to set the background brightness.
static void opt_keybinds(unsigned int wid)
Opens the keybindings menu.
static void menuKeybinds_genList(unsigned int wid)
Generates the keybindings list.
static int opt_lastKeyPress
static void opt_plugins(unsigned int wid)
Opens the keybindings menu.
static void opt_accessibility(unsigned int wid)
Initializes the accessibility window.
static void opt_setColourblindSimulate(unsigned int wid, const char *str)
Handles the colourblind correction.
static int opt_videoSave(unsigned int wid, const char *str)
Saves the video settings.
static void opt_audioLevelStr(char *buf, int max, int type, double pos)
Sets the sound or music volume string based on level.
static void opt_unsetKey(unsigned int wid, const char *str)
Unsets the key.
static void opt_video(unsigned int wid)
Initializes the video window.
static void opt_setMapOverlayOpacity(unsigned int wid, const char *str)
Callback to set autonav abort threshold.
void opt_menu(void)
Creates the options menu thingy.
static KeySemanticType opt_selectedKeybind
static void opt_setKey(unsigned int wid, const char *str)
Rebinds a key.
static void opt_audio(unsigned int wid)
Opens the audio settings menu.
static void opt_close(unsigned int wid, const char *name)
Closes the options screen without saving.
static void menuKeybinds_update(unsigned int wid, const char *name)
Updates the keybindings menu.
static void opt_gameplayUpdate(unsigned int wid, const char *str)
Updates the gameplay options.
static void opt_setColourblindCorrect(unsigned int wid, const char *str)
Handles the colourblind correction.
static void opt_gameplayDefaults(unsigned int wid, const char *str)
Sets the default gameplay options.
static void opt_setGammaCorrection(unsigned int wid, const char *str)
Callback to set the gamma correction value (reciprocal of exponent).
static int opt_setKeyEvent(unsigned int wid, SDL_Event *event)
Tries to set the key from an event.
static int opt_gameplaySave(unsigned int wid, const char *str)
Saves the gameplay options.
static void opt_videoRes(unsigned int wid, const char *str)
Callback when resolution changes.
static int opt_audioSave(unsigned int wid, const char *str)
Saves the audio stuff.
static void opt_setScalefactor(unsigned int wid, const char *str)
Callback to set the scaling factor.
static void opt_setZoomFar(unsigned int wid, const char *str)
Callback to set the far zoom.
void pause_setSpeed(double mod)
Adjusts the game's dt modifier.
void pilot_calcStats(Pilot *pilot)
Recalculates the pilot's stats based on his outfits.
void player_soundPlayGUI(int sound, int once)
Plays a GUI sound (unaffected by time accel).
plugin_t * plugin_test(const char *filename)
Tests to see if a file is a plugin and loads information.
void plugin_insert(plugin_t *plg)
Inserts a plugin to the list, but does not properly enable it (requires restart).
const char * plugin_name(const plugin_t *plg)
Tries to tget the name of a plugin.
const char * plugin_dir(void)
Gets the plugin directory.
void plugin_free(plugin_t *plg)
Frees a previously allocated plugin.
const plugin_t * plugin_list(void)
Returns the list of all the plugins.
double sound_getVolumeLog(void)
Gets the current sound volume (logarithmic).
double sound_getVolume(void)
Gets the current sound volume (linear).
int sound_volume(const double vol)
Sets the volume.
Struct containing player options.