Skip to content

Commit

Permalink
fixes #54 #58
Browse files Browse the repository at this point in the history
  • Loading branch information
kirides committed Jul 2, 2021
1 parent b940e49 commit 684c2f3
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
17 changes: 11 additions & 6 deletions D3D11Engine/D3D11GraphicsEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4676,10 +4676,12 @@ LRESULT D3D11GraphicsEngine::OnWindowMessage( HWND hWnd, UINT msg, WPARAM wParam
switch ( msg ) {
case WM_ACTIVATE:
case WM_ACTIVATEAPP:
if ( wParam == 0 ) {
m_isWindowActive = false;
} else {
m_isWindowActive = true;
if ( Engine::GAPI->GetRendererState().RendererSettings.EnableInactiveFpsLock ) {
if ( wParam == 0 ) {
m_isWindowActive = false;
} else {
m_isWindowActive = true;
}
}
break;
}
Expand Down Expand Up @@ -5665,9 +5667,12 @@ void D3D11GraphicsEngine::DrawString( const std::string& str, float x, float y,
if ( !font ) return;
if ( !font->tex ) return;
float UIScale = 1.0f;

static int savedBarSize = -1;
if ( oCGame::GetGame() ) {
UIScale = (float)oCGame::GetGame()->hpBar->psizex / 180;
if ( savedBarSize == -1 ) {
savedBarSize = oCGame::GetGame()->swimBar->psizex;
}
UIScale = (float)savedBarSize / 180;
}

constexpr float FONT_CACHE_PRIO = -1;
Expand Down
9 changes: 7 additions & 2 deletions D3D11Engine/GothicAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,9 @@ void GothicAPI::SetEnableGothicInput( bool value ) {
return; // Do nothing, we decremented the counter and it's still not 0
}

if ( oCGame::GetPlayer() ) oCGame::GetPlayer()->SetSleeping( value ? 0 : 1 );
if ( oCGame::GetGame() && oCGame::GetGame()->_zCSession_camVob ) oCGame::GetGame()->_zCSession_camVob->SetSleeping( value ? 0 : 1 );

if ( !value )
disableCounter++;

Expand Down Expand Up @@ -3589,7 +3592,8 @@ XRESULT GothicAPI::SaveMenuSettings( const std::string& file ) {
WritePrivateProfileStringA( "General", "EnableGodRays", std::to_string( s.EnableGodRays ? TRUE : FALSE ).c_str(), ini.c_str() );
WritePrivateProfileStringA( "General", "AllowNormalmaps", std::to_string( s.AllowNormalmaps ? TRUE : FALSE ).c_str(), ini.c_str() );
WritePrivateProfileStringA( "General", "AllowNumpadKeys", std::to_string( s.AllowNumpadKeys ? TRUE : FALSE ).c_str(), ini.c_str() );

WritePrivateProfileStringA( "General", "EnableInactiveFpsLock", std::to_string( s.EnableInactiveFpsLock ? TRUE : FALSE ).c_str(), ini.c_str() );

/*
* Draw-distance is saved on a per World basis using SaveRendererWorldSettings
*/
Expand Down Expand Up @@ -3671,7 +3675,8 @@ XRESULT GothicAPI::LoadMenuSettings( const std::string& file ) {
s.EnableGodRays = GetPrivateProfileBoolA( "General", "EnableGodRays", defaultRendererSettings.EnableGodRays, ini );
s.AllowNormalmaps = GetPrivateProfileBoolA( "General", "AllowNormalmaps", defaultRendererSettings.AllowNormalmaps, ini );
s.AllowNumpadKeys = GetPrivateProfileBoolA( "General", "AllowNumpadKeys", defaultRendererSettings.AllowNumpadKeys, ini );

s.AllowNumpadKeys = GetPrivateProfileBoolA( "General", "EnableInactiveFpsLock", defaultRendererSettings.EnableInactiveFpsLock, ini );

/*
* Draw-distance is Loaded on a per World basis using LoadRendererWorldSettings
*/
Expand Down
2 changes: 2 additions & 0 deletions D3D11Engine/GothicGraphicsState.h
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,7 @@ struct GothicRendererSettings {
SmoothShadowCameraUpdate = true;
DisplayFlip = false;
LowLatency = false;
EnableInactiveFpsLock = true;
}

void SetupOldWorldSpecificValues() {
Expand Down Expand Up @@ -768,6 +769,7 @@ struct GothicRendererSettings {
bool LowLatency;
bool StretchWindow;
bool SmoothShadowCameraUpdate;
bool EnableInactiveFpsLock;
};

struct GothicRendererTiming {
Expand Down
1 change: 1 addition & 0 deletions D3D11Engine/GothicMemoryLocations1_08k.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ struct GothicMemoryLocations {
static const unsigned int MASK_SkeepingMode = 3;

static const unsigned int EndMovement = 0x005F0B60;
static const unsigned int SetSleeping = 0x005D7250;
};

struct zCInput {
Expand Down
2 changes: 1 addition & 1 deletion D3D11Engine/GothicMemoryLocations2_6_fix.h
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ struct GothicMemoryLocations {
static const unsigned int MASK_SkeepingMode = 3;

static const unsigned int EndMovement = 0x0061E0D0;

static const unsigned int SetSleeping = 0x00602930;
};

struct zCVisual {
Expand Down
4 changes: 3 additions & 1 deletion D3D11Engine/zCVob.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ class zCVob {

return (flags & GothicMemoryLocations::zCVob::MASK_SkeepingMode);
}

void SetSleeping(int on) {
XCALL( GothicMemoryLocations::zCVob::SetSleeping );
}
/** Returns whether the visual of this vob is visible */
bool GetShowVisual() {
//unsigned int flags = *(unsigned int*)THISPTR_OFFSET( GothicMemoryLocations::zCVob::Offset_Flags );
Expand Down

0 comments on commit 684c2f3

Please sign in to comment.