Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MTA10/core/CCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ void CCore::ApplyGameSettings ( void )
CVARS_GET ( "classic_controls", bval ); pController->SetClassicControls ( bval );
CVARS_GET ( "volumetric_shadows", bval ); m_pGame->GetSettings ()->SetVolumetricShadowsEnabled ( bval );
CVARS_GET ( "aspect_ratio", iVal ); m_pGame->GetSettings ()->SetAspectRatio ( (eAspectRatio)iVal, CVARS_GET_VALUE < bool > ( "hud_match_aspect_ratio" ) );
CVARS_GET ( "fov", iVal ); m_pGame->GetSettings ()->SetFieldOfView ( iVal );
CVARS_GET ( "fov", iVal ); iVal = Clamp ( 70, iVal, 100 ); m_pGame->GetSettings ()->SetFieldOfView ( iVal );
CVARS_GET ( "grass", bval ); m_pGame->GetSettings ()->SetGrassEnabled ( bval );
CVARS_GET ( "heat_haze", bval ); m_pMultiplayer->SetHeatHazeEnabled ( bval );
CVARS_GET ( "fast_clothes_loading", iVal ); m_pMultiplayer->SetFastClothesLoading ( (CMultiplayer::EFastClothesLoading)iVal );
Expand Down
9 changes: 4 additions & 5 deletions MTA10/core/CSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void CSettings::CreateGUI ( void )
}
else
{
// Otherwise use black background image
// Otherwise use black background image
CGUIStaticImage* pFiller = reinterpret_cast < CGUIStaticImage* > ( pManager->CreateStaticImage () );
pFiller->LoadFromFile ( CORE_MTA_FILLER );
pFiller->SetVisible ( false );
Expand Down Expand Up @@ -1771,7 +1771,7 @@ void CSettings::UpdateVideoTab ( void )

// Customized sa files
m_pCheckBoxCustomizedSAFiles->SetSelected ( GetApplicationSettingInt ( "customized-sa-files-request" ) != 0 );
m_pCheckBoxCustomizedSAFiles->SetVisible ( GetApplicationSettingInt ( "customized-sa-files-show" ) != 0 );
m_pCheckBoxCustomizedSAFiles->SetVisible ( GetApplicationSettingInt ( "customized-sa-files-show" ) != 0 );

// Grass
bool bGrassEnabled;
Expand Down Expand Up @@ -3057,13 +3057,12 @@ void CSettings::SaveData ( void )
gameSettings->SetDrawDistance ( ( m_pDrawDistance->GetScrollPosition () * 0.875f ) + 0.925f );
gameSettings->SetBrightness ( m_pBrightness->GetScrollPosition () * 384 );
gameSettings->SetMouseSensitivity ( m_pMouseSensitivity->GetScrollPosition () );
gameSettings->SetMipMappingEnabled ( m_pCheckBoxMipMapping->GetSelected () );
gameSettings->SetMipMappingEnabled ( m_pCheckBoxMipMapping->GetSelected () );
SetApplicationSettingInt ( "customized-sa-files-request", bCustomizedSAFilesEnabled ? 1 : 0 );

// iFieldOfView
int iFieldOfView = Min < int > ( 4, ( m_pFieldOfView->GetScrollPosition () ) * ( 4 + 1 ) ) * 5 + 70;
CVARS_SET ( "fov", iFieldOfView );
gameSettings->SetFieldOfView ( iFieldOfView );

// Anisotropic filtering
int iAnisotropic = Min < int > ( m_iMaxAnisotropic, ( m_pAnisotropic->GetScrollPosition () ) * ( m_iMaxAnisotropic + 1 ) );
Expand All @@ -3090,7 +3089,7 @@ void CSettings::SaveData ( void )
// Volumetric shadows
bool bVolumetricShadowsEnabled = m_pCheckBoxVolumetricShadows->GetSelected ();
CVARS_SET ( "volumetric_shadows", bVolumetricShadowsEnabled );
gameSettings->SetVolumetricShadowsEnabled ( bVolumetricShadowsEnabled );
gameSettings->SetVolumetricShadowsEnabled ( bVolumetricShadowsEnabled );

// Device selection dialog
bool bDeviceSelectionDialogEnabled = m_pCheckBoxDeviceSelectionDialog->GetSelected ();
Expand Down
39 changes: 30 additions & 9 deletions MTA10/game_sa/CSettingsSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,34 +485,55 @@ void CSettingsSA::SetRadarMode ( eRadarMode hudMode )
////////////////////////////////////////////////
float ms_fFOV = 70;
float ms_fFOVCar = 70;
float ms_fFOVCarMax = 100; // When car go fast
float ms_fFOVCarMax = 100; // at high vehicle velocity

float CSettingsSA::GetFieldOfView ( void )
// consider moving this to the camera class - qaisjp
float CSettingsSA::GetFieldOfViewPlayer ( void )
{
return ms_fFOV;
}

float CSettingsSA::GetFieldOfViewVehicle ( void )
{
return ms_fFOVCar;
}

float CSettingsSA::GetFieldOfViewVehicleMax ( void )
{
return ms_fFOVCarMax;
}

void CSettingsSA::SetFieldOfView ( float fAngle )
{
fAngle = Clamp( 70.f, fAngle, 100.f );
SetFieldOfViewPlayer ( fAngle );
SetFieldOfViewVehicle ( fAngle );
}

void CSettingsSA::SetFieldOfViewPlayer ( float fAngle )
{
ms_fFOV = fAngle;
ms_fFOVCar = fAngle;

// Player follow
MemPut < void* > ( 0x0522F3A, &ms_fFOV );
MemPut < void* > ( 0x0522F5D, &ms_fFOV );
MemPut < float > ( 0x0522F7A, ms_fFOV );
}

// Car follow
void CSettingsSA::SetFieldOfViewVehicle ( float fAngle )
{
ms_fFOVCar = fAngle;
MemPut < void* > ( 0x0524B76, &ms_fFOVCar );
MemPut < void* > ( 0x0524B9A, &ms_fFOVCar );
MemPut < void* > ( 0x0524BA2, &ms_fFOVCar );
MemPut < void* > ( 0x0524BB4, &ms_fFOVCarMax );
MemPut < float > ( 0x0524BC5, ms_fFOVCarMax );
MemPut < void* > ( 0x0524BD3, &ms_fFOVCar );
MemPut < float > ( 0x0524BE4, ms_fFOVCar );
}

void CSettingsSA::SetFieldOfViewVehicleMax ( float fAngle )
{
ms_fFOVCarMax = fAngle;
MemPut < void* > ( 0x0524BB4, &ms_fFOVCarMax );
MemPut < float > ( 0x0524BC5, ms_fFOVCarMax );
}


////////////////////////////////////////////////
//
Expand Down
7 changes: 6 additions & 1 deletion MTA10/game_sa/CSettingsSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,12 @@ class CSettingsSA : public CGameSettings
void SetRadarMode ( eRadarMode hudMode );

void SetFieldOfView ( float fAngle );
float GetFieldOfView ( void );
void SetFieldOfViewPlayer ( float fAngle );
void SetFieldOfViewVehicle ( float fAngle );
void SetFieldOfViewVehicleMax ( float fAngle );
float GetFieldOfViewPlayer ( void );
float GetFieldOfViewVehicle ( void );
float GetFieldOfViewVehicleMax ( void );

void Save ( void );

Expand Down
13 changes: 9 additions & 4 deletions MTA10/mods/deathmatch/logic/CClientGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2781,9 +2781,9 @@ void CClientGame::AddBuiltInEvents ( void )
m_Events.AddEvent ( "onClientPlayerStealthKill", "target", NULL, false );
m_Events.AddEvent ( "onClientPlayerHitByWaterCannon", "vehicle", NULL, false );
m_Events.AddEvent ( "onClientPlayerHeliKilled", "heli", NULL, false );
m_Events.AddEvent ( "onClientPlayerPickupHit", "pickup, matchingDimension", NULL, false );
m_Events.AddEvent ( "onClientPlayerPickupLeave", "pickup, matchingDimension", NULL, false );
m_Events.AddEvent ( "onClientPlayerNetworkStatus", "type, ticks", NULL, false );
m_Events.AddEvent ( "onClientPlayerPickupHit", "pickup, matchingDimension", NULL, false );
m_Events.AddEvent ( "onClientPlayerPickupLeave", "pickup, matchingDimension", NULL, false );
m_Events.AddEvent ( "onClientPlayerNetworkStatus", "type, ticks", NULL, false );

// Ped events
m_Events.AddEvent ( "onClientPedDamage", "attacker, weapon, bodypart", NULL, false );
Expand Down Expand Up @@ -5465,6 +5465,11 @@ void CClientGame::ResetMapInfo ( void )
g_pGame->GetWorld ()->SetCurrentArea ( 0 );
m_pCamera->SetFocusToLocalPlayer ();

float fFOV;
g_pCore->GetCVars ()->Get ( "fov", fFOV );
g_pGame->GetSettings ()->SetFieldOfView ( Clamp ( 70.f, fFOV, 100.f ) );
g_pGame->GetSettings ()->SetFieldOfViewVehicleMax ( 100 );

// Dimension
SetAllDimensions ( 0 );

Expand Down Expand Up @@ -5526,7 +5531,7 @@ void CClientGame::ResetMapInfo ( void )
// Water-colour
g_pMultiplayer->ResetWater ( );

// Water
// Water
GetManager ()->GetWaterManager ()->ResetWorldWaterLevel ();

// Re-enable interior sounds and furniture
Expand Down
1 change: 0 additions & 1 deletion MTA10/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4443,7 +4443,6 @@ bool CStaticFunctionDefinitions::SetCameraMatrix ( const CVector& vecPosition, C
return true;
}


bool CStaticFunctionDefinitions::SetCameraTarget ( CClientEntity * pEntity )
{
assert ( pEntity );
Expand Down
2 changes: 1 addition & 1 deletion MTA10/mods/shared_logic/CClientCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ void CClientCamera::SetFocus ( CClientPlayer* pPlayer, eCamMode eMode, bool bSmo
// Should we attach to a player, or set the camera to free?
if ( pPlayer )
{
// Attach the camera to the player vehicle if in a vehicle. To the player model otherwize
// Attach the camera to the player vehicle if in a vehicle. To the player model otherwise
CClientVehicle* pVehicle = pPlayer->GetOccupiedVehicle ();
if ( pVehicle )
{
Expand Down
67 changes: 67 additions & 0 deletions MTA10/mods/shared_logic/lua/CLuaFunctionDefs.Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,73 @@ int CLuaFunctionDefs::SetCameraMatrix ( lua_State* luaVM )
return 1;
}

// Only when onfoot/invehicle
int CLuaFunctionDefs::SetCameraFieldOfView ( lua_State* luaVM )
{
float fFOV; eFieldOfViewMode eMode;
CScriptArgReader argStream ( luaVM );

argStream.ReadEnumString ( eMode );
argStream.ReadNumber ( fFOV );

if ( fFOV < 0 || fFOV > 179 )
argStream.SetCustomError ( "Outside 0-179 boundaries" );

if ( !argStream.HasErrors () )
{
if (eMode == FOV_MODE_PLAYER)
g_pGame->GetSettings ()->SetFieldOfViewPlayer ( fFOV );
else if ( eMode == FOV_MODE_VEHICLE )
g_pGame->GetSettings ()->SetFieldOfViewVehicle ( fFOV );
else if ( eMode == FOV_MODE_VEHICLE_MAX )
g_pGame->GetSettings ()->SetFieldOfViewVehicleMax ( fFOV );
else {
argStream.m_iIndex = 1;
m_pScriptDebugging->LogCustom ( luaVM, SString("Enum not yet implemented: " + EnumToString ( eMode )) );
lua_pushboolean ( luaVM, false );
return 1;
}
lua_pushboolean ( luaVM, true );
return 1;
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );

lua_pushboolean ( luaVM, false );
return 1;
}

// Only when onfoot/invehicle
int CLuaFunctionDefs::GetCameraFieldOfView ( lua_State* luaVM )
{
eFieldOfViewMode eMode;
CScriptArgReader argStream ( luaVM );

argStream.ReadEnumString ( eMode );

if ( !argStream.HasErrors() )
{
float fFOV;
if ( eMode == FOV_MODE_PLAYER )
fFOV = g_pGame->GetSettings ()->GetFieldOfViewPlayer ();
else if ( eMode == FOV_MODE_VEHICLE )
fFOV = g_pGame->GetSettings ()->GetFieldOfViewVehicle ();
else if ( eMode == FOV_MODE_VEHICLE_MAX )
fFOV = g_pGame->GetSettings ()->GetFieldOfViewVehicleMax ();
else {
argStream.m_iIndex = 1;
m_pScriptDebugging->LogCustom ( luaVM, SString ( "Enum not yet implemented: " + EnumToString ( eMode ) ) );
lua_pushboolean ( luaVM, false );
return 1;
}

lua_pushnumber ( luaVM, fFOV );
return 1;
}

lua_pushboolean ( luaVM, false );
return 1;
}

int CLuaFunctionDefs::SetCameraTarget ( lua_State* luaVM )
{
Expand Down
6 changes: 4 additions & 2 deletions MTA10/mods/shared_logic/lua/CLuaFunctionDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -518,13 +518,15 @@ class CLuaFunctionDefs
LUA_DECLARE ( GetCameraMatrix );
LUA_DECLARE ( GetCameraTarget );
LUA_DECLARE ( GetCameraInterior );
LUA_DECLARE ( GetCameraGoggleEffect );
LUA_DECLARE ( GetCameraShakeLevel );
LUA_DECLARE ( GetCameraGoggleEffect );
LUA_DECLARE ( GetCameraShakeLevel );
LUA_DECLARE ( GetCameraFieldOfView );

// Cam set funcs
LUA_DECLARE ( SetCameraMatrix );
LUA_DECLARE ( SetCameraTarget );
LUA_DECLARE ( SetCameraInterior );
LUA_DECLARE ( SetCameraFieldOfView );
LUA_DECLARE ( FadeCamera );
LUA_DECLARE ( SetCameraClip );
LUA_DECLARE ( GetCameraClip );
Expand Down
7 changes: 7 additions & 0 deletions MTA10/mods/shared_logic/lua/CLuaFunctionParseHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,13 @@ IMPLEMENT_ENUM_BEGIN(eWebBrowserMouseButton)
ADD_ENUM(BROWSER_MOUSEBUTTON_RIGHT, "right")
IMPLEMENT_ENUM_END("webbrowser-mouse-button")

IMPLEMENT_ENUM_BEGIN(eFieldOfViewMode)
ADD_ENUM(FOV_MODE_PLAYER, "player")
ADD_ENUM(FOV_MODE_VEHICLE, "vehicle")
ADD_ENUM(FOV_MODE_VEHICLE_MAX, "vehicle_max")
ADD_ENUM(FOV_MODE_AIMING, "aiming")
IMPLEMENT_ENUM_END("fieldofview-mode")

//
// Get best guess at name of userdata type
//
Expand Down
8 changes: 8 additions & 0 deletions MTA10/mods/shared_logic/lua/CLuaFunctionParseHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ DECLARE_ENUM( eDXVerticalAlign );
DECLARE_ENUM( eHudComponent );


enum eFieldOfViewMode
{
FOV_MODE_PLAYER,
FOV_MODE_VEHICLE,
FOV_MODE_VEHICLE_MAX,
FOV_MODE_AIMING
};
DECLARE_ENUM ( eFieldOfViewMode );

// class -> class type
inline eCGUIType GetClassType ( CGUIButton* ) { return CGUI_BUTTON; }
Expand Down
4 changes: 3 additions & 1 deletion MTA10/mods/shared_logic/lua/CLuaMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1449,14 +1449,16 @@ void CLuaMain::AddCameraClass ( lua_State* luaVM )
lua_classfunction ( luaVM, "getInterior", "getCameraInterior" );
lua_classfunction ( luaVM, "getViewMode", "getCameraViewMode" );
lua_classfunction ( luaVM, "getMatrix", CLuaOOPDefs::GetCameraMatrix );
lua_classfunction ( luaVM, "setMatrix", "setCameraMatrix" );
lua_classfunction ( luaVM, "getFieldOfView", "getCameraFieldOfView" );
lua_classfunction ( luaVM, "getGoggleEffect", "getCameraGoggleEffect" );
lua_classfunction ( luaVM, "getClip", "getCameraClip" );
lua_classfunction ( luaVM, "getFarClipDistance", "getFarClipDistance" );
lua_classfunction ( luaVM, "getNearClipDistance", "getNearClipDistance" );

lua_classfunction ( luaVM, "setPosition", CLuaOOPDefs::SetCameraPosition );
lua_classfunction ( luaVM, "setRotation", CLuaOOPDefs::SetCameraRotation );
lua_classfunction ( luaVM, "setMatrix", "setCameraMatrix" );
lua_classfunction ( luaVM, "setFieldOfView", "setCameraFieldOfView" );
lua_classfunction ( luaVM, "setInterior", "setCameraInterior" );
lua_classfunction ( luaVM, "setTarget", "setCameraTarget" );
lua_classfunction ( luaVM, "setViewMode", "setCameraViewMode" );
Expand Down
6 changes: 4 additions & 2 deletions MTA10/mods/shared_logic/lua/CLuaManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -746,11 +746,13 @@ void CLuaManager::LoadCFunctions ( void )
CLuaCFunctions::AddFunction ( "getCameraMatrix", CLuaFunctionDefs::GetCameraMatrix );
CLuaCFunctions::AddFunction ( "getCameraTarget", CLuaFunctionDefs::GetCameraTarget );
CLuaCFunctions::AddFunction ( "getCameraInterior", CLuaFunctionDefs::GetCameraInterior );
CLuaCFunctions::AddFunction ( "getCameraGoggleEffect", CLuaFunctionDefs::GetCameraGoggleEffect );
CLuaCFunctions::AddFunction ( "getCameraShakeLevel", CLuaFunctionDefs::GetCameraShakeLevel );
CLuaCFunctions::AddFunction ( "getCameraGoggleEffect", CLuaFunctionDefs::GetCameraGoggleEffect );
CLuaCFunctions::AddFunction ( "getCameraShakeLevel", CLuaFunctionDefs::GetCameraShakeLevel );
CLuaCFunctions::AddFunction ( "getCameraFieldOfView", CLuaFunctionDefs::GetCameraFieldOfView );

// Cam set funcs
CLuaCFunctions::AddFunction ( "setCameraMatrix", CLuaFunctionDefs::SetCameraMatrix );
CLuaCFunctions::AddFunction ( "setCameraFieldOfView", CLuaFunctionDefs::SetCameraFieldOfView );
CLuaCFunctions::AddFunction ( "setCameraTarget", CLuaFunctionDefs::SetCameraTarget );
CLuaCFunctions::AddFunction ( "setCameraInterior", CLuaFunctionDefs::SetCameraInterior );
CLuaCFunctions::AddFunction ( "fadeCamera", CLuaFunctionDefs::FadeCamera );
Expand Down
7 changes: 6 additions & 1 deletion MTA10/sdk/game/CSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,12 @@ class CGameSettings
virtual void SetRadarMode ( eRadarMode hudMode ) = 0;

virtual void SetFieldOfView ( float fAngle ) = 0;
virtual float GetFieldOfView ( void ) = 0;
virtual void SetFieldOfViewPlayer ( float fAngle ) = 0;
virtual void SetFieldOfViewVehicle ( float fAngle ) = 0;
virtual void SetFieldOfViewVehicleMax( float fAngle ) = 0;
virtual float GetFieldOfViewPlayer ( void ) = 0;
virtual float GetFieldOfViewVehicle ( void ) = 0;
virtual float GetFieldOfViewVehicleMax( void ) = 0;

virtual void Save ( void ) = 0;
};
Expand Down