Skip to content

Commit 5d269f7

Browse files
committed
Add JPEGQuality option to Options.ini (default 80)
1 parent 1c23940 commit 5d269f7

File tree

11 files changed

+37
-5
lines changed

11 files changed

+37
-5
lines changed

Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DScreenshot.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static DWORD WINAPI screenshotThreadFunc(LPVOID param)
6565
return 0;
6666
}
6767

68-
void W3D_TakeCompressedScreenshot(ScreenshotFormat format, int quality)
68+
void W3D_TakeCompressedScreenshot(ScreenshotFormat format, int quality = 0)
6969
{
7070
char leafname[256];
7171
char pathname[1024];
@@ -130,6 +130,9 @@ void W3D_TakeCompressedScreenshot(ScreenshotFormat format, int quality)
130130
surfaceCopy->Release_Ref();
131131
surfaceCopy = NULL;
132132

133+
if (quality <= 0 && format == SCREENSHOT_JPEG)
134+
quality = TheGlobalData->m_jpegQuality;
135+
133136
ScreenshotThreadData* threadData = new ScreenshotThreadData();
134137
threadData->imageData = image;
135138
threadData->width = width;

Generals/Code/GameEngine/Include/Common/GlobalData.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ class GlobalData : public SubsystemInterface
139139
Int m_terrainLODTargetTimeMS;
140140
Bool m_useAlternateMouse;
141141
Bool m_rightMouseAlwaysScrolls;
142+
Int m_jpegQuality;
142143
Bool m_useWaterPlane;
143144
Bool m_useCloudPlane;
144145
Bool m_useShadowVolumes;

Generals/Code/GameEngine/Include/Common/UserPreferences.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ class OptionPreferences : public UserPreferences
9191
void setOnlineIPAddress(UnsignedInt IP); // convenience function
9292
Bool getArchiveReplaysEnabled() const; // convenience function
9393
Bool getAlternateMouseModeEnabled(void); // convenience function
94+
Int getJPEGQuality(void); // convenience function
9495
Real getScrollFactor(void); // convenience function
9596
Bool getDrawScrollAnchor(void);
9697
Bool getMoveScrollAnchor(void);

Generals/Code/GameEngine/Source/Common/GlobalData.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,7 @@ void GlobalData::parseGameDataDefinition( INI* ini )
11771177
// override INI values with user preferences
11781178
OptionPreferences optionPref;
11791179
TheWritableGlobalData->m_useAlternateMouse = optionPref.getAlternateMouseModeEnabled();
1180+
TheWritableGlobalData->m_jpegQuality = optionPref.getJPEGQuality();
11801181
TheWritableGlobalData->m_keyboardScrollFactor = optionPref.getScrollFactor();
11811182
TheWritableGlobalData->m_drawScrollAnchor = optionPref.getDrawScrollAnchor();
11821183
TheWritableGlobalData->m_moveScrollAnchor = optionPref.getMoveScrollAnchor();

Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,17 @@ Bool OptionPreferences::getAlternateMouseModeEnabled(void)
335335
return FALSE;
336336
}
337337

338+
Int OptionPreferences::getJPEGQuality(void)
339+
{
340+
OptionPreferences::const_iterator it = find("JPEGQuality");
341+
if (it == end())
342+
return 80;
343+
344+
Int quality = atoi(it->second.str());
345+
if (quality < 1) quality = 1;
346+
if (quality > 100) quality = 100;
347+
return quality;
348+
}
338349

339350
Real OptionPreferences::getScrollFactor(void)
340351
{

Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2889,12 +2889,12 @@ static void CreateBMPFile(LPTSTR pszFile, char *image, Int width, Int height)
28892889

28902890
void W3DDisplay::takeScreenShotCompressed(void)
28912891
{
2892-
W3D_TakeCompressedScreenshot(SCREENSHOT_JPEG, 80);
2892+
W3D_TakeCompressedScreenshot(SCREENSHOT_JPEG);
28932893
}
28942894

28952895
void W3DDisplay::takeScreenShotPNG(void)
28962896
{
2897-
W3D_TakeCompressedScreenshot(SCREENSHOT_PNG, 0);
2897+
W3D_TakeCompressedScreenshot(SCREENSHOT_PNG);
28982898
}
28992899

29002900
/** Start/Stop capturing an AVI movie*/

GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ class GlobalData : public SubsystemInterface
143143
Bool m_clientRetaliationModeEnabled;
144144
Bool m_doubleClickAttackMove;
145145
Bool m_rightMouseAlwaysScrolls;
146+
Int m_jpegQuality;
146147
Bool m_useWaterPlane;
147148
Bool m_useCloudPlane;
148149
Bool m_useShadowVolumes;

GeneralsMD/Code/GameEngine/Include/Common/UserPreferences.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ class OptionPreferences : public UserPreferences
9393
Bool getAlternateMouseModeEnabled(void); // convenience function
9494
Bool getRetaliationModeEnabled(); // convenience function
9595
Bool getDoubleClickAttackMoveEnabled(void); // convenience function
96+
Int getJPEGQuality(void); // convenience function
9697
Real getScrollFactor(void); // convenience function
9798
Bool getDrawScrollAnchor(void);
9899
Bool getMoveScrollAnchor(void);

GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,6 +1205,7 @@ void GlobalData::parseGameDataDefinition( INI* ini )
12051205
TheWritableGlobalData->m_useAlternateMouse = optionPref.getAlternateMouseModeEnabled();
12061206
TheWritableGlobalData->m_clientRetaliationModeEnabled = optionPref.getRetaliationModeEnabled();
12071207
TheWritableGlobalData->m_doubleClickAttackMove = optionPref.getDoubleClickAttackMoveEnabled();
1208+
TheWritableGlobalData->m_jpegQuality = optionPref.getJPEGQuality();
12081209
TheWritableGlobalData->m_keyboardScrollFactor = optionPref.getScrollFactor();
12091210
TheWritableGlobalData->m_drawScrollAnchor = optionPref.getDrawScrollAnchor();
12101211
TheWritableGlobalData->m_moveScrollAnchor = optionPref.getMoveScrollAnchor();

GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,18 @@ Bool OptionPreferences::getDoubleClickAttackMoveEnabled(void)
368368
return FALSE;
369369
}
370370

371+
Int OptionPreferences::getJPEGQuality(void)
372+
{
373+
OptionPreferences::const_iterator it = find("JPEGQuality");
374+
if (it == end())
375+
return 80;
376+
377+
Int quality = atoi(it->second.str());
378+
if (quality < 1) quality = 1;
379+
if (quality > 100) quality = 100;
380+
return quality;
381+
}
382+
371383
Real OptionPreferences::getScrollFactor(void)
372384
{
373385
OptionPreferences::const_iterator it = find("ScrollFactor");

0 commit comments

Comments
 (0)