Skip to content

Commit

Permalink
add fov and aspect ratio correction options to menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Chomenor committed Sep 17, 2021
1 parent bc12983 commit 06d2708
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 2 deletions.
13 changes: 13 additions & 0 deletions code/ui/ui_atoms.c
Original file line number Diff line number Diff line change
Expand Up @@ -2161,6 +2161,11 @@ void UI_LoadButtonText()
menu_button_text[MBT_REMOVE_IGNORE][1] = "REMOVE IGNORE";
menu_button_text[MBT_FLUSH_IGNORE][0] = "CLEAR";
menu_button_text[MBT_FLUSH_IGNORE][1] = "REMOVE ALL IGNORES";
menu_button_text[MBT_FOV][0] = "FIELD OF VIEW";
menu_button_text[MBT_FOV][1] = "ADJUST FIELD OF VIEW";
menu_button_text[MBT_ASPECTCORRECTION][0] = "ASPECT CORRECTION";
menu_button_text[MBT_ASPECTCORRECTION][1] = "ENABLE OR DISABLE ASPECT RATIO CORRECTION";

menu_button_text[MBT_ALTSWAP_CONTROL][0] = "ALT FIRE SWAPPING";
menu_button_text[MBT_ALTSWAP_CONTROL][1] = "SELECT ALT FIRE BUTTON SWAPPING MODE";
menu_button_text[MBT_ALTSWAP_EDIT][0] = "EDIT";
Expand Down Expand Up @@ -2195,6 +2200,10 @@ void UI_LoadButtonText()
menu_button_text[MBT_REMOVE_IGNORE][1] = "IGNORE AUFHEBEN";
menu_button_text[MBT_FLUSH_IGNORE][0] = "ALLE LÖSCHEN";
menu_button_text[MBT_FLUSH_IGNORE][1] = "ALLE IGNORES ENTFERNEN";
menu_button_text[MBT_FOV][0] = "SICHTFELD";
menu_button_text[MBT_FOV][1] = "SICHTFELD ANPASSEN";
menu_button_text[MBT_ASPECTCORRECTION][0] = "ASPEKTKORREKTUR";
menu_button_text[MBT_ASPECTCORRECTION][1] = "AKTIVIEREN ODER DEAKTIVIEREN DER SEITENVERHÄLTNISKORREKTUR";

menu_button_text[MBT_ALTSWAP_CONTROL][0] = "ALT FEUER WECHSELN";
menu_button_text[MBT_ALTSWAP_CONTROL][1] = "MODUS FÜR DAS ALTERNATIVE FEUER AUSWÄHLEN";
Expand Down Expand Up @@ -2241,6 +2250,10 @@ void UI_LoadButtonText()
menu_button_text[MBT_REMOVE_IGNORE][1] = "SUPPRIMER L'IGNORE";
menu_button_text[MBT_FLUSH_IGNORE][0] = "SUPPR. TOUS";
menu_button_text[MBT_FLUSH_IGNORE][1] = "VIDER LA LISTE DES JOUEURS IGNOREE";
menu_button_text[MBT_FOV][0] = "CHAMP DE VISION";
menu_button_text[MBT_FOV][1] = "AJUSTER LE CHAMP DE VISION";
menu_button_text[MBT_ASPECTCORRECTION][0] = "CORRECTION D'ASPECT";
menu_button_text[MBT_ASPECTCORRECTION][1] = "ACTIVER OU DÉSACTIVER LA CORRECTION DU RATIO D'AFFICHAGE";

menu_button_text[MBT_ALTSWAP_CONTROL][0] = "ÉCHANGE DE FEU ALT";
menu_button_text[MBT_ALTSWAP_CONTROL][1] = "SÉLECTIONNER LE MODE D'ÉCHANGE DU BOUTON ALT FIRE";
Expand Down
33 changes: 33 additions & 0 deletions code/ui/ui_cvars.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,22 @@ void IntensityCallback( void *s, int notification )
trap_Cvar_SetValue( "r_intensity", slider->curvalue / 10.0f );
}

/*
=================
FovCallback
=================
*/
void FovCallback( void *s, int notification )
{
menuslider_s *slider = ( menuslider_s * ) s;

if (notification != QM_ACTIVATED)
return;

// Use asterisk notation to enable horizontal scaling.
trap_Cvar_Set( "cg_fov", va( "%f*", slider->curvalue ) );
}

/*
=================
ScreensizeCallback
Expand Down Expand Up @@ -135,6 +151,23 @@ void AutoswitchCallback( void *unused, int notification )
}


/*
=================
AspectCorrectionCallback
=================
*/
void AspectCorrectionCallback( void *s, int notification )
{
menulist_s *aspectCorrection = ( menulist_s * ) s;

if (notification != QM_ACTIVATED)
{
return;
}

trap_Cvar_SetValue( "cg_aspectCorrect", aspectCorrection->curvalue );
}

/*
=================
AnisotropicFilteringCallback
Expand Down
4 changes: 4 additions & 0 deletions code/ui/ui_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,8 @@ typedef enum
MBT_ADD_IGNORE,
MBT_REMOVE_IGNORE,
MBT_FLUSH_IGNORE,
MBT_FOV,
MBT_ASPECTCORRECTION,
MBT_ALTSWAP_CONTROL,
MBT_ALTSWAP_EDIT,
MBT_ALTSWAP_ALL_STANDARD,
Expand Down Expand Up @@ -1841,6 +1843,7 @@ void UI_FontsMenu( void);
// ui_cvars.c
//
extern void GammaCallback( void *s, int notification );
extern void FovCallback( void *s, int notification );
extern void ScreensizeCallback( void *s, int notification );

//
Expand Down Expand Up @@ -1900,6 +1903,7 @@ void UI_PrintMenuGraphics(menugraphics_s *menuGraphics,int maxI);
extern void InvertMouseCallback(void *s, int notification);
extern void MouseSpeedCallback( void *s, int notification );
extern void SmoothMouseCallback( void *s, int notification );
extern void AspectCorrectionCallback( void *s, int notification );
extern void AnisotropicFilteringCallback( void *s, int notification );
extern void JoyXButtonCallback( void *s, int notification );
extern void JoyYButtonCallback( void *s, int notification );
Expand Down
85 changes: 83 additions & 2 deletions code/ui/ui_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ typedef struct
menuframework_s menu;

menuslider_s gamma_slider;
menuslider_s fov_slider;
menuslider_s screensize_slider;
menulist_s aspectCorrection;
menulist_s anisotropicfiltering;
menuaction_s apply_action2;

Expand Down Expand Up @@ -2092,7 +2094,39 @@ static void VideoData2_MenuInit( void )
s_videodata2.apply_action2.width = 82;
s_videodata2.apply_action2.height = 70;

y = 330;
y += 30;
s_videodata2.fov_slider.generic.type = MTYPE_SLIDER;
s_videodata2.fov_slider.generic.x = x + 162;
s_videodata2.fov_slider.generic.y = y;
s_videodata2.fov_slider.generic.flags = QMF_SMALLFONT;
s_videodata2.fov_slider.generic.callback = FovCallback;
s_videodata2.fov_slider.minvalue = 60;
s_videodata2.fov_slider.maxvalue = 120;
s_videodata2.fov_slider.color = CT_DKPURPLE1;
s_videodata2.fov_slider.color2 = CT_LTPURPLE1;
s_videodata2.fov_slider.generic.name = PIC_MONBAR2;
s_videodata2.fov_slider.width = 256;
s_videodata2.fov_slider.height = 32;
s_videodata2.fov_slider.focusWidth = 145;
s_videodata2.fov_slider.focusHeight = 18;
s_videodata2.fov_slider.picName = GRAPHIC_SQUARE;
s_videodata2.fov_slider.picX = x;
s_videodata2.fov_slider.picY = y;
s_videodata2.fov_slider.picWidth = MENU_BUTTON_MED_WIDTH + 21;
s_videodata2.fov_slider.picHeight = MENU_BUTTON_MED_HEIGHT;
s_videodata2.fov_slider.textX = MENU_BUTTON_TEXT_X;
s_videodata2.fov_slider.textY = MENU_BUTTON_TEXT_Y;
s_videodata2.fov_slider.textEnum = MBT_FOV;
s_videodata2.fov_slider.textcolor = CT_BLACK;
s_videodata2.fov_slider.textcolor2 = CT_WHITE;
s_videodata2.fov_slider.thumbName = PIC_SLIDER;
s_videodata2.fov_slider.thumbHeight = 32;
s_videodata2.fov_slider.thumbWidth = 16;
s_videodata2.fov_slider.thumbGraphicWidth = 9;
s_videodata2.fov_slider.thumbColor = CT_DKBLUE1;
s_videodata2.fov_slider.thumbColor2 = CT_LTBLUE1;

y += 30;
s_videodata2.screensize_slider.generic.type = MTYPE_SLIDER;
s_videodata2.screensize_slider.generic.x = x + 162;
s_videodata2.screensize_slider.generic.y = y;
Expand Down Expand Up @@ -2124,7 +2158,23 @@ static void VideoData2_MenuInit( void )
s_videodata2.screensize_slider.thumbColor = CT_DKBLUE1;
s_videodata2.screensize_slider.thumbColor2 = CT_LTBLUE1;

y += 34;
y += 30;
s_videodata2.aspectCorrection.generic.type = MTYPE_SPINCONTROL;
s_videodata2.aspectCorrection.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;
s_videodata2.aspectCorrection.generic.x = x;
s_videodata2.aspectCorrection.generic.y = y;
s_videodata2.aspectCorrection.generic.name = GRAPHIC_BUTTONRIGHT;
s_videodata2.aspectCorrection.generic.callback = AspectCorrectionCallback;
s_videodata2.aspectCorrection.color = CT_DKPURPLE1;
s_videodata2.aspectCorrection.color2 = CT_LTPURPLE1;
s_videodata2.aspectCorrection.textX = MENU_BUTTON_TEXT_X;
s_videodata2.aspectCorrection.textY = MENU_BUTTON_TEXT_Y;
s_videodata2.aspectCorrection.textEnum = MBT_ASPECTCORRECTION;
s_videodata2.aspectCorrection.textcolor = CT_BLACK;
s_videodata2.aspectCorrection.textcolor2 = CT_WHITE;
s_videodata2.aspectCorrection.listnames = s_OffOnNone_Names;

y += 30;
s_videodata2.anisotropicfiltering.generic.type = MTYPE_SPINCONTROL;
s_videodata2.anisotropicfiltering.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;
s_videodata2.anisotropicfiltering.generic.x = x;
Expand All @@ -2146,11 +2196,40 @@ static void VideoData2_MenuInit( void )
{
Menu_AddItem( &s_videodata2.menu, ( void * )&s_videodata2.apply_action2);
}
Menu_AddItem( &s_videodata2.menu, ( void * )&s_videodata2.fov_slider);
Menu_AddItem( &s_videodata2.menu, ( void * )&s_videodata2.screensize_slider);
Menu_AddItem( &s_videodata2.menu, ( void * )&s_videodata2.anisotropicfiltering);
Menu_AddItem( &s_videodata2.menu, ( void * )&s_videodata2.aspectCorrection);

}

/*
=================
UI_VideoData2SettingsGetCurrentFov
=================
*/
static float UI_VideoData2SettingsGetCurrentFov( void )
{
float fov;
char buffer[256];

trap_Cvar_VariableStringBuffer( "cg_fov", buffer, sizeof( buffer ) );
fov = atof( buffer );

if ( !strchr( buffer, '*' ) ) {
// Convert existing unscaled fov to scaled version, which is what is used by UI.
float x = uis.glconfig.vidWidth / tan( fov / 360 * M_PI );
float fov_y = atan2( uis.glconfig.vidHeight, x );
fov_y = fov_y * 360 / M_PI;

x = 480.0 / tan( fov_y / 360 * M_PI );
fov = atan2( 640.0, x );
fov = fov * 360 / M_PI;
}

return fov;
}

/*
=================
UI_VideoData2SettingsGetCvars
Expand All @@ -2159,7 +2238,9 @@ UI_VideoData2SettingsGetCvars
static void UI_VideoData2SettingsGetCvars()
{
s_videodata2.gamma_slider.curvalue = trap_Cvar_VariableValue( "r_gamma" ) * 10.0f;
s_videodata2.fov_slider.curvalue = UI_VideoData2SettingsGetCurrentFov();
s_videodata2.screensize_slider.curvalue = trap_Cvar_VariableValue( "cg_viewsize" );
s_videodata2.aspectCorrection.curvalue = trap_Cvar_VariableValue( "cg_aspectCorrect" ) ? 1 : 0;
s_videodata2.anisotropicfiltering.curvalue = trap_Cvar_VariableValue( "r_ext_texture_filter_anisotropic" );
}

Expand Down

0 comments on commit 06d2708

Please sign in to comment.