@@ -282,61 +282,9 @@ to be resized (does not affect the selected client resolution).
282282 foreach ( var ( translation , name ) in Translation . GetTranslations ( ) )
283283 ddTranslation . AddItem ( new XNADropDownItem { Text = name , Tag = translation } ) ;
284284
285- if ( ClientConfiguration . Instance . ClientGameType == ClientType . TS )
285+ if ( ClientConfiguration . Instance . ClientGameType == ClientType . TS && RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
286286 {
287- lblCompatibilityFixes = new XNALabel ( WindowManager ) ;
288- lblCompatibilityFixes . Name = nameof ( lblCompatibilityFixes ) ;
289- lblCompatibilityFixes . FontIndex = 1 ;
290- lblCompatibilityFixes . Text = "Compatibility Fixes (advanced):" . L10N ( "Client:DTAConfig:TSCompatibilityFixAdv" ) ;
291- AddChild ( lblCompatibilityFixes ) ;
292- lblCompatibilityFixes . CenterOnParent ( ) ;
293- lblCompatibilityFixes . Y = Height - 103 ;
294-
295- lblGameCompatibilityFix = new XNALabel ( WindowManager ) ;
296- lblGameCompatibilityFix . Name = nameof ( lblGameCompatibilityFix ) ;
297- lblGameCompatibilityFix . ClientRectangle = new Rectangle ( 132 ,
298- lblCompatibilityFixes . Bottom + 20 , 0 , 0 ) ;
299- lblGameCompatibilityFix . Text = "DTA/TI/TS Compatibility Fix:" . L10N ( "Client:DTAConfig:TSCompatibilityFix" ) ;
300-
301- btnGameCompatibilityFix = new XNAClientButton ( WindowManager ) ;
302- btnGameCompatibilityFix . Name = nameof ( btnGameCompatibilityFix ) ;
303- btnGameCompatibilityFix . ClientRectangle = new Rectangle (
304- lblGameCompatibilityFix . Right + 20 ,
305- lblGameCompatibilityFix . Y - 4 , UIDesignConstants . BUTTON_WIDTH_133 , UIDesignConstants . BUTTON_HEIGHT ) ;
306- btnGameCompatibilityFix . FontIndex = 1 ;
307- btnGameCompatibilityFix . Text = "Enable" . L10N ( "Client:DTAConfig:Enable" ) ;
308-
309- if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
310- btnGameCompatibilityFix . LeftClick += BtnGameCompatibilityFix_LeftClick ;
311- else
312- btnGameCompatibilityFix . AllowClick = false ;
313-
314- lblMapEditorCompatibilityFix = new XNALabel ( WindowManager ) ;
315- lblMapEditorCompatibilityFix . Name = nameof ( lblMapEditorCompatibilityFix ) ;
316- lblMapEditorCompatibilityFix . ClientRectangle = new Rectangle (
317- lblGameCompatibilityFix . X ,
318- lblGameCompatibilityFix . Bottom + 20 , 0 , 0 ) ;
319- lblMapEditorCompatibilityFix . Text = "FinalSun Compatibility Fix:" . L10N ( "Client:DTAConfig:TSFinalSunFix" ) ;
320-
321- btnMapEditorCompatibilityFix = new XNAClientButton ( WindowManager ) ;
322- btnMapEditorCompatibilityFix . Name = nameof ( btnMapEditorCompatibilityFix ) ;
323- btnMapEditorCompatibilityFix . ClientRectangle = new Rectangle (
324- btnGameCompatibilityFix . X ,
325- lblMapEditorCompatibilityFix . Y - 4 ,
326- btnGameCompatibilityFix . Width ,
327- btnGameCompatibilityFix . Height ) ;
328- btnMapEditorCompatibilityFix . FontIndex = 1 ;
329- btnMapEditorCompatibilityFix . Text = "Enable" . L10N ( "Client:DTAConfig:TSButtonEnable" ) ;
330-
331- if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
332- btnMapEditorCompatibilityFix . LeftClick += BtnMapEditorCompatibilityFix_LeftClick ;
333- else
334- btnMapEditorCompatibilityFix . AllowClick = false ;
335-
336- AddChild ( lblGameCompatibilityFix ) ;
337- AddChild ( btnGameCompatibilityFix ) ;
338- AddChild ( lblMapEditorCompatibilityFix ) ;
339- AddChild ( btnMapEditorCompatibilityFix ) ;
287+ AddCompatibilityFixControls ( ) ;
340288 }
341289
342290 AddChild ( chkWindowedMode ) ;
@@ -358,6 +306,96 @@ to be resized (does not affect the selected client resolution).
358306 AddChild ( ddIngameResolution ) ;
359307 }
360308
309+ [ SupportedOSPlatform ( "windows" ) ]
310+ private void AddCompatibilityFixControls ( )
311+ {
312+ lblCompatibilityFixes = new XNALabel ( WindowManager ) ;
313+ lblCompatibilityFixes . Name = "lblCompatibilityFixes" ;
314+ lblCompatibilityFixes . FontIndex = 1 ;
315+ lblCompatibilityFixes . Text = "Legacy Compatibility Fixes:" ;
316+ AddChild ( lblCompatibilityFixes ) ;
317+ lblCompatibilityFixes . CenterOnParent ( ) ;
318+ lblCompatibilityFixes . Y = Height - 97 ;
319+
320+ lblGameCompatibilityFix = new XNALabel ( WindowManager ) ;
321+ lblGameCompatibilityFix . Name = "lblGameCompatibilityFix" ;
322+ lblGameCompatibilityFix . ClientRectangle = new Rectangle ( 132 ,
323+ lblCompatibilityFixes . Bottom + 20 , 0 , 0 ) ;
324+ lblGameCompatibilityFix . Text = "DTA/TI/TS Compatibility Fix:" ;
325+
326+ btnGameCompatibilityFix = new XNAClientButton ( WindowManager ) ;
327+ btnGameCompatibilityFix . Name = "btnGameCompatibilityFix" ;
328+ btnGameCompatibilityFix . ClientRectangle = new Rectangle (
329+ lblGameCompatibilityFix . Right + 20 ,
330+ lblGameCompatibilityFix . Y - 4 , 133 , 23 ) ;
331+ btnGameCompatibilityFix . FontIndex = 1 ;
332+ btnGameCompatibilityFix . Text = "Disable" ;
333+ btnGameCompatibilityFix . LeftClick += BtnGameCompatibilityFix_LeftClick ;
334+
335+ lblMapEditorCompatibilityFix = new XNALabel ( WindowManager ) ;
336+ lblMapEditorCompatibilityFix . Name = "lblMapEditorCompatibilityFix" ;
337+ lblMapEditorCompatibilityFix . ClientRectangle = new Rectangle (
338+ lblGameCompatibilityFix . X ,
339+ lblGameCompatibilityFix . Bottom + 20 , 0 , 0 ) ;
340+ lblMapEditorCompatibilityFix . Text = "FinalSun Compatibility Fix:" ;
341+
342+ btnMapEditorCompatibilityFix = new XNAClientButton ( WindowManager ) ;
343+ btnMapEditorCompatibilityFix . Name = "btnMapEditorCompatibilityFix" ;
344+ btnMapEditorCompatibilityFix . ClientRectangle = new Rectangle (
345+ btnGameCompatibilityFix . X ,
346+ lblMapEditorCompatibilityFix . Y - 4 ,
347+ btnGameCompatibilityFix . Width ,
348+ btnGameCompatibilityFix . Height ) ;
349+ btnMapEditorCompatibilityFix . FontIndex = 1 ;
350+ btnMapEditorCompatibilityFix . Text = "Disable" ;
351+ btnMapEditorCompatibilityFix . LeftClick += BtnMapEditorCompatibilityFix_LeftClick ;
352+
353+ AddChild ( lblGameCompatibilityFix ) ;
354+ AddChild ( btnGameCompatibilityFix ) ;
355+ AddChild ( lblMapEditorCompatibilityFix ) ;
356+ AddChild ( btnMapEditorCompatibilityFix ) ;
357+
358+ RegistryKey regKey = Registry . CurrentUser . OpenSubKey ( "SOFTWARE\\ Tiberian Sun Client" ) ;
359+
360+ if ( regKey == null )
361+ return ;
362+
363+ object tsCompatFixValue = regKey . GetValue ( "TSCompatFixInstalled" , "No" ) ;
364+ string tsCompatFixString = ( string ) tsCompatFixValue ;
365+
366+ if ( tsCompatFixString == "Yes" )
367+ {
368+ GameCompatFixInstalled = true ;
369+ }
370+
371+ object fsCompatFixValue = regKey . GetValue ( "FSCompatFixInstalled" , "No" ) ;
372+ string fsCompatFixString = ( string ) fsCompatFixValue ;
373+
374+ if ( fsCompatFixString == "Yes" )
375+ {
376+ FinalSunCompatFixInstalled = true ;
377+ }
378+
379+ // These compatibility fixes from 2015 are no longer necessary on modern systems.
380+ // They are only offered for uninstallation; if they are not installed, hide them.
381+ if ( ! FinalSunCompatFixInstalled )
382+ {
383+ lblMapEditorCompatibilityFix . Disable ( ) ;
384+ btnMapEditorCompatibilityFix . Disable ( ) ;
385+ }
386+
387+ if ( ! GameCompatFixInstalled )
388+ {
389+ lblGameCompatibilityFix . Disable ( ) ;
390+ btnGameCompatibilityFix . Disable ( ) ;
391+ }
392+
393+ if ( ! FinalSunCompatFixInstalled && ! GameCompatFixInstalled )
394+ {
395+ lblCompatibilityFixes . Disable ( ) ;
396+ }
397+ }
398+
361399 private void GetRenderers ( )
362400 {
363401 renderers = new List < DirectDrawWrapper > ( ) ;
@@ -403,51 +441,6 @@ private void GetRenderers()
403441 public void PostInit ( )
404442 {
405443 Load ( ) ;
406-
407- if ( ! RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
408- return ;
409-
410- if ( ! GameCompatFixInstalled && ! GameCompatFixDeclined )
411- {
412- string defaultGame = ClientConfiguration . Instance . LocalGame ;
413-
414- var messageBox = XNAMessageBox . ShowYesNoDialog ( WindowManager , "New Compatibility Fix" . L10N ( "Client:DTAConfig:TSFixTitle" ) ,
415- string . Format ( ( "A performance-enhancing compatibility fix for modern Windows versions\n " +
416- "has been included in this version of {0}. Enabling it requires\n " +
417- "administrative priveleges. Would you like to install the compatibility fix?\n \n " +
418- "You'll always be able to install or uninstall the compatibility fix later from the options menu." ) . L10N ( "Client:DTAConfig:TSFixTextV2" ) ,
419- defaultGame ) ) ;
420- messageBox . YesClickedAction = MessageBox_YesClicked ;
421- messageBox . NoClickedAction = MessageBox_NoClicked ;
422- }
423- }
424-
425- [ SupportedOSPlatform ( "windows" ) ]
426- private void MessageBox_NoClicked ( XNAMessageBox messageBox )
427- {
428- // Set compatibility fix declined flag in registry
429- try
430- {
431- RegistryKey regKey = Registry . CurrentUser . OpenSubKey ( "SOFTWARE\\ Tiberian Sun Client" ) ;
432-
433- try
434- {
435- regKey = Registry . CurrentUser . OpenSubKey ( "SOFTWARE" , true ) ;
436- regKey = regKey . CreateSubKey ( "Tiberian Sun Client" ) ;
437- regKey . SetValue ( "TSCompatFixDeclined" , "Yes" ) ;
438- }
439- catch ( Exception ex )
440- {
441- Logger . Log ( "Setting TSCompatFixDeclined failed! Returned error: " + ex . ToString ( ) ) ;
442- }
443- }
444- catch { }
445- }
446-
447- [ SupportedOSPlatform ( "windows" ) ]
448- private void MessageBox_YesClicked ( XNAMessageBox messageBox )
449- {
450- BtnGameCompatibilityFix_LeftClick ( messageBox , EventArgs . Empty ) ;
451444 }
452445
453446 [ SupportedOSPlatform ( "windows" ) ]
@@ -469,9 +462,13 @@ private void BtnGameCompatibilityFix_LeftClick(object sender, EventArgs e)
469462 regKey = regKey . CreateSubKey ( "Tiberian Sun Client" ) ;
470463 regKey . SetValue ( "TSCompatFixInstalled" , "No" ) ;
471464
472- btnGameCompatibilityFix . Text = "Enable" ;
473-
474465 GameCompatFixInstalled = false ;
466+
467+ lblGameCompatibilityFix . Disable ( ) ;
468+ btnGameCompatibilityFix . Disable ( ) ;
469+
470+ if ( ! FinalSunCompatFixInstalled )
471+ lblCompatibilityFixes . Disable ( ) ;
475472 }
476473 catch ( Exception ex )
477474 {
@@ -482,31 +479,6 @@ private void BtnGameCompatibilityFix_LeftClick(object sender, EventArgs e)
482479
483480 return ;
484481 }
485-
486- try
487- {
488- Process sdbinst = Process . Start ( "sdbinst.exe" , "-q \" " + ProgramConstants . GamePath + "Resources/compatfix.sdb\" " ) ;
489-
490- sdbinst . WaitForExit ( ) ;
491-
492- Logger . Log ( "DTA/TI/TS Compatibility Fix succesfully installed." ) ;
493- XNAMessageBox . Show ( WindowManager , "Compatibility Fix Installed" . L10N ( "Client:DTAConfig:TSFixInstallSuccessTitle" ) ,
494- "The DTA/TI/TS Compatibility Fix has been succesfully installed." . L10N ( "Client:DTAConfig:TSFixInstallSuccessText" ) ) ;
495-
496- RegistryKey regKey = Registry . CurrentUser . OpenSubKey ( "SOFTWARE" , true ) ;
497- regKey = regKey . CreateSubKey ( "Tiberian Sun Client" ) ;
498- regKey . SetValue ( "TSCompatFixInstalled" , "Yes" ) ;
499-
500- btnGameCompatibilityFix . Text = "Disable" ;
501-
502- GameCompatFixInstalled = true ;
503- }
504- catch ( Exception ex )
505- {
506- Logger . Log ( "Installing DTA/TI/TS Compatibility Fix failed. Error message: " + ex . ToString ( ) ) ;
507- XNAMessageBox . Show ( WindowManager , "Installing Compatibility Fix Failed" . L10N ( "Client:DTAConfig:TSFixInstallFailTitle" ) ,
508- "Installing DTA/TI/TS Compatibility Fix failed. Error message:" . L10N ( "Client:DTAConfig:TSFixInstallFailText" ) + " " + ex . Message ) ;
509- }
510482 }
511483
512484 [ SupportedOSPlatform ( "windows" ) ]
@@ -531,6 +503,12 @@ private void BtnMapEditorCompatibilityFix_LeftClick(object sender, EventArgs e)
531503 "The FinalSun Compatibility Fix has been succesfully uninstalled." . L10N ( "Client:DTAConfig:TSFinalSunFixUninstallText" ) ) ;
532504
533505 FinalSunCompatFixInstalled = false ;
506+
507+ lblMapEditorCompatibilityFix . Disable ( ) ;
508+ btnMapEditorCompatibilityFix . Disable ( ) ;
509+
510+ if ( ! GameCompatFixInstalled )
511+ lblCompatibilityFixes . Disable ( ) ;
534512 }
535513 catch ( Exception ex )
536514 {
@@ -541,31 +519,6 @@ private void BtnMapEditorCompatibilityFix_LeftClick(object sender, EventArgs e)
541519
542520 return ;
543521 }
544-
545- try
546- {
547- Process sdbinst = Process . Start ( "sdbinst.exe" , "-q \" " + ProgramConstants . GamePath + "Resources/FSCompatFix.sdb\" " ) ;
548-
549- sdbinst . WaitForExit ( ) ;
550-
551- RegistryKey regKey = Registry . CurrentUser . OpenSubKey ( "SOFTWARE" , true ) ;
552- regKey = regKey . CreateSubKey ( "Tiberian Sun Client" ) ;
553- regKey . SetValue ( "FSCompatFixInstalled" , "Yes" ) ;
554-
555- btnMapEditorCompatibilityFix . Text = "Disable" . L10N ( "Client:DTAConfig:TSDisable" ) ;
556-
557- Logger . Log ( "FinalSun Compatibility Fix succesfully installed." ) ;
558- XNAMessageBox . Show ( WindowManager , "Compatibility Fix Installed" . L10N ( "Client:DTAConfig:TSFinalSunCompatibilityFixInstalledTitle" ) ,
559- "The FinalSun Compatibility Fix has been succesfully installed." . L10N ( "Client:DTAConfig:TSFinalSunCompatibilityFixInstalledText" ) ) ;
560-
561- FinalSunCompatFixInstalled = true ;
562- }
563- catch ( Exception ex )
564- {
565- Logger . Log ( "Installing FinalSun Compatibility Fix failed. Error message: " + ex . ToString ( ) ) ;
566- XNAMessageBox . Show ( WindowManager , "Installing Compatibility Fix Failed" . L10N ( "Client:DTAConfig:TSFinalSunCompatibilityFixInstalledFailedTitle" ) ,
567- "Installing FinalSun Compatibility Fix failed. Error message:" . L10N ( "Client:DTAConfig:TSFinalSunCompatibilityFixInstalledFailedText" ) + " " + ex . Message ) ;
568- }
569522 }
570523
571524 private void ChkBorderlessMenu_CheckedChanged ( object sender , EventArgs e )
@@ -705,46 +658,6 @@ public override void Load()
705658 if ( ClientConfiguration . Instance . ClientGameType == ClientType . TS )
706659 {
707660 chkBackBufferInVRAM . Checked = ! UserINISettings . Instance . BackBufferInVRAM ;
708-
709- if ( ! RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
710- return ;
711-
712- RegistryKey regKey = Registry . CurrentUser . OpenSubKey ( "SOFTWARE\\ Tiberian Sun Client" ) ;
713-
714- if ( regKey == null )
715- return ;
716-
717- object tsCompatFixValue = regKey . GetValue ( "TSCompatFixInstalled" , "No" ) ;
718- string tsCompatFixString = ( string ) tsCompatFixValue ;
719-
720- if ( tsCompatFixString == "Yes" )
721- {
722- GameCompatFixInstalled = true ;
723- btnGameCompatibilityFix . Text = "Disable" . L10N ( "Client:DTAConfig:TSDisable" ) ;
724- }
725-
726- object fsCompatFixValue = regKey . GetValue ( "FSCompatFixInstalled" , "No" ) ;
727- string fsCompatFixString = ( string ) fsCompatFixValue ;
728-
729- if ( fsCompatFixString == "Yes" )
730- {
731- FinalSunCompatFixInstalled = true ;
732- btnMapEditorCompatibilityFix . Text = "Disable" . L10N ( "Client:DTAConfig:TSDisable" ) ;
733- }
734-
735- object tsCompatFixDeclinedValue = regKey . GetValue ( "TSCompatFixDeclined" , "No" ) ;
736-
737- if ( ( ( string ) tsCompatFixDeclinedValue ) == "Yes" )
738- {
739- GameCompatFixDeclined = true ;
740- }
741-
742- //object fsCompatFixDeclinedValue = regKey.GetValue("FSCompatFixDeclined", "No");
743-
744- //if (((string)fsCompatFixDeclinedValue) == "Yes")
745- //{
746- // FinalSunCompatFixDeclined = true;
747- //}
748661 }
749662 else
750663 {
0 commit comments