Skip to content

Commit 29e0f82

Browse files
committed
Add Script_FontScale
1 parent d6e403d commit 29e0f82

File tree

7 files changed

+346
-0
lines changed

7 files changed

+346
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--- Script_FontScale ---
2+
3+
0. Description
4+
Verhindert, dass sich die Größe der Fokusnamen in Abhängigkeit von der Auflösung
5+
des Spiels ändert, indem die Schriftgröße des Fokusnamens entsprechend der
6+
Rendering-Auflösung skaliert wird.
7+
8+
1. Installation
9+
Der Ordner 'scripts' muss ins Gothic 3 Installationverzeichnis kopiert werden.
10+
Es ist nicht notwendig ein neues Spiel zu beginnen.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--- Script_FontScale ---
2+
3+
0. Description
4+
Prevents the size of focus names from changing depending on the resolution of
5+
the game, by scaling the focus name font size according to the rendering resolution.
6+
7+
1. Installation
8+
The 'scripts' folder has to be copied into the Gothic 3 install folder.
9+
There is no need to start a new game.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#include "Script_FontScale.h"
2+
3+
#include "util/Memory.h"
4+
#include "util/Hook.h"
5+
#include "util/Util.h"
6+
7+
namespace
8+
{
9+
const GEFloat FOCUS_NAME_FONT_SCALE_FACTOR = 1 / 1080.0f;
10+
const GEInt DEFAULT_FONT_HEIGHT = 24;
11+
12+
void GE_STDCALL DrawFocusNames_UpdateFont(gCGUIEntityRenderer & a_FocusNameRenderer)
13+
{
14+
static GEU32 s_LastViewportHeight = 1080;
15+
16+
eCGfxShared::eSGfxViewport Viewport {};
17+
if (eCGfxAdmin * pGfxAdmin = FindModule<eCGfxAdmin>())
18+
pGfxAdmin->GetAccessToMixer().GetViewport(Viewport);
19+
20+
GEU32 ViewportHeight = Viewport.Height - Viewport.Y;
21+
if(s_LastViewportHeight != ViewportHeight)
22+
{
23+
s_LastViewportHeight = ViewportHeight;
24+
25+
// GUI scaling has changed, recalculate the font size
26+
GEFloat FontScaleHeight = ViewportHeight * FOCUS_NAME_FONT_SCALE_FACTOR;
27+
GEInt FontHeight = RoundFloat(DEFAULT_FONT_HEIGHT * FontScaleHeight);
28+
29+
eSSetupEngine const & Setup = eCApplication::GetInstance().GetSetupEngineDesc();
30+
31+
// Create font
32+
SFFGUIFont FontConfig;
33+
FontConfig.FaceName = Setup.m_DefaultFont;
34+
FontConfig.Height = FontHeight;
35+
FontConfig.Width = 0;
36+
FontConfig.Weight = Setup.m_bDefaultFontBold ? 800 : 400;
37+
FontConfig.CharSet = 1;
38+
FontConfig.OutPrecision = 0;
39+
FontConfig.Quality = 0;
40+
FontConfig.PitchAndFamily = 0;
41+
FontConfig.Italic = 0;
42+
43+
a_FocusNameRenderer.m_FontIndex = eCGUIModule::GetInstance().GetAdmin().CreateFontA(FontConfig);
44+
}
45+
}
46+
}
47+
48+
void ApplyHooks()
49+
{
50+
// The focus name is rendered with a constant pixel size.
51+
// Therefore when in fullscreen mode, the focus name looks larger in lower resolutions,
52+
// and smaller in higher resolutions.
53+
54+
// Update font used for focus name rendering
55+
static mCCallHook Hook_DrawFocusNames_UpdateFont;
56+
Hook_DrawFocusNames_UpdateFont
57+
.Prepare(RVA_Game(0x7981C), &DrawFocusNames_UpdateFont)
58+
.AddRegArg(mCRegisterBase::mERegisterType_Edi) // gCGUIEntityRenderer &
59+
.InsertCall().Hook();
60+
}
61+
62+
63+
gSScriptInit & GetScriptInit()
64+
{
65+
static gSScriptInit s_ScriptInit;
66+
return s_ScriptInit;
67+
}
68+
69+
extern "C" __declspec( dllexport )
70+
gSScriptInit const * GE_STDCALL ScriptInit( void )
71+
{
72+
ApplyHooks();
73+
74+
return &GetScriptInit();
75+
}
76+
77+
//
78+
// Entry Point
79+
//
80+
81+
BOOL APIENTRY DllMain( HMODULE hModule, DWORD dwReason, LPVOID )
82+
{
83+
switch( dwReason )
84+
{
85+
case DLL_PROCESS_ATTACH:
86+
::DisableThreadLibraryCalls( hModule );
87+
break;
88+
case DLL_PROCESS_DETACH:
89+
break;
90+
}
91+
return TRUE;
92+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef SCRIPT_MOUSE_DRAG_H_INCLUDED
2+
#define SCRIPT_MOUSE_DRAG_H_INCLUDED
3+
4+
#include "Script.h"
5+
6+
gSScriptInit & GetScriptInit();
7+
8+
#endif
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
Microsoft Visual Studio Solution File, Format Version 12.00
2+
# Visual Studio 2013
3+
VisualStudioVersion = 12.0.31101.0
4+
MinimumVisualStudioVersion = 10.0.40219.1
5+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Script_FontScale", "Script_FontScale.vcxproj", "{01579160-3197-46CB-9663-9EB62EFDF62A}"
6+
EndProject
7+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Script", "..\..\Script.vcxproj", "{DF45B4AC-7FD2-4C19-9E70-6EE4DC96B604}"
8+
EndProject
9+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Engine", "..\..\Engine.vcxproj", "{F385328B-69B2-4E58-B520-9562EFD53AD8}"
10+
EndProject
11+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Game", "..\..\Game.vcxproj", "{F74F8EFB-8610-40F4-BFEC-03FB5D4190D7}"
12+
EndProject
13+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GFC", "..\..\GFC.vcxproj", "{84E2573C-0D33-417F-A740-B42636728ABC}"
14+
EndProject
15+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SharedBase", "..\..\SharedBase.vcxproj", "{7823C28A-70F8-484E-A6DC-CCEFEBC34C03}"
16+
EndProject
17+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Importer", "..\..\Importer.vcxproj", "{23213CDA-14E6-4EE1-B018-995D09AE753D}"
18+
EndProject
19+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Asmjit", "..\..\Shared\Asmjit\Asmjit.vcxproj", "{32A1BE07-45F2-4B54-9CF0-992DFFC8D06A}"
20+
EndProject
21+
Global
22+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
23+
Debug|Win32 = Debug|Win32
24+
Release|Win32 = Release|Win32
25+
EndGlobalSection
26+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
27+
{01579160-3197-46CB-9663-9EB62EFDF62A}.Debug|Win32.ActiveCfg = Debug|Win32
28+
{01579160-3197-46CB-9663-9EB62EFDF62A}.Debug|Win32.Build.0 = Debug|Win32
29+
{01579160-3197-46CB-9663-9EB62EFDF62A}.Release|Win32.ActiveCfg = Release|Win32
30+
{01579160-3197-46CB-9663-9EB62EFDF62A}.Release|Win32.Build.0 = Release|Win32
31+
{DF45B4AC-7FD2-4C19-9E70-6EE4DC96B604}.Debug|Win32.ActiveCfg = Debug|Win32
32+
{DF45B4AC-7FD2-4C19-9E70-6EE4DC96B604}.Debug|Win32.Build.0 = Debug|Win32
33+
{DF45B4AC-7FD2-4C19-9E70-6EE4DC96B604}.Release|Win32.ActiveCfg = Release|Win32
34+
{DF45B4AC-7FD2-4C19-9E70-6EE4DC96B604}.Release|Win32.Build.0 = Release|Win32
35+
{F385328B-69B2-4E58-B520-9562EFD53AD8}.Debug|Win32.ActiveCfg = Debug|Win32
36+
{F385328B-69B2-4E58-B520-9562EFD53AD8}.Debug|Win32.Build.0 = Debug|Win32
37+
{F385328B-69B2-4E58-B520-9562EFD53AD8}.Release|Win32.ActiveCfg = Release|Win32
38+
{F385328B-69B2-4E58-B520-9562EFD53AD8}.Release|Win32.Build.0 = Release|Win32
39+
{F74F8EFB-8610-40F4-BFEC-03FB5D4190D7}.Debug|Win32.ActiveCfg = Debug|Win32
40+
{F74F8EFB-8610-40F4-BFEC-03FB5D4190D7}.Debug|Win32.Build.0 = Debug|Win32
41+
{F74F8EFB-8610-40F4-BFEC-03FB5D4190D7}.Release|Win32.ActiveCfg = Release|Win32
42+
{F74F8EFB-8610-40F4-BFEC-03FB5D4190D7}.Release|Win32.Build.0 = Release|Win32
43+
{84E2573C-0D33-417F-A740-B42636728ABC}.Debug|Win32.ActiveCfg = Debug|Win32
44+
{84E2573C-0D33-417F-A740-B42636728ABC}.Debug|Win32.Build.0 = Debug|Win32
45+
{84E2573C-0D33-417F-A740-B42636728ABC}.Release|Win32.ActiveCfg = Release|Win32
46+
{84E2573C-0D33-417F-A740-B42636728ABC}.Release|Win32.Build.0 = Release|Win32
47+
{7823C28A-70F8-484E-A6DC-CCEFEBC34C03}.Debug|Win32.ActiveCfg = Debug|Win32
48+
{7823C28A-70F8-484E-A6DC-CCEFEBC34C03}.Debug|Win32.Build.0 = Debug|Win32
49+
{7823C28A-70F8-484E-A6DC-CCEFEBC34C03}.Release|Win32.ActiveCfg = Release|Win32
50+
{7823C28A-70F8-484E-A6DC-CCEFEBC34C03}.Release|Win32.Build.0 = Release|Win32
51+
{23213CDA-14E6-4EE1-B018-995D09AE753D}.Debug|Win32.ActiveCfg = Debug|Win32
52+
{23213CDA-14E6-4EE1-B018-995D09AE753D}.Debug|Win32.Build.0 = Debug|Win32
53+
{23213CDA-14E6-4EE1-B018-995D09AE753D}.Release|Win32.ActiveCfg = Release|Win32
54+
{23213CDA-14E6-4EE1-B018-995D09AE753D}.Release|Win32.Build.0 = Release|Win32
55+
{32A1BE07-45F2-4B54-9CF0-992DFFC8D06A}.Debug|Win32.ActiveCfg = Debug|Win32
56+
{32A1BE07-45F2-4B54-9CF0-992DFFC8D06A}.Debug|Win32.Build.0 = Debug|Win32
57+
{32A1BE07-45F2-4B54-9CF0-992DFFC8D06A}.Release|Win32.ActiveCfg = Release|Win32
58+
{32A1BE07-45F2-4B54-9CF0-992DFFC8D06A}.Release|Win32.Build.0 = Release|Win32
59+
EndGlobalSection
60+
GlobalSection(SolutionProperties) = preSolution
61+
HideSolutionNode = FALSE
62+
EndGlobalSection
63+
EndGlobal
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
</ItemGroup>
13+
<PropertyGroup Label="Globals">
14+
<ProjectGuid>{01579160-3197-46CB-9663-9EB62EFDF62A}</ProjectGuid>
15+
<RootNamespace>Script_FontScale</RootNamespace>
16+
</PropertyGroup>
17+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
18+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
19+
<ConfigurationType>DynamicLibrary</ConfigurationType>
20+
<PlatformToolset>v120</PlatformToolset>
21+
</PropertyGroup>
22+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
23+
<ConfigurationType>DynamicLibrary</ConfigurationType>
24+
<PlatformToolset>v120</PlatformToolset>
25+
</PropertyGroup>
26+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
27+
<ImportGroup Label="ExtensionSettings">
28+
</ImportGroup>
29+
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
30+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
31+
<Import Project="..\..\GothicScriptsRelease.props" />
32+
<Import Project="..\..\Shared\Asmjit\Asmjit.props" />
33+
</ImportGroup>
34+
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
35+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
36+
<Import Project="..\..\GothicScriptsDebug.props" />
37+
<Import Project="..\..\Shared\Asmjit\Asmjit.props" />
38+
</ImportGroup>
39+
<PropertyGroup Label="UserMacros" />
40+
<PropertyGroup>
41+
<_ProjectFileVersion>12.0.30501.0</_ProjectFileVersion>
42+
</PropertyGroup>
43+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
44+
<ClCompile>
45+
<AdditionalIncludeDirectories>.\;..\..\Shared\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
46+
<ExceptionHandling />
47+
</ClCompile>
48+
</ItemDefinitionGroup>
49+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
50+
<ClCompile>
51+
<AdditionalIncludeDirectories>.\;..\..\Shared\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
52+
<ExceptionHandling />
53+
</ClCompile>
54+
<Link />
55+
</ItemDefinitionGroup>
56+
<ItemGroup>
57+
<ClCompile Include="..\..\Shared\util\AsmjitUtil.cpp" />
58+
<ClCompile Include="..\..\Shared\util\Debug.cpp" />
59+
<ClCompile Include="..\..\Shared\util\Hook.cpp" />
60+
<ClCompile Include="..\..\Shared\util\Logging.cpp" />
61+
<ClCompile Include="..\..\Shared\util\Memory.cpp" />
62+
<ClCompile Include="..\..\Shared\util\Util.cpp" />
63+
<ClCompile Include="Script_FontScale.cpp" />
64+
</ItemGroup>
65+
<ItemGroup>
66+
<ClInclude Include="..\..\Shared\util\AsmjitUtil.h" />
67+
<ClInclude Include="..\..\Shared\util\Debug.h" />
68+
<ClInclude Include="..\..\Shared\util\Hook.h" />
69+
<ClInclude Include="..\..\Shared\util\Logging.h" />
70+
<ClInclude Include="..\..\Shared\util\Memory.h" />
71+
<ClInclude Include="..\..\Shared\util\Util.h" />
72+
<ClInclude Include="Script_FontScale.h" />
73+
</ItemGroup>
74+
<ItemGroup>
75+
<None Include="..\..\Shared\util\Logging.inl" />
76+
</ItemGroup>
77+
<ItemGroup>
78+
<ProjectReference Include="..\..\Engine.vcxproj">
79+
<Project>{f385328b-69b2-4e58-b520-9562efd53ad8}</Project>
80+
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
81+
</ProjectReference>
82+
<ProjectReference Include="..\..\Game.vcxproj">
83+
<Project>{f74f8efb-8610-40f4-bfec-03fb5d4190d7}</Project>
84+
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
85+
</ProjectReference>
86+
<ProjectReference Include="..\..\GFC.vcxproj">
87+
<Project>{84e2573c-0d33-417f-a740-b42636728abc}</Project>
88+
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
89+
</ProjectReference>
90+
<ProjectReference Include="..\..\Importer.vcxproj">
91+
<Project>{23213cda-14e6-4ee1-b018-995d09ae753d}</Project>
92+
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
93+
</ProjectReference>
94+
<ProjectReference Include="..\..\Script.vcxproj">
95+
<Project>{df45b4ac-7fd2-4c19-9e70-6ee4dc96b604}</Project>
96+
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
97+
</ProjectReference>
98+
<ProjectReference Include="..\..\SharedBase.vcxproj">
99+
<Project>{7823c28a-70f8-484e-a6dc-ccefebc34c03}</Project>
100+
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
101+
</ProjectReference>
102+
<ProjectReference Include="..\..\Shared\Asmjit\Asmjit.vcxproj">
103+
<Project>{32a1be07-45f2-4b54-9cf0-992dffc8d06a}</Project>
104+
</ProjectReference>
105+
</ItemGroup>
106+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
107+
<ImportGroup Label="ExtensionTargets">
108+
</ImportGroup>
109+
</Project>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="util">
5+
<UniqueIdentifier>{a473925b-9924-47ad-b92f-dc6fbaf970cb}</UniqueIdentifier>
6+
</Filter>
7+
</ItemGroup>
8+
<ItemGroup>
9+
<ClCompile Include="..\..\Shared\util\AsmjitUtil.cpp">
10+
<Filter>util</Filter>
11+
</ClCompile>
12+
<ClCompile Include="..\..\Shared\util\Debug.cpp">
13+
<Filter>util</Filter>
14+
</ClCompile>
15+
<ClCompile Include="..\..\Shared\util\Hook.cpp">
16+
<Filter>util</Filter>
17+
</ClCompile>
18+
<ClCompile Include="..\..\Shared\util\Logging.cpp">
19+
<Filter>util</Filter>
20+
</ClCompile>
21+
<ClCompile Include="..\..\Shared\util\Memory.cpp">
22+
<Filter>util</Filter>
23+
</ClCompile>
24+
<ClCompile Include="..\..\Shared\util\Util.cpp">
25+
<Filter>util</Filter>
26+
</ClCompile>
27+
<ClCompile Include="Script_FontScale.cpp" />
28+
</ItemGroup>
29+
<ItemGroup>
30+
<ClInclude Include="..\..\Shared\util\AsmjitUtil.h">
31+
<Filter>util</Filter>
32+
</ClInclude>
33+
<ClInclude Include="..\..\Shared\util\Debug.h">
34+
<Filter>util</Filter>
35+
</ClInclude>
36+
<ClInclude Include="..\..\Shared\util\Hook.h">
37+
<Filter>util</Filter>
38+
</ClInclude>
39+
<ClInclude Include="..\..\Shared\util\Logging.h">
40+
<Filter>util</Filter>
41+
</ClInclude>
42+
<ClInclude Include="..\..\Shared\util\Memory.h">
43+
<Filter>util</Filter>
44+
</ClInclude>
45+
<ClInclude Include="..\..\Shared\util\Util.h">
46+
<Filter>util</Filter>
47+
</ClInclude>
48+
<ClInclude Include="Script_FontScale.h" />
49+
</ItemGroup>
50+
<ItemGroup>
51+
<None Include="..\..\Shared\util\Logging.inl">
52+
<Filter>util</Filter>
53+
</None>
54+
</ItemGroup>
55+
</Project>

0 commit comments

Comments
 (0)