naev 0.12.5
options.c File Reference

Options menu. More...

#include "options.h"
#include "array.h"
#include "background.h"
#include "colour.h"
#include "conf.h"
#include "dialogue.h"
#include "difficulty.h"
#include "input.h"
#include "log.h"
#include "music.h"
#include "ndata.h"
#include "nebula.h"
#include "nfile.h"
#include "nstring.h"
#include "pause.h"
#include "player.h"
#include "plugin.h"
#include "render.h"
#include "sound.h"
#include "toolkit.h"
Include dependency graph for options.c:

Go to the source code of this file.

Macros

#define BUTTON_WIDTH   120
#define BUTTON_HEIGHT   30
#define OPT_WIN_GAMEPLAY   0
#define OPT_WIN_ACCESSIBILITY   1
#define OPT_WIN_VIDEO   2
#define OPT_WIN_AUDIO   3
#define OPT_WIN_INPUT   4
#define OPT_WIN_PLUGINS   5
#define OPT_WINDOWS   6
#define AUTONAV_RESET_DIST_MAX   10e3
#define LANG_CODE_START    7

Functions

static void opt_close (unsigned int wid, const char *name)
 Closes the options screen without saving.
static void opt_needRestart (void)
 Marks that needs restart.
static char ** lang_list (int *n)
static void opt_gameplay (unsigned int wid)
 Opens the gameplay menu.
static void opt_setMapOverlayOpacity (unsigned int wid, const char *str)
 Callback to set autonav abort threshold.
static void opt_OK (unsigned int wid, const char *str)
 Saves all options and closes the options screen.
static int opt_gameplaySave (unsigned int wid, const char *str)
 Saves the gameplay options.
static void opt_gameplayDefaults (unsigned int wid, const char *str)
 Sets the default gameplay options.
static void opt_gameplayUpdate (unsigned int wid, const char *str)
 Updates the gameplay options.
static void opt_accessibility (unsigned int wid)
 Initializes the accessibility window.
static int opt_accessibilitySave (unsigned int wid, const char *str)
static void opt_accessibilityDefaults (unsigned int wid, const char *str)
 Sets video defaults.
static void opt_setBGBrightness (unsigned int wid, const char *str)
 Callback to set the background brightness.
static void opt_setNebuNonuniformity (unsigned int wid, const char *str)
 Callback to set the nebula non-uniformity parameter.
static void opt_setSaturation (unsigned int wid, const char *str)
static void opt_setJumpBrightness (unsigned int wid, const char *str)
 Callback to set the background brightness.
static void opt_setColourblindCorrect (unsigned int wid, const char *str)
 Handles the colourblind correction.
static void opt_setColourblindSimulate (unsigned int wid, const char *str)
 Handles the colourblind correction.
static void opt_listColourblind (unsigned int wid, const char *str)
 Handles the colourblind mode change.
static void opt_setGameSpeed (unsigned int wid, const char *str)
static void opt_video (unsigned int wid)
 Initializes the video window.
static void opt_videoRes (unsigned int wid, const char *str)
 Callback when resolution changes.
static int opt_videoSave (unsigned int wid, const char *str)
 Saves the video settings.
static void opt_videoDefaults (unsigned int wid, const char *str)
 Sets video defaults.
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_setGammaCorrection (unsigned int wid, const char *str)
 Callback to set the gamma correction value (reciprocal of exponent).
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.
static void opt_setZoomNear (unsigned int wid, const char *str)
 Callback to set the far zoom.
static void opt_checkHealth (unsigned int wid, const char *str)
 Handles the health bar checkbox.
static void opt_checkRestart (unsigned int wid, const char *str)
 Basically flags for needing a restart.
static void opt_audio (unsigned int wid)
 Opens the audio settings menu.
static int opt_audioSave (unsigned int wid, const char *str)
 Saves the audio stuff.
static void opt_audioDefaults (unsigned int wid, const char *str)
 Sets the audio defaults.
static void opt_audioUpdate (unsigned int wid)
 Updates the gameplay options.
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_setAudioLevel (unsigned int wid, const char *str)
 Callback to set the sound or music level.
static void opt_setEngineLevel (unsigned int wid, const char *str)
static void opt_beep (unsigned int wid, const char *str)
static void opt_keybinds (unsigned int wid)
 Opens the keybindings menu.
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 menuKeybinds_genList (unsigned int wid)
 Generates the keybindings list.
static void menuKeybinds_update (unsigned int wid, const char *name)
 Updates the keybindings menu.
static void opt_keyDefaults (unsigned int wid, const char *str)
 Restores the key defaults.
static int opt_setKeyEvent (unsigned int wid, SDL_Event *event)
 Tries to set the key from an event.
static void opt_setKey (unsigned int wid, const char *str)
 Rebinds a key.
static void opt_unsetKey (unsigned int wid, const char *str)
 Unsets the key.
static void opt_plugins (unsigned int wid)
 Opens the keybindings menu.
static void opt_plugins_regenList (unsigned int wid)
static void opt_plugins_add (unsigned int wid, const char *name)
static void opt_plugins_update (unsigned int wid, const char *name)
void opt_menu (void)
 Creates the options menu thingy.
void opt_resize (void)
 Handles resize events for the options menu.
int opt_setVideoMode (int w, int h, int fullscreen, int confirm)
 Applies new video-mode options.
static void opt_plugins_add_callback (void *userdata, const char *const *filelist, int filter)

Variables

static unsigned int opt_wid = 0
static unsigned int * opt_windows
static const char * opt_names []
static const glColour * cHeader = &cFontGrey
static int opt_restart = 0
static PlayerConf_t local_conf
static KeySemanticType opt_selectedKeybind
static int opt_lastKeyPress = 0

Detailed Description

Options menu.

Definition in file options.c.

Macro Definition Documentation

◆ AUTONAV_RESET_DIST_MAX

#define AUTONAV_RESET_DIST_MAX   10e3

Definition at line 50 of file options.c.

◆ BUTTON_HEIGHT

#define BUTTON_HEIGHT   30

Button height, standard across menus.

Definition at line 40 of file options.c.

◆ BUTTON_WIDTH

#define BUTTON_WIDTH   120

Button width, standard across menus.

Definition at line 39 of file options.c.

◆ LANG_CODE_START

#define LANG_CODE_START    7

Length of a language-list item's prefix, like the "[ 81%] " in "[ \ 81%] de".

Definition at line 51 of file options.c.

◆ OPT_WIN_ACCESSIBILITY

#define OPT_WIN_ACCESSIBILITY   1

Definition at line 43 of file options.c.

◆ OPT_WIN_AUDIO

#define OPT_WIN_AUDIO   3

Definition at line 45 of file options.c.

◆ OPT_WIN_GAMEPLAY

#define OPT_WIN_GAMEPLAY   0

Definition at line 42 of file options.c.

◆ OPT_WIN_INPUT

#define OPT_WIN_INPUT   4

Definition at line 46 of file options.c.

◆ OPT_WIN_PLUGINS

#define OPT_WIN_PLUGINS   5

Definition at line 47 of file options.c.

◆ OPT_WIN_VIDEO

#define OPT_WIN_VIDEO   2

Definition at line 44 of file options.c.

◆ OPT_WINDOWS

#define OPT_WINDOWS   6

Definition at line 48 of file options.c.

Function Documentation

◆ lang_list()

char ** lang_list ( int * n)
static

Definition at line 259 of file options.c.

◆ menuKeybinds_genList()

void menuKeybinds_genList ( unsigned int wid)
static

Generates the keybindings list.

Parameters
widWindow to update.

Definition at line 610 of file options.c.

◆ menuKeybinds_getDim()

void menuKeybinds_getDim ( unsigned int wid,
int * w,
int * h,
int * lw,
int * lh,
int * bw,
int * bh )
static

Gets the keybind menu dimensions.

Definition at line 558 of file options.c.

◆ menuKeybinds_update()

void menuKeybinds_update ( unsigned int wid,
const char * name )
static

Updates the keybindings menu.

Parameters
widWindow to update.
nameUnused.

Definition at line 715 of file options.c.

◆ opt_accessibility()

void opt_accessibility ( unsigned int wid)
static

Initializes the accessibility window.

Definition at line 1200 of file options.c.

◆ opt_accessibilityDefaults()

void opt_accessibilityDefaults ( unsigned int wid,
const char * str )
static

Sets video defaults.

Definition at line 1314 of file options.c.

◆ opt_accessibilitySave()

int opt_accessibilitySave ( unsigned int wid,
const char * str )
static

Definition at line 1299 of file options.c.

◆ opt_audio()

void opt_audio ( unsigned int wid)
static

Opens the audio settings menu.

Definition at line 902 of file options.c.

◆ opt_audioDefaults()

void opt_audioDefaults ( unsigned int wid,
const char * str )
static

Sets the audio defaults.

Definition at line 997 of file options.c.

◆ opt_audioLevelStr()

void opt_audioLevelStr ( char * buf,
int max,
int type,
double pos )
static

Sets the sound or music volume string based on level.

Parameters
[out]bufBuffer to use.
maxMaximum length of the buffer.
type0 for sound, 1 for audio.
posPosition of the fader calling the function.

Definition at line 883 of file options.c.

◆ opt_audioSave()

int opt_audioSave ( unsigned int wid,
const char * str )
static

Saves the audio stuff.

Definition at line 969 of file options.c.

◆ opt_audioUpdate()

void opt_audioUpdate ( unsigned int wid)
static

Updates the gameplay options.

Definition at line 1015 of file options.c.

◆ opt_beep()

void opt_beep ( unsigned int wid,
const char * str )
static

Definition at line 959 of file options.c.

◆ opt_checkHealth()

void opt_checkHealth ( unsigned int wid,
const char * str )
static

Handles the health bar checkbox.

Definition at line 1619 of file options.c.

◆ opt_checkRestart()

void opt_checkRestart ( unsigned int wid,
const char * str )
static

Basically flags for needing a restart.

Definition at line 1628 of file options.c.

◆ opt_close()

void opt_close ( unsigned int wid,
const char * name )
static

Closes the options screen without saving.

Definition at line 217 of file options.c.

◆ opt_gameplay()

void opt_gameplay ( unsigned int wid)
static

Opens the gameplay menu.

Definition at line 290 of file options.c.

◆ opt_gameplayDefaults()

void opt_gameplayDefaults ( unsigned int wid,
const char * str )
static

Sets the default gameplay options.

Definition at line 519 of file options.c.

◆ opt_gameplaySave()

int opt_gameplaySave ( unsigned int wid,
const char * str )
static

Saves the gameplay options.

Definition at line 434 of file options.c.

◆ opt_gameplayUpdate()

void opt_gameplayUpdate ( unsigned int wid,
const char * str )
static

Updates the gameplay options.

Definition at line 539 of file options.c.

◆ opt_getVideoMode()

void opt_getVideoMode ( int * w,
int * h,
int * fullscreen )
static

Detects the video-mode options corresponding to the gl_screen we have set up.

Parameters
[out]wWidth of the video mode (if fullscreen) or window in screen coordinates (otherwise).
[out]hHeight of the video mode (if fullscreen) or window in screen coordinates (otherwise).
[out]fullscreenWhether it's a fullscreen mode.

Definition at line 1710 of file options.c.

◆ opt_keybinds()

void opt_keybinds ( unsigned int wid)
static

Opens the keybindings menu.

Definition at line 580 of file options.c.

◆ opt_keyDefaults()

void opt_keyDefaults ( unsigned int wid,
const char * str )
static

Restores the key defaults.

Definition at line 788 of file options.c.

◆ opt_listColourblind()

void opt_listColourblind ( unsigned int wid,
const char * str )
static

Handles the colourblind mode change.

Definition at line 1610 of file options.c.

◆ opt_menu()

void opt_menu ( void )

Creates the options menu thingy.

Definition at line 141 of file options.c.

◆ opt_needRestart()

void opt_needRestart ( void )
static

Marks that needs restart.

Definition at line 1492 of file options.c.

◆ opt_OK()

void opt_OK ( unsigned int wid,
const char * str )
static

Saves all options and closes the options screen.

Definition at line 191 of file options.c.

◆ opt_plugins()

void opt_plugins ( unsigned int wid)
static

Opens the keybindings menu.

Definition at line 1933 of file options.c.

◆ opt_plugins_add()

void opt_plugins_add ( unsigned int wid,
const char * name )
static

Definition at line 2126 of file options.c.

◆ opt_plugins_add_callback()

void opt_plugins_add_callback ( void * userdata,
const char *const * filelist,
int filter )
static

Definition at line 2000 of file options.c.

◆ opt_plugins_regenList()

void opt_plugins_regenList ( unsigned int wid)
static

Definition at line 1968 of file options.c.

◆ opt_plugins_update()

void opt_plugins_update ( unsigned int wid,
const char * name )
static

Definition at line 2138 of file options.c.

◆ opt_resize()

void opt_resize ( void )

Handles resize events for the options menu.

Definition at line 241 of file options.c.

◆ opt_setAudioLevel()

void opt_setAudioLevel ( unsigned int wid,
const char * str )
static

Callback to set the sound or music level.

Parameters
widWindow calling the callback.
strName of the widget calling the callback.

Definition at line 858 of file options.c.

◆ opt_setBGBrightness()

void opt_setBGBrightness ( unsigned int wid,
const char * str )
static

Callback to set the background brightness.

Parameters
widWindow calling the callback.
strName of the widget calling the callback.

Definition at line 1848 of file options.c.

◆ opt_setColourblindCorrect()

void opt_setColourblindCorrect ( unsigned int wid,
const char * str )
static

Handles the colourblind correction.

Definition at line 1578 of file options.c.

◆ opt_setColourblindSimulate()

void opt_setColourblindSimulate ( unsigned int wid,
const char * str )
static

Handles the colourblind correction.

Definition at line 1594 of file options.c.

◆ opt_setEngineLevel()

void opt_setEngineLevel ( unsigned int wid,
const char * str )
static

Definition at line 833 of file options.c.

◆ opt_setGameSpeed()

void opt_setGameSpeed ( unsigned int wid,
const char * str )
static

Definition at line 1902 of file options.c.

◆ opt_setGammaCorrection()

void opt_setGammaCorrection ( unsigned int wid,
const char * str )
static

Callback to set the gamma correction value (reciprocal of exponent).

Parameters
widWindow calling the callback.
strName of the widget calling the callback.

Definition at line 1832 of file options.c.

◆ opt_setJumpBrightness()

void opt_setJumpBrightness ( unsigned int wid,
const char * str )
static

Callback to set the background brightness.

Parameters
widWindow calling the callback.
strName of the widget calling the callback.

Definition at line 1893 of file options.c.

◆ opt_setKey()

void opt_setKey ( unsigned int wid,
const char * str )
static

Rebinds a key.

Definition at line 1141 of file options.c.

◆ opt_setKeyEvent()

int opt_setKeyEvent ( unsigned int wid,
SDL_Event * event )
static

Tries to set the key from an event.

Definition at line 1030 of file options.c.

◆ opt_setMapOverlayOpacity()

void opt_setMapOverlayOpacity ( unsigned int wid,
const char * str )
static

Callback to set autonav abort threshold.

Parameters
widWindow calling the callback.
strName of the widget calling the callback.

Definition at line 1920 of file options.c.

◆ opt_setNebuNonuniformity()

void opt_setNebuNonuniformity ( unsigned int wid,
const char * str )
static

Callback to set the nebula non-uniformity parameter.

Parameters
widWindow calling the callback.
strName of the widget calling the callback.

Definition at line 1877 of file options.c.

◆ opt_setSaturation()

void opt_setSaturation ( unsigned int wid,
const char * str )
static

Definition at line 1858 of file options.c.

◆ opt_setScalefactor()

void opt_setScalefactor ( unsigned int wid,
const char * str )
static

Callback to set the scaling factor.

Parameters
widWindow calling the callback.
strName of the widget calling the callback.

Definition at line 1770 of file options.c.

◆ opt_setVideoMode()

int opt_setVideoMode ( int w,
int h,
int fullscreen,
int confirm )

Applies new video-mode options.

Parameters
wWidth of the video mode (if fullscreen) or window in screen coordinates (otherwise).
hHeight of the video mode (if fullscreen) or window in screen coordinates (otherwise).
fullscreenWhether it's a fullscreen mode.
confirmWhether to confirm the new settings.
Returns
0 on success.

Definition at line 1646 of file options.c.

◆ opt_setZoomFar()

void opt_setZoomFar ( unsigned int wid,
const char * str )
static

Callback to set the far zoom.

Parameters
widWindow calling the callback.
strName of the widget calling the callback.

Definition at line 1788 of file options.c.

◆ opt_setZoomNear()

void opt_setZoomNear ( unsigned int wid,
const char * str )
static

Callback to set the far zoom.

Parameters
widWindow calling the callback.
strName of the widget calling the callback.

Definition at line 1810 of file options.c.

◆ opt_unsetKey()

void opt_unsetKey ( unsigned int wid,
const char * str )
static

Unsets the key.

Definition at line 1181 of file options.c.

◆ opt_video()

void opt_video ( unsigned int wid)
static

Initializes the video window.

Definition at line 1339 of file options.c.

◆ opt_videoDefaults()

void opt_videoDefaults ( unsigned int wid,
const char * str )
static

Sets video defaults.

Definition at line 1732 of file options.c.

◆ opt_videoRes()

void opt_videoRes ( unsigned int wid,
const char * str )
static

Callback when resolution changes.

Definition at line 1505 of file options.c.

◆ opt_videoSave()

int opt_videoSave ( unsigned int wid,
const char * str )
static

Saves the video settings.

Definition at line 1514 of file options.c.

Variable Documentation

◆ cHeader

const glColour* cHeader = &cFontGrey
static

Definition at line 63 of file options.c.

◆ local_conf

PlayerConf_t local_conf
static

Definition at line 66 of file options.c.

◆ opt_lastKeyPress

int opt_lastKeyPress = 0
static

Last keypress.

Definition at line 72 of file options.c.

◆ opt_names

const char* opt_names[]
static
Initial value:
= {
N_( "Gameplay" ), N_( "Accessibility" ), N_( "Video" ),
N_( "Audio" ), N_( "Input" ), N_( "Plugins" ),
}

Definition at line 57 of file options.c.

◆ opt_restart

int opt_restart = 0
static

Definition at line 65 of file options.c.

◆ opt_selectedKeybind

KeySemanticType opt_selectedKeybind
static

Selected keybinding.

Definition at line 71 of file options.c.

◆ opt_wid

unsigned int opt_wid = 0
static

Definition at line 55 of file options.c.

◆ opt_windows

unsigned int* opt_windows
static

Definition at line 56 of file options.c.