diff --git a/code/ui/ui_atoms.c b/code/ui/ui_atoms.c index 5d78f6e..8e68ed3 100644 --- a/code/ui/ui_atoms.c +++ b/code/ui/ui_atoms.c @@ -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"; @@ -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"; @@ -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"; diff --git a/code/ui/ui_cvars.c b/code/ui/ui_cvars.c index 4f9b0e0..1892585 100644 --- a/code/ui/ui_cvars.c +++ b/code/ui/ui_cvars.c @@ -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 @@ -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 diff --git a/code/ui/ui_local.h b/code/ui/ui_local.h index aae2c89..41c410f 100644 --- a/code/ui/ui_local.h +++ b/code/ui/ui_local.h @@ -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, @@ -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 ); // @@ -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 ); diff --git a/code/ui/ui_video.c b/code/ui/ui_video.c index 5ef4b0f..c8ac6c0 100644 --- a/code/ui/ui_video.c +++ b/code/ui/ui_video.c @@ -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; @@ -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; @@ -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; @@ -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 @@ -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" ); }