naev 0.10.4
Macros | Functions | Variables
options.c File Reference

Options menu. More...

#include "options.h"
#include "array.h"
#include "conf.h"
#include "background.h"
#include "colour.h"
#include "dialogue.h"
#include "difficulty.h"
#include "input.h"
#include "log.h"
#include "music.h"
#include "ndata.h"
#include "nfile.h"
#include "nstring.h"
#include "player.h"
#include "plugin.h"
#include "render.h"
#include "sound.h"
#include "toolkit.h"

Go to the source code of this file.

Macros

#define BUTTON_WIDTH   200
 
#define BUTTON_HEIGHT   30
 
#define OPT_WIN_GAMEPLAY   0
 
#define OPT_WIN_VIDEO   1
 
#define OPT_WIN_AUDIO   2
 
#define OPT_WIN_INPUT   3
 
#define OPT_WIN_PLUGINS   4
 
#define OPT_WINDOWS   5
 
#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. More...
 
static void opt_needRestart (void)
 Marks that needs restart. More...
 
static char ** lang_list (int *n)
 
static void opt_gameplay (unsigned int wid)
 Opens the gameplay menu. More...
 
static void opt_setAutonavResetSpeed (unsigned int wid, const char *str)
 Callback to set autonav abort threshold. More...
 
static void opt_setMapOverlayOpacity (unsigned int wid, const char *str)
 Callback to set autonav abort threshold. More...
 
static void opt_OK (unsigned int wid, const char *str)
 Saves all options and closes the options screen. More...
 
static int opt_gameplaySave (unsigned int wid, const char *str)
 Saves the gameplay options. More...
 
static void opt_gameplayDefaults (unsigned int wid, const char *str)
 Sets the default gameplay options. More...
 
static void opt_gameplayUpdate (unsigned int wid, const char *str)
 Updates the gameplay options. More...
 
static void opt_video (unsigned int wid)
 Initializes the video window. More...
 
static void opt_videoRes (unsigned int wid, const char *str)
 Callback when resolution changes. More...
 
static int opt_videoSave (unsigned int wid, const char *str)
 Saves the video settings. More...
 
static void opt_videoDefaults (unsigned int wid, const char *str)
 Sets video defaults. More...
 
static void opt_getVideoMode (int *w, int *h, int *fullscreen)
 Detects the video-mode options corresponding to the gl_screen we have set up. More...
 
static void opt_setGammaCorrection (unsigned int wid, const char *str)
 Callback to set the gamma correction value (reciprocal of exponent). More...
 
static void opt_setScalefactor (unsigned int wid, const char *str)
 Callback to set the scaling factor. More...
 
static void opt_setZoomFar (unsigned int wid, const char *str)
 Callback to set the far zoom. More...
 
static void opt_setZoomNear (unsigned int wid, const char *str)
 Callback to set the far zoom. More...
 
static void opt_setBGBrightness (unsigned int wid, const char *str)
 Callback to set the background brightness. More...
 
static void opt_setNebuNonuniformity (unsigned int wid, const char *str)
 Callback to set the nebula non-uniformity parameter. More...
 
static void opt_setJumpBrightness (unsigned int wid, const char *str)
 Callback to set the background brightness. More...
 
static void opt_checkColorblind (unsigned int wid, const char *str)
 Handles the colorblind checkbox being checked. More...
 
static void opt_checkHealth (unsigned int wid, const char *str)
 Handles the fancy background checkbox. More...
 
static void opt_audio (unsigned int wid)
 Opens the audio settings menu. More...
 
static int opt_audioSave (unsigned int wid, const char *str)
 Saves the audio stuff. More...
 
static void opt_audioDefaults (unsigned int wid, const char *str)
 Sets the audio defaults. More...
 
static void opt_audioUpdate (unsigned int wid)
 Updates the gameplay options. More...
 
static void opt_audioLevelStr (char *buf, int max, int type, double pos)
 Sets the sound or music volume string based on level. More...
 
static void opt_setAudioLevel (unsigned int wid, const char *str)
 Callback to set the sound or music level. More...
 
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. More...
 
static void menuKeybinds_getDim (unsigned int wid, int *w, int *h, int *lw, int *lh, int *bw, int *bh)
 Gets the keybind menu dimensions. More...
 
static void menuKeybinds_genList (unsigned int wid)
 Generates the keybindings list. More...
 
static void menuKeybinds_update (unsigned int wid, const char *name)
 Updates the keybindings menu. More...
 
static void opt_keyDefaults (unsigned int wid, const char *str)
 Restores the key defaults. More...
 
static int opt_setKeyEvent (unsigned int wid, SDL_Event *event)
 Tries to set the key from an event. More...
 
static void opt_setKey (unsigned int wid, const char *str)
 Rebinds a key. More...
 
static void opt_unsetKey (unsigned int wid, const char *str)
 Unsets the key. More...
 
static void opt_plugins (unsigned int wid)
 Opens the keybindings menu. More...
 
static void opt_plugins_update (unsigned int wid, const char *name)
 
void opt_menu (void)
 Creates the options menu thingy. More...
 
void opt_resize (void)
 Handles resize events for the options menu. More...
 
int opt_setVideoMode (int w, int h, int fullscreen, int confirm)
 Applies new video-mode options. More...
 

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 const char * 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 47 of file options.c.

◆ BUTTON_HEIGHT

#define BUTTON_HEIGHT   30

Button height, standard across menus.

Definition at line 38 of file options.c.

◆ BUTTON_WIDTH

#define BUTTON_WIDTH   200

Button width, standard across menus.

Definition at line 37 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 48 of file options.c.

◆ OPT_WIN_AUDIO

#define OPT_WIN_AUDIO   2

Definition at line 42 of file options.c.

◆ OPT_WIN_GAMEPLAY

#define OPT_WIN_GAMEPLAY   0

Definition at line 40 of file options.c.

◆ OPT_WIN_INPUT

#define OPT_WIN_INPUT   3

Definition at line 43 of file options.c.

◆ OPT_WIN_PLUGINS

#define OPT_WIN_PLUGINS   4

Definition at line 44 of file options.c.

◆ OPT_WIN_VIDEO

#define OPT_WIN_VIDEO   1

Definition at line 41 of file options.c.

◆ OPT_WINDOWS

#define OPT_WINDOWS   5

Definition at line 45 of file options.c.

Function Documentation

◆ lang_list()

static char ** lang_list ( int *  n)
static

Definition at line 232 of file options.c.

◆ menuKeybinds_genList()

static void menuKeybinds_genList ( unsigned int  wid)
static

Generates the keybindings list.

Parameters
widWindow to update.

Definition at line 673 of file options.c.

◆ menuKeybinds_getDim()

static 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 619 of file options.c.

◆ menuKeybinds_update()

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

Updates the keybindings menu.

Parameters
widWindow to update.
nameUnused.

Definition at line 770 of file options.c.

◆ opt_audio()

static void opt_audio ( unsigned int  wid)
static

Opens the audio settings menu.

Definition at line 953 of file options.c.

◆ opt_audioDefaults()

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

Sets the audio defaults.

Definition at line 1059 of file options.c.

◆ opt_audioLevelStr()

static 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 937 of file options.c.

◆ opt_audioSave()

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

Saves the audio stuff.

Definition at line 1031 of file options.c.

◆ opt_audioUpdate()

static void opt_audioUpdate ( unsigned int  wid)
static

Updates the gameplay options.

Definition at line 1077 of file options.c.

◆ opt_beep()

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

Definition at line 1021 of file options.c.

◆ opt_checkColorblind()

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

Handles the colorblind checkbox being checked.

Definition at line 1531 of file options.c.

◆ opt_checkHealth()

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

Handles the fancy background checkbox.

Definition at line 1541 of file options.c.

◆ opt_close()

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

Closes the options screen without saving.

Definition at line 190 of file options.c.

◆ opt_gameplay()

static void opt_gameplay ( unsigned int  wid)
static

Opens the gameplay menu.

Definition at line 257 of file options.c.

◆ opt_gameplayDefaults()

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

Sets the default gameplay options.

Definition at line 536 of file options.c.

◆ opt_gameplaySave()

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

Saves the gameplay options.

Definition at line 432 of file options.c.

◆ opt_gameplayUpdate()

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

Updates the gameplay options.

Definition at line 561 of file options.c.

◆ opt_getVideoMode()

static 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 1610 of file options.c.

◆ opt_keybinds()

static void opt_keybinds ( unsigned int  wid)
static

Opens the keybindings menu.

Definition at line 641 of file options.c.

◆ opt_keyDefaults()

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

Restores the key defaults.

Definition at line 843 of file options.c.

◆ opt_menu()

void opt_menu ( void  )

Creates the options menu thingy.

Definition at line 127 of file options.c.

◆ opt_needRestart()

static void opt_needRestart ( void  )
static

Marks that needs restart.

Definition at line 1448 of file options.c.

◆ opt_OK()

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

Saves all options and closes the options screen.

Definition at line 166 of file options.c.

◆ opt_plugins()

static void opt_plugins ( unsigned int  wid)
static

Opens the keybindings menu.

Definition at line 1800 of file options.c.

◆ opt_plugins_update()

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

Definition at line 1839 of file options.c.

◆ opt_resize()

void opt_resize ( void  )

Handles resize events for the options menu.

Definition at line 214 of file options.c.

◆ opt_setAudioLevel()

static 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 911 of file options.c.

◆ opt_setAutonavResetSpeed()

static void opt_setAutonavResetSpeed ( 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 595 of file options.c.

◆ opt_setBGBrightness()

static 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 1743 of file options.c.

◆ opt_setEngineLevel()

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

Definition at line 889 of file options.c.

◆ opt_setGammaCorrection()

static 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 1727 of file options.c.

◆ opt_setJumpBrightness()

static 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 1773 of file options.c.

◆ opt_setKey()

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

Rebinds a key.

Definition at line 1205 of file options.c.

◆ opt_setKeyEvent()

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

Tries to set the key from an event.

Definition at line 1092 of file options.c.

◆ opt_setMapOverlayOpacity()

static 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 1788 of file options.c.

◆ opt_setNebuNonuniformity()

static 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 1758 of file options.c.

◆ opt_setScalefactor()

static 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 1665 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 1556 of file options.c.

◆ opt_setZoomFar()

static 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 1683 of file options.c.

◆ opt_setZoomNear()

static 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 1705 of file options.c.

◆ opt_unsetKey()

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

Unsets the key.

Definition at line 1244 of file options.c.

◆ opt_video()

static void opt_video ( unsigned int  wid)
static

Initializes the video window.

Definition at line 1263 of file options.c.

◆ opt_videoDefaults()

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

Sets video defaults.

Definition at line 1630 of file options.c.

◆ opt_videoRes()

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

Callback when resolution changes.

Definition at line 1465 of file options.c.

◆ opt_videoSave()

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

Saves the video settings.

Definition at line 1474 of file options.c.

Variable Documentation

◆ cHeader

const glColour* cHeader = &cFontGrey
static

Definition at line 59 of file options.c.

◆ local_conf

PlayerConf_t local_conf
static

Definition at line 62 of file options.c.

◆ opt_lastKeyPress

int opt_lastKeyPress = 0
static

Last keypress.

Definition at line 68 of file options.c.

◆ opt_names

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

Definition at line 52 of file options.c.

◆ opt_restart

int opt_restart = 0
static

Definition at line 61 of file options.c.

◆ opt_selectedKeybind

const char* opt_selectedKeybind
static

Selected keybinding.

Definition at line 67 of file options.c.

◆ opt_wid

unsigned int opt_wid = 0
static

Definition at line 50 of file options.c.

◆ opt_windows

unsigned int* opt_windows
static

Definition at line 51 of file options.c.