Game Development Community

RC3: Options dialog and resolution bugs + how to fix

by Kirakorn Chimkool · in Torque Game Builder · 06/20/2006 (2:54 am) · 3 replies

Since the source code has been changed to proper setup the values of "$pref::Video::resolution" and "$pref::Video::windowedRes" but the "options.cs" script don't updated yet. It cause some bugs for the options dialog.

Bug #1:
In windowed mode: If the script prefs.cs does not exist (ie. run TGB in the first time) or the value of "$pref::Video::resolution" doest not set, When you open option dialog and cancel it then re-open the dialog again. The resolution list will reset to the lowest resolution.

How this happen:
The script always use "$pref::Video::resolution" that does not set if you did not go to fullscreen mode.

How to fix:
Open file common\gameScripts\options.cs line 289

change
function revertAVOptionChanges()
{
   %selId = ResolutionMenu.findText(getWords($pref::Video::resolution, 0, 1));
   if (%selId == -1)
      %selId = 0;
      
   ResolutionMenu.setSelected(%selId);
   
   FullscreenToggle.setValue($pref::Video::fullScreen);

to
function revertAVOptionChanges()
{
   FullscreenToggle.setValue($pref::Video::fullScreen);
   
   if (FullscreenToggle.getValue())
      %selId = ResolutionMenu.findText(getWords($pref::Video::resolution, 0, 1));
   else
      %selId = ResolutionMenu.findText(getWords($pref::Video::windowedRes, 0, 1));
   
   if (%selId == -1)
      %selId = 0;
      
   ResolutionMenu.setSelected(%selId);

Bug #2:
- Start TGB, open option dialog then set resolution to 800x600 fullscreen and apply setting.
- Open option dialog again and set resolution to 640x480 windowed mode and apply setting.
- Quit TGB, If you open the prefs.cs you will see the value of "$pref::Video::resolution" and "$pref::Video::windowedRes" is difference.
- Force TGB to start in fullscreen mode (ie. -fullscreen or edit the prefs.cs) then open an option dialog. The resolution list will be set to windowed mode resolution. That's wrong.

How this happen:
The script always use "$pref::Video::windowedRes" and don't care about TGB is in windowed mode or not.

How to fix:
Open file common\gameScripts\options.cs line 51

change
// Attempt to keep the same res and bpp settings.
   if (ResolutionMenu.size() > 0)
      %prevRes = ResolutionMenu.getText();
   else
      %prevRes = getWords($pref::Video::windowedRes, 0, 1);

to
// Attempt to keep the same res and bpp settings.
   if (ResolutionMenu.size() > 0)
      %prevRes = ResolutionMenu.getText();
   else
   {
      if (FullscreenToggle.getValue())
         %prevRes = getWords($pref::Video::resolution, 0, 1);
      else
         %prevRes = getWords($pref::Video::windowedRes, 0, 1);
   }

line 62

change
%prevBPP = getWord($pref::Video::windowedRes, 2);

to
%prevBPP = getWord($pref::Video::resolution, 2);

Bug #3: Typo

Open file common\gameScripts\options.cs line 195

change
ResolutionMenu.setSelected( ResolutionMenu.size() );

to
ResolutionMenu.setSelected( ResolutionMenu.size() - 1 );

#1
06/20/2006 (7:07 am)
Thank you, Tanapat. While some of your suggestions don't apply to a custom options script I'm working on, you helped to locate a bug (in my script) that I just couldn't seem to figure out. It's tough getting resolution and windowRes to work right under all circumstances.
#2
06/20/2006 (11:29 am)
Thanks for not only identifying the bugs but actually taking the time to see what was causing them and going out of your way to get them fixed.
#3
07/14/2006 (11:21 am)
Tanapat,

This has been fixed and will be in the 1.1.1 release. Thanks for the report and FIX!

Cheers,
-Justin